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:com.vmware.bdd.security.tls.SimpleSeverTrustTlsSocketFactory.java

private static void check(TrustStoreConfig trustStoreCfg) {
    if (trustStoreCfg == null) {
        throw new TlsInitException("SIMPLE_TLS_SOCK_FACTORY.PARAMS_REQUIRED", null,
                "trust store config object.");
    }/* w w w.ja v a2 s  . c  o  m*/

    if (trustStoreCfg.getPassword() == null) {
        throw new TlsInitException("SIMPLE_TLS_SOCK_FACTORY.PARAMS_REQUIRED", null, "PasswordProvider");
    } else if (ArrayUtils.isEmpty(trustStoreCfg.getPassword().getPlainChars())) {
        throw new TlsInitException("SIMPLE_TLS_SOCK_FACTORY.PARAMS_REQUIRED", null, "Password");
    }

    if (CommonUtil.isBlank(trustStoreCfg.getPath())) {
        throw new TlsInitException("SIMPLE_TLS_SOCK_FACTORY.PARAMS_REQUIRED", null, "Trust Store Path");
    }

    if (CommonUtil.isBlank(trustStoreCfg.getType())) {
        throw new TlsInitException("SIMPLE_TLS_SOCK_FACTORY.PARAMS_REQUIRED", null, "Trust Store Type");
    }
}

From source file:com.dushyant.portlet.gwt.PathBasedGwtRpcServiceResolver.java

/**
 * Scans the application context and its parents for service beans that implement the {@link
 * com.google.gwt.user.client.rpc.RemoteService}
 *
 * @param appContext Application context
 *
 * @return Map<String, Object> A map of RemoteServiceRelativePath annotation values vs the RPC service instances
 */// w ww .  ja va 2s . c om
private Map<String, Object> initGwtRpcServiceMap(final ApplicationContext appContext) {
    // Create a map of rpc services keyed against the RemoteServiceRelativePath annotation value
    Map<String, Object> rpcServiceMap = new HashMap<String, Object>();

    // If Gwt RPC service beans exist already (may be explicitly configured through spring config xml file)
    // then add them first.
    Map<String, Object> existingGwtRpcServiceMap = getGwtRpcServiceMap();
    if (existingGwtRpcServiceMap != null) {
        rpcServiceMap.putAll(existingGwtRpcServiceMap);
    }

    if (appContext != null) {
        //Find the beans of type RemoteService
        String[] remoteServiceBeans = appContext.getBeanNamesForType(RemoteService.class);
        if (!ArrayUtils.isEmpty(remoteServiceBeans)) {
            // If remoteServiceBeans are found then scan for Gwt Rpc beans
            scanForGwtRpcBeans(appContext, rpcServiceMap, remoteServiceBeans);
        }
    }
    return rpcServiceMap;
}

From source file:com.adobe.acs.commons.replication.impl.ReplicateVersionServlet.java

private JsonObject validate(String[] rootPaths, String[] agents, Date date) {

    final JsonObject obj = new JsonObject();

    if (ArrayUtils.isEmpty(rootPaths)) {
        obj.addProperty(KEY_ERROR, "Select at least 1 root path.");
        log.debug("Error validating root paths (they're empty)");
        return obj;
    }/* w ww.  ja v a  2 s.  c  om*/

    for (final String rootPath : rootPaths) {
        if (StringUtils.isBlank(rootPath)) {
            obj.addProperty(KEY_ERROR, "Root paths cannot be empty.");
            log.debug("Error validating a root path");
            return obj;
        }
    }

    if (date == null) {
        obj.addProperty(KEY_ERROR,
                "Specify the date and time to select the appropriate resource versions for replication.");
        log.debug("Error validating date");
        return obj;
    }

    if (ArrayUtils.isEmpty(agents)) {
        obj.addProperty(KEY_ERROR, "Select at least 1 replication agent.");
        log.debug("Error validating agents");
        return obj;
    }

    log.debug("Validated all version replication inputs successfully");

    return obj;
}

From source file:com.xtructure.xutil.test.MethodInfo.java

