List of usage examples for com.liferay.portal.kernel.util StringPool STAR
String STAR
To view the source code for com.liferay.portal.kernel.util StringPool STAR.
Click Source Link
From source file:com.liferay.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void validate(long companyId, long groupId, long classNameId, Map<Locale, String> titleMap, String content, String ddmStructureKey, String ddmTemplateKey, Date displayDate, Date expirationDate, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes, ServiceContext serviceContext) throws PortalException { Locale articleDefaultLocale = LocaleUtil.fromLanguageId(LocalizationUtil.getDefaultLanguageId(content)); if (!ExportImportThreadLocal.isImportInProcess()) { if (!LanguageUtil.isAvailableLocale(groupId, articleDefaultLocale)) { LocaleException le = new LocaleException(LocaleException.TYPE_CONTENT, "The locale " + articleDefaultLocale + " is not available in site with groupId" + groupId); le.setSourceAvailableLocales(Collections.singleton(articleDefaultLocale)); le.setTargetAvailableLocales(LanguageUtil.getAvailableLocales(groupId)); throw le; }// w ww . j ava2 s . c o m if ((expirationDate != null) && (expirationDate.before(new Date()) || ((displayDate != null) && expirationDate.before(displayDate)))) { throw new ArticleExpirationDateException("Expiration date " + expirationDate + " is in the past"); } } if ((classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) && (titleMap.isEmpty() || Validator.isNull(titleMap.get(articleDefaultLocale)))) { throw new ArticleTitleException("Title is null"); } validateContent(content); DDMStructure ddmStructure = ddmStructureLocalService.getStructure(PortalUtil.getSiteGroupId(groupId), classNameLocalService.getClassNameId(JournalArticle.class), ddmStructureKey, true); validateDDMStructureFields(ddmStructure, classNameId, content, articleDefaultLocale); if (Validator.isNotNull(ddmTemplateKey)) { DDMTemplate ddmTemplate = ddmTemplateLocalService.getTemplate(PortalUtil.getSiteGroupId(groupId), classNameLocalService.getClassNameId(DDMStructure.class), ddmTemplateKey, true); if (ddmTemplate.getClassPK() != ddmStructure.getStructureId()) { throw new NoSuchTemplateException("{templateKey=" + ddmTemplateKey + "}"); } } else if (classNameId == JournalArticleConstants.CLASSNAME_ID_DEFAULT) { throw new NoSuchTemplateException("DDM template key is null"); } if (!smallImage || Validator.isNotNull(smallImageURL) || (smallImageFile == null) || (smallImageBytes == null)) { return; } String smallImageName = smallImageFile.getName(); boolean validSmallImageExtension = false; for (String imageExtension : _journalFileUploadsConfiguration.imageExtensions()) { if (StringPool.STAR.equals(imageExtension) || StringUtil.endsWith(smallImageName, imageExtension)) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new ArticleSmallImageNameException(smallImageName); } long smallImageMaxSize = _journalFileUploadsConfiguration.smallImageMaxSize(); if ((smallImageMaxSize > 0) && (smallImageBytes.length > smallImageMaxSize)) { throw new ArticleSmallImageSizeException(smallImageBytes.length + " exceeds " + smallImageMaxSize); } }
From source file:com.liferay.journal.web.internal.upload.ImageJournalUploadHandler.java
License:Open Source License
@Override public void validateFile(String fileName, String contentType, long size) throws PortalException { _dlValidator.validateFileSize(fileName, size); String extension = FileUtil.getExtension(fileName); for (String imageExtension : _journalFileUploadsConfiguration.imageExtensions()) { if (StringPool.STAR.equals(imageExtension) || imageExtension.equals(StringPool.PERIOD + extension)) { return; }/*from ww w.ja va2s.c o m*/ } throw new ImageTypeException("Invalid image type for file name " + fileName); }
From source file:com.liferay.knowledgebase.admin.importer.util.KBArticleImporterUtil.java
License:Open Source License
public static void validateImageFileExtension(String imageFileName) throws KBArticleImportException { boolean validImageFileExtension = false; for (String fileExtension : PortletPropsValues.MARKDOWN_IMPORTER_IMAGE_FILE_EXTENSIONS) { if (StringPool.STAR.equals(fileExtension) || StringUtil.endsWith(imageFileName, fileExtension)) { validImageFileExtension = true; break; }//from w w w . ja v a 2s . co m } if (!validImageFileExtension) { throw new KBArticleImportException(imageFileName); } }
From source file:com.liferay.portlet.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected void validate(String title, String content, boolean smallImage, String smallImageURL, String smallImageFileName, byte[] smallImageBytes) throws PortalException, SystemException { if (Validator.isNull(title)) { throw new EntryTitleException(); } else if (Validator.isNull(content)) { throw new EntryContentException(); }/*from ww w .j a va 2 s. c o m*/ String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.BLOGS_IMAGE_EXTENSIONS, StringPool.COMMA); if (smallImage && Validator.isNull(smallImageURL) && (smallImageBytes != null)) { if (smallImageFileName != null) { boolean validSmallImageExtension = false; for (String _imageExtension : imageExtensions) { if (StringPool.STAR.equals(_imageExtension) || StringUtil.endsWith(smallImageFileName, _imageExtension)) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new EntrySmallImageNameException(smallImageFileName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.BLOGS_IMAGE_SMALL_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new EntrySmallImageSizeException(); } } }
From source file:com.liferay.portlet.configuration.toolbar.contributor.locator.internal.BasePortletToolbarContributorLocator.java
License:Open Source License
@Override public List<PortletToolbarContributor> getPortletToolbarContributors(String portletId, PortletRequest portletRequest) { String value = ParamUtil.getString(portletRequest, getParameterName(), "-"); List<PortletToolbarContributor> portletToolbarContributors = _serviceTrackerMap .getService(getKey(portletId, value)); if (ListUtil.isEmpty(portletToolbarContributors)) { portletToolbarContributors = _serviceTrackerMap.getService(getKey(portletId, StringPool.STAR)); }//from w ww. java 2s . co m return portletToolbarContributors; }
From source file:com.liferay.portlet.documentlibrary.store.DLStoreImpl.java
License:Open Source License
public void validate(String fileName, boolean validateFileExtension) throws PortalException, SystemException { if (!isValidName(fileName)) { throw new FileNameException(fileName); }// w w w. j a va 2 s . c o m if (validateFileExtension) { boolean validFileExtension = false; String[] fileExtensions = PrefsPropsUtil.getStringArray(PropsKeys.DL_FILE_EXTENSIONS, StringPool.COMMA); for (String fileExtension : fileExtensions) { if (StringPool.STAR.equals(fileExtension) || StringUtil.endsWith(fileName, fileExtension) //Looks like Liferay's bug. Original file name should be checked! //But in this place we have changed fileName. //So, also checked original name. || StringUtil.endsWith(fileName, fileExtension + "_temp.tmp")) { validFileExtension = true; break; } } if (!validFileExtension) { throw new FileExtensionException(fileName); } } }
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;// www . j a v a2 s.co 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.journal.service.impl.JournalArticleLocalServiceImpl.java
License:Open Source License
protected void validate(long companyId, long groupId, long classNameId, Map<Locale, String> titleMap, String content, String type, String structureId, String templateId, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes) throws PortalException, SystemException { Locale defaultLocale = LocaleUtil.fromLanguageId(LocalizationUtil.getDefaultLocale(content)); if ((classNameId == 0) && (titleMap.isEmpty() || Validator.isNull(titleMap.get(defaultLocale)))) { throw new ArticleTitleException(); } else if (Validator.isNull(type)) { throw new ArticleTypeException(); }/*from ww w. j ava 2s. c om*/ validateContent(content); if (Validator.isNotNull(structureId)) { Group companyGroup = groupLocalService.getCompanyGroup(companyId); try { journalStructurePersistence.findByG_S(groupId, structureId); } catch (NoSuchStructureException nsse) { journalStructurePersistence.findByG_S(companyGroup.getGroupId(), structureId); } JournalTemplate template = null; if (Validator.isNotNull(templateId)) { try { template = journalTemplatePersistence.findByG_T(groupId, templateId); } catch (NoSuchTemplateException nste) { template = journalTemplatePersistence.findByG_T(companyGroup.getGroupId(), templateId); } if (!template.getStructureId().equals(structureId)) { throw new NoSuchTemplateException(); } } else if (classNameId == 0) { throw new NoSuchTemplateException(); } } String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, StringPool.COMMA); if (smallImage && Validator.isNull(smallImageURL) && (smallImageFile != null) && (smallImageBytes != null)) { String smallImageName = smallImageFile.getName(); if (smallImageName != null) { boolean validSmallImageExtension = false; for (String _imageExtension : imageExtensions) { if (StringPool.STAR.equals(_imageExtension) || StringUtil.endsWith(smallImageName, _imageExtension)) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new ArticleSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new ArticleSmallImageSizeException(); } } }
From source file:com.liferay.portlet.journal.service.impl.JournalTemplateLocalServiceImpl.java
License:Open Source License
protected void validate(Map<Locale, String> nameMap, String xsl, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes) throws PortalException, SystemException { Locale locale = LocaleUtil.getDefault(); if (nameMap.isEmpty() || Validator.isNull(nameMap.get(locale))) { throw new TemplateNameException(); } else if (Validator.isNull(xsl)) { throw new TemplateXslException(); }//w w w .ja v a 2 s. c om String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.JOURNAL_IMAGE_EXTENSIONS, StringPool.COMMA); if (smallImage && Validator.isNull(smallImageURL) && (smallImageFile != null) && (smallImageBytes != null)) { String smallImageName = smallImageFile.getName(); if (smallImageName != null) { boolean validSmallImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(smallImageName, imageExtensions[i])) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new TemplateSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.JOURNAL_IMAGE_SMALL_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new TemplateSmallImageSizeException(); } } }
From source file:com.liferay.portlet.shopping.service.impl.ShoppingItemLocalServiceImpl.java
License:Open Source License
protected void validate(long companyId, long itemId, String sku, String name, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes, boolean mediumImage, String mediumImageURL, File mediumImageFile, byte[] mediumImageBytes, boolean largeImage, String largeImageURL, File largeImageFile, byte[] largeImageBytes) throws PortalException, SystemException { if (Validator.isNull(sku)) { throw new ItemSKUException(); }/*w w w.java2 s . com*/ ShoppingItem item = shoppingItemPersistence.fetchByC_S(companyId, sku); if (item != null) { if (itemId > 0) { if (item.getItemId() != itemId) { throw new DuplicateItemSKUException(); } } else { throw new DuplicateItemSKUException(); } } if (Validator.isNull(name)) { throw new ItemNameException(); } String[] imageExtensions = PrefsPropsUtil.getStringArray(PropsKeys.SHOPPING_IMAGE_EXTENSIONS, StringPool.COMMA); // Small image if (smallImage && Validator.isNull(smallImageURL) && smallImageFile != null && smallImageBytes != null) { String smallImageName = smallImageFile.getName(); if (smallImageName != null) { boolean validSmallImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(smallImageName, imageExtensions[i])) { validSmallImageExtension = true; break; } } if (!validSmallImageExtension) { throw new ItemSmallImageNameException(smallImageName); } } long smallImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_MEDIUM_MAX_SIZE); if ((smallImageMaxSize > 0) && ((smallImageBytes == null) || (smallImageBytes.length > smallImageMaxSize))) { throw new ItemSmallImageSizeException(); } } // Medium image if (mediumImage && Validator.isNull(mediumImageURL) && mediumImageFile != null && mediumImageBytes != null) { String mediumImageName = mediumImageFile.getName(); if (mediumImageName != null) { boolean validMediumImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(mediumImageName, imageExtensions[i])) { validMediumImageExtension = true; break; } } if (!validMediumImageExtension) { throw new ItemMediumImageNameException(mediumImageName); } } long mediumImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_MEDIUM_MAX_SIZE); if ((mediumImageMaxSize > 0) && ((mediumImageBytes == null) || (mediumImageBytes.length > mediumImageMaxSize))) { throw new ItemMediumImageSizeException(); } } // Large image if (largeImage && Validator.isNull(largeImageURL) && largeImageFile != null && largeImageBytes != null) { String largeImageName = largeImageFile.getName(); if (largeImageName != null) { boolean validLargeImageExtension = false; for (int i = 0; i < imageExtensions.length; i++) { if (StringPool.STAR.equals(imageExtensions[i]) || StringUtil.endsWith(largeImageName, imageExtensions[i])) { validLargeImageExtension = true; break; } } if (!validLargeImageExtension) { throw new ItemLargeImageNameException(largeImageName); } } long largeImageMaxSize = PrefsPropsUtil.getLong(PropsKeys.SHOPPING_IMAGE_LARGE_MAX_SIZE); if ((largeImageMaxSize > 0) && ((largeImageBytes == null) || (largeImageBytes.length > largeImageMaxSize))) { throw new ItemLargeImageSizeException(); } } }