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

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

Introduction

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

Prototype

public static String defaultIfBlank(String str, String defaultStr) 

Source Link

Document

Returns either the passed in String, or if the String is whitespace, empty ("") or null, the value of defaultStr.

Usage

From source file:org.itracker.model.util.IssueUtilities.java

public static String getSeverityName(String value, Locale locale) {
    return StringUtils.defaultIfBlank(
            ITrackerResources.getString(ITrackerResources.KEY_BASE_SEVERITY + value, locale),
            String.valueOf(value));
}

From source file:org.itracker.model.util.IssueUtilities.java

public static String getActivityName(IssueActivityType type, Locale locale) {
    return StringUtils.defaultIfBlank(
            ITrackerResources.getString("itracker.activity." + String.valueOf(type.name()), locale),
            type.name());//  w w w .j  av  a2s  . c o m
}

From source file:org.jahia.bin.JahiaController.java

/**
 * Sets the permission, required to handle this action. <code>null</code> if no particular permission is required.
 * /* www  .  j  a v a 2 s  .  c o  m*/
 * @param requiredPermission
 *            the permission, required to handle this action. <code>null</code> if no particular permission is required
 */
public void setRequiredPermission(String requiredPermission) {
    this.requiredPermission = StringUtils.defaultIfBlank(requiredPermission, null);
}

From source file:org.jahia.modules.dm.thumbnails.DocumentThumbnailJob.java

protected void doOperation(JCRNodeWrapper documentNode, JobExecutionContext jobExecutionContext)
        throws Exception {
    DocumentThumbnailService service = DocumentManagement.getInstance().getDocumentThumbnailService();
    if (service == null || !service.isEnabled()) {
        logger.info(//  www  .j  a  v a2 s.  c o m
                "Thumbnail generation service is not enabled. Skipping generation of a thumbnail for node {}",
                documentNode.getPath());
        return;
    }

    JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();

    int intValue = jobDataMap.getIntValue(THUMBNAIL_SIZE);

    service.createThumbnailForNode(documentNode,
            StringUtils.defaultIfBlank(jobDataMap.getString(THUMBNAIL_NAME), "thumbnail"),
            intValue > 0 ? intValue : 150);

    documentNode.getSession().save();
}

From source file:org.jahia.modules.dm.thumbnails.video.VideoThumbnailJob.java

protected void doOperation(JCRNodeWrapper documentNode, JobExecutionContext jobExecutionContext)
        throws Exception {
    VideoThumbnailService service = DocumentManagement.getInstance().getVideoThumbnailService();
    if (service == null || !service.isEnabled()) {
        logger.info(//from   w w w  . j a  v a2  s  .c  om
                "Thumbnail generation service is not enabled. Skipping generation of a thumbnail for node {}",
                documentNode.getPath());
        return;
    }

    JobDataMap jobDataMap = jobExecutionContext.getJobDetail().getJobDataMap();

    service.createThumbnailForNode(documentNode,
            StringUtils.defaultIfBlank(jobDataMap.getString(THUMBNAIL_NAME), "thumbnail"),
            jobDataMap.getIntValue(THUMBNAIL_OFFSET), jobDataMap.getString(THUMBNAIL_SIZE));

    documentNode.getSession().save();
}

From source file:org.jahia.modules.docrules.EmailDocumentRule.java

private String getBody(JCRNodeWrapper document, JCRNodeWrapper folder)
        throws ValueFormatException, PathNotFoundException, RepositoryException {
    String body = null;//from w  ww  .  j  av  a2s . c o m
    if (folder.hasProperty("j:documentRuleBody")) {
        body = folder.getProperty("j:documentRuleBody").getString();
    }
    body = StringUtils.defaultIfBlank(body, this.body);

    return evaluate(body, document);
}

From source file:org.jahia.modules.docrules.EmailDocumentRule.java

