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

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

Introduction

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

Prototype

public static String[] stripAll(String[] strs) 

Source Link

Document

Strips whitespace from the start and end of every String in an array.

Usage

From source file:net.sf.groovyMonkey.ScriptMetadata.java

public static String stripIllegalChars(final String string) {
    if (StringUtils.isBlank(string))
        return "";
    if (StringUtils.equals(string.trim(), ">"))
        return "_";
    final boolean prefix = string.trim().startsWith(">");
    final boolean postfix = string.trim().endsWith(">");
    final String processed = StringUtils.removeEnd(StringUtils.removeStart(string.trim(), ">"), ">");
    final StringBuffer buffer = new StringBuffer();
    if (processed.contains(">")) {
        for (final String str : StringUtils.stripAll(StringUtils.split(processed, ">"))) {
            final StringBuffer stripped = new StringBuffer(
                    compile("[^\\p{Alnum}_-]").matcher(str).replaceAll(""));
            buffer.append("__").append("" + stripped);
        }//from   w ww  . j av  a 2s  . c o  m
    } else
        buffer.append(compile("[^\\p{Alnum}_-]").matcher(processed).replaceAll(""));
    if (prefix)
        buffer.insert(0, "_");
    if (postfix)
        buffer.append("_");
    return "" + buffer;
}

From source file:nu.mine.kino.projects.utils.Utils.java

public static String[] parseCommna(String prefixs) {
    String[] split = StringUtils.stripAll(StringUtils.split(prefixs, ','));
    // String[] split = prefixs.split(",");
    return split;
}

From source file:org.apache.hadoop.yarn.server.applicationhistoryservice.metrics.timeline.aggregators.TimelineMetricAppAggregator.java

private List<String> getAppIdsForHostAggregation(Configuration metricsConf) {
    String appIds = metricsConf.get(CLUSTER_AGGREGATOR_APP_IDS);
    if (!StringUtils.isEmpty(appIds)) {
        return Arrays.asList(StringUtils.stripAll(appIds.split(",")));
    }//from   ww  w  .ja  va 2s . c o m
    return Collections.emptyList();
}

From source file:org.apache.roller.weblogger.business.plugins.PluginManagerImpl.java

/**
 * Initialize PagePlugins declared in roller.properties.
 * By using the full class name we also allow for the implementation of
 * "external" Plugins (maybe even packaged seperately). These classes are
 * then later instantiated by PageHelper.
 *///from w  w  w. ja  v  a 2 s.  c  om
private void loadPagePluginClasses() {
    log.debug("Initializing page plugins");

    String pluginStr = WebloggerConfig.getProperty("plugins.page");
    if (log.isDebugEnabled())
        log.debug(pluginStr);
    if (pluginStr != null) {
        String[] plugins = StringUtils.stripAll(StringUtils.split(pluginStr, ","));
        for (int i = 0; i < plugins.length; i++) {
            if (log.isDebugEnabled())
                log.debug("try " + plugins[i]);
            try {
                Class pluginClass = Class.forName(plugins[i]);
                if (isPagePlugin(pluginClass)) {
                    WeblogEntryPlugin plugin = (WeblogEntryPlugin) pluginClass.newInstance();
                    mPagePlugins.put(plugin.getName(), pluginClass);
                } else {
                    log.warn(pluginClass + " is not a PagePlugin");
                }
            } catch (ClassNotFoundException e) {
                log.error("ClassNotFoundException for " + plugins[i]);
            } catch (InstantiationException e) {
                log.error("InstantiationException for " + plugins[i]);
            } catch (IllegalAccessException e) {
                log.error("IllegalAccessException for " + plugins[i]);
            }
        }
    }
}

From source file:org.apache.roller.weblogger.business.plugins.PluginManagerImpl.java

/**
 * Initialize all comment plugins defined in weblogger config.
 *//*  www.  ja  v  a 2s .  c  om*/
