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:au.org.emii.portal.composer.MapComposer.java

public void openUrl(Event event) {
    String s = (String) event.getData();

    LOGGER.debug("\n\n******\n\ns: " + s + "\n\n******\n\n");

    String url = "";
    String header = "";
    String download = "";
    String[] data = s.split("\n");
    if (!ArrayUtils.isEmpty(data)) {

        LOGGER.debug("data.length: " + data.length);

        if (data.length == 1) {
            url = data[0];/*from   ww w .java 2  s. c  o  m*/
        }
        if (data.length == 2) {
            url = data[0];
            header = data[1];

            // now the 'header' might be a 'header' or 'download link'
            if (header.startsWith("pid:")) {
                download = header;
                header = "";
            }
        }
        if (data.length == 3) {
            url = data[0];
            header = data[1];
            download = data[2];
        }

        if (download.length() > 0 && download.startsWith(StringConstants.PID)) {
            download = download.substring(4);
        }

        activateLink(url, header, false, download);
    }

}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

public boolean testResultAvail(String rootModulePath, String subModuleName, List<String> testAgainsts,
        String action) throws PhrescoException {
    boolean resultAvailable = false;
    try {//from  ww w.ja  va  2  s. co  m
        String reportDir = "";
        String resultExtension = "";
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        if (Constants.PHASE_PERFORMANCE_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getPerformanceTestReportDir(rootModulePath, subModuleName);
            resultExtension = FrameworkServiceUtil.getPerformanceResultFileExtension(rootModulePath,
                    subModuleName);
        } else {
            reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
            resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
        }
        for (String testAgainst : testAgainsts) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            if (Constants.PHASE_PERFORMANCE_TEST.equals(action)) {
                reportDir = FrameworkServiceUtil.getPerformanceTestReportDir(rootModulePath, subModuleName);
            } else {
                reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
            }

            if (StringUtils.isNotEmpty(reportDir) && StringUtils.isNotEmpty(testAgainst)) {
                Pattern p = Pattern.compile(TEST_DIRECTORY);
                Matcher matcher = p.matcher(reportDir);
                reportDir = matcher.replaceAll(testAgainst);
                sb.append(reportDir);
            }

            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension) && file.exists()) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                    break;
                }
            }
        }

        if (CollectionUtils.isEmpty(testAgainsts) && Constants.PHASE_PERFORMANCE_TEST.equals(action)
                && StringUtils.isNotEmpty(reportDir)) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            sb.append(reportDir);
            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension)) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                }
            }
        }

    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return resultAvailable;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

public boolean testResultAvailunit(String rootModulePath, String subModuleName, List<String> testAgainsts,
        String action) throws PhrescoException {
    boolean resultAvailable = false;
    try {//from   ww w.ja v  a 2s . com
        String reportDir = "";
        String resultExtension = "";
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        if (Constants.PHASE_UNIT_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getUnitTestRptDir(rootModulePath, subModuleName);
            resultExtension = "xml";
        } /*else {
           reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
           resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
          }*/
        for (String testAgainst : testAgainsts) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            if (Constants.PHASE_UNIT_TEST.equals(action)) {
                reportDir = FrameworkServiceUtil.getUnitTestRptDir(rootModulePath, subModuleName);
            } /*else {
               reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
              }*/

            if (StringUtils.isNotEmpty(reportDir) && StringUtils.isNotEmpty(testAgainst)) {
                Pattern p = Pattern.compile(TEST_DIRECTORY);
                Matcher matcher = p.matcher(reportDir);
                reportDir = matcher.replaceAll(testAgainst);
                sb.append(reportDir);
            }

            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension) && file.exists()) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                    break;
                }
            }
        }

        if (CollectionUtils.isEmpty(testAgainsts) && Constants.PHASE_UNIT_TEST.equals(action)
                && StringUtils.isNotEmpty(reportDir)) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            sb.append(reportDir);
            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension)) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                }
            }
        }

    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return resultAvailable;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

public boolean testResultAvailfunctional(String rootModulePath, String subModuleName, List<String> testAgainsts,
        String action) throws PhrescoException {
    boolean resultAvailable = false;
    try {//from ww  w.  ja v  a2  s.  com
        String reportDir = "";
        String resultExtension = "";
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        if (Constants.PHASE_FUNCTIONAL_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getFunctionalTestRptDir(rootModulePath, subModuleName);
            resultExtension = "xml";
        } /*else {
           reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
           resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
          }*/
        for (String testAgainst : testAgainsts) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            if (Constants.PHASE_FUNCTIONAL_TEST.equals(action)) {
                reportDir = FrameworkServiceUtil.getFunctionalTestRptDir(rootModulePath, subModuleName);
            } /*else {
               reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
              }*/

            if (StringUtils.isNotEmpty(reportDir) && StringUtils.isNotEmpty(testAgainst)) {
                Pattern p = Pattern.compile(TEST_DIRECTORY);
                Matcher matcher = p.matcher(reportDir);
                reportDir = matcher.replaceAll(testAgainst);
                sb.append(reportDir);
            }

            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension) && file.exists()) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                    break;
                }
            }
        }

        if (CollectionUtils.isEmpty(testAgainsts) && Constants.PHASE_FUNCTIONAL_TEST.equals(action)
                && StringUtils.isNotEmpty(reportDir)) {
            StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
            sb.append(reportDir);
            File file = new File(sb.toString());
            if (StringUtils.isNotEmpty(resultExtension)) {
                File[] children = file.listFiles(new XmlNameFileFilter(resultExtension));
                if (!ArrayUtils.isEmpty(children)) {
                    resultAvailable = true;
                }
            }
        }

    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return resultAvailable;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

