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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 34d3df3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -dist: xenial -language: java -jdk: openjdk8 -env: - - CI=true -before_script: - - chmod +x gradlew -script: - - ./gradlew test --info -after_success: - - ./gradlew jacocoTestReport coveralls -before_cache: - - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock - - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ -cache: - directories: - - $HOME/.gradle/caches/ - - $HOME/.gradle/wrapper/ \ No newline at end of file diff --git a/bnd.bnd b/bnd.bnd index 122fe04..8c93584 100644 --- a/bnd.bnd +++ b/bnd.bnd @@ -1,6 +1,6 @@ Bundle-Name: Liferay Dummy Factory Portlet Bundle-SymbolicName: liferay.dummy.factory -Bundle-Version: 7.4.2 +Bundle-Version: 7.4.3 Web-ContextPath: /liferay-dummy-factory -dsannotations-options: inherit -sources: true diff --git a/build.gradle b/build.gradle index 2f34dd5..ee17c39 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,11 @@ 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.portal:com.liferay.portal.kernel' + compileOnly 'com.liferay.portal:com.liferay.portal.impl' + compileOnly 'com.liferay:com.liferay.dynamic.data.mapping.api' + compileOnly 'com.liferay:com.liferay.journal.api' + compileOnly 'com.liferay:com.liferay.message.boards.api' testCompile 'org.codehaus.groovy:groovy-all:2.5.+' testCompile group: 'cglib', name: 'cglib-nodep', version: 'latest.integration' @@ -93,7 +98,7 @@ test { jacocoTestReport { reports { xml.enabled true - html.enabled = true + html.enabled = false } } diff --git a/latest/liferay.dummy.factory-7.4.2.jar b/latest/liferay.dummy.factory-7.4.3.jar similarity index 86% rename from latest/liferay.dummy.factory-7.4.2.jar rename to latest/liferay.dummy.factory-7.4.3.jar index 83b6ed1..e365e13 100644 Binary files a/latest/liferay.dummy.factory-7.4.2.jar and b/latest/liferay.dummy.factory-7.4.3.jar differ diff --git a/package.json b/package.json index 32ab87c..eb5f638 100644 --- a/package.json +++ b/package.json @@ -2,13 +2,13 @@ "name": "liferay-dummy-factory", "version": "1.0.0", "dependencies": { - "jquery": "^3.6.0", + "jquery": "^3.7.0", "lodash": "^4.17.21" }, "devDependencies": { - "@liferay/npm-scripts": "^47.6.1", - "liferay-npm-bundler": "^2.28.3", - "liferay-npm-build-support": "^2.28.3" + "@liferay/npm-scripts": "^47.19.0", + "liferay-npm-bundler": "^2.31.2", + "liferay-npm-build-support": "^2.31.2" }, "scripts": { "build": "liferay-npm-bundler" 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..c5ba9a3 100644 --- a/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java +++ b/src/main/java/com/liferay/support/tools/company/CompanyDefaultDummyGenerator.java @@ -5,13 +5,16 @@ import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; import com.liferay.portal.kernel.model.Company; +import com.liferay.portal.kernel.security.auth.CompanyThreadLocal; import com.liferay.portal.kernel.service.CompanyLocalService; +import com.liferay.portal.kernel.util.PortalUtil; import com.liferay.support.tools.common.DummyGenerator; import com.liferay.support.tools.utils.ProgressManager; -import javax.portlet.ActionRequest; import org.osgi.service.component.annotations.Component; import org.osgi.service.component.annotations.Reference; +import javax.portlet.ActionRequest; + /** * Company Generator * @@ -49,21 +52,22 @@ protected void exec(ActionRequest request, CompanyContext paramContext) //Create company web id StringBundler webId = new StringBundler(2); - webId.append(paramContext.getWebId()); //Create company Virtual Host Name StringBundler virtualHostname = new StringBundler(2); - virtualHostname.append(paramContext.getVirtualHostname()); //Create company Mail Domain 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); - mx.append(i); + webId.append(String.valueOf(i)).append(paramContext.getWebId()); + virtualHostname.append(String.valueOf(i)).append(paramContext.getVirtualHostname()); + mx.append(String.valueOf(i)).append(paramContext.getMx()); + } else { + webId.append(paramContext.getWebId()); + virtualHostname.append(paramContext.getVirtualHostname()); + mx.append(paramContext.getMx()); } try { @@ -72,21 +76,15 @@ protected void exec(ActionRequest request, CompanyContext paramContext) } Company company = _companyLocalService.addCompany( + null, webId.toString(), virtualHostname.toString(), mx.toString(), - paramContext.isSystem(), paramContext.getMaxUsers(), paramContext.isActive()); - _portalInstancesLocalService.initializePortalInstance( - company.getCompanyId(), company.getWebId(), - paramContext.getServletContext()); - - } catch (Exception e) { - //Finish progress - progressManager.finish(); - throw e; + } catch (Throwable e) { + _log.error(e,e); } } @@ -96,5 +94,4 @@ protected void exec(ActionRequest request, CompanyContext paramContext) System.out.println("Finished creating " + paramContext.getNumberOfCompanies() + " companies"); } - } \ No newline at end of file diff --git a/src/main/java/com/liferay/support/tools/constants/LDFPortletKeys.java b/src/main/java/com/liferay/support/tools/constants/LDFPortletKeys.java index 111709b..78c03d5 100644 --- a/src/main/java/com/liferay/support/tools/constants/LDFPortletKeys.java +++ b/src/main/java/com/liferay/support/tools/constants/LDFPortletKeys.java @@ -35,7 +35,7 @@ public class LDFPortletKeys { // Command public static final String COMMON = "/ldf/common"; - public static final String ORGANIZAION = "/ldf/org"; + public static final String ORGANIZATION = "/ldf/org"; public static final String SITES = "/ldf/sites"; public static final String PAGES = "/ldf/pages"; public static final String USERS = "/ldf/users"; 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/messageboard/MBMVCResourceCommand.java b/src/main/java/com/liferay/support/tools/messageboard/MBMVCResourceCommand.java index 200cc17..ef261a8 100644 --- a/src/main/java/com/liferay/support/tools/messageboard/MBMVCResourceCommand.java +++ b/src/main/java/com/liferay/support/tools/messageboard/MBMVCResourceCommand.java @@ -18,23 +18,17 @@ import com.liferay.portal.kernel.portlet.bridges.mvc.MVCResourceCommand; import com.liferay.portal.kernel.servlet.ServletResponseUtil; import com.liferay.portal.kernel.theme.ThemeDisplay; -import com.liferay.portal.kernel.util.Constants; -import com.liferay.portal.kernel.util.ContentTypes; -import com.liferay.portal.kernel.util.ParamUtil; -import com.liferay.portal.kernel.util.Portal; -import com.liferay.portal.kernel.util.WebKeys; +import com.liferay.portal.kernel.util.*; import com.liferay.portal.kernel.workflow.WorkflowConstants; import com.liferay.support.tools.constants.LDFPortletKeys; import com.liferay.support.tools.utils.CommonUtil; - -import java.util.List; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import javax.portlet.ResourceRequest; import javax.portlet.ResourceResponse; import javax.servlet.http.HttpServletResponse; - -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; +import java.util.List; /** * Message Board resources @@ -64,10 +58,10 @@ protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse String serializedJson = ""; if(cmd.equals(CMD_THREAD_LIST)) { - serializedJson = getThreadList(resourceRequest,resourceResponse ); + serializedJson = getThreadList(resourceRequest); } else if (cmd.equals(CMD_CATEGORY_LIST)) { - serializedJson = getCategoryList(resourceRequest,resourceResponse ); + serializedJson = getCategoryList(resourceRequest); } else { _log.error("Unknown command is passed <" + cmd + ">"); @@ -85,11 +79,10 @@ protected void doServeResource(ResourceRequest resourceRequest, ResourceResponse * Get Category list * * @param resourceRequest - * @param resourceResponse * @return * @throws PortalException */ - private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws PortalException { + private String getCategoryList(ResourceRequest resourceRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); @@ -100,7 +93,7 @@ private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse long siteGroupId = groupIds[0]; if(_log.isDebugEnabled()) { - _log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">"); + _log.debug("SiteGroup Id <" + siteGroupId + ">"); } List categories = _mbCategoryService.getCategories( @@ -134,11 +127,10 @@ private String getCategoryList(ResourceRequest resourceRequest, ResourceResponse * Depending on the passed site groupd id, fetch all pages in the site and return JSON object list. * * @param resourceRequest - * @param resourceResponse * @return * @throws PortalException */ - protected String getThreadList(ResourceRequest resourceRequest, ResourceResponse resourceResponse) + protected String getThreadList(ResourceRequest resourceRequest) throws PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); @@ -146,7 +138,7 @@ protected String getThreadList(ResourceRequest resourceRequest, ResourceResponse long siteGroupId = ParamUtil.getLong(resourceRequest, "siteGroupId", themeDisplay.getSiteGroupId()); if(_log.isDebugEnabled()) { - _log.debug("SiteGroup Id <" + String.valueOf(siteGroupId) + ">"); + _log.debug("SiteGroup Id <" + siteGroupId + ">"); } List threads = _mbThreadService.getGroupThreads( @@ -167,8 +159,8 @@ protected String getThreadList(ResourceRequest resourceRequest, ResourceResponse _log.debug("----------"); } - String subject = message.getSubject() + " (" + thread.getCategory().getName() + ")"; - curUserJSONObject.put("rootMessageSubject" , subject); + // String subject = message.getSubject() + " (" + thread.getCategory().getName() + ")"; + curUserJSONObject.put("rootMessageSubject" , message.getSubject() + thread.getThreadId()); curUserJSONObject.put("threadId" , thread.getThreadId()); curUserJSONObject.put("rootMessageId" , thread.getRootMessageId()); 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..cbad90c 100644 --- a/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java +++ b/src/main/java/com/liferay/support/tools/portlet/DummyFactoryPanelApp.java @@ -15,23 +15,26 @@ @Component( immediate = true, property = { - "panel.app.order:Integer=100", + "panel.app.order:Integer=600", "panel.category.key=" + PanelCategoryKeys.CONTROL_PANEL_APPS }, 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/portlet/LiferayDummyFactoryPortlet.java b/src/main/java/com/liferay/support/tools/portlet/LiferayDummyFactoryPortlet.java index 044d1cc..5366fbd 100644 --- a/src/main/java/com/liferay/support/tools/portlet/LiferayDummyFactoryPortlet.java +++ b/src/main/java/com/liferay/support/tools/portlet/LiferayDummyFactoryPortlet.java @@ -50,7 +50,8 @@ "javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY, "javax.portlet.resource-bundle=content.Language", "javax.portlet.security-role-ref=administrator,power-user,user", - "javax.portlet.supports.mime-type=text/html" + "javax.portlet.supports.mime-type=text/html", + "javax.portlet.version=3.0" }, service = Portlet.class ) diff --git a/src/main/java/com/liferay/support/tools/portlet/actions/CommonMVCRenderCommand.java b/src/main/java/com/liferay/support/tools/portlet/actions/CommonMVCRenderCommand.java index 79871ca..f347b93 100644 --- a/src/main/java/com/liferay/support/tools/portlet/actions/CommonMVCRenderCommand.java +++ b/src/main/java/com/liferay/support/tools/portlet/actions/CommonMVCRenderCommand.java @@ -11,14 +11,15 @@ import com.liferay.support.tools.utils.JqueryResolver; import com.liferay.support.tools.utils.LodashResolver; import com.liferay.support.tools.utils.WikiCommons; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; +import org.osgi.service.component.annotations.ReferencePolicy; +import org.osgi.service.component.annotations.ReferencePolicyOption; import javax.portlet.PortletException; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; - /** * Render command for all jsps * @@ -28,7 +29,7 @@ immediate = true, property = { "javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY, - "mvc.command.name=" + LDFPortletKeys.ORGANIZAION, + "mvc.command.name=" + LDFPortletKeys.ORGANIZATION, "mvc.command.name=" + LDFPortletKeys.SITES, "mvc.command.name=" + LDFPortletKeys.PAGES, "mvc.command.name=" + LDFPortletKeys.USERS, @@ -37,7 +38,7 @@ "mvc.command.name=" + LDFPortletKeys.MB, "mvc.command.name=" + LDFPortletKeys.CATEGORY, "mvc.command.name=" + LDFPortletKeys.BLOGS, - "mvc.command.name=" + LDFPortletKeys.WIKI, + // "mvc.command.name=" + LDFPortletKeys.WIKI, "mvc.command.name=" + LDFPortletKeys.COMMON }, service = MVCRenderCommand.class @@ -56,9 +57,9 @@ public String render(RenderRequest renderRequest, RenderResponse renderResponse) // Carry around mode renderRequest.setAttribute(LDFPortletKeys.MODE, mode); - // Component libralies - renderRequest.setAttribute(LDFPortletWebKeys.WIKI_COMMONS, _wikiCommons); - +// // Component libralies +// renderRequest.setAttribute(LDFPortletWebKeys.WIKI_COMMONS, _wikiCommons); +// if(_log.isDebugEnabled()) { _log.debug("mode <" + mode + ">"); _log.debug("jsp <" + _commonUtil @@ -76,13 +77,13 @@ public String render(RenderRequest renderRequest, RenderResponse renderResponse) .getOrDefault(mode, LDFPortletKeys.JSP_ORGANIZAION); } - @Reference + @Reference(bind = "-") private CommonUtil _commonUtil; - @Reference - private WikiCommons _wikiCommons; - - @Reference +// @Reference(bind = "-") +// private WikiCommons _wikiCommons; +// + @Reference(bind = "-") private NPMResolver _npmResolver; private static Log _log = LogFactoryUtil diff --git a/src/main/java/com/liferay/support/tools/portlet/actions/OrganizationMVCActionCommand.java b/src/main/java/com/liferay/support/tools/portlet/actions/OrganizationMVCActionCommand.java index 038530d..65408f9 100644 --- a/src/main/java/com/liferay/support/tools/portlet/actions/OrganizationMVCActionCommand.java +++ b/src/main/java/com/liferay/support/tools/portlet/actions/OrganizationMVCActionCommand.java @@ -27,7 +27,7 @@ immediate = true, property = { "javax.portlet.name=" + LDFPortletKeys.LIFERAY_DUMMY_FACTORY, - "mvc.command.name=" + LDFPortletKeys.ORGANIZAION + "mvc.command.name=" + LDFPortletKeys.ORGANIZATION }, service = MVCActionCommand.class ) 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); } diff --git a/src/main/java/com/liferay/support/tools/utils/WikiCommons.java b/src/main/java/com/liferay/support/tools/utils/WikiCommons.java index aa8227c..c627014 100644 --- a/src/main/java/com/liferay/support/tools/utils/WikiCommons.java +++ b/src/main/java/com/liferay/support/tools/utils/WikiCommons.java @@ -1,5 +1,6 @@ package com.liferay.support.tools.utils; + import com.liferay.petra.string.StringPool; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.log.Log; @@ -11,22 +12,22 @@ import com.liferay.portal.kernel.util.WebKeys; import com.liferay.portal.kernel.workflow.WorkflowThreadLocal; import com.liferay.wiki.configuration.WikiGroupServiceConfiguration; +import com.liferay.wiki.constants.WikiPageConstants; import com.liferay.wiki.engine.WikiEngine; import com.liferay.wiki.engine.WikiEngineRenderer; import com.liferay.wiki.model.WikiNode; import com.liferay.wiki.model.WikiPage; -import com.liferay.wiki.model.WikiPageConstants; import com.liferay.wiki.service.WikiNodeLocalService; -import com.liferay.wiki.service.WikiNodeLocalServiceUtil; import com.liferay.wiki.service.WikiPageLocalService; import com.liferay.wiki.service.WikiPageLocalServiceUtil; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +import javax.portlet.PortletRequest; import java.util.Collection; import java.util.LinkedHashMap; import java.util.Locale; import java.util.Map; -import javax.portlet.PortletRequest; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; /** * Utilities for Wiki @@ -36,37 +37,6 @@ @Component(immediate = true, service = WikiCommons.class) public class WikiCommons { - private static final Log _log = LogFactoryUtil.getLog(WikiCommons.class); - - private WikiEngineRenderer _wikiEngineRenderer; - private WikiGroupServiceConfiguration _wikiGroupServiceConfiguration; - private WikiNodeLocalService _wikiNodeLocalService; - private WikiPageLocalService _wikiPageLocalService; - - @Reference(unbind = "-") - protected void setWikiEngineRenderer( - WikiEngineRenderer wikiEngineRenderer) { - - _wikiEngineRenderer = wikiEngineRenderer; - } - - @Reference(unbind = "-") - protected void setWikiGroupServiceConfiguration( - WikiGroupServiceConfiguration wikiGroupServiceConfiguration) { - - _wikiGroupServiceConfiguration = wikiGroupServiceConfiguration; - } - - @Reference(unbind = "-") - protected void setWikiNodeLocalService(WikiNodeLocalService wikiNodeLocalService) { - _wikiNodeLocalService = wikiNodeLocalService; - } - - @Reference(unbind = "-") - protected void setWikiPageLocalService(WikiPageLocalService wikiPageLocalService) { - _wikiPageLocalService = wikiPageLocalService; - } - /** * Get Wiki format list * @@ -152,7 +122,7 @@ public void getFirstVisiblePage( WorkflowThreadLocal.setEnabled(false); WikiPageLocalServiceUtil.addPage( - themeDisplay.getDefaultUserId(), nodeId, + themeDisplay.getGuestUserId(), nodeId, _wikiGroupServiceConfiguration.frontPageName(), null, WikiPageConstants.NEW, true, serviceContext); } catch (Exception e) { @@ -209,11 +179,41 @@ public WikiNode getFirstVisibleNode(PortletRequest portletRequest, long scopeGro serviceContext.setScopeGroupId(scopeGroupId); node = _wikiNodeLocalService.addDefaultNode( - themeDisplay.getDefaultUserId(), serviceContext); + themeDisplay.getGuestUserId(), serviceContext); _log.info("Wiki Node has been initialized"); return node; } + private static final Log _log = LogFactoryUtil.getLog(WikiCommons.class); + + private WikiEngineRenderer _wikiEngineRenderer; + private WikiGroupServiceConfiguration _wikiGroupServiceConfiguration; + private WikiNodeLocalService _wikiNodeLocalService; + private WikiPageLocalService _wikiPageLocalService; + + @Reference(unbind = "-") + protected void setWikiEngineRenderer( + WikiEngineRenderer wikiEngineRenderer) { + + _wikiEngineRenderer = wikiEngineRenderer; + } + + @Reference(unbind = "-") + protected void setWikiGroupServiceConfiguration( + WikiGroupServiceConfiguration wikiGroupServiceConfiguration) { + + _wikiGroupServiceConfiguration = wikiGroupServiceConfiguration; + } + + @Reference(unbind = "-") + protected void setWikiNodeLocalService(WikiNodeLocalService wikiNodeLocalService) { + _wikiNodeLocalService = wikiNodeLocalService; + } + + @Reference(unbind = "-") + protected void setWikiPageLocalService(WikiPageLocalService wikiPageLocalService) { + _wikiPageLocalService = wikiPageLocalService; + } } diff --git a/src/main/resources/META-INF/resources/blogs.jsp b/src/main/resources/META-INF/resources/blogs.jsp index 5b1cae7..021efe2 100644 --- a/src/main/resources/META-INF/resources/blogs.jsp +++ b/src/main/resources/META-INF/resources/blogs.jsp @@ -1,147 +1,150 @@ <%@ include file="/init.jsp" %> -
+
- - +
+
+ - - <%@ include file="/command_select.jspf" %> + + <%@ include file="/command_select.jspf" %> - - - - + + + + -