private void loadCommentPlugins() {

    log.debug("Initializing comment plugins");

    String pluginStr = WebloggerConfig.getProperty("comment.formatter.classnames");
    if (pluginStr != null) {
        String[] plugins = StringUtils.stripAll(StringUtils.split(pluginStr, ","));
        for (int i = 0; i < plugins.length; i++) {
            log.debug("trying " + plugins[i]);

            try {
                Class pluginClass = Class.forName(plugins[i]);
                WeblogEntryCommentPlugin plugin = (WeblogEntryCommentPlugin) pluginClass.newInstance();

                // make sure and maintain ordering
                commentPlugins.add(i, plugin);

                log.debug("Configured comment plugin: " + plugins[i]);

            } catch (ClassCastException e) {
                log.error("ClassCastException for " + plugins[i]);
            } catch (ClassNotFoundException e) {
                log.error("ClassNotFoundException for " + plugins[i]);
            } catch (InstantiationException e) {
                log.error("InstantiationException for " + plugins[i]);
            } catch (IllegalAccessException e) {
                log.error("IllegalAccessException for " + plugins[i]);
            }
        }
    }

}

From source file:org.apache.roller.weblogger.business.runnable.ThreadManagerImpl.java

public void initialize() throws InitializationException {

    // initialize tasks, making sure that each task has a tasklock record in the db
    List<RollerTask> webloggerTasks = new ArrayList<RollerTask>();
    String tasksStr = WebloggerConfig.getProperty("tasks.enabled");
    String[] tasks = StringUtils.stripAll(StringUtils.split(tasksStr, ","));
    for (String taskName : tasks) {

        String taskClassName = WebloggerConfig.getProperty("tasks." + taskName + ".class");
        if (taskClassName != null) {
            log.info("Initializing task: " + taskName);

            try {
                Class taskClass = Class.forName(taskClassName);
                RollerTask task = (RollerTask) taskClass.newInstance();
                task.init(taskName);/*from www . j  a  v  a2s  .  com*/

                // make sure there is a tasklock record in the db
                TaskLock taskLock = getTaskLockByName(task.getName());
                if (taskLock == null) {
                    log.debug("Task record does not exist, inserting empty record to start with");

                    // insert an empty record
                    taskLock = new TaskLock();
                    taskLock.setName(task.getName());
                    taskLock.setLastRun(new Date(0));
                    taskLock.setTimeAquired(new Date(0));
                    taskLock.setTimeLeased(0);

                    // save it
                    this.saveTaskLock(taskLock);
                }

                // add it to the list of configured tasks
                webloggerTasks.add(task);

            } catch (ClassCastException ex) {
                log.warn("Task does not extend RollerTask class", ex);
            } catch (WebloggerException ex) {
                log.error("Error scheduling task", ex);
            } catch (Exception ex) {
                log.error("Error instantiating task", ex);
            }
        }
    }

    // create scheduler
    TaskScheduler scheduler = new TaskScheduler(webloggerTasks);

    // start scheduler thread, but only if it's not already running
    if (schedulerThread == null && scheduler != null) {
        log.debug("Starting scheduler thread");
        schedulerThread = new Thread(scheduler, "Roller Weblogger Task Scheduler");
        // set thread priority between MAX and NORM so we get slightly preferential treatment
        schedulerThread.setPriority((Thread.MAX_PRIORITY + Thread.NORM_PRIORITY) / 2);
        schedulerThread.start();
    }
}

From source file:org.apache.roller.weblogger.ui.core.filters.SchemeEnforcementFilter.java

/**
 * Filter init./*from w  ww.  j  av  a  2 s . com*/
 * 
 * We are just collecting init properties which we'll use for each request.
 */
