Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into feature/MARP-558-M…
Browse files Browse the repository at this point in the history
…ultilingualism-for-Detail-Page-Description

# Conflicts:
#	marketplace-service/src/main/java/com/axonivy/market/assembler/ProductDetailModelAssembler.java
#	marketplace-service/src/main/java/com/axonivy/market/assembler/ProductModelAssembler.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/CommonConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/GitHubConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/MavenConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/MetaConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/ProductJsonConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/constants/ReadmeConstants.java
#	marketplace-service/src/main/java/com/axonivy/market/controller/ProductController.java
#	marketplace-service/src/main/java/com/axonivy/market/controller/ProductDetailsController.java
#	marketplace-service/src/main/java/com/axonivy/market/entity/Product.java
#	marketplace-service/src/main/java/com/axonivy/market/entity/ProductModuleContent.java
#	marketplace-service/src/main/java/com/axonivy/market/factory/ProductFactory.java
#	marketplace-service/src/main/java/com/axonivy/market/github/model/Meta.java
#	marketplace-service/src/main/java/com/axonivy/market/github/service/GHAxonIvyProductRepoService.java
#	marketplace-service/src/main/java/com/axonivy/market/github/service/impl/GHAxonIvyProductRepoServiceImpl.java
#	marketplace-service/src/main/java/com/axonivy/market/github/util/GitHubUtils.java
#	marketplace-service/src/main/java/com/axonivy/market/model/MultilingualismValue.java
#	marketplace-service/src/main/java/com/axonivy/market/model/ProductDetailModel.java
#	marketplace-service/src/main/java/com/axonivy/market/model/ProductModel.java
#	marketplace-service/src/main/java/com/axonivy/market/repository/ProductRepository.java
#	marketplace-service/src/main/java/com/axonivy/market/service/ProductService.java
#	marketplace-service/src/main/java/com/axonivy/market/service/impl/ProductServiceImpl.java
#	marketplace-service/src/main/java/com/axonivy/market/service/impl/VersionServiceImpl.java
#	marketplace-service/src/main/java/com/axonivy/market/util/XmlReaderUtils.java
#	marketplace-service/src/test/java/com/axonivy/market/controller/ProductControllerTest.java
#	marketplace-service/src/test/java/com/axonivy/market/controller/ProductDetailsControllerTest.java
#	marketplace-service/src/test/java/com/axonivy/market/factory/ProductFactoryTest.java
#	marketplace-service/src/test/java/com/axonivy/market/service/GHAxonIvyProductRepoServiceImplTest.java
#	marketplace-service/src/test/java/com/axonivy/market/service/ProductServiceImplTest.java
#	marketplace-service/src/test/java/com/axonivy/market/service/VersionServiceImplTest.java
#	marketplace-service/src/test/java/com/axonivy/market/util/GitHubUtilsTest.java
  • Loading branch information
tutn-axonivy committed Jul 15, 2024
2 parents 04fc064 + 5608003 commit a1e0a75
Show file tree
Hide file tree
Showing 92 changed files with 4,111 additions and 2,839 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/service-dev-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ jobs:
- name: Restart Tomcat server
run: |
sudo systemctl stop tomcat
sudo systemctl start tomcat
sudo systemctl start tomcat
10 changes: 10 additions & 0 deletions marketplace-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@
<artifactId>github-api</artifactId>
<version>1.321</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.axonivy.market;

import com.axonivy.market.service.ProductService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.time.StopWatch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -9,10 +11,6 @@
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import com.axonivy.market.service.ProductService;

import lombok.extern.log4j.Log4j2;

@Log4j2
@EnableAsync
@EnableScheduling
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.axonivy.market.assembler;

import com.axonivy.market.controller.FeedbackController;
import com.axonivy.market.entity.Feedback;
import com.axonivy.market.entity.User;
import com.axonivy.market.exceptions.model.NotFoundException;
import com.axonivy.market.model.FeedbackModel;
import com.axonivy.market.service.UserService;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;

import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;

