Skip to content

Commit

Permalink
MARP-1202 Release 1.2.0
Browse files Browse the repository at this point in the history
Create release 1.2.0
  • Loading branch information
ndkhanh-axonivy authored Oct 7, 2024
2 parents 313a4bd + 471ebb1 commit d45f12e
Show file tree
Hide file tree
Showing 97 changed files with 2,088 additions and 1,293 deletions.
2 changes: 2 additions & 0 deletions marketplace-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ This command should return the ``OK`` code
* Run ``docker-compose up -d --build`` to start a Marketplace DEV at the local

#### If you already have MongoDB on your local machine with public port `27017`
* Create a docker network to connect ui > service > mongodb by run ``docker network create marketplace-network``

* Navigate to ``marketplace-build/dev``

* Run ``docker-compose up -d --build`` to start a Marketplace DEV at the local
Expand Down
10 changes: 8 additions & 2 deletions marketplace-build/config/mongodb/authen-docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: marketplace-db
name: marketplace

services:
mongodb:
Expand All @@ -14,6 +14,12 @@ services:
volumes:
- mongodata:/data/db
- ./mongod.conf:/etc/mongod.conf
networks:
- marketplace-network

volumes:
mongodata:
mongodata:

networks:
marketplace-network:
external: true
21 changes: 21 additions & 0 deletions marketplace-build/config/nginx/dev/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
user www-data;
worker_processes auto;

events {}

http {
Expand All @@ -24,5 +27,23 @@ http {
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}

# Start: Handle for DOCs
location /market-cache/ {
alias /usr/share/nginx/html/market-cache/;
index index.html;
try_files $uri $uri/ /index.html;
}
# End: Handle for DOCs

# Start: Handle for LIBs
# Workaround for static libs. e.g: https://market.axonivy.com/demos-app/dev/lib/ivy-demos-app.zip
location ~ ^/([^/]+)/([^/]+)/lib/(.*)$ {
alias /usr/share/nginx/html/cache/$1/$2/lib/;
try_files $3 =404;
}
# End: Handle for LIBs

error_page 403 /error-page;
}
}
18 changes: 18 additions & 0 deletions marketplace-build/config/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,23 @@ http {
proxy_cache_bypass $http_upgrade;
proxy_redirect off;
}

# Start: Handle for DOCs
location /market-cache/ {
alias /usr/share/nginx/html/market-cache/;
index index.html;
try_files $uri $uri/ /index.html;
}
# End: Handle for DOCs

# Start: Handle for LIBs
# Workaround for static libs. e.g: https://market.axonivy.com/demos-app/dev/lib/ivy-demos-app.zip
location ~ ^/([^/]+)/([^/]+)/lib/(.*)$ {
alias /usr/share/nginx/html/cache/$1/$2/lib/;
try_files $3 =404;
}
# End: Handle for LIBs

error_page 403 /error-page;
}
}
15 changes: 14 additions & 1 deletion marketplace-build/dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ services:
restart: always
volumes:
- ../../marketplace-build/config/nginx/dev/nginx.conf:/etc/nginx/nginx.conf
- marketcache:/usr/share/nginx/html/market-cache
ports:
- "4200:80"
depends_on:
- service
networks:
- marketplace-network

service:
container_name: marketplace-service
restart: always
volumes:
- /home/axonivy/marketplace/data/market-installations.json:/data/market-installation.json
- /home/axonivy/marketplace/data/market-installations.json:/app/data/market-installation.json
- marketcache:/app/data/market-cache
environment:
- MONGODB_HOST=${SERVICE_MONGODB_HOST}
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
Expand All @@ -42,3 +46,12 @@ services:
- BUILD_VERSION=${BUILD_VERSION}
ports:
- "8080:8080"
networks:
- marketplace-network

volumes:
marketcache:

