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:jp.primecloud.auto.process.vmware.VmwareNetworkProcess.java

protected List<VirtualEthernetCard> createEthernetCards(VmwareProcessClient vmwareProcessClient,
        Long instanceNo, VirtualMachine machine) {
    Instance instance = instanceDao.read(instanceNo);
    List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(instance.getFarmNo());

    // ?????/*  w w w .j a v a2s  .co m*/
    PlatformVmware platformVmware = platformVmwareDao.read(instance.getPlatformNo());
    String publicNetworkName = platformVmware.getPublicNetwork();
    String privateNetworkName = platformVmware.getPrivateNetwork();
    for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
        if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) {
            publicNetworkName = vmwareNetwork.getNetworkName();
        } else {
            privateNetworkName = vmwareNetwork.getNetworkName();
        }
    }

    // ???
    List<VirtualEthernetCard> ethernetCards = new ArrayList<VirtualEthernetCard>();
    VmwareClient vmwareClient = vmwareProcessClient.getVmwareClient();
    // rootFolder?
    ManagedEntity rootFolder = vmwareClient.getRootEntity();
    InventoryNavigator rootNavi = new InventoryNavigator(rootFolder);
    ManagedEntity[] targets;

    try {
        // ??
        targets = rootNavi.searchManagedEntities("Network");
    } catch (RemoteException e) {
        throw new RuntimeException(e);
    }

    VirtualEthernetCard pulicEthernetCard = new VirtualEthernetCard();
    VirtualEthernetCard privateEthernetCard = new VirtualEthernetCard();
    for (ManagedEntity target : targets) {
        // Public??
        if (StringUtils.equals(target.getName(), publicNetworkName)) {
            pulicEthernetCard = editEthernetCards(machine, publicNetworkName);
        }
        // Private??
        if (StringUtils.equals(target.getName(), privateNetworkName)) {
            privateEthernetCard = editEthernetCards(machine, privateNetworkName);
        }
    }
    // Public??
    ethernetCards.add(pulicEthernetCard);
    // Private??
    ethernetCards.add(privateEthernetCard);

    return ethernetCards;
}

From source file:com.haulmont.cuba.security.app.EntityLog.java

protected void loadEntities() {
    log.debug("Loading entities");
    entitiesManual = new HashMap<>();
    entitiesAuto = new HashMap<>();
    Transaction tx = persistence.createTransaction();
    try {//w  ww  .  jav a 2  s . c  o m
        EntityManager em = persistence.getEntityManager();
        TypedQuery<LoggedEntity> q = em.createQuery(
                "select e from sec$LoggedEntity e where e.auto = true or e.manual = true", LoggedEntity.class);
        //            q.setView(null);
        List<LoggedEntity> list = q.getResultList();
        for (LoggedEntity loggedEntity : list) {
            if (loggedEntity.getName() == null) {
                throw new IllegalStateException("Unable to initialize EntityLog: empty LoggedEntity.name");
            }
            Set<String> attributes = new HashSet<>();
            for (LoggedAttribute loggedAttribute : loggedEntity.getAttributes()) {
                if (loggedAttribute.getName() == null) {
                    throw new IllegalStateException(
                            "Unable to initialize EntityLog: empty LoggedAttribute.name");
                }
                attributes.add(loggedAttribute.getName());
            }
            if (BooleanUtils.isTrue(loggedEntity.getAuto()))
                entitiesAuto.put(loggedEntity.getName(), attributes);
            if (BooleanUtils.isTrue(loggedEntity.getManual()))
                entitiesManual.put(loggedEntity.getName(), attributes);
        }
        tx.commit();
    } finally {
        tx.end();
    }
    log.debug("Loaded: entitiesAuto={}, entitiesManual={}", entitiesAuto.size(), entitiesManual.size());
}

From source file:jp.primecloud.auto.process.vmware.VmwareMachineProcess.java

/**
 * TODO: //from  w  ww  .ja v  a2 s . c  o  m
 *
 * @param vmwareProcessClient
 * @param instanceNo
 */
