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

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

Introduction

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

Prototype

public static boolean isNotTrue(Boolean bool) 

Source Link

Document

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

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

Usage

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

protected void startInstances(Long loadBalancerNo, List<Long> instanceNos) {
    // ??/*from ww  w  .  java2  s.co  m*/
    List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
    for (Instance instance : instances) {
        if (BooleanUtils.isNotTrue(instance.getEnabled())) {
            instance.setEnabled(true);
            instanceDao.update(instance);
        }
    }

    // ????
    List<ComponentInstance> componentInstances = componentInstanceDao.readInInstanceNos(instanceNos);
    for (ComponentInstance componentInstance : componentInstances) {
        if (BooleanUtils.isNotTrue(componentInstance.getEnabled())) {
            componentInstance.setEnabled(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    // ??????
    List<Instance> targetInstances = new ArrayList<Instance>();
    for (Instance instance : instances) {
        InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus());
        if (status == InstanceStatus.STOPPED) {
            targetInstances.add(instance);
        }
    }

    // ????????
    if (targetInstances.isEmpty()) {
        return;
    }

    // ?????
    final LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo);
    List<Callable<Void>> callables = new ArrayList<Callable<Void>>();
    final Map<String, Object> loggingContext = LoggingUtils.getContext();
    for (final Instance instance : targetInstances) {
        Callable<Void> callable = new Callable<Void>() {
            @Override
            public Void call() throws Exception {
                LoggingUtils.setContext(loggingContext);
                try {
                    if (log.isInfoEnabled()) {
                        log.info(MessageUtils.getMessage("IPROCESS-200211", loadBalancer.getLoadBalancerNo(),
                                instance.getInstanceNo(), loadBalancer.getLoadBalancerName(),
                                instance.getInstanceName()));
                    }

                    instanceProcess.start(instance.getInstanceNo());

                    if (log.isInfoEnabled()) {
                        log.info(MessageUtils.getMessage("IPROCESS-200212", loadBalancer.getLoadBalancerNo(),
                                instance.getInstanceNo(), loadBalancer.getLoadBalancerName(),
                                instance.getInstanceName()));
                    }
                } catch (Exception e) {
                    log.error(e.getMessage(), e);
                    throw e;
                } finally {
                    LoggingUtils.removeContext();
                }
                return null;
            }
        };
        callables.add(callable);
    }

    try {
        List<Future<Void>> futures = executorService.invokeAll(callables);

        // ???
        List<Throwable> throwables = new ArrayList<Throwable>();
        for (Future<Void> future : futures) {
            try {
                future.get();
            } catch (ExecutionException e) {
                throwables.add(e.getCause());
            } catch (InterruptedException ignore) {
            }
        }

        // ??
        if (throwables.size() > 0) {
            throw new MultiCauseException(throwables.toArray(new Throwable[throwables.size()]));
        }
    } catch (InterruptedException e) {
    }
}

From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java

/**
 * {@inheritDoc}/*from w  ww  .jav a2s . c  o  m*/
 */
@Override
public void startComponents(Long farmNo, Long componentNo, List<Long> instanceNos) {
    // ????
    List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo);
    for (ComponentInstance componentInstance : componentInstances) {
        if (!instanceNos.contains(componentInstance.getInstanceNo())) {
            continue;
        }
        if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
            // ????????
            if (BooleanUtils.isTrue(componentInstance.getEnabled())
                    || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
                componentInstance.setEnabled(false);
                componentInstance.setConfigure(true);
                componentInstanceDao.update(componentInstance);
            }
            continue;
        }
        if (BooleanUtils.isNotTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
            componentInstance.setEnabled(true);
            componentInstance.setConfigure(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    // ?????????
    List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
    for (Instance instance : instances) {
        if (BooleanUtils.isNotTrue(instance.getEnabled())) {
            instance.setEnabled(true);
            instanceDao.update(instance);
        }
    }

    // ????
    scheduleFarm(farmNo);
}

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

/**
 * This method will return a a sorted list containing the newly added evaluated adverse events + adverse events associated to data collection, that got modified +
 * adverse events associated to data collection that are not reported.
 *
 * @return the modified reportable adverse events
 *///from ww  w.j a v a2s .  c om
@Transient
public List<AdverseEvent> getModifiedReportableAdverseEvents() {
    List<AdverseEvent> reportableAdverseEvents = new ArrayList<AdverseEvent>();
    for (AdverseEvent ae : getPopulatedAdverseEvents()) {
        if (ae.isModified() || BooleanUtils.isNotTrue(ae.getReported()))
            reportableAdverseEvents.add(ae);
    }
    return reportableAdverseEvents;
}

From source file:jp.primecloud.auto.ui.WinServiceAdd.java

private void showServices() {
    serviceTable.removeAllItems();//w w  w .  ja v a 2  s .c o  m

    // ????
    for (int i = 0; i < componentTypes.size(); i++) {
        ComponentTypeDto componentType = componentTypes.get(i);

        if (BooleanUtils.isNotTrue(componentType.getComponentType().getSelectable())) {
            //????????
            continue;
        }

        // ??
        String name = componentType.getComponentType().getComponentTypeNameDisp();
        Icons nameIcon = Icons.fromName(componentType.getComponentType().getComponentTypeName());

        Label slbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, nameIcon) + "\"><div>" + name + "</div>",
                Label.CONTENT_XHTML);
        slbl.setHeight(COLUMN_HEIGHT);

        // 
        String description = componentType.getComponentType().getLayerDisp();

        serviceTable.addItem(new Object[] { (i + 1), slbl, description },
                componentType.getComponentType().getComponentTypeNo());
    }

    Long componentTypeNo = null;
    if (serviceTable.getItemIds().size() > 0) {
        componentTypeNo = (Long) serviceTable.getItemIds().toArray()[0];
    }

    // ???
    serviceTable.select(componentTypeNo);
}

