List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:de.hybris.platform.commercefacades.storesession.impl.DefaultStoreSessionFacade.java
@Override public Collection<CurrencyData> getAllCurrencies() { List<CurrencyModel> currencyModelList = getCommerceCommonI18NService().getAllCurrencies(); if (currencyModelList.isEmpty()) { currencyModelList = getCommonI18NService().getAllCurrencies(); }//from w w w . j a v a 2 s . c o m Assert.notEmpty(currencyModelList, "No supported currencies found for the current site."); return Converters.convertAll(currencyModelList, getCurrencyConverter()); }
From source file:eu.europeana.aas.acl.CassandraAclService.java
@Override public Map<ObjectIdentity, Acl> readAclsById(List<ObjectIdentity> objects, List<Sid> sids) throws NotFoundException { Assert.notEmpty(objects, "Objects to lookup required"); if (LOG.isDebugEnabled()) { LOG.debug("BEGIN readAclById: objectIdentities: " + objects + ", sids: " + sids); }/*w ww.j a v a2s .c o m*/ // contains FULLY loaded Acl objects Map<ObjectIdentity, Acl> result = new HashMap<>(); List<ObjectIdentity> objectsToLookup = new ArrayList<>(objects); // Check for Acls in the cache if (aclCache != null) { for (ObjectIdentity oi : objects) { boolean aclLoaded = false; Acl acl = aclCache.getFromCache(oi); if (acl != null && acl.isSidLoaded(sids)) { // Ensure any cached element supports all the requested SIDs result.put(oi, acl); aclLoaded = true; } if (aclLoaded) { objectsToLookup.remove(oi); } } } if (!objectsToLookup.isEmpty()) { Map<ObjectIdentity, Acl> loadedAcls = doLookup(objectsToLookup); result.putAll(loadedAcls); // Put loaded Acls in the cache if (aclCache != null) { for (Acl loadedAcl : loadedAcls.values()) { aclCache.putInCache((AclImpl) loadedAcl); } } } for (ObjectIdentity oid : objects) { if (!result.containsKey(oid)) { throw new NotFoundException("Unable to find ACL information for object identity '" + oid + "'"); } } if (LOG.isDebugEnabled()) { LOG.debug("END readAclById: acls: " + result.values()); } return result; }
From source file:eu.europeana.aas.acl.repository.CassandraAclRepository.java
/** * Validates all <code>AclObjectIdentity</code> objects in the list. * /*w ww .j a v a2 s . co m*/ * @param aoiList * a list of <code>AclObjectIdentity</code> objects to validate. */ private void assertAclObjectIdentityList(List<AclObjectIdentity> aoiList) { Assert.notEmpty(aoiList, "The AclObjectIdentity list cannot be empty"); for (AclObjectIdentity aoi : aoiList) { assertAclObjectIdentity(aoi); } }
From source file:hello.MetricsActivator.java
/** * Set the array of simple patterns for component names to register (defaults to '*'). * The pattern is applied to all components before they are registered, looking for a * match on the 'name' property of the ObjectName. A MessageChannel and a * MessageHandler (for instance) can share a name because they have a different type, * so in that case they would either both be included or both excluded. Since version * 4.2, a leading '!' negates the pattern match ('!foo*' means don't export components * where the name matches the pattern 'foo*'). For components with names that match * multiple patterns, the first pattern wins. * @param componentNamePatterns the patterns. *//*from www.j av a 2 s . c o m*/ public void setComponentNamePatterns(String[] componentNamePatterns) { Assert.notEmpty(componentNamePatterns, "componentNamePatterns must not be empty"); this.componentNamePatterns = Arrays.copyOf(componentNamePatterns, componentNamePatterns.length); }
From source file:hello.MetricsActivator.java
/** * Set the array of simple patterns for component names for which message counts will * be enabled (defaults to '*'). Only patterns that also match * {@link #setComponentNamePatterns(String[]) componentNamePatterns} will be * considered. Enables message counting (`sendCount`, `errorCount`, `receiveCount`) * for those components that support counters (channels, message handlers, etc). * This is the initial setting only, individual components can have counts * enabled/disabled at runtime. May be overridden by an entry in * {@link #setEnabledStatsPatterns(String[]) enabledStatsPatterns} which is additional * functionality over simple counts. If a pattern starts with `!`, counts are disabled * for matches. For components that match multiple patterns, the first pattern wins. * Disabling counts at runtime also disables stats. * @param enabledCountsPatterns the patterns. * @since 4.2/*from w w w . j av a2s .c om*/ */ public void setEnabledCountsPatterns(String[] enabledCountsPatterns) { Assert.notEmpty(enabledCountsPatterns, "enabledCountsPatterns must not be empty"); this.enabledCountsPatterns = Arrays.copyOf(enabledCountsPatterns, enabledCountsPatterns.length); }
From source file:hello.MetricsActivator.java
/** * Set the array of simple patterns for component names for which message statistics * will be enabled (response times, rates etc), as well as counts (a positive match * here overrides {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns}, * you can't have statistics without counts). (defaults to '*'). Only patterns that * also match {@link #setComponentNamePatterns(String[]) componentNamePatterns} will * be considered. Enables statistics for those components that support statistics * (channels - when sending, message handlers, etc). This is the initial setting only, * individual components can have stats enabled/disabled at runtime. If a pattern * starts with `!`, stats (and counts) are disabled for matches. Note: this means that * '!foo' here will disable stats and counts for 'foo' even if counts are enabled for * 'foo' in {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns}. For * components that match multiple patterns, the first pattern wins. Enabling stats at * runtime also enables counts.//from w ww . j a v a 2 s . com * @param enabledStatsPatterns the patterns. * @since 4.2 */ public void setEnabledStatsPatterns(String[] enabledStatsPatterns) { Assert.notEmpty(enabledStatsPatterns, "componentNamePatterns must not be empty"); this.enabledStatsPatterns = Arrays.copyOf(enabledStatsPatterns, enabledStatsPatterns.length); }
From source file:net.stickycode.mockwire.spring30.MockwireFieldInjectionAnnotationBeanPostProcessor.java
/** * Set the 'autowired' annotation types, to be used on constructors, fields, * setter methods and arbitrary config methods. * <p>The default autowired annotation type is the Spring-provided * {@link Autowired} annotation, as well as {@link Value}. * <p>This setter property exists so that developers can provide their own * (non-Spring-specific) annotation types to indicate that a member is * supposed to be autowired.// www . j a va 2 s. c o m */ public void setAutowiredAnnotationTypes(Set<Class<? extends Annotation>> autowiredAnnotationTypes) { Assert.notEmpty(autowiredAnnotationTypes, "'autowiredAnnotationTypes' must not be empty"); this.autowiredAnnotationTypes.clear(); this.autowiredAnnotationTypes.addAll(autowiredAnnotationTypes); }
From source file:ome.services.search.SimilarTerms.java
@Transactional(readOnly = true) public Object doWork(Session s, ServiceFactory sf) { if (values.onlyTypes == null || values.onlyTypes.size() != 1) { throw new ApiUsageException("Searches by similar terms are currently limited to a single type.\n" + "Plese use Search.onlyType()"); }/*from w w w . ja va 2s .c o m*/ final Class<?> cls = values.onlyTypes.get(0); final FullTextSession session = Search.getFullTextSession(s); final SearchFactory factory = session.getSearchFactory(); final DirectoryProvider[] directory = factory.getDirectoryProviders(cls); final ReaderProvider provider = factory.getReaderProvider(); Assert.notEmpty(directory, "Must have a directory provider"); Assert.isTrue(directory.length == 1, "Can only handle one directory"); final IndexReader reader = provider.openReader(directory[0]); FuzzyTermEnum fuzzy = null; List<TextAnnotation> rv = new ArrayList<TextAnnotation>(); try { fuzzy = new FuzzyTermEnum(reader, new Term("combined_fields", terms[0])); while (fuzzy.next()) { CommentAnnotation text = new CommentAnnotation(); text.setNs(terms[0]); text.setTextValue(fuzzy.term().text()); rv.add(text); } return rv; } catch (IOException e) { throw new InternalException("Error reading from index: " + e.getMessage()); } finally { if (fuzzy != null) { fuzzy.endEnum(); } } }
From source file:org.acegisecurity.acl.AclProviderManager.java
private void checkIfValidList(List listToCheck) { Assert.notEmpty(listToCheck, "A list of AclManagers is required"); }
From source file:org.acegisecurity.ui.logout.LogoutFilter.java
public LogoutFilter(String logoutSuccessUrl, LogoutHandler[] handlers) { Assert.hasText(logoutSuccessUrl, "LogoutSuccessUrl required"); Assert.notEmpty(handlers, "LogoutHandlers are required"); this.logoutSuccessUrl = logoutSuccessUrl; this.handlers = handlers; }