Example usage for org.springframework.util Assert isNull

List of usage examples for org.springframework.util Assert isNull

Introduction

In this page you can find the example usage for org.springframework.util Assert isNull.

Prototype

public static void isNull(@Nullable Object object, Supplier<String> messageSupplier) 

Source Link

Document

Assert that an object is null .

Usage

From source file:org.zalando.failsafeactuator.service.CircuitBreakerRegistry.java

/**
 * Will put the {@link CircuitBreaker} into the registry. There is no check which avoids overwriting of identifiers. Therefore be sure that your identifiers
 * are unique, or you want to overwrite the current {@link CircuitBreaker} which is registered with this identifier.
 *
 * @param breaker Which should be added//ww  w .  jav  a 2  s  .  c  om
 * @param name Which is used to identify the CircuitBreaker
 */
void registerCircuitBreaker(final CircuitBreaker breaker, final String name) {
    Assert.hasText(name, "Name for circuit breaker needs to be set");
    Assert.notNull(breaker, "Circuit breaker to add, can't be null");

    final CircuitBreaker replaced = concurrentBreakerMap.put(name, breaker);
    Assert.isNull(replaced, String.format(ALREADY_REGISTERED_ERROR, name));
}

From source file:fr.mby.opa.picsimpl.dao.DbProposalDao.java

@Override
public ProposalBranch forkBranch(final ProposalBranch fork, final long branchToForkId) {
    Assert.notNull(fork, "No ProposalBag supplied !");
    Assert.isNull(fork.getId(), "Id should not be set for creation !");

    // Duplicate the branch to Fork
    new TxCallback(this.getEmf()) {

        @Override/*from w w  w .  j av  a  2  s .c  om*/
        @SuppressWarnings("unchecked")
        protected void executeInTransaction(final EntityManager em) {
            final Query loadFullBranchQuery = em.createNamedQuery(ProposalBranch.LOAD_FULL_BRANCH);
            loadFullBranchQuery.setParameter("branchId", branchToForkId);
            final ProposalBranch branchToFork = Iterables.getFirst(loadFullBranchQuery.getResultList(), null);
            if (branchToFork == null) {
                throw new ProposalBranchNotFoundException();
            }

            fork.setBags(branchToFork.getBags());
            em.persist(fork);
        }
    };

    return fork;
}

From source file:org.socialsignin.spring.data.dynamodb.repository.cdi.DynamoDBRepositoryBean.java

/**
 * Constructs a {@link DynamoDBRepositoryBean}.
 * //w ww .j a  v a  2 s.  c o m
 * @param beanManager
 *            must not be {@literal null}.
 * @param dynamoDBMapperBean
 *            must not be {@literal null}.
 * @param qualifiers
 *            must not be {@literal null}.
 * @param repositoryType
 *            must not be {@literal null}.
 */
DynamoDBRepositoryBean(BeanManager beanManager, Bean<AmazonDynamoDB> amazonDynamoDBBean,
        Bean<DynamoDBMapperConfig> dynamoDBMapperConfigBean, Bean<DynamoDBOperations> dynamoDBOperationsBean,
        Set<Annotation> qualifiers, Class<T> repositoryType) {

    super(qualifiers, repositoryType, beanManager);
    if (dynamoDBOperationsBean == null) {
        Assert.notNull(amazonDynamoDBBean);
    } else {
        Assert.isNull(amazonDynamoDBBean,
                "Cannot specify both amazonDynamoDB bean and dynamoDBOperationsBean in repository configuration");
        Assert.isNull(dynamoDBMapperConfigBean,
                "Cannot specify both dynamoDBMapperConfigBean bean and dynamoDBOperationsBean in repository configuration");

    }
    this.amazonDynamoDBBean = amazonDynamoDBBean;
    this.dynamoDBMapperConfigBean = dynamoDBMapperConfigBean;
    this.dynamoDBOperationsBean = dynamoDBOperationsBean;
}

From source file:org.openinfinity.sso.security.spring.IdentityBasedAuthenticationUserDetailsService.java