networks:
marketplace-network:
external: true
5 changes: 4 additions & 1 deletion marketplace-build/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ services:
restart: always
volumes:
- ./config/nginx/nginx.conf:/etc/nginx/nginx.conf
- marketcache:/usr/share/nginx/html/market-cache
ports:
- "4200:80"
depends_on:
Expand All @@ -37,7 +38,8 @@ services:
container_name: marketplace-service
restart: always
volumes:
- /home/axonivy/marketplace/data/market-installations.json:/data/market-installation.json
- /home/axonivy/marketplace/data/market-installations.json:/app/data/market-installation.json
- marketcache:/app/data/market-cache
environment:
- MONGODB_HOST=${SERVICE_MONGODB_HOST}
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
Expand All @@ -62,3 +64,4 @@ services:

volumes:
mongodata:
marketcache:
7 changes: 5 additions & 2 deletions marketplace-build/release/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
image: ghcr.io/axonivy-market/marketplace-ui:${RELEASE_VERSION}
volumes:
- ../config/nginx/nginx.conf:/etc/nginx/nginx.conf
- marketcache:/usr/share/nginx/html/market-cache
restart: always
ports:
- "80:80"
Expand All @@ -29,7 +30,8 @@ services:
expose:
- 8080
volumes:
- /home/axonivy/marketplace/data/market-installations.json:/data/market-installation.json
- /home/axonivy/marketplace/data/market-installations.json:/app/data/market-installation.json
- marketcache:/app/data/market-cache
environment:
- MONGODB_HOST=${SERVICE_MONGODB_HOST}
- MONGODB_DATABASE=${SERVICE_MONGODB_DATABASE}
Expand All @@ -43,4 +45,5 @@ services:
- MARKET_CORS_ALLOWED_ORIGIN=${MARKET_CORS_ALLOWED_ORIGIN}
- MARKET_MONGO_LOG_LEVEL=${MARKET_MONGO_LOG_LEVEL}
volumes:
mongodata:
mongodata:
marketcache:
1 change: 1 addition & 0 deletions marketplace-service/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
data/
unzip/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
Expand Down
1 change: 1 addition & 0 deletions marketplace-service/.gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
data/
unzip/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.axonivy.market;

import com.axonivy.market.service.ExternalDocumentService;
import com.axonivy.market.service.ProductService;
import lombok.AllArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
Expand All @@ -12,14 +14,17 @@
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.List;