public void getGuestInfo(VmwareProcessClient vmwareProcessClient, Long instanceNo) {
    Instance instance = instanceDao.read(instanceNo);
    VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo);
    List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(instance.getFarmNo());

    // ?????
    Platform platform = platformDao.read(instance.getPlatformNo());
    PlatformVmware platformVmware = platformVmwareDao.read(instance.getPlatformNo());
    String publicNetworkName = platformVmware.getPublicNetwork();
    String privateNetworkName = platformVmware.getPrivateNetwork();
    for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
        if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) {
            publicNetworkName = vmwareNetwork.getNetworkName();
        } else {
            privateNetworkName = vmwareNetwork.getNetworkName();
        }
    }

    String publicIpAddress = null;
    String privateIpAddress = null;

    VirtualMachine machine = vmwareProcessClient.getVirtualMachine(vmwareInstance.getMachineName());
    for (GuestNicInfo nicInfo : machine.getGuest().getNet()) {
        // NIC?IPv4??
        NetIpConfigInfoIpAddress[] tmpAddresses = nicInfo.getIpConfig().getIpAddress();
        if (tmpAddresses == null) {
            continue;
        }

        String ipAddress = null;
        for (NetIpConfigInfoIpAddress tmpAdress : tmpAddresses) {
            try {
                InetAddress inetAddress = InetAddress.getByName(tmpAdress.getIpAddress());
                if (inetAddress instanceof Inet4Address) {
                    ipAddress = tmpAdress.getIpAddress();
                    break;
                }
            } catch (UnknownHostException ignore) {
            }
        }

        // NIC?Public?Private??
        if (publicNetworkName.equals(nicInfo.getNetwork())) {
            publicIpAddress = ipAddress;
        } else if (privateNetworkName.equals(nicInfo.getNetwork())) {
            privateIpAddress = ipAddress;
        }
    }

    if (publicIpAddress == null) {
        // IP???????
        throw new AutoException("EPROCESS-000510", vmwareInstance.getMachineName());
    } else if (privateIpAddress == null) {
        // IP???????
        throw new AutoException("EPROCESS-000511", vmwareInstance.getMachineName());
    }

    // 
    processLogger.writeLogSupport(ProcessLogger.LOG_DEBUG, null, instance, "VmwareInstanceStartFinish",
            new Object[] { platform.getPlatformName(), vmwareInstance.getMachineName() });

    // ??
    vmwareInstance = vmwareInstanceDao.read(instanceNo);
    vmwareInstance.setIpAddress(publicIpAddress);
    vmwareInstance.setPrivateIpAddress(privateIpAddress);
    vmwareInstanceDao.update(vmwareInstance);

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100432", vmwareInstance.getMachineName()));
    }
}

From source file:com.evolveum.midpoint.model.common.expression.evaluator.AbstractSearchExpressionEvaluator.java

private ObjectSearchStrategyType getSearchStrategy() {
    SearchObjectExpressionEvaluatorType evaluator = getExpressionEvaluatorType();
    if (evaluator.getSearchStrategy() != null) {
        return evaluator.getSearchStrategy();
    }/*from  ww w .j  a v  a 2s  . com*/
    if (BooleanUtils.isTrue(evaluator.isSearchOnResource())) {
        return ObjectSearchStrategyType.ON_RESOURCE;
    }
    return ObjectSearchStrategyType.IN_REPOSITORY;
}

From source file:jp.primecloud.auto.process.ComponentProcess.java

protected List<Component> getComponents(Long farmNo) {
    // ????//from w  w  w .j  av  a  2s .  com
    List<Component> components = componentDao.readByFarmNo(farmNo);

    // ???
    List<Component> tmpComponents = new ArrayList<Component>();
    for (Component component : components) {
        if (BooleanUtils.isTrue(component.getLoadBalancer())) {
            continue;
        }
        tmpComponents.add(component);
    }
    components = tmpComponents;

    // ???
    Comparator<Component> comparator = new Comparator<Component>() {
        @Override
        public int compare(Component o1, Component o2) {
            ComponentType c1 = componentTypeDao.read(o1.getComponentTypeNo());
            ComponentType c2 = componentTypeDao.read(o2.getComponentTypeNo());
            Integer runOrder1 = c1.getRunOrder();
            Integer runOrder2 = c2.getRunOrder();

            int ro1 = runOrder1 == null ? 0 : runOrder1.intValue();
            int ro2 = runOrder2 == null ? 0 : runOrder2.intValue();

            return ro1 - ro2;
        }
    };

    Collections.sort(components, comparator);

    return components;
}

