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.engine.definition.visitor.CmsPropertyVisitor.java

private boolean elementExtendsComplexCmsPropertyType(XSComplexType complexType) {

    Boolean elementExtendsComplexCmsPropertyType = null;

    //According to XSOM API method getBaseType always returns not null
    XSType currentElementType = complexType.getBaseType();
    do {//from w w w.j  a v a2  s  . c  om
        String typeName = currentElementType.getName();
        String typeNamespace = currentElementType.getTargetNamespace();

        logger.debug("Checking base type {}{}", new Object[] { "{" + typeNamespace + "}", typeName });

        ItemQName complexTypeAsItemQName = ItemUtils.createNewItem("", typeNamespace, typeName);

        //ComplexType extends complex type ComplexCmsPropertyType
        if (complexTypeAsItemQName.equals(CmsDefinitionItem.complexCmsPropertyType)) {
            elementExtendsComplexCmsPropertyType = true;
        } else {
            //ComplexType may be extending a complex type which represents a complexCmsPropertyType
            //either this super type or one of its parent extend complexCmsPropertyType
            ItemQName parentTypeAsItemQName = ItemUtils.createNewItem("",
                    currentElementType.getBaseType().getTargetNamespace(),
                    currentElementType.getBaseType().getName());

            if (!complexTypeAsItemQName.equals(parentTypeAsItemQName)) {
                currentElementType = currentElementType.getBaseType();
            } else {
                break;
            }

        }
    } while (elementExtendsComplexCmsPropertyType == null);

    return BooleanUtils.isTrue(elementExtendsComplexCmsPropertyType);
}

From source file:org.betaconceptframework.astroboa.engine.jcr.io.ImportedEntity.java