public UserDetails loadUserDetails(PreAuthenticatedAuthenticationToken token) throws UsernameNotFoundException {
    LOGGER.debug("IdentityBasedAuthenticationUserDetailsService.loadUserDetails initialized.");
    String sessionIdentifier = httpServletRequest.getAttribute(ATTRIBUTE_SESSION_IDENTIFIER) != null
            ? (String) httpServletRequest.getAttribute(ATTRIBUTE_SESSION_IDENTIFIER)
            : (String) httpServletRequest.getAttribute(HEADER_SESSION_IDENTIFIER);
    String sessionId = (String) httpServletRequest.getAttribute(sessionIdentifier);
    Assert.isNull(sessionId, "Session id not found from the request.");
    LOGGER.debug(/*from   w  w w.  j a  v  a2  s. c om*/
            "IdentityBasedAuthenticationUserDetailsService.loadUserDetails fetched identity with session id ["
                    + sessionId + "]");
    final Identity identity = IdentityContext.loadIdentity(sessionId);
    LOGGER.debug("IdentityBasedAuthenticationUserDetailsService.loadUserDetails session found for identity id ["
            + identity.getUserPrincipal().getName() + "]");
    token.setDetails(identity);
    return new UserDetails() {

        private static final long serialVersionUID = 1404244132102359899L;

        public Collection<? extends GrantedAuthority> getAuthorities() {
            Collection<GrantedAuthority> grantedAuthorities = new TreeSet<GrantedAuthority>();
            for (Principal principal : identity.getAllPrincipalsForIdentity()) {
                GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(principal.getName());
                grantedAuthorities.add(grantedAuthority);
            }
            return grantedAuthorities;
        }

        public String getPassword() {
            return identity.getPassword();
        }

        public String getUsername() {
            return identity.getUserPrincipal().getName();
        }

        public boolean isAccountNonExpired() {
            return true;
        }

        public boolean isAccountNonLocked() {
            return true;
        }

        public boolean isCredentialsNonExpired() {
            return true;
        }

        public boolean isEnabled() {
            return true;
        }

    };
}

From source file:it.reply.orchestrator.config.properties.OidcProperties.java

@Override
public void afterPropertiesSet() throws Exception {
    if (enabled) {
        for (IamProperties iamConfiguration : iamProperties) {
            String issuer = iamConfiguration.getIssuer();
            Assert.hasText(issuer, "OIDC Issuer field must not be empty");
            OrchestratorProperties orchestratorConfiguration = iamConfiguration.getOrchestrator();
            Assert.notNull(orchestratorConfiguration,
                    "Orchestrator OAuth2 client for issuer " + issuer + " must be provided");
            Assert.isNull(iamPropertiesMap.put(issuer, iamConfiguration),
                    "Duplicated configuration provided for OIDC issuer " + issuer);
            Assert.hasText(orchestratorConfiguration.getClientId(),
                    "Orchestrator OAuth2 clientId for issuer " + issuer + " must be provided");
            Assert.hasText(orchestratorConfiguration.getClientSecret(),
                    "Orchestrator OAuth2 clientSecret for issuer " + issuer + " must be provided");
            if (orchestratorConfiguration.getScopes().isEmpty()) {
                LOG.warn("No Orchestrator OAuth2 scopes provided for issuer {}", issuer);
            }//from   www . j  a  va  2  s. c  o  m

            OidcClientProperties cluesConfiguration = iamConfiguration.getClues();
            if (cluesConfiguration != null) {
                Assert.hasText(cluesConfiguration.getClientId(),
                        "CLUES OAuth2 clientId for issuer " + issuer + " must be provided");
                Assert.hasText(cluesConfiguration.getClientSecret(),
                        "CLUES OAuth2 clientSecret for issuer " + issuer + " must be provided");
            } else {
                LOG.warn("No CLUES OAuth2 configuration provided for issuer {}", issuer);
            }
        }
        if (iamPropertiesMap.keySet().isEmpty()) {
            LOG.warn("Empty IAM configuration list provided");
        } else {
            LOG.info("IAM configuration successfully parsed for issuers {}", iamPropertiesMap.keySet());
        }
    } else {
        LOG.info("IAM support is disabled");
    }

}