@Log4j2
@EnableAsync
@EnableScheduling
@SpringBootApplication
@AllArgsConstructor
public class MarketplaceServiceApplication {

private final ProductService productService;
final ProductService productService;
final ExternalDocumentService externalDocumentService;

public static void main(String[] args) {
SpringApplication.run(MarketplaceServiceApplication.class, args);
Expand All @@ -28,19 +33,36 @@ public static void main(String[] args) {
@Async
@EventListener(ApplicationStartedEvent.class)
public void startInitializeSystem() {
syncProductData();
List<String> productIds = syncProductData();
syncExternalDocumentData(productIds);
}

private void syncProductData() {
private List<String> syncProductData() {
var watch = new StopWatch();
log.warn("Synchronizing Market repo: Started synchronizing data for Axon Ivy Market repo");
watch.start();
if (productService.syncLatestDataFromMarketRepo()) {
log.warn("Synchronizing Market repo: Data is already up to date");
List<String> syncedProductIds = productService.syncLatestDataFromMarketRepo();
if (ObjectUtils.isEmpty(syncedProductIds)) {
log.warn("Synchronizing Market repo: Nothing updated");
} else {
watch.stop();
log.warn("Synchronizing Market repo: Finished synchronizing data for Axon Ivy Market repo in [{}] milliseconds",
watch.getTime());
log.warn("Synchronizing Market repo: Synced products [{}]", syncedProductIds);
}
return syncedProductIds;
}

private void syncExternalDocumentData(List<String> productIds) {
var watch = new StopWatch();
log.warn("Synchronizing External Document: Started synchronizing data for Document");
watch.start();
if (ObjectUtils.isEmpty(productIds)) {
log.warn("Synchronizing External Document: Nothing updated");
}
productIds.forEach(id -> externalDocumentService.syncDocumentForProduct(id, false));
watch.stop();
log.warn("Synchronizing External Document: Finished synchronizing data for Document in [{}] milliseconds",
watch.getTime());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.axonivy.market.entity.Product;
import com.axonivy.market.model.ProductDetailModel;
import com.axonivy.market.util.ImageUtils;
import com.axonivy.market.util.VersionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport;
Expand Down Expand Up @@ -58,7 +57,7 @@ private ProductDetailModel createModel(Product product, String version, String r
methodOn(ProductDetailsController.class).findBestMatchProductDetailsByVersion(productId, version);
case RequestMappingConstants.BY_ID_AND_VERSION ->
methodOn(ProductDetailsController.class).findProductDetailsByVersion(productId, version);
default -> methodOn(ProductDetailsController.class).findProductDetails(productId);
default -> methodOn(ProductDetailsController.class).findProductDetails(productId, false);
};

model.add(linkTo(selfLinkWithTag).withSelfRel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ProductModelAssembler() {
@Override
public ProductModel toModel(Product product) {
ProductModel resource = new ProductModel();
resource.add(linkTo(methodOn(ProductDetailsController.class).findProductDetails(product.getId())).withSelfRel());
resource.add(linkTo(methodOn(ProductDetailsController.class).findProductDetails(product.getId(),false)).withSelfRel());
return createResource(resource, product);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.*;
import org.springframework.data.annotation.Transient;

import java.io.Serial;
Expand All @@ -15,6 +12,7 @@

@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_EMPTY)
Expand All @@ -31,6 +29,7 @@ public class Artifact implements Serializable {
@Transient
private Boolean isProductArtifact;
private List<ArchivedArtifact> archivedArtifacts;
private Boolean doc;
private boolean isInvalidArtifact;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
public class DirectoryConstants {
public static final String DATA_DIR = "data";
public static final String WORK_DIR = "work";

}
public static final String CACHE_DIR = "market-cache";
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public class EntityConstants {
public static final String PRODUCT_MODULE_CONTENT = "ProductModuleContent";
public static final String IMAGE = "Image";
public static final String MAVEN_ARTIFACT_VERSION = "MavenArtifactVersion";
public static final String EXTERNAL_DOCUMENT_META = "ExternalDocumentMeta";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class MavenConstants {
public static final String SNAPSHOT_VERSION = "SNAPSHOT";
public static final String SNAPSHOT_RELEASE_POSTFIX = "-" + SNAPSHOT_VERSION;
public static final String SPRINT_RELEASE_POSTFIX = "-m";
public static final String DEV_RELEASE_POSTFIX = "-dev";
public static final String PRODUCT_ARTIFACT_POSTFIX = "-product";
public static final String DEFAULT_IVY_MAVEN_BASE_URL = "https://maven.axonivy.com";
public static final String ARTIFACT_FILE_NAME_FORMAT = "%s-%s.%s";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.axonivy.market.constants;

public class MongoDBConstants {
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MongoDBConstants {
public static final String ID = "_id";
public static final String PRODUCT_COLLECTION = "Product";
public static final String INSTALLATION_COUNT = "InstallationCount";
Expand All @@ -13,7 +16,5 @@ public class MongoDBConstants {
public static final String RELEASED_VERSIONS = "releasedVersions";
public static final String ARTIFACTS = "artifacts";
public static final String MAVEN_VERSIONS = "mavenVersions";
private MongoDBConstants() {
}

public static final String ARTIFACTS_DOC = "artifacts.doc";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ public class RequestMappingConstants {
public static final String VERSIONS_IN_DESIGNER = "/{id}/designerversions";
public static final String DESIGNER_INSTALLATION_BY_ID = "/installation/{id}/designer";
public static final String CUSTOM_SORT = "custom-sort";
public static final String EXTERNAL_DOCUMENT = API + "/externaldocument";
}
Loading

0 comments on commit d45f12e

Please sign in to comment.