List of usage examples for com.liferay.portal.util PrefsPropsUtil getStringArray
public static String[] getStringArray(String name, String delimiter)
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(); }// ww w. j av a 2 s . c o m 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(); }//ww w. j a va 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(); }/*from ww w . j ava 2 s .c om*/ 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(); } } }