List of usage examples for org.springframework.util Assert hasLength
public static void hasLength(@Nullable String text, Supplier<String> messageSupplier)
From source file:org.esupportail.portlet.filemanager.services.evaluators.ListUserAttributesEvaluatorEditor.java
/** * @throws Exception//from www.j av a2 s.c om * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ public void afterPropertiesSet() throws Exception { Assert.notEmpty(getValueList(), "The property valueList in class " + this.getClass().getSimpleName() + " must not be null and not empty."); Assert.hasLength(getUserAttribute(), "The property userAttribute in class " + this.getClass().getSimpleName() + " must not be null and not empty."); Assert.hasLength(getMode(), "The property mode in class " + this.getClass().getSimpleName() + " must not be null and not empty."); this.setAsText(getValueList(), getUserAttribute(), getMode()); }
From source file:org.jdbcluster.domain.DomainCheckerImpl.java
public boolean check(ICluster cluster, String propSlavePath) { Assert.notNull(cluster, "Cluster may not be null"); Assert.hasLength(propSlavePath, "propSlavePath may not be null"); Field fSlave = JDBClusterUtil.getField(propSlavePath, cluster); String slaveValue = (String) JDBClusterUtil.invokeGetPropertyMethod(propSlavePath, cluster); DomainDependancy ddSlave = fSlave.getAnnotation(DomainDependancy.class); if (logger.isDebugEnabled()) logger.debug("check for cluster [" + cluster.getClass().getName() + "] and Property Slave Path [" + propSlavePath + "] and Slave Value [" + slaveValue + "] and Domain Dependancy Domain Id [" + ddSlave.domainId() + "]"); return check(cluster, fSlave, slaveValue, ddSlave); }
From source file:org.terasoluna.gfw.common.sequencer.JdbcSequencer.java
/** * <p>/*from w ww . j a v a2 s. c o m*/ * check properties. throw IllegalArgumentException under the following conditions * </p> * <ul> * <li>{@link #jdbcTemplate} is null</li> * <li>{@link #nextValueQuery} is empty</li> * <li>{@link #currentValueQuery} is empty</li> * <li>{@link #sequenceClass} is null</li> * </ul> * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws IllegalArgumentException { Assert.notNull(jdbcTemplate, "jdbcTemplate must not be null"); Assert.hasLength(nextValueQuery, "nextValueQuery must not be empty"); Assert.hasLength(currentValueQuery, "currentValueQuery must not be empty"); Assert.notNull(sequenceClass, "sequenceClass must not be null"); }
From source file:org.kmnet.com.fw.common.dao.JdbcSequencer.java
/** * <p>/*ww w .j a va 2s .c om*/ * check properties. throw IllegalArgumentException under the following conditions * </p> * <ul> * <li>{@link #jdbcTemplate} is null</li> * <li>{@link #nextValueQuery} is empty</li> * <li>{@link #currentValueQuery} is empty</li> * <li>{@link #sequenceClass} is null</li> * </ul> * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() */ @Override public void afterPropertiesSet() throws IllegalArgumentException { Assert.notNull(jdbcTemplate, "namedJdbcTemplate must not be null"); Assert.hasLength(nextValueQuery, "nextValueQuery must not be empty"); Assert.hasLength(currentValueQuery, "currentValueQuery must not be empty"); Assert.notNull(sequenceClass, "sequenceClass must not be null"); }
From source file:org.cloudfoundry.client.lib.rest.CloudControllerClientV1.java
public String login() { if (cloudCredentials.getEmail() == null) { Assert.hasLength(cloudCredentials.getToken(), "No authentication details provided"); token = cloudCredentials.getToken(); return token; }/*from w ww . j a v a 2 s .com*/ Assert.hasLength(cloudCredentials.getEmail(), "Email cannot be null or empty"); Assert.hasLength(cloudCredentials.getPassword(), "Password cannot be null or empty"); if (oauthClient != null) { OAuth2AccessToken token = oauthClient.getToken(cloudCredentials.getEmail(), cloudCredentials.getPassword()); this.token = token.getTokenType() + " " + token.getValue(); return this.token; } else { Map<String, String> payload = new HashMap<String, String>(); payload.put("password", cloudCredentials.getPassword()); Map<String, String> response = getRestTemplate().postForObject(getUrl("users/{id}/tokens"), payload, Map.class, cloudCredentials.getEmail()); token = response.get("token"); return token; } }
From source file:com.skymobi.monitor.security.MongoUserManager.java
private void saveUser(User user) { Assert.hasLength(user.getUsername(), "username can't be empty"); Assert.hasLength(user.getPassword(), "password can't be empty"); mongoTemplate.save(user, COLLECTION_NAME_USER); }
From source file:org.jdbcluster.privilege.PrivilegeCheckerImpl.java
/** * intersects required static privileges for cluster new against given * privileges/*from w w w . ja v a 2s.co m*/ * * @param clusterType defines the Cluster to check * @return true if the privileges are sufficient */ public boolean checkClusterNew(IUser user, String clusterType) { Assert.hasLength(clusterType, "clusterType may not be null or \"\""); Class<? extends Cluster> clazz = ClusterTypeFactory.newInstance(clusterType).getClusterClass(); // if Cluster is no PrivilegedCluster creation is always possible if (!PrivilegedCluster.class.isAssignableFrom(clazz)) return true; Class<? extends PrivilegedCluster> clusterClass = clazz.asSubclass(PrivilegedCluster.class); Set<String> requiredPrivileges = calcStaticClusterPrivileges(clusterClass); return userPrivilegeIntersect(user, requiredPrivileges); }
From source file:org.esupportail.portlet.filemanager.services.evaluators.UserAttributesEvaluator.java
/** * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet() *///w w w .j a v a 2 s. c o m public void afterPropertiesSet() throws Exception { Assert.hasLength(attribute, "The portlet Attribute to evaluate must be set !"); Assert.hasLength(value, "The value to compare must be set !"); Assert.notNull(mode, "The comparison mode must not be null !"); }
From source file:org.pentaho.custom.authentication.provider.userroledao.hibernate.HibernateUserRoleDao.java
public void deleteUser(IUser userToDelete) throws NotFoundException, UncategorizedUserRoleDaoException { Assert.notNull(userToDelete,/*from w w w . j ava 2 s . co m*/ Messages.getInstance().getString("HibernateUserRoleDao.ERROR_0001_USER_CANNOT_BE_NULL")); //$NON-NLS-1$ Assert.hasLength(userToDelete.getUsername(), Messages.getInstance().getString("HibernateUserRoleDao.ERROR_0002_USERNAME_CANNOT_BE_BLANK")); //$NON-NLS-1$ IUser user = getUser(userToDelete.getUsername()); if (user != null) { try { getHibernateTemplate().delete(user); } catch (DataAccessException e) { throw new UncategorizedUserRoleDaoException( Messages.getInstance().getString("HibernateUserRoleDao.ERROR_0004_DATA_ACCESS_EXCEPTION"), //$NON-NLS-1$ e); } } else { throw new NotFoundException(userToDelete.getUsername()); } }
From source file:com.yeahmobi.yunit.DbUnitRunner.java
private void verifyExpected(DbUnitTestContext testContext, Collection<ExpectedDatabase> annotations) throws Exception { if (testContext.getTestException() != null) { if (logger.isDebugEnabled()) { logger.debug("Skipping @DatabaseTest expectation due to test exception " + testContext.getTestException().getClass()); }//from w w w . j a v a 2s.co m return; } IDatabaseConnection connection = testContext.getConnection(); for (ExpectedDatabase annotation : annotations) { String query = annotation.query(); String table = annotation.table(); IDataSet expectedDataSet = loadDataset(testContext, annotation.value(), "expected.xml"); if (expectedDataSet != null) { if (logger.isDebugEnabled()) { logger.debug("Veriftying @DatabaseTest expectation using " + annotation.value()); } DatabaseAssertion assertion = annotation.assertionMode().getDatabaseAssertion(); if (StringUtils.hasLength(query)) { Assert.hasLength(table, "The table name must be specified when using a SQL query"); ITable expectedTable = expectedDataSet.getTable(table); ITable actualTable = connection.createQueryTable(table, query); assertion.assertEquals(expectedTable, actualTable); } else if (StringUtils.hasLength(table)) { ITable actualTable = connection.createTable(table); ITable expectedTable = expectedDataSet.getTable(table); assertion.assertEquals(expectedTable, actualTable); } else { IDataSet actualDataSet = connection.createDataSet(); assertion.assertEquals(expectedDataSet, actualDataSet); } } } }