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

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

Introduction

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

Prototype

public static boolean isEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is empty or null.

Usage

From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java

private void importMarketLogs(File[] inputFiles) {
    if (ArrayUtils.isEmpty(inputFiles)) {
        return;/*from w ww. ja v  a2 s. c om*/
    }

    for (final File current : inputFiles) {
        final MarketLogFile logFile;
        try {
            logFile = new EveMarketLogParser(dataModelProvider.getStaticDataModel(), systemClock)
                    .parseFile(current);
        } catch (Exception e) {
            log.error("importMarketLogs(): Failed to parse " + current, e);
            displayError("Failed to parse logfile " + current.getAbsolutePath() + ": " + e.getMessage());
            continue;
        }

        // make sure the user is aware when importing data from a file
        // other than the current default region /
        // is warned when importing data that conflicts
        // with already existing data.
        if (!reallyImportFile(logFile) || logFile.isEmpty()) {
            log.debug("importMarketLogs(): Skipping file " + current.getAbsoluteFile()
                    + " [ empty / user choice ]");
            continue;
        }

        final ImportMarketLogFileComponent comp = new ImportMarketLogFileComponent(logFile);

        comp.setModal(true);

        final Window window = ComponentWrapper.wrapComponent(current.getName(), comp);

        if (window == null) { // component may refuse to display
                              // because the file holds data for a region other
                              // from the current default region and the
                              // user chose to cancel the operation
            continue;
        }

        window.setVisible(true);

        if (comp.wasCancelled()) {
            continue; // user skipped this file
        }

        log.info("importMarketLogs(): Importing data from file " + current.getAbsolutePath());
        this.marketDataProvider.store(comp.getPriceInfosForImport());
    }
}

From source file:com.nec.harvest.service.impl.BudgetPerformanceServiceImpl.java