public boolean addAttribute(String attributeName, String attributeValue) {

    if (entity == null) {
        logger.warn("Attribute {} and its value {} are not imported because no entity exists", name,
                attributeValue);//ww w  .j av a2s .c  om
    }

    if (StringUtils.isEmpty(attributeName)) {
        logger.warn("Attribute value {} provided with no attribute name for element {}", attributeValue, name);
        return false;
    }

    //We could use reflection
    if (StringUtils.equals(attributeName, CmsBuiltInItem.CmsIdentifier.getLocalPart())) {
        if (entity instanceof CmsRepositoryEntity) {
            ((CmsRepositoryEntity) entity).setId(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsConstants.URL_ATTRIBUTE_NAME)) {
        if (entity instanceof BinaryChannel) {
            ((BinaryChannelImpl) entity).setExternalLocationOfTheContent(attributeValue);
        }
        //Attribute URL is ignored
        return true;
    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.Name.getLocalPart())) {

        if (entity instanceof Taxonomy) {
            ((Taxonomy) entity).setName(attributeValue);
            return true;
        } else if (entity instanceof Topic) {
            ((Topic) entity).setName(attributeValue);
            return true;
        } else if (entity instanceof Space) {
            ((Space) entity).setName(attributeValue);
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsConstants.LANG_ATTRIBUTE_NAME)
            || StringUtils.equals(attributeName, CmsConstants.LANG_ATTRIBUTE_NAME_WITH_PREFIX)) {

        locale = attributeValue;

        return true;

    } else if (CmsConstants.NUMBER_OF_CHILDREN_ATTRIBUTE_NAME.equals(attributeName)) {

        try {
            if (entity instanceof Taxonomy) {
                ((Taxonomy) entity).setNumberOfRootTopics(Integer.valueOf(attributeValue));
                return true;
            } else if (entity instanceof Topic) {
                ((Topic) entity).setNumberOfChildren(Integer.valueOf(attributeValue));
                return true;
            } else if (entity instanceof Space) {
                ((Space) entity).setNumberOfChildren(Integer.valueOf(attributeValue));
                return true;
            }
        } catch (Exception e) {
            logger.error("", e);
            return false;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.MimeType.getLocalPart())) {
        if (entity instanceof BinaryChannel) {
            ((BinaryChannel) entity).setMimeType(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.Encoding.getLocalPart())) {
        if (entity instanceof BinaryChannel) {
            ((BinaryChannel) entity).setEncoding(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.SourceFileName.getLocalPart())) {
        if (entity instanceof BinaryChannel) {
            ((BinaryChannel) entity).setSourceFilename(attributeValue);
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsConstants.LAST_MODIFICATION_DATE_ATTRIBUTE_NAME)) {
        if (entity instanceof BinaryChannel) {
            ((BinaryChannel) entity)
                    .setModified(df.newXMLGregorianCalendar(attributeValue).toGregorianCalendar());
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.AllowsReferrerContentObjects.getLocalPart())) {

        if (entity instanceof Topic) {
            ((Topic) entity)
                    .setAllowsReferrerContentObjects(BooleanUtils.isTrue(Boolean.valueOf(attributeValue)));
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.Order.getLocalPart())) {
        if (entity instanceof Topic) {
            ((Topic) entity).setOrder(Long.valueOf(attributeValue));
            return true;
        } else if (entity instanceof Space) {
            ((Space) entity).setOrder(Long.valueOf(attributeValue));
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.ExternalId.getLocalPart())) {

        if (entity instanceof RepositoryUser) {
            ((RepositoryUser) entity).setExternalId(attributeValue);
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.Label.getLocalPart())) {
        if (entity instanceof RepositoryUser) {
            ((RepositoryUser) entity).setLabel(attributeValue);
            return true;
        }

    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.SystemName.getLocalPart())) {
        if (entity instanceof ContentObject) {
            ((ContentObject) entity).setSystemName(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsBuiltInItem.ContentObjectTypeName.getLocalPart())) {
        if (entity instanceof ContentObject) {
            ((ContentObject) entity).setContentObjectType(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsConstants.REPOSITORY_ID_ATTRIBUTE_NAME)) {
        if (entity instanceof Repository) {
            ((Repository) entity).setId(attributeValue);
            return true;
        }
    } else if (StringUtils.equals(attributeName,
            CmsConstants.REPOSITORY_SERIALIZATION_CREATION_DATE_ATTRIBUTE_NAME)) {
        if (entity instanceof Repository) {
            ((Repository) entity).setCreated(df.newXMLGregorianCalendar(attributeValue).toGregorianCalendar());
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsConstants.OFFSET)) {
        if (entity instanceof List) {
            //Ignore this attribute. Its about resource collection
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsConstants.LIMIT)) {
        if (entity instanceof List) {
            //Ignore this attribute. Its about resource collection
            return true;
        }
    } else if (StringUtils.equals(attributeName, CmsConstants.TOTAL_RESOURCE_COUNT)) {
        if (entity instanceof List) {
            //Ignore this attribute. Its about resource collection
            return true;
        }
    }

    return false;

}

From source file:org.betaconceptframework.astroboa.engine.service.security.management.IdentityStoreImpl.java

private CmsPerson createPersonFromContentObject(ContentObject personObject) {
    CmsPerson person = new CmsPerson();

    BooleanProperty enabledProperty = (BooleanProperty) personObject
            .getCmsProperty("personAuthentication.authenticationDataEnabled");
    person.setEnabled(enabledProperty != null && enabledProperty.hasValues()
            && BooleanUtils.isTrue(enabledProperty.getSimpleTypeValue()));

    StringProperty userNameProperty = (StringProperty) personObject
            .getCmsProperty("personAuthentication.username");
    if (userNameProperty != null && userNameProperty.hasValues()) {
        person.setUsername(userNameProperty.getSimpleTypeValue());
    }/*w  w w  .  ja va  2 s  .c  o m*/

    StringProperty familyNameProperty = (StringProperty) personObject.getCmsProperty("name.familyName");
    if (familyNameProperty != null && familyNameProperty.hasValues()) {
        person.setFamilyName(familyNameProperty.getSimpleTypeValue());
    }

    StringProperty fatherNameProperty = (StringProperty) personObject.getCmsProperty("name.fatherName");
    if (fatherNameProperty != null && fatherNameProperty.hasValues()) {
        person.setFatherName(fatherNameProperty.getSimpleTypeValue());
    }

    StringProperty givenNameProperty = (StringProperty) personObject.getCmsProperty("name.givenName");
    if (givenNameProperty != null && givenNameProperty.hasValues()) {
        person.setFirstName(givenNameProperty.getSimpleTypeValue());
    }

    StringProperty displayNameProperty = (StringProperty) personObject.getCmsProperty("displayName");
    if (displayNameProperty != null && displayNameProperty.hasValues()) {
        person.setDisplayName(displayNameProperty.getSimpleTypeValue());
    }

    person.setUserid(personObject.getId());

    return person;
}

From source file:org.betaconceptframework.astroboa.model.impl.query.render.RenderPropertiesImpl.java

@Override
public boolean allContentObjectPropertiesAreRendered() {
    return BooleanUtils.isTrue((Boolean) renderInstructions
            .get(RenderInstruction.DISABLE_LAZY_LOADING_OF_CONTENT_OBJECT_PROPERTIES));
}

From source file:org.betaconceptframework.astroboa.model.impl.query.render.RenderPropertiesImpl.java

@Override
public boolean isParentEntityRendered() {
    return BooleanUtils.isTrue((Boolean) renderInstructions.get(RenderInstruction.RENDER_PARENT));
}

From source file:org.betaconceptframework.astroboa.model.impl.query.render.RenderPropertiesImpl.java

@Override
public boolean areSerializeContentObjectsUsingTheSameNameAsCollectionItemName() {
    return BooleanUtils.isTrue((Boolean) renderInstructions
            .get(RenderInstruction.SERIALIZE_OBJECTS_USING_THE_SAME_NAME_FOR_EACH_COLLECTION_ITEM));
}

From source file:org.betaconceptframework.astroboa.model.impl.query.render.RenderPropertiesImpl.java

@Override
public boolean isPrettyPrintEnabled() {
    return BooleanUtils.isTrue((Boolean) renderInstructions.get(RenderInstruction.PRETTY_PRINT));
}

From source file:org.betaconceptframework.astroboa.model.jaxb.adapter.BooleanAdapter.java

@Override
public Boolean marshal(Boolean v) throws Exception {
    if (BooleanUtils.isTrue(v)) {
        return v;
    }//from w w  w. ja  va2s.  com

    /*
     * FindBugs (v 2.3.1) reports the following for the fact that we explicitly return null
     * 
     * NP: Method with Boolean return type returns explicit null (NP_BOOLEAN_RETURN_NULL)
     * A method that returns either Boolean.TRUE, Boolean.FALSE or null is an accident waiting to happen. 
     * This method can be invoked as though it returned a value of type boolean, and the compiler will insert 
     * automatic unboxing of the Boolean value. If a null value is returned, this will result in a NullPointerException.
     * 
     * However, since this  is used only by JAXB, JAXB handles the null value without any NPE. That means that
     * it process the Boolean result as Boolean and not as boolean.
     */
    return null;
}

From source file:org.betaconceptframework.astroboa.model.jaxb.adapter.BooleanAdapter.java

@Override
public Boolean unmarshal(Boolean v) throws Exception {
    return BooleanUtils.isTrue(v);
}

From source file:org.betaconceptframework.astroboa.model.jaxb.AstroboaMarshaller.java

@Override
public void marshal(Object arg0, Writer arg1) throws JAXBException {
    if (outputTypeIsJSON()) {

        XMLStreamWriter jsonXmlStreamWriter = null;
        try {/* www. j av  a2s.  c o m*/

            jsonXmlStreamWriter = CmsEntitySerialization.Context.createJsonXmlStreamWriter(arg1, true,
                    BooleanUtils.isTrue((Boolean) marshaller.getProperty(Marshaller.JAXB_FORMATTED_OUTPUT)));

            marshal(arg0, jsonXmlStreamWriter);
        } catch (Exception e) {
            try {
                if (jsonXmlStreamWriter != null) {
                    jsonXmlStreamWriter.flush();
                    logger.error("JSON Export so far {}", arg1);
                }
            } catch (Exception e1) {
                //Ignore it
            }
            throw new JAXBException(e);
        }
    } else {
        marshaller.marshal(arg0, arg1);
    }

}