List of usage examples for com.liferay.portal.kernel.util StringPool PERIOD
String PERIOD
To view the source code for com.liferay.portal.kernel.util StringPool PERIOD.
Click Source Link
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected String getThumbnailFilePath(long groupId, long fileEntryId, long fileVersionId, String thumbnailType, int index) { StringBundler sb = new StringBundler(5); sb.append(getPathSegment(groupId, fileEntryId, fileVersionId, false)); if (index != THUMBNAIL_INDEX_DEFAULT) { sb.append(StringPool.DASH);/* w w w .j a v a2 s . c om*/ sb.append(index); } if ((fileVersionId > 0) && Validator.isNotNull(thumbnailType)) { sb.append(StringPool.PERIOD); sb.append(thumbnailType); } return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.util.DLPreviewableProcessor.java
License:Open Source License
protected String getThumbnailTempFilePath(String id, String type) { StringBundler sb = new StringBundler(4); sb.append(THUMBNAIL_TMP_PATH);//from w ww . j a va 2 s. co m sb.append(id); if (Validator.isNotNull(type)) { sb.append(StringPool.PERIOD); sb.append(type); } return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.util.DocumentConversionUtil.java
License:Open Source License
public static String getFilePath(String id, String targetExtension) { StringBundler sb = new StringBundler(5); sb.append(SystemProperties.get(SystemProperties.TMP_DIR)); sb.append("/liferay/document_conversion/"); sb.append(id);/* w ww .j ava 2 s .c o m*/ sb.append(StringPool.PERIOD); sb.append(targetExtension); return sb.toString(); }
From source file:com.liferay.portlet.documentlibrary.util.DocumentConversionUtil.java
License:Open Source License
public static boolean isComparableVersion(String extension) { boolean enabled = false; String dotExtension = StringPool.PERIOD + extension; for (int i = 0; i < _COMPARABLE_FILE_EXTENSIONS.length; i++) { if (StringPool.STAR.equals(_COMPARABLE_FILE_EXTENSIONS[i]) || dotExtension.equals(_COMPARABLE_FILE_EXTENSIONS[i])) { enabled = true;/* ww w .j a v a2 s .c o m*/ break; } } if (!enabled) { return false; } if (extension.equals("css") || extension.equals("js") || extension.equals("htm") || extension.equals("html") || extension.equals("txt") || extension.equals("xml")) { return true; } try { if (isEnabled() && isConvertBeforeCompare(extension)) { return true; } } catch (Exception e) { if (_log.isErrorEnabled()) { _log.error(e, e); } } return false; }
From source file:com.liferay.portlet.documentlibrary.util.ImageProcessorImpl.java
License:Open Source License
private void _storeThumbnail(long companyId, long groupId, long fileEntryId, long fileVersionId, long custom1ImageId, long custom2ImageId, InputStream is, String type) throws Exception { StringBundler sb = new StringBundler(5); sb.append(getPathSegment(groupId, fileEntryId, fileVersionId, false)); if (custom1ImageId != 0) { sb.append(StringPool.DASH);/*from w w w. java2 s . c om*/ sb.append(1); } else if (custom2ImageId != 0) { sb.append(StringPool.DASH); sb.append(2); } sb.append(StringPool.PERIOD); sb.append(type); String filePath = sb.toString(); File file = null; try { file = FileUtil.createTempFile(is); addFileToStore(companyId, THUMBNAIL_PATH, filePath, file); } finally { FileUtil.delete(file); } }
From source file:com.liferay.portlet.documentlibrary.util.VideoProcessorImpl.java
License:Open Source License
private String _getVideoTempFilePath(String tempFileId, String targetExtension) { StringBundler sb = new StringBundler(5); sb.append(PREVIEW_TMP_PATH);// w w w . j ava 2s . com sb.append(tempFileId); for (int i = 0; i < _PREVIEW_TYPES.length; i++) { if (_PREVIEW_TYPES[i].equals(targetExtension)) { sb.append("_tmp"); break; } } sb.append(StringPool.PERIOD); sb.append(targetExtension); return sb.toString(); }
From source file:com.liferay.portlet.dynamicdatamapping.util.comparator.StructureVersionVersionComparator.java
License:Open Source License
@Override public int compare(DDMStructureVersion structureVersion1, DDMStructureVersion structureVersion2) { int value = 0; String version1 = structureVersion1.getVersion(); String version2 = structureVersion2.getVersion(); int[] versionParts1 = StringUtil.split(version1, StringPool.PERIOD, 0); int[] versionParts2 = StringUtil.split(version2, StringPool.PERIOD, 0); if ((versionParts1.length != 2) && (versionParts2.length != 2)) { value = 0;/*w w w .ja v a 2s. com*/ } else if (versionParts1.length != 2) { value = -1; } else if (versionParts2.length != 2) { value = 1; } else if (versionParts1[0] > versionParts2[0]) { value = 1; } else if (versionParts1[0] < versionParts2[0]) { value = -1; } else if (versionParts1[1] > versionParts2[1]) { value = 1; } else if (versionParts1[1] < versionParts2[1]) { value = -1; } if (_ascending) { return value; } else { return -value; } }
From source file:com.liferay.portlet.dynamicdatamapping.util.comparator.TemplateVersionVersionComparator.java
License:Open Source License
@Override public int compare(DDMTemplateVersion templateVersion1, DDMTemplateVersion templateVersion2) { int value = 0; String version1 = templateVersion1.getVersion(); String version2 = templateVersion2.getVersion(); int[] versionParts1 = StringUtil.split(version1, StringPool.PERIOD, 0); int[] versionParts2 = StringUtil.split(version2, StringPool.PERIOD, 0); if ((versionParts1.length != 2) && (versionParts2.length != 2)) { value = 0;/* w w w.j a va 2 s . c om*/ } else if (versionParts1.length != 2) { value = -1; } else if (versionParts2.length != 2) { value = 1; } else if (versionParts1[0] > versionParts2[0]) { value = 1; } else if (versionParts1[0] < versionParts2[0]) { value = -1; } else if (versionParts1[1] > versionParts2[1]) { value = 1; } else if (versionParts1[1] < versionParts2[1]) { value = -1; } if (_ascending) { return value; } else { return -value; } }
From source file:com.liferay.portlet.journal.lar.JournalPortletDataHandlerImpl.java
License:Open Source License
public static void importTemplate(PortletDataContext portletDataContext, Element templateElement) throws Exception { String path = templateElement.attributeValue("path"); if (!portletDataContext.isPathNotProcessed(path)) { return;/*from w ww .j av a 2 s. c o m*/ } JournalTemplate template = (JournalTemplate) portletDataContext.getZipEntryAsObject(path); long userId = portletDataContext.getUserId(template.getUserUuid()); JournalCreationStrategy creationStrategy = JournalCreationStrategyFactory.getInstance(); long authorId = creationStrategy.getAuthorUserId(portletDataContext, template); if (authorId != JournalCreationStrategy.USE_DEFAULT_USER_ID_STRATEGY) { userId = authorId; } String templateId = template.getTemplateId(); boolean autoTemplateId = false; if (Validator.isNumber(templateId) || (JournalTemplateUtil.fetchByG_T(portletDataContext.getScopeGroupId(), templateId) != null)) { autoTemplateId = true; } Map<String, String> structureIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalStructure.class + ".structureId"); String parentStructureId = MapUtil.getString(structureIds, template.getStructureId(), template.getStructureId()); String xsl = template.getXsl(); xsl = importDLFileEntries(portletDataContext, templateElement, xsl); Group group = GroupLocalServiceUtil.getGroup(portletDataContext.getScopeGroupId()); xsl = StringUtil.replace(xsl, "@data_handler_group_friendly_url@", group.getFriendlyURL()); template.setXsl(xsl); boolean formatXsl = false; boolean addGroupPermissions = creationStrategy.addGroupPermissions(portletDataContext, template); boolean addGuestPermissions = creationStrategy.addGuestPermissions(portletDataContext, template); ServiceContext serviceContext = portletDataContext.createServiceContext(templateElement, template, _NAMESPACE); serviceContext.setAddGroupPermissions(addGroupPermissions); serviceContext.setAddGuestPermissions(addGuestPermissions); File smallFile = null; String smallImagePath = templateElement.attributeValue("small-image-path"); if (template.isSmallImage() && Validator.isNotNull(smallImagePath)) { if (smallImagePath.endsWith(StringPool.PERIOD)) { smallImagePath += template.getSmallImageType(); } byte[] bytes = portletDataContext.getZipEntryAsByteArray(smallImagePath); if (bytes != null) { smallFile = FileUtil.createTempFile(template.getSmallImageType()); FileUtil.write(smallFile, bytes); } } JournalTemplate importedTemplate = null; if (portletDataContext.isDataStrategyMirror()) { JournalTemplate existingTemplate = JournalTemplateUtil.fetchByUUID_G(template.getUuid(), portletDataContext.getScopeGroupId()); if (existingTemplate == null) { Group companyGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId()); long companyGroupId = companyGroup.getGroupId(); existingTemplate = JournalTemplateUtil.fetchByUUID_G(template.getUuid(), companyGroupId); } if (existingTemplate == null) { serviceContext.setUuid(template.getUuid()); importedTemplate = JournalTemplateLocalServiceUtil.addTemplate(userId, portletDataContext.getScopeGroupId(), templateId, autoTemplateId, parentStructureId, template.getNameMap(), template.getDescriptionMap(), template.getXsl(), formatXsl, template.getLangType(), template.getCacheable(), template.isSmallImage(), template.getSmallImageURL(), smallFile, serviceContext); } else { String structureId = existingTemplate.getStructureId(); if (Validator.isNull(structureId) && Validator.isNotNull(template.getStructureId())) { JournalStructure structure = JournalStructureUtil.fetchByG_S(template.getGroupId(), template.getStructureId()); if (structure == null) { structureId = template.getStructureId(); } else { JournalStructure existingStructure = JournalStructureUtil.findByUUID_G(structure.getUuid(), portletDataContext.getScopeGroupId()); structureId = existingStructure.getStructureId(); } } importedTemplate = JournalTemplateLocalServiceUtil.updateTemplate(existingTemplate.getGroupId(), existingTemplate.getTemplateId(), structureId, template.getNameMap(), template.getDescriptionMap(), template.getXsl(), formatXsl, template.getLangType(), template.getCacheable(), template.isSmallImage(), template.getSmallImageURL(), smallFile, serviceContext); } } else { importedTemplate = JournalTemplateLocalServiceUtil.addTemplate(userId, portletDataContext.getScopeGroupId(), templateId, autoTemplateId, parentStructureId, template.getNameMap(), template.getDescriptionMap(), template.getXsl(), formatXsl, template.getLangType(), template.getCacheable(), template.isSmallImage(), template.getSmallImageURL(), smallFile, serviceContext); } if (smallFile != null) { smallFile.delete(); } portletDataContext.importClassedModel(template, importedTemplate, _NAMESPACE); Map<String, String> templateIds = (Map<String, String>) portletDataContext .getNewPrimaryKeysMap(JournalTemplate.class + ".templateId"); templateIds.put(template.getTemplateId(), importedTemplate.getTemplateId()); if (!templateId.equals(importedTemplate.getTemplateId())) { if (_log.isWarnEnabled()) { _log.warn("A template with the ID " + templateId + " already " + "exists. The new generated ID is " + importedTemplate.getTemplateId()); } } }
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);/* w ww .j av a 2 s. co m*/ sb.append(article.getVersion()); 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(); }