Example usage for java.lang Boolean equals

List of usage examples for java.lang Boolean equals

Introduction

In this page you can find the example usage for java.lang Boolean equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Returns true if and only if the argument is not null and is a Boolean object that represents the same boolean value as this object.

Usage

From source file:com.cloud.hypervisor.vmware.mo.HypervisorHostHelper.java

public static boolean isSpecMatch(DVPortgroupConfigInfo currentDvPortgroupInfo,
        DVPortgroupConfigSpec newDvPortGroupSpec) {
    String dvPortGroupName = newDvPortGroupSpec.getName();
    s_logger.debug("Checking if configuration of dvPortGroup [" + dvPortGroupName + "] has changed.");
    boolean specMatches = true;
    DVSTrafficShapingPolicy currentTrafficShapingPolicy;
    currentTrafficShapingPolicy = currentDvPortgroupInfo.getDefaultPortConfig().getInShapingPolicy();

    assert (currentTrafficShapingPolicy != null);

    LongPolicy oldAverageBandwidthPolicy = currentTrafficShapingPolicy.getAverageBandwidth();
    LongPolicy oldBurstSizePolicy = currentTrafficShapingPolicy.getBurstSize();
    LongPolicy oldPeakBandwidthPolicy = currentTrafficShapingPolicy.getPeakBandwidth();
    BoolPolicy oldIsEnabledPolicy = currentTrafficShapingPolicy.getEnabled();
    Long oldAverageBandwidth = null;
    Long oldBurstSize = null;/*from  w  w  w  .j  a v  a  2s.  com*/
    Long oldPeakBandwidth = null;
    Boolean oldIsEnabled = null;

    if (oldAverageBandwidthPolicy != null) {
        oldAverageBandwidth = oldAverageBandwidthPolicy.getValue();
    }
    if (oldBurstSizePolicy != null) {
        oldBurstSize = oldBurstSizePolicy.getValue();
    }
    if (oldPeakBandwidthPolicy != null) {
        oldPeakBandwidth = oldPeakBandwidthPolicy.getValue();
    }
    if (oldIsEnabledPolicy != null) {
        oldIsEnabled = oldIsEnabledPolicy.isValue();
    }

    DVSTrafficShapingPolicy newTrafficShapingPolicyInbound = newDvPortGroupSpec.getDefaultPortConfig()
            .getInShapingPolicy();
    LongPolicy newAverageBandwidthPolicy = newTrafficShapingPolicyInbound.getAverageBandwidth();
    LongPolicy newBurstSizePolicy = newTrafficShapingPolicyInbound.getBurstSize();
    LongPolicy newPeakBandwidthPolicy = newTrafficShapingPolicyInbound.getPeakBandwidth();
    BoolPolicy newIsEnabledPolicy = newTrafficShapingPolicyInbound.getEnabled();
    Long newAverageBandwidth = null;
    Long newBurstSize = null;
    Long newPeakBandwidth = null;
    Boolean newIsEnabled = null;
    if (newAverageBandwidthPolicy != null) {
        newAverageBandwidth = newAverageBandwidthPolicy.getValue();
    }
    if (newBurstSizePolicy != null) {
        newBurstSize = newBurstSizePolicy.getValue();
    }
    if (newPeakBandwidthPolicy != null) {
        newPeakBandwidth = newPeakBandwidthPolicy.getValue();
    }
    if (newIsEnabledPolicy != null) {
        newIsEnabled = newIsEnabledPolicy.isValue();
    }

    if (!oldIsEnabled.equals(newIsEnabled)) {
        s_logger.info("Detected change in state of shaping policy (enabled/disabled) [" + newIsEnabled + "]");
        specMatches = false;
    }

    if (oldIsEnabled || newIsEnabled) {
        if (oldAverageBandwidth != null && !oldAverageBandwidth.equals(newAverageBandwidth)) {
            s_logger.info(
                    "Average bandwidth setting in new shaping policy doesn't match the existing setting.");
            specMatches = false;
        } else if (oldBurstSize != null && !oldBurstSize.equals(newBurstSize)) {
            s_logger.info("Burst size setting in new shaping policy doesn't match the existing setting.");
            specMatches = false;
        } else if (oldPeakBandwidth != null && !oldPeakBandwidth.equals(newPeakBandwidth)) {
            s_logger.info("Peak bandwidth setting in new shaping policy doesn't match the existing setting.");
            specMatches = false;
        }
    }

    boolean oldAutoExpandSetting = currentDvPortgroupInfo.isAutoExpand();
    boolean autoExpandEnabled = newDvPortGroupSpec.isAutoExpand();
    if (oldAutoExpandSetting != autoExpandEnabled) {
        specMatches = false;
    }
    if (!autoExpandEnabled) {
        // Allow update of number of dvports per dvPortGroup is auto expand is not enabled.
        int oldNumPorts = currentDvPortgroupInfo.getNumPorts();
        int newNumPorts = newDvPortGroupSpec.getNumPorts();
        if (oldNumPorts < newNumPorts) {
            s_logger.info("Need to update the number of dvports for dvPortGroup :[" + dvPortGroupName
                    + "] from existing number of dvports " + oldNumPorts + " to " + newNumPorts);
            specMatches = false;
        } else if (oldNumPorts > newNumPorts) {
            s_logger.warn("Detected that new number of dvports [" + newNumPorts + "] in dvPortGroup ["
                    + dvPortGroupName + "] is less than existing number of dvports [" + oldNumPorts
                    + "]. Attempt to update this dvPortGroup may fail!");
            specMatches = false;
        }
    }

    VMwareDVSPortSetting currentPortSetting = ((VMwareDVSPortSetting) currentDvPortgroupInfo
            .getDefaultPortConfig());
    VMwareDVSPortSetting newPortSetting = ((VMwareDVSPortSetting) newDvPortGroupSpec.getDefaultPortConfig());
    if ((currentPortSetting.getSecurityPolicy() == null && newPortSetting.getSecurityPolicy() != null)
            || (currentPortSetting.getSecurityPolicy() != null && newPortSetting.getSecurityPolicy() == null)) {
        specMatches = false;
    }
    if (currentPortSetting.getSecurityPolicy() != null && newPortSetting.getSecurityPolicy() != null) {
        if (currentPortSetting.getSecurityPolicy().getAllowPromiscuous() != null
                && newPortSetting.getSecurityPolicy().getAllowPromiscuous() != null
                && newPortSetting.getSecurityPolicy().getAllowPromiscuous().isValue() != null
                && !newPortSetting.getSecurityPolicy().getAllowPromiscuous().isValue()
                        .equals(currentPortSetting.getSecurityPolicy().getAllowPromiscuous().isValue())) {
            specMatches = false;
        }
        if (currentPortSetting.getSecurityPolicy().getForgedTransmits() != null
                && newPortSetting.getSecurityPolicy().getForgedTransmits() != null
                && newPortSetting.getSecurityPolicy().getForgedTransmits().isValue() != null
                && !newPortSetting.getSecurityPolicy().getForgedTransmits().isValue()
                        .equals(currentPortSetting.getSecurityPolicy().getForgedTransmits().isValue())) {
            specMatches = false;
        }
        if (currentPortSetting.getSecurityPolicy().getMacChanges() != null
                && newPortSetting.getSecurityPolicy().getMacChanges() != null
                && newPortSetting.getSecurityPolicy().getMacChanges().isValue() != null
                && !newPortSetting.getSecurityPolicy().getMacChanges().isValue()
                        .equals(currentPortSetting.getSecurityPolicy().getMacChanges().isValue())) {
            specMatches = false;
        }
    }

    VmwareDistributedVirtualSwitchVlanSpec oldVlanSpec = currentPortSetting.getVlan();
    VmwareDistributedVirtualSwitchVlanSpec newVlanSpec = newPortSetting.getVlan();

    int oldVlanId, newVlanId;
    if (oldVlanSpec instanceof VmwareDistributedVirtualSwitchPvlanSpec
            && newVlanSpec instanceof VmwareDistributedVirtualSwitchPvlanSpec) {
        VmwareDistributedVirtualSwitchPvlanSpec oldpVlanSpec = (VmwareDistributedVirtualSwitchPvlanSpec) oldVlanSpec;
        VmwareDistributedVirtualSwitchPvlanSpec newpVlanSpec = (VmwareDistributedVirtualSwitchPvlanSpec) newVlanSpec;
        oldVlanId = oldpVlanSpec.getPvlanId();
        newVlanId = newpVlanSpec.getPvlanId();
    } else if (oldVlanSpec instanceof VmwareDistributedVirtualSwitchTrunkVlanSpec
            && newVlanSpec instanceof VmwareDistributedVirtualSwitchTrunkVlanSpec) {
        VmwareDistributedVirtualSwitchTrunkVlanSpec oldpVlanSpec = (VmwareDistributedVirtualSwitchTrunkVlanSpec) oldVlanSpec;
        VmwareDistributedVirtualSwitchTrunkVlanSpec newpVlanSpec = (VmwareDistributedVirtualSwitchTrunkVlanSpec) newVlanSpec;
        oldVlanId = oldpVlanSpec.getVlanId().get(0).getStart();
        newVlanId = newpVlanSpec.getVlanId().get(0).getStart();
    } else if (oldVlanSpec instanceof VmwareDistributedVirtualSwitchVlanIdSpec
            && newVlanSpec instanceof VmwareDistributedVirtualSwitchVlanIdSpec) {
        VmwareDistributedVirtualSwitchVlanIdSpec oldVlanIdSpec = (VmwareDistributedVirtualSwitchVlanIdSpec) oldVlanSpec;
        VmwareDistributedVirtualSwitchVlanIdSpec newVlanIdSpec = (VmwareDistributedVirtualSwitchVlanIdSpec) newVlanSpec;
        oldVlanId = oldVlanIdSpec.getVlanId();
        newVlanId = newVlanIdSpec.getVlanId();
    } else {
        s_logger.debug("Old and new vlan spec type mismatch found for [" + dvPortGroupName
                + "] has changed. Old spec type is: " + oldVlanSpec.getClass() + ", and new spec type is:"
                + newVlanSpec.getClass());
        return false;
    }

    if (oldVlanId != newVlanId) {
        s_logger.info("Detected that new VLAN [" + newVlanId + "] of dvPortGroup [" + dvPortGroupName
                + "] is different from current VLAN [" + oldVlanId + "]");
        specMatches = false;
    }

    return specMatches;
}

