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

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

Introduction

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

Prototype

public static boolean isNotFalse(Boolean bool) 

Source Link

Document

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

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

Usage

From source file:com.haulmont.cuba.gui.xml.layout.loaders.FieldGroupLoader.java

protected void loadVisible(FieldGroup resultComponent, FieldGroup.FieldConfig field) {
    Element element = field.getXmlDescriptor();
    if (element != null) {
        String visible = element.attributeValue("visible");
        if (StringUtils.isNotEmpty(visible)) {
            field.setVisible(Boolean.parseBoolean(visible));
        }//w w w  .  ja va  2  s  .c om
    }

    if (!field.isCustom() && BooleanUtils.isNotFalse(field.isVisible())) {
        MetaClass metaClass = getMetaClass(resultComponent, field);
        MetaPropertyPath propertyPath = metadataTools.resolveMetaPropertyPath(metaClass, field.getProperty());

        checkNotNullArgument(propertyPath, "Could not resolve property path '%s' in '%s'", field.getId(),
                metaClass);

        if (!security.isEntityAttrReadPermitted(metaClass, propertyPath.toString())) {
            field.setVisible(false);
        }
    }
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

protected Component showWindowDialog(Window window, OpenType openType, boolean forciblyDialog) {
    final CubaWindow vWindow = createDialogWindow(window);
    vWindow.setStyleName("c-app-dialog-window");
    if (ui.isTestMode()) {
        vWindow.setCubaId("dialog_" + window.getId());
        vWindow.setId(ui.getTestIdManager().getTestId("dialog_" + window.getId()));
    }/* w  w w.j  a  va2 s.  c  o m*/

    Layout layout = (Layout) WebComponentsHelper.getComposition(window);
    vWindow.setContent(layout);

    vWindow.addPreCloseListener(event -> {
        event.setPreventClose(true);
        if (!isCloseWithCloseButtonPrevented(window)) {
            // user has clicked on X
            window.close(Window.CLOSE_ACTION_ID);
        }
    });

    String closeShortcut = clientConfig.getCloseShortcut();
    KeyCombination closeCombination = KeyCombination.create(closeShortcut);

    ShortcutAction exitAction = new ShortcutAction("closeShortcutAction", closeCombination.getKey().getCode(),
            KeyCombination.Modifier.codes(closeCombination.getModifiers()));

    Map<com.vaadin.event.Action, Runnable> actions = singletonMap(exitAction, () -> {
        if (openType.getOpenMode() != OpenMode.DIALOG
                || BooleanUtils.isNotFalse(window.getDialogOptions().getCloseable())) {
            if (isCloseWithShortcutPrevented(window)) {
                return;
            }
            window.close(Window.CLOSE_ACTION_ID);
        }
    });

    WebComponentsHelper.setActions(vWindow, actions);

    boolean dialogParamsSizeUndefined = openType.getHeight() == null && openType.getWidth() == null;

    ThemeConstants theme = app.getThemeConstants();

    if (forciblyDialog && dialogParamsSizeUndefined) {
        layout.setHeight(100, Unit.PERCENTAGE);

        vWindow.setWidth(theme.getInt("cuba.web.WebWindowManager.forciblyDialog.width"), Unit.PIXELS);
        vWindow.setHeight(theme.getInt("cuba.web.WebWindowManager.forciblyDialog.height"), Unit.PIXELS);

        // resizable by default, but may be overridden in dialog params
        vWindow.setResizable(BooleanUtils.isNotFalse(openType.getResizable()));

        window.setHeightFull();
    } else {
        if (openType.getWidth() == null) {
            vWindow.setWidth(theme.getInt("cuba.web.WebWindowManager.dialog.width"), Unit.PIXELS);
        } else if (openType.getWidth() == AUTO_SIZE_PX) {
            vWindow.setWidthUndefined();
            layout.setWidthUndefined();
            window.setWidthAuto();
        } else {
            vWindow.setWidth(openType.getWidth(),
                    openType.getWidthUnit() != null ? WebWrapperUtils.toVaadinUnit(openType.getWidthUnit())
                            : Unit.PIXELS);
        }

        if (openType.getHeight() != null && openType.getHeight() != AUTO_SIZE_PX) {
            vWindow.setHeight(openType.getHeight(),
                    openType.getHeightUnit() != null ? WebWrapperUtils.toVaadinUnit(openType.getHeightUnit())
                            : Unit.PIXELS);
            layout.setHeight("100%");
            window.setHeightFull();
        } else {
            window.setHeightAuto();
        }

        // non resizable by default
        vWindow.setResizable(BooleanUtils.isTrue(openType.getResizable()));
    }

    if (openType.getCloseable() != null) {
        vWindow.setClosable(openType.getCloseable());
    }

    boolean modal = true;
    if (!hasModalWindow() && openType.getModal() != null) {
        modal = openType.getModal();
    }
    vWindow.setModal(modal);

    if (vWindow.isModal()) {
        boolean informationDialog = false;
        if (openType.getCloseOnClickOutside() != null) {
            informationDialog = openType.getCloseOnClickOutside();
        }
        vWindow.setCloseOnClickOutside(informationDialog);
    }

    if (openType.getMaximized() != null) {
        if (openType.getMaximized()) {
            vWindow.setWindowMode(WindowMode.MAXIMIZED);
        } else {
            vWindow.setWindowMode(WindowMode.NORMAL);
        }
    }

    if (openType.getPositionX() == null && openType.getPositionY() == null) {
        vWindow.center();
    } else {
        if (openType.getPositionX() != null) {
            vWindow.setPositionX(openType.getPositionX());
        }
        if (openType.getPositionY() != null) {
            vWindow.setPositionY(openType.getPositionY());
        }
    }

    getDialogParams().reset();

    ui.addWindow(vWindow);

    return vWindow;
}

From source file:com.evolveum.midpoint.provisioning.ucf.impl.connid.ConnectorInstanceConnIdImpl.java

@Override
public AsynchronousOperationReturnValue<Collection<ResourceAttribute<?>>> addObject(
        PrismObject<? extends ShadowType> shadow, Collection<Operation> additionalOperations,
        StateReporter reporter, OperationResult parentResult) throws CommunicationException,
        GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException {
    validateShadow(shadow, "add", false);
    ShadowType shadowType = shadow.asObjectable();

    ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow);
    OperationResult result = parentResult.createSubresult(ConnectorInstance.class.getName() + ".addObject");
    result.addParam("resourceObject", shadow);
    result.addParam("additionalOperations", DebugUtil.debugDump(additionalOperations)); // because of serialization issues

    ObjectClassComplexTypeDefinition ocDef;
    ResourceAttributeContainerDefinition attrContDef = attributesContainer.getDefinition();
    if (attrContDef != null) {
        ocDef = attrContDef.getComplexTypeDefinition();
    } else {//from   www  . j a va2s  . c  o  m
        ocDef = resourceSchema.findObjectClassDefinition(shadow.asObjectable().getObjectClass());
        if (ocDef == null) {
            throw new SchemaException("Unknown object class " + shadow.asObjectable().getObjectClass());
        }
    }

    // getting icf object class from resource object class
    ObjectClass icfObjectClass = connIdNameMapper.objectClassToIcf(shadow, getSchemaNamespace(), connectorType,
            BooleanUtils.isNotFalse(legacySchema));

    if (icfObjectClass == null) {
        result.recordFatalError("Couldn't get icf object class from " + shadow);
        throw new IllegalArgumentException("Couldn't get icf object class from " + shadow);
    }

    // setting ifc attributes from resource object attributes
    Set<Attribute> attributes = null;
    try {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("midPoint object before conversion:\n{}", attributesContainer.debugDump());
        }
        attributes = connIdConvertor.convertFromResourceObject(attributesContainer, ocDef);

        if (shadowType.getCredentials() != null && shadowType.getCredentials().getPassword() != null) {
            PasswordType password = shadowType.getCredentials().getPassword();
            ProtectedStringType protectedString = password.getValue();
            GuardedString guardedPassword = ConnIdUtil.toGuardedString(protectedString, "new password",
                    protector);
            if (guardedPassword != null) {
                attributes.add(AttributeBuilder.build(OperationalAttributes.PASSWORD_NAME, guardedPassword));
            }
        }

        if (ActivationUtil.hasAdministrativeActivation(shadowType)) {
            attributes.add(AttributeBuilder.build(OperationalAttributes.ENABLE_NAME,
                    ActivationUtil.isAdministrativeEnabled(shadowType)));
        }

        if (ActivationUtil.hasValidFrom(shadowType)) {
            attributes.add(AttributeBuilder.build(OperationalAttributes.ENABLE_DATE_NAME,
                    XmlTypeConverter.toMillis(shadowType.getActivation().getValidFrom())));
        }

        if (ActivationUtil.hasValidTo(shadowType)) {
            attributes.add(AttributeBuilder.build(OperationalAttributes.DISABLE_DATE_NAME,
                    XmlTypeConverter.toMillis(shadowType.getActivation().getValidTo())));
        }

        if (ActivationUtil.hasLockoutStatus(shadowType)) {
            attributes.add(AttributeBuilder.build(OperationalAttributes.LOCK_OUT_NAME,
                    ActivationUtil.isLockedOut(shadowType)));
        }

        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("ConnId attributes after conversion:\n{}", ConnIdUtil.dump(attributes));
        }
    } catch (SchemaException | RuntimeException ex) {
        result.recordFatalError("Error while converting resource object attributes. Reason: " + ex.getMessage(),
                ex);
        throw new SchemaException(
                "Error while converting resource object attributes. Reason: " + ex.getMessage(), ex);
    }

    if (attributes == null) {
        result.recordFatalError("Couldn't set attributes for icf.");
        throw new IllegalStateException("Couldn't set attributes for icf.");
    }

    List<String> icfAuxiliaryObjectClasses = new ArrayList<>();
    for (QName auxiliaryObjectClass : shadowType.getAuxiliaryObjectClass()) {
        icfAuxiliaryObjectClasses.add(connIdNameMapper
                .objectClassToIcf(auxiliaryObjectClass, resourceSchemaNamespace, connectorType, false)
                .getObjectClassValue());
    }
    if (!icfAuxiliaryObjectClasses.isEmpty()) {
        AttributeBuilder ab = new AttributeBuilder();
        ab.setName(PredefinedAttributes.AUXILIARY_OBJECT_CLASS_NAME);
        ab.addValue(icfAuxiliaryObjectClasses);
        attributes.add(ab.build());
    }

    OperationOptionsBuilder operationOptionsBuilder = new OperationOptionsBuilder();
    OperationOptions options = operationOptionsBuilder.build();

    checkAndExecuteAdditionalOperations(reporter, additionalOperations, BeforeAfterType.BEFORE, result);

    OperationResult connIdResult = result.createSubresult(ConnectorFacade.class.getName() + ".create");
    connIdResult.addArbitraryObjectAsParam("objectClass", icfObjectClass);
    connIdResult.addArbitraryObjectCollectionAsParam("auxiliaryObjectClasses", icfAuxiliaryObjectClasses);
    connIdResult.addArbitraryObjectCollectionAsParam("attributes", attributes);
    connIdResult.addArbitraryObjectAsParam("options", options);
    connIdResult.addContext("connector", connIdConnectorFacade.getClass());

    Uid uid = null;
    try {

        // CALL THE ConnId FRAMEWORK
        InternalMonitor.recordConnectorOperation("create");
        InternalMonitor.recordConnectorModification("create");
        recordIcfOperationStart(reporter, ProvisioningOperation.ICF_CREATE, ocDef, null); // TODO provide object name
        uid = connIdConnectorFacade.create(icfObjectClass, attributes, options);
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_CREATE, ocDef, uid);

    } catch (Throwable ex) {
        recordIcfOperationEnd(reporter, ProvisioningOperation.ICF_CREATE, ocDef, ex, null); // TODO name
        Throwable midpointEx = processConnIdException(ex, this, connIdResult);
        result.computeStatus("Add object failed");

        // Do some kind of acrobatics to do proper throwing of checked
        // exception
        if (midpointEx instanceof ObjectAlreadyExistsException) {
            throw (ObjectAlreadyExistsException) midpointEx;
        } else if (midpointEx instanceof CommunicationException) {
            //            icfResult.muteError();
            //            result.muteError();
            throw (CommunicationException) midpointEx;
        } else if (midpointEx instanceof GenericFrameworkException) {
            throw (GenericFrameworkException) midpointEx;
        } else if (midpointEx instanceof SchemaException) {
            throw (SchemaException) midpointEx;
        } else if (midpointEx instanceof ConfigurationException) {
            throw (ConfigurationException) midpointEx;
        } else if (midpointEx instanceof RuntimeException) {
            throw (RuntimeException) midpointEx;
        } else if (midpointEx instanceof Error) {
            throw (Error) midpointEx;
        } else {
            throw new SystemException(
                    "Got unexpected exception: " + ex.getClass().getName() + ": " + ex.getMessage(), ex);
        }
    }

    if (uid == null || uid.getUidValue() == null || uid.getUidValue().isEmpty()) {
        connIdResult.recordFatalError("ConnId did not returned UID after create");
        result.computeStatus("Add object failed");
        throw new GenericFrameworkException("ConnId did not returned UID after create");
    }

    Collection<ResourceAttribute<?>> identifiers = ConnIdUtil.convertToIdentifiers(uid,
            attributesContainer.getDefinition().getComplexTypeDefinition(), resourceSchema);
    for (ResourceAttribute<?> identifier : identifiers) {
        attributesContainer.getValue().addReplaceExisting(identifier);
    }
    connIdResult.recordSuccess();

    checkAndExecuteAdditionalOperations(reporter, additionalOperations, BeforeAfterType.AFTER, result);

    result.computeStatus();
    return AsynchronousOperationReturnValue.wrap(attributesContainer.getAttributes(), result);
}

