List of usage examples for com.liferay.portal.kernel.util StringPool SLASH
String SLASH
To view the source code for com.liferay.portal.kernel.util StringPool SLASH.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java
License:Open Source License
@Override public int putResource(WebDAVRequest webDavRequest) throws WebDAVException { File file = null;/*from w ww .ja v a 2s .c om*/ try { HttpServletRequest request = webDavRequest.getHttpServletRequest(); String[] pathArray = webDavRequest.getPathArray(); long companyId = webDavRequest.getCompanyId(); long groupId = webDavRequest.getGroupId(); long parentFolderId = getParentFolderId(companyId, pathArray); String title = WebDAVUtil.getResourceName(pathArray); String description = StringPool.BLANK; String changeLog = StringPool.BLANK; ServiceContext serviceContext = ServiceContextFactory.getInstance(request); serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId)); serviceContext.setAddGuestPermissions(true); String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE), ContentTypes.APPLICATION_OCTET_STREAM); String extension = FileUtil.getExtension(title); file = FileUtil.createTempFile(extension); FileUtil.write(file, request.getInputStream()); if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) { contentType = MimeTypesUtil.getContentType(file, title); } try { FileEntry fileEntry = DLAppServiceUtil.getFileEntry(groupId, parentFolderId, title); if (!hasLock(fileEntry, webDavRequest.getLockUuid()) && (fileEntry.getLock() != null)) { return WebDAVUtil.SC_LOCKED; } long fileEntryId = fileEntry.getFileEntryId(); description = fileEntry.getDescription(); String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(), fileEntry.getFileEntryId()); serviceContext.setAssetTagNames(assetTagNames); DLAppServiceUtil.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog, false, file, serviceContext); } catch (NoSuchFileEntryException nsfee) { if (file.length() == 0) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType, title, description, changeLog, file, serviceContext); } if (_log.isInfoEnabled()) { _log.info("Added " + StringUtil.merge(pathArray, StringPool.SLASH)); } return HttpServletResponse.SC_CREATED; } catch (PrincipalException pe) { return HttpServletResponse.SC_FORBIDDEN; } catch (NoSuchFolderException nsfe) { return HttpServletResponse.SC_CONFLICT; } catch (PortalException pe) { if (_log.isWarnEnabled()) { _log.warn(pe, pe); } return HttpServletResponse.SC_CONFLICT; } catch (Exception e) { throw new WebDAVException(e); } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.dynamicdatalists.util.DDLImpl.java
License:Open Source License
public String storeRecordFieldFile(DDLRecord record, String fieldName, InputStream inputStream) throws Exception { DDLRecordVersion recordVersion = record.getLatestRecordVersion(); String dirName = getRecordFileUploadPath(record) + StringPool.SLASH + recordVersion.getVersion(); try {/*from w ww. j a v a 2 s .c o m*/ DLStoreUtil.addDirectory(record.getCompanyId(), CompanyConstants.SYSTEM, dirName); } catch (DuplicateDirectoryException dde) { } String fileName = dirName + StringPool.SLASH + fieldName; try { DLStoreUtil.addFile(record.getCompanyId(), CompanyConstants.SYSTEM, fileName, inputStream); } catch (DuplicateFileException dfe) { } return fileName; }
From source file:com.liferay.portlet.dynamicdatamapping.service.impl.DDMStructureLocalServiceImpl.java
License:Open Source License
protected void validate(List<Element> elements, Set<String> names) throws PortalException { for (Element element : elements) { String elementName = element.getName(); if (elementName.equals("meta-data")) { continue; }/* w ww . jav a 2 s . c om*/ String name = element.attributeValue("name", StringPool.BLANK); String type = element.attributeValue("type", StringPool.BLANK); if (Validator.isNull(name) || name.startsWith(DDMStructureConstants.XSD_NAME_RESERVED)) { throw new StructureXsdException(); } char[] charArray = name.toCharArray(); for (int i = 0; i < charArray.length; i++) { if (!Character.isLetterOrDigit(charArray[i]) && (charArray[i] != CharPool.DASH) && (charArray[i] != CharPool.UNDERLINE)) { throw new StructureXsdException(); } } String path = name; Element parentElement = element.getParent(); while (!parentElement.isRootElement()) { path = parentElement.attributeValue("name", StringPool.BLANK) + StringPool.SLASH + path; parentElement = parentElement.getParent(); } path = path.toLowerCase(); if (names.contains(path)) { throw new StructureDuplicateElementException(); } else { names.add(path); } if (Validator.isNull(type)) { throw new StructureXsdException(); } validate(element.elements(), names); } }
From source file:com.liferay.portlet.InvokerPortletImpl.java
License:Open Source License
protected void invoke(LiferayPortletRequest portletRequest, LiferayPortletResponse portletResponse, String lifecycle, List<? extends PortletFilter> filters) throws IOException, PortletException { FilterChain filterChain = new FilterChainImpl(_portlet, filters); if (_portletConfigImpl.isWARFile()) { String invokerPortletName = _portletConfigImpl.getInitParameter(INIT_INVOKER_PORTLET_NAME); if (invokerPortletName == null) { invokerPortletName = _portletConfigImpl.getPortletName(); }/*from w ww .java 2 s . c o m*/ String path = StringPool.SLASH + invokerPortletName + "/invoke"; RequestDispatcher requestDispatcher = _portletContextImpl.getServletContext() .getRequestDispatcher(path); HttpServletRequest request = portletRequest.getHttpServletRequest(); HttpServletResponse response = portletResponse.getHttpServletResponse(); request.setAttribute(JavaConstants.JAVAX_PORTLET_PORTLET, _portlet); request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle); request.setAttribute(PortletServlet.PORTLET_SERVLET_FILTER_CHAIN, filterChain); try { // Resource phase must be a forward because includes do not // allow you to specify the content type or headers if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) { requestDispatcher.forward(request, response); } else { requestDispatcher.include(request, response); } } catch (ServletException se) { Throwable cause = se.getRootCause(); if (cause instanceof PortletException) { throw (PortletException) cause; } throw new PortletException(cause); } } else { PortletFilterUtil.doFilter(portletRequest, portletResponse, lifecycle, filterChain); } portletResponse.transferMarkupHeadElements(); Map<String, String[]> properties = portletResponse.getProperties(); if ((properties != null) && (properties.size() > 0)) { if (_expCache != null) { String[] expCache = properties.get(RenderResponse.EXPIRATION_CACHE); if ((expCache != null) && (expCache.length > 0) && (expCache[0] != null)) { _expCache = new Integer(GetterUtil.getInteger(expCache[0])); } } } }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
public static String getArticlePath(PortletDataContext portletDataContext, JournalArticle article) throws Exception { StringBundler sb = new StringBundler(8); sb.append(portletDataContext.getPortletPath(PortletKeys.JOURNAL)); sb.append("/articles/"); sb.append(article.getArticleResourceUuid()); sb.append(StringPool.SLASH); sb.append(article.getVersion());//from w w w.ja v a 2 s .c o m sb.append(StringPool.SLASH); sb.append("article.xml"); return sb.toString(); }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
public static void importArticle(PortletDataContext portletDataContext, Element articleElement) throws Exception { String path = articleElement.attributeValue("path"); if (!portletDataContext.isPathNotProcessed(path)) { return;/*from www. j a v a 2 s . c o m*/ } JournalArticle article = (JournalArticle) portletDataContext.getZipEntryAsObject(path); prepareLanguagesForImport(article); long userId = portletDataContext.getUserId(article.getUserUuid()); JournalCreationStrategy creationStrategy = JournalCreationStrategyFactory.getInstance(); long authorId = creationStrategy.getAuthorUserId(portletDataContext, article); if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) { userId = authorId; } User user = UserLocalServiceUtil.getUser(userId); String articleId = article.getArticleId(); boolean autoArticleId = false; Map<String, String> articleIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalArticle.class + ".articleId"); String newArticleId = articleIds.get(articleId); // ======= Start of change ============ if (Validator.isNotNull(newArticleId)) { // A sibling of a different version was already assigned a new // article id articleId = newArticleId; } // =======end of change================ String content = article.getContent(); content = importDLFileEntries(portletDataContext, articleElement, content); Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId()); content = StringUtil.replace(content, "@data_handler_group_friendly_url@", group.getFriendlyURL()); content = importLinksToLayout(portletDataContext, content); article.setContent(content); String newContent = creationStrategy.getTransformedContent(portletDataContext, article); if (!StringUtils.equals(JournalCreationStrategy.ARTICLE_CONTENT_UNCHANGED, newContent)) { article.setContent(newContent); } Map<String, String> structureIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalStructure.class); String parentStructureId = MapUtil.getString(structureIds, article.getStructureId(), article.getStructureId()); Map<String, String> templateIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalTemplate.class); String parentTemplateId = MapUtil.getString(templateIds, article.getTemplateId(), article.getTemplateId()); Date displayDate = article.getDisplayDate(); int displayDateMonth = 0; int displayDateDay = 0; int displayDateYear = 0; int displayDateHour = 0; int displayDateMinute = 0; if (displayDate != null) { Calendar displayCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); displayCal.setTime(displayDate); displayDateMonth = displayCal.get(Calendar.MONTH); displayDateDay = displayCal.get(Calendar.DATE); displayDateYear = displayCal.get(Calendar.YEAR); displayDateHour = displayCal.get(Calendar.HOUR); displayDateMinute = displayCal.get(Calendar.MINUTE); if (displayCal.get(Calendar.AM_PM) == Calendar.PM) { displayDateHour += 12; } } Date expirationDate = article.getExpirationDate(); int expirationDateMonth = 0; int expirationDateDay = 0; int expirationDateYear = 0; int expirationDateHour = 0; int expirationDateMinute = 0; boolean neverExpire = true; if (expirationDate != null) { Calendar expirationCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); expirationCal.setTime(expirationDate); expirationDateMonth = expirationCal.get(Calendar.MONTH); expirationDateDay = expirationCal.get(Calendar.DATE); expirationDateYear = expirationCal.get(Calendar.YEAR); expirationDateHour = expirationCal.get(Calendar.HOUR); expirationDateMinute = expirationCal.get(Calendar.MINUTE); neverExpire = false; if (expirationCal.get(Calendar.AM_PM) == Calendar.PM) { expirationDateHour += 12; } } Date reviewDate = article.getReviewDate(); int reviewDateMonth = 0; int reviewDateDay = 0; int reviewDateYear = 0; int reviewDateHour = 0; int reviewDateMinute = 0; boolean neverReview = true; if (reviewDate != null) { Calendar reviewCal = CalendarFactoryUtil.getCalendar(user.getTimeZone()); reviewCal.setTime(reviewDate); reviewDateMonth = reviewCal.get(Calendar.MONTH); reviewDateDay = reviewCal.get(Calendar.DATE); reviewDateYear = reviewCal.get(Calendar.YEAR); reviewDateHour = reviewCal.get(Calendar.HOUR); reviewDateMinute = reviewCal.get(Calendar.MINUTE); neverReview = false; if (reviewCal.get(Calendar.AM_PM) == Calendar.PM) { reviewDateHour += 12; } } long structurePrimaryKey = 0; if (Validator.isNotNull(article.getStructureId())) { String structureUuid = articleElement.attributeValue("structure-uuid"); JournalStructure existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid, portletDataContext.getScopeGroupId()); if (existingStructure == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); existingStructure = JournalStructureUtil.fetchByUUID_G(structureUuid, companyGroupId); } if (existingStructure == null) { String newStructureId = structureIds.get(article.getStructureId()); if (Validator.isNotNull(newStructureId)) { existingStructure = JournalStructureUtil.fetchByG_S(portletDataContext.getScopeGroupId(), String.valueOf(newStructureId)); } if (existingStructure == null) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(); sb.append("Structure "); sb.append(article.getStructureId()); sb.append(" is missing for article "); sb.append(article.getArticleId()); sb.append(", skipping this article."); _log.warn(sb.toString()); } return; } } structurePrimaryKey = existingStructure.getPrimaryKey(); parentStructureId = existingStructure.getStructureId(); } if (Validator.isNotNull(article.getTemplateId())) { String templateUuid = articleElement.attributeValue("template-uuid"); JournalTemplate existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid, portletDataContext.getScopeGroupId()); if (existingTemplate == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); existingTemplate = JournalTemplateUtil.fetchByUUID_G(templateUuid, companyGroupId); } if (existingTemplate == null) { String newTemplateId = templateIds.get(article.getTemplateId()); if (Validator.isNotNull(newTemplateId)) { existingTemplate = JournalTemplateUtil.fetchByG_T(portletDataContext.getScopeGroupId(), newTemplateId); } if (existingTemplate == null) { if (_log.isWarnEnabled()) { StringBundler sb = new StringBundler(); sb.append("Template "); sb.append(article.getTemplateId()); sb.append(" is missing for article "); sb.append(article.getArticleId()); sb.append(", skipping this article."); _log.warn(sb.toString()); } return; } } parentTemplateId = existingTemplate.getTemplateId(); } File smallFile = null; String smallImagePath = articleElement.attributeValue("small-image-path"); if (article.isSmallImage() && Validator.isNotNull(smallImagePath)) { byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath); smallFile = FileUtil.createTempFile(article.getSmallImageType()); FileUtil.write(smallFile, bytes); } Map<String, byte[]> images = new HashMap<String, byte[]>(); String imagePath = articleElement.attributeValue("image-path"); if (portletDataContext.getBooleanParameter(_NAMESPACE, "images") && Validator.isNotNull(imagePath)) { List<String> imageFiles = portletDataContext.getZipFolderEntries(imagePath); for (String imageFile : imageFiles) { String fileName = imageFile; if (fileName.contains(StringPool.SLASH)) { fileName = fileName.substring(fileName.lastIndexOf(CharPool.SLASH) + 1); } if (fileName.endsWith(".xml")) { continue; } int pos = fileName.lastIndexOf(CharPool.PERIOD); if (pos != -1) { fileName = fileName.substring(0, pos); } images.put(fileName, portletDataContext.getZipEntryAsByteArray(imageFile)); } } String articleURL = null; boolean addGroupPermissions = creationStrategy.addGroupPermissions(portletDataContext, article); boolean addGuestPermissions = creationStrategy.addGuestPermissions(portletDataContext, article); ServiceContext serviceContext = portletDataContext.createServiceContext(articleElement, article, _NAMESPACE); serviceContext.setAddGroupPermissions(addGroupPermissions); serviceContext.setAddGuestPermissions(addGuestPermissions); serviceContext.setAttribute("imported", Boolean.TRUE.toString()); if (article.getStatus() != WorkflowConstants.STATUS_APPROVED) { serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT); } JournalArticle importedArticle = null; String articleResourceUuid = articleElement.attributeValue("article-resource-uuid"); if (portletDataContext.isDataStrategyMirror()) { JournalArticleResource articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid, portletDataContext.getScopeGroupId()); if (articleResource == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); articleResource = JournalArticleResourceUtil.fetchByUUID_G(articleResourceUuid, companyGroupId); } //Modification start if (articleResource == null) { articleResource = JournalArticleResourceUtil.fetchByG_A(portletDataContext.getScopeGroupId(), articleId); } //Modification end serviceContext.setUuid(articleResourceUuid); JournalArticle existingArticle = null; if (articleResource != null) { try { existingArticle = JournalArticleLocalServiceUtil.getLatestArticle( articleResource.getResourcePrimKey(), WorkflowConstants.STATUS_ANY, false); } catch (NoSuchArticleException nsae) { } } if (existingArticle == null) { existingArticle = JournalArticleUtil.fetchByG_A_V(portletDataContext.getScopeGroupId(), newArticleId, article.getVersion()); } if (existingArticle == null) { importedArticle = JournalArticleLocalServiceUtil.addArticle(userId, portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } else { importedArticle = JournalArticleLocalServiceUtil.updateArticle(userId, existingArticle.getGroupId(), existingArticle.getArticleId(), existingArticle.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } } else { importedArticle = JournalArticleLocalServiceUtil.addArticle(userId, portletDataContext.getScopeGroupId(), article.getClassNameId(), structurePrimaryKey, articleId, autoArticleId, article.getVersion(), article.getTitleMap(), article.getDescriptionMap(), article.getContent(), article.getType(), parentStructureId, parentTemplateId, article.getLayoutUuid(), displayDateMonth, displayDateDay, displayDateYear, displayDateHour, displayDateMinute, expirationDateMonth, expirationDateDay, expirationDateYear, expirationDateHour, expirationDateMinute, neverExpire, reviewDateMonth, reviewDateDay, reviewDateYear, reviewDateHour, reviewDateMinute, neverReview, article.isIndexable(), article.isSmallImage(), article.getSmallImageURL(), smallFile, images, articleURL, serviceContext); } if (smallFile != null) { smallFile.delete(); } portletDataContext.importClassedModel(article, importedArticle, _NAMESPACE); if (Validator.isNull(newArticleId)) { articleIds.put(article.getArticleId(), importedArticle.getArticleId()); } Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); if (importedArticle.getGroupId() == companyGroup.getGroupId()) { portletDataContext.addCompanyReference(JournalArticle.class, articleId); } if (!articleId.equals(importedArticle.getArticleId())) { if (_log.isWarnEnabled()) { _log.warn("An article with the ID " + articleId + " already " + "exists. The new generated ID is " + importedArticle.getArticleId()); } } }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static String exportDLFileEntries(PortletDataContext portletDataContext, Element dlFileEntryTypesElement, Element dlFoldersElement, Element dlFileEntriesElement, Element dlFileRanksElement, Element dlRepositoriesElement, Element dlRepositoryEntriesElement, Element entityElement, String content, boolean checkDateRange) throws Exception { Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getGroupId()); if (group.isStagingGroup()) { group = group.getLiveGroup();// w w w. ja va 2 s .c o m } if (group.isStaged() && !group.isStagedRemotely() && !group.isStagedPortlet(PortletKeys.DOCUMENT_LIBRARY)) { return content; } StringBuilder sb = new StringBuilder(content); int beginPos = content.length(); int currentLocation = -1; while (true) { currentLocation = content.lastIndexOf("/c/document_library/get_file?", beginPos); if (currentLocation == -1) { currentLocation = content.lastIndexOf("/documents/", beginPos); } if (currentLocation == -1) { return sb.toString(); } beginPos = currentLocation; int endPos1 = content.indexOf(CharPool.APOSTROPHE, beginPos); int endPos2 = content.indexOf(CharPool.CLOSE_BRACKET, beginPos); int endPos3 = content.indexOf(CharPool.CLOSE_CURLY_BRACE, beginPos); int endPos4 = content.indexOf(CharPool.CLOSE_PARENTHESIS, beginPos); int endPos5 = content.indexOf(CharPool.LESS_THAN, beginPos); int endPos6 = content.indexOf(CharPool.QUESTION, beginPos); int endPos7 = content.indexOf(CharPool.QUOTE, beginPos); int endPos8 = content.indexOf(CharPool.SPACE, beginPos); int endPos = endPos1; if ((endPos == -1) || ((endPos2 != -1) && (endPos2 < endPos))) { endPos = endPos2; } if ((endPos == -1) || ((endPos3 != -1) && (endPos3 < endPos))) { endPos = endPos3; } if ((endPos == -1) || ((endPos4 != -1) && (endPos4 < endPos))) { endPos = endPos4; } if ((endPos == -1) || ((endPos5 != -1) && (endPos5 < endPos))) { endPos = endPos5; } if ((endPos == -1) || ((endPos6 != -1) && (endPos6 < endPos))) { endPos = endPos6; } if ((endPos == -1) || ((endPos7 != -1) && (endPos7 < endPos))) { endPos = endPos7; } if ((endPos == -1) || ((endPos8 != -1) && (endPos8 < endPos))) { endPos = endPos8; } if ((beginPos == -1) || (endPos == -1)) { break; } try { String oldParameters = content.substring(beginPos, endPos); while (oldParameters.contains(StringPool.AMPERSAND_ENCODED)) { oldParameters = oldParameters.replace(StringPool.AMPERSAND_ENCODED, StringPool.AMPERSAND); } Map<String, String[]> map = new HashMap<String, String[]>(); if (oldParameters.startsWith("/documents/")) { String[] pathArray = oldParameters.split(StringPool.SLASH); map.put("groupId", new String[] { pathArray[2] }); if (pathArray.length == 4) { map.put("uuid", new String[] { pathArray[3] }); } else if (pathArray.length == 5) { map.put("folderId", new String[] { pathArray[3] }); String name = HttpUtil.decodeURL(pathArray[4]); int pos = name.indexOf(StringPool.QUESTION); if (pos != -1) { name = name.substring(0, pos); } map.put("name", new String[] { name }); } else if (pathArray.length > 5) { String uuid = pathArray[5]; int pos = uuid.indexOf(StringPool.QUESTION); if (pos != -1) { uuid = uuid.substring(0, pos); } map.put("uuid", new String[] { uuid }); } } else { oldParameters = oldParameters.substring(oldParameters.indexOf(CharPool.QUESTION) + 1); map = HttpUtil.parameterMapFromString(oldParameters); } FileEntry fileEntry = null; String uuid = MapUtil.getString(map, "uuid"); if (Validator.isNotNull(uuid)) { String groupIdString = MapUtil.getString(map, "groupId"); long groupId = GetterUtil.getLong(groupIdString); if (groupIdString.equals("@group_id@")) { groupId = portletDataContext.getScopeGroupId(); } fileEntry = DLAppLocalServiceUtil.getFileEntryByUuidAndGroupId(uuid, groupId); } else { String folderIdString = MapUtil.getString(map, "folderId"); if (Validator.isNotNull(folderIdString)) { long folderId = GetterUtil.getLong(folderIdString); String name = MapUtil.getString(map, "name"); String groupIdString = MapUtil.getString(map, "groupId"); long groupId = GetterUtil.getLong(groupIdString); if (groupIdString.equals("@group_id@")) { groupId = portletDataContext.getScopeGroupId(); } fileEntry = DLAppLocalServiceUtil.getFileEntry(groupId, folderId, name); } } if (fileEntry == null) { beginPos--; continue; } DLPortletDataHandlerImpl.exportFileEntry(portletDataContext, dlFileEntryTypesElement, dlFoldersElement, dlFileEntriesElement, dlFileRanksElement, dlRepositoriesElement, dlRepositoryEntriesElement, fileEntry, checkDateRange); Element dlReferenceElement = entityElement.addElement("dl-reference"); dlReferenceElement.addAttribute("default-repository", String.valueOf(fileEntry.isDefaultRepository())); String path = null; if (fileEntry.isDefaultRepository()) { path = DLPortletDataHandlerImpl.getFileEntryPath(portletDataContext, fileEntry); } else { path = DLPortletDataHandlerImpl.getRepositoryEntryPath(portletDataContext, fileEntry.getFileEntryId()); } dlReferenceElement.addAttribute("path", path); String dlReference = "[$dl-reference=" + path + "$]"; sb.replace(beginPos, endPos, dlReference); } catch (Exception e) { if (_log.isDebugEnabled()) { _log.debug(e, e); } else if (_log.isWarnEnabled()) { _log.warn(e.getMessage()); } } beginPos--; } return sb.toString(); }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static void exportFeed(PortletDataContext portletDataContext, Element feedsElement, JournalFeed feed) throws Exception { if (!portletDataContext.isWithinDateRange(feed.getModifiedDate())) { return;/*w w w . j a va2 s .com*/ } String path = getFeedPath(portletDataContext, feed); if (!portletDataContext.isPathNotProcessed(path)) { return; } feed = (JournalFeed) feed.clone(); Element feedElement = feedsElement.addElement("feed"); Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId()); String newGroupFriendlyURL = group.getFriendlyURL().substring(1); String[] friendlyUrlParts = StringUtil.split(feed.getTargetLayoutFriendlyUrl(), '/'); String oldGroupFriendlyURL = friendlyUrlParts[2]; if (newGroupFriendlyURL.equals(oldGroupFriendlyURL)) { String targetLayoutFriendlyUrl = StringUtil.replaceFirst(feed.getTargetLayoutFriendlyUrl(), StringPool.SLASH + newGroupFriendlyURL + StringPool.SLASH, "/@data_handler_group_friendly_url@/"); feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl); } portletDataContext.addClassedModel(feedElement, path, feed, _NAMESPACE); }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static String getArticleImagePath(PortletDataContext portletDataContext, JournalArticle article) throws Exception { StringBundler sb = new StringBundler(6); sb.append(portletDataContext.getPortletPath(PortletKeys.JOURNAL)); sb.append("/articles/"); sb.append(article.getArticleResourceUuid()); sb.append(StringPool.SLASH); sb.append(article.getVersion());//from ww w . ja v a2 s.co m sb.append(StringPool.SLASH); return sb.toString(); }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
protected static String getArticleImagePath(PortletDataContext portletDataContext, JournalArticle article, JournalArticleImage articleImage, Image image) throws Exception { StringBundler sb = new StringBundler(13); sb.append(portletDataContext.getPortletPath(PortletKeys.JOURNAL)); sb.append("/articles/"); sb.append(article.getArticleResourceUuid()); sb.append(StringPool.SLASH); sb.append(article.getVersion());/* w w w . ja va 2 s. c o m*/ sb.append(StringPool.SLASH); sb.append(articleImage.getElInstanceId()); sb.append(StringPool.UNDERLINE); sb.append(articleImage.getElName()); if (Validator.isNotNull(articleImage.getLanguageId())) { sb.append(StringPool.UNDERLINE); sb.append(articleImage.getLanguageId()); } sb.append(StringPool.PERIOD); sb.append(image.getType()); return sb.toString(); }