/**
 * Returns a cell with the parameters of the given child.
 * /*ww  w.  j  av  a  2s . c o m*/
 * @param child
 *            the child, the parameters of which should be returned
 * 
 * @return a cell with the parameters of the given child
 */
private final String paramCell(final InvocationInfo child) {
    return (ArrayUtils.isEmpty(child.getResult().getParameters()) ? "<td>&nbsp;</td>"
            : String.format("<td>%s</td>", //
                    new ToStringBuilder( //
                            child.getResult(), ToStringStyle.SIMPLE_STYLE) //
                                    .append(child.getResult().getParameters()) //
                                    .toString()));
}

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

public BigDecimal getAuthorizedInvoiceAdminFeeAmount() {
    BigDecimal total = new BigDecimal(0.0);
    if (!ArrayUtils.isEmpty(invoices)) {
        for (int i = 0; i < invoices.length; i++) {
            if (invoices[i].isAuthorized()) {
                total = total.add(BigDecimalUtil.nullSafe(invoices[i].getInvoiceAdminFee()));
            }/* ww w. j a v  a2s  .  c  om*/
        }
    }
    return total;
}

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

/** {@inheritDoc} */
@Override/*  w w w. j a  v a2 s  .  co m*/
public Map<String, BudgetPerformance> findByOrgCodeAndMonthAndKmkCodeJs(String orgCode, String monthly,
        String... kmkCodeJs) throws ServiceException {
    if (StringUtils.isEmpty(orgCode)) {
        throw new IllegalArgumentException("Organization must not be null or empty");
    }
    if (StringUtils.isEmpty(monthly)) {
        throw new IllegalArgumentException("Monthly must not be null or empty");
    }
    if (ArrayUtils.isEmpty(kmkCodeJs)) {
        throw new IllegalArgumentException("KmkCodeJs must not be null");
    }

    final Session session = HibernateSessionManager.getSession();
    Transaction tx = null;

    Map<String, BudgetPerformance> mapBudgetPerformances = new HashMap<String, BudgetPerformance>();
    try {
        tx = session.beginTransaction();
        Criterion criterion = Restrictions.and(Restrictions.eq("pk.organization.strCode", orgCode),
                Restrictions.and(Restrictions.eq("pk.getSudo", monthly),
                        Restrictions.and(Restrictions.in("pk.kmkCodeJ", kmkCodeJs),
                                Restrictions.eq("delKbn", Constants.STATUS_ACTIVE))));
        Criteria crit = session.createCriteria(BudgetPerformance.class);
        crit.add(criterion);

        List<BudgetPerformance> budgetPerformances = repository.findByCriteria(crit);
        if (CollectionUtils.isNotEmpty(budgetPerformances)) {
            for (int i = 0; i < budgetPerformances.size(); i++) {
                BudgetPerformance budgetPerformance = budgetPerformances.get(i);
                mapBudgetPerformances.put(budgetPerformance.getPk().getKmkCodeJ(), budgetPerformance);
            }
        }
        tx.commit();
    } catch (HibernateException ex) {
        if (tx != null) {
            tx.rollback();
        }
        throw new ServiceException(
                "An exception occured while get budget performance data by organization code " + orgCode, ex);
    } finally {
        HibernateSessionManager.closeSession(session);
    }
    return mapBudgetPerformances;
}

From source file:com.iyonger.apm.web.model.AgentManager.java

/**
 * Initialize agent manager.//from   ww  w. j  a va2s .c  o m
 */
