List of usage examples for org.springframework.util Assert isNull
public static void isNull(@Nullable Object object, Supplier<String> messageSupplier)
From source file:org.finra.herd.service.impl.BusinessObjectFormatServiceImpl.java
@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override//from w w w . jav a 2 s . c om public BusinessObjectFormat updateBusinessObjectFormatRetentionInformation( BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatRetentionInformationUpdateRequest updateRequest) { // Validate and trim the business object format retention information update request update request. Assert.notNull(updateRequest, "A business object format retention information update request must be specified."); Assert.notNull(updateRequest.isRecordFlag(), "A record flag in business object format retention information update request must be specified."); businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, false); Assert.isNull(businessObjectFormatKey.getBusinessObjectFormatVersion(), "Business object format version must not be specified."); // Validate business object format retention information. RetentionTypeEntity recordRetentionTypeEntity = null; if (updateRequest.getRetentionType() != null) { // Trim the business object format retention in update request. updateRequest.setRetentionType(updateRequest.getRetentionType().trim()); // Retrieve and ensure that a retention type exists. recordRetentionTypeEntity = businessObjectFormatDaoHelper .getRecordRetentionTypeEntity(updateRequest.getRetentionType()); if (recordRetentionTypeEntity.getCode().equals(RetentionTypeEntity.PARTITION_VALUE)) { Assert.notNull(updateRequest.getRetentionPeriodInDays(), String.format("A retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE)); Assert.isTrue(updateRequest.getRetentionPeriodInDays() > 0, String.format( "A positive retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE)); } else { Assert.isNull(updateRequest.getRetentionPeriodInDays(), String.format("A retention period in days cannot be specified for %s retention type.", recordRetentionTypeEntity.getCode())); } } else { // Do not allow retention period to be specified without retention type. Assert.isNull(updateRequest.getRetentionPeriodInDays(), "A retention period in days cannot be specified without retention type."); } // Retrieve and ensure that a business object format exists. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper .getBusinessObjectFormatEntity(businessObjectFormatKey); businessObjectFormatEntity.setRecordFlag(BooleanUtils.isTrue(updateRequest.isRecordFlag())); businessObjectFormatEntity.setRetentionPeriodInDays(updateRequest.getRetentionPeriodInDays()); businessObjectFormatEntity.setRetentionType(recordRetentionTypeEntity); // Persist and refresh the entity. businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity); // Create and return the business object format object from the persisted entity. return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity); }
From source file:org.finra.herd.service.impl.BusinessObjectFormatServiceImpl.java
@NamespacePermission(fields = "#businessObjectFormatKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override/*from w w w .j av a2s . c o m*/ public BusinessObjectFormat updateBusinessObjectFormatSchemaBackwardsCompatibilityChanges( BusinessObjectFormatKey businessObjectFormatKey, BusinessObjectFormatSchemaBackwardsCompatibilityUpdateRequest businessObjectFormatSchemaBackwardsCompatibilityUpdateRequest) { // Validate business object format schema backwards compatibility changes update request. Assert.notNull(businessObjectFormatSchemaBackwardsCompatibilityUpdateRequest, "A business object format schema backwards compatibility changes update request must be specified."); Assert.notNull( businessObjectFormatSchemaBackwardsCompatibilityUpdateRequest .isAllowNonBackwardsCompatibleChanges(), "allowNonBackwardsCompatibleChanges flag in business object format schema backwards compatibility changes update request must be specified."); // Validate and trim the business object format key parameters. businessObjectFormatHelper.validateBusinessObjectFormatKey(businessObjectFormatKey, false); Assert.isNull(businessObjectFormatKey.getBusinessObjectFormatVersion(), "Business object format version must not be specified."); // Retrieve and ensure that a business object format exists. BusinessObjectFormatEntity businessObjectFormatEntity = businessObjectFormatDaoHelper .getBusinessObjectFormatEntity(businessObjectFormatKey); businessObjectFormatEntity.setAllowNonBackwardsCompatibleChanges( BooleanUtils.isTrue(businessObjectFormatSchemaBackwardsCompatibilityUpdateRequest .isAllowNonBackwardsCompatibleChanges())); // Persist and refresh the entity. businessObjectFormatEntity = businessObjectFormatDao.saveAndRefresh(businessObjectFormatEntity); // Create and return the business object format object from the persisted entity. return businessObjectFormatHelper.createBusinessObjectFormatFromEntity(businessObjectFormatEntity); }
From source file:org.finra.herd.service.impl.BusinessObjectFormatServiceImpl.java
/** * Validate the business object format parents * * @param businessObjectFormatParents business object format parents *///from ww w . j a v a2s. com private void validateBusinessObjectFormatParents(List<BusinessObjectFormatKey> businessObjectFormatParents) { // Validate parents business object format. if (!CollectionUtils.isEmpty(businessObjectFormatParents)) { for (BusinessObjectFormatKey parentBusinessObjectFormatKey : businessObjectFormatParents) { Assert.notNull(parentBusinessObjectFormatKey, "Parent object format must be specified."); businessObjectFormatHelper.validateBusinessObjectFormatKey(parentBusinessObjectFormatKey, false); Assert.isNull(parentBusinessObjectFormatKey.getBusinessObjectFormatVersion(), "Business object format version must not be specified."); } } }
From source file:org.ngrinder.security.NGrinderAuthenticationProvider.java
/** * Sets the PasswordEncoder instance to be used to encode and validate passwords. If not set, * the password will be compared as plain text. * <p>//from w w w .j a v a 2 s . c om * For systems which are already using salted password which are encoded with a previous * release, the encoder should be of type * {@code org.springframework.security.authentication.encoding.PasswordEncoder} . Otherwise, the * recommended approach is to use * {@code org.springframework.security.crypto.password.PasswordEncoder}. * * @param passwordEncoder * must be an instance of one of the {@code PasswordEncoder} types. */ public void setPasswordEncoder(Object passwordEncoder) { Assert.notNull(passwordEncoder, "passwordEncoder cannot be null"); if (passwordEncoder instanceof PasswordEncoder) { this.passwordEncoder = (PasswordEncoder) passwordEncoder; return; } if (passwordEncoder instanceof org.springframework.security.crypto.password.PasswordEncoder) { final org.springframework.security.crypto.password.PasswordEncoder delegate = cast(passwordEncoder); this.passwordEncoder = new PasswordEncoder() { public String encodePassword(String rawPass, Object salt) { checkSalt(salt); return delegate.encode(rawPass); } public boolean isPasswordValid(String encPass, String rawPass, Object salt) { checkSalt(salt); return delegate.matches(rawPass, encPass); } private void checkSalt(Object salt) { Assert.isNull(salt, "Salt value must be null when used with crypto module PasswordEncoder"); } }; return; } throw new IllegalArgumentException("passwordEncoder must be a PasswordEncoder instance"); }
From source file:org.springframework.amqp.rabbit.AsyncRabbitTemplate.java
private String getOrSetCorrelationIdAndSetReplyTo(Message message) { String correlationId;//from w ww .ja v a 2 s . c o m MessageProperties messageProperties = message.getMessageProperties(); Assert.notNull(messageProperties, "the message properties cannot be null"); String currentCorrelationId = messageProperties.getCorrelationId(); if (!StringUtils.hasText(currentCorrelationId)) { correlationId = UUID.randomUUID().toString(); messageProperties.setCorrelationId(correlationId); Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null"); } else { correlationId = currentCorrelationId; } messageProperties.setReplyTo(this.replyAddress); return correlationId; }
From source file:org.springframework.amqp.rabbit.connection.SimpleResourceHolder.java
/** * Bind the given resource for the given key to the current thread. * @param key the key to bind the value to (usually the resource factory) * @param value the value to bind (usually the active resource object) * @throws IllegalStateException if there is already a value bound to the thread *//*w w w.jav a2s . c o m*/ public static void bind(Object key, Object value) { Assert.notNull(value, "Value must not be null"); Map<Object, Object> map = resources.get(); // set ThreadLocal Map if none found if (map == null) { map = new HashMap<Object, Object>(); resources.set(map); } Object oldValue = map.put(key, value); Assert.isNull(oldValue, "Already value [" + oldValue + "] for key [" + key + "] bound to thread [" + Thread.currentThread().getName() + "]"); if (logger.isTraceEnabled()) { logger.trace("Bound value [" + value + "] for key [" + key + "] to thread [" + Thread.currentThread().getName() + "]"); } }
From source file:org.springframework.amqp.rabbit.core.AsyncRabbitTemplate.java
private String getOrSetCorrelationIdAndSetReplyTo(Message message) { String correlationId;/* ww w. j av a2s. c o m*/ MessageProperties messageProperties = message.getMessageProperties(); Assert.notNull(messageProperties, "the message properties cannot be null"); byte[] currentCorrelationId = messageProperties.getCorrelationId(); if (currentCorrelationId == null) { correlationId = UUID.randomUUID().toString(); messageProperties.setCorrelationId(correlationId.getBytes(this.charset)); Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null"); } else { correlationId = new String(currentCorrelationId, this.charset); } messageProperties.setReplyTo(this.replyAddress); return correlationId; }
From source file:org.springframework.batch.core.configuration.xml.StepParserStepFactoryBean.java
/** * Create a {@link Step} from the configuration provided. * /* ww w. j ava2 s . c om*/ * @see FactoryBean#getObject() */ public final Object getObject() throws Exception { if (hasChunkElement) { Assert.isNull(tasklet, "Step [" + name + "] has both a <chunk/> element and a 'ref' attribute referencing a Tasklet."); validateFaultTolerantSettings(); if (isFaultTolerant()) { FaultTolerantStepFactoryBean<I, O> fb = new FaultTolerantStepFactoryBean<I, O>(); configureSimple(fb); configureFaultTolerant(fb); return fb.getObject(); } else { SimpleStepFactoryBean<I, O> fb = new SimpleStepFactoryBean<I, O>(); configureSimple(fb); return fb.getObject(); } } else if (tasklet != null) { TaskletStep ts = new TaskletStep(); configureTaskletStep(ts); return ts; } else if (flow != null) { FlowStep ts = new FlowStep(); configureFlowStep(ts); return ts; } else if (job != null) { JobStep ts = new JobStep(); configureJobStep(ts); return ts; } else { PartitionStep ts = new PartitionStep(); configurePartitionStep(ts); return ts; } }
From source file:org.springframework.batch.core.repository.dao.JdbcStepExecutionDao.java
private List<Object[]> buildStepExecutionParameters(StepExecution stepExecution) { Assert.isNull(stepExecution.getId(), "to-be-saved (not updated) StepExecution can't already have an id assigned"); Assert.isNull(stepExecution.getVersion(), "to-be-saved (not updated) StepExecution can't already have a version assigned"); validateStepExecution(stepExecution); stepExecution.setId(stepExecutionIncrementer.nextLongValue()); stepExecution.incrementVersion(); //Should be 0 List<Object[]> parameters = new ArrayList<Object[]>(); String exitDescription = truncateExitDescription(stepExecution.getExitStatus().getExitDescription()); Object[] parameterValues = new Object[] { stepExecution.getId(), stepExecution.getVersion(), stepExecution.getStepName(), stepExecution.getJobExecutionId(), stepExecution.getStartTime(), stepExecution.getEndTime(), stepExecution.getStatus().toString(), stepExecution.getCommitCount(), stepExecution.getReadCount(), stepExecution.getFilterCount(), stepExecution.getWriteCount(), stepExecution.getExitStatus().getExitCode(), exitDescription, stepExecution.getReadSkipCount(), stepExecution.getWriteSkipCount(), stepExecution.getProcessSkipCount(), stepExecution.getRollbackCount(), stepExecution.getLastUpdated() }; Integer[] parameterTypes = new Integer[] { Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.BIGINT, Types.TIMESTAMP, Types.TIMESTAMP, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.TIMESTAMP }; parameters.add(0, Arrays.copyOf(parameterValues, parameterValues.length)); parameters.add(1, Arrays.copyOf(parameterTypes, parameterTypes.length)); return parameters; }
From source file:org.springframework.batch.item.database.AbstractCursorItemReader.java
/** * Execute the statement to open the cursor. *//* www. ja va 2 s .co m*/ @Override protected void doOpen() throws Exception { Assert.state(!initialized, "Stream is already initialized. Close before re-opening."); Assert.isNull(rs, "ResultSet still open! Close before re-opening."); initializeConnection(); openCursor(con); initialized = true; }