From source file:org.apache.maven.shared.release.DefaultReleaseManager.java

private void prepare(ReleasePrepareRequest prepareRequest, ReleaseResult result)
        throws ReleaseExecutionException, ReleaseFailureException {
    updateListener(prepareRequest.getReleaseManagerListener(), "prepare", GOAL_START);

    ReleaseDescriptor config;//ww w.  j  ava2  s  .  c  om
    if (BooleanUtils.isNotFalse(prepareRequest.getResume())) {
        config = loadReleaseDescriptor(prepareRequest.getReleaseDescriptor(),
                prepareRequest.getReleaseManagerListener());
    } else {
        config = prepareRequest.getReleaseDescriptor();
    }

    // Later, it would be a good idea to introduce a proper workflow tool so that the release can be made up of a
    // more flexible set of steps.

    String completedPhase = config.getCompletedPhase();
    int index = preparePhases.indexOf(completedPhase);

    for (int idx = 0; idx <= index; idx++) {
        updateListener(prepareRequest.getReleaseManagerListener(), preparePhases.get(idx), PHASE_SKIP);
    }

    if (index == preparePhases.size() - 1) {
        logInfo(result, "Release preparation already completed. You can now continue with release:perform, "
                + "or start again using the -Dresume=false flag");
    } else if (index >= 0) {
        logInfo(result, "Resuming release from phase '" + preparePhases.get(index + 1) + "'");
    }

    // start from next phase
    for (int i = index + 1; i < preparePhases.size(); i++) {
        String name = preparePhases.get(i);

        ReleasePhase phase = releasePhases.get(name);

        if (phase == null) {
            throw new ReleaseExecutionException("Unable to find phase '" + name + "' to execute");
        }

        updateListener(prepareRequest.getReleaseManagerListener(), name, PHASE_START);

        ReleaseResult phaseResult = null;
        try {
            if (BooleanUtils.isTrue(prepareRequest.getDryRun())) {
                phaseResult = phase.simulate(config, prepareRequest.getReleaseEnvironment(),
                        prepareRequest.getReactorProjects());
            } else {
                phaseResult = phase.execute(config, prepareRequest.getReleaseEnvironment(),
                        prepareRequest.getReactorProjects());
            }
        } finally {
            if (result != null && phaseResult != null) {
                result.appendOutput(phaseResult.getOutput());
            }
        }

        config.setCompletedPhase(name);
        try {
            configStore.write(config);
        } catch (ReleaseDescriptorStoreException e) {
            // TODO: rollback?
            throw new ReleaseExecutionException("Error writing release properties after completing phase", e);
        }

        updateListener(prepareRequest.getReleaseManagerListener(), name, PHASE_END);
    }

    updateListener(prepareRequest.getReleaseManagerListener(), "prepare", GOAL_END);
}