From source file:jp.primecloud.auto.ui.WinServerAdd.java

private void showClouds() {
    cloudTable.removeAllItems();//  w ww .  j  a  v a  2  s . c  o m

    // ?
    for (int i = 0; i < platforms.size(); i++) {
        PlatformDto platformDto = platforms.get(i);

        if (BooleanUtils.isNotTrue(platformDto.getPlatform().getSelectable())) {
            //??????
            continue;
        }

        //????
        Icons icon = CommonUtils.getPlatformIcon(platformDto);

        String description = platformDto.getPlatform().getPlatformNameDisp();

        Label slbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, icon) + "\"><div>" + description + "</div>",
                Label.CONTENT_XHTML);
        slbl.setHeight(COLUMN_HEIGHT);

        cloudTable.addItem(new Object[] { (i + 1), slbl }, platformDto.getPlatform().getPlatformNo());
    }

    Long platformNo = null;
    if (cloudTable.getItemIds().size() > 0) {
        platformNo = (Long) cloudTable.getItemIds().toArray()[0];
    }

    // ???
    cloudTable.select(platformNo);
}

From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java

/**
 * {@inheritDoc}//from   w  w w . j av a  2s  .c o m
 */
@Override
public void stopComponents(Long farmNo, List<Long> componentNos, boolean stopInstance) {
    // ????
    List<ComponentInstance> componentInstances = componentInstanceDao.readInComponentNos(componentNos);
    for (ComponentInstance componentInstance : componentInstances) {
        if (BooleanUtils.isTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
            componentInstance.setEnabled(false);
            componentInstance.setConfigure(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    // ?????????
    if (stopInstance) {
        Set<Long> instanceNos = new LinkedHashSet<Long>();
        for (ComponentInstance componentInstance : componentInstances) {
            instanceNos.add(componentInstance.getInstanceNo());
        }
        List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
        for (Instance instance : instances) {
            if (BooleanUtils.isNotTrue(instance.getEnabled())) {
                continue;
            }

            // ???????????
            boolean allDisabled = true;
            List<ComponentInstance> componentInstances2 = componentInstanceDao
                    .readByInstanceNo(instance.getInstanceNo());
            for (ComponentInstance componentInstance : componentInstances2) {
                if (BooleanUtils.isTrue(componentInstance.getEnabled())) {
                    allDisabled = false;
                    break;
                }
            }

            // ???????
            if (allDisabled) {
                instance.setEnabled(false);
                instanceDao.update(instance);
            }
        }
    }

    // ????
    scheduleFarm(farmNo);
}

From source file:com.evolveum.midpoint.model.impl.importer.ObjectImporter.java

private <T extends ObjectType> void importObjectToRepository(PrismObject<T> object, ImportOptionsType options,
        boolean raw, Task task, OperationResult objectResult) throws ObjectNotFoundException,
        ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException,
        SecurityViolationException, SchemaException, ObjectAlreadyExistsException {

    OperationResult result = objectResult
            .createSubresult(ObjectImporter.class.getName() + ".importObjectToRepository");

    if (options == null) {
        options = new ImportOptionsType();
    }//ww w  .  j a  v a 2 s .c om

    if (BooleanUtils.isTrue(options.isKeepOid()) && object.getOid() == null) {
        // Try to check if there is existing object with the same type and name
        ObjectQuery query = ObjectQueryUtil.createNameQuery(object);
        List<PrismObject<T>> foundObjects = repository.searchObjects(object.getCompileTimeClass(), query, null,
                result);
        if (foundObjects.size() == 1) {
            String oid = foundObjects.iterator().next().getOid();
            object.setOid(oid);
        }
    }

    try {
        String oid = addObject(object, BooleanUtils.isTrue(options.isOverwrite()),
                BooleanUtils.isFalse(options.isEncryptProtectedValues()), raw, task, result);

        if (object.canRepresent(TaskType.class)) {
            taskManager.onTaskCreate(oid, result);
        }
        result.recordSuccess();

    } catch (ObjectAlreadyExistsException e) {
        if (BooleanUtils.isTrue(options.isOverwrite() && BooleanUtils.isNotTrue(options.isKeepOid())
                && object.getOid() == null)) {
            // This is overwrite, without keep oid, therefore we do not have conflict on OID
            // this has to be conflict on name. So try to delete the conflicting object and create new one (with a new OID).
            result.muteLastSubresultError();
            ObjectQuery query = ObjectQueryUtil.createNameQuery(object);
            List<PrismObject<T>> foundObjects = repository.searchObjects(object.getCompileTimeClass(), query,
                    null, result);
            if (foundObjects.size() == 1) {
                PrismObject<T> foundObject = foundObjects.iterator().next();
                String deletedOid = deleteObject(foundObject, repository, result);
                if (deletedOid != null) {
                    if (object.canRepresent(TaskType.class)) {
                        taskManager.onTaskDelete(deletedOid, result);
                    }
                    if (BooleanUtils.isTrue(options.isKeepOid())) {
                        object.setOid(deletedOid);
                    }
                    addObject(object, false, BooleanUtils.isFalse(options.isEncryptProtectedValues()), raw,
                            task, result);
                    if (object.canRepresent(TaskType.class)) {
                        taskManager.onTaskCreate(object.getOid(), result);
                    }
                    result.recordSuccess();
                } else {
                    // cannot delete, throw original exception
                    result.recordFatalError("Object already exists, cannot overwrite", e);
                    throw e;
                }
            } else {
                // Cannot locate conflicting object
                String message = "Conflicting object already exists but it was not possible to precisely locate it, "
                        + foundObjects.size() + " objects with same name exist";
                result.recordFatalError(message, e);
                throw new ObjectAlreadyExistsException(message, e);
            }
        } else {
            result.recordFatalError(e);
            throw e;
        }
    } catch (ObjectNotFoundException | ExpressionEvaluationException | CommunicationException
            | ConfigurationException | PolicyViolationException | SecurityViolationException
            | SchemaException e) {
        result.recordFatalError("Cannot import " + object + ": " + e.getMessage(), e);
        throw e;
    } catch (RuntimeException ex) {
        result.recordFatalError("Couldn't import object: " + object + ". Reason: " + ex.getMessage(), ex);
        throw ex;
    }
}

From source file:jp.primecloud.auto.process.puppet.PuppetNodeProcess.java

protected Map<String, Object> createNodeMap(Long instanceNo, boolean start) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("start", start);

    // Instance/* w  ww  .j a  va  2 s .c om*/
    Instance instance = instanceDao.read(instanceNo);
    map.put("instance", instance);

    // Farm
    Farm farm = farmDao.read(instance.getFarmNo());
    map.put("farm", farm);

    // User
    User user = userDao.read(farm.getUserNo());
    PccSystemInfo pccSystemInfo = pccSystemInfoDao.read();
    PasswordEncryptor encryptor = new PasswordEncryptor();
    user.setPassword(encryptor.decrypt(user.getPassword(), pccSystemInfo.getSecretKey()));
    map.put("user", user);

    // Component
    List<Component> components = componentDao.readByFarmNo(instance.getFarmNo());
    map.put("components", components);
    Map<Long, Component> componentMap = new HashMap<Long, Component>();
    for (Component component : components) {
        componentMap.put(component.getComponentNo(), component);
    }

    // ComponentType
    List<ComponentType> componentTypes = componentTypeDao.readAll();
    Map<Long, ComponentType> componentTypeMap = new HashMap<Long, ComponentType>();
    for (ComponentType componentType : componentTypes) {
        componentTypeMap.put(componentType.getComponentTypeNo(), componentType);
    }

    // PuppetInstance
    PuppetInstance puppetInstance = puppetInstanceDao.read(instanceNo);
    map.put("puppetInstance", puppetInstance);

    // Platform
    Platform platform = platformDao.read(instance.getPlatformNo());
    map.put("platform", platform);
    // TODO CLOUD BRANCHING
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) {
        // AwsVolume
        List<AwsVolume> awsVolumes = awsVolumeDao.readByInstanceNo(instanceNo);
        map.put("awsVolumes", awsVolumes);
    } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platform.getPlatformType())) {
        // CloudStackVolume
        List<CloudstackVolume> cloudstackVolumes = cloudstackVolumeDao.readByInstanceNo(instanceNo);
        map.put("cloudstackVolumes", cloudstackVolumes);
    } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platform.getPlatformType())) {
        // VmwareDisk
        List<VmwareDisk> vmwareDisks = vmwareDiskDao.readByInstanceNo(instanceNo);
        map.put("vmwareDisks", vmwareDisks);
    } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) {
        // VcloudDisk
        List<VcloudDisk> vcloudDisks = vcloudDiskDao.readByInstanceNo(instanceNo);
        map.put("vcloudDisks", vcloudDisks);
    } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platform.getPlatformType())) {
        // AzureDisk
        List<AzureDisk> azureDisks = azureDiskDao.readByInstanceNo(instanceNo);
        map.put("azureDisks", azureDisks);
    } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platform.getPlatformType())) {
        // OpenstackVolume
        List<OpenstackVolume> osVolumes = openstackVolumeDao.readByInstanceNo(instanceNo);
        map.put("osVolumes", osVolumes);
    }

    // ???
    map.put("zabbixServer", Config.getProperty("zabbix.server"));
    map.put("rsyslogServer", Config.getProperty("rsyslog.server"));

    // Zabbix???IP
    String zabbixListenIp = instance.getPublicIp();
    if (PCCConstant.PLATFORM_TYPE_AWS.equals(platform.getPlatformType())) {
        if (BooleanUtils.isTrue(platform.getInternal())) {
            // ?AWS???privateIp????
            // ????????
            // Eucalyptus
            // AWS
            // ?VPC(VPC+VPN???)
            zabbixListenIp = instance.getPrivateIp();
        }
    }
    map.put("zabbixListenIp", zabbixListenIp);

    // Zabbix ??
    // Zabbix?????? prefix + - + fqdn ??
    // prefix?config.properties??
    String zabbixHostname = instance.getFqdn();
    if (StringUtils.isNotEmpty(Config.getProperty("zabbix.prefix"))) {
        zabbixHostname = Config.getProperty("zabbix.prefix") + "-" + instance.getFqdn();
    }
    log.debug("zabbixHostname =" + zabbixHostname);
    map.put("zabbixHostname", zabbixHostname);

    // ???
    List<Component> associatedComponents = new ArrayList<Component>();
    List<ComponentType> associatedComponentTypes = new ArrayList<ComponentType>();
    List<ComponentInstance> componentInstances = componentInstanceDao.readByInstanceNo(instanceNo);
    for (ComponentInstance componentInstance : componentInstances) {
        // ??
        if (BooleanUtils.isNotTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
            continue;
        }

        for (Component component : components) {
            if (component.getComponentNo().equals(componentInstance.getComponentNo())) {
                associatedComponents.add(component);
                ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo());
                associatedComponentTypes.add(componentType);
            }
        }
    }

    map.put("associatedComponents", associatedComponents);
    map.put("associatedComponentTypes", associatedComponentTypes);

    //????(???,????)
    Map<String, String> componentTypeNameMap = new HashMap<String, String>();
    for (ComponentInstance componentInstance : componentInstances) {
        if (!componentTypeNameMap.containsKey(componentInstance.getComponentNo())) {
            Component component = componentMap.get(componentInstance.getComponentNo());
            ComponentType componentType = componentTypeMap.get(component.getComponentTypeNo());
            componentTypeNameMap.put(componentInstance.getComponentNo().toString(),
                    componentType.getComponentTypeName());
        }
    }

    map.put("componentTypeNameMap", componentTypeNameMap);
    return map;
}

