List of usage examples for com.liferay.portal.kernel.util StringUtil merge
public static String merge(short[] array, String delimiter)
From source file:com.idetronic.subur.service.impl.ExpertiseLocalServiceImpl.java
License:Open Source License
protected void validate(String name) throws PortalException { if (!SuburAssetUtil.isValidWord(name)) { throw new ExpertiseException(StringUtil.merge(SuburAssetUtil.INVALID_CHARACTERS, StringPool.SPACE), ExpertiseException.INVALID_CHARACTER); }/*from w ww . java 2 s. c o m*/ }
From source file:com.idetronic.subur.service.impl.ResearchInterestLocalServiceImpl.java
License:Open Source License
protected void validate(String name) throws PortalException { if (!SuburAssetUtil.isValidWord(name)) { throw new ResearchInterestException( StringUtil.merge(SuburAssetUtil.INVALID_CHARACTERS, StringPool.SPACE), ResearchInterestException.INVALID_CHARACTER); }//from ww w.jav a2 s. c o m }
From source file:com.liferay.akismet.moderation.portlet.ModerationPortlet.java
License:Open Source License
public void markNotSpamWikiPages(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); checkWikiPagePermission(themeDisplay.getScopeGroupId()); long[] wikiPageIds = ParamUtil.getLongValues(actionRequest, "notSpamWikiPageIds"); List<String> wikiPageLinks = new ArrayList<String>(); for (long wikiPageId : wikiPageIds) { WikiPage wikiPage = WikiPageLocalServiceUtil.getPageByPageId(wikiPageId); WikiPage latestVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), false); String latestContent = null; if (latestVersionWikiPage != null) { latestContent = latestVersionWikiPage.getContent(); }//from w w w.j a va 2s .com WikiPage previousVersionWikiPage = AkismetUtil.getWikiPage(wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), true); String previousContent = null; if (previousVersionWikiPage != null) { previousContent = previousVersionWikiPage.getContent(); } // Selected version wikiPage.setStatus(WorkflowConstants.STATUS_APPROVED); wikiPage.setSummary(StringPool.BLANK); wikiPage = WikiPageLocalServiceUtil.updateWikiPage(wikiPage); // Latest version if ((latestContent != null) && ((previousContent == null) || latestContent.equals(previousContent))) { ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest); WikiPageLocalServiceUtil.revertPage(themeDisplay.getUserId(), wikiPage.getNodeId(), wikiPage.getTitle(), wikiPage.getVersion(), serviceContext); } else { StringBundler sb = new StringBundler(5); sb.append("<a href=\""); long plid = PortalUtil.getPlidFromPortletId(wikiPage.getGroupId(), PortletKeys.WIKI); LiferayPortletURL liferayPortletURL = PortletURLFactoryUtil.create(actionRequest, PortletKeys.WIKI, plid, PortletRequest.RENDER_PHASE); WikiNode wikiNode = wikiPage.getNode(); liferayPortletURL.setParameter("struts_action", "/wiki/view"); liferayPortletURL.setParameter("nodeName", wikiNode.getName()); liferayPortletURL.setParameter("title", wikiPage.getTitle()); liferayPortletURL.setParameter("version", String.valueOf(wikiPage.getVersion())); sb.append(liferayPortletURL.toString()); sb.append("\" target=\"_blank\">"); sb.append(HtmlUtil.escape(wikiPage.getTitle())); sb.append("</a>"); wikiPageLinks.add(sb.toString()); } // Akismet if (AkismetUtil.isWikiEnabled(wikiPage.getCompanyId())) { AkismetUtil.submitHam(wikiPage); } } if (!wikiPageLinks.isEmpty()) { SessionMessages.add(actionRequest, "anotherUserHasMadeChangesToThesePages", StringUtil.merge(wikiPageLinks, "<br />")); addSuccessMessage(actionRequest, actionResponse); super.sendRedirect(actionRequest, actionResponse); } }
From source file:com.liferay.asset.categories.navigation.web.internal.exportimport.portlet.preferences.processor.AssetCategoriesNavigationPortletPreferencesProcessor.java
License:Open Source License
@Override protected String getExportPortletPreferencesValue(PortletDataContext portletDataContext, Portlet portlet, String className, long primaryKeyLong) throws Exception { String uuid = null;//from w w w. j a v a 2s . c o m long groupId = 0; Element rootElement = portletDataContext.getExportDataRootElement(); if (className.equals(AssetVocabulary.class.getName())) { AssetVocabulary assetVocabulary = _assetVocabularyLocalService.fetchAssetVocabulary(primaryKeyLong); if (assetVocabulary != null) { uuid = assetVocabulary.getUuid(); groupId = assetVocabulary.getGroupId(); portletDataContext.addReferenceElement(portlet, rootElement, assetVocabulary, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } if (Validator.isNull(uuid)) { return null; } return StringUtil.merge(new Object[] { uuid, groupId }, StringPool.POUND); }
From source file:com.liferay.asset.publisher.web.internal.exportimport.portlet.preferences.processor.AssetPublisherExportImportPortletPreferencesProcessor.java
License:Open Source License
@Override protected String getExportPortletPreferencesValue(PortletDataContext portletDataContext, Portlet portlet, String className, long primaryKeyLong) throws Exception { String uuid = null;/*ww w. j ava 2 s .c o m*/ long groupId = 0L; Element rootElement = portletDataContext.getExportDataRootElement(); if (className.equals(AssetCategory.class.getName())) { AssetCategory assetCategory = _assetCategoryLocalService.fetchCategory(primaryKeyLong); if (assetCategory != null) { uuid = assetCategory.getUuid(); groupId = assetCategory.getGroupId(); portletDataContext.addReferenceElement(portlet, rootElement, assetCategory, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } else if (className.equals(AssetVocabulary.class.getName())) { AssetVocabulary assetVocabulary = _assetVocabularyLocalService.fetchAssetVocabulary(primaryKeyLong); if (assetVocabulary != null) { uuid = assetVocabulary.getUuid(); groupId = assetVocabulary.getGroupId(); portletDataContext.addReferenceElement(portlet, rootElement, assetVocabulary, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } else if (className.equals(DDMStructure.class.getName())) { DDMStructure ddmStructure = _ddmStructureLocalService.fetchStructure(primaryKeyLong); if (ddmStructure != null) { uuid = ddmStructure.getUuid(); groupId = ddmStructure.getGroupId(); portletDataContext.addReferenceElement(portlet, rootElement, ddmStructure, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } else if (className.equals(DLFileEntryType.class.getName())) { DLFileEntryType dlFileEntryType = _dlFileEntryTypeLocalService.fetchFileEntryType(primaryKeyLong); if (dlFileEntryType != null) { uuid = dlFileEntryType.getUuid(); groupId = dlFileEntryType.getGroupId(); portletDataContext.addReferenceElement(portlet, rootElement, dlFileEntryType, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } else if (className.equals(Organization.class.getName())) { Organization organization = _organizationLocalService.fetchOrganization(primaryKeyLong); if (organization != null) { uuid = organization.getUuid(); portletDataContext.addReferenceElement(portlet, rootElement, organization, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true); } } if (Validator.isNull(uuid)) { return null; } return StringUtil.merge(new Object[] { uuid, groupId }, StringPool.POUND); }
From source file:com.liferay.calendar.portlet.CalendarPortlet.java
License:Open Source License
protected void serveCalendarResources(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); String keywords = ParamUtil.getString(resourceRequest, "keywords"); JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); long classNameId = PortalUtil.getClassNameId(CalendarResource.class); List<CalendarResource> calendarResources = CalendarResourceServiceUtil.search(themeDisplay.getCompanyId(), new long[] { themeDisplay.getCompanyGroupId(), themeDisplay.getScopeGroupId() }, new long[] { classNameId }, keywords, true, true, 0, SearchContainer.DEFAULT_DELTA, new CalendarResourceNameComparator()); for (CalendarResource calendarResource : calendarResources) { addCalendarJSONObject(resourceRequest, jsonArray, calendarResource.getClassNameId(), calendarResource.getClassPK()); }/*from w ww .j a v a2 s .c o m*/ long groupClassNameId = PortalUtil.getClassNameId(Group.class); List<CalendarResource> companyCalendarResources = CalendarResourceServiceUtil.search( themeDisplay.getCompanyId(), new long[] { themeDisplay.getCompanyGroupId() }, new long[] { groupClassNameId }, keywords, true, true, 0, SearchContainer.DEFAULT_DELTA, new CalendarResourceNameComparator()); for (CalendarResource calendarResource : companyCalendarResources) { addCalendarJSONObject(resourceRequest, jsonArray, calendarResource.getClassNameId(), calendarResource.getClassPK()); } String name = StringUtil.merge(CustomSQLUtil.keywords(keywords), StringPool.BLANK); LinkedHashMap<String, Object> params = new LinkedHashMap<String, Object>(); params.put("usersGroups", themeDisplay.getUserId()); List<Group> groups = GroupLocalServiceUtil.search(themeDisplay.getCompanyId(), name, null, params, true, 0, SearchContainer.DEFAULT_DELTA); for (Group group : groups) { addCalendarJSONObject(resourceRequest, jsonArray, groupClassNameId, group.getGroupId()); } long userClassNameId = PortalUtil.getClassNameId(User.class); List<User> users = UserLocalServiceUtil.search(themeDisplay.getCompanyId(), keywords, 0, null, 0, SearchContainer.DEFAULT_DELTA, new UserFirstNameComparator()); for (User user : users) { addCalendarJSONObject(resourceRequest, jsonArray, userClassNameId, user.getUserId()); } writeJSON(resourceRequest, resourceResponse, jsonArray); }
From source file:com.liferay.calendar.web.internal.portlet.CalendarPortlet.java
License:Open Source License
protected void serveCalendarResources(ResourceRequest resourceRequest, ResourceResponse resourceResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY); String keywords = ParamUtil.getString(resourceRequest, "keywords"); Set<Calendar> calendarsSet = new LinkedHashSet<>(); Hits hits = search(themeDisplay, keywords); for (Document document : hits.getDocs()) { long calendarId = GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)); Calendar calendar = _calendarService.getCalendar(calendarId); CalendarResource calendarResource = calendar.getCalendarResource(); if (calendarResource.isActive()) { Group group = _groupLocalService.getGroup(calendar.getGroupId()); if (group.hasStagingGroup()) { Group stagingGroup = group.getStagingGroup(); long stagingGroupId = stagingGroup.getGroupId(); if (stagingGroupId == themeDisplay.getScopeGroupId()) { calendar = _calendarLocalService.fetchCalendarByUuidAndGroupId(calendar.getUuid(), stagingGroupId); }//from w w w . j a v a2 s .co m } calendarsSet.add(calendar); } } String name = StringUtil.merge(CustomSQLUtil.keywords(keywords), StringPool.BLANK); LinkedHashMap<String, Object> params = new LinkedHashMap<>(); params.put("usersGroups", themeDisplay.getUserId()); List<Group> groups = _groupLocalService.search(themeDisplay.getCompanyId(), name, null, params, true, 0, SearchContainer.DEFAULT_DELTA); for (Group group : groups) { long groupClassNameId = _portal.getClassNameId(Group.class); addCalendar(resourceRequest, calendarsSet, groupClassNameId, group.getGroupId()); } long userClassNameId = _portal.getClassNameId(User.class); List<User> users = _userLocalService.search(themeDisplay.getCompanyId(), keywords, 0, null, 0, SearchContainer.DEFAULT_DELTA, new UserFirstNameComparator()); for (User user : users) { addCalendar(resourceRequest, calendarsSet, userClassNameId, user.getUserId()); } JSONArray jsonArray = JSONFactoryUtil.createJSONArray(); for (Calendar calendar : calendarsSet) { JSONObject jsonObject = CalendarUtil.toCalendarJSONObject(themeDisplay, calendar); jsonArray.put(jsonObject); } writeJSON(resourceRequest, resourceResponse, jsonArray); }
From source file:com.liferay.configuration.admin.web.internal.model.ConfigurationModel.java
License:Open Source License
protected String getLabelAttributeValue() { String factoryInstanceLabelAttribute = getLabelAttribute(); String value = null;// w w w. jav a2 s . c o m if (Validator.isNotNull(factoryInstanceLabelAttribute)) { Dictionary<String, Object> properties = _configuration.getProperties(); Object valueObj = properties.get(factoryInstanceLabelAttribute); if (valueObj instanceof Object[]) { value = StringUtil.merge((Object[]) valueObj, StringPool.COMMA_AND_SPACE); } else { value = String.valueOf(valueObj); } } return value; }
From source file:com.liferay.document.library.internal.verify.DLServiceVerifyProcess.java
License:Open Source License
protected void checkFileVersionMimeTypes(final String[] originalMimeTypes) throws Exception { ActionableDynamicQuery actionableDynamicQuery = _dlFileVersionLocalService.getActionableDynamicQuery(); actionableDynamicQuery.setAddCriteriaMethod(new ActionableDynamicQuery.AddCriteriaMethod() { @Override//from www . j av a2 s . c o m public void addCriteria(DynamicQuery dynamicQuery) { Criterion criterion = RestrictionsFactoryUtil.eq("mimeType", originalMimeTypes[0]); for (int i = 1; i < originalMimeTypes.length; i++) { criterion = RestrictionsFactoryUtil.or(criterion, RestrictionsFactoryUtil.eq("mimeType", originalMimeTypes[i])); } dynamicQuery.add(criterion); } }); actionableDynamicQuery .setPerformActionMethod(new ActionableDynamicQuery.PerformActionMethod<DLFileVersion>() { @Override public void performAction(DLFileVersion dlFileVersion) { InputStream inputStream = null; try { inputStream = _dlFileEntryLocalService.getFileAsStream(dlFileVersion.getFileEntryId(), dlFileVersion.getVersion(), false); } catch (Exception e) { if (_log.isWarnEnabled()) { DLFileEntry dlFileEntry = _dlFileEntryLocalService .fetchDLFileEntry(dlFileVersion.getFileEntryId()); if (dlFileEntry == null) { _log.warn("Unable to find file entry associated " + "with file version " + dlFileVersion.getFileVersionId(), e); } else { StringBundler sb = new StringBundler(4); sb.append("Unable to find file version "); sb.append(dlFileVersion.getVersion()); sb.append(" for file entry "); sb.append(dlFileEntry.getName()); _log.warn(sb.toString(), e); } } return; } String title = DLUtil.getTitleWithExtension(dlFileVersion.getTitle(), dlFileVersion.getExtension()); String mimeType = getMimeType(inputStream, title); if (mimeType.equals(dlFileVersion.getMimeType())) { return; } dlFileVersion.setMimeType(mimeType); _dlFileVersionLocalService.updateDLFileVersion(dlFileVersion); try { DLFileEntry dlFileEntry = dlFileVersion.getFileEntry(); if (Objects.equals(dlFileEntry.getVersion(), dlFileVersion.getVersion())) { dlFileEntry.setMimeType(mimeType); _dlFileEntryLocalService.updateDLFileEntry(dlFileEntry); } } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn("Unable to get file entry " + dlFileVersion.getFileEntryId(), pe); } } } }); if (_log.isDebugEnabled()) { long count = actionableDynamicQuery.performCount(); _log.debug("Processing " + count + " file versions with mime types: " + StringUtil.merge(originalMimeTypes, StringPool.COMMA)); } actionableDynamicQuery.performActions(); }
From source file:com.liferay.document.library.web.internal.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public Status makeCollection(WebDAVRequest webDAVRequest) throws WebDAVException { try {//w w w. j a v a2 s .com HttpServletRequest request = webDAVRequest.getHttpServletRequest(); if (request.getContentLength() > 0) { return new Status(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE); } String[] pathArray = webDAVRequest.getPathArray(); long companyId = webDAVRequest.getCompanyId(); long groupId = webDAVRequest.getGroupId(); long parentFolderId = getParentFolderId(companyId, pathArray); String name = WebDAVUtil.getResourceName(pathArray); String description = StringPool.BLANK; ServiceContext serviceContext = new ServiceContext(); serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId)); serviceContext.setAddGuestPermissions(true); _dlAppService.addFolder(groupId, parentFolderId, name, description, serviceContext); String location = StringUtil.merge(pathArray, StringPool.SLASH); return new Status(location, HttpServletResponse.SC_CREATED); } catch (DuplicateFolderNameException dfne) { if (_log.isDebugEnabled()) { _log.debug(dfne, dfne); } return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } catch (DuplicateFileEntryException dfee) { if (_log.isDebugEnabled()) { _log.debug(dfee, dfee); } return new Status(HttpServletResponse.SC_METHOD_NOT_ALLOWED); } catch (NoSuchFolderException nsfe) { if (_log.isDebugEnabled()) { _log.debug(nsfe, nsfe); } return new Status(HttpServletResponse.SC_CONFLICT); } catch (PrincipalException pe) { if (_log.isDebugEnabled()) { _log.debug(pe, pe); } return new Status(HttpServletResponse.SC_FORBIDDEN); } catch (Exception e) { throw new WebDAVException(e); } }