From source file:org.apache.maven.shared.release.DefaultReleaseManager.java

private void perform(ReleasePerformRequest performRequest, ReleaseResult result)
        throws ReleaseExecutionException, ReleaseFailureException {
    updateListener(performRequest.getReleaseManagerListener(), "perform", GOAL_START);

    ReleaseDescriptor releaseDescriptor = loadReleaseDescriptor(performRequest.getReleaseDescriptor(),
            performRequest.getReleaseManagerListener());

    for (String name : performPhases) {
        ReleasePhase phase = releasePhases.get(name);

        if (phase == null) {
            throw new ReleaseExecutionException("Unable to find phase '" + name + "' to execute");
        }//from www.j a v a 2s .co m

        updateListener(performRequest.getReleaseManagerListener(), name, PHASE_START);

        ReleaseResult phaseResult = null;
        try {
            if (BooleanUtils.isTrue(performRequest.getDryRun())) {
                phaseResult = phase.simulate(releaseDescriptor, performRequest.getReleaseEnvironment(),
                        performRequest.getReactorProjects());
            } else {
                phaseResult = phase.execute(releaseDescriptor, performRequest.getReleaseEnvironment(),
                        performRequest.getReactorProjects());
            }
        } finally {
            if (result != null && phaseResult != null) {
                result.appendOutput(phaseResult.getOutput());
            }
        }

        updateListener(performRequest.getReleaseManagerListener(), name, PHASE_END);
    }

    if (BooleanUtils.isNotFalse(performRequest.getClean())) {
        // call release:clean so that resume will not be possible anymore after a perform
        clean(releaseDescriptor, performRequest.getReleaseManagerListener(),
                performRequest.getReactorProjects());
    }

    updateListener(performRequest.getReleaseManagerListener(), "perform", GOAL_END);
}