@Log4j2
@Component
public class FeedbackModelAssembler extends RepresentationModelAssemblerSupport<Feedback, FeedbackModel> {

private final UserService userService;

public FeedbackModelAssembler(UserService userService) {
super(Feedback.class, FeedbackModel.class);
this.userService = userService;
}

@Override
public FeedbackModel toModel(Feedback feedback) {
FeedbackModel resource = new FeedbackModel();
resource.add(linkTo(methodOn(FeedbackController.class).findFeedback(feedback.getId()))
.withSelfRel());
return createResource(resource, feedback);
}

private FeedbackModel createResource(FeedbackModel model, Feedback feedback) {
User user;
try {
user = userService.findUser(feedback.getUserId());
}
catch (NotFoundException e) {
log.warn(e.getMessage());
user = new User();
}
model.setId(feedback.getId());
model.setUsername(StringUtils.isBlank(user.getName()) ? user.getUsername() : user.getName());
model.setUserAvatarUrl(user.getAvatarUrl());
model.setUserProvider(user.getProvider());
model.setProductId(feedback.getProductId());
model.setContent(feedback.getContent());
model.setRating(feedback.getRating());
model.setCreatedAt(feedback.getCreatedAt());
model.setUpdatedAt(feedback.getUpdatedAt());
return model;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,68 @@

import com.axonivy.market.controller.ProductDetailsController;
import com.axonivy.market.entity.Product;
import com.axonivy.market.entity.ProductModuleContent;
import com.axonivy.market.model.ProductDetailModel;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ProductDetailModelAssembler extends RepresentationModelAssemblerSupport<Product, ProductDetailModel> {

private final ProductModelAssembler productModelAssembler;

public ProductDetailModelAssembler(ProductModelAssembler productModelAssembler) {
super(ProductDetailsController.class, ProductDetailModel.class);
this.productModelAssembler = productModelAssembler;
}

@Override
public ProductDetailModel toModel(Product product) {
ProductDetailModel model = instantiateModel(product);
productModelAssembler.createResource(model, product);
model.add(
linkTo(methodOn(ProductDetailsController.class).findProductDetails(product.getId(), product.getType()))
.withSelfRel());
createDetailResource(model, product);
return model;
}

private void createDetailResource(ProductDetailModel model, Product product) {
model.setVendor(product.getVendor());
model.setVendorUrl(product.getVendorUrl());
model.setNewestReleaseVersion(product.getNewestReleaseVersion());
model.setPlatformReview(product.getPlatformReview());
model.setSourceUrl(product.getSourceUrl());
model.setStatusBadgeUrl(product.getStatusBadgeUrl());
model.setLanguage(product.getLanguage());
model.setIndustry(product.getIndustry());
model.setCompatibility(product.getCompatibility());
model.setContactUs(product.getContactUs());
model.setCost(product.getCost());
model.setProductModuleContents(product.getProductModuleContents());
}
}
private final ProductModelAssembler productModelAssembler;

public ProductDetailModelAssembler(ProductModelAssembler productModelAssembler) {
super(ProductDetailsController.class, ProductDetailModel.class);
this.productModelAssembler = productModelAssembler;
}

@Override
public ProductDetailModel toModel(Product product) {
return createModel(product, null);
}

public ProductDetailModel toModel(Product product, String tag) {
return createModel(product, tag);
}

private ProductDetailModel createModel(Product product, String tag) {
ResponseEntity<ProductDetailModel> selfLinkWithTag;
ProductDetailModel model = instantiateModel(product);
productModelAssembler.createResource(model, product);
if (StringUtils.isBlank(tag)) {
selfLinkWithTag = methodOn(ProductDetailsController.class).findProductDetails(product.getId());
} else {
selfLinkWithTag = methodOn(ProductDetailsController.class).findProductDetailsByVersion(product.getId(), tag);
}
model.add(linkTo(selfLinkWithTag).withSelfRel());
createDetailResource(model, product, tag);
return model;
}

private void createDetailResource(ProductDetailModel model, Product product, String tag) {
model.setVendor(product.getVendor());
model.setNewestReleaseVersion(product.getNewestReleaseVersion());
model.setPlatformReview(product.getPlatformReview());
model.setSourceUrl(product.getSourceUrl());
model.setStatusBadgeUrl(product.getStatusBadgeUrl());
model.setLanguage(product.getLanguage());
model.setIndustry(product.getIndustry());
model.setCompatibility(product.getCompatibility());
model.setContactUs(product.getContactUs());
model.setCost(product.getCost());

if (StringUtils.isBlank(tag) && StringUtils.isNotBlank(product.getNewestReleaseVersion())) {
tag = product.getNewestReleaseVersion();
}
ProductModuleContent content = getProductModuleContentByTag(product.getProductModuleContents(), tag);
model.setProductModuleContent(content);
}

private ProductModuleContent getProductModuleContentByTag(List<ProductModuleContent> contents, String tag) {
return contents.stream().filter(content -> StringUtils.equals(content.getTag(), tag)).findAny().orElse(null);
}
}
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
package com.axonivy.market.assembler;

import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;

import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;

import com.axonivy.market.controller.ProductDetailsController;
import com.axonivy.market.entity.Product;
import com.axonivy.market.model.ProductModel;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
import org.springframework.stereotype.Component;

import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn;

@Component
public class ProductModelAssembler extends RepresentationModelAssemblerSupport<Product, ProductModel> {

public ProductModelAssembler() {
super(ProductDetailsController.class, ProductModel.class);
}

@Override
public ProductModel toModel(Product product) {
ProductModel resource = new ProductModel();
resource.add(linkTo(methodOn(ProductDetailsController.class).findProductDetails(product.getId(), product.getType()))
.withSelfRel());
return createResource(resource, product);
}

public ProductModel createResource(ProductModel model, Product product) {
model.setId(product.getId());
model.setNames(product.getNames());
model.setShortDescriptions(product.getShortDescriptions());
model.setType(product.getType());
model.setTags(product.getTags());
model.setLogoUrl(product.getLogoUrl());
return model;
}

}
public ProductModelAssembler() {
super(ProductDetailsController.class, ProductModel.class);
}

@Override
public ProductModel toModel(Product product) {
ProductModel resource = new ProductModel();
resource.add(linkTo(methodOn(ProductDetailsController.class).findProductDetails(product.getId())).withSelfRel());
return createResource(resource, product);
}

public ProductModel createResource(ProductModel model, Product product) {
model.setId(product.getId());
model.setNames(product.getNames());
model.setShortDescriptions(product.getShortDescriptions());
model.setType(product.getType());
model.setTags(product.getTags());
model.setLogoUrl(product.getLogoUrl());
return model;
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package com.axonivy.market.config;

import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.springdoc.core.customizers.OpenApiCustomizer;
import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.Parameter;
import static com.axonivy.market.constants.CommonConstants.*;
import static com.axonivy.market.constants.CommonConstants.REQUESTED_BY;

@Configuration
public class MarketApiDocumentConfig {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package com.axonivy.market.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import com.axonivy.market.constants.CommonConstants;
import com.axonivy.market.exceptions.model.MissingHeaderException;

import io.swagger.v3.oas.models.PathItem.HttpMethod;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

@Component
public class MarketHeaderInterceptor implements HandlerInterceptor {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.axonivy.market.config;

import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
import org.springframework.data.mongodb.config.EnableMongoAuditing;
import org.springframework.data.mongodb.core.convert.DbRefResolver;
import org.springframework.data.mongodb.core.convert.DefaultDbRefResolver;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;

import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

@Configuration
@EnableMongoRepositories(basePackages = "com.axonivy.market.repository")
@EnableMongoAuditing
public class MongoConfig extends AbstractMongoClientConfiguration {

@Value("${spring.data.mongodb.host}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CommonConstants {
public static final int INITIAL_PAGE = 1;
public static final int INITIAL_PAGE_SIZE = 10;
public static final String REQUESTED_BY = "X-Requested-By";
public static final String LOGO_FILE = "logo.png";
public static final String SLASH = "/";
public static final String DOT_SEPARATOR = ".";
public static final String PLUS = "+";
public static final String DASH_SEPARATOR = "-";
public static final String SPACE_SEPARATOR = " ";
public static final int INITIAL_PAGE = 1;
public static final int INITIAL_PAGE_SIZE = 10;
public static final String REQUESTED_BY = "X-Requested-By";
public static final String LOGO_FILE = "logo.png";
public static final String SLASH = "/";
public static final String DOT_SEPARATOR = ".";
public static final String PLUS = "+";
public static final String DASH_SEPARATOR = "-";
public static final String SPACE_SEPARATOR = " ";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ public class EntityConstants {
public static final String PRODUCT = "Product";
public static final String MAVEN_ARTIFACT_VERSION = "MavenArtifactVersion";
public static final String GH_REPO_META = "GitHubRepoMeta";
public static final String FEEDBACK = "Feedback";
}
Loading

0 comments on commit a1e0a75

Please sign in to comment.