Example usage for org.apache.commons.lang ArrayUtils contains

List of usage examples for org.apache.commons.lang ArrayUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils contains.

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:net.di2e.ecdr.commons.endpoint.rest.AbstractRestSearchEndpoint.java

protected boolean isUniqueQuery(MultivaluedMap<String, String> queryParameters, String sourceId) {
    boolean isUniqueQuery = true;
    String oid = queryParameters.getFirst(SearchConstants.OID_PARAMETER);

    if (StringUtils.isNotBlank(oid)) {
        isUniqueQuery = queryRequestCache.isQueryIdUnique(oid);
    } else {//from  w w  w  .ja v  a  2s  . com
        String uuid = UUID.randomUUID().toString();
        queryParameters.putSingle(SearchConstants.OID_PARAMETER, uuid);
        queryRequestCache.add(uuid);
    }

    String path = queryParameters.getFirst(SearchConstants.PATH_PARAMETER);
    if (StringUtils.isNotBlank(path)) {
        String[] pathValues = path.split(",");
        if (ArrayUtils.contains(pathValues, sourceId)) {
            isUniqueQuery = false;
            LOGGER.debug("The '{}' with value '{}' contains the local source id {}",
                    SearchConstants.PATH_PARAMETER, path, sourceId);
        }
    } else {
        queryParameters.putSingle(SearchConstants.PATH_PARAMETER, catalogFramework.getId());
    }
    return isUniqueQuery;
}

From source file:com.cartmatic.estore.common.helper.ConfigUtil.java

public void setSystemMode(String systemMode) {
    Assert.isTrue(ArrayUtils.contains(supportedSystemModes, systemMode),
            "System mode [" + systemMode + "] is not supported.");
    this.systemMode = systemMode;
    logger.info("Using system mode:" + this.systemMode);
}

From source file:eu.europeana.portal2.web.presentation.model.FullDocPage.java

public String getShownAtProvider() {
    if (isHasDataProvider() && !ArrayUtils.contains(shownAtProviderOverride, getCollectionId())) {
        return getDocument().getEdmDataProvider()[0];
    }//  w  ww  . ja  va 2  s  . com
    return StringUtils.defaultIfBlank(getShortcutFirstValue("EdmProvider"), "");
}

From source file:com.topsec.tsm.sim.sysconfig.web.SystemConfigController.java

/**
 * ??/*from  ww  w.j a v a 2s .c o m*/
 * @param conf
 * @param pathInfo
 * @param result
 * @return
 */
private boolean storePathAvailable(String[] oldArchivePathList, Config conf, Map<String, Object> pathInfo,
        Result result) {
    try {
        String pathListString = (String) pathInfo.get("archive_path_list");
        String[] pathList = StringUtil.split(pathListString, ";");
        int override = StringUtil.toInt(pathInfo.get("override").toString());
        if (override > 95 || override < 11) {
            result.buildError("?11%-95%");
            return false;
        }
        int alarmThreshold = StringUtil.toInt(pathInfo.get("alert").toString());
        if (alarmThreshold > 94 || alarmThreshold < 10) {
            result.buildError("??10%-94%");
            return false;
        }
        int usePercent = getDiskUsePercent(pathList);
        if (alarmThreshold <= usePercent) {
            result.buildError("??" + usePercent
                    + "%,???");
            return false;
        }
        try {
            Node auditorNode = nodeMgrFacade.getKernelAuditor(false);
            StorePath[] pathDetailInfo = (StorePath[]) NodeUtil.dispatchCommand(NodeUtil.getRoute(auditorNode),
                    MessageDefinition.CMD_QUERY_PATH_INFO, pathList, 60 * 1000);
            //<partition,path>
            Map<String, String> partitionMap = new HashMap<String, String>();
            //???10G???
            long partitionMinSpace = 10;
            for (int i = 0; i < pathDetailInfo.length; i++) {
                StorePath info = pathDetailInfo[i];
                if (info == null) {
                    result.buildError(pathList[i] + "???");
                    return false;
                }
                //??
                if (!ArrayUtils.contains(oldArchivePathList, info.getPath())
                        && info.getUsage().availableGB() < partitionMinSpace) {
                    result.buildError("{}?{}G", info.getPath(), partitionMinSpace);
                    return false;
                }
                if (partitionMap.containsKey(info.getPartition())) {//???
                    result.buildError("{}{}???", info.getPath(),
                            partitionMap.get(info.getPartition()));
                    return false;
                }
                partitionMap.put(info.getPartition(), info.getPath());
            }
        } catch (Exception e) {
            result.buildError("?!");
            return false;
        }
        Response response = eventResponseService.getResponsesByNodeIdAndCofingKey(NodeDefinition.NODE_TYPE_SMP,
                "sys_cfg_backup");
        if (response != null) {
            Config backupConfig = RespCfgHelper.getConfig(response);
            if (backupPartitionInStorePartition(backupConfig, conf)) {
                result.buildError("????");
                return false;
            }
        }
    } catch (CommunicationException e) {
        result.buildError("?!");
        return false;
    } catch (Exception e) {
        result.buildError("??");
        return false;
    }
    return true;
}

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

/**
 * Gets the fields by applicability./*from  ww  w. ja v a 2  s . c o m*/
 *
 * @param mandatoryTypes the mandatory types
 * @return the fields by applicability
 */