From source file:org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil.java

/**
 * Returns true if the value of the "skipPasswordExpirationCheck" thread local variable is true, else false
 * //w  w w . ja v  a 2s .  com
 * @return true/false
 */
public static Boolean skipPasswordExpirationCheck() {
    return BooleanUtils.isNotFalse(skipPasswordExpirationCheck.get());
}

From source file:org.sonar.plugins.gosu.jacoco.JaCoCoReportMerger.java

private static boolean loadSourceFiles(ISessionInfoVisitor infoStore, IExecutionDataVisitor dataStore,
        File... reports) {//from   w ww.  j  a  va  2  s  .  c o  m
    Boolean isCurrentVersionFormat = null;
    for (File report : reports) {
        if (report.isFile()) {
            JaCoCoReportReader jacocoReportReader = new JaCoCoReportReader(report).readJacocoReport(dataStore,
                    infoStore);
            boolean reportFormatIsCurrent = jacocoReportReader.useCurrentBinaryFormat();
            if (isCurrentVersionFormat == null) {
                isCurrentVersionFormat = reportFormatIsCurrent;
            } else if (!isCurrentVersionFormat.equals(reportFormatIsCurrent)) {
                throw new IllegalStateException(
                        "You are trying to merge two different JaCoCo binary formats. Please use only one version of JaCoCo.");
            }
        }
    }
    return BooleanUtils.isNotFalse(isCurrentVersionFormat);
}