private List<String> testResultFiles(String rootModulePath, String subModuleName, List<String> testAgainsts,
        boolean showDevice, String action) throws PhrescoException {
    List<String> testResultFiles = new ArrayList<String>();
    String reportDir = "";
    String resultExtension = "";
    try {/*from  w w w .j av a2s.  co m*/
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
        if (Constants.PHASE_PERFORMANCE_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getPerformanceTestReportDir(rootModulePath, subModuleName);
            resultExtension = FrameworkServiceUtil.getPerformanceResultFileExtension(rootModulePath,
                    subModuleName);
        } else {
            reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
            resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
        }

        //test against will be available 
        if (StringUtils.isNotEmpty(reportDir) && CollectionUtils.isNotEmpty(testAgainsts)) {
            Pattern p = Pattern.compile(TEST_DIRECTORY);
            Matcher matcher = p.matcher(reportDir);
            reportDir = matcher.replaceAll(testAgainsts.get(0));
            sb.append(reportDir);
        }

        //for android - test type will not be available --- to get device id from result xml
        if (Constants.PHASE_PERFORMANCE_TEST.equals(action) && showDevice) {
            sb.append(reportDir);
        }

        File file = new File(sb.toString());

        if (StringUtils.isNotEmpty(resultExtension)) {
            File[] resultFiles = file.listFiles(new XmlNameFileFilter(resultExtension));
            if (!ArrayUtils.isEmpty(resultFiles)) {
                QualityUtil.sortResultFile(resultFiles);
                for (File resultFile : resultFiles) {
                    if (resultFile.isFile()) {
                        testResultFiles.add(resultFile.getName());
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return testResultFiles;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

private List<String> testResultFilesunit(String rootModulePath, String subModuleName, List<String> testAgainsts,
        String showDevice, String action) throws PhrescoException {
    List<String> testResultFiles = new ArrayList<String>();
    String reportDir = "";
    String resultExtension = "";
    try {/*from   w w  w.j  a  v  a 2  s .  c o m*/
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
        if (Constants.PHASE_UNIT_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getUnitTestRptDir(rootModulePath, subModuleName);
            resultExtension = "xml";
        } /*else {
           reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
           resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
          }
          */
        //test against will be available 
        if (StringUtils.isNotEmpty(reportDir) && CollectionUtils.isNotEmpty(testAgainsts)) {
            Pattern p = Pattern.compile(TEST_DIRECTORY);
            Matcher matcher = p.matcher(reportDir);
            reportDir = matcher.replaceAll(testAgainsts.get(0));
            sb.append(reportDir);
        }

        //for android - test type will not be available --- to get device id from result xml
        if (Constants.PHASE_UNIT_TEST.equals(action) && StringUtils.isNotEmpty(showDevice)) {
            sb.append(reportDir);
        }

        File file = new File(sb.toString());

        if (StringUtils.isNotEmpty(resultExtension)) {
            File[] resultFiles = file.listFiles(new XmlNameFileFilter(resultExtension));
            if (!ArrayUtils.isEmpty(resultFiles)) {
                QualityUtil.sortResultFile(resultFiles);
                for (File resultFile : resultFiles) {
                    if (resultFile.isFile()) {
                        testResultFiles.add(resultFile.getName());
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return testResultFiles;
}

From source file:com.photon.phresco.framework.rest.api.QualityService.java

private List<String> testResultFilesfunctional(String rootModulePath, String subModuleName,
        List<String> testAgainsts, boolean showDevice, String action) throws PhrescoException {
    List<String> testResultFiles = new ArrayList<String>();
    String reportDir = "";
    String resultExtension = "";
    try {/*from w  ww.  ja v  a  2  s . c o  m*/
        ProjectInfo projectInfo = Utility.getProjectInfo(rootModulePath, subModuleName);
        File testFolderLocation = Utility.getTestFolderLocation(projectInfo, rootModulePath, subModuleName);
        StringBuilder sb = new StringBuilder(testFolderLocation.getPath());
        if (Constants.PHASE_FUNCTIONAL_TEST.equals(action)) {
            reportDir = FrameworkServiceUtil.getFunctionalTestRptDir(rootModulePath, subModuleName);
            resultExtension = "xml";
        } /*else {
           reportDir = FrameworkServiceUtil.getLoadTestReportDir(rootModulePath, subModuleName);
           resultExtension = FrameworkServiceUtil.getLoadResultFileExtension(rootModulePath, subModuleName);
          }
          */
        //test against will be available 
        if (StringUtils.isNotEmpty(reportDir) && CollectionUtils.isNotEmpty(testAgainsts)) {
            Pattern p = Pattern.compile(TEST_DIRECTORY);
            Matcher matcher = p.matcher(reportDir);
            reportDir = matcher.replaceAll(testAgainsts.get(0));
            sb.append(reportDir);
        }

        //for android - test type will not be available --- to get device id from result xml
        if (Constants.PHASE_FUNCTIONAL_TEST.equals(action) && showDevice) {
            sb.append(reportDir);
        }

        File file = new File(sb.toString());

        if (StringUtils.isNotEmpty(resultExtension)) {
            File[] resultFiles = file.listFiles(new XmlNameFileFilter(resultExtension));
            if (!ArrayUtils.isEmpty(resultFiles)) {
                QualityUtil.sortResultFile(resultFiles);
                for (File resultFile : resultFiles) {
                    if (resultFile.isFile()) {
                        testResultFiles.add(resultFile.getName());
                    }
                }
            }
        }
    } catch (Exception e) {
        throw new PhrescoException(e);
    }

    return testResultFiles;
}

From source file:com.cloud.hypervisor.kvm.resource.LibvirtComputingResource.java

/**
* This method retrieves the memory statistics from the domain given as parameters.
* If no memory statistic is found, it will return {@link NumberUtils#LONG_ZERO} as the value of free memory in the domain.
* If it can retrieve the domain memory statistics, it will return the free memory statistic; that means, it returns the value at the first position of the array returned by {@link Domain#memoryStats(int)}.
*
* @return the amount of free memory in KBs
*//*from  w ww.j  av a2 s . c  om*/
protected long getMemoryFreeInKBs(Domain dm) throws LibvirtException {
    MemoryStatistic[] mems = dm.memoryStats(NUMMEMSTATS);
    if (ArrayUtils.isEmpty(mems)) {
        return NumberUtils.LONG_ZERO;
    }
    return mems[0].getValue();
}

From source file:com.test.stringtest.StringUtils.java

/**
 * <p>Check if a String starts with any of an array of specified strings.</p>
 * //w  ww  .j  a v a2s.  c o m
 * <pre>
 * StringUtils.startsWithAny(null, null)      = false
 * StringUtils.startsWithAny(null, new String[] {"abc"})  = false
 * StringUtils.startsWithAny("abcxyz", null)     = false
 * StringUtils.startsWithAny("abcxyz", new String[] {""}) = false
 * StringUtils.startsWithAny("abcxyz", new String[] {"abc"}) = true
 * StringUtils.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
 * </pre>
 *
 * @see #startsWith(String, String)
 * @param string  the String to check, may be null
 * @param searchStrings the Strings to find, may be null or empty
 * @return <code>true</code> if the String starts with any of the the prefixes, case insensitive, or
 *  both <code>null</code>
 * @since 2.5
 */
public static boolean startsWithAny(String string, String[] searchStrings) {
    if (isEmpty(string) || ArrayUtils.isEmpty(searchStrings)) {
        return false;
    }
    for (int i = 0; i < searchStrings.length; i++) {
        String searchString = searchStrings[i];
        if (StringUtils.startsWith(string, searchString)) {
            return true;
        }
    }
    return false;
}

From source file:net.ymate.framework.commons.HttpClientHelper.java

public static SSLConnectionSocketFactory createConnectionSocketFactory(String certType, URL certFilePath,
        char[] passwordChars) throws KeyStoreException, IOException, CertificateException,
        NoSuchAlgorithmException, UnrecoverableKeyException, KeyManagementException {
    if (StringUtils.isBlank(certType)) {
        throw new NullArgumentException("certType");
    }//w  w  w  .j av  a  2s.  co m
    if (certFilePath == null) {
        throw new NullArgumentException("certFilePath");
    }
    if (ArrayUtils.isEmpty(passwordChars)) {
        throw new NullArgumentException("passwordChars");
    }
    KeyStore _keyStore = KeyStore.getInstance(certType);
    InputStream _certFileStream = null;
    try {
        _certFileStream = certFilePath.openStream();
        _keyStore.load(_certFileStream, passwordChars);
    } finally {
        IOUtils.closeQuietly(_certFileStream);
    }
    SSLContext _sslContext = SSLContexts.custom().loadKeyMaterial(_keyStore, passwordChars).build();
    return new SSLConnectionSocketFactory(_sslContext, new String[] { "TLSv1" }, null,
            new DefaultHostnameVerifier());
}