Skip to content

Commit

Permalink
Merge pull request #215 from axonivy-market/develop
Browse files Browse the repository at this point in the history
MARP-1301: Create new release 1.4.0
  • Loading branch information
nqhoan-axonivy authored Oct 25, 2024
2 parents 5dd8e35 + 2790ca9 commit 6e97614
Show file tree
Hide file tree
Showing 102 changed files with 1,490 additions and 1,514 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private List<String> syncProductData() {
var watch = new StopWatch();
log.warn("Synchronizing Market repo: Started synchronizing data for Axon Ivy Market repo");
watch.start();
List<String> syncedProductIds = productService.syncLatestDataFromMarketRepo();
List<String> syncedProductIds = productService.syncLatestDataFromMarketRepo(false);
if (ObjectUtils.isEmpty(syncedProductIds)) {
log.warn("Synchronizing Market repo: Nothing updated");
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public ProductDetailModel toModel(Product product, String version, String reques
}

private ProductDetailModel createModel(Product product, String version, String requestPath) {
ResponseEntity<ProductDetailModel> selfLinkWithTag;
ResponseEntity<ProductDetailModel> selfLinkWithVersion;
ProductDetailModel model = instantiateModel(product);
productModelAssembler.createResource(model, product);
String productId = Optional.of(product).map(Product::getId).orElse(StringUtils.EMPTY);
Expand All @@ -53,15 +53,15 @@ private ProductDetailModel createModel(Product product, String version, String r
model.setMetaProductJsonUrl(link.getHref());
}

selfLinkWithTag = switch (requestPath) {
selfLinkWithVersion = switch (requestPath) {
case RequestMappingConstants.BEST_MATCH_BY_ID_AND_VERSION ->
methodOn(ProductDetailsController.class).findBestMatchProductDetailsByVersion(productId, version);
case RequestMappingConstants.BY_ID_AND_VERSION ->
methodOn(ProductDetailsController.class).findProductDetailsByVersion(productId, version);
default -> methodOn(ProductDetailsController.class).findProductDetails(productId, false);
};

model.add(linkTo(selfLinkWithTag).withSelfRel());
model.add(linkTo(selfLinkWithVersion).withSelfRel());
createDetailResource(model, product);
return model;
}
Expand Down Expand Up @@ -89,6 +89,6 @@ private void createDetailResource(ProductDetailModel model, Product product) {
linkTo(methodOn(ImageController.class).findImageById(product.getVendorImageDarkMode())).withSelfRel();
model.setVendorImageDarkMode(vendorDarkModeLink.getHref());
}
model.setMavenDropins(product.isMavenDropins());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.axonivy.market.constants.CommonConstants;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.kohsuke.github.GHTag;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -24,28 +21,6 @@ public class MavenVersionComparator {
private MavenVersionComparator() {
}

public static GHTag findHighestTag(List<GHTag> ghTags) {
if (CollectionUtils.isEmpty(ghTags)) {
return null;
}
String highestVersion = findHighestMavenVersion(ghTags.stream().map(GHTag::getName).toList());
return ghTags.stream().filter(tag -> tag.getName().equals(highestVersion)).findAny().orElse(null);
}

public static String findHighestMavenVersion(List<String> versions) {
if (CollectionUtils.isEmpty(versions)) {
return null;
}

String highestVersion = versions.get(0);
for (var version : versions) {
if (compare(version, highestVersion) > EQUAL) {
highestVersion = version;
}
}
return highestVersion;
}

public static int compare(String version, String otherVersion) {
version = stripLeadingChars(version);
otherVersion = stripLeadingChars(otherVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ public class GitHubConstants {
public static final String GITHUB_PROVIDER_NAME = "GitHub";
public static final String GITHUB_GET_ACCESS_TOKEN_URL = "https://github.com/login/oauth/access_token";
public static final String README_FILE_LOCALE_REGEX = "_(..)";
public static final String STANDARD_TAG_PREFIX = "v";
public static final String COMMON_IMAGES_FOLDER_NAME = "images";
public static final String MS_GRAPH_PRODUCT_DIRECTORY = "msgraph-connector-product";
public static final String MG_GRAPH_IMAGES_FOR_SETUP_FILE = "doc";

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public static class Json {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.axonivy.market.constants;

import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MavenConstants {
public static final String SNAPSHOT_VERSION = "SNAPSHOT";
public static final String SNAPSHOT_RELEASE_POSTFIX = "-" + SNAPSHOT_VERSION;
Expand All @@ -20,8 +24,4 @@ public class MavenConstants {
public static final String SNAPSHOT_LAST_UPDATED_DATE_TIME_FORMAT = "yyyyMMdd.HHmmss";
public static final String VALUE_TAG = "value";
public static final String DEFAULT_PRODUCT_FOLDER_TYPE = "zip";


private MavenConstants() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ public class MongoDBConstants {
public static final String SYNCHRONIZED_INSTALLATION_COUNT = "SynchronizedInstallationCount";
public static final String PRODUCT_ID = "productId";
public static final String DESIGNER_VERSION = "designerVersion";
public static final String TAG = "tag";
public static final String PROJECT_KEY = "$project";
public static final String VERSION = "version";
public static final String RELEASED_VERSIONS = "releasedVersions";
public static final String ARTIFACTS = "artifacts";
public static final String MAVEN_VERSIONS = "mavenVersions";
public static final String ARTIFACTS_DOC = "artifacts.doc";
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReadmeConstants {
public static final String IMAGES = "images";
public static final String README_FILE = "README.md";
public static final String README_FILE_NAME = "README";
public static final String DEMO_PART = "## Demo";
public static final String SETUP_PART = "## Setup";
public static final String SETUP_FILE = "setup.md";
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ public class RequestParamConstants {
public static final String ARTIFACT = "artifact";
public static final String MARKET_ITEM_PATH = "marketItemPath";
public static final String OVERRIDE_MARKET_ITEM_PATH = "overrideMarketItemPath";

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.List;

import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
Expand All @@ -44,6 +41,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static com.axonivy.market.constants.RequestMappingConstants.*;
import static com.axonivy.market.constants.RequestParamConstants.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;
Expand Down Expand Up @@ -100,13 +99,10 @@ public ResponseEntity<Message> syncProducts(@RequestHeader(value = AUTHORIZATION
String token = AuthorizationUtils.getBearerToken(authorizationHeader);
gitHubService.validateUserInOrganizationAndTeam(token, GitHubConstants.AXONIVY_MARKET_ORGANIZATION_NAME,
GitHubConstants.AXONIVY_MARKET_TEAM_NAME);
if (Boolean.TRUE.equals(resetSync)) {
productService.clearAllProducts();
}

var stopWatch = new StopWatch();
stopWatch.start();
List<String> syncedProductIds = productService.syncLatestDataFromMarketRepo();
List<String> syncedProductIds = productService.syncLatestDataFromMarketRepo(resetSync);
var message = new Message();
message.setHelpCode(ErrorCode.SUCCESSFUL.getCode());
message.setHelpText(ErrorCode.SUCCESSFUL.getHelpText());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public ResponseEntity<List<MavenArtifactVersionModel>> findProductVersionsById(
"Ivy designer")
public ResponseEntity<Map<String, Object>> findProductJsonContent(@PathVariable(ID) String productId,
@PathVariable(VERSION) String version) {
Map<String, Object> productJsonContent = versionService.getProductJsonContentByIdAndTag(productId, version);
Map<String, Object> productJsonContent = versionService.getProductJsonContentByIdAndVersion(productId, version);
return new ResponseEntity<>(productJsonContent, HttpStatus.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class Product implements Serializable {
private Date updatedAt;
@Transient
private String bestMatchVersion;
@Transient
private boolean isMavenDropins;

@Override
public int hashCode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public class ProductJsonContent {
@JsonIgnore
private String id;
private String version;
/**
* @deprecated
*/
@Deprecated(forRemoval = true, since = "1.5.0")
private String relatedTag;
private String productId;
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,20 @@ public class ProductModuleContent implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "product Id (from meta.json)", example = "portal")
private String productId;
/**
* @deprecated
*/
@Deprecated(forRemoval = true, since = "1.5.0")
@Schema(description = "Target release tag", example = "v10.0.25")
private String tag;
/**
* @deprecated
*/
@Deprecated(forRemoval = true, since = "1.5.0")
@Schema(description = "Versions in maven", example = "10.0.25-SNAPSHOT")
private Set<String> mavenVersions;
@Schema(description = "Maven version", example = "10.0.25")
private String version;
@Schema(description = "Product detail description content ",
example = "{ \"de\": \"E-Sign-Konnektor\", \"en\": \"E-sign connector\" }")
private Map<String, String> description;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static Product mappingByMetaJSONFile(Product product, GHContent ghContent
extractSourceUrl(product, meta);
List<Artifact> artifacts = CollectionUtils.isEmpty(
meta.getMavenArtifacts()) ? new ArrayList<>() : meta.getMavenArtifacts();
artifacts.stream().forEach(
artifacts.forEach(
artifact -> artifact.setInvalidArtifact(!artifact.getArtifactId().contains(meta.getId())));
product.setArtifacts(artifacts);
product.setReleasedVersions(new ArrayList<>());
Expand All @@ -86,8 +86,6 @@ public static Product mappingByMetaJSONFile(Product product, GHContent ghContent
public static void transferComputedPersistedDataToProduct(Product persisted, Product product) {
product.setMarketDirectory(persisted.getMarketDirectory());
product.setCustomOrder(persisted.getCustomOrder());
product.setNewestReleaseVersion(persisted.getNewestReleaseVersion());
product.setReleasedVersions(persisted.getReleasedVersions());
product.setInstallationCount(persisted.getInstallationCount());
product.setSynchronizedInstallationCount(persisted.getSynchronizedInstallationCount());
}
Expand Down Expand Up @@ -127,10 +125,9 @@ private static Meta jsonDecode(GHContent ghContent) throws IOException {
}

public static void mappingIdForProductModuleContent(ProductModuleContent content) {
if (StringUtils.isNotBlank(content.getProductId())) {
String version = StringUtils.isNotBlank(
content.getTag()) ? content.getTag() : content.getMavenVersions().stream().findAny().orElse(null);
content.setId(String.format(CommonConstants.ID_WITH_NUMBER_PATTERN, content.getProductId(), version));
if (StringUtils.isNotBlank(content.getProductId()) && StringUtils.isNotBlank(content.getVersion())) {
content.setId(
String.format(CommonConstants.ID_WITH_NUMBER_PATTERN, content.getProductId(), content.getVersion()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,13 @@
import com.axonivy.market.entity.Product;
import com.axonivy.market.entity.ProductModuleContent;
import org.kohsuke.github.GHContent;
import org.kohsuke.github.GHRepository;
import org.kohsuke.github.GHTag;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public interface GHAxonIvyProductRepoService {

GHContent getContentFromGHRepoAndTag(String repoName, String filePath, String tagVersion);

List<GHTag> getAllTagsFromRepoName(String repoName) throws IOException;

ProductModuleContent getReadmeAndProductContentsFromTag(Product product, GHRepository ghRepository, String tag);

void extractReadMeFileFromContents(Product product, List<GHContent> contents,
ProductModuleContent productModuleContent);

void updateSetupPartForProductModuleContent(Product product,
Map<String, Map<String, String>> moduleContents, String tag) throws IOException;
}
Loading

0 comments on commit 6e97614

Please sign in to comment.