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.service.impl.FarmServiceImpl.java

/**
 * {@inheritDoc}//from www. j  ava 2 s.  com
 */
@Override
public void deleteFarm(Long farmNo) {
    // ?
    if (farmNo == null) {
        throw new AutoApplicationException("ECOMMON-000003", "farmNo");
    }

    // ??
    Farm farm = farmDao.read(farmNo);
    if (farm == null) {
        // ?????
        return;
    }

    // ?????????????
    List<Component> components = componentDao.readByFarmNo(farmNo);
    for (Component component : components) {
        // ?????????
        if (BooleanUtils.isTrue(component.getLoadBalancer())) {
            continue;
        }

        List<ComponentInstance> componentInstances = componentInstanceDao
                .readByComponentNo(component.getComponentNo());
        for (ComponentInstance componentInstance : componentInstances) {
            ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus());
            if (status != ComponentInstanceStatus.STOPPED) {
                // ????????
                throw new AutoApplicationException("ESERVICE-000202", component.getComponentName());
            }
        }
    }

    // ???????????
    List<Instance> instances = instanceDao.readByFarmNo(farmNo);
    for (Instance instance : instances) {
        // ???????
        if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
            continue;
        }

        if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.STOPPED) {
            // ??????
            throw new AutoApplicationException("ESERVICE-000203", instance.getInstanceName());
        }
    }

    // ????????????
    List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo);
    for (LoadBalancer loadBalancer : loadBalancers) {
        if (LoadBalancerStatus.fromStatus(loadBalancer.getStatus()) != LoadBalancerStatus.STOPPED) {
            // ???????
            throw new AutoApplicationException("ESERVICE-000207", loadBalancer.getLoadBalancerName());
        }
    }

    // ??
    Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix"));
    if (BooleanUtils.isTrue(useZabbix)) {
        zabbixHostProcess.deleteFarmHostgroup(farmNo);
    }

    // ???
    for (LoadBalancer loadBalancer : loadBalancers) {
        loadBalancerService.deleteLoadBalancer(loadBalancer.getLoadBalancerNo());
    }

    // ????
    for (Component component : components) {
        componentService.deleteComponent(component.getComponentNo());
    }

    // ??
    for (Instance instance : instances) {
        instanceService.deleteInstance(instance.getInstanceNo());
    }

    // TODO CLOUD BRANCHING
    // AWS??
    // AWS??
    // TODO: ???????
    List<AwsVolume> awsVolumes = awsVolumeDao.readByFarmNo(farmNo);
    for (AwsVolume awsVolume : awsVolumes) {
        if (StringUtils.isEmpty(awsVolume.getVolumeId())) {
            continue;
        }

        IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(),
                awsVolume.getPlatformNo());
        try {
            // ?
            gateway.deleteVolume(awsVolume.getVolumeId());

            // EC2??DeleteVolume???????Wait???
            //awsProcessClient.waitDeleteVolume(volumeId);
        } catch (AutoException ignore) {
            // ??????????????
        }
    }
    awsVolumeDao.deleteByFarmNo(farmNo);

    // VMware??
    // VLAN??
    List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(farmNo);
    for (VmwareNetwork vmwareNetwork : vmwareNetworks) {
        // PortGroup
        VmwareProcessClient vmwareProcessClient = vmwareProcessClientFactory
                .createVmwareProcessClient(vmwareNetwork.getPlatformNo());
        try {
            vmwareNetworkProcess.removeNetwork(vmwareProcessClient, vmwareNetwork.getNetworkNo());
        } finally {
            vmwareProcessClient.getVmwareClient().logout();
        }

        // VLAN?
        vmwareNetwork.setFarmNo(null);
        vmwareNetworkDao.update(vmwareNetwork);
    }

    // VCloud??
    // VCloud vApp??
    List<Platform> platforms = platformDao.readAll();
    for (Platform platform : platforms) {
        if (!PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platform.getPlatformType())) {
            //VCloud????
            continue;
        }

        IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(),
                platform.getPlatformNo());
        try {
            if (BooleanUtils.isTrue(platform.getSelectable())
                    && vcloudCertificateDao.countByUserNoAndPlatformNo(farm.getUserNo(),
                            platform.getPlatformNo()) > 0
                    && vcloudKeyPairDao.countByUserNoAndPlatformNo(farm.getUserNo(),
                            platform.getPlatformNo()) > 0) {
                // myCloud(vApp)?
                gateway.deleteMyCloud(farmNo);
            }
        } catch (AutoException ignore) {
            // ??VCloud????
            // ??????????????
        }
    }

    // Azure??
    // ????

    // OpenStack??
    // ????

    //??
    userAuthDao.deleteByFarmNo(farmNo);

    // ??
    farmDao.deleteByFarmNo(farmNo);

    // 
    eventLogger.log(EventLogLevel.INFO, farmNo, farm.getFarmName(), null, null, null, null, "FarmDelete", null,
            null, null);
}

