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

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

Introduction

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

Prototype

public static String strip(String str) 

Source Link

Document

Strips whitespace from the start and end of a String.

Usage

From source file:org.telscenter.sail.webapp.presentation.util.impl.SessionNavLogImpl.java

/**
 * Given a <code>String</code> XML SockEntry, returns a <code>String</code>
 * with the XML header info removed/* w w w  .  j  a v a2 s . c o  m*/
 * 
 * @param <code>String</code> s
 * @return <code>String</code>
 */
private String stripHead(String s) {
    return StringUtils.strip(s.substring(StringUtils.indexOf(s, '>') + 1, StringUtils.lastIndexOf(s, '>')));
}

From source file:org.telscenter.sail.webapp.presentation.util.impl.SessionNavLogImpl.java

/**
 * Given a <code>String</code> XML SockEntry, returns the <code>String</code>
 * activityType/*from   w  w w .  ja  v a 2s.  co m*/
 * 
 * @param <code>String</code> s
 * @return <code>String</code>
 */
public String activityType(String s) {
    String headless = stripHead(s);
    return StringUtils.strip(
            headless.substring(StringUtils.indexOf(headless, '<') + 1, StringUtils.indexOf(headless, ' ')));
}

From source file:org.telscenter.sail.webapp.presentation.util.impl.SessionNavLogImpl.java

/**
 * Given a <code>String</code> XML SockEntry, returns the <code>String</code>
 * podUUID/*from w w w.  j a v  a2s. com*/
 * 
 * @param <code>String</code> s
 * @return <code>String</code>
 */
public String podUUID(String s) {
    String headless = stripHead(s);
    return StringUtils.strip(
            headless.substring(StringUtils.indexOf(headless, '"') + 1, StringUtils.lastIndexOf(headless, '"')));
}

From source file:org.twinkql.instance.BeanInstantiator.java

@SuppressWarnings("unchecked")
public <T> T instantiate(String classNameOrAlias, Class<T> requiredType, boolean newInstance) {
    classNameOrAlias = StringUtils.strip(classNameOrAlias);

    classNameOrAlias = this.convertAliasToClassName(classNameOrAlias);

    Object callback = this.doInstantiate(classNameOrAlias, newInstance);

    if (requiredType != null) {
        if (!ClassUtils.isAssignable(callback.getClass(), requiredType)) {
            throw new RuntimeException();
        }//w  w  w  .  ja v a 2s  .c o  m
    }

    return (T) callback;
}

From source file:org.vosao.business.impl.CommentBusinessImpl.java

@Override
public CommentEntity addComment(String name, String content, PageEntity page) {

    ConfigEntity config = VosaoContext.getInstance().getConfig();
    CommentEntity comment = new CommentEntity(name, content, new Date(), page.getFriendlyURL());
    getDao().getCommentDao().save(comment);
    getBusiness().getSystemService().getPageCache().remove(page.getFriendlyURL());
    List<String> toAddresses = StrUtil.fromCSV(config.getCommentsEmail());
    if (toAddresses.size() == 0) {
        toAddresses.add(config.getSiteEmail());
    }/*  ww w  .j  av a 2  s .  c o  m*/
    for (String email : toAddresses) {
        EmailUtil.sendEmail(createCommentLetter(comment, page), COMMENT_LETTER_SUBJECT, config.getSiteEmail(),
                config.getSiteDomain() + " admin", StringUtils.strip(email));
        logger.debug("New comment letter was sent to " + email);
    }
    return comment;
}

From source file:org.vosao.business.impl.FormBusinessImpl.java

@Override
public String sendEmail(FormDataEntity formData) {
    FormEntity form = getFormDao().getById(formData.getFormId());
    ConfigEntity config = VosaoContext.getInstance().getConfig();
    FormConfigEntity formConfig = getDao().getFormConfigDao().getConfig();
    VelocityContext context = new VelocityContext();
    List<FieldEntity> fields = getDao().getFieldDao().getByForm(form);
    context.put("form", form);
    context.put("fields", fields);
    context.put("values", formData.getValues());
    context.put("config", config);
    String letter = getSystemService().render(formConfig.getLetterTemplate(), context);
    List<String> emails = StrUtil.fromCSV(form.getEmail());
    for (String email : emails) {
        String error = EmailUtil.sendEmail(letter, form.getLetterSubject(), config.getSiteEmail(), "Site admin",
                StringUtils.strip(email), getFileItems(formData));
        if (error != null) {
            return error;
        }/*from  w  ww. ja  va 2 s. co  m*/
        logger.info("Form successfully submitted and emailed.");
    }
    return null;
}

From source file:org.vosao.business.impl.plugin.PluginLoader.java

