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.etcc.csc.presentation.datatype.PaymentContext.java

public List<Invoice> getAuthorizedHighwayTollInvs() {
    List<Invoice> list = new ArrayList<Invoice>();
    if (!ArrayUtils.isEmpty(highwayTollInvs)) {
        for (int i = 0; i < highwayTollInvs.length; i++) {
            if (highwayTollInvs[i].isAuthorized()) {
                list.add(highwayTollInvs[i]);
            }/* w w w  . jav a 2 s  .  c  o  m*/
        }
    }
    return list;
}

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

private void importMarketLogs() {

    File inputDir = null;/*from w w  w .j  av a 2s  . c o  m*/
    if (appConfigProvider.getAppConfig().hasLastMarketLogImportDirectory()) {
        inputDir = appConfigProvider.getAppConfig().getLastMarketLogImportDirectory();

        if (!inputDir.exists() || !inputDir.isDirectory()) {
            inputDir = null;
        }
    }

    final JFileChooser chooser = inputDir != null ? new JFileChooser(inputDir) : new JFileChooser();

    chooser.setFileHidingEnabled(false);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(true);

    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        File[] files = chooser.getSelectedFiles();
        if (!ArrayUtils.isEmpty(files)) {
            appConfigProvider.getAppConfig().setLastMarketLogImportDirectory(files[0].getParentFile());
            try {
                appConfigProvider.save();
            } catch (IOException e) {
                log.error("importMarketLogs(): Failed to save configuration", e);
            }
            importMarketLogs(files);
        }
    }

}

From source file:gov.nih.nci.firebird.nes.person.NesPersonServiceBean.java

private IdentifiedPerson searchForIdentifiedPerson(IdentifiedPerson searchIdentifiedPerson) {
    IdentifiedPerson identifiedPerson = null;
    try {/*  w  w w  . ja v a  2 s . co m*/
        IdentifiedPerson[] identifiedPersons = identifiedPersonClient.query(searchIdentifiedPerson,
                createLimitOffset());
        if (!ArrayUtils.isEmpty(identifiedPersons)) {
            identifiedPerson = identifiedPersons[0];
        }
    } catch (TooManyResultsFault e) {
        handleUnexpectedError(e);
    } catch (RemoteException e) {
        handleUnexpectedError(e);
    }
    return identifiedPerson;
}

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

public boolean getOpenHighwayTollInvExists() {
    if (!ArrayUtils.isEmpty(highwayTollInvs)) {
        for (int i = 0; i < highwayTollInvs.length; i++) {
            if ("N".equals(highwayTollInvs[i].getPaidIndicator())) {
                return true;
            }/*from  www  . j a  va  2 s.  c o m*/
        }
    }
    return false;
}

From source file:net.grinder.AgentController.java

private void sendLog(ConsoleCommunication consoleCommunication, String testId) {
    File logFolder = new File(agentConfig.getHome().getLogDirectory(), testId);
    if (!logFolder.exists()) {
        return;/*w  w w  .j a  va  2 s.  co m*/
    }
    File[] logFiles = logFolder.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return (name.endsWith(".log"));
        }
    });

    if (logFiles == null || ArrayUtils.isEmpty(logFiles)) {
        LOGGER.error("No log exists under {}", logFolder.getAbsolutePath());
        return;
    }
    Arrays.sort(logFiles);
    // Take only one file... if agent.send.all.logs is not set.
    if (!agentConfig.getAgentProperties().getPropertyBoolean(PROP_AGENT_ALL_LOGS)) {
        logFiles = new File[] { logFiles[0] };
    }
    final byte[] compressedLog = LogCompressUtils.compress(logFiles, Charset.defaultCharset(),
            Charset.forName("UTF-8"));
    consoleCommunication
            .sendMessage(new LogReportGrinderMessage(testId, compressedLog, new AgentAddress(m_agentIdentity)));
    // Delete logs to clean up
    if (!agentConfig.getAgentProperties().getPropertyBoolean(PROP_AGENT_KEEP_LOGS)) {
        LOGGER.info("Clean up the perftest logs");
        FileUtils.deleteQuietly(logFolder);
    }
}

From source file:eu.europa.esig.dss.pdf.pdfbox.PdfBoxSignatureService.java

