From c29f0e0f9a034564b2ebb34103ae733a6e0d99b2 Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Mon, 5 Sep 2022 09:40:05 +0900 Subject: [PATCH 01/11] Adopt layout to 7.4 --- src/main/resources/META-INF/resources/blogs.jsp | 4 ++-- src/main/resources/META-INF/resources/category.jsp | 4 ++-- src/main/resources/META-INF/resources/company.jsp | 4 ++-- src/main/resources/META-INF/resources/documents.jsp | 5 ++--- src/main/resources/META-INF/resources/mb.jsp | 4 ++-- src/main/resources/META-INF/resources/pages.jsp | 4 ++-- src/main/resources/META-INF/resources/sites.jsp | 4 ++-- src/main/resources/META-INF/resources/users.jsp | 4 ++-- src/main/resources/META-INF/resources/view.jsp | 4 ++-- src/main/resources/META-INF/resources/wcm.jsp | 4 ++-- src/main/resources/META-INF/resources/wiki.jsp | 6 +++--- 11 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/main/resources/META-INF/resources/blogs.jsp b/src/main/resources/META-INF/resources/blogs.jsp index 5b1cae7..e98b508 100644 --- a/src/main/resources/META-INF/resources/blogs.jsp +++ b/src/main/resources/META-INF/resources/blogs.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/category.jsp b/src/main/resources/META-INF/resources/category.jsp index 192431f..270b836 100644 --- a/src/main/resources/META-INF/resources/category.jsp +++ b/src/main/resources/META-INF/resources/category.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/company.jsp b/src/main/resources/META-INF/resources/company.jsp index 34da30e..de54741 100644 --- a/src/main/resources/META-INF/resources/company.jsp +++ b/src/main/resources/META-INF/resources/company.jsp @@ -2,11 +2,11 @@ <%@ page contentType="text/html; charset=UTF-8" %> -
+
diff --git a/src/main/resources/META-INF/resources/documents.jsp b/src/main/resources/META-INF/resources/documents.jsp index 08634d7..f377ca5 100644 --- a/src/main/resources/META-INF/resources/documents.jsp +++ b/src/main/resources/META-INF/resources/documents.jsp @@ -1,12 +1,11 @@ <%@ include file="/init.jsp" %> -
- +
diff --git a/src/main/resources/META-INF/resources/mb.jsp b/src/main/resources/META-INF/resources/mb.jsp index 7e53d2b..9f811dd 100644 --- a/src/main/resources/META-INF/resources/mb.jsp +++ b/src/main/resources/META-INF/resources/mb.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp"%> -
+
diff --git a/src/main/resources/META-INF/resources/pages.jsp b/src/main/resources/META-INF/resources/pages.jsp index fd16aba..dd6c6ea 100644 --- a/src/main/resources/META-INF/resources/pages.jsp +++ b/src/main/resources/META-INF/resources/pages.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/sites.jsp b/src/main/resources/META-INF/resources/sites.jsp index 2cdaa7f..6f7ed9f 100644 --- a/src/main/resources/META-INF/resources/sites.jsp +++ b/src/main/resources/META-INF/resources/sites.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/users.jsp b/src/main/resources/META-INF/resources/users.jsp index aab3975..871e78d 100644 --- a/src/main/resources/META-INF/resources/users.jsp +++ b/src/main/resources/META-INF/resources/users.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/view.jsp b/src/main/resources/META-INF/resources/view.jsp index 45abda1..7d69bc7 100644 --- a/src/main/resources/META-INF/resources/view.jsp +++ b/src/main/resources/META-INF/resources/view.jsp @@ -1,11 +1,11 @@ <%@ include file="/init.jsp" %> -
+
diff --git a/src/main/resources/META-INF/resources/wcm.jsp b/src/main/resources/META-INF/resources/wcm.jsp index a472299..2ab7ff4 100644 --- a/src/main/resources/META-INF/resources/wcm.jsp +++ b/src/main/resources/META-INF/resources/wcm.jsp @@ -13,11 +13,11 @@ ); %> -
+
diff --git a/src/main/resources/META-INF/resources/wiki.jsp b/src/main/resources/META-INF/resources/wiki.jsp index aaf5618..67b6578 100644 --- a/src/main/resources/META-INF/resources/wiki.jsp +++ b/src/main/resources/META-INF/resources/wiki.jsp @@ -11,11 +11,11 @@ %> - -
+ +
From f5cc3d0a259bb12e3b3ac2dd1837104dff0b3690 Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Mon, 29 May 2023 18:09:53 +0900 Subject: [PATCH 02/11] Update backend to U77 --- build.gradle | 5 +- .../company/CompanyDefaultDummyGenerator.java | 11 +- .../EditFileEntryMVCActionCommand.java | 138 +++++------------- .../journal/JournalRandomDummyGenerator.java | 16 +- .../journal/JournalSimpleDummyGenerator.java | 50 ++++--- .../JournalStructureBaseDummyGenerator.java | 2 +- ...ournalStructureTemplateDummyGenerator.java | 20 +-- .../tools/portlet/DummyFactoryPanelApp.java | 11 +- .../support/tools/user/UserDataService.java | 134 ++++++++--------- 9 files changed, 172 insertions(+), 215 deletions(-) diff --git a/build.gradle b/build.gradle index 2f34dd5..f36a843 100644 --- a/build.gradle +++ b/build.gradle @@ -42,8 +42,8 @@ apply plugin: 'com.github.kt3k.coveralls' dependencies { compile 'com.google.errorprone:error_prone_annotations:2.3.1' compile 'commons-digester:commons-digester:2.1' - compile "com.google.guava:guava:27.1-jre" - compile "commons-io:commons-io:2.5" + compile 'com.google.guava:guava:30.0-jre' + compile 'commons-io:commons-io:2.7' compile "commons-validator:commons-validator:1.6" compile "org.apache.commons:commons-lang3:3.9" compile "com.github.mifmif:generex:1.0.2" @@ -64,6 +64,7 @@ dependencies { compile group: "org.apache.felix", name: "org.apache.felix.gogo.runtime", version: "1.1.+" compileOnly group: "com.liferay.portal", name: "release.dxp.api" + compileOnly 'com.liferay:com.liferay.dynamic.data.mapping.api' testCompile 'org.codehaus.groovy:groovy-all:2.5.+' testCompile group: 'cglib', name: 'cglib-nodep', version: 'latest.integration' diff --git a/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java b/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java index 70bdc74..13264e0 100644 --- a/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java @@ -6,6 +6,7 @@ import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.model.Company; import com.liferay.portal.kernel.service.CompanyLocalService; +import com.liferay.portal.util.PortalInstances; import com.liferay.support.tools.common.DummyGenerator; import com.liferay.support.tools.utils.ProgressManager; import javax.portlet.ActionRequest; @@ -59,7 +60,7 @@ protected void exec(ActionRequest request, CompanyContext paramContext) StringBundler mx = new StringBundler(2); mx.append(paramContext.getMx()); - //Add number more then one company + //Add number more than one company if (1 < paramContext.getNumberOfCompanies()) { webId.append(i); virtualHostname.append(i); @@ -72,16 +73,14 @@ protected void exec(ActionRequest request, CompanyContext paramContext) } Company company = _companyLocalService.addCompany( - webId.toString(), + Long.valueOf(webId.toString()), virtualHostname.toString(), mx.toString(), - paramContext.isSystem(), + String.valueOf(paramContext.isSystem()), paramContext.getMaxUsers(), paramContext.isActive()); - _portalInstancesLocalService.initializePortalInstance( - company.getCompanyId(), company.getWebId(), - paramContext.getServletContext()); + PortalInstances.initCompany(company); } catch (Exception e) { //Finish progress diff --git a/src/main/java/com/liferay/support/tools/document/library/EditFileEntryMVCActionCommand.java b/src/main/java/com/liferay/support/tools/document/library/EditFileEntryMVCActionCommand.java index a92767a..d2f3156 100644 --- a/src/main/java/com/liferay/support/tools/document/library/EditFileEntryMVCActionCommand.java +++ b/src/main/java/com/liferay/support/tools/document/library/EditFileEntryMVCActionCommand.java @@ -38,7 +38,11 @@ import com.liferay.portal.kernel.settings.TypedSettings; import com.liferay.portal.kernel.theme.PortletDisplay; import com.liferay.portal.kernel.theme.ThemeDisplay; -import com.liferay.portal.kernel.upload.*; +import com.liferay.portal.kernel.upload.LiferayFileItemException; +import com.liferay.portal.kernel.upload.UploadException; +import com.liferay.portal.kernel.upload.UploadPortletRequest; +import com.liferay.portal.kernel.upload.UploadRequestSizeException; +import com.liferay.portal.kernel.upload.configuration.UploadServletRequestConfigurationProvider; import com.liferay.portal.kernel.util.*; import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.support.tools.constants.LDFPortletKeys; @@ -53,14 +57,7 @@ import java.util.HashSet; import java.util.Set; -@Component( - property = { - "javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY, - "mvc.command.name=/df/document/edit_file_entry", - "mvc.command.name=/df/document/upload_multiple_file_entries" - }, - service = MVCActionCommand.class -) +@Component(property = {"javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY, "mvc.command.name=/df/document/edit_file_entry", "mvc.command.name=/df/document/upload_multiple_file_entries"}, service = MVCActionCommand.class) public class EditFileEntryMVCActionCommand extends BaseMVCActionCommand { @Override @@ -110,14 +107,12 @@ protected void doProcessAction(ActionRequest actionRequest, ActionResponse actio deleteTempFileEntry(actionRequest, actionResponse); } - if (cmd.equals(Constants.ADD_TEMP) || - cmd.equals(Constants.DELETE_TEMP)) { + if (cmd.equals(Constants.ADD_TEMP) || cmd.equals(Constants.DELETE_TEMP)) { MutableRenderParameters mutableRenderParameters = actionResponse.getRenderParameters(); mutableRenderParameters.setValue("mvcPath", "/null.jsp"); } else { String redirect = ParamUtil.getString(actionRequest, "redirect"); - int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", - WorkflowConstants.ACTION_SAVE_DRAFT); + int workflowAction = ParamUtil.getInteger(actionRequest, "workflowAction", WorkflowConstants.ACTION_SAVE_DRAFT); if ((fileEntry != null) && (workflowAction == WorkflowConstants.ACTION_SAVE_DRAFT)) { @@ -141,30 +136,20 @@ protected void doProcessAction(ActionRequest actionRequest, ActionResponse actio * @return * @throws Exception */ - protected String getSaveAndContinueRedirect( - PortletConfig portletConfig, ActionRequest actionRequest, - FileEntry fileEntry, String redirect) - throws Exception { + protected String getSaveAndContinueRedirect(PortletConfig portletConfig, ActionRequest actionRequest, FileEntry fileEntry, String redirect) throws Exception { - ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute( - WebKeys.THEME_DISPLAY); + ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); - LiferayPortletURL portletURL = PortletURLFactoryUtil.create( - actionRequest, portletConfig.getPortletName(), themeDisplay.getLayout(), - PortletRequest.RENDER_PHASE); + LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), themeDisplay.getLayout(), PortletRequest.RENDER_PHASE); MutableRenderParameters mutableRenderParameters = portletURL.getRenderParameters(); - mutableRenderParameters.setValues( - "mvcRenderCommandName", "/df/document/edit_file_entry"); + mutableRenderParameters.setValues("mvcRenderCommandName", "/df/document/edit_file_entry"); mutableRenderParameters.setValues(Constants.CMD, Constants.UPDATE); mutableRenderParameters.setValues("redirect", redirect); - mutableRenderParameters.setValues( - "groupId", String.valueOf(fileEntry.getGroupId())); - mutableRenderParameters.setValues( - "fileEntryId", String.valueOf(fileEntry.getFileEntryId())); - mutableRenderParameters.setValues( - "version", String.valueOf(fileEntry.getVersion())); + mutableRenderParameters.setValues("groupId", String.valueOf(fileEntry.getGroupId())); + mutableRenderParameters.setValues("fileEntryId", String.valueOf(fileEntry.getFileEntryId())); + mutableRenderParameters.setValues("version", String.valueOf(fileEntry.getVersion())); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); @@ -267,8 +252,7 @@ protected void addTempFileEntry(ActionRequest actionRequest, ActionResponse acti String mimeType = uploadPortletRequest.getContentType("file"); - FileEntry fileEntry = _dlAppService.addTempFileEntry(themeDisplay.getScopeGroupId(), folderId, - TEMP_FOLDER_NAME, tempFileName, inputStream, mimeType); + FileEntry fileEntry = _dlAppService.addTempFileEntry(themeDisplay.getScopeGroupId(), folderId, TEMP_FOLDER_NAME, tempFileName, inputStream, mimeType); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); @@ -292,8 +276,7 @@ protected void addTempFileEntry(ActionRequest actionRequest, ActionResponse acti * @return * @throws Exception */ - public FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest actionRequest, - ActionResponse actionResponse) throws Exception { + public FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { UploadPortletRequest uploadPortletRequest = PortalUtil.getUploadPortletRequest(actionRequest); @@ -309,13 +292,9 @@ public FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest acti String title = ParamUtil.getString(uploadPortletRequest, "title"); String description = ParamUtil.getString(uploadPortletRequest, "description"); String changeLog = ParamUtil.getString(uploadPortletRequest, "changeLog"); - DLVersionNumberIncrease dlVersionNumberIncrease = - DLVersionNumberIncrease.valueOf( - uploadPortletRequest.getParameter("versionIncrease"), - DLVersionNumberIncrease.AUTOMATIC); + DLVersionNumberIncrease dlVersionNumberIncrease = DLVersionNumberIncrease.valueOf(uploadPortletRequest.getParameter("versionIncrease"), DLVersionNumberIncrease.AUTOMATIC); - boolean updateVersionDetails = ParamUtil.getBoolean( - uploadPortletRequest, "updateVersionDetails"); + boolean updateVersionDetails = ParamUtil.getBoolean(uploadPortletRequest, "updateVersionDetails"); if (!updateVersionDetails) { dlVersionNumberIncrease = DLVersionNumberIncrease.AUTOMATIC; @@ -342,47 +321,19 @@ public FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest acti inputStream = uploadPortletRequest.getFileAsStream("file"); - ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), - uploadPortletRequest); + ServiceContext serviceContext = ServiceContextFactory.getInstance(DLFileEntry.class.getName(), uploadPortletRequest); FileEntry fileEntry = null; if (cmd.equals(Constants.ADD)) { // Add file entry - fileEntry = _dlAppService.addFileEntry( - null, - repositoryId, - folderId, - sourceFileName, - contentType, - title, - StringPool.BLANK, - description, - changeLog, - inputStream, - size, - (Date)null, - (Date)null, - serviceContext); + fileEntry = _dlAppService.addFileEntry(null, repositoryId, folderId, sourceFileName, contentType, title, StringPool.BLANK, description, changeLog, inputStream, size, (Date) null, (Date) null, serviceContext); } else { // Update file entry - fileEntry = _dlAppService.updateFileEntry( - fileEntryId, - sourceFileName, - contentType, - title, - StringPool.BLANK, - description, - changeLog, - dlVersionNumberIncrease, - inputStream, - size, - (Date)null, - (Date)null, - serviceContext); + fileEntry = _dlAppService.updateFileEntry(fileEntryId, sourceFileName, contentType, title, StringPool.BLANK, description, changeLog, dlVersionNumberIncrease, inputStream, size, (Date) null, (Date) null, serviceContext); } return fileEntry; @@ -401,21 +352,14 @@ public FileEntry updateFileEntry(PortletConfig portletConfig, ActionRequest acti * @param e * @throws Exception */ - protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest, - ActionResponse actionResponse, String cmd, Exception e) throws Exception { + protected void handleUploadException(PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse, String cmd, Exception e) throws Exception { if (e instanceof AssetCategoryException || e instanceof AssetTagException) { SessionErrors.add(actionRequest, e.getClass(), e); - } else if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException - || e instanceof DuplicateFolderNameException || e instanceof FileExtensionException - || e instanceof FileMimeTypeException || e instanceof FileNameException - || e instanceof FileSizeException || e instanceof LiferayFileItemException - || e instanceof NoSuchFolderException || e instanceof SourceFileNameException - || e instanceof StorageFieldRequiredException || e instanceof UploadRequestSizeException) { + } else if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof DuplicateFolderNameException || e instanceof FileExtensionException || e instanceof FileMimeTypeException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof LiferayFileItemException || e instanceof NoSuchFolderException || e instanceof SourceFileNameException || e instanceof StorageFieldRequiredException || e instanceof UploadRequestSizeException) { - if (!cmd.equals(Constants.ADD_DYNAMIC) && !cmd.equals(Constants.ADD_MULTIPLE) - && !cmd.equals(Constants.ADD_TEMP)) { + if (!cmd.equals(Constants.ADD_DYNAMIC) && !cmd.equals(Constants.ADD_MULTIPLE) && !cmd.equals(Constants.ADD_TEMP)) { if (e instanceof AntivirusScannerException) { SessionErrors.add(actionRequest, e.getClass(), e); @@ -428,9 +372,7 @@ protected void handleUploadException(PortletConfig portletConfig, ActionRequest hideDefaultErrorMessage(actionRequest); } - if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException - || e instanceof FileExtensionException || e instanceof FileNameException - || e instanceof FileSizeException || e instanceof UploadRequestSizeException) { + if (e instanceof AntivirusScannerException || e instanceof DuplicateFileEntryException || e instanceof FileExtensionException || e instanceof FileNameException || e instanceof FileSizeException || e instanceof UploadRequestSizeException) { HttpServletResponse response = PortalUtil.getHttpServletResponse(actionResponse); @@ -455,18 +397,15 @@ protected void handleUploadException(PortletConfig portletConfig, ActionRequest errorMessage = themeDisplay.translate("please-enter-a-unique-document-name"); errorType = ServletResponseConstants.SC_DUPLICATE_FILE_EXCEPTION; } else if (e instanceof FileExtensionException) { - errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-extension-x", - StringUtil.merge(getAllowedFileExtensions(portletConfig, actionRequest, actionResponse))); + errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-extension-x", StringUtil.merge(getAllowedFileExtensions(portletConfig, actionRequest, actionResponse))); errorType = ServletResponseConstants.SC_FILE_EXTENSION_EXCEPTION; } else if (e instanceof FileNameException) { errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-name"); errorType = ServletResponseConstants.SC_FILE_NAME_EXCEPTION; } else if (e instanceof FileSizeException) { - long fileMaxSize = _uploadServletRequestConfigurationHelper.getMaxSize(); + long fileMaxSize = _uploadServletRequestConfigurationProvider.getMaxSize(); - errorMessage = themeDisplay.translate( - "please-enter-a-file-with-a-valid-file-size-no-larger" + "-than-x", - TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale())); + errorMessage = themeDisplay.translate("please-enter-a-file-with-a-valid-file-size-no-larger" + "-than-x", TextFormatter.formatStorageSize(fileMaxSize, themeDisplay.getLocale())); errorType = ServletResponseConstants.SC_FILE_SIZE_EXCEPTION; } @@ -484,9 +423,7 @@ protected void handleUploadException(PortletConfig portletConfig, ActionRequest } else { SessionErrors.add(actionRequest, e.getClass()); } - } else if (e instanceof DuplicateLockException || e instanceof FileEntryLockException.MustOwnLock - || e instanceof InvalidFileVersionException || e instanceof NoSuchFileEntryException - || e instanceof PrincipalException) { + } else if (e instanceof DuplicateLockException || e instanceof FileEntryLockException.MustOwnLock || e instanceof InvalidFileVersionException || e instanceof NoSuchFileEntryException || e instanceof PrincipalException) { if (e instanceof DuplicateLockException) { DuplicateLockException dle = (DuplicateLockException) e; @@ -518,15 +455,13 @@ protected void handleUploadException(PortletConfig portletConfig, ActionRequest * @return * @throws PortalException */ - protected String[] getAllowedFileExtensions(PortletConfig portletConfig, PortletRequest portletRequest, - PortletResponse portletResponse) throws PortalException { + protected String[] getAllowedFileExtensions(PortletConfig portletConfig, PortletRequest portletRequest, PortletResponse portletResponse) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletDisplay portletDisplay = themeDisplay.getPortletDisplay(); - Settings settings = SettingsFactoryUtil - .getSettings(new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portletDisplay.getId())); + Settings settings = SettingsFactoryUtil.getSettings(new PortletInstanceSettingsLocator(themeDisplay.getLayout(), portletDisplay.getId())); TypedSettings typedSettings = new TypedSettings(settings); @@ -551,13 +486,8 @@ protected void setDLTrashService(DLTrashService dlTrashService) { _dlTrashService = dlTrashService; } - @Reference(unbind = "-") - protected void setUploadServletRequestConfigurationHelper(UploadServletRequestConfigurationHelper uploadServletRequestConfigurationHelper) { - _uploadServletRequestConfigurationHelper = uploadServletRequestConfigurationHelper; - } - - private UploadServletRequestConfigurationHelper - _uploadServletRequestConfigurationHelper; + @Reference + private UploadServletRequestConfigurationProvider _uploadServletRequestConfigurationProvider; private DLAppService _dlAppService; private DLTrashService _dlTrashService; diff --git a/src/main/java/com/liferay/support/tools/journal/JournalRandomDummyGenerator.java b/src/main/java/com/liferay/support/tools/journal/JournalRandomDummyGenerator.java index ffad10a..cb986f4 100644 --- a/src/main/java/com/liferay/support/tools/journal/JournalRandomDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/journal/JournalRandomDummyGenerator.java @@ -1,9 +1,12 @@ package com.liferay.support.tools.journal; +import com.liferay.dynamic.data.mapping.model.DDMStructure; +import com.liferay.dynamic.data.mapping.service.DDMStructureService; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.service.JournalArticleLocalService; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.service.GroupLocalService; +import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.support.tools.constants.LDFPortletKeys; import com.liferay.support.tools.utils.ProgressManager; @@ -47,6 +50,11 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E "Starting to create " + paramContext.getNumberOfArticles() + " articles for site id <" + _groupLocalService.getGroup(groupId).getDescriptiveName() + ">"); + DDMStructure ddmStructure = _ddmStructureService.getStructure( + PortalUtil.getSiteGroupId(groupId), + PortalUtil.getClassNameId(com.liferay.journal.model.JournalArticle.class.getName()), + LDFPortletKeys._DDM_STRUCTURE_KEY, true); + for (long i = 1; i <= paramContext.getNumberOfArticles(); i++) { // Update progress progressManager.trackProgress( @@ -94,13 +102,14 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E try { // Create article JournalArticle createdArticle = _journalArticleLocalService.addArticle( + null, paramContext.getServiceContext().getUserId(), // userId, groupId, // groupId, paramContext.getFolderId(), // folderId titleMap, // titleMap paramContext.getDescriptionMap(), // descriptionMap content, // content - LDFPortletKeys._DDM_STRUCTURE_KEY, // ddmStructureKey, + ddmStructure.getStructureId(), LDFPortletKeys._DDM_TEMPLATE_KEY, // ddmTemplateKey, paramContext.getServiceContext() // serviceContext ); @@ -133,6 +142,9 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E private GroupLocalService _groupLocalService; @Reference - private RandomizeContentGenerator _randomizeContentGenerator; + private RandomizeContentGenerator _randomizeContentGenerator; + + @Reference + private DDMStructureService _ddmStructureService; } diff --git a/src/main/java/com/liferay/support/tools/journal/JournalSimpleDummyGenerator.java b/src/main/java/com/liferay/support/tools/journal/JournalSimpleDummyGenerator.java index ef85dbb..da69d82 100644 --- a/src/main/java/com/liferay/support/tools/journal/JournalSimpleDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/journal/JournalSimpleDummyGenerator.java @@ -1,5 +1,7 @@ package com.liferay.support.tools.journal; +import com.liferay.dynamic.data.mapping.model.DDMStructure; +import com.liferay.dynamic.data.mapping.service.DDMStructureService; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.service.JournalArticleLocalService; import com.liferay.portal.kernel.exception.PortalException; @@ -7,19 +9,18 @@ import com.liferay.portal.kernel.util.StringBundler; import com.liferay.support.tools.constants.LDFPortletKeys; import com.liferay.support.tools.utils.ProgressManager; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import com.liferay.portal.kernel.util.PortalUtil; +import javax.portlet.ActionRequest; import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.portlet.ActionRequest; - -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; - /** * Simple Journal Articles Generator - * + * * @author Yasuyuki Takeo * */ @@ -28,7 +29,7 @@ public class JournalSimpleDummyGenerator extends JournalStructureBaseDummyGenera @Override protected JournalContext getContext(ActionRequest request) throws PortalException { - + return new JournalContext(request); } @@ -40,16 +41,21 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E long progressCount = 0; long[] groupIds = paramContext.getGroupIds(); - + for (long groupId : groupIds) { System.out.println( "Starting to create " + paramContext.getNumberOfArticles() + " articles for site id <" + _groupLocalService.getGroup(groupId).getDescriptiveName() + ">"); + DDMStructure ddmStructure = _ddmStructureService.getStructure( + PortalUtil.getSiteGroupId(groupId), + PortalUtil.getClassNameId(com.liferay.journal.model.JournalArticle.class.getName()), + LDFPortletKeys._DDM_STRUCTURE_KEY, true); + for (long i = 1; i <= paramContext.getNumberOfArticles(); i++) { // Update progress progressManager.trackProgress( - progressCount, + progressCount, paramContext.getNumberOfArticles()*groupIds.length ); @@ -57,42 +63,43 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E StringBundler title = new StringBundler(2); title.append(paramContext.getBaseTitle()); - // Add number more then one article + // Add number more than one article if (1 < paramContext.getNumberOfArticles()) { title.append(i); } // Build contents - String content = + String content = _journalUtils.buildFields( - paramContext.getThemeDisplay().getCompanyGroupId(), - paramContext.getLocales(), + paramContext.getThemeDisplay().getCompanyGroupId(), + paramContext.getLocales(), paramContext.getBaseArticle() ); Map titleMap = new ConcurrentHashMap(); titleMap.put( - paramContext.getDefaultLocale(), + paramContext.getDefaultLocale(), title.toString() ); try { // Create article JournalArticle createdArticle = _journalArticleLocalService.addArticle( + null, paramContext.getServiceContext().getUserId(), // userId, groupId, // groupId, paramContext.getFolderId(), // folderId titleMap, // titleMap paramContext.getDescriptionMap(), // descriptionMap content, // content + ddmStructure.getStructureId(), LDFPortletKeys._DDM_STRUCTURE_KEY, // ddmStructureKey, - LDFPortletKeys._DDM_TEMPLATE_KEY, // ddmTemplateKey, paramContext.getServiceContext() // serviceContext ); - + // Update never expired and never reviewed updateArticle(createdArticle, paramContext); - + } catch (Throwable e) { // Finish progress progressManager.finish(); @@ -110,11 +117,14 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E @Reference private JournalUtils _journalUtils; - + @Reference private JournalArticleLocalService _journalArticleLocalService; - + @Reference - private GroupLocalService _groupLocalService; + private GroupLocalService _groupLocalService; + + @Reference + private DDMStructureService _ddmStructureService; } diff --git a/src/main/java/com/liferay/support/tools/journal/JournalStructureBaseDummyGenerator.java b/src/main/java/com/liferay/support/tools/journal/JournalStructureBaseDummyGenerator.java index 2825535..73204cb 100644 --- a/src/main/java/com/liferay/support/tools/journal/JournalStructureBaseDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/journal/JournalStructureBaseDummyGenerator.java @@ -141,8 +141,8 @@ protected JournalArticle updateArticle(JournalArticle createdArticle, JournalCon createdArticle.getVersion(), createdArticle.getTitleMap(), createdArticle.getDescriptionMap(), + createdArticle.getFriendlyURLMap(), createdArticle.getContent(), - createdArticle.getDDMStructureKey(), createdArticle.getDDMTemplateKey(), createdArticle.getLayoutUuid(), displayDateMonth, diff --git a/src/main/java/com/liferay/support/tools/journal/JournalStructureTemplateDummyGenerator.java b/src/main/java/com/liferay/support/tools/journal/JournalStructureTemplateDummyGenerator.java index c6740fe..5a05473 100644 --- a/src/main/java/com/liferay/support/tools/journal/JournalStructureTemplateDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/journal/JournalStructureTemplateDummyGenerator.java @@ -2,6 +2,7 @@ import com.liferay.dynamic.data.mapping.model.DDMStructure; import com.liferay.dynamic.data.mapping.service.DDMStructureLocalService; +import com.liferay.dynamic.data.mapping.service.DDMStructureService; import com.liferay.dynamic.data.mapping.service.DDMTemplateLocalService; import com.liferay.journal.model.JournalArticle; import com.liferay.journal.service.JournalArticleLocalService; @@ -9,16 +10,14 @@ import com.liferay.portal.kernel.service.GroupLocalService; import com.liferay.portal.kernel.util.StringBundler; import com.liferay.support.tools.utils.ProgressManager; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import javax.portlet.ActionRequest; import java.util.Locale; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import javax.portlet.ActionRequest; - -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; - /** * Structure / Template selected Journal Articles Generator * @@ -42,9 +41,6 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E _DDMStructureLocalService.getStructure( paramContext.getDdmStructureId() ); - - String structureKey = - ddmStructure.getStructureKey(); // Template key String templateKey = @@ -97,13 +93,14 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E try { // Create article JournalArticle createdArticle = _journalArticleLocalService.addArticle( + null, paramContext.getServiceContext().getUserId(), // userId, groupId, // groupId, paramContext.getFolderId(), // folderId titleMap, // titleMap paramContext.getDescriptionMap(), // descriptionMap content, // content - structureKey, // ddmStructureKey, + ddmStructure.getStructureId(), // ddmStructureId, templateKey, // ddmTemplateKey, paramContext.getServiceContext() // serviceContext ); @@ -139,6 +136,9 @@ protected void exec(ActionRequest request, JournalContext paramContext) throws E private DDMStructureLocalService _DDMStructureLocalService; @Reference - private DDMTemplateLocalService _DDMTemplateLocalService; + private DDMTemplateLocalService _DDMTemplateLocalService; + + @Reference + private DDMStructureService _ddmStructureService; } diff --git a/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java b/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java index 562407d..b90f2d7 100644 --- a/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java +++ b/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java @@ -21,17 +21,20 @@ service = PanelApp.class ) public class DummyFactoryPanelApp extends BasePanelApp { + + @Override + public Portlet getPortlet() { + return _portlet; + } + @Override public String getPortletId() { return LDFPortletKeys.LIFERAY_DUMMY_FACTORY; } - @Override @Reference( target = "(javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY + ")", unbind = "-" ) - public void setPortlet(Portlet portlet) { - super.setPortlet(portlet); - } + private Portlet _portlet; } diff --git a/src/main/java/com/liferay/support/tools/user/UserDataService.java b/src/main/java/com/liferay/support/tools/user/UserDataService.java index 0fd78ce..2539b7a 100644 --- a/src/main/java/com/liferay/support/tools/user/UserDataService.java +++ b/src/main/java/com/liferay/support/tools/user/UserDataService.java @@ -11,10 +11,7 @@ import com.liferay.portal.kernel.exception.UserScreenNameException; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; -import com.liferay.portal.kernel.model.Organization; -import com.liferay.portal.kernel.model.Role; -import com.liferay.portal.kernel.model.RoleConstants; -import com.liferay.portal.kernel.model.User; +import com.liferay.portal.kernel.model.*; import com.liferay.portal.kernel.security.access.control.AccessControlled; import com.liferay.portal.kernel.service.*; import com.liferay.portal.kernel.transaction.Isolation; @@ -37,11 +34,11 @@ @Component(service = UserDataService.class) @ProviderType @Transactional( - isolation = Isolation.PORTAL, - rollbackFor = { - PortalException.class, - SystemException.class - } + isolation = Isolation.PORTAL, + rollbackFor = { + PortalException.class, + SystemException.class + } ) public class UserDataService { @@ -64,48 +61,53 @@ public class UserDataService { * @throws PortalException */ public User createUserData( - ServiceContext serviceContext, long[] organizationIds, long[] groupIds, - long[] roleIds, long[] userGroupIds, boolean male, boolean fakerEnable, - String password, String screenName, String emailAddress, - String baseScreenName, long index, String localeStr) - throws PortalException { + ServiceContext serviceContext, long[] organizationIds, long[] groupIds, + long[] roleIds, long[] userGroupIds, boolean male, boolean fakerEnable, + String password, String screenName, String emailAddress, + String baseScreenName, long index, String localeStr) + throws PortalException { // For generating dummy user name Faker faker = _commonUtil.createFaker(localeStr); // Generate first / last name String firstName = - (fakerEnable) ? faker.name().firstName() : baseScreenName; + (fakerEnable) ? faker.name().firstName() : baseScreenName; String lastName = - (fakerEnable) ? faker.name().lastName() : String.valueOf(index); + (fakerEnable) ? faker.name().lastName() : String.valueOf(index); User user = null; try { // Create User user = _userLocalService.addUserWithWorkflow( - serviceContext.getUserId(), serviceContext.getCompanyId(), // companyId, - false, // autoPassword, - password, // password1, - password, // password2, - false, // autoScreenName, - screenName.toString(), - emailAddress.toString(), - LocaleUtil.getDefault(), // locale, - firstName, // firstName, - StringPool.BLANK, // middleName, - lastName, // lastName, - 0, // prefixId, - 0, // suffixId, - male, // male - 1, // birthdayMonth, - 1, // birthdayDay, - 1970, // birthdayYear, - StringPool.BLANK, // jobTitle, - groupIds, organizationIds, getRegularRoleIds(roleIds), // this is only for the regular roles - userGroupIds, // userGroupIds, - false, // sendEmail - serviceContext // serviceContext + serviceContext.getUserId(), + serviceContext.getCompanyId(), // companyId, + false, // autoPassword, + password, // password1, + password, // password2, + false, // autoScreenName, + screenName, + emailAddress, + LocaleUtil.getDefault(), // locale, + firstName, // firstName, + StringPool.BLANK, // middleName, + lastName, // lastName, + 0, // prefixId, + 0, // suffixId, + male, // male + 1, // birthdayMonth, + 1, // birthdayDay, + 1970, // birthdayYear, + StringPool.BLANK, // jobTitle, + // TODO : User Type may want to be configurable moving forward + UserConstants.TYPE_REGULAR, + groupIds, + organizationIds, + getRegularRoleIds(roleIds), // this is only for the regular roles + userGroupIds, // userGroupIds, + false, // sendEmail + serviceContext // serviceContext ); if (_log.isDebugEnabled()) { @@ -137,16 +139,16 @@ groupIds, organizationIds, getRegularRoleIds(roleIds), // this is only for the r public List getFakerAvailableLocales(Set locales) { List fakerList = new ArrayList<>( - Arrays.asList( - "bg", "ca", "ca-CAT", "da-DK", "de", "de-AT", "de-CH", "en", - "en-AU", "en-au-ocker", "en-BORK", "en-CA", "en-GB", "en-IND", - "en-NEP", "en-NG", "en-NZ", "en-PAK", "en-SG", "en-UG", "en-US", - "en-ZA", "es", "es-MX", "fa", "fi-FI", "fr", "he", "in-ID", - "it", "ja", "ko", "nb-NO", "nl", "pl", "pt", "pt-BR", "ru", - "sk", "sv", "sv-SE", "tr", "uk", "vi", "zh-CN", "zh-TW")); + Arrays.asList( + "bg", "ca", "ca-CAT", "da-DK", "de", "de-AT", "de-CH", "en", + "en-AU", "en-au-ocker", "en-BORK", "en-CA", "en-GB", "en-IND", + "en-NEP", "en-NG", "en-NZ", "en-PAK", "en-SG", "en-UG", "en-US", + "en-ZA", "es", "es-MX", "fa", "fi-FI", "fr", "he", "in-ID", + "it", "ja", "ko", "nb-NO", "nl", "pl", "pt", "pt-BR", "ru", + "sk", "sv", "sv-SE", "tr", "uk", "vi", "zh-CN", "zh-TW")); return locales.stream().filter( - locale -> fakerList.contains(locale.getLanguage())).collect( - Collectors.toList()); + locale -> fakerList.contains(locale.getLanguage())).collect( + Collectors.toList()); } /** @@ -157,7 +159,7 @@ public List getFakerAvailableLocales(Set locales) { * @throws PortalException */ public long[] getRegularRoleIds(long[] roleIds) - throws PortalException { + throws PortalException { Map> roles = _commonUtil.filterRoles(roleIds); List regularRoles = roles.get(RoleConstants.TYPE_REGULAR); @@ -168,8 +170,8 @@ public long[] getRegularRoleIds(long[] roleIds) if (_log.isDebugEnabled()) { String regularids = regularRoles.stream().map( - r -> String.valueOf(r.getRoleId())).collect( - Collectors.joining(",")); + r -> String.valueOf(r.getRoleId())).collect( + Collectors.joining(",")); _log.debug("Regular ids : " + regularids); } @@ -186,7 +188,7 @@ public long[] getRegularRoleIds(long[] roleIds) * @throws PortalException */ public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) - throws PortalException { + throws PortalException { Map> roles = _commonUtil.filterRoles(roleIds); List orgRoles = roles.get(RoleConstants.TYPE_ORGANIZATION); @@ -199,8 +201,8 @@ public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) if (_log.isDebugEnabled()) { String orgids = orgRoles.stream().map( - o -> String.valueOf(o.getPrimaryKey())).collect( - Collectors.joining(",")); + o -> String.valueOf(o.getPrimaryKey())).collect( + Collectors.joining(",")); _log.debug("Organization ids : " + orgids); } @@ -210,13 +212,13 @@ public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) } List orgs = - _organizationLocalService.getOrganizations(organizationIds); + _organizationLocalService.getOrganizations(organizationIds); long[] orgGroupdIds = - orgs.stream().mapToLong(Organization::getGroupId).toArray(); + orgs.stream().mapToLong(Organization::getGroupId).toArray(); for (long orgGroupdId : orgGroupdIds) { _userGroupRoleLocalService.addUserGroupRoles( - userId, orgGroupdId, orgIds); + userId, orgGroupdId, orgIds); } } @@ -230,7 +232,7 @@ public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) * @throws PortalException */ public void setSiteRoles(long userId, long[] groupIds, long[] roleIds) - throws PortalException { + throws PortalException { Map> roles = _commonUtil.filterRoles(roleIds); List siteRoles = roles.get(RoleConstants.TYPE_SITE); @@ -240,12 +242,12 @@ public void setSiteRoles(long userId, long[] groupIds, long[] roleIds) } long[] siteIds = - siteRoles.stream().mapToLong(Role::getRoleId).toArray(); + siteRoles.stream().mapToLong(Role::getRoleId).toArray(); if (_log.isDebugEnabled()) { String siteids = siteRoles.stream().map( - s -> String.valueOf(s.getRoleId())).collect( - Collectors.joining(",")); + s -> String.valueOf(s.getRoleId())).collect( + Collectors.joining(",")); _log.debug("Site ids : " + siteids); } @@ -256,7 +258,7 @@ public void setSiteRoles(long userId, long[] groupIds, long[] roleIds) for (long groupId : groupIds) { _userGroupRoleLocalService.addUserGroupRoles( - userId, groupId, siteIds); + userId, groupId, siteIds); } } @@ -268,14 +270,14 @@ public void setSiteRoles(long userId, long[] groupIds, long[] roleIds) * @throws PortalException */ public void updateAnnouncementsDeliveries( - long userId, List announcementsDeliveries) - throws PortalException { + long userId, List announcementsDeliveries) + throws PortalException { for (AnnouncementsDelivery announcementsDelivery : announcementsDeliveries) { _announcementsDeliveryLocalService.updateDelivery( - userId, announcementsDelivery.getType(), - announcementsDelivery.isEmail(), announcementsDelivery.isSms()); + userId, announcementsDelivery.getType(), + announcementsDelivery.isEmail(), announcementsDelivery.isSms()); } } @@ -298,5 +300,5 @@ public void updateAnnouncementsDeliveries( private OrganizationLocalService _organizationLocalService; private static final Log _log = - LogFactoryUtil.getLog(UserDataService.class); + LogFactoryUtil.getLog(UserDataService.class); } From 4ca5aebf63fed0bad2789eda2257bbeea6b1026c Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Mon, 29 May 2023 18:31:01 +0900 Subject: [PATCH 03/11] Update the fieldset group new markup --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ae9cc1e..c543157 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ package-lock.json node_modules .classpath .project +.vscode/settings.json From b1a1381d7db5924b90d99d76e16df23dcdb19813 Mon Sep 17 00:00:00 2001 From: Yasuyuki Takeo Date: Mon, 29 May 2023 18:31:56 +0900 Subject: [PATCH 04/11] Update fieldset markups --- .../resources/META-INF/resources/blogs.jsp | 255 ++++---- .../resources/META-INF/resources/category.jsp | 196 +++--- .../resources/META-INF/resources/company.jsp | 181 +++--- .../META-INF/resources/documents.jsp | 394 ++++++------ src/main/resources/META-INF/resources/mb.jsp | 258 ++++---- .../resources/META-INF/resources/pages.jsp | 236 ++++---- .../resources/META-INF/resources/sites.jsp | 301 +++++----- .../resources/META-INF/resources/users.jsp | 566 +++++++++--------- .../resources/META-INF/resources/view.jsp | 213 +++---- src/main/resources/META-INF/resources/wcm.jsp | 322 +++++----- .../resources/META-INF/resources/wiki.jsp | 228 +++---- 11 files changed, 1587 insertions(+), 1563 deletions(-) diff --git a/src/main/resources/META-INF/resources/blogs.jsp b/src/main/resources/META-INF/resources/blogs.jsp index e98b508..ebf1e2c 100644 --- a/src/main/resources/META-INF/resources/blogs.jsp +++ b/src/main/resources/META-INF/resources/blogs.jsp @@ -7,141 +7,144 @@
- - - - - <%@ include file="/command_select.jspf" %> - - - - - - -