Example usage for org.apache.commons.lang BooleanUtils isTrue

List of usage examples for org.apache.commons.lang BooleanUtils isTrue

Introduction

In this page you can find the example usage for org.apache.commons.lang BooleanUtils isTrue.

Prototype

public static boolean isTrue(Boolean bool) 

Source Link

Document

Checks if a Boolean value is true, handling null by returning false.

 BooleanUtils.isTrue(Boolean.TRUE)  = true BooleanUtils.isTrue(Boolean.FALSE) = false BooleanUtils.isTrue(null)          = false 

Usage

From source file:org.betaconceptframework.astroboa.resourceapi.utility.XmlSchemaGenerator.java

private void addLongProperty(Map<String, Object> property) {

    String name = (String) property.get("name");
    String minOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("mandatory"))) ? "1" : "0";
    String maxOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("multiple"))) ? "unbounded"
            : "1";

    addLine("<xs:element name=\"" + name + "\" type=\"xs:long\" minOccurs=\"" + minOccurs + "\" maxOccurs=\""
            + maxOccurs + "\">");
    addLabel((Map<String, Object>) property.get("label"));
    addLine("</xs:element>");

}

From source file:org.betaconceptframework.astroboa.resourceapi.utility.XmlSchemaGenerator.java

private void addDoubleProperty(Map<String, Object> property) {

    String name = (String) property.get("name");
    String minOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("mandatory"))) ? "1" : "0";
    String maxOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("multiple"))) ? "unbounded"
            : "1";

    addLine("<xs:element name=\"" + name + "\" type=\"xs:double\" minOccurs=\"" + minOccurs + "\" maxOccurs=\""
            + maxOccurs + "\">");
    addLabel((Map<String, Object>) property.get("label"));
    addLine("</xs:element>");

}

From source file:org.betaconceptframework.astroboa.resourceapi.utility.XmlSchemaGenerator.java

private void addDateProperty(Map<String, Object> property) {

    String name = (String) property.get("name");
    String minOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("mandatory"))) ? "1" : "0";
    String maxOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("multiple"))) ? "unbounded"
            : "1";

    addLine("<xs:element name=\"" + name + "\" type=\"xs:datetime\" minOccurs=\"" + minOccurs
            + "\" maxOccurs=\"" + maxOccurs + "\">");
    addLabel((Map<String, Object>) property.get("label"));
    addLine("</xs:element>");

}

From source file:org.betaconceptframework.astroboa.resourceapi.utility.XmlSchemaGenerator.java

private void addBooleanProperty(Map<String, Object> property) {

    String name = (String) property.get("name");
    String minOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("mandatory"))) ? "1" : "0";
    String maxOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("multiple"))) ? "unbounded"
            : "1";

    addLine("<xs:element name=\"" + name + "\" type=\"xs:boolean\" minOccurs=\"" + minOccurs + "\" maxOccurs=\""
            + maxOccurs + "\">");
    addLabel((Map<String, Object>) property.get("label"));
    addLine("</xs:element>");

}

From source file:org.betaconceptframework.astroboa.resourceapi.utility.XmlSchemaGenerator.java

private void addBinaryProperty(Map<String, Object> property) {

    String name = (String) property.get("name");
    String minOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("mandatory"))) ? "1" : "0";
    String maxOccurs = BooleanUtils.isTrue(Boolean.valueOf((String) property.get("multiple"))) ? "unbounded"
            : "1";

    addLine("<xs:element name=\"" + name + "\" type=\"bccmsmodel:binaryChannelType\" minOccurs=\"" + minOccurs
            + "\" maxOccurs=\"" + maxOccurs + "\">");
    addLabel((Map<String, Object>) property.get("label"));
    addLine("</xs:element>");

}

From source file:org.broadleafcommerce.openadmin.security.BroadleafAdminAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    String failureUrlParam = StringUtil.cleanseUrlString(request.getParameter("failureUrl"));
    String successUrlParam = StringUtil.cleanseUrlString(request.getParameter("successUrl"));
    String failureUrl = failureUrlParam == null ? null : failureUrlParam.trim();
    Boolean sessionTimeout = (Boolean) request.getAttribute("sessionTimeout");

    if (StringUtils.isEmpty(failureUrl) && BooleanUtils.isNotTrue(sessionTimeout)) {
        failureUrl = defaultFailureUrl;/*from  w w  w.  j  ava  2s . c o m*/
    }

    if (BooleanUtils.isTrue(sessionTimeout)) {
        failureUrl = "?sessionTimeout=true";
    }
    //Grab url the user, was redirected from
    successUrlParam = request.getHeader("referer");
    if (failureUrl != null) {
        if (!StringUtils.isEmpty(successUrlParam)) {
            if (!failureUrl.contains("?")) {
                failureUrl += "?successUrl=" + successUrlParam;
            } else {
                failureUrl += "&successUrl=" + successUrlParam;
            }
        }

        saveException(request, exception);
        getRedirectStrategy().sendRedirect(request, response, failureUrl);
    } else {
        super.onAuthenticationFailure(request, response, exception);
    }
}

