Example usage for org.springframework.util Assert hasText

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

Introduction

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

Prototype

public static void hasText(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Usage

From source file:cat.albirar.framework.sets.registry.impl.SetRegistryDefaultImpl.java

/**
 * {@inheritDoc}//  w  w  w  . j  av a 2 s .  c  o  m
 */
@Override
public boolean putSet(INamedSet<?> set) {
    Assert.notNull(set, "The 'set' argument are required'");
    Assert.hasText(set.getName(), "The setName are required and cannot be empty or only whitespace!");
    return (registry.put(set.getName(), set) == null);
}

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);
            }/*w ww .  j a v a2 s.  co  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:org.agatom.springatom.data.model.vin.VinNumber.java

private VinNumber(final String number) throws VinNumberServiceException {
    this();/*from ww  w. j  av a 2s  . c o  m*/
    try {
        Assert.hasText(number, "VinNumber must not be empty or null");
        Assert.isTrue(number.length() == 17, "VinNumber must have correct length");
    } catch (Exception exp) {
        throw new VinNumberServiceException("VinNumber is either null or has insufficient length 17", exp);
    }
    this.setNumber(number);
}

From source file:org.cleverbus.component.externalcall.ExternalCallComponent.java

@Override
public Endpoint createEndpoint(String uri) throws Exception {
    String endpointURI = ObjectHelper.after(uri, ":");
    if (endpointURI != null && endpointURI.startsWith("//")) {
        endpointURI = endpointURI.substring(2);
    }//from   w  w w .  java2  s  .c  om
    Assert.hasText(endpointURI, "External Call endpoint URI must not be empty");

    String keyTypeString = ObjectHelper.before(endpointURI, ":");
    Assert.notNull(keyTypeString, "External Call endpoint URI must be in format [keyType]:[targetURI]");
    String targetURI = ObjectHelper.after(endpointURI, ":");
    if (targetURI != null && targetURI.startsWith("//")) {
        targetURI = targetURI.substring(2);
    }
    Assert.hasText(keyTypeString, "External Call key type must not be empty");
    Assert.hasText(targetURI, "External Call target URI must not be empty");

    ExternalCallKeyType keyType = null;
    for (ExternalCallKeyType aKeyType : ExternalCallKeyType.values()) {
        if (aKeyType.name().equalsIgnoreCase(keyTypeString)) {
            keyType = aKeyType;
            break;
        }
    }
    Assert.notNull(keyType, String.format("External Call key type \"%s\" is invalid. It must be one of: %s",
            keyTypeString, Arrays.toString(ExternalCallKeyType.values())));

    return new ExternalCallEndpoint(uri, this, keyType, targetURI);
}

From source file:com.tealium.publisher.ftp.FtpSession.java

@Override
public String[] listNames(String path) throws IOException {
    Assert.hasText(path, "path must not be null");
    try {/* www .  ja  va2  s .c  o m*/
        FTPFile[] files = this.client.list(path);

        if (files != null) {
            String[] names = new String[files.length];

            for (int i = 0; i < files.length; i++) {
                names[i] = files[i].getName();
            }
            return names;
        } else {
            return null;
        }
    } catch (IllegalStateException | FTPIllegalReplyException | FTPException | FTPDataTransferException
            | FTPAbortedException | FTPListParseException e) {
        logger.error("listNames: " + path + "-" + getError(e), e);
        throw new IOException(getError(e).toString());
    }

}

From source file:fr.acxio.tools.agia.item.MultiLineItemReader.java

public synchronized void setNextVariableName(String sNextVariableName) {
    Assert.hasText(sNextVariableName, "nextVariableName must not be empty");
    nextVariableName = sNextVariableName;
}

From source file:com.oembedler.moon.graphql.engine.GraphQLQueryTemplate.java

public String buildQuery(final String mutationName) {
    Assert.hasText(mutationName, "Mutation value must not be null");

    GraphQLObjectType objectType = graphQLSchema.getMutationType();
    GraphQLFieldDefinition graphQLFieldDefinition = objectType.getFieldDefinition(mutationName);
    Assert.notNull(graphQLFieldDefinition, "Mutation does not exist");

    GraphQLObjectType graphQLOutputType = (GraphQLObjectType) graphQLFieldDefinition.getType();

    return String.format(MUTATION_TEMPLATE, mutationName, getMutationArgumentName(graphQLFieldDefinition),
            getMutationArgumentType(graphQLFieldDefinition), mutationName, getMutationInputArgumentName(),
            getMutationInputArgumentName(), expandNestedObjectTree("", graphQLOutputType));
}

From source file:org.esco.portlet.changeetab.mvc.controller.ChangeEtablissementController.java

@ActionMapping("changeEtab")
public void changeEtab(@ModelAttribute("command") final ChangeEtabCommand changeEtabCommand,
        final ActionRequest request, final ActionResponse response) throws Exception {
    final String selectedEtabCode = changeEtabCommand.getSelectedEtabCode();
    Assert.hasText(selectedEtabCode, "No Etablissement code selected !");

    ChangeEtablissementController.LOG.debug("Selected Etab code to change: [{}]", selectedEtabCode);

    final Collection<String> changeableEtabCodes = this.userInfoService.getChangeableEtabCodes(request);
    if (!changeableEtabCodes.contains(selectedEtabCode)) {
        // If selected Id is not an allowed Id
        ChangeEtablissementController.LOG
                .warn("Attempt to switch to a not allowed Etablissement with code: [{}] !", selectedEtabCode);
        ChangeEtablissementController.LOG.debug("Allowed Etablissements are: [{}]",
                StringUtils.collectionToCommaDelimitedString(changeableEtabCodes));
    } else {//from  w  w  w .j a v a 2  s  . c  o  m
        // Process the etablissement swap.
        final String userId = this.userInfoService.getUserId(request);
        if (StringUtils.hasText(userId)) {
            final Etablissement selectedEtab = this.etablissementService
                    .retrieveEtablissementsByCode(selectedEtabCode);
            this.userService.changeCurrentEtablissement(userId, selectedEtab);

            if (this.redirectAfterChange) {
                request.getPortalContext();
                response.sendRedirect(this.logoutUrlRedirect);
            }
        } else {
            ChangeEtablissementController.LOG
                    .warn("No user Id found in request ! Cannot process the etablishment swapping !");
        }
    }

    changeEtabCommand.reset();
}

From source file:fr.mby.portal.coreimpl.action.BasicUserAction.java

@Override
public String getParameter(final String name) throws IllegalArgumentException {
    Assert.hasText(name, "No property name provided !");

    String value = null;//from   w  ww. j a v a 2 s.  com
    final String[] values = this.getParameterValues(name);
    if (values != null && values.length > 0) {
        value = values[0];
    }

    return value;
}