private List<PdfSignatureOrDocTimestampInfo> getSignatures(CertificatePool validationCertPool,
        byte[] originalBytes) {
    List<PdfSignatureOrDocTimestampInfo> signatures = new ArrayList<PdfSignatureOrDocTimestampInfo>();
    ByteArrayInputStream bais = null;
    PDDocument doc = null;// ww w .  j  av  a2  s. com
    try {

        bais = new ByteArrayInputStream(originalBytes);
        doc = PDDocument.load(bais);

        List<PDSignature> pdSignatures = doc.getSignatureDictionaries();
        if (CollectionUtils.isNotEmpty(pdSignatures)) {
            logger.debug("{} signature(s) found", pdSignatures.size());

            PdfDict catalog = new PdfBoxDict(doc.getDocumentCatalog().getCOSDictionary(), doc);
            PdfDssDict dssDictionary = PdfDssDict.build(catalog);

            for (PDSignature signature : pdSignatures) {
                String subFilter = signature.getSubFilter();
                byte[] cms = signature.getContents(originalBytes);

                if (StringUtils.isEmpty(subFilter) || ArrayUtils.isEmpty(cms)) {
                    logger.warn("Wrong signature with empty subfilter or cms.");
                    continue;
                }

                byte[] signedContent = signature.getSignedContent(originalBytes);
                int[] byteRange = signature.getByteRange();

                PdfSignatureOrDocTimestampInfo signatureInfo = null;
                if (PdfBoxDocTimeStampService.SUB_FILTER_ETSI_RFC3161.getName().equals(subFilter)) {
                    boolean isArchiveTimestamp = false;

                    // LT or LTA
                    if (dssDictionary != null) {
                        // check is DSS dictionary already exist
                        if (isDSSDictionaryPresentInPreviousRevision(
                                getOriginalBytes(byteRange, signedContent))) {
                            isArchiveTimestamp = true;
                        }
                    }

                    signatureInfo = new PdfBoxDocTimestampInfo(validationCertPool, signature, dssDictionary,
                            cms, signedContent, isArchiveTimestamp);
                } else {
                    signatureInfo = new PdfBoxSignatureInfo(validationCertPool, signature, dssDictionary, cms,
                            signedContent);
                }

                if (signatureInfo != null) {
                    signatures.add(signatureInfo);
                }
            }
            Collections.sort(signatures, new PdfSignatureOrDocTimestampInfoComparator());
            linkSignatures(signatures);

            for (PdfSignatureOrDocTimestampInfo sig : signatures) {
                logger.debug("Signature " + sig.uniqueId() + " found with byteRange "
                        + Arrays.toString(sig.getSignatureByteRange()) + " (" + sig.getSubFilter() + ")");
            }
        }

    } catch (Exception e) {
        logger.warn("Cannot analyze signatures : " + e.getMessage(), e);
    } finally {
        IOUtils.closeQuietly(bais);
        IOUtils.closeQuietly(doc);
    }

    return signatures;
}

From source file:com.lyh.licenseworkflow.dao.EnhancedHibernateDaoSupport.java

/**
 * ?? from DeviceResource where type = 'ROUTER' and temp = false;
 *
 * @param propertyNames ???//www  . j a  v a  2 s  . c  o  m
 * @param values        
 * @return ??
 */
@SuppressWarnings("unchecked")
public List<T> getEntitiesByPropNames(final String[] propertyNames, final Object[] values) {
    if (ArrayUtils.isEmpty(propertyNames) || ArrayUtils.isEmpty(values)
            || propertyNames.length != values.length) {
        throw new IllegalArgumentException("arguments is invalid.");
    }
    return (List<T>) getHibernateTemplate().execute(new HibernateCallback() {

        @Override
        public Object doInHibernate(Session session) throws HibernateException, SQLException {
            Criteria c = session.createCriteria(getEntityName());
            for (int i = 0; i < propertyNames.length; i++) {
                String propertyName = propertyNames[i];
                if (propertyName.indexOf(".") != -1) {
                    Criteria subC = null;
                    String[] props = StringUtils.split(propertyName, ".");
                    for (int j = 0; j < props.length; j++) {
                        if (j != props.length - 1) {
                            subC = c.createCriteria(props[j]);
                        }
                    }
                    if (values[i] == null)
                        subC.add(Restrictions.isNull(propertyName.substring(propertyName.indexOf(".") + 1)));
                    else
                        subC.add(Restrictions.eq(propertyName.substring(propertyName.indexOf(".") + 1),
                                values[i]));
                } else {
                    if (values[i] == null)
                        c.add(Restrictions.isNull(propertyNames[i]));
                    else if (values[i].toString().indexOf("%") != -1) {// ,?value?%
                        c.add(Restrictions.like(propertyNames[i], values[i]));
                    } else {
                        c.add(Restrictions.eq(propertyNames[i], values[i]));
                    }
                }
            }
            return c.list();
        }
    });
}