From source file:com.epam.catgenome.manager.DownloadFileManager.java

/**
 * Download file from URL to file in our system !!!DANGEROUS!!!
 * This method just copy all information from file to file.
 * URL must be from white list, this must be checked where the method is called.
 *
 * @param urlString URL string of resource to download
 * @return downloaded File object/* w  w  w .  j  a  va2s . c  o  m*/
 * @throws IOException
 */
public File downloadFromURL(final String urlString) throws IOException {
    final File newFile = createFileFromURL(urlString);
    final URL url = new URL(urlString);
    checkURL(url);
    final File tmpFile = createTmpFileFromURL(urlString);
    String errorString = downloadFileFromURL(url, tmpFile);
    Assert.isNull(errorString, errorString);
    Files.copy(tmpFile, newFile);
    return newFile;
}

From source file:com.creactiviti.piper.core.Coordinator.java

/**
 * Starts a job instance./*from  w ww  . j ava 2  s  .  c o m*/
 * 
 * @param aJobParams
 *          The Key-Value map representing the job
 *          parameters
 * @return Job
 *           The instance of the Job
 */
public Job create(Map<String, Object> aJobParams) {
    Assert.notNull(aJobParams, "request can't be null");
    MapObject jobParams = MapObject.of(aJobParams);
    String pipelineId = jobParams.getRequiredString(PIPELINE_ID);
    Pipeline pipeline = pipelineRepository.findOne(pipelineId);
    Assert.notNull(pipeline, String.format("Unkown pipeline: %s", pipelineId));
    Assert.isNull(pipeline.getError(),
            pipeline.getError() != null ? String.format("%s: %s", pipelineId, pipeline.getError().getMessage())
                    : null);

    validate(jobParams, pipeline);

    MapObject inputs = MapObject.of(jobParams.getMap(INPUTS, Collections.EMPTY_MAP));
    List<Accessor> webhooks = jobParams.getList(WEBHOOKS, MapObject.class, Collections.EMPTY_LIST);
    List<String> tags = (List<String>) aJobParams.get(TAGS);

    SimpleJob job = new SimpleJob();
    job.setId(UUIDGenerator.generate());
    job.setLabel(jobParams.getString(DSL.LABEL, pipeline.getLabel()));
    job.setPriority(jobParams.getInteger(DSL.PRIORITY, Prioritizable.DEFAULT_PRIORITY));
    job.setPipelineId(pipeline.getId());
    job.setStatus(JobStatus.CREATED);
    job.setCreateTime(new Date());
    job.setParentTaskExecutionId((String) aJobParams.get(DSL.PARENT_TASK_EXECUTION_ID));
    job.setTags(tags != null ? tags.toArray(new String[tags.size()]) : new String[0]);
    job.setWebhooks(webhooks != null ? webhooks : Collections.EMPTY_LIST);
    job.setInputs(inputs);
    log.debug("Job {} started", job.getId());
    jobRepository.create(job);

    MapContext context = new MapContext(jobParams.getMap(INPUTS, Collections.EMPTY_MAP));
    contextRepository.push(job.getId(), context);

    eventPublisher
            .publishEvent(PiperEvent.of(Events.JOB_STATUS, "jobId", job.getId(), "status", job.getStatus()));

    messenger.send(Queues.JOBS, job);

    return job;
}

From source file:com._4dconcept.springframework.data.marklogic.core.query.QueryBuilder.java

public QueryBuilder ofType(Class<?> type) {
    Assert.isNull(example, "Query by example or by type are mutually exclusive");
    this.type = type;
    return this;
}

From source file:com._4dconcept.springframework.data.marklogic.core.query.QueryBuilder.java

public QueryBuilder alike(Example example) {
    Assert.isNull(type, "Query by example or by type are mutually exclusive");
    this.example = example;
    return this;
}

From source file:com.jaxio.celerio.model.Attribute.java

public void setColumnConfig(ColumnConfig columnConfig) {
    Assert.isNull(this.columnConfig, "you can set the columnConfig only once");
    this.columnConfig = columnConfig;
}