Example usage for org.springframework.util Assert isTrue

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

Introduction

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

Prototype

public static void isTrue(boolean expression, Supplier<String> messageSupplier) 

Source Link

Document

Assert a boolean expression, throwing an IllegalArgumentException if the expression evaluates to false .

Usage

From source file:com.jaxio.celerio.factory.EntityConfigFactory.java

public void assertEntityConfigListIsConsistent(List<EntityConfig> entityConfigs) {
    Map<String, EntityConfig> entityConfigsByEntityName = newHashMap();

    for (EntityConfig entityConfig : entityConfigs) {
        assertEntityConfigIsValid(entityConfig);
        if (!entityConfig.hasEntityName() && entityConfig.hasTableName()) {
            applyEntityNameFallBack(entityConfig);
        }/*www.jav  a 2  s .c  o m*/
        Assert.isTrue(!entityConfigsByEntityName.containsKey(entityConfig.getEntityName().toUpperCase()),
                "Two entity config cannot have the same entity name: " + entityConfig.getEntityName());
        entityConfigsByEntityName.put(entityConfig.getEntityName().toUpperCase(), entityConfig);
    }

    // please respect the call ordering
    resolveMissingTableNameOnEntityConfigs(entityConfigsByEntityName);
    resolveMissingInheritanceStrategyOnEntityConfigs(entityConfigsByEntityName);
}

From source file:com.kurento.kmf.jsonrpcconnector.internal.server.PerSessionJsonRpcHandler.java

private JsonRpcHandler<T> getHandler(Session session) {
    JsonRpcHandler<T> handler = this.handlers.get(session);
    Assert.isTrue(handler != null, "JsonRpcHandler not found for " + session);
    return handler;
}

From source file:org.xine.marketplace.frontend.views.security.JsfLoginUrlAuthenticationEntryPoint.java

@Override
public void afterPropertiesSet() throws Exception {
    Assert.isTrue(StringUtils.hasText(this.loginFormUrl) && UrlUtils.isValidRedirectUrl(this.loginFormUrl),
            "loginFormUrl must be specified and must be a valid redirect URL");
    if (this.useForward && UrlUtils.isAbsoluteUrl(this.loginFormUrl)) {
        throw new IllegalArgumentException("useForward must be false if using an absolute loginFormURL");
    }/*from w  w  w  . j a va  2 s  .  c o  m*/
    Assert.notNull(this.portMapper, "portMapper must be specified");
    Assert.notNull(this.portResolver, "portResolver must be specified");
}

From source file:org.cleverbus.core.common.asynch.msg.MessageSplitterImpl.java

@Override
@Handler/*from  w  w  w  . ja v  a 2s.com*/
public final void splitMessage(@Header(AsynchConstants.MSG_HEADER) Message parentMsg, @Body Object body) {
    Assert.notNull(parentMsg, "the parentMsg must not be null");
    Assert.isTrue(parentMsg.getState() == MsgStateEnum.PROCESSING && parentMsg.getFailedCount() == 0,
            "only new message can be split to child messages");

    // get child messages
    List<ChildMessage> childMessages = splitterCallback.getChildMessages(parentMsg, body);

    Log.debug("Count of child messages: " + childMessages.size());

    // create messages
    final List<Message> messages = new ArrayList<Message>(childMessages.size());
    for (int i = 0; i < childMessages.size(); i++) {
        ChildMessage childMsg = childMessages.get(i);

        Message message = ChildMessage.createMessage(childMsg);

        // correlation ID is unique - add order to distinguish it
        message.setCorrelationId(parentMsg.getCorrelationId() + "_" + i);
        messages.add(message);
    }

    // mark original message as parent message
    parentMsg.setParentMessage(true);

    // save all messages at once
    messageService.insertMessages(messages);

    final ProducerTemplate msgProducer = camelCtx.createProducerTemplate();

    try {
        // process messages separately one by one
        executor.submit(new Runnable() {
            @Override
            public void run() {
                for (Message msg : messages) {
                    Log.debug("Message " + msg.toHumanString() + " will be processed ...");

                    // send to process (wait for reply and then process next child message); it's new exchange
                    msgProducer.requestBody(AsynchMessageRoute.URI_SYNC_MSG, msg);

                    Log.debug("Message " + msg.toHumanString() + " was successfully processed.");
                }
            }
        });
    } finally {
        if (msgProducer != null) {
            try {
                msgProducer.stop();
            } catch (Exception ex) {
                Log.error("error occurred during stopping producerTemplate", ex);
            }
        }
    }
}

From source file:com.athena.peacock.controller.web.ospackage.PackageController.java

