List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:com.project.framework.dao.GenericDao.java
/** * ?/* w w w. j a va 2 s .c o m*/ * * @param entitys * @param flushSize ORM????? */ public void delete(final List<T> entitys, int flushSize) { Assert.notNull(entitys, "entity Can not NULL"); Assert.notEmpty(entitys, "entitys Can not EMPTY"); Session session = getSession(); int count = 1; for (T entity : entitys) { session.delete(entity); if (count++ % flushSize == 0) { session.flush(); session.clear(); } } logger.debug("batch delete {}, number of rows affected: {}", entityClass.getSimpleName(), count - 1); }
From source file:us.swcraft.springframework.store.persistence.AerospikeTemplate.java
@Override public void persistIfAbsent(final String key, final Set<Bin> bins) { Assert.notNull(key, "key can't be null"); final Key recordKey = new Key(namespace, setname, key); Assert.notNull(bins, "bins can't be null"); Assert.notEmpty(bins, "bins should have data to store"); getAerospikeClient().put(writePolicyCreateOnly, recordKey, bins.toArray(BIN_ARRAY_TYPE)); }
From source file:fr.mby.saml2.sp.opensaml.core.OpenSaml20SpProcessor.java
@Override public void afterPropertiesSet() throws Exception { Assert.notNull(this.saml20Storage, "The SAML 2.0 Storage wasn't injected !"); Assert.notNull(this.getSpConfig(), "No SP configuration provided for this SP processor !"); Assert.notNull(this.queryProcessorFactory, "No QueryProcessorFactory injected !"); // Retrieve IdP connectors and // Register this SP processor in the IdP connectors Assert.notEmpty(this.idpConnectors, "No IdP connector injected in the SP processor !"); for (final ISaml20IdpConnector idpConnector : this.idpConnectors) { try {// w w w .j av a 2s .co m idpConnector.registerSaml20SpProcessor(this); final IIdpConfig idpConfig = idpConnector.getIdpConfig(); if (idpConfig != null) { this.idpConnectorsByEntityId.put(idpConfig.getIdpEntityId(), idpConnector); } else { this.logger.warn( "No IdP config found while registering an IdPConnector in SPProcessor with id: [{}] !", this.getSpConfig().getId()); } } catch (final IllegalAccessError e) { // Catch exception thrown by fake IdPs like CAS Fake IdP. } } this.spSigningCredential = SecurityHelper.getSimpleCredential( this.getSpConfig().getSigningCredential().getEntityCertificate(), this.getSpConfig().getSigningKey()); Assert.notNull(this.spSigningCredential, "Unable to build SP signing credentials (signing public + private keys) !"); this.decrypter = this.buildDecrypter(); // Register this processor in the Helper SamlHelper.registerSpProcessor(this); if (this.authenticationHandler == null) { this.logger.warn("No Authentication Handler configured !"); } if (this.singleLogoutHandler == null) { this.logger.warn("No Single Logout Handler configured !"); } }
From source file:org.elasticsoftware.elasticactors.spring.AnnotationConfigApplicationContext.java
/** * Register one or more annotated classes to be processed. * Note that {@link #refresh()} must be called in order for the context * to fully process the new class.//from w w w . ja v a2 s . com * <p>Calls to {@code register} are idempotent; adding the same * annotated class more than once has no additional effect. * @param annotatedClasses one or more annotated classes, * e.g. {@link org.springframework.context.annotation.Configuration @Configuration} classes * @see #scan(String...) * @see #refresh() */ public void register(Class<?>... annotatedClasses) { Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified"); this.reader.register(annotatedClasses); }
From source file:org.elasticsoftware.elasticactors.spring.AnnotationConfigApplicationContext.java
/** * Perform a scan within the specified base packages. * Note that {@link #refresh()} must be called in order for the context to * fully process the new class./* www . ja va 2 s . c o m*/ * @param basePackages the packages to check for annotated classes * @see #register(Class...) * @see #refresh() */ public void scan(String... basePackages) { Assert.notEmpty(basePackages, "At least one base package must be specified"); this.scanner.scan(basePackages); }
From source file:pl.bristleback.server.bristle.conf.resolver.init.PojoConfigResolver.java
private void assertThatArrayIsNotEmpty(String... parameters) { Assert.notEmpty(parameters, "Exception while resolving initial configuration. \n" + "Empty array is not allowed as the configuration parameter value."); }
From source file:org.elasticsoftware.elasticactors.spring.AnnotationConfigWebApplicationContext.java
/** * Register one or more annotated classes to be processed. * Note that {@link #refresh()} must be called in order for the context * to fully process the new class./*from ww w . j av a 2s .c o m*/ * <p>Calls to {@code register} are idempotent; adding the same * annotated class more than once has no additional effect. * @param annotatedClasses one or more annotated classes, * e.g. {@link org.springframework.context.annotation.Configuration @Configuration} classes * @see #scan(String...) * @see #loadBeanDefinitions(DefaultListableBeanFactory) * @see #setConfigLocation(String) * @see #refresh() */ public void register(Class<?>... annotatedClasses) { Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified"); this.annotatedClasses.addAll(Arrays.asList(annotatedClasses)); }
From source file:org.openwms.core.AbstractGenericEntityService.java
/** * {@inheritDoc}/*from w ww .j a v a 2 s .c o m*/ */ @Override public Collection<T> saveAll(Collection<T> entities) { Assert.notEmpty(entities, translate(ExceptionCodes.ENTITY_NOT_BE_NULL)); List<T> result = new ArrayList<>(entities.size()); entities.forEach(f -> result.add(f.isNew() ? create(f) : getRepository().save(f))); return result; }
From source file:com.emc.ecs.sync.source.EcsS3Source.java
@Override public void configure(SyncSource source, Iterator<SyncFilter> filters, SyncTarget target) { Assert.hasText(accessKey, "accessKey is required"); Assert.hasText(secretKey, "secretKey is required"); Assert.hasText(bucketName, "bucketName is required"); Assert.isTrue(bucketName.matches("[A-Za-z0-9._-]+"), bucketName + " is not a valid bucket name"); S3Config s3Config;/*from w w w.j a va 2 s . com*/ if (enableVHosts) { Assert.notNull(endpoint, "endpoint is required"); s3Config = new S3Config(endpoint); } else { // try to infer from endpoint if (endpoint != null) { if (vdcs == null && endpoint.getHost() != null) { vdcs = new ArrayList<>(); for (String host : endpoint.getHost().split(",")) { vdcs.add(new Vdc(host)); } } if (port <= 0 && endpoint.getPort() > 0) port = endpoint.getPort(); if (protocol == null && endpoint.getScheme() != null) protocol = endpoint.getScheme(); } Assert.hasText(protocol, "protocol is required"); Assert.notEmpty(vdcs, "at least one VDC is required"); s3Config = new S3Config(Protocol.valueOf(protocol.toUpperCase()), vdcs.toArray(new Vdc[vdcs.size()])); if (port > 0) s3Config.setPort(port); s3Config.setSmartClient(smartClientEnabled); } s3Config.withIdentity(accessKey).withSecretKey(secretKey); if (apacheClientEnabled) { s3 = new S3JerseyClient(s3Config); } else { System.setProperty("http.maxConnections", "100"); s3 = new S3JerseyClient(s3Config, new URLConnectionClientHandler()); } // TODO: generalize uri translation EcsS3Util.S3Uri s3Uri = new EcsS3Util.S3Uri(); s3Uri.protocol = protocol; s3Uri.vdcs = vdcs; s3Uri.port = port; s3Uri.accessKey = accessKey; s3Uri.secretKey = secretKey; s3Uri.rootKey = rootKey; if (sourceUri == null) sourceUri = s3Uri.toUri(); if (!s3.bucketExists(bucketName)) { throw new ConfigurationException("The bucket " + bucketName + " does not exist."); } if (rootKey == null) rootKey = ""; // make sure rootKey isn't null // for version support. TODO: genericize version support if (target instanceof EcsS3Target) { s3Target = (EcsS3Target) target; if (s3Target.isIncludeVersions()) { VersioningConfiguration versioningConfig = s3.getBucketVersioning(bucketName); List<VersioningConfiguration.Status> versionedStates = Arrays .asList(VersioningConfiguration.Status.Enabled, VersioningConfiguration.Status.Suspended); versioningEnabled = versionedStates.contains(versioningConfig.getStatus()); } } if (sourceKeyList != null) { if (!sourceKeyList.exists()) { throw new ConfigurationException("The key list file " + sourceKeyList + " does not exist"); } } }
From source file:org.elasticsoftware.elasticactors.spring.AnnotationConfigWebApplicationContext.java
/** * Perform a scan within the specified base packages. * Note that {@link #refresh()} must be called in order for the context to * fully process the new class./*from www . j ava 2 s. co m*/ * @param basePackages the packages to check for annotated classes * @see #loadBeanDefinitions(DefaultListableBeanFactory) * @see #register(Class...) * @see #setConfigLocation(String) * @see #refresh() */ public void scan(String... basePackages) { Assert.notEmpty(basePackages, "At least one base package must be specified"); this.basePackages.addAll(Arrays.asList(basePackages)); }