/** {@inheritDoc} */
@Override/*from  ww  w . j  av  a  2 s. c  o  m*/
public Map<String, BudgetPerformanceBean> findByOrgCodesAndPeriodMonthAndKmkCodeJs(List<String> orgCodes,
        String startMonth, String endMonth, String... kmkCodeJs) throws ServiceException {
    if (CollectionUtils.isEmpty(orgCodes)) {
        throw new IllegalArgumentException(
                "Organization codes or current month in acton must not be null or empty");
    }
    if (StringUtils.isEmpty(startMonth)) {
        throw new IllegalArgumentException("Start month must not be null or empty");
    }
    if (StringUtils.isEmpty(endMonth)) {
        throw new IllegalArgumentException("End month month must not be null or empty");
    }
    if (ArrayUtils.isEmpty(kmkCodeJs)) {
        throw new IllegalArgumentException("KmkCodeJs must not be null");
    }

    logger.info(
            "Get budgetperformance by  organization codes:" + StringUtils.join(orgCodes, ",") + " startMonth "
                    + startMonth + " endMonth " + endMonth + "kmkcodej " + StringUtils.join(kmkCodeJs, ","));
    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    Map<String, BudgetPerformanceBean> mapBudgetPerformances = new HashMap<String, BudgetPerformanceBean>();
    try {
        tx = session.beginTransaction();
        StringBuilder sql = new StringBuilder(
                "SELECT Getsudo as getSudo, KmkCodej as kmkCodeJ, SUM(YosanKingaku) as yosanKingaku,");
        sql.append(" SUM(JisekiKingaku) as jisekiKingaku ");
        sql.append(" FROM " + TblConstants.TBL_BUDGET_PERFORMANCE);
        sql.append(" WHERE StrCode IN (:strCode) ");
        sql.append(" AND Getsudo >= :startMonth AND Getsudo <= :endMonth ");
        sql.append(" AND KmkCodej IN (:kmkCodeJs)");
        sql.append(" AND DelKbn = " + Constants.STATUS_ACTIVE);
        sql.append(" GROUP BY Getsudo, KmkCodej ");
        sql.append(" ORDER BY Getsudo");

        Query query = repository.getSQLQuery(session, sql.toString());
        query.setParameterList("strCode", orgCodes);
        query.setParameter("startMonth", startMonth);
        query.setParameter("endMonth", endMonth);
        query.setParameterList("kmkCodeJs", kmkCodeJs);
        query.setResultTransformer(Transformers.aliasToBean(BudgetPerformanceBean.class));

        List<BudgetPerformanceBean> budgetPerformances = query.list();
        // Release transaction
        tx.commit();
        if (CollectionUtils.isEmpty(budgetPerformances)) {
            throw new ObjectNotFoundException("There is no the budget performance object");
        }

        for (BudgetPerformanceBean budgetPerformance : budgetPerformances) {
            String key = budgetPerformance.getGetSudo() + budgetPerformance.getKmkCodeJ();
            mapBudgetPerformances.put(key, budgetPerformance);
        }
    } catch (SQLGrammarException | GenericJDBCException ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException(
                "An exception occured while get budget performance data by organization code " + orgCodes, ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return mapBudgetPerformances;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getHighwayTollTotalUnPaidInvAmount() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(highwayTollInvs)) {
        for (int i = 0; i < highwayTollInvs.length; i++) {
            if ("N".equals(highwayTollInvs[i].getPaidIndicator())) {
                amount = amount.add(highwayTollInvs[i].getAmount());
            }//ww  w.java 2  s . c  om
        }
    }
    return amount;
}

From source file:edu.jhuapl.openessence.web.util.ControllerUtils.java

public static List<Dimension> getResultDimensionsByIds(final OeDataSource ds, final String[] resultDimensionIds)
        throws OeDataSourceException {
    final List<Dimension> results;
    if (ArrayUtils.isEmpty(resultDimensionIds)
            || (resultDimensionIds.length == 1 && "all".equalsIgnoreCase(resultDimensionIds[0]))) {
        results = new ArrayList<Dimension>();
        results.addAll(ds.getResultDimensions());
    } else {// w ww  .  j  a v a2  s  .c  om
        results = new ArrayList<Dimension>(resultDimensionIds.length);
        for (final String resultDimensionId : resultDimensionIds) {
            final Dimension d = ds.getResultDimension(resultDimensionId);
            if (d != null) {
                results.add(d);
            } else {
                throw new OeDataSourceException("No Such Result Dimension " + resultDimensionId);
            }
        }
    }
    return results;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public List<Invoice> getAuthorizedFirstInvs() {
    List<Invoice> list = new ArrayList<Invoice>();
    if (!ArrayUtils.isEmpty(firstInvs)) {
        for (int i = 0; i < firstInvs.length; i++) {
            if (firstInvs[i].isAuthorized()) {
                list.add(firstInvs[i]);/*w  w  w .ja va2s  . c om*/
            }
        }
    }
    return list;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public boolean getOpenFirstInvExists() {
    if (!ArrayUtils.isEmpty(firstInvs)) {
        for (int i = 0; i < firstInvs.length; i++) {
            if ("N".equals(firstInvs[i].getPaidIndicator())) {
                return true;
            }/*from  w  w w . j av  a 2 s .  c  om*/
        }
    }
    return false;
}

From source file:com.gewara.util.XSSFilter.java

/**
 * // w w w. j  a va  2  s.c  om
 * @param entity
 * @param attrs
 * @return
 */
public static <T extends BaseObject> T filterObjAttrs(T entity, String... attrs) {
    if (ArrayUtils.isEmpty(attrs))
        return entity;
    XSSFilter filter = new XSSFilter();
    try {
        Map result = PropertyUtils.describe(entity);
        for (Object key : result.keySet()) {
            if (result.get(key) instanceof String && ArrayUtils.contains(attrs, String.valueOf(key))) {
                String cleanString = filter.filter(String.valueOf(result.get(key)));
                result.put(key, cleanString);
            }
        }
        BeanUtil.copyProperties(entity, result);
    } catch (Exception ex) {
    }
    return entity;
}

From source file:com.etcc.csc.presentation.datatype.PaymentContext.java

public BigDecimal getFirstInvTotalUnPaidAmount() {
    BigDecimal amount = BigDecimal.ZERO;
    if (!ArrayUtils.isEmpty(firstInvs)) {
        for (int i = 0; i < firstInvs.length; i++) {
            if ("N".equals(firstInvs[i].getPaidIndicator())) {
                amount = amount.add(firstInvs[i].getAmount());
            }/* w  ww .  j  av  a 2 s  .co m*/
        }
    }
    return amount;
}

From source file:gov.nih.nci.firebird.security.IamRoleHandler.java

private String getNesId(String ctepId) {
    IdentifiedPerson identifiedPerson = createIdentifiedPersonForCtepId(ctepId);
    LimitOffset limitOffset = new LimitOffset();
    limitOffset.setLimit(1);/*from ww w  .j av a 2s .  c o  m*/
    try {
        IdentifiedPerson[] results = identifiedPersonService.query(identifiedPerson, limitOffset);
        if (!ArrayUtils.isEmpty(results)) {
            return results[0].getPlayerIdentifier().getExtension();
        } else {
            throw new IllegalArgumentException("No IdentifiedPerson found for CTEP Id: " + ctepId);
        }
    } catch (RemoteException e) {
        LOG.error("Couldn't retrieve NES ID for CTEP ID: " + ctepId, e);
        throw new IllegalStateException(e);
    }
}

From source file:com.netscape.cms.servlet.csadmin.CertUtil.java

/**
 * reads from the admin cert profile caAdminCert.profile and determines the algorithm as follows:
 *
 * 1.  First gets list of allowed algorithms from profile (constraint.params.signingAlgsAllowed)
 *     If entry does not exist, uses entry "ca.profiles.defaultSigningAlgsAllowed" from CS.cfg
 *     If that entry does not exist, uses basic default
 *
 * 2.  Gets default.params.signingAlg from profile.
 *     If entry does not exist or equals "-", selects first algorithm in allowed algorithm list
 *     that matches CA signing key type/*w w w .ja v  a  2s . c o m*/
 *     Otherwise returns entry if it matches signing CA key type.
 *
 * @throws EBaseException
 * @throws IOException
 * @throws FileNotFoundException
 */

public static String getAdminProfileAlgorithm(IConfigStore config)
        throws EBaseException, FileNotFoundException, IOException {
    String caSigningKeyType = config.getString("preop.cert.signing.keytype", "rsa");
    String pfile = config.getString("profile.caAdminCert.config");
    Properties props = new Properties();
    props.load(new FileInputStream(pfile));

    Set<String> keys = props.stringPropertyNames();
    Iterator<String> iter = keys.iterator();
    String defaultAlg = null;
    String[] algsAllowed = null;

    while (iter.hasNext()) {
        String key = iter.next();
        if (key.endsWith("default.params.signingAlg")) {
            defaultAlg = props.getProperty(key);
        }
        if (key.endsWith("constraint.params.signingAlgsAllowed")) {
            algsAllowed = StringUtils.split(props.getProperty(key), ",");
        }
    }

    if (algsAllowed == null) { //algsAllowed not defined in profile, use a global setting
        algsAllowed = StringUtils.split(config.getString("ca.profiles.defaultSigningAlgsAllowed",
                "SHA256withRSA,SHA256withEC,SHA1withDSA"), ",");
    }

    if (ArrayUtils.isEmpty(algsAllowed)) {
        throw new EBaseException("No allowed signing algorithms defined.");
    }

    if (StringUtils.isNotEmpty(defaultAlg) && !defaultAlg.equals("-")) {
        // check if the defined default algorithm is valid
        if (!isAlgorithmValid(caSigningKeyType, defaultAlg)) {
            throw new EBaseException("Administrator cert cannot be signed by specfied algorithm."
                    + "Algorithm incompatible with signing key");
        }

        for (String alg : algsAllowed) {
            if (defaultAlg.trim().equals(alg.trim())) {
                return defaultAlg;
            }
        }
        throw new EBaseException("Administrator Certificate cannot be signed by the specified algorithm "
                + "as it is not one of the allowed signing algorithms.  Check the admin cert profile.");
    }

    // no algorithm specified.  Pick the first allowed algorithm.
    for (String alg : algsAllowed) {
        if (isAlgorithmValid(caSigningKeyType, alg))
            return alg;
    }

    throw new EBaseException("Admin certificate cannot be signed by any of the specified possible algorithms."
            + "Algorithm is incompatible with the CA signing key type");
}