From source file:com.mindcognition.mindraider.install.Installer.java

/**
 * upgrade to 0.506 re-save all: 1. notebook models; 2. notebook resources;
 * 3. concept resources//from   w w w  .  j  av a 2s. c o  m
 */
private static void upgradeTo0506() {
    logger.debug(Messages.getString("Installer.upgradingTo", "0.506"));

    try {
        // 1. repair notebook models
        // for each folder get notebook descriptors
        ResourceDescriptor[] folders = MindRaider.labelCustodian.getLabelDescriptors();
        if (folders != null) {
            for (int i = 0; i < folders.length; i++) {
                String uri = folders[i].getUri();
                StatusBar.setText("", uri, 70);

                try {
                    // resave folder resource
                    new FolderResource(MindRaider.labelCustodian.get(uri)).save();
                } catch (Exception e2) {
                    logger.debug(Messages.getString("Installer.unableToResaveFolder", uri), e2);
                }

                ResourceDescriptor[] notebooks = MindRaider.labelCustodian.getOutlineDescriptors(uri);

                if (notebooks != null) {
                    for (int j = 0; j < notebooks.length; j++) {
                        String notebookUri = notebooks[j].getUri();
                        StatusBar.setText("", notebookUri, 70);

                        // upgrade model
                        String notebookModelFilename = MindRaider.outlineCustodian.getModelFilenameByDirectory(
                                MindRaider.outlineCustodian.getOutlineDirectory(notebookUri));
                        Model oldModel = RdfModel.loadModel(notebookModelFilename);

                        // fix notebook
                        Resource notebookRdf = oldModel.getResource(notebookUri);
                        // * rdfs:bag -> rdfs:seq
                        notebookRdf.removeAll(RDF.type);
                        OutlineCustodian.createOutlineRdfResource(notebooks[j], oldModel, notebookRdf);

                        // * fix every concept in the model
                        com.emental.mindraider.core.rest.Resource notebookR = MindRaider.outlineCustodian
                                .get(notebookUri);
                        OutlineResource notebookResource = new OutlineResource(notebookR);
                        try {
                            // save resource to update its properties
                            notebookResource.save();
                        } catch (Exception e1) {
                            logger.error("Unable to save notebook!", e1);
                        }
                        String[] conceptUris = notebookResource.getConceptUris();
                        if (!ArrayUtils.isEmpty(conceptUris)) {
                            for (String conceptUri : conceptUris) {
                                try {
                                    Resource conceptRdf = oldModel.getResource(conceptUri);
                                    ConceptResource conceptResource = MindRaider.noteCustodian.get(notebookUri,
                                            conceptUri);
                                    // add attachments to the resource
                                    // empty attachemnts group (detect,
                                    // whether group presents and if it
                                    // doesn't, then create it)
                                    if (!conceptResource.attachmentsExist()) {
                                        conceptResource.resource.getData()
                                                .addPropertyGroup(new ResourcePropertyGroup(
                                                        ConceptResource.PROPERTY_GROUP_LABEL_ATTACHMENTS,
                                                        new URI(ConceptResource.PROPERTY_GROUP_URI_ATTACHMENTS)));
                                        // add attachments there (if
                                        // exists)
                                        StmtIterator a = oldModel.listStatements(conceptRdf,
                                                MindRaiderVocabulary.attachment, (RDFNode) null);
                                        while (a.hasNext()) {
                                            String url = a.nextStatement().getObject().toString();

                                            logger.debug(Messages.getString("Installer.attachmentUrl", url));
                                            conceptResource.addAttachment(null, url);
                                        }
                                    }

                                    // save resource to update its
                                    // properties
                                    // MindRaider.conceptCustodian.save(noteResource,oldModel);
                                    conceptResource.save();

                                    // * rdfs:seq
                                    conceptRdf.removeAll(RDF.type);
                                    conceptRdf.addProperty(RDF.type, RDF.Seq);
                                    // * MR type
                                    conceptRdf.addProperty(RDF.type,
                                            oldModel.createResource(MindRaiderConstants.MR_OWL_CLASS_CONCEPT));
                                    // * rdfs:label
                                    conceptRdf.addProperty(RDFS.label,
                                            oldModel.createLiteral(conceptResource.getLabel()));
                                    // * dc:created
                                    conceptRdf.addProperty(DC.date, oldModel.createLiteral(
                                            conceptResource.resource.getMetadata().getCreated()));
                                    // * rdfs:comment (annotation
                                    // snippet)
                                    conceptRdf.addProperty(RDFS.comment,
                                            oldModel.createLiteral(OutlineTreeInstance
                                                    .getAnnotationCite(conceptResource.getAnnotation())));
                                    // * xlink:href
                                    conceptRdf.addProperty(MindRaiderVocabulary.xlinkHref,
                                            MindRaider.profile.getRelativePath(MindRaider.noteCustodian
                                                    .getConceptResourceFilename(notebookUri, conceptUri)));
                                } catch (Exception e) {
                                    logger.error(Messages.getString("Installer.unableToUpgradeConcept"), e);
                                }
                            }
                        }

                        // result overview
                        // StringWriter result=new StringWriter();
                        // oldModel.write(result);
                        // logger.debug(result.toString());

                        // write model
                        RdfModel.saveModel(oldModel, notebookModelFilename);
                    }
                }
            }
        }

        // update version in the profile
        MindRaider.profile.setVersion(MindRaider.getVersion());
        MindRaider.profile.save();
    } finally {
    }
}