private PluginEntity readPluginConfig(WarItem zipItem) throws UnsupportedEncodingException, DocumentException {
    PluginEntity result = new PluginEntity();
    Element root = DocumentHelper.parseText(zipItem.data.toString("UTF-8")).getRootElement();
    result.setName(root.elementText("name"));
    result.setTitle(root.elementText("title"));
    result.setVersion(root.elementText("version"));
    result.setDescription(root.elementText("description"));
    result.setWebsite(root.elementText("website"));
    if (root.element("entry-point-class") != null) {
        result.setEntryPointClass(StringUtils.strip(root.elementText("entry-point-class")));
    }// ww w.  j av  a 2 s.  com
    if (root.element("plugin-config-url") != null) {
        result.setConfigURL(StringUtils.strip(root.elementText("plugin-config-url")));
    }
    StringBuffer header = new StringBuffer();
    if (root.element("header-javascript") != null) {
        for (Element e : (List<Element>) root.elements("header-javascript")) {
            header.append("<script type=\"text/javascript\" src=\"/file/plugins/").append(result.getName())
                    .append("/").append(e.getText()).append("\"></script>\n");
        }
    }
    if (root.element("header-css") != null) {
        for (Element e : (List<Element>) root.elements("header-css")) {
            header.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"/file/plugins/")
                    .append(result.getName()).append("/").append(e.getText()).append("\"/>\n");
        }
    }
    result.setPageHeader(header.toString());
    if (root.element("config") != null) {
        result.setConfigStructure(root.element("config").asXML());
    }
    return result;
}

From source file:org.vosao.service.back.impl.MessageServiceImpl.java

@Override
public ServiceResponse save(Map<String, String> vo) {
    List<String> errors = new ArrayList<String>();
    if (StringUtils.isEmpty(vo.get("code"))) {
        errors.add(Messages.get("code_is_empty"));
    } else {/*from  w  w  w  .ja v  a 2 s  .  co  m*/
        String code = StringUtils.strip(vo.get("code"));
        List<LanguageEntity> languages = getDao().getLanguageDao().select();
        for (LanguageEntity lang : languages) {
            if (!StringUtils.isEmpty(vo.get(lang.getCode()))) {
                MessageEntity message = getDao().getMessageDao().getByCode(code, lang.getCode());
                if (message == null) {
                    message = new MessageEntity();
                    message.setCode(code);
                    message.setLanguageCode(lang.getCode());
                }
                message.setValue(vo.get(lang.getCode()));
                getDao().getMessageDao().save(message);
            }
        }
        return ServiceResponse.createSuccessResponse(Messages.get("message.success_save"));
    }
    return ServiceResponse.createErrorResponse(Messages.get("errors_occured"), errors);
}

From source file:pt.webdetails.cdf.dd.FsPluginResourceLocations.java

private void initLocations() {

    for (PathOrigin origin : CdeSettings.getCustomComponentLocations()) {
        customComponentDirectories.add(origin);
    }/*from w  w  w. ja v  a 2s.  c om*/

    // External component locations
    PluginsAnalyzer pluginsAnalyzer = new PluginsAnalyzer(CdeEnvironment.getContentAccessFactory(),
            PentahoSystem.get(IPluginManager.class));
    pluginsAnalyzer.refresh();

    // FIXME will fail often if not everytime
    for (PluginPair<List<Element>> entry : pluginsAnalyzer.getPluginsWithSection("/cde-components/path")) {
        for (Element pathNode : entry.getValue()) {
            String path = StringUtils.strip(pathNode.getStringValue());
            String origin = pathNode.attributeValue("origin");//TODO:hcoded
            if (StringUtils.isEmpty(origin)) {
                //FIXME:
                customComponentDirectories.add(inferPathOriginFromLegacyLocation(entry.getPlugin(), path));
                logger.debug(String.format("Found CDE components location declared in %s [%s]",
                        entry.getPlugin().getId(), path));
            }
        }

    }
}

From source file:pt.webdetails.cte.CteSettings.java

protected List<String> initBlacklistedFileExtensions() {

    List<String> blacklistedFileExtensions = new ArrayList<String>();
    List<Element> xmlElements = getSettingsXmlSection(Constants.SETTINGS_XPATH_BLACKLISTED_FILE_EXTENSIONS);

    if (xmlElements != null) {

        for (Element xmlElement : xmlElements) {

            String value = StringUtils.strip(xmlElement.getTextTrim());

            if (StringUtils.isEmpty(value)) {
                logger.error("Invalid empty file extension. Skipping..");
                continue;
            }/* www . java2s .  c  o  m*/

            blacklistedFileExtensions.add(value);
        }
    }

    return blacklistedFileExtensions;
}