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.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

public boolean obtainEditableDocument(String documentLocation) throws Exception {
    Boolean ret = (Boolean) invokeDocumentManagementServiceMBean("obtainEditableDocument",
            new String[] { documentLocation }, new String[] { String.class.getName() });
    return BooleanUtils.isTrue(ret);
}

From source file:org.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

public boolean disposeEditableDocument(String documentLocation) throws Exception {
    Boolean ret = (Boolean) invokeDocumentManagementServiceMBean("disposeEditableDocument",
            new String[] { documentLocation }, new String[] { String.class.getName() });
    return BooleanUtils.isTrue(ret);
}

From source file:org.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

public boolean commitEditableDocument(String documentLocation) throws Exception {
    Boolean ret = (Boolean) invokeDocumentManagementServiceMBean("commitEditableDocument",
            new String[] { documentLocation }, new String[] { String.class.getName() });
    return BooleanUtils.isTrue(ret);
}

From source file:org.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

boolean depublishDocument(String documentLocation) throws Exception {
    Boolean ret = (Boolean) invokeDocumentManagementServiceMBean("depublishDocument",
            new String[] { documentLocation }, new String[] { String.class.getName() });
    return BooleanUtils.isTrue(ret);
}

From source file:org.onehippo.forge.channelmanager.pagesupport.channel.event.DocumentManagementServiceClient.java

public boolean publishDocument(String documentLocation) throws Exception {
    Boolean ret = (Boolean) invokeDocumentManagementServiceMBean("publishDocument",
            new String[] { documentLocation }, new String[] { String.class.getName() });
    return BooleanUtils.isTrue(ret);
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean obtainEditableDocument(String documentLocation) {
    log.debug("##### obtainEditableDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }//from ww  w  . j ava  2  s .com

    boolean obtained = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean obtainEditableInstance = (Boolean) documentWorkflow.hints().get("obtainEditableInstance");

        if (BooleanUtils.isTrue(obtainEditableInstance)) {
            documentWorkflow.obtainEditableInstance();
            obtained = true;
        } else {
            throw new IllegalStateException(
                    "Document at '" + documentLocation + "' is not allowed to obtain an editable instance.");
        }
    } catch (Exception e) {
        log.error("Failed to obtain editable instance on document.", e);
        throw new RuntimeException(
                "Failed to obtain editable instance on document at '" + documentLocation + "'. " + e);
    }

    return obtained;
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean disposeEditableDocument(String documentLocation) {
    log.debug("##### disposeEditableDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }// w w w. j a  va2  s. c  o m

    boolean disposed = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean disposeEditableInstance = (Boolean) documentWorkflow.hints().get("disposeEditableInstance");

        if (BooleanUtils.isTrue(disposeEditableInstance)) {
            documentWorkflow.disposeEditableInstance();
            disposed = true;
        } else {
            throw new IllegalStateException(
                    "Document at '" + documentLocation + "' is not allowed to dispose an editable instance.");
        }
    } catch (Exception e) {
        log.error("Failed to dispose editable instance on document.", e);
        throw new RuntimeException(
                "Failed to dispose editable instance on document at '" + documentLocation + "'. " + e);
    }

    return disposed;
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean commitEditableDocument(String documentLocation) {
    log.debug("##### commitEditableDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }//  w  w w  .  j  av a  2 s.c  om

    boolean committed = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean commitEditableInstance = (Boolean) documentWorkflow.hints().get("commitEditableInstance");

        if (BooleanUtils.isTrue(commitEditableInstance)) {
            documentWorkflow.commitEditableInstance();
            committed = true;
        } else {
            throw new IllegalStateException(
                    "Document at '" + documentLocation + "' is not allowed to commit an editable instance.");
        }
    } catch (Exception e) {
        log.error("Failed to commit editable instance on document.", e);
        throw new RuntimeException(
                "Failed to commit editable instance on document at '" + documentLocation + "'. " + e);
    }

    return committed;
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean depublishDocument(String documentLocation) {
    log.debug("##### depublishDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }//from   www . j a  v a2  s .  c  o  m

    boolean depublished = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean isLive = (Boolean) documentWorkflow.hints().get("isLive");

        if (BooleanUtils.isFalse(isLive)) {
            // already offline, so just return true
            depublished = true;
        } else {
            Boolean depublish = (Boolean) documentWorkflow.hints().get("depublish");

            if (!BooleanUtils.isTrue(depublish)) {
                throw new IllegalStateException(
                        "Document at '" + documentLocation + "' doesn't have depublish action.");
            }

            documentWorkflow.depublish();
            depublished = true;
        }
    } catch (RepositoryException | WorkflowException | RemoteException e) {
        log.error("Failed to depublish document at '{}'.", documentLocation, e);
        throw new RuntimeException("Failed to depublish document at '" + documentLocation + "'. " + e);
    }

    return depublished;
}

From source file:org.onehippo.forge.channelmanager.pagesupport.document.management.impl.DocumentWorkflowDocumentManagementService.java

@Override
public boolean publishDocument(String documentLocation) {
    log.debug("##### publishDocument('{}')", documentLocation);

    if (StringUtils.isBlank(documentLocation)) {
        throw new IllegalArgumentException("Invalid document location: '" + documentLocation + "'.");
    }/*  w  ww .  j ava2 s.  c o  m*/

    boolean published = false;

    try {
        if (!getSession().nodeExists(documentLocation)) {
            throw new IllegalArgumentException("Document doesn't exist at '" + documentLocation + "'.");
        }

        Node documentHandleNode = HippoWorkflowUtils
                .getHippoDocumentHandle(getSession().getNode(documentLocation));

        if (documentHandleNode == null) {
            throw new IllegalArgumentException("Document handle is not found at '" + documentLocation + "'.");
        }

        DocumentWorkflow documentWorkflow = getDocumentWorkflow(documentHandleNode);

        Boolean publish = (Boolean) documentWorkflow.hints().get("publish");

        if (!BooleanUtils.isTrue(publish)) {
            throw new IllegalStateException(
                    "Document at '" + documentLocation + "' doesn't have publish action.");
        }

        documentWorkflow.publish();
        published = true;
    } catch (RepositoryException | WorkflowException | RemoteException e) {
        log.error("Failed to publish document at '{}'.", documentLocation, e);
        throw new RuntimeException("Failed to publish document at '" + documentLocation + "'. " + e);
    }

    return published;
}