@PostConstruct
public void init() {
    int port = config.getControllerPort();

    ConsoleCommunicationSetting consoleCommunicationSetting = ConsoleCommunicationSetting.asDefault();
    if (config.getInactiveClientTimeOut() > 0) {
        consoleCommunicationSetting.setInactiveClientTimeOut(config.getInactiveClientTimeOut());
    }

    agentControllerServerDaemon = new AgentControllerServerDaemon(config.getCurrentIP(), port,
            consoleCommunicationSetting);
    agentControllerServerDaemon.start();
    agentControllerServerDaemon.setAgentDownloadRequestListener(this);
    agentControllerServerDaemon.addLogArrivedListener(new LogArrivedListener() {
        @Override
        public void logArrived(String testId, AgentAddress agentAddress, byte[] logs) {
            AgentControllerIdentityImplementation agentIdentity = convert(agentAddress.getIdentity());
            if (ArrayUtils.isEmpty(logs)) {
                LOGGER.error("Log is arrived from {} but no log content", agentIdentity.getIp());
            }
            File logFile = null;
            try {
                logFile = new File(config.getHome().getPerfTestLogDirectory(testId.replace("test_", "")),
                        agentIdentity.getName() + "-" + agentIdentity.getRegion() + "-log.zip");
                FileUtils.writeByteArrayToFile(logFile, logs);
            } catch (IOException e) {
                LOGGER.error("Error while write logs from {} to {}", agentAddress.getIdentity().getName(),
                        logFile.getAbsolutePath());
                LOGGER.error("Error is following", e);
            }
        }
    });
}

From source file:com.google.gwt.dev.javac.CompilationUnitDiskCache.java

public void put(SourceFileCompilationUnit unit) {
    // don't mess with troubles ;)
    if (!ArrayUtils.isEmpty(unit.getProblems())) {
        for (CategorizedProblem problem : unit.getProblems()) {
            if (problem.isError()) {
                return;
            }//from   ww w.  jav a 2s .c  o  m
        }
    }
    // use the type name as key 
    String fileName = getFileName(unit.getSourceFile());
    File cacheFile = new File(m_cacheDir, fileName);
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(cacheFile);
        CachedCompilationUnit.save(unit, outputStream);
    } catch (Throwable e) {
        removeFromCache(cacheFile);
    } finally {
        IOUtils.closeQuietly(outputStream);
    }
}

From source file:net.jforum.core.support.hibernate.CacheEvictionRules.java

@AfterReturning("execution (* net.jforum.services.ModerationService.moveTopics(..)) && args(toForumId, log, topicIds)")
public void moveTopics(int toForumId, ModerationLog log, int... topicIds) {
    if (!ArrayUtils.isEmpty(topicIds)) {
        this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalPosts#" + toForumId));
        this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalTopics#" + toForumId));
        Cache cache = this.factoryImplementor.getSecondLevelCacheRegion("net.jforum.entities.Forum");

        if (cache != null) {
            cache.remove("net.jforum.entities.Forum#" + toForumId);
        }//  w w w. jav  a2  s. c  o  m

        Topic topic = (Topic) this.sessionFactory.getCurrentSession().get(Topic.class, topicIds[0]);
        Forum forum = topic.getForum();

        this.clearCacheRegion(this.factoryImplementor.getQueryCache("forumDAO.getTotalPosts#" + forum.getId()));
        this.clearCacheRegion(
                this.factoryImplementor.getQueryCache("forumDAO.getTotalTopics#" + forum.getId()));

        Cache cache2 = this.factoryImplementor.getSecondLevelCacheRegion("net.jforum.entities.Forum");

        if (cache2 != null) {
            cache2.remove("net.jforum.entities.Forum#" + forum.getId());
        }
    }
}

From source file:com.marvelution.hudson.plugins.apiv2.resources.impl.ActivityRestResourceImpl.java

/**
 * Get the filtered activities/*  w ww.  j ava2  s.com*/
 * 
 * @param types the {@link ActivityType}s to filter by
 * @param jobs the jobnames to filter by
 * @param userIds the userIds to filter by
 * @return the {@link List} of {@link ActivityCache}s
 * @since 4.5.0
 */
private Collection<ActivityCache> getFilteredActivities(ActivityType[] types, String[] jobs, String[] userIds) {
    if (ArrayUtils.isEmpty(types)) {
        types = ActivityType.values();
    }
    Predicate<ActivityCache> predicates = ActivityCachePredicates.isActivity(types);
    if (jobs != null) {
        predicates = Predicates.and(predicates, ActivityCachePredicates.relatesToJobs(jobs));
    }
    if (userIds != null) {
        predicates = Predicates.and(predicates, ActivityCachePredicates.relatesToUsers(userIds));
    }
    return Collections2.filter(APIv2Plugin.getActivitiesCache().getSortedActivities(), predicates);
}