From source file:org.apache.hadoop.hbase.client.AsyncProcess.java

/**
 * Check if we should send new operations to this region or region server.
 * We're taking into account the past decision; if we have already accepted
 * operation on a given region, we accept all operations for this region.
 *
 * @param loc; the region and the server name we want to use.
 * @return true if this region is considered as busy.
 *//*from  w  w w.  jav a2  s . c om*/
protected boolean canTakeOperation(HRegionLocation loc, Map<Long, Boolean> regionsIncluded,
        Map<ServerName, Boolean> serversIncluded) {
    long regionId = loc.getRegionInfo().getRegionId();
    Boolean regionPrevious = regionsIncluded.get(regionId);

    if (regionPrevious != null) {
        // We already know what to do with this region.
        return regionPrevious;
    }

    Boolean serverPrevious = serversIncluded.get(loc.getServerName());
    if (Boolean.FALSE.equals(serverPrevious)) {
        // It's a new region, on a region server that we have already excluded.
        regionsIncluded.put(regionId, Boolean.FALSE);
        return false;
    }

    AtomicInteger regionCnt = taskCounterPerRegion.get(loc.getRegionInfo().getRegionName());
    if (regionCnt != null && regionCnt.get() >= maxConcurrentTasksPerRegion) {
        // Too many tasks on this region already.
        regionsIncluded.put(regionId, Boolean.FALSE);
        return false;
    }

    if (serverPrevious == null) {
        // The region is ok, but we need to decide for this region server.
        int newServers = 0; // number of servers we're going to contact so far
        for (Map.Entry<ServerName, Boolean> kv : serversIncluded.entrySet()) {
            if (kv.getValue()) {
                newServers++;
            }
        }

        // Do we have too many total tasks already?
        boolean ok = (newServers + tasksInProgress.get()) < maxTotalConcurrentTasks;

        if (ok) {
            // If the total is fine, is it ok for this individual server?
            AtomicInteger serverCnt = taskCounterPerServer.get(loc.getServerName());
            ok = (serverCnt == null || serverCnt.get() < maxConcurrentTasksPerServer);
        }

        if (!ok) {
            regionsIncluded.put(regionId, Boolean.FALSE);
            serversIncluded.put(loc.getServerName(), Boolean.FALSE);
            return false;
        }

        serversIncluded.put(loc.getServerName(), Boolean.TRUE);
    } else {
        assert serverPrevious.equals(Boolean.TRUE);
    }

    regionsIncluded.put(regionId, Boolean.TRUE);

    return true;
}