private String getSubject(JCRNodeWrapper document, JCRNodeWrapper folder)
        throws ValueFormatException, PathNotFoundException, RepositoryException {
    String subject = null;//from   ww  w. j  a v a 2  s  .  c o  m
    if (folder.hasProperty("j:documentRuleSubject")) {
        subject = folder.getProperty("j:documentRuleSubject").getString();
    }
    subject = StringUtils.defaultIfBlank(subject, this.subject);

    return evaluate(subject, document);
}

From source file:org.jahia.modules.gateway.decoders.NewsMailDecoderImpl.java

public String decode(Pattern matchingPattern, MailContent parsedMailContent, Message originalMessage)
        throws Exception {
    String title = originalMessage.getSubject();
    String nodepath = retrieveToken(parsedMailContent, matchingPattern, 2);

    nodepath = StringUtils.isNotBlank(nodepath) && paths.containsKey(nodepath) ? paths.get(nodepath)
            : "/sites/systemsite/contents/news";

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("nodetype", "jnt:news");
    jsonObject.put("name", StringUtils.defaultIfBlank(title, "Unknown"));
    jsonObject.put("locale", "en");
    jsonObject.put("workspace", Constants.EDIT_WORKSPACE);
    jsonObject.put("path", nodepath);
    Map<String, String> properties = new LinkedHashMap<String, String>();
    properties.put("desc", parsedMailContent.getBody());
    properties.put("jcr:title", StringUtils.defaultIfBlank(title, "Unknown"));
    properties.put("date", DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(System.currentTimeMillis()));
    if (!parsedMailContent.getFiles().isEmpty()) {
        properties.put("image", parsedMailContent.getFiles().get(0).getFile().getAbsolutePath());
    }// ww w.  j a  v  a  2s. c  om
    jsonObject.put("properties", properties);

    JahiaUser sender = getSender(originalMessage);
    if (sender != null) {
        properties.put("username", sender.getName());
    }

    return jsonObject.toString();
}

From source file:org.jahia.modules.gatewaysamples.decoders.MainContentMailDecoder.java

@Override
public String decode(Pattern matchingPattern, MailContent parsedMailContent, Message originalMessage)
        throws Exception {
    String title = originalMessage.getSubject();

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("nodetype", "jnt:mainContent");
    jsonObject.put("name", StringUtils.defaultIfBlank(title, "Unknown"));
    jsonObject.put("locale", "en");
    jsonObject.put("workspace", Constants.EDIT_WORKSPACE);
    jsonObject.put("path", "/sites/systemsite/contents");
    Map<String, String> properties = new LinkedHashMap<String, String>();
    properties.put("body", parsedMailContent.getBody());
    properties.put("jcr:title", StringUtils.defaultIfBlank(title, "Unknown"));
    if (!parsedMailContent.getFiles().isEmpty()) {
        properties.put("image", parsedMailContent.getFiles().get(0).getFile().getAbsolutePath());
    }/*from  w w w .j  a v a 2 s.  c  o  m*/
    jsonObject.put("properties", properties);

    JahiaUser sender = getSender(originalMessage);
    if (sender != null) {
        properties.put("username", sender.getName());
    }

    return jsonObject.toString();
}

From source file:org.jahia.modules.serversettings.flow.WebprojectHandler.java

/**
 * Returns the ID of the default template set.
 *
 * @return the ID of the default template set
 *///from  w w w .ja v a 2  s  .c  o  m
public String getDefaultTemplateSetId() {
    String id = null;
    String defTemplateSet = StringUtils
            .defaultIfBlank(SettingsBean.getInstance().lookupString("default_templates_set"), StringUtils.EMPTY)
            .trim();
    if (defTemplateSet.length() > 0) {
        JahiaTemplatesPackage pkg = templateManagerService.getTemplatePackage(defTemplateSet);
        if (pkg == null) {
            pkg = templateManagerService.getTemplatePackageById(defTemplateSet);
        }
        if (pkg == null) {
            logger.warn("Unable to find default template set \"{}\","
                    + " specified via default_templates_set (jahia.properties)");
        } else {
            id = pkg.getId();
        }
    }
    return id;
}