From source file:jp.primecloud.auto.ui.WinServerAdd.java

private void showImages(Long platformNo) {
    imageTable.removeAllItems();/*  w w  w .  j a v  a 2 s  .  c om*/
    serviceTable.removeAllItems();
    if (platformNo == null) {
        return;
    }

    // ????????
    List<ImageDto> images = null;
    for (PlatformDto platform : platforms) {
        if (platformNo.equals(platform.getPlatform().getPlatformNo())) {
            images = platform.getImages();
            break;
        }
    }

    // ?????
    if (images == null) {
        return;
    }

    // ??
    int n = 0;
    for (ImageDto image : images) {
        // ?????????
        if (BooleanUtils.isNotTrue(image.getImage().getSelectable())) {
            continue;
        }

        // ???
        String name = image.getImage().getImageNameDisp();
        Icons nameIcon = CommonUtils.getImageIcon(image);

        Label nlbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, nameIcon) + "\"><div>" + name + "</div>",
                Label.CONTENT_XHTML);
        nlbl.setHeight(COLUMN_HEIGHT);

        // OS??
        String os = image.getImage().getOsDisp();
        Icons osIcon = CommonUtils.getOsIcon(image);

        Label slbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, osIcon) + "\"><div>" + os + "</div>",
                Label.CONTENT_XHTML);
        slbl.setHeight(COLUMN_HEIGHT);

        n++;
        imageTable.addItem(new Object[] { n, nlbl, slbl }, image.getImage().getImageNo());
    }

    Long imageNo = null;
    if (imageTable.getItemIds().size() > 0) {
        imageNo = (Long) imageTable.getItemIds().toArray()[0];
    }

    // ????
    imageTable.select(imageNo);
}