public void init(FilterConfig filterConfig) {

    // determine if we are doing scheme enforcement
    this.schemeEnforcementEnabled = WebloggerConfig.getBooleanProperty("schemeenforcement.enabled");
    this.secureLoginEnabled = WebloggerConfig.getBooleanProperty("securelogin.enabled");

    if (this.schemeEnforcementEnabled && this.secureLoginEnabled) {
        // gather some more properties
        String http_port = WebloggerConfig.getProperty("securelogin.http.port");
        String https_port = WebloggerConfig.getProperty("securelogin.https.port");

        try {
            this.httpPort = Integer.parseInt(http_port);
            this.httpsPort = Integer.parseInt(https_port);
        } catch (NumberFormatException nfe) {
            // ignored ... guess we'll have to use the defaults
            log.warn("error with secure login ports", nfe);
        }

        // finally, construct our list of allowable https urls and ignored
        // resources
        String cfgs = WebloggerConfig.getProperty("schemeenforcement.https.urls");
        String[] cfgsArray = cfgs.split(",");
        for (int i = 0; i < cfgsArray.length; i++)
            this.allowedUrls.add(cfgsArray[i]);

        cfgs = WebloggerConfig.getProperty("schemeenforcement.https.ignored");
        cfgsArray = StringUtils.stripAll(StringUtils.split(cfgs, ","));
        for (int i = 0; i < cfgsArray.length; i++)
            this.ignored.add(cfgsArray[i]);

        // some logging for the curious
        log.info("Scheme enforcement = enabled");
        if (log.isDebugEnabled()) {
            log.debug("allowed urls are:");
            for (String allowedUrl : allowedUrls)
                log.debug(allowedUrl);
            log.debug("ignored extensions are:");
            for (String ignore : ignored)
                log.debug(ignore);
        }
    }
}

From source file:org.apache.roller.weblogger.ui.core.filters.ValidateSaltFilter.java

public void init(FilterConfig filterConfig) throws ServletException {

    // Construct our list of ignord urls
    String urls = WebloggerConfig.getProperty("salt.ignored.urls");
    String[] urlsArray = StringUtils.stripAll(StringUtils.split(urls, ","));
    for (int i = 0; i < urlsArray.length; i++) {
        this.ignored.add(urlsArray[i]);
    }//from ww w .j a va2 s. com
}

From source file:org.apache.roller.weblogger.ui.core.plugins.UIPluginManagerImpl.java

/**
 * Initialize the set of configured editors and define the default editor.
 *//*from   w w w .j  av a  2  s .  c o m*/
private void loadEntryEditorClasses() {

    log.debug("Initializing entry editor plugins");

    String editorStr = WebloggerConfig.getProperty("plugins.weblogEntryEditors");
    if (editorStr != null) {

        String[] editorList = StringUtils.stripAll(StringUtils.split(editorStr, ","));
        for (int i = 0; i < editorList.length; i++) {

            log.debug("trying editor " + editorList[i]);

            try {
                Class editorClass = Class.forName(editorList[i]);
                WeblogEntryEditor editor = (WeblogEntryEditor) editorClass.newInstance();

                // looks okay, add it to the map
                this.editors.put(editor.getId(), editor);

            } catch (ClassCastException cce) {
                log.error("It appears that your editor does not implement " + "the WeblogEntryEditor interface",
                        cce);
            } catch (Exception e) {
                log.error("Unable to instantiate editor [" + editorList[i] + "]", e);
            }
        }
    }

    if (this.editors.size() < 1) {
        log.warn("No entry editors configured, this means that publishing " + "entries will be impossible.");
        return;
    }

    // make sure the default editor is defined
    String defaultEditorId = WebloggerConfig.getProperty("plugins.defaultEditor");
    if (defaultEditorId != null) {
        this.defaultEditor = (WeblogEntryEditor) this.editors.get(defaultEditorId);
    }

    if (this.defaultEditor == null) {
        // someone didn't configure the default editor properly
        // guess we'll just have to pick one for them
        log.warn("Default editor was not properly configured, picking one at random instead.");

        Object editor = this.editors.values().iterator().next();
        this.defaultEditor = (WeblogEntryEditor) editor;
    }
}

From source file:org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel.java

public String[] stripAll(String[] strs) {
    return StringUtils.stripAll(strs);
}