From source file:gov.nih.nci.cabig.caaers.web.study.StudyCommand.java

public boolean isDataEntryComplete() {
    return BooleanUtils.isTrue(study.getDataEntryStatus());
}

From source file:de.iteratec.iteraplan.presentation.dialog.TabularReporting.TabularReportingFrontendServiceImpl.java

private String getResultFormat(ManageReportMemoryBean memBean) {
    String resultFormat = memBean.getTabularOptions().getResultFormat();
    // if no resultFormat is set, default to HTML
    if (resultFormat == null || BooleanUtils.isTrue(memBean.getMassUpdateMode())) {
        resultFormat = Constants.REPORTS_EXPORT_HTML;
    }/*from   ww  w  .ja  va2s  .  c o m*/
    return resultFormat;
}

From source file:jp.primecloud.auto.process.lb.PuppetLoadBalancerProcess.java

protected Map<String, Object> createLoadBalancerMap(Long loadBalancerNo) {
    Map<String, Object> map = new HashMap<String, Object>();

    // LoadBalancer
    LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo);
    map.put("loadBalancer", loadBalancer);

    // LoadBalancerListener
    List<LoadBalancerListener> allListeners = loadBalancerListenerDao.readByLoadBalancerNo(loadBalancerNo);
    List<LoadBalancerListener> listeners = new ArrayList<LoadBalancerListener>();
    for (LoadBalancerListener listener : allListeners) {
        if (BooleanUtils.isTrue(listener.getEnabled())) {
            listeners.add(listener);/*from   w w  w. ja va2  s  . co m*/
        }
    }
    map.put("listeners", listeners);

    // LoadBalancerHealthCheck
    LoadBalancerHealthCheck healthCheck = loadBalancerHealthCheckDao.read(loadBalancerNo);
    map.put("healthCheck", healthCheck);

    // LoadBalancerinstance
    List<LoadBalancerInstance> lbInstances = loadBalancerInstanceDao.readByLoadBalancerNo(loadBalancerNo);
    List<Long> targetInstanceNos = new ArrayList<Long>();
    for (LoadBalancerInstance lbInstance : lbInstances) {
        if (BooleanUtils.isTrue(lbInstance.getEnabled())) {
            targetInstanceNos.add(lbInstance.getInstanceNo());
        }
    }
    List<Instance> tmpInstances = instanceDao.readInInstanceNos(targetInstanceNos);
    List<Instance> targetInstances = new ArrayList<Instance>();
    for (Instance tmpInstance : tmpInstances) {
        if (BooleanUtils.isTrue(tmpInstance.getEnabled())) {
            InstanceStatus status = InstanceStatus.fromStatus(tmpInstance.getStatus());
            if (status == InstanceStatus.RUNNING) {
                targetInstances.add(tmpInstance);
            }
        }
    }
    map.put("targetInstances", targetInstances);

    return map;
}

From source file:gov.nih.nci.cabig.caaers.domain.repository.ReportRepositoryImpl.java

public List<Report> createChildReports(Report report) {

    List<Report> instantiatedReports = null;
    //check if there is children
    ReportDefinitionQuery query = new ReportDefinitionQuery();
    query.filterByParent(report.getReportDefinition().getId());
    query.filterByEnabled();//w ww .j a va 2  s.c  o m
    List<ReportDefinition> rdChildren = (List<ReportDefinition>) reportDefinitionDao.search(query);
    if (CollectionUtils.isNotEmpty(rdChildren)) {
        if (BooleanUtils.isTrue(report.isAmendable())) {
            amendReport(report);
        }

        instantiatedReports = new ArrayList<Report>();
        for (ReportDefinition rdChild : rdChildren) {
            rdChild.setManuallySelected(report.isManuallySelected());
            Report childReport = createReport(rdChild, report.getAeReport(), report);
            instantiatedReports.add(childReport);
        }
    }

    return instantiatedReports;
}

From source file:mitm.common.security.smime.handler.SMIMEInfoHandlerImpl.java