From source file:org.broadleafcommerce.openadmin.server.service.persistence.validation.RequiredPropertyValidator.java

@Override
public PropertyValidationResult validate(Entity entity, Serializable instance,
        Map<String, FieldMetadata> entityFieldMetadata, BasicFieldMetadata propertyMetadata,
        String propertyName, String value) {
    boolean required = BooleanUtils.isTrue(propertyMetadata.getRequired());
    if (propertyMetadata.getRequiredOverride() != null) {
        required = propertyMetadata.getRequiredOverride();
    }//from  w  ww . j a  v a2  s.  c  o  m
    boolean valid = !(required && StringUtils.isEmpty(value));
    return new PropertyValidationResult(valid, ERROR_MESSAGE);
}

From source file:org.broadleafcommerce.openadmin.web.service.FormBuilderServiceImpl.java

/**
 * Determines whether or not a particular field in a record is derived. By default this checks the {@link BasicFieldMetadata}
 * for the given Property to see if something on the backend has marked it as derived
 * /*  ww w. ja v  a2  s . c o  m*/
 * @param headerField the header for this recordField
 * @param recordField the recordField being populated
 * @param p the property that relates to this recordField
 * @return whether or not this field is derived
 * @see {@link #createListGrid(String, List, org.broadleafcommerce.openadmin.web.form.component.ListGrid.Type, DynamicResultSet, String, int, String)}
 */
protected Boolean isDerivedField(Field headerField, Field recordField, Property p) {
    return BooleanUtils.isTrue(((BasicFieldMetadata) p.getMetadata()).getIsDerived());
}

From source file:org.cleverbus.api.route.AbstractBasicRoute.java

@Handler
public boolean isAsynch(@Header(AsynchConstants.ASYNCH_MSG_HEADER) Boolean asynch) {
    return BooleanUtils.isTrue(asynch);
}

From source file:org.cleverbus.api.route.AbstractBasicRoute.java

/**
 * Handles specified exception./*from   w w w.j  a v  a 2  s  . com*/
 *
 * @param ex the thrown exception
 * @param asynch {@code true} if it's asynchronous message processing otherwise synchronous processing
 * @return next route URI
 */
@Handler
public String exceptionHandling(Exception ex, @Header(AsynchConstants.ASYNCH_MSG_HEADER) Boolean asynch) {
    Assert.notNull(ex, "the ex must not be null");
    Assert.isTrue(BooleanUtils.isTrue(asynch), "it must be asynchronous message");

    String nextUri;

    if (ExceptionUtils.indexOfThrowable(ex, ValidationException.class) >= 0
            || ExceptionUtils.indexOfThrowable(ex, ValidationIntegrationException.class) >= 0) {
        Log.warn("Validation error, no further processing - " + ex.getMessage());
        nextUri = AsynchConstants.URI_ERROR_FATAL;

    } else if (ExceptionUtils.indexOfThrowable(ex, BusinessException.class) >= 0) {
        Log.warn("Business exception, no further processing.");
        nextUri = AsynchConstants.URI_ERROR_FATAL;

    } else if (ExceptionUtils.indexOfThrowable(ex, NoDataFoundException.class) >= 0) {
        Log.warn("No data found, no further processing.");
        nextUri = AsynchConstants.URI_ERROR_FATAL;

    } else if (ExceptionUtils.indexOfThrowable(ex, MultipleDataFoundException.class) >= 0) {
        Log.warn("Multiple data found, no further processing.");
        nextUri = AsynchConstants.URI_ERROR_FATAL;

    } else if (ExceptionUtils.indexOfThrowable(ex, LockFailureException.class) >= 0) {
        Log.warn("Locking exception.");
        nextUri = AsynchConstants.URI_ERROR_HANDLING;

    } else {
        Log.error("Unspecified exception - " + ex.getClass().getSimpleName() + " (" + ex.getMessage() + ")");
        nextUri = AsynchConstants.URI_ERROR_HANDLING;
    }

    return nextUri;
}