@Transient
public List<ReportMandatoryField> getFieldsByApplicability(final Mandatory... mandatoryTypes) {
    ArrayList<ReportMandatoryField> reportMandatoryFields = new ArrayList<ReportMandatoryField>();
    for (ReportMandatoryField mf : getMandatoryFields()) {
        if (ArrayUtils.contains(mandatoryTypes, mf.getMandatory())) {
            reportMandatoryFields.add(mf);
        }
    }
    return reportMandatoryFields;
}

From source file:com.cartmatic.estore.common.helper.ConfigUtil.java

public String[] getBulkProdCommAttrs() {
    String temp[] = this.getConfig("BulkProdCommAttrs").split(",");
    while (ArrayUtils.contains(temp, "")) {
        temp = (String[]) ArrayUtils.removeElement(temp, "");
    }//ww w  .ja  v  a  2 s.  co m
    return temp;
}

From source file:com.cartmatic.estore.common.helper.ConfigUtil.java

public String[] getBulkSkuCommAttrs() {
    String temp[] = this.getConfig("BulkSkuCommAttrs").split(",");
    while (ArrayUtils.contains(temp, "")) {
        temp = (String[]) ArrayUtils.removeElement(temp, "");
    }/*from w w  w  . j a  va2 s  . c o  m*/
    return temp;
}

From source file:com.cartmatic.estore.common.helper.ConfigUtil.java

public String[] getBulkProdAttrs() {
    String temp[] = this.getConfig("BulkProdAttrs").split(",");
    while (ArrayUtils.contains(temp, "")) {
        temp = (String[]) ArrayUtils.removeElement(temp, "");
    }//from   w w  w  .  j a  v a  2  s.  c  om
    return temp;
}

From source file:com.ecyrd.jspwiki.PageManager.java

/**
 *  For a single wiki page, replaces all Acl entries matching a supplied array of Principals 
 *  with a new Principal./*from   ww w. j ava 2 s. c  om*/
 * 
 *  @param page the wiki page whose Acl is to be modified
 *  @param oldPrincipals an array of Principals to replace; all AclEntry objects whose
 *   {@link AclEntry#getPrincipal()} method returns one of these Principals will be replaced
 *  @param newPrincipal the Principal that should receive the old Principals' permissions
 *  @return <code>true</code> if the Acl was actually changed; <code>false</code> otherwise
 */
protected boolean changeAcl(WikiPage page, Principal[] oldPrincipals, Principal newPrincipal) {
    Acl acl = page.getAcl();
    boolean pageChanged = false;
    if (acl != null) {
        Enumeration entries = acl.entries();
        Collection<AclEntry> entriesToAdd = new ArrayList<AclEntry>();
        Collection<AclEntry> entriesToRemove = new ArrayList<AclEntry>();
        while (entries.hasMoreElements()) {
            AclEntry entry = (AclEntry) entries.nextElement();
            if (ArrayUtils.contains(oldPrincipals, entry.getPrincipal())) {
                // Create new entry
                AclEntry newEntry = new AclEntryImpl();
                newEntry.setPrincipal(newPrincipal);
                Enumeration permissions = entry.permissions();
                while (permissions.hasMoreElements()) {
                    Permission permission = (Permission) permissions.nextElement();
                    newEntry.addPermission(permission);
                }
                pageChanged = true;
                entriesToRemove.add(entry);
                entriesToAdd.add(newEntry);
            }
        }
        for (Iterator ix = entriesToRemove.iterator(); ix.hasNext();) {
            AclEntry entry = (AclEntry) ix.next();
            acl.removeEntry(entry);
        }
        for (Iterator ix = entriesToAdd.iterator(); ix.hasNext();) {
            AclEntry entry = (AclEntry) ix.next();
            acl.addEntry(entry);
        }
    }
    return pageChanged;
}

From source file:com.manydesigns.portofino.actions.admin.TablesAction.java

protected void configureTypesSelectionProvider(DefaultSelectionProvider typesSP, ColumnForm columnForm) {
    Type type = columnForm.getType();
    Class[] javaTypes = getAvailableJavaTypes(type, columnForm.getLength());
    long precision = columnForm.getLength() != null ? columnForm.getLength() : type.getMaximumPrecision();
    int scale = columnForm.getScale() != null ? columnForm.getScale() : type.getMaximumScale();
    Class defaultJavaType = Type.getDefaultJavaType(columnForm.getJdbcType(), precision, scale);
    if (defaultJavaType == null) {
        defaultJavaType = Object.class;
    }/*from  w ww .j a  v  a2s.com*/
    typesSP.appendRow(new Object[] { columnForm.getColumnName(), type, null },
            new String[] { columnForm.getColumnName(),
                    type.getTypeName() + " (JDBC: " + type.getJdbcType() + ")",
                    "Auto (" + defaultJavaType.getSimpleName() + ")" },
            true);
    try {
        Class existingType = Class.forName(columnForm.getJavaType());
        if (!ArrayUtils.contains(javaTypes, existingType)) {
            typesSP.appendRow(new Object[] { columnForm.getColumnName(), type, null },
                    new String[] { columnForm.getColumnName(),
                            type.getTypeName() + " (JDBC: " + type.getJdbcType() + ")",
                            existingType.getSimpleName() },
                    true);
        }
    } catch (Exception e) {
        logger.debug("Invalid Java type", e);
    }
    for (Class c : javaTypes) {
        typesSP.appendRow(new Object[] { columnForm.getColumnName(), type, c.getName() },
                new String[] { columnForm.getColumnName(),
                        type.getTypeName() + " (JDBC: " + type.getJdbcType() + ")", c.getSimpleName() },
                true);
    }
}