Skip to content

Commit

Permalink
feat: Increment portlet instance and page template import versions - …
Browse files Browse the repository at this point in the history
…MEED-7108 - Meeds-io/meeds#2229 (#144)

This change will increment version of page templates and portlet
instances in order to force reimport from sources the system entities in
order to import newly introduced background images.
  • Loading branch information
boubaker authored Jun 25, 2024
1 parent 5cdebcc commit 45d5a3e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ public class PageTemplateImportService {

private static final String PAGE_TEMPLATE_VERSION = "version";

private static final long PAGE_TEMPLATE_IMPORT_VERSION = 1;

private static final Log LOG = ExoLogger.getLogger(PageTemplateImportService.class);

private static final Random RANDOM = new Random();
Expand All @@ -106,6 +104,9 @@ public class PageTemplateImportService {
@Value("${meeds.pages.import.override:false}")
private boolean forceReimportTemplates;

@Value("${meeds.pages.import.version:2}")
private long pageTemplateImportVersion;

@PostConstruct
public void init() {
CompletableFuture.runAsync(this::importPageTemplates);
Expand All @@ -115,7 +116,7 @@ public void init() {
public void importPageTemplates() {
LOG.info("Importing Page Templates");
if (!forceReimportTemplates
&& getSettingValue(PAGE_TEMPLATE_VERSION) != PAGE_TEMPLATE_IMPORT_VERSION) {
&& getSettingValue(PAGE_TEMPLATE_VERSION) != pageTemplateImportVersion) {
forceReimportTemplates = true;
}

Expand All @@ -142,7 +143,7 @@ && getSettingValue(PAGE_TEMPLATE_VERSION) != PAGE_TEMPLATE_IMPORT_VERSION) {
layoutTranslationService.postImport(PageTemplateTranslationPlugin.OBJECT_TYPE);
LOG.info("Processing Post Page Templates import finished");

setSettingValue(PAGE_TEMPLATE_VERSION, PAGE_TEMPLATE_IMPORT_VERSION);
setSettingValue(PAGE_TEMPLATE_VERSION, pageTemplateImportVersion);
} catch (Exception e) {
LOG.warn("An error occurred while importing page templates", e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ public class PortletInstanceImportService {

private static final String PORTLET_INSTANCE_VERSION = "version";

private static final long PORTLET_INSTANCE_IMPORT_VERSION = 1;

private static final Log LOG =
ExoLogger.getLogger(PortletInstanceImportService.class);

Expand Down Expand Up @@ -116,6 +114,9 @@ public class PortletInstanceImportService {
@Value("${meeds.portlets.import.override:false}")
private boolean forceReimport;

@Value("${meeds.portlets.import.version:2}")
private long portletInstanceImportVersion;

@PostConstruct
public void init() {
CompletableFuture.runAsync(this::importPortletInstances);
Expand All @@ -125,7 +126,7 @@ public void init() {
public void importPortletInstances() {
LOG.info("Importing Portlet instances");
if (!forceReimport
&& getSettingValue(PORTLET_INSTANCE_VERSION) != PORTLET_INSTANCE_IMPORT_VERSION) {
&& getSettingValue(PORTLET_INSTANCE_VERSION) != portletInstanceImportVersion) {
forceReimport = true;
}

Expand All @@ -148,7 +149,7 @@ && getSettingValue(PORTLET_INSTANCE_VERSION) != PORTLET_INSTANCE_IMPORT_VERSION)
layoutTranslationService.postImport(PortletInstanceTranslationPlugin.OBJECT_TYPE);
LOG.info("Processing Post Portlet instances import finished");

setSettingValue(PORTLET_INSTANCE_VERSION, PORTLET_INSTANCE_IMPORT_VERSION);
setSettingValue(PORTLET_INSTANCE_VERSION, portletInstanceImportVersion);
} catch (Exception e) {
LOG.warn("An error occurred while importing portlet instances", e);
} finally {
Expand Down

0 comments on commit 45d5a3e

Please sign in to comment.