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

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

Introduction

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

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

Checks if a String is empty ("") or null.

Usage

From source file:edu.harvard.iq.dataverse.DataCitation.java

public DataCitation(DatasetVersion dsv) {
    // authors (or producer)
    authors = dsv.getAuthorsStr(false);//  w  w  w . j  a v a  2 s.c  om
    if (StringUtils.isEmpty(authors)) {
        authors = dsv.getDatasetProducersString();
    }

    // year
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
    if (!dsv.getDataset().isHarvested()) {
        Date citationDate = dsv.getCitationDate();
        if (citationDate == null) {
            if (dsv.getDataset().getPublicationDate() != null) {
                citationDate = dsv.getDataset().getPublicationDate();
            } else { // for drafts
                citationDate = new Date();
            }
        }

        year = new SimpleDateFormat("yyyy").format(citationDate);

    } else {
        try {
            year = sdf.format(sdf.parse(dsv.getDistributionDate()));
        } catch (ParseException ex) {
            // ignore
        } catch (Exception ex) {
            // ignore
        }
    }

    // title
    title = dsv.getTitle();

    // The Global Identifier: 
    // It is always part of the citation for the local datasets; 
    // And for *some* harvested datasets. 
    if (!dsv.getDataset().isHarvested()
            || HarvestingClient.HARVEST_STYLE_VDC.equals(dsv.getDataset().getHarvestedFrom().getHarvestStyle())
            || HarvestingClient.HARVEST_STYLE_ICPSR
                    .equals(dsv.getDataset().getHarvestedFrom().getHarvestStyle())
            || HarvestingClient.HARVEST_STYLE_DATAVERSE
                    .equals(dsv.getDataset().getHarvestedFrom().getHarvestStyle())) {
        if (!StringUtils.isEmpty(dsv.getDataset().getIdentifier())) {
            // creating a global id like this:
            // persistentId = new GlobalId(dsv.getDataset().getGlobalId());
            // you end up doing new GlobalId((New GlobalId(dsv.getDataset())).toString())
            // - doing an extra formatting-and-parsing-again
            // This achieves the same thing:
            persistentId = new GlobalId(dsv.getDataset());
        }
    }

    // distributors
    if (!dsv.getDataset().isHarvested()) {
        distributors = dsv.getRootDataverseNameforCitation();
    } else {
        distributors = dsv.getDistributorName();
        //remove += [distributor] SEK 8-18-2016
    }

    // version
    if (!dsv.getDataset().isHarvested()) {
        if (dsv.isDraft()) {
            version = "DRAFT VERSION";
        } else if (dsv.getVersionNumber() != null) {
            version = "V" + dsv.getVersionNumber();
            if (dsv.isDeaccessioned()) {
                version += ", DEACCESSIONED VERSION";
            }
        }
    }

    // UNF
    UNF = dsv.getUNF();

    // optional values
    for (DatasetFieldType dsfType : dsv.getDataset().getOwner().getCitationDatasetFieldTypes()) {
        DatasetField dsf = dsv.getDatasetField(dsfType);
        if (dsf != null) {
            optionalValues.add(dsf);

            if (dsf.getDatasetFieldType().getFieldType().equals(DatasetFieldType.FieldType.URL)) {
                optionalURLcount++;
            }
        }
    }
}

From source file:net.dstc.mkts.config.ServerSettingsImpl.java

@Override
public String getContextPath() {
    if (StringUtils.isEmpty(contextPath)) {
        contextPath = CONTEXT_PATH + "/*";
    }/*  w w  w. j  av  a  2  s  . c  om*/
    return contextPath;
}

From source file:jenkins.plugins.coverity.CoverityTool.PostCovBuildCommand.java

@Override
protected void prepareCommand() {
    InvocationAssistance invocationAssistance = publisher.getInvocationAssistance();
    try {/*from   ww w.java2  s .  c o m*/
        String postCovBuildCmd = invocationAssistance.getPostCovBuildCmd();
        if (!StringUtils.isEmpty(postCovBuildCmd)) {
            addArguments(EnvParser.tokenize(postCovBuildCmd));
        }
        listener.getLogger().println("[Coverity] post cov-build command: " + commandLine.toString());
    } catch (ParseException e) {
        throw new RuntimeException("ParseException occurred during tokenizing the post cov-build command.");
    }
}

From source file:com.proofpoint.http.server.HashLoginServiceProvider.java

public HashLoginService get() {
    String authConfig = config.getUserAuthFile();
    try {/*from  www .  j  a  v a 2  s . c om*/
        if (!StringUtils.isEmpty(authConfig)) {
            HashLoginService service = new HashLoginService(HttpServerModule.REALM_NAME, authConfig);
            service.loadUsers();
            return service;
        }
        return null;
    } catch (IOException e) {
        log.error(e, "Error when loading user auth info from %s", authConfig);
    }

    return null;
}

From source file:com.adaptris.core.services.jmx.JmxOperationInvoker.java

