Skip to content

Commit

Permalink
fix: Update NewsArticlesUpgrade - EXO-74263_EXO-74265_EXO-74266 (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
azayati authored Sep 25, 2024
1 parent 1824e46 commit 8d304a2
Showing 1 changed file with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public class NewsArticlesUpgrade extends UpgradeProductPlugin {
private IndexingService indexingService;

private IdentityManager identityManager;

private SettingService settingService;

private int migratedNewsArticlesCount = 0;
Expand All @@ -124,7 +124,7 @@ public class NewsArticlesUpgrade extends UpgradeProductPlugin {
private static final String PLUGIN_NAME = "NewsArticlesUpgradePlugin";

private static final String PLUGIN_EXECUTED_KEY = "articlesUpgradeExecuted";

private boolean upgradeFailed = false;

public NewsArticlesUpgrade(InitParams initParams,
Expand Down Expand Up @@ -238,7 +238,9 @@ public void afterUpgrade() {
}

@Override
public boolean shouldProceedToUpgrade(String newVersion, String previousGroupVersion, UpgradePluginExecutionContext upgradePluginExecutionContext) {
public boolean shouldProceedToUpgrade(String newVersion,
String previousGroupVersion,
UpgradePluginExecutionContext upgradePluginExecutionContext) {
SettingValue<?> settingValue = settingService.get(Context.GLOBAL.id(PLUGIN_NAME),
Scope.APPLICATION.id(PLUGIN_NAME),
PLUGIN_EXECUTED_KEY);
Expand Down Expand Up @@ -320,10 +322,11 @@ public int manageNewsArticles(List<Node> newsArticlesNodes, Session session) thr
properties = publishedNews.getProperties();
properties.setNoteId(Long.parseLong(article.getId()));
if (publishedNews.getAuthor() != null) {
properties = noteService.saveNoteMetadata(properties,
article.getLang(),
Long.valueOf(identityManager.getOrCreateUserIdentity(publishedNews.getAuthor())
.getId()));
properties =
noteService.saveNoteMetadata(properties,
article.getLang(),
Long.valueOf(identityManager.getOrCreateUserIdentity(publishedNews.getAuthor())
.getId()));
}
PageVersion pageVersion = noteService.getPublishedVersionByPageIdAndLang(Long.parseLong(article.getId()), null);
setArticleIllustration(pageVersion.getParent(), article.getSpaceId(), publishedNode, "notePage");
Expand All @@ -341,7 +344,8 @@ public int manageNewsArticles(List<Node> newsArticlesNodes, Session session) thr
News draftForExistingArticle = newsService.createDraftForExistingPage(news,
news.getAuthor(),
publishedPage,
news.getCreationDate().getTime());
news.getCreationDate().getTime(),
space);
DraftPage draftPage = noteService.getDraftNoteById(draftForExistingArticle.getId(),
draftForExistingArticle.getAuthor());
setArticleIllustration(draftPage, draftForExistingArticle.getSpaceId(), newsArticleNode, "noteDraftPage");
Expand Down Expand Up @@ -441,10 +445,7 @@ private Long saveArticleIllustration(InputStream articleIllustrationFileInputStr
}
}

private void setArticleIllustration(Page article,
String spaceId,
Node newsNode,
String articleObjectType) throws Exception {
private void setArticleIllustration(Page article, String spaceId, Node newsNode, String articleObjectType) throws Exception {
if (newsNode.hasNode("illustration")) {
Node illustrationNode = newsNode.getNode("illustration");
Node illustrationContentNode = illustrationNode.getNode("jcr:content");
Expand Down

0 comments on commit 8d304a2

Please sign in to comment.