private MimeMessage handleSigned(MimeMessage message, SMIMEInspector sMIMEInspector, int level)
        throws MessagingException {
    SMIMESignedInspector signedInspector = sMIMEInspector.getSignedInspector();

    Collection<X509Certificate> certificates = null;

    try {/*  w w  w .j a  va2s.c  o  m*/
        certificates = signedInspector.getCertificates();
    } catch (CryptoMessageSyntaxException e) {
        logger.error("Error getting certificates from signed message.", e);
    }

    Set<String> signerEmail = new HashSet<String>();

    List<SignerInfo> signers;

    try {
        signers = signedInspector.getSigners();
    } catch (CryptoMessageSyntaxException e) {
        throw new MessagingException("Error getting signers.", e);
    }

    Boolean signatureValid = null;

    for (int signerIndex = 0; signerIndex < signers.size(); signerIndex++) {
        Boolean thisSignatureValid = null;

        try {
            SignerInfo signer = signers.get(signerIndex);

            SignerIdentifier signerId;

            try {
                signerId = signer.getSignerId();
            } catch (IOException e) {
                logger.error("Error getting signerId", e);

                /*
                 * Continue with other signers
                 */
                continue;
            }

            addSignerIdentifierInfo(message, signerIndex, signerId, level);

            /*
             * try to get the signing certificate using a certificate selector
             */
            CertSelector certSelector;

            try {
                certSelector = signerId.getSelector();
            } catch (IOException e) {
                logger.error("Error getting selector for signer", e);

                /*
                 * Continue with other signers
                 */
                continue;
            }

            /* first search through the certificates that are embedded in the CMS blob */
            Collection<X509Certificate> signingCerts = CertificateUtils.getMatchingCertificates(certificates,
                    certSelector);

            if (signingCerts.size() == 0 && securityServices.getKeyAndCertStore() != null) {
                /*
                 * the certificate could not be found in the CMS blob. If the CertStore is
                 * set we will see if the CertStore has a match.
                 */
                try {
                    signingCerts = securityServices.getKeyAndCertStore().getCertificates(certSelector);
                } catch (CertStoreException e) {
                    logger.error("Error getting certificates from the CertStore.", e);
                }
            }

            X509Certificate signingCertificate = null;

            if (signingCerts != null && signingCerts.size() > 0) {
                /*
                 * there can be more than one match, although in practice this should not happen
                 * often. Get the first one. If the sender is so stupid to send different
                 * certificates with same issuer/serial, subjectKeyId (which is not likely) than
                 * he/she cannot expect the signature to validate correctly. If the sender did
                 * not add a certificate to the CMS blob but the certificate was found in the
                 * CertStore it can happen that the wrong certificate was found. Solving this
                 * requires that we step through all certificates found an verify until we found
                 * the correct one.
                 */
                signingCertificate = signingCerts.iterator().next();
            }

            if (signingCertificate != null) {
                if (!verifySignature(message, signerIndex, signer, signingCertificate, level)) {
                    thisSignatureValid = false;
                }

                /*
                 * we expect that the certificates from the CMS blob were already added to the stores
                 * if the certificate is not in the store the path cannot be build. It is possible to
                 * add them temporarily to the CertPathBuilder but that's not always as fast as adding
                 * them to the global CertStore.
                 */
                if (!verifySigningCertificate(message, signerIndex, signingCertificate, certificates, level)) {
                    thisSignatureValid = false;
                }

                if (thisSignatureValid == null) {
                    thisSignatureValid = true;
                }

                try {
                    signerEmail.addAll(new X509CertificateInspector(signingCertificate).getEmail());
                } catch (Exception e) {
                    logger.error("Error getting email addresses", e);
                }
            } else {
                String info = "Signing certificate could not be found.";

                logger.warn(info);

                setHeader(SMIMESecurityInfoHeader.SIGNER_VERIFIED + signerIndex, "False", level, message);
                setHeader(SMIMESecurityInfoHeader.SIGNER_VERIFICATION_INFO + signerIndex, info, level, message);
            }
        } finally {
            /*
             * Only make the overall signatureValid true if it was not already set and if the current
             * signature check is valid
             */
            if (BooleanUtils.isTrue(thisSignatureValid) && signatureValid == null) {
                signatureValid = true;
            }

            if (BooleanUtils.isFalse(thisSignatureValid)) {
                signatureValid = false;
            }
        }
    } /* end for */

    onSigned(message, sMIMEInspector, level, BooleanUtils.isTrue(signatureValid), signerEmail);

    return message;
}