From source file:com.photon.phresco.framework.actions.applications.Projects.java

/**
 * To get the application infos for mobile technology
 * @param appInfos//w w w.ja v a2  s .c  o  m
 * @param layerId
 * @return
 * @throws PhrescoException
 */
private List<ApplicationInfo> getMobileLayerAppInfos(List<ApplicationInfo> appInfos, String layerId)
        throws PhrescoException {
    String[] techGroupIds = getReqParameterValues(layerId + REQ_PARAM_NAME_TECH_GROUP);
    if (!ArrayUtils.isEmpty(techGroupIds)) {
        for (String techGroupId : techGroupIds) {
            String techId = getReqParameter(techGroupId + REQ_PARAM_NAME_TECHNOLOGY);
            String version = getReqParameter(techGroupId + REQ_PARAM_NAME_VERSION);
            boolean phoneEnabled = Boolean.parseBoolean(getReqParameter(techGroupId + REQ_PARAM_NAME_PHONE));
            boolean tabletEnabled = Boolean.parseBoolean(getReqParameter(techGroupId + REQ_PARAM_NAME_TABLET));
            Technology technology = getServiceManager().getTechnology(techId);
            String techName = technology.getName().replaceAll("\\s", "").toLowerCase();
            String dirName = getProjectCode() + HYPHEN + techName;
            String projectName = getProjectName() + HYPHEN + techName;
            appInfos.add(getAppInfo(projectName, dirName, techId, version, phoneEnabled, tabletEnabled));
        }
    }

    return appInfos;
}

From source file:com.etcc.csc.datatype.PaymentDetailUtil.java

public static OLC_VPS_UNINV_PMT_REC[] violationsToOLC_VPS_UNINV_PMT_RECs(Violation[] violations)
        throws Exception {
    if (ArrayUtils.isEmpty(violations)) {
        return null;
    }//w w  w  . ja v  a2 s  .  com
    OLC_VPS_UNINV_PMT_REC[] OLC_VPS_UNINV_PMT_RECs = new OLC_VPS_UNINV_PMT_REC[violations.length];
    for (int i = 0; i < violations.length; i++) {
        OLC_VPS_UNINV_PMT_REC rec = violationToOLC_VPS_UNINV_PMT_REC(violations[i]);
        rec.setARR_INDEX(new BigDecimal(i + 1));
        OLC_VPS_UNINV_PMT_RECs[i] = rec;
    }
    return OLC_VPS_UNINV_PMT_RECs;
}