From source file:jp.primecloud.auto.service.impl.ProcessServiceImpl.java

/**
 * {@inheritDoc}/*from  ww  w.j  ava 2s .c  om*/
 */
@Override
public void stopComponents(Long farmNo, Long componentNo, List<Long> instanceNos, boolean stopInstance) {
    // ????
    List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo);
    for (ComponentInstance componentInstance : componentInstances) {
        if (!instanceNos.contains(componentInstance.getInstanceNo())) {
            continue;
        }
        if (BooleanUtils.isTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
            componentInstance.setEnabled(false);
            componentInstance.setConfigure(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    if (stopInstance) {
        // ?????????
        for (ComponentInstance componentInstance : componentInstances) {
            instanceNos.add(componentInstance.getInstanceNo());
        }
        List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
        for (Instance instance : instances) {
            if (BooleanUtils.isNotTrue(instance.getEnabled())) {
                continue;
            }

            // ???????????
            boolean allDisabled = true;
            List<ComponentInstance> componentInstances2 = componentInstanceDao
                    .readByInstanceNo(instance.getInstanceNo());
            for (ComponentInstance componentInstance : componentInstances2) {
                if (BooleanUtils.isTrue(componentInstance.getEnabled())) {
                    allDisabled = false;
                    break;
                }
            }

            // ???????
            if (allDisabled) {
                instance.setEnabled(false);
                instanceDao.update(instance);
            }
        }
    }

    // ????
    scheduleFarm(farmNo);
}