@RequestMapping("/reload")
public @ResponseBody SimpleJsonResponse reload(SimpleJsonResponse jsonRes, PackageDto ospackage)
        throws Exception {
    Assert.isTrue(StringUtils.isNotEmpty(ospackage.getMachineId()), "machineId must not be null.");

    OSPackageInfoMessage msg = new OSPackageInfoMessage(MessageType.PACKAGE_INFO);
    msg.setAgentId(ospackage.getMachineId());
    msg.setBlocking(false);/*from  w  ww.j  ava  2 s .c om*/

    try {
        PeacockDatagram<AbstractMessage> datagram = new PeacockDatagram<AbstractMessage>(msg);
        peacockTransmitter.sendMessage(datagram);

        jsonRes.setSuccess(true);
        jsonRes.setMsg("    ? ?.");
    } catch (Exception e) {
        String message = "      ? ?.";

        if (e.getMessage() != null && e.getMessage().equals("Channel is null.")) {
            message += "<br/>Instance? ? ?.";
        }
        jsonRes.setSuccess(false);
        jsonRes.setMsg(message);

        logger.error("Unhandled Expeption has occurred. ", e);
    }

    return jsonRes;
}

From source file:de.itsvs.cwtrpc.security.AbstractRpcProcessingFilter.java

public void setFilterProcessesUrl(String filterProcessesUrl) {
    Assert.hasText(filterProcessesUrl, "'filterProcessesUrl' must not be null");
    Assert.isTrue(UrlUtils.isValidRedirectUrl(filterProcessesUrl), filterProcessesUrl + " is not a valid URL");
    this.filterProcessesUrl = filterProcessesUrl;
}

From source file:com.frank.search.solr.repository.support.SolrRepositoryFactoryBean.java

@Override
public void afterPropertiesSet() {

    super.afterPropertiesSet();
    Assert.isTrue((operations != null || solrClient != null),
            "SolrOperations or SolrClient must be configured!");
}

From source file:com.athena.peacock.common.core.util.ZipUtil.java

/**
 * <pre>/*  w  w w.  jav a  2  s.com*/
 * ? ?? ? ?  .
 * </pre>
 * @param sourceFile
 * @param destDir
 * @return 
 * @throws IOException
 */
public static String decompress(String sourceFile, String destDir) throws IOException {
    Assert.notNull(sourceFile, "sourceFile cannot be null.");

    File src = new File(sourceFile);
    File dest = null;

    Assert.isTrue(src.exists(), src + " does not exist.");
    Assert.isTrue(src.isFile(), sourceFile + " is not a file.");

    if (StringUtils.isEmpty(destDir)) {
        dest = new File(src.getParent(), src.getName().substring(0, src.getName().lastIndexOf(".")));
    } else {
        dest = new File(destDir);
    }

    Unzip unzip = new Unzip();
    unzip.setSrc(src);
    unzip.setDest(dest);
    unzip.execute();

    return dest.getAbsolutePath();
}

From source file:org.kurento.jsonrpc.internal.server.PerSessionJsonRpcHandler.java

@Override
public void handleRequest(Transaction transaction, Request<T> request) throws Exception {

    JsonRpcHandler<T> handler = getHandler(transaction.getSession());

    Assert.isTrue(handler != null, "Handler of class " + provider.getClass()
            + " can't be created. Be sure that there" + " is a bean registered of this type");

    try {/*from   w  w w.  ja v a  2s.c  o  m*/
        handler.handleRequest(transaction, request);
    } catch (Exception e) {
        handler.handleUncaughtException(transaction.getSession(), e);
    }
}

From source file:org.broadleafcommerce.payment.service.gateway.PayPalExpressTransactionServiceImpl.java

@Override
public PaymentResponseDTO capture(PaymentRequestDTO paymentRequestDTO) throws PaymentException {
    Assert.isTrue(paymentRequestDTO.getAdditionalFields().containsKey(MessageConstants.TRANSACTIONID),
            "The RequestDTO must contain a TRANSACTIONID");

    PayPalPaymentRequest request = buildBasicRequest(paymentRequestDTO, PayPalTransactionType.CAPTURE);
    request.setMethodType(PayPalMethodType.CAPTURE);
    request.setTransactionID(//from www  . ja v  a  2 s  . c  om
            (String) paymentRequestDTO.getAdditionalFields().get(MessageConstants.TRANSACTIONID));

    PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.THIRD_PARTY_ACCOUNT,
            PayPalExpressPaymentGatewayType.PAYPAL_EXPRESS);
    PayPalPaymentResponse response;

    response = (PayPalPaymentResponse) process(request);
    setCommonPaymentResponse(response, responseDTO);
    responseDTO.successful(response.isSuccessful());
    responseDTO.paymentTransactionType(PaymentTransactionType.CAPTURE);
    setDecisionInformation(response, responseDTO);

    return responseDTO;
}