List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:org.craftercms.engine.targeting.impl.TargetedContentStoreAdapter.java
@Override public boolean exists(Context context, String path) throws InvalidContextException, StoreException { context = ((ContextWrapper) context).getActualContext(); if (SiteProperties.isTargetingEnabled() && !TargetingUtils.excludePath(path)) { List<String> candidatePaths = candidateTargetedUrlsResolver.getUrls(path); if (CollectionUtils.isNotEmpty(candidatePaths)) { for (String candidatePath : candidatePaths) { if (actualAdapter.exists(context, candidatePath)) { if (logger.isDebugEnabled()) { logger.debug("Targeted of " + path + " found at " + candidatePath); }//w w w .j a va2 s . co m return true; } } return false; } else { return actualAdapter.exists(context, path); } } else { return actualAdapter.exists(context, path); } }
From source file:org.craftercms.engine.targeting.impl.TargetedContentStoreAdapter.java
@Override public Content findContent(Context context, CachingOptions cachingOptions, String path) throws InvalidContextException, StoreException { context = ((ContextWrapper) context).getActualContext(); if (SiteProperties.isTargetingEnabled() && !TargetingUtils.excludePath(path)) { List<String> candidatePaths = candidateTargetedUrlsResolver.getUrls(path); if (CollectionUtils.isNotEmpty(candidatePaths)) { for (String candidatePath : candidatePaths) { Content content = actualAdapter.findContent(context, cachingOptions, candidatePath); if (content != null) { if (logger.isDebugEnabled()) { logger.debug("Targeted version of " + path + " found at " + candidatePath); }/*from w w w . ja va 2 s . c o m*/ return content; } } return null; } else { return actualAdapter.findContent(context, cachingOptions, path); } } else { return actualAdapter.findContent(context, cachingOptions, path); } }
From source file:org.craftercms.engine.targeting.impl.TargetedContentStoreAdapter.java
@Override public Item findItem(Context context, CachingOptions cachingOptions, String path, boolean withDescriptor) throws InvalidContextException, XmlFileParseException, StoreException { context = ((ContextWrapper) context).getActualContext(); if (SiteProperties.isTargetingEnabled() && !TargetingUtils.excludePath(path)) { List<String> candidatePaths = candidateTargetedUrlsResolver.getUrls(path); if (CollectionUtils.isNotEmpty(candidatePaths)) { for (String candidatePath : candidatePaths) { Item item = actualAdapter.findItem(context, cachingOptions, candidatePath, withDescriptor); if (item != null) { if (logger.isDebugEnabled()) { logger.debug("Targeted version of " + path + " found at " + candidatePath); }//from ww w .j a v a2 s . c om return item; } } return null; } else { return actualAdapter.findItem(context, cachingOptions, path, withDescriptor); } } else { return actualAdapter.findItem(context, cachingOptions, path, withDescriptor); } }
From source file:org.craftercms.engine.targeting.impl.TargetedContentStoreAdapter.java
@Override public List<Item> findItems(Context context, CachingOptions cachingOptions, String path, boolean withDescriptor) throws InvalidContextException, XmlFileParseException, StoreException { context = ((ContextWrapper) context).getActualContext(); if (SiteProperties.isTargetingEnabled() && !TargetingUtils.excludePath(path)) { List<String> candidatePaths = candidateTargetedUrlsResolver.getUrls(path); if (CollectionUtils.isNotEmpty(candidatePaths)) { if (SiteProperties.isMergeFolders()) { if (logger.isDebugEnabled()) { logger.debug("Merging child items of " + candidatePaths); }//from ww w . j a va 2 s . c o m List<Item> mergedItems = null; for (String candidatePath : candidatePaths) { List<Item> items = actualAdapter.findItems(context, cachingOptions, candidatePath, withDescriptor); mergedItems = mergeItems(mergedItems, items); } return mergedItems; } else { for (String candidatePath : candidatePaths) { List<Item> items = actualAdapter.findItems(context, cachingOptions, candidatePath, withDescriptor); if (CollectionUtils.isNotEmpty(items)) { if (logger.isDebugEnabled()) { logger.debug("Targeted version of " + path + " found at " + candidatePath); } return items; } } return null; } } else { return actualAdapter.findItems(context, cachingOptions, path, withDescriptor); } } else { return actualAdapter.findItems(context, cachingOptions, path, withDescriptor); } }
From source file:org.craftercms.engine.util.ContentStoreUtils.java
public static List<String> findChildrenUrl(ContentStoreService storeService, Context context, String folderUrl) {//from w w w .ja v a 2 s .c o m List<Item> children = storeService.findChildren(context, folderUrl); List<String> childrenUrl = new ArrayList<>(); if (CollectionUtils.isNotEmpty(children)) { for (Item child : children) { childrenUrl.add(child.getUrl()); } } return childrenUrl; }
From source file:org.craftercms.engine.util.spring.mvc.AnnotationDrivenConfigCustomizer.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof RequestMappingHandlerAdapter) { RequestMappingHandlerAdapter adapter = (RequestMappingHandlerAdapter) bean; if (contentNegotiationManager != null) { adapter.setContentNegotiationManager(contentNegotiationManager); }/* w w w. j a va 2s. com*/ if (CollectionUtils.isNotEmpty(messageConverters)) { List<HttpMessageConverter<?>> mergedConverters = new ArrayList<>(messageConverters); mergedConverters.addAll(adapter.getMessageConverters()); adapter.setMessageConverters(mergedConverters); } } else if (bean instanceof RequestMappingHandlerMapping) { RequestMappingHandlerMapping mapping = (RequestMappingHandlerMapping) bean; if (CollectionUtils.isNotEmpty(interceptors)) { mapping.setInterceptors(interceptors.toArray(new Object[interceptors.size()])); } } else if (bean instanceof ExceptionHandlerExceptionResolver) { ExceptionHandlerExceptionResolver exceptionResolver = (ExceptionHandlerExceptionResolver) bean; if (contentNegotiationManager != null) { exceptionResolver.setContentNegotiationManager(contentNegotiationManager); } if (CollectionUtils.isNotEmpty(messageConverters)) { List<HttpMessageConverter<?>> mergedConverters = new ArrayList<>(messageConverters); mergedConverters.addAll(exceptionResolver.getMessageConverters()); exceptionResolver.setMessageConverters(mergedConverters); } } return bean; }
From source file:org.craftercms.engine.view.CrafterPageViewResolver.java
protected void loadScripts(ScriptFactory scriptFactory, SiteItem page, CrafterPageView view) { if (scriptFactory != null) { List<String> scriptUrls = scriptResolver.getScriptUrls(page); if (CollectionUtils.isNotEmpty(scriptUrls)) { if (logger.isDebugEnabled()) { logger.debug("Scripts associated to page " + page.getStoreUrl() + ": " + scriptUrls); }//from w w w . j av a 2s . c o m List<Script> scripts = new ArrayList<Script>(scriptUrls.size()); for (String scriptUrl : scriptUrls) { Script script = scriptFactory.getScript(scriptUrl); scripts.add(script); view.addDependencyKey(script.getKey()); } view.setScripts(scripts); } } }
From source file:org.craftercms.profile.services.impl.ProfileServiceImpl.java
@Override public Profile createProfile(String tenantName, String username, String password, String email, boolean enabled, Set<String> roles, Map<String, Object> attributes, String verificationUrl) throws ProfileException { checkIfManageProfilesIsAllowed(tenantName); if (!EmailUtils.validateEmail(email)) { throw new InvalidEmailAddressException(email); }/*from w ww . j a v a 2 s . com*/ try { Tenant tenant = getTenant(tenantName); Date now = new Date(); Profile profile = new Profile(); profile.setTenant(tenantName); profile.setUsername(username); profile.setPassword(CryptoUtils.hashPassword(password)); profile.setEmail(email); profile.setCreatedOn(now); profile.setLastModified(now); profile.setVerified(false); boolean emailNewProfiles = tenant.isVerifyNewProfiles(); if (!emailNewProfiles || StringUtils.isEmpty(verificationUrl)) { profile.setEnabled(enabled); } if (CollectionUtils.isNotEmpty(roles)) { profile.setRoles(roles); } for (AttributeDefinition definition : tenant.getAttributeDefinitions()) { if (definition.getDefaultValue() != null) { profile.setAttribute(definition.getName(), definition.getDefaultValue()); } } if (MapUtils.isNotEmpty(attributes)) { rejectAttributesIfActionNotAllowed(tenant, attributes.keySet(), AttributeAction.WRITE_ATTRIBUTE); profile.getAttributes().putAll(attributes); } profileRepository.insert(profile); logger.debug(LOG_KEY_PROFILE_CREATED, profile); if (emailNewProfiles && StringUtils.isNotEmpty(verificationUrl)) { VerificationToken token = verificationService.createToken(profile); verificationService.sendEmail(token, profile, verificationUrl, newProfileEmailFromAddress, newProfileEmailSubject, newProfileEmailTemplateName); } return profile; } catch (DuplicateKeyException e) { throw new ProfileExistsException(tenantName, username); } catch (MongoDataException e) { throw new I10nProfileException(ERROR_KEY_CREATE_PROFILE_ERROR, e, username, tenantName); } }
From source file:org.craftercms.studio.impl.v1.asset.processing.AssetProcessingConfigReaderImpl.java
@Override @SuppressWarnings("unchecked") public List<ProcessorPipelineConfiguration> readConfig(HierarchicalConfiguration config) throws AssetProcessingConfigurationException { List<HierarchicalConfiguration> pipelinesConfig = config.configurationsAt(PIPELINES_CONFIG_KEY); if (CollectionUtils.isNotEmpty(pipelinesConfig)) { List<ProcessorPipelineConfiguration> mappedPipelinesConfig = new ArrayList<>(pipelinesConfig.size()); for (HierarchicalConfiguration pipelineConfig : pipelinesConfig) { mappedPipelinesConfig.add(readPipelineConfig(pipelineConfig)); }//from w w w .j a v a2s. c o m return mappedPipelinesConfig; } else { return Collections.emptyList(); } }
From source file:org.craftercms.studio.impl.v1.service.dependency.DependencyServiceImpl.java
private void insertDependenciesIntoDatabase(List<DependencyEntity> dependencyEntities) { logger.debug("Insert list of dependency entities into database"); if (CollectionUtils.isNotEmpty(dependencyEntities)) { Map<String, Object> params = new HashMap<>(); params.put(StudioConstants.JSON_PROPERTY_DEPENDENCIES, dependencyEntities); dependencyMapper.insertList(params); }/*from w ww . j a va 2s.com*/ }