From source file:org.sonar.plugins.jacoco.JaCoCoReportMerger.java

private static boolean loadSourceFiles(ExecutionDataVisitor executionDataVisitor, File... reports) {
    Boolean isCurrentVersionFormat = null;
    for (File report : reports) {
        if (report.isFile()) {
            JacocoReportReader jacocoReportReader = new JacocoReportReader(report)
                    .readJacocoReport(executionDataVisitor, executionDataVisitor);
            boolean reportFormatIsCurrent = jacocoReportReader.useCurrentBinaryFormat();
            if (isCurrentVersionFormat == null) {
                isCurrentVersionFormat = reportFormatIsCurrent;
            } else if (!isCurrentVersionFormat.equals(reportFormatIsCurrent)) {
                throw new IllegalStateException(
                        "You are trying to merge two different JaCoCo binary formats. Please use only one version of JaCoCo.");
            }/* w w  w .  j  a  v a 2s.  com*/
        }
    }
    return BooleanUtils.isNotFalse(isCurrentVersionFormat);
}

From source file:org.sonar.server.qualitygate.ws.AppAction.java

private void addMetrics(JsonWriter writer) {
    writer.name("metrics").beginArray();
    for (Metric metric : qualityGates.gateMetrics()) {
        writer.beginObject().prop("id", metric.getId()).prop("key", metric.getKey())
                .prop("name", metric.getName()).prop("type", metric.getType().toString())
                .prop("domain", metric.getDomain()).prop("hidden", BooleanUtils.isNotFalse(metric.isHidden()))
                .endObject();// www.  j a  v  a2 s  .  c  o  m
    }
    writer.endArray();
}