From source file:com.evolveum.midpoint.common.refinery.RefinedAttributeDefinitionImpl.java

static <T> RefinedAttributeDefinition<T> parse(ResourceAttributeDefinition<T> schemaAttrDef,
        ResourceAttributeDefinitionType schemaHandlingAttrDefType,
        ObjectClassComplexTypeDefinition objectClassDef, PrismContext prismContext, String contextDescription)
        throws SchemaException {

    RefinedAttributeDefinitionImpl<T> rAttrDef = new RefinedAttributeDefinitionImpl<>(schemaAttrDef,
            prismContext);//from  www  . ja va2  s . c o m

    if (schemaHandlingAttrDefType != null && schemaHandlingAttrDefType.getDisplayName() != null) {
        rAttrDef.setDisplayName(schemaHandlingAttrDefType.getDisplayName());
    } else {
        if (schemaAttrDef.getDisplayName() != null) {
            rAttrDef.setDisplayName(schemaAttrDef.getDisplayName());
        }
    }

    if (schemaHandlingAttrDefType != null && schemaHandlingAttrDefType.getDisplayOrder() != null) {
        rAttrDef.setDisplayOrder(schemaHandlingAttrDefType.getDisplayOrder());
    } else {
        if (schemaAttrDef.getDisplayOrder() != null) {
            rAttrDef.setDisplayOrder(schemaAttrDef.getDisplayOrder());
        }
    }

    rAttrDef.matchingRuleQName = schemaAttrDef.getMatchingRuleQName();
    if (schemaHandlingAttrDefType != null) {
        rAttrDef.fetchStrategy = schemaHandlingAttrDefType.getFetchStrategy();
        if (schemaHandlingAttrDefType.getMatchingRule() != null) {
            rAttrDef.matchingRuleQName = schemaHandlingAttrDefType.getMatchingRule();
        }
    }

    PropertyLimitations schemaLimitations = getOrCreateLimitations(rAttrDef.limitationsMap, LayerType.SCHEMA);
    schemaLimitations.setMinOccurs(schemaAttrDef.getMinOccurs());
    schemaLimitations.setMaxOccurs(schemaAttrDef.getMaxOccurs());
    schemaLimitations.setProcessing(schemaAttrDef.getProcessing());
    schemaLimitations.getAccess().setAdd(schemaAttrDef.canAdd());
    schemaLimitations.getAccess().setModify(schemaAttrDef.canModify());
    schemaLimitations.getAccess().setRead(schemaAttrDef.canRead());

    if (schemaHandlingAttrDefType != null) {

        if (schemaHandlingAttrDefType.getDescription() != null) {
            rAttrDef.setDescription(schemaHandlingAttrDefType.getDescription());
        }

        if (schemaHandlingAttrDefType.isTolerant() == null) {
            rAttrDef.tolerant = true;
        } else {
            rAttrDef.tolerant = schemaHandlingAttrDefType.isTolerant();
        }

        if (schemaHandlingAttrDefType.isSecondaryIdentifier() == null) {
            rAttrDef.secondaryIdentifier = false;
        } else {
            rAttrDef.secondaryIdentifier = schemaHandlingAttrDefType.isSecondaryIdentifier();
        }

        rAttrDef.tolerantValuePattern = schemaHandlingAttrDefType.getTolerantValuePattern();
        rAttrDef.intolerantValuePattern = schemaHandlingAttrDefType.getIntolerantValuePattern();

        rAttrDef.isExclusiveStrong = BooleanUtils.isTrue(schemaHandlingAttrDefType.isExclusiveStrong());
        rAttrDef.isVolatilityTrigger = BooleanUtils.isTrue(schemaHandlingAttrDefType.isVolatilityTrigger());

        if (schemaHandlingAttrDefType.getOutbound() != null) {
            rAttrDef.setOutboundMappingType(schemaHandlingAttrDefType.getOutbound());
        }

        if (schemaHandlingAttrDefType.getInbound() != null) {
            rAttrDef.setInboundMappingTypes(schemaHandlingAttrDefType.getInbound());
        }

        rAttrDef.setModificationPriority(schemaHandlingAttrDefType.getModificationPriority());

        rAttrDef.setReadReplaceMode(schemaHandlingAttrDefType.isReadReplaceMode()); // may be null at this point

        if (schemaHandlingAttrDefType.isDisplayNameAttribute() != null
                && schemaHandlingAttrDefType.isDisplayNameAttribute()) {
            rAttrDef.isDisplayNameAttribute = true;
        }
    }

    PropertyLimitations previousLimitations = null;
    for (LayerType layer : LayerType.values()) {
        PropertyLimitations limitations = getOrCreateLimitations(rAttrDef.limitationsMap, layer);
        if (previousLimitations != null) {
            limitations.setMinOccurs(previousLimitations.getMinOccurs());
            limitations.setMaxOccurs(previousLimitations.getMaxOccurs());
            limitations.setProcessing(previousLimitations.getProcessing());
            limitations.getAccess().setAdd(previousLimitations.getAccess().isAdd());
            limitations.getAccess().setRead(previousLimitations.getAccess().isRead());
            limitations.getAccess().setModify(previousLimitations.getAccess().isModify());
        }
        previousLimitations = limitations;
        if (schemaHandlingAttrDefType != null) {
            if (layer != LayerType.SCHEMA) {
                // SCHEMA is a pseudo-layer. It cannot be overriden ... unless specified explicitly
                PropertyLimitationsType genericLimitationsType = MiscSchemaUtil
                        .getLimitationsType(schemaHandlingAttrDefType.getLimitations(), null);
                if (genericLimitationsType != null) {
                    applyLimitationsType(limitations, genericLimitationsType);
                }
            }
            PropertyLimitationsType layerLimitationsType = MiscSchemaUtil
                    .getLimitationsType(schemaHandlingAttrDefType.getLimitations(), layer);
            if (layerLimitationsType != null) {
                applyLimitationsType(limitations, layerLimitationsType);
            }
        }
    }

    return rAttrDef;

}

From source file:com.hortonworks.streamline.streams.cluster.resource.ClusterCatalogResource.java

private Response buildClustersGetResponse(Collection<Cluster> clusters, Boolean detail) {
    if (BooleanUtils.isTrue(detail)) {
        List<ClusterResourceUtil.ClusterServicesImportResult> clustersWithServices = clusters.stream()
                .map(c -> ClusterResourceUtil.enrichCluster(c, environmentService))
                .collect(Collectors.toList());
        return WSUtils.respondEntities(clustersWithServices, OK);
    } else {//from  w w  w.j ava  2  s  .  c o  m
        return WSUtils.respondEntities(clusters, OK);
    }
}

From source file:com.hortonworks.streamline.streams.cluster.resource.ClusterCatalogResource.java

private Response buildClusterGetResponse(Cluster cluster, Boolean detail) {
    if (BooleanUtils.isTrue(detail)) {
        ClusterResourceUtil.ClusterServicesImportResult clusterWithServices = ClusterResourceUtil
                .enrichCluster(cluster, environmentService);
        return WSUtils.respondEntity(clusterWithServices, OK);
    } else {//  w  w w  .  j  a  v a 2s. c  om
        return WSUtils.respondEntity(cluster, OK);
    }
}

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//  ww  w .  ja v a  2s.c o m
    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: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();
    }// w w 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:com.jaeksoft.searchlib.webservice.crawler.webcrawler.WebCrawlerImpl.java

@Override
public CommonResult crawl(String use, String login, String key, String url, Boolean returnData) {
    try {//  w  w  w .  j  a v a 2s  .  c  o  m
        Client client = getLoggedClient(use, login, key, Role.WEB_CRAWLER_START_STOP);
        ClientFactory.INSTANCE.properties.checkApi();
        WebCrawlThread webCrawlThread = client.getWebCrawlMaster().manualCrawl(LinkUtils.newEncodedURL(url),
                HostUrlList.ListType.MANUAL);
        if (!webCrawlThread.waitForStart(120))
            throw new WebServiceException("Time out reached (120 seconds)");
        if (!webCrawlThread.waitForEnd(3600))
            throw new WebServiceException("Time out reached (3600 seconds)");
        UrlItem urlItem = webCrawlThread.getCurrentUrlItem();
        CommonResult cr = null;
        if (BooleanUtils.isTrue(returnData)) {
            Crawl crawl = webCrawlThread.getCurrentCrawl();
            if (crawl != null) {
                List<IndexDocument> indexDocuments = crawl.getTargetIndexDocuments();
                if (CollectionUtils.isNotEmpty(indexDocuments)) {
                    CommonListResult<List<FieldValueList>> clr = new CommonListResult<List<FieldValueList>>(
                            indexDocuments.size());
                    for (IndexDocument indexDocument : indexDocuments) {
                        List<FieldValueList> list = FieldValueList.getNewList(indexDocument);
                        if (list != null)
                            clr.items.add(list);
                    }
                    cr = clr;
                }
            }
        }

        String message = urlItem != null
                ? "Result: " + urlItem.getFetchStatus() + " - " + urlItem.getParserStatus() + " - "
                        + urlItem.getIndexStatus()
                : null;
        if (cr == null)
            cr = new CommonResult(true, message);
        cr.addDetail("URL", urlItem.getUrl());
        cr.addDetail("HttpResponseCode", urlItem.getResponseCode());
        cr.addDetail("RobotsTxtStatus", urlItem.getRobotsTxtStatus());
        cr.addDetail("FetchStatus", urlItem.getFetchStatus());
        cr.addDetail("ParserStatus", urlItem.getParserStatus());
        cr.addDetail("IndexStatus", urlItem.getIndexStatus());
        cr.addDetail("RedirectionURL", urlItem.getRedirectionUrl());
        cr.addDetail("ContentBaseType", urlItem.getContentBaseType());
        cr.addDetail("ContentTypeCharset", urlItem.getContentTypeCharset());
        cr.addDetail("ContentLength", urlItem.getContentLength());
        return cr;
    } catch (MalformedURLException e) {
        throw new CommonServiceException(e);
    } catch (SearchLibException e) {
        throw new CommonServiceException(e);
    } catch (ParseException e) {
        throw new CommonServiceException(e);
    } catch (IOException e) {
        throw new CommonServiceException(e);
    } catch (SyntaxError e) {
        throw new CommonServiceException(e);
    } catch (URISyntaxException e) {
        throw new CommonServiceException(e);
    } catch (ClassNotFoundException e) {
        throw new CommonServiceException(e);
    } catch (InterruptedException e) {
        throw new CommonServiceException(e);
    } catch (InstantiationException e) {
        throw new CommonServiceException(e);
    } catch (IllegalAccessException e) {
        throw new CommonServiceException(e);
    }
}

From source file:com.evolveum.midpoint.wf.impl.processors.primary.policy.ApprovalSchemaBuilder.java

private void sortFragments(List<Fragment> fragments) {
    fragments.forEach(f -> {//from ww w .  j  ava  2  s .  c o m
        if (f.compositionStrategy != null && BooleanUtils.isTrue(f.compositionStrategy.isMergeable())
                && f.compositionStrategy.getOrder() == null) {
            throw new IllegalStateException("Mergeable composition strategy with no order: "
                    + f.compositionStrategy + " in " + f.policyRule);
        }
    });

    // relying on the fact that the sort algorithm is stable
    fragments.sort((f1, f2) -> {
        ApprovalCompositionStrategyType s1 = f1.compositionStrategy;
        ApprovalCompositionStrategyType s2 = f2.compositionStrategy;
        Integer o1 = s1 != null ? s1.getOrder() : null;
        Integer o2 = s2 != null ? s2.getOrder() : null;
        if (o1 == null || o2 == null) {
            return MiscUtil.compareNullLast(o1, o2);
        }
        int c = Integer.compare(o1, o2);
        if (c != 0) {
            return c;
        }
        // non-mergeable first
        boolean m1 = BooleanUtils.isTrue(s1.isMergeable());
        boolean m2 = BooleanUtils.isTrue(s2.isMergeable());
        if (m1 && !m2) {
            return 1;
        } else if (!m1 && m2) {
            return -1;
        } else {
            return 0;
        }
    });
}

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

/**
 * {@inheritDoc}//  w w  w .  ja va  2  s  .c om
 */
@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.haulmont.cuba.core.app.EntityDiffManager.java

protected EntityPropertyDiff getDynamicAttributeDifference(Object firstValue, Object secondValue,
        MetaProperty metaProperty, CategoryAttribute categoryAttribute) {
    Range range = metaProperty.getRange();
    if (range.isDatatype() || range.isEnum()) {
        if (!Objects.equals(firstValue, secondValue)) {
            return new EntityBasicPropertyDiff(firstValue, secondValue, metaProperty);
        }//from   www. ja  v  a 2s . co m
    } else if (range.isClass()) {
        if (BooleanUtils.isTrue(categoryAttribute.getIsCollection())) {
            return getDynamicAttributeCollectionDiff(firstValue, secondValue, metaProperty);
        } else {
            if (!Objects.equals(firstValue, secondValue)) {
                return new EntityClassPropertyDiff(firstValue, secondValue, metaProperty);
            }
        }
    }
    return null;
}