public Object invoke(String serviceUrl, String objectName, String username, String password, String methodName,
        Object[] params, String[] signatures) throws Exception {
    Map<String, String[]> env = new HashMap<>();
    if ((!StringUtils.isEmpty(username)) && (!StringUtils.isEmpty(password))) {
        String[] credentials = { username, Password.decode(password) };
        env.put(JMXConnector.CREDENTIALS, credentials);
    }/* w ww .j a  va 2  s .co m*/
    JMXServiceURL jmxServiceUrl = new JMXServiceURL(serviceUrl);
    JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxServiceUrl, env);
    ObjectName objectNameInst = ObjectName.getInstance(objectName);
    MBeanServerConnection mbeanConn = jmxConnector.getMBeanServerConnection();
    try {
        return mbeanConn.invoke(objectNameInst, methodName, params, signatures);
    } finally {
        jmxConnector.close();

    }
}

From source file:com.github.dbourdette.otto.data.filler.TokenizeOperation.java

@Override
public List<String> handle(String column) {
    String[] tokens = StringUtils.split(column, separator);

    List<String> result = new ArrayList<String>();

    if (StringUtils.isEmpty(column)) {
        result.add("");

        return result;
    }/*w  w  w.  j  av a2 s . c  o  m*/

    for (String token : tokens) {
        if (!ArrayUtils.contains(stopWords, token)) {
            result.add(token);
        }
    }

    return result;
}

From source file:com.recomdata.transmart.data.export.util.ZipUtil.java

/**
 * This method will bundle all the files into a zip file. 
 * If there are 2 files with the same name, only the first file is part of the zip.
 * /*from  ww  w.  jav a 2 s.c om*/
 * @param zipFileName
 * @param files
 * 
 * @return zipFile absolute path
 * 
 */
public static String bundleZipFile(String zipFileName, List<File> files) {
    File zipFile = null;
    Map<String, File> filesMap = new HashMap<String, File>();

    if (StringUtils.isEmpty(zipFileName))
        return null;

    try {
        zipFile = new File(zipFileName);
        if (zipFile.exists() && zipFile.isFile() && zipFile.delete()) {
            zipFile = new File(zipFileName);
        }

        ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
        zipOut.setLevel(ZipOutputStream.DEFLATED);
        byte[] buffer = new byte[BUFFER_SIZE];

        for (File file : files) {
            if (filesMap.containsKey(file.getName())) {
                continue;
            } else if (file.exists() && file.canRead()) {
                filesMap.put(file.getName(), file);
                zipOut.putNextEntry(new ZipEntry(file.getName()));
                FileInputStream fis = new FileInputStream(file);
                int bytesRead;
                while ((bytesRead = fis.read(buffer)) != -1) {
                    zipOut.write(buffer, 0, bytesRead);
                }
                zipOut.flush();
                zipOut.closeEntry();
            }
        }
        zipOut.finish();
        zipOut.close();
    } catch (IOException e) {
        //log.error("Error while creating Zip file");
    }

    return (null != zipFile) ? zipFile.getAbsolutePath() : null;
}

From source file:com.nhncorp.hangeul.admin.manage.bo.HangeulManageBOImpl.java

/**
 *  1, 2 ?   /*w w w .  j  a va  2s  .  c o  m*/
 * @return
 * @see com.nhncorp.hangeul.admin.work.bo.HangeulWorkManageBO#getHangeulWorkListCount()
 */
@Override
public int getHangeulWorkListCount(ArticleParam articleParam) {
    if (articleParam == null || StringUtils.isEmpty(articleParam.getHangeulWorkType())) {
        return 0;
    }

    return hangeulWorkManageDAO.selectHangeulWorkListCount(articleParam);
}

From source file:net.sourceforge.fenixedu.domain.contacts.MobilePhone.java

public static MobilePhone createMobilePhone(Party party, String number, PartyContactType type,
        Boolean isDefault, Boolean visibleToPublic, Boolean visibleToStudents, Boolean visibleToTeachers,
        Boolean visibleToEmployees, Boolean visibleToAlumni) {
    MobilePhone result = null;/*  w w w  .  j  a  v  a  2  s  . c  o  m*/
    if (!StringUtils.isEmpty(number)) {
        result = new MobilePhone(party, type, visibleToPublic, visibleToStudents, visibleToTeachers,
                visibleToEmployees, visibleToAlumni, isDefault, number);
    }
    return result;
}

From source file:be.fedict.eid.pkira.blm.model.certificatedomain.validation.UniqueCertificateDomainNameValidator.java

@Override
public boolean isValid(Object value) {
    if (StringUtils.isEmpty((String) value)) {
        return true;
    }/*  w  ww .  j  a  v  a  2 s  . c o m*/
    CertificateDomainHome certificateDomainHome = (CertificateDomainHome) Component
            .getInstance(CertificateDomainHome.NAME);
    CertificateDomain certificateDomain = certificateDomainHome.findByName((String) value);
    if (certificateDomain == null || certificateDomain.equals(certificateDomainHome.getInstance())) {
        return true;
    }
    return false;
}