List of usage examples for org.apache.commons.lang Validate notEmpty
public static void notEmpty(String string)
Validate an argument, throwing IllegalArgumentException
if the argument String is empty (null
or zero length).
Validate.notEmpty(myString);
The message in the exception is 'The validated string is empty'.
From source file:com.vmware.identity.idm.IDPConfig.java
/** * * @param alias can be null, but otherwise cannot be empty *///from w ww . j a v a 2 s . c o m public void setAlias(String alias) { if (alias != null) Validate.notEmpty(alias); this.alias = alias; }
From source file:net.iglyduck.utils.sqlbuilder.UnionUnit.java
protected UnionUnit union(String join, TempTable t) { Validate.notEmpty(join); Validate.notNull(t);// w ww .ja va2s . c om Validate.notNull(head); UnionItem item = new UnionItem(join).item(t); tail.setNext(item); tail = item; return this; }
From source file:io.cloudslang.lang.runtime.bindings.InputsBinding.java
private void bindInput(Input input, Map<String, ? extends Value> context, Map<String, Value> targetContext, Set<SystemProperty> systemProperties) { Value value;//from www . j a va 2 s.c o m String inputName = input.getName(); Validate.notEmpty(inputName); String errorMessagePrefix = "Error binding input: '" + inputName; try { value = resolveValue(input, context, targetContext, systemProperties); } catch (Throwable t) { throw new RuntimeException(errorMessagePrefix + "', \n\tError is: " + t.getMessage(), t); } if (input.isRequired() && isEmpty(value)) { throw new RuntimeException("Input with name: \'" + inputName + "\' is Required, but value is empty"); } validateStringValue(errorMessagePrefix, value); targetContext.put(inputName, value); }
From source file:ar.com.zauber.garfio.config.impl.PropertiesConfiguration.java
/** constructor @throws Exception on error */ public PropertiesConfiguration(final Properties properties, final String username, final String revision) throws Exception { Validate.notNull(properties);// w w w . ja v a2s .c o m Validate.notEmpty(username); this.config = properties; final String moduleClassName = config.getProperty(GARFIO_MODULE_CLASS); Validate.isTrue(!StringUtils.isBlank(moduleClassName), "You must set property " + GARFIO_MODULE_CLASS); try { final Class<GarfioModule> gafioModuleClass = (Class<GarfioModule>) Class.forName(moduleClassName); garfioModule = gafioModuleClass.newInstance(); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("the class specified in the " + "property " + GARFIO_MODULE_CLASS + " was not found `" + moduleClassName + "'"); } final String classicUsers = config.getProperty(GARFIO_CLASSIC_USERS, ""); final String template = config.getProperty(GARFIO_TEMPLATE); final Reader reader; if (template == null) { reader = new InputStreamReader(PropertiesConfiguration.class.getClassLoader() .getResourceAsStream("ar/com/zauber/garfio/templates/comment.vm")); } else { reader = new InputStreamReader(new FileInputStream(template)); } Validate.notNull(reader); commentFormatter = new SvnCommentFormatter(reader, new SvnCommitCommand(revision, getRepositoryName())); trackerSession = garfioModule.getTrackerSession(commentFormatter, username, config); Validate.notNull(trackerSession); parserFactory = new SimpleLogParserFactory(classicUsers, trackerSession); }
From source file:com.vmware.identity.saml.SamlAuthorityFactoryPerformanceWrapper.java
@Override public TokenServices createTokenServices(String tenantName) throws NoSuchIdPException, SystemException { Validate.notEmpty(tenantName); return new TokenServices(createTokenAuthority(tenantName), createTokenValidator(tenantName), createAuthnOnlyTokenValidator(tenantName)); }
From source file:demo.service.CustomerService.java
@DELETE @Path("/{id}/") public Response deleteCustomer(@PathParam("id") String id) { Validate.notNull(id);/*from w w w.ja va 2s . c o m*/ Validate.notEmpty(id); LOGGER.log(Level.FINE, "Invoking deleteCustomer, id={0}", id); long identifier = Long.parseLong(id); Response response; if (isCustomerExists(identifier)) { LOGGER.log(Level.FINE, "Specified customer exists, remove data, id={0}", id); customers.remove(identifier); LOGGER.log(Level.INFO, "Customer was removed successful, id={0}", id); response = Response.ok().build(); } else { LOGGER.log(Level.SEVERE, "Specified customer does not exist, remove fail, id={0}", id); response = Response.notModified().build(); } return response; }
From source file:me.eccentric_nz.TARDIS.utility.TARDISUUIDCache.java
/** * Get the UUID from the cache for the player named 'name', with blocking * get.//from ww w . j a v a2s . co m * * If the player named is not in the cache, then we will fetch the UUID in a * blocking fashion. Note that this will block the thread until the fetch is * complete, so only use this in a thread or in special circumstances. * * @param name The player name. * @return a UUID */ public UUID getId(String name) { Validate.notEmpty(name); UUID uuid = cache.get(name); if (uuid == null) { syncFetch(nameList(name)); return cache.get(name); } else if (uuid.equals(ZERO_UUID)) { uuid = null; } return uuid; }
From source file:com.vmware.identity.authz.RoleAdminBuilder.java
/** * Define a role with group where users having this role will be stored into. * <p>/*from www . j a v a 2 s . c om*/ * Constructor is also calling this method with initially specified role, * group and details. * * @param role * role definition; {@code not-null} value is required * @param group * group name containing users with given role; {@code not-null} * and not-empty string value is required * @param details * group details used to create a group with given name if such * does not exist; {@code not-null} value is required */ public RoleAdminBuilder<R> addRoleGroup(R role, String group, GroupDetails details) { Validate.notNull(role); Validate.notEmpty(group); Validate.notNull(details); _roleGroups.put(role, new SystemGroup(group, details)); return this; }
From source file:com.vmware.identity.saml.config.Config.java
/** * * Creates a new configuration/*from w w w .j av a2 s. c o m*/ * * @param samlAuthorityConfig * Saml authority configuration properties, required * @param tokenRestrictions * token issuance configuration properties, required * @param validCerts * not empty array of SAML authority certificates, required. No * assumptions should be made for the order of the certificate * chains. However, within certificate chains, the certificates are * ordered from leaf to root CA. Entire chains can be kept even if * some of them is no longer valid, because when certificate is * checked if it is signed with a certificate among those chains, * this certificate will be no longer valid itself. required * @param clockTolerance * Maximum allowed clock skew between token sender and consumer, in * milliseconds, required. * @param inExternalIdps a list of external idps registered. * @throws IllegalArgumentException * when some of the arguments are invalid */ public Config(SamlAuthorityConfiguration samlAuthorityConfig, TokenRestrictions tokenRestrictions, Collection<List<Certificate>> validCerts, long clockTolerance, Collection<IDPConfig> inExternalIdps) { Validate.notNull(samlAuthorityConfig); Validate.notNull(tokenRestrictions); Validate.notEmpty(validCerts); List<Certificate> authorityCert = samlAuthorityConfig.getSigningCertificateChain(); boolean authorityCertInValidCerts = false; for (List<Certificate> currentChain : validCerts) { Validate.notEmpty(currentChain); Validate.noNullElements(currentChain); if (!authorityCertInValidCerts && currentChain.equals(authorityCert)) { authorityCertInValidCerts = true; } } Validate.isTrue(authorityCertInValidCerts, "signing certificate chain is not in valid chains."); Validate.isTrue(clockTolerance >= 0); this.samlAuthorityConfig = samlAuthorityConfig; this.validCerts = validCerts; this.clockTolerance = clockTolerance; this.tokenRestrictions = tokenRestrictions; HashMap<String, IDPConfig> idpsSet = new HashMap<String, IDPConfig>(); if (inExternalIdps != null) { for (IDPConfig conf : inExternalIdps) { if (conf != null) { idpsSet.put(conf.getEntityID(), conf); } } } this.externalIdps = Collections.unmodifiableMap(idpsSet); }
From source file:net.iglyduck.utils.sqlbuilder.JoinUnit.java
protected JoinUnit join(String join, WrapTable t, ExpressUnit on) { Validate.notEmpty(join); Validate.notNull(t);//from w w w.j a v a2s . c o m Validate.notNull(head); JoinItem item = new JoinItem(join).item(t).on(on); tail.setNext(item); tail = item; return this; }