From source file:edu.lternet.pasta.datapackagemanager.DataPackageManager.java

private Integer getNextReservableIdentifier(String scope) throws Exception {
    Integer nextReservable = null;
    final Boolean isSpokenFor = new Boolean(true);
    DataPackageRegistry dataPackageRegistry = new DataPackageRegistry(dbDriver, dbURL, dbUser, dbPassword);

    HashMap<Integer, Boolean> spokenFor = new HashMap<Integer, Boolean>();

    /*/*from  www .j  a v  a 2  s .c  o m*/
     * First get a list of all known identifiers for this scope that exist
     * in the resource registry. Include identifiers for data packages that
     * were deleted since these identifier values can't be reused.
     */
    boolean includeDeleted = true;
    ArrayList<String> identifierList = dataPackageRegistry.listDataPackageIdentifiers(scope, includeDeleted);

    for (String identifier : identifierList) {
        Integer spokenForIdentifier = Integer.parseInt(identifier);
        spokenFor.put(spokenForIdentifier, isSpokenFor);
    }

    /*
     * Next get a list of all known identifiers for this scope that are
     * actively being worked on (i.e. an upload operation for this
     * identifier is actively in progress).
     */
    ArrayList<Integer> identifiers = dataPackageRegistry.listWorkingOnIdentifiers(scope);

    for (Integer identifier : identifiers) {
        spokenFor.put(identifier, isSpokenFor);
    }

    /*
     * Finally, get a list of all active reservations for this scope.
     */
    String reservationString = dataPackageRegistry.listReservationIdentifiers(scope);
    String[] reservationEntries = reservationString.split("\n");
    if (reservationEntries != null && reservationEntries.length > 0) {
        for (String reservedIdentifier : reservationEntries) {
            Integer spokenForIdentifier = Integer.parseInt(reservedIdentifier);
            spokenFor.put(spokenForIdentifier, isSpokenFor);
        }
    }

    /*
     * Now find the first available identifier value that isn't claimed by
     * one of the three previous lists.
     */
    Integer nextCandidate = new Integer(1);
    while (nextReservable == null) {
        Boolean value = spokenFor.get(nextCandidate);
        if (value != null && value.equals(isSpokenFor)) {
            nextCandidate = nextCandidate + 1;
        } else {
            nextReservable = nextCandidate;
        }
    }

    return nextReservable;
}

From source file:org.openbravo.erpCommon.ad_forms.ModuleManagement.java

@SuppressWarnings("unchecked")
private void printPageSettings(HttpServletResponse response, HttpServletRequest request)
        throws ServletException, IOException {
    VariablesSecureApp vars = new VariablesSecureApp(request);

    boolean activeInstance = ActivationKey.getInstance().isActive();

    // Possible maturity levels are obtained from CR, obtain them once per session and store
    MaturityLevel levels = (MaturityLevel) vars.getSessionObject("SettingsModule|MaturityLevels");
    if (levels == null) {
        levels = new MaturityLevel();
        if (!levels.hasInternetError()) {
            vars.setSessionObject("SettingsModule|MaturityLevels", levels);
        }/*from  w w w. ja  va  2  s.co m*/
    }
    String discard[] = { "", "" };
    OBError myMessage = null;

    try {
        OBContext.setAdminMode();
        SystemInformation sysInfo = OBDal.getInstance().get(SystemInformation.class, "0");

        if (vars.commandIn("SETTINGS_ADD", "SETTINGS_REMOVE")) {
            String moduleId;

            if (vars.commandIn("SETTINGS_ADD")) {
                moduleId = vars.getStringParameter("inpModule", IsIDFilter.instance);
            } else {
                moduleId = vars.getStringParameter("inpModuleId", IsIDFilter.instance);
            }

            org.openbravo.model.ad.module.Module mod = OBDal.getInstance()
                    .get(org.openbravo.model.ad.module.Module.class, moduleId);
            if (mod != null) {
                // do not update the audit info here, as its a local config change, which should not be
                // treated as 'local changes' by i.e. update.database
                try {
                    boolean warn = false;
                    OBInterceptor.setPreventUpdateInfoChange(true);
                    if (vars.commandIn("SETTINGS_ADD")) {
                        // GA is not allowed for community instances
                        int level = Integer.parseInt(vars.getNumericParameter("inpModuleLevel"));
                        if (!activeInstance && level >= MaturityLevel.CS_MATURITY) {
                            myMessage = OBErrorBuilder.buildMessage(myMessage, "Warning",
                                    Utility.messageBD(this, "OBUIAPP_GAinCommunity", vars.getLanguage())
                                            .replace("%0", levels.getLevelName(Integer.toString(level))));

                            warn = true;
                        } else {
                            mod.setMaturityUpdate(Integer.toString(level));
                        }

                    } else {
                        mod.setMaturityUpdate(null);
                    }
                    OBDal.getInstance().flush();
                    OBDal.getInstance().commitAndClose();

                    // clean module updates if there are any
                    if (!warn) {
                        boolean isCleaned = cleanModulesUpdates();
                        if (isCleaned) {
                            myMessage = OBErrorBuilder.buildMessage(myMessage, "Info",
                                    Utility.messageBD(this, "ModuleUpdatesRemoved", vars.getLanguage()));
                        }
                        myMessage = OBErrorBuilder.buildMessage(myMessage, "Success",
                                Utility.messageBD(this, "ModuleManagementSettingSaved", vars.getLanguage()));
                    }
                } finally {
                    OBInterceptor.setPreventUpdateInfoChange(false);
                }
            } else {
                log4j.error("Module does not exists ID:" + moduleId);
            }
        } else if (vars.commandIn("SETTINGS_SAVE")) {

            boolean warn = false;

            // Save global maturity levels. GA is not allowed for community instances
            String maturityWarnMsg = "";
            try {
                int maturitySearch = Integer.parseInt(vars.getNumericParameter("inpSearchLevel"));
                if (!activeInstance && maturitySearch >= MaturityLevel.CS_MATURITY) {
                    maturityWarnMsg = Utility.messageBD(this, "OBUIAPP_GAinCommunity", vars.getLanguage())
                            .replace("%0", levels.getLevelName(Integer.toString(maturitySearch)));
                    warn = true;
                } else {
                    sysInfo.setMaturitySearch(Integer.toString(maturitySearch));
                }

                int maturityScan = Integer.parseInt(vars.getNumericParameter("inpScanLevel"));
                if (!activeInstance && maturityScan >= MaturityLevel.CS_MATURITY) {
                    if (maturityWarnMsg.isEmpty()) {
                        maturityWarnMsg += Utility.messageBD(this, "OBUIAPP_GAinCommunity", vars.getLanguage())
                                .replace("%0", levels.getLevelName(Integer.toString(maturityScan)));
                    }
                    warn = true;
                } else {
                    sysInfo.setMaturityUpdate(Integer.toString(maturityScan));
                }
            } catch (Exception e) {
                log4j.error("Error reading maturity search", e);
            }

            // Save enforcement
            String warnMsg = "";
            for (Enumeration<String> e = request.getParameterNames(); e.hasMoreElements();) {
                String parameter = e.nextElement();
                if (parameter.startsWith("inpEnforcement")) {
                    String depId = parameter.replace("inpEnforcement", "");
                    String value = vars.getStringParameter(parameter);
                    org.openbravo.model.ad.module.ModuleDependency dep = OBDal.getInstance()
                            .get(org.openbravo.model.ad.module.ModuleDependency.class, depId);
                    if (dep != null) {
                        boolean save = true;
                        if ("MINOR".equals(value)) {
                            // Setting Minor version enforcement, check the configuration is still valid
                            VersionComparator vc = new VersionComparator();
                            if (dep.getLastVersion() == null && vc.compare(dep.getFirstVersion(),
                                    dep.getDependentModule().getVersion()) != 0) {
                                save = false;
                                warn = true;
                                warnMsg += "<br/>" + Utility
                                        .messageBD(this, "ModuleDependsButInstalled", vars.getLanguage())
                                        .replace("@module@", dep.getDependentModule().getName())
                                        .replace("@version@", dep.getFirstVersion())
                                        .replace("@installed@", dep.getDependentModule().getVersion());
                            } else if (dep.getLastVersion() != null && !(vc.compare(dep.getFirstVersion(),
                                    dep.getDependentModule().getVersion()) <= 0
                                    && vc.compare(dep.getLastVersion(),
                                            dep.getDependentModule().getVersion()) >= 0)) {
                                save = false;
                                warn = true;
                                warnMsg += "<br/>" + Utility
                                        .messageBD(this, "ModuleDependsButInstalled", vars.getLanguage())
                                        .replace("@module@", dep.getDependentModule().getName())
                                        .replace("@version@",
                                                dep.getFirstVersion() + " - " + dep.getLastVersion())
                                        .replace("@installed@", dep.getDependentModule().getVersion());
                            }
                        }
                        if (save) {
                            if (value.equals(dep.getDependencyEnforcement())) {
                                // setting no instance enforcement in case the selected value is the default
                                dep.setInstanceEnforcement(null);
                            } else {
                                dep.setInstanceEnforcement(value);
                            }
                        }
                    }
                }
            }

            // clean module updates if there are any
            final boolean isCleaned = cleanModulesUpdates();
            if (isCleaned) {
                myMessage = OBErrorBuilder.buildMessage(myMessage, "Info",
                        Utility.messageBD(this, "ModuleUpdatesRemoved", vars.getLanguage()));
            }

            if (warn) {
                String msgBody = "";
                if (!maturityWarnMsg.isEmpty()) {
                    msgBody += maturityWarnMsg;
                }

                if (!warnMsg.isEmpty()) {
                    msgBody += "<br/>"
                            + Utility.messageBD(this, "CannotSetMinorEnforcements", vars.getLanguage())
                            + warnMsg;
                }

                myMessage = OBErrorBuilder.buildMessage(myMessage, "Warning", msgBody);
            } else {
                myMessage = OBErrorBuilder.buildMessage(myMessage, "Success",
                        Utility.messageBD(this, "ModuleManagementSettingSaved", vars.getLanguage()));
            }
        }

        // Populate module specific grid
        OBCriteria<org.openbravo.model.ad.module.Module> qModuleSpecific = OBDal.getInstance()
                .createCriteria(org.openbravo.model.ad.module.Module.class);
        qModuleSpecific
                .add(Restrictions.isNotNull(org.openbravo.model.ad.module.Module.PROPERTY_MATURITYUPDATE));
        qModuleSpecific.addOrder(Order.asc(org.openbravo.model.ad.module.Module.PROPERTY_NAME));
        ArrayList<HashMap<String, String>> moduleSpecifics = new ArrayList<HashMap<String, String>>();
        List<org.openbravo.model.ad.module.Module> moduleSpecificList = qModuleSpecific.list();
        if (moduleSpecificList.isEmpty()) {
            discard[0] = "moduleTable";
        }
        for (org.openbravo.model.ad.module.Module module : moduleSpecificList) {
            HashMap<String, String> m = new HashMap<String, String>();
            m.put("id", module.getId());
            m.put("name", module.getName());

            if (!activeInstance && Integer.parseInt(module.getMaturityUpdate()) >= MaturityLevel.CS_MATURITY) {
                m.put("level", levels.getLevelName(Integer.toString(MaturityLevel.QA_APPR_MATURITY)));
            } else {
                m.put("level", levels.getLevelName(module.getMaturityUpdate()));
            }
            moduleSpecifics.add(m);
        }

        // Populate combo of modules without specific setting
        OBCriteria<org.openbravo.model.ad.module.Module> qModule = OBDal.getInstance()
                .createCriteria(org.openbravo.model.ad.module.Module.class);
        qModule.add(Restrictions.isNull(org.openbravo.model.ad.module.Module.PROPERTY_MATURITYUPDATE));
        qModule.addOrder(Order.asc(org.openbravo.model.ad.module.Module.PROPERTY_NAME));

        ArrayList<HashMap<String, String>> modules = new ArrayList<HashMap<String, String>>();
        List<org.openbravo.model.ad.module.Module> moduleList = qModule.list();
        if (moduleList.isEmpty()) {
            discard[0] = "assignModule";
        }
        for (org.openbravo.model.ad.module.Module module : moduleList) {
            HashMap<String, String> m = new HashMap<String, String>();
            m.put("id", module.getId());
            m.put("name", module.getName());
            modules.add(m);
        }

        // Dependencies table
        OBCriteria<org.openbravo.model.ad.module.ModuleDependency> qDeps = OBDal.getInstance()
                .createCriteria(org.openbravo.model.ad.module.ModuleDependency.class);
        qDeps.add(Restrictions
                .eq(org.openbravo.model.ad.module.ModuleDependency.PROPERTY_USEREDITABLEENFORCEMENT, true));
        qDeps.addOrder(Order.asc(org.openbravo.model.ad.module.ModuleDependency.PROPERTY_MODULE));
        qDeps.addOrder(Order.asc(org.openbravo.model.ad.module.ModuleDependency.PROPERTY_ISINCLUDED));
        qDeps.addOrder(Order.asc(org.openbravo.model.ad.module.ModuleDependency.PROPERTY_DEPENDANTMODULENAME));
        List<org.openbravo.model.ad.module.ModuleDependency> deps = qDeps.list();

        if (deps.isEmpty()) {
            discard[1] = "enforcementTable";
        } else {
            discard[1] = "noEditableEnforcement";
        }

        FieldProvider fpDeps[] = new FieldProvider[deps.size()];
        FieldProvider fpEnforcements[][] = new FieldProvider[deps.size()][];
        int i = 0;
        String lastName = "";
        Boolean lastType = null;

        // Get the static text values once, not to query db each time for them
        OBCriteria<org.openbravo.model.ad.domain.List> qList = OBDal.getInstance()
                .createCriteria(org.openbravo.model.ad.domain.List.class);
        qList.add(Restrictions.eq(org.openbravo.model.ad.domain.List.PROPERTY_REFERENCE + ".id",
                "8BA0A3775CE14CE69989B6C09982FB2E"));
        qList.addOrder(Order.asc(org.openbravo.model.ad.domain.List.PROPERTY_SEQUENCENUMBER));
        SQLReturnObject[] fpEnforcementCombo = new SQLReturnObject[qList.list().size()];
        for (org.openbravo.model.ad.domain.List value : qList.list()) {
            SQLReturnObject val = new SQLReturnObject();
            val.setData("ID", value.getSearchKey());
            val.setData("NAME", Utility.getListValueName("Dependency Enforcement", value.getSearchKey(),
                    vars.getLanguage()));
            fpEnforcementCombo[i] = val;
            i++;
        }
        String inclusionType = Utility.messageBD(this, "InclusionType", vars.getLanguage());
        String dependencyType = Utility.messageBD(this, "DependencyType", vars.getLanguage());
        String defaultStr = Utility.messageBD(this, "Default", vars.getLanguage());

        i = 0;
        for (org.openbravo.model.ad.module.ModuleDependency dep : deps) {
            HashMap<String, String> d = new HashMap<String, String>();

            d.put("baseModule", dep.getDependentModule().getName());
            d.put("currentVersion", dep.getDependentModule().getVersion());
            d.put("firstVersion", dep.getFirstVersion());
            d.put("lastVersion", dep.getLastVersion());
            d.put("depId", dep.getId());

            // Grouping by module and dependency
            String currentName = dep.getModule().getName();
            Boolean currentType = dep.isIncluded();
            if (lastName.equals(currentName)) {
                d.put("modName", "");
                if (!currentType.equals(lastType)) {
                    d.put("depType", dep.isIncluded() ? inclusionType : dependencyType);
                } else {
                    d.put("depType", "");
                }
            } else {
                d.put("modName", currentName);
                d.put("depType", dep.isIncluded() ? inclusionType : dependencyType);
                lastName = currentName;
                lastType = currentType;
            }

            d.put("selectedEnforcement", dep.getInstanceEnforcement() == null ? dep.getDependencyEnforcement()
                    : dep.getInstanceEnforcement());
            fpDeps[i] = FieldProviderFactory.getFieldProvider(d);
            fpEnforcements[i] = getEnforcementCombo(dep, fpEnforcementCombo, defaultStr);
            i++;
        }

        final XmlDocument xmlDocument = xmlEngine
                .readXmlTemplate("org/openbravo/erpCommon/ad_forms/ModuleManagementSettings", discard)
                .createXmlDocument();

        xmlDocument.setData("moduleDetail", FieldProviderFactory.getFieldProviderArray(moduleSpecifics));
        xmlDocument.setData("moduleCombo", FieldProviderFactory.getFieldProviderArray(modules));

        // Populate maturity levels combos
        String selectedScanLevel;
        String selectedSearchLevel;

        if (activeInstance) {
            selectedScanLevel = sysInfo.getMaturityUpdate() == null
                    ? Integer.toString(MaturityLevel.CS_MATURITY)
                    : sysInfo.getMaturityUpdate();
            selectedSearchLevel = sysInfo.getMaturitySearch() == null
                    ? Integer.toString(MaturityLevel.CS_MATURITY)
                    : sysInfo.getMaturitySearch();
        } else {
            // Community instances cannot use GA, setting CR if it is used
            int actualScanLevel = sysInfo.getMaturityUpdate() == null ? MaturityLevel.QA_APPR_MATURITY
                    : Integer.parseInt(sysInfo.getMaturityUpdate());
            int actualSearchLevel = sysInfo.getMaturitySearch() == null ? MaturityLevel.QA_APPR_MATURITY
                    : Integer.parseInt(sysInfo.getMaturitySearch());

            if (actualScanLevel >= MaturityLevel.CS_MATURITY) {
                actualScanLevel = MaturityLevel.QA_APPR_MATURITY;
            }
            if (actualSearchLevel >= MaturityLevel.CS_MATURITY) {
                actualSearchLevel = MaturityLevel.QA_APPR_MATURITY;
            }
            selectedScanLevel = Integer.toString(actualScanLevel);
            selectedSearchLevel = Integer.toString(actualSearchLevel);
        }

        xmlDocument.setParameter("selectedScanLevel", selectedScanLevel);
        xmlDocument.setData("reportScanLevel", "liststructure", levels.getCombo());
        xmlDocument.setParameter("selectedSearchLevel", selectedSearchLevel);
        xmlDocument.setData("reportSearchLevel", "liststructure", levels.getCombo());
        xmlDocument.setData("reportModuleLevel", "liststructure", levels.getCombo());

        // less and most mature values
        xmlDocument.setParameter("lessMature", levels.getLessMature());
        xmlDocument.setParameter("mostMature", levels.getMostMature());

        response.setContentType("text/html; charset=UTF-8");
        final PrintWriter out = response.getWriter();
        xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n");
        xmlDocument.setParameter("language", "defaultLang=\"" + vars.getLanguage() + "\";");

        xmlDocument.setData("dependencyDetail", fpDeps);
        xmlDocument.setDataArray("reportEnforcementType", "liststructure", fpEnforcements);

        // Interface parameters
        final ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "ModuleManagement", false, "", "", "",
                false, "ad_forms", strReplaceWith, false, true);
        toolbar.prepareSimpleToolBarTemplate();
        xmlDocument.setParameter("toolbar", toolbar.toString());

        try {
            final WindowTabs tabs = new WindowTabs(this, vars,
                    "org.openbravo.erpCommon.ad_forms.ModuleManagement");
            xmlDocument.setParameter("theme", vars.getTheme());
            final NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "ModuleManagement.html",
                    classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb());
            xmlDocument.setParameter("navigationBar", nav.toString());
            final LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "ModuleManagement.html",
                    strReplaceWith);
            xmlDocument.setParameter("leftTabs", lBar.manualTemplate());
        } catch (final Exception ex) {
            throw new ServletException(ex);
        }

        if (myMessage != null) {
            xmlDocument.setParameter("messageType", myMessage.getType());
            xmlDocument.setParameter("messageTitle", myMessage.getTitle());
            xmlDocument.setParameter("messageMessage", myMessage.getMessage());
        }

        out.println(xmlDocument.print());
        out.close();
    } finally {
        OBContext.restorePreviousMode();
    }
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.teacher.StudentGroupManagementDA.java

public ActionForward deleteGroupProperties(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws FenixActionException {

    ActionMessages actionErrors = new ActionMessages();

    String objectCode = getExecutionCourse(request).getExternalId();

    String groupPropertiesCode = null;
    try {//from  www  . ja  v a 2  s  .  c om
        String groupPropertiesCodeString = request.getParameter("groupPropertiesCode");
        groupPropertiesCode = groupPropertiesCodeString;
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        actionErrors.add("errors.delete.groupPropertie", new ActionMessage(e.getMessage()));
        saveErrors(request, actionErrors);

        return prepareViewExecutionCourseProjects(mapping, form, request, response);
    }

    Boolean result = Boolean.FALSE;
    try {
        result = DeleteGrouping.runDeleteGrouping(objectCode, groupPropertiesCode);
    } catch (ExistingServiceException e) {
        ActionMessages actionErrors1 = new ActionMessages();
        ActionMessage error = null;
        error = new ActionMessage("error.noGroupProperties");
        actionErrors1.add("error.noGroupProperties", error);
        saveErrors(request, actionErrors1);
        return prepareViewExecutionCourseProjects(mapping, form, request, response);
    } catch (InvalidSituationServiceException e) {
        ActionMessages actionErrors2 = new ActionMessages();
        ActionMessage error = null;
        error = new ActionMessage("error.groupProperties.delete.attendsSet.withGroups");
        actionErrors2.add("error.groupProperties.delete.attendsSet.withGroups", error);
        saveErrors(request, actionErrors2);
        return viewShiftsAndGroups(mapping, form, request, response);
    } catch (FenixServiceException e) {
        logger.error(e.getMessage(), e);
        throw new FenixActionException(e.getMessage());
    }
    if (result.equals(Boolean.FALSE)) {
        actionErrors.add("errors.delete.groupPropertie", new ActionMessage("error.groupProperties.delete"));
        saveErrors(request, actionErrors);

        return prepareViewExecutionCourseProjects(mapping, form, request, response);
    }

    return prepareViewExecutionCourseProjects(mapping, form, request, response);
}

From source file:org.geoserver.security.GeoServerSecurityManager.java

/**
 * Loads all the password encoders that match the specified criteria.
 * //from ww w.  ja v  a 2  s .c  om
 * @param filter Class used to filter password encoders.
 * @param config Flag indicating if a reversible encoder is required, true forces reversible, 
 *  false forces irreversible, null means either.
 * @param strong Flag indicating if an encoder that supports strong encryption is required, true 
 *  forces strong encryption, false forces weak encryption, null means either.
 *  
 * @return All matching encoders, or an empty list.
 */
public <T extends GeoServerPasswordEncoder> List<T> loadPasswordEncoders(Class<T> filter, Boolean reversible,
        Boolean strong) {

    filter = (Class<T>) (filter != null ? filter : GeoServerPasswordEncoder.class);

    List list = GeoServerExtensions.extensions(filter);
    for (Iterator it = list.iterator(); it.hasNext();) {
        boolean remove = false;
        T pw = (T) it.next();
        if (reversible != null && !reversible.equals(pw.isReversible())) {
            remove = true;
        }
        if (!remove && strong != null && strong.equals(pw.isAvailableWithoutStrongCryptogaphy())) {
            remove = true;
        }

        if (remove) {
            it.remove();
        } else {
            try {
                pw.initialize(this);
            } catch (IOException e) {
                LOGGER.log(Level.WARNING, "Error initializing password encoder " + pw.getName() + ", skipping",
                        e);
                it.remove();
            }
        }
    }
    return list;
}

From source file:com.gtwm.pb.model.manageData.DataManagement.java

public SortedSet<CommentInfo> getComments(BaseField field, int rowId) throws SQLException, CantDoThatException {
    SortedSet<CommentInfo> comments = new TreeSet<CommentInfo>();
    Boolean hasComments = field.hasComments();
    if (hasComments != null) {
        if (hasComments.equals(false)) {
            return comments;
        }/* ww w  . j  a  va  2  s.c  o m*/
    }
    String sqlCode = "SELECT created, author, text FROM dbint_comments WHERE internalfieldname=? AND rowid=? order by created desc limit 10";
    Connection conn = null;
    try {
        conn = this.dataSource.getConnection();
        conn.setAutoCommit(false);
        PreparedStatement statement = conn.prepareStatement(sqlCode);
        String internalFieldName = field.getInternalFieldName();
        statement.setString(1, internalFieldName);
        statement.setInt(2, rowId);
        ResultSet results = statement.executeQuery();
        while (results.next()) {
            Timestamp createdTimestamp = results.getTimestamp(1);
            Calendar created = Calendar.getInstance();
            created.setTimeInMillis(createdTimestamp.getTime());
            String author = results.getString(2);
            String comment = results.getString(3);
            comments.add(new Comment(internalFieldName, rowId, author, created, comment));
        }
        results.close();
        statement.close();
        if (comments.size() > 0) {
            field.setHasComments(true);
        } else if (hasComments == null) {
            // We've seen there are no comments for this particular record
            // but we don't know if there are any for the field in other
            // records. Check.
            sqlCode = "SELECT count(*) from dbint_comments WHERE internalfieldname=?";
            statement = conn.prepareStatement(sqlCode);
            statement.setString(1, internalFieldName);
            results = statement.executeQuery();
            if (results.next()) {
                int numComments = results.getInt(1);
                if (numComments > 0) {
                    field.setHasComments(true);
                } else {
                    // Another check in case another thread e.g. running
                    // addComment has set this to true.
                    // We don't want to overwrite that
                    // TODO: Really, this should be atomic but it takes such
                    // a small amount of time compared to the SQL it's
                    // probably fine
                    if (field.hasComments() == null) {
                        field.setHasComments(false);
                    }
                }
            } else {
                logger.error("Unable to see if comments exist with query " + statement);
            }
            results.close();
            statement.close();
        }
    } finally {
        if (conn != null) {
            conn.close();
        }
    }
    return comments;
}

From source file:gov.nih.nci.evs.browser.utils.DataUtils.java

public static Vector<String> getVersionListData(String codingSchemeName) {

    Vector<String> v = new Vector();
    try {//  w  w w.j ava 2s. c om
        // RemoteServerUtil rsu = new RemoteServerUtil();
        // EVSApplicationService lbSvc = rsu.createLexBIGService();
        LexBIGService lbSvc = RemoteServerUtil.createLexBIGService();
        CodingSchemeRenderingList csrl = lbSvc.getSupportedCodingSchemes();
        if (csrl == null) {
            _logger.warn("csrl is NULL");
            return null;
        }

        CodingSchemeRendering[] csrs = csrl.getCodingSchemeRendering();
        for (int i = 0; i < csrs.length; i++) {
            CodingSchemeRendering csr = csrs[i];
            Boolean isActive = csr.getRenderingDetail().getVersionStatus()
                    .equals(CodingSchemeVersionStatus.ACTIVE);
            if (isActive != null && isActive.equals(Boolean.TRUE)) {
                CodingSchemeSummary css = csr.getCodingSchemeSummary();
                String formalname = css.getFormalName();
                if (formalname.compareTo(codingSchemeName) == 0) {
                    String representsVersion = css.getRepresentsVersion();
                    v.add(representsVersion);
                }
            }
        }
    } catch (Exception ex) {

    }
    return v;
}

From source file:mondrian.test.SchemaTest.java

public void testVirtualCubesVisibility() throws Exception {
    for (Boolean testValue : new Boolean[] { true, false }) {
        String cubeDef = "<VirtualCube name=\"Foo\" defaultMeasure=\"Store Sales\" visible=\"@REPLACE_ME@\">\n"
                + "  <VirtualCubeDimension cubeName=\"Sales\" name=\"Customers\"/>\n"
                + "  <VirtualCubeMeasure cubeName=\"Sales\" name=\"[Measures].[Store Sales]\"/>\n"
                + "</VirtualCube>\n";
        cubeDef = cubeDef.replace("@REPLACE_ME@", String.valueOf(testValue));
        final TestContext context = TestContext.instance().create(null, null, cubeDef, null, null, null);
        final Cube cube = context.getConnection().getSchema().lookupCube("Foo", true);
        assertTrue(testValue.equals(cube.isVisible()));
    }//from   w w w . java2  s. com
}

From source file:gov.nih.nci.evs.browser.servlet.AjaxServlet.java

public static void initializeNodeCheckState(PrintWriter out, Boolean value_set_tab) {
    out.println("   function initializeNodeCheckState(nodes) {");
    out.println("       nodes = nodes || tree.getRoot().children;");
    out.println("       var checkedNodes = document.forms[\"hidden_form\"].checkedNodes.value;");
    out.println("       var partialCheckedNodes = document.forms[\"hidden_form\"].partialCheckedNodes.value;");
    out.println("       for(var i=0, l=nodes.length; i<l; i=i+1) {");
    out.println("            var n = nodes[i];");
    out.println("");

    if (value_set_tab.equals(Boolean.TRUE)) {
        out.println("            if (checkedNodes.indexOf(n.label) != -1) {");
        out.println("                n.setCheckState(2);");
        out.println("            } else if (partialCheckedNodes.indexOf(n.label) != -1) {");
        out.println("                n.setCheckState(1);");
        out.println("            }");
    } else {//from  w w w .  ja  v a  2 s .c  om
        out.println("                n.setCheckState(2);");
    }

    out.println("");
    out.println("            if (n.hasChildren()) {");
    out.println("              initializeNodeCheckState(n.children);");
    out.println("            }");
    out.println("        }");
    out.println("   }");
}