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

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

Introduction

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

Prototype

public static String remove(String str, char remove) 

Source Link

Document

Removes all occurrences of a character from within the source string.

Usage

From source file:cec.easyshop.storefront.security.impl.WebHttpSessionRequestCache.java

protected String calculateRelativeRedirectUrl(final String contextPath, final String url) {
    if (UrlUtils.isAbsoluteUrl(url)) {
        String relUrl = url.substring(url.indexOf("://") + 3);
        String modifiedContextPath = (StringUtils.isNotEmpty(contextPath)) ? contextPath : "/";
        final String urlEncodingAttributes = getSessionService()
                .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
        if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes)
                && modifiedContextPath.contains(urlEncodingAttributes)) {
            modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes);
        }//from   ww  w. java 2  s.c o  m

        relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length());

        return (StringUtils.isEmpty(relUrl)) ? "/" : relUrl;
    } else {
        return url;
    }
}

From source file:com.ctc.storefront.security.impl.WebHttpSessionRequestCache.java

protected String calculateRelativeRedirectUrl(final String contextPath, final String url) {
    if (UrlUtils.isAbsoluteUrl(url)) {
        String relUrl = url.substring(url.indexOf("://") + 3);
        String modifiedContextPath = StringUtils.isNotEmpty(contextPath) ? contextPath : "/";
        final String urlEncodingAttributes = getSessionService()
                .getAttribute(WebConstants.URL_ENCODING_ATTRIBUTES);
        if (urlEncodingAttributes != null && !url.contains(urlEncodingAttributes)
                && modifiedContextPath.contains(urlEncodingAttributes)) {
            modifiedContextPath = StringUtils.remove(modifiedContextPath, urlEncodingAttributes);
        }/*from ww  w  .j  a  v a 2 s.  c  om*/

        relUrl = relUrl.substring(relUrl.indexOf(modifiedContextPath) + modifiedContextPath.length());

        return StringUtils.isEmpty(relUrl) ? "/" : relUrl;
    } else {
        return url;
    }
}

From source file:io.ecarf.core.utils.LogParser.java

/**
 * @throws Exception /*from ww w  .  j  av a 2s  .co  m*/
 * 
 */
public LogParser(String folder) throws Exception {
    super();

    boolean remote = folder.startsWith(GoogleMetaData.CLOUD_STORAGE_PREFIX);

    if (remote) {

        String bucket = StringUtils.remove(folder, GoogleMetaData.CLOUD_STORAGE_PREFIX);
        this.setUp();
        List<StorageObject> objects = this.service.listCloudStorageObjects(bucket);

        for (StorageObject object : objects) {
            String name = object.getName();
            if (name.endsWith(Constants.DOT_LOG)) {
                String localFile = FilenameUtils.getLocalFilePath(name);

                service.downloadObjectFromCloudStorage(name, localFile, bucket);

                this.files.add(localFile);
            }
        }

    } else {
        // local file
        DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
            public boolean accept(Path file) throws IOException {

                String filename = file.toString();
                return filename.endsWith(Constants.DOT_LOG) && filename.contains(PROCESSOR)
                        || filename.contains(COORDINATOR);
            }
        };

        Path dir = Paths.get(folder);
        try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) {
            for (Path path : stream) {
                this.files.add(path.toString());
            }
        }
    }

}

From source file:com.alibaba.otter.shared.arbitrate.impl.ArbitrateViewServiceImpl.java

public List<ProcessStat> listProcesses(Long channelId, Long pipelineId) {
    List<ProcessStat> processStats = new ArrayList<ProcessStat>();
    String processRoot = ManagePathUtils.getProcessRoot(channelId, pipelineId);
    IZkConnection connection = zookeeper.getConnection();
    // zkclient?stat??zk
    ZooKeeper orginZk = ((ZooKeeperx) connection).getZookeeper();

    // ?process//w  w w.j a  v  a  2s  .  c om
    List<String> processNodes = zookeeper.getChildren(processRoot);
    List<Long> processIds = new ArrayList<Long>();
    for (String processNode : processNodes) {
        processIds.add(ManagePathUtils.getProcessId(processNode));
    }

    Collections.sort(processIds);

    for (int i = 0; i < processIds.size(); i++) {
        Long processId = processIds.get(i);
        // ?process??
        ProcessStat processStat = new ProcessStat();
        processStat.setPipelineId(pipelineId);
        processStat.setProcessId(processId);

        List<StageStat> stageStats = new ArrayList<StageStat>();
        processStat.setStageStats(stageStats);
        try {
            String processPath = ManagePathUtils.getProcess(channelId, pipelineId, processId);
            Stat zkProcessStat = new Stat();
            List<String> stages = orginZk.getChildren(processPath, false, zkProcessStat);
            Collections.sort(stages, new StageComparator());

            StageStat prev = null;
            for (String stage : stages) {// ?processstage
                String stagePath = processPath + "/" + stage;
                Stat zkStat = new Stat();

                StageStat stageStat = new StageStat();
                stageStat.setPipelineId(pipelineId);
                stageStat.setProcessId(processId);

                byte[] bytes = orginZk.getData(stagePath, false, zkStat);
                if (bytes != null && bytes.length > 0) {
                    // ?zookeeperdata?managernodePipeKey?????'@'?
                    String json = StringUtils.remove(new String(bytes, "UTF-8"), '@');
                    EtlEventData data = JsonUtils.unmarshalFromString(json, EtlEventData.class);
                    stageStat.setNumber(data.getNumber());
                    stageStat.setSize(data.getSize());

                    Map exts = new HashMap();
                    if (!CollectionUtils.isEmpty(data.getExts())) {
                        exts.putAll(data.getExts());
                    }
                    exts.put("currNid", data.getCurrNid());
                    exts.put("nextNid", data.getNextNid());
                    exts.put("desc", data.getDesc());
                    stageStat.setExts(exts);
                }
                if (prev != null) {// start?
                    stageStat.setStartTime(prev.getEndTime());
                } else {
                    stageStat.setStartTime(zkProcessStat.getMtime()); // process?,select
                                                                      // await??USED?
                }
                stageStat.setEndTime(zkStat.getMtime());
                if (ArbitrateConstants.NODE_SELECTED.equals(stage)) {
                    stageStat.setStage(StageType.SELECT);
                } else if (ArbitrateConstants.NODE_EXTRACTED.equals(stage)) {
                    stageStat.setStage(StageType.EXTRACT);
                } else if (ArbitrateConstants.NODE_TRANSFORMED.equals(stage)) {
                    stageStat.setStage(StageType.TRANSFORM);
                    // } else if
                    // (ArbitrateConstants.NODE_LOADED.equals(stage)) {
                    // stageStat.setStage(StageType.LOAD);
                }

                prev = stageStat;
                stageStats.add(stageStat);
            }

            // ??
            StageStat currentStageStat = new StageStat();
            currentStageStat.setPipelineId(pipelineId);
            currentStageStat.setProcessId(processId);
            if (prev == null) {
                byte[] bytes = orginZk.getData(processPath, false, zkProcessStat);
                if (bytes == null || bytes.length == 0) {
                    continue; // 
                }

                ProcessNodeEventData nodeData = JsonUtils.unmarshalFromByte(bytes, ProcessNodeEventData.class);
                if (nodeData.getStatus().isUnUsed()) {// process,
                    continue; // process
                } else {
                    currentStageStat.setStage(StageType.SELECT);// select?
                    currentStageStat.setStartTime(zkProcessStat.getMtime());
                }
            } else {
                // ?stage
                StageType stage = prev.getStage();
                if (stage.isSelect()) {
                    currentStageStat.setStage(StageType.EXTRACT);
                } else if (stage.isExtract()) {
                    currentStageStat.setStage(StageType.TRANSFORM);
                } else if (stage.isTransform()) {
                    currentStageStat.setStage(StageType.LOAD);
                } else if (stage.isLoad()) {// ??
                    continue;
                }

                currentStageStat.setStartTime(prev.getEndTime());// ?
            }

            if (currentStageStat.getStage().isLoad()) {// loadprocess
                if (i == 0) {
                    stageStats.add(currentStageStat);
                }
            } else {
                stageStats.add(currentStageStat);// 
            }

        } catch (NoNodeException e) {
            // ignore
        } catch (KeeperException e) {
            throw new ArbitrateException(e);
        } catch (InterruptedException e) {
            // ignore
        } catch (UnsupportedEncodingException e) {
            // ignore
        }

        processStats.add(processStat);
    }

    return processStats;
}

From source file:com.CentrumGuy.CodWarfare.Main.java

private static String getFileVersion(String version) {
    version = StringUtils.remove(version, ThisPlugin.getPlugin().getName() + " v");
    version = StringUtils.remove(version, " ");
    return version;
}

From source file:de.hybris.platform.storefront.controllers.pages.checkout.steps.AbstractCheckoutStepController.java

protected void setCheckoutStepLinksForModel(final Model model, final CheckoutStep checkoutStep) {
    model.addAttribute("previousStepUrl", StringUtils.remove(checkoutStep.previousStep(), "redirect:"));
    model.addAttribute("nextStepUrl", StringUtils.remove(checkoutStep.nextStep(), "redirect:"));
    model.addAttribute("currentStepUrl", StringUtils.remove(checkoutStep.currentStep(), "redirect:"));
    model.addAttribute("progressBarId", checkoutStep.getProgressBarId());
}

From source file:hudson.maven.RedeployPublisherTest.java

@Test
public void testTarGzUniqueVersionTrue() throws Exception {
    j.configureDefaultMaven();/*from  ww w .  j a  va2 s.co m*/
    MavenModuleSet m2 = j.createMavenProject();
    File repo = tmp.getRoot();

    // a fake build
    m2.setScm(new SingleFileSCM("pom.xml", getClass().getResource("targz-artifact.pom")));
    m2.getPublishersList().add(new RedeployPublisher("", repo.toURI().toString(), true, false));

    MavenModuleSetBuild b = m2.scheduleBuild2(0).get();
    j.assertBuildStatus(Result.SUCCESS, b);

    File artifactDir = new File(repo, "test/test/0.1-SNAPSHOT/");
    String[] files = artifactDir.list(new FilenameFilter() {

        public boolean accept(File dir, String name) {
            System.out.print("deployed file " + name);
            return name.contains("-bin.tar.gz") || name.endsWith(".jar") || name.endsWith("-bin.zip");
        }
    });
    System.out.println("deployed files " + Arrays.asList(files));
    assertFalse("tar.gz doesn't exist",
            new File(repo, "test/test/0.1-SNAPSHOT/test-0.1-SNAPSHOT-bin.tar.gz").exists());
    assertTrue("tar.gz doesn't exist", !files[0].contains("SNAPSHOT"));
    for (String file : files) {
        if (file.endsWith("-bin.tar.gz")) {
            String ver = StringUtils.remove(file, "-bin.tar.gz");
            ver = ver.substring(ver.length() - 1, ver.length());
            assertEquals("-bin.tar.gz not ended with 1 , file " + file, "1", ver);
        }
        if (file.endsWith(".jar")) {
            String ver = StringUtils.remove(file, ".jar");
            ver = ver.substring(ver.length() - 1, ver.length());
            assertEquals(".jar not ended with 1 , file " + file, "1", ver);
        }
        if (file.endsWith("-bin.zip")) {
            String ver = StringUtils.remove(file, "-bin.zip");
            ver = ver.substring(ver.length() - 1, ver.length());
            assertEquals("-bin.zip not ended with 1 , file " + file, "1", ver);
        }
    }

}

From source file:com.mapr.ocr.text.ImageToText.java

public void startReadingFiles(String inputPath) {

    JavaPairRDD<String, PortableDataStream> readRDD = jsc.binaryFiles(inputPath);

    final StringBuilder resultText = new StringBuilder();

    readRDD.map(new Function<Tuple2<String, PortableDataStream>, String>() {
        @Override//from  w ww  .j  a v a2 s  .com
        public String call(Tuple2<String, PortableDataStream> pair) {
            LOGGER.log(Level.INFO, "Read File " + pair._2.getPath());
            LOGGER.log(Level.INFO, "PDF Document " + resultText);
            //Remove the file: prefix
            String fileName = StringUtils.remove(pair._2.getPath(), "maprfs://");

            processFile(StringUtils.remove(fileName, "file:"));
            return null;
        }
    }).collect();

}

From source file:de.hybris.platform.acceleratorfacades.urlencoder.impl.DefaultUrlEncoderFacade.java

@Override
public String calculateAndUpdateUrlEncodingData(final String uri, final String contextPath) {
    final List<UrlEncoderData> urlEncodingAttributes = getCurrentUrlEncodingData();
    final String[] splitUrl = StringUtils.split(uri, "/");
    int splitUrlCounter = (ArrayUtils.isNotEmpty(splitUrl)
            && (StringUtils.remove(contextPath, "/").equals(splitUrl[0]))) ? 1 : 0;

    final StringBuilder patternSb = new StringBuilder();
    for (final UrlEncoderData urlEncoderData : urlEncodingAttributes) {
        String tempValue = urlEncoderData.getCurrentValue();
        if ((splitUrlCounter) < splitUrl.length) {
            tempValue = splitUrl[splitUrlCounter];
            if (!isValid(urlEncoderData.getAttributeName(), tempValue)) {
                tempValue = urlEncoderData.getDefaultValue();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Encoding attributes are absent. Injecting default value :  [" + tempValue + "]");
                }/* www  . ja v a2 s.c  o m*/
            }
            urlEncoderData.setCurrentValue(tempValue);
            splitUrlCounter++;
        }

        if (patternSb.length() != 0) {
            patternSb.append('/');
        }
        patternSb.append(tempValue);

    }
    return patternSb.toString();
}

From source file:com.razorfish.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlWithoutReferer(final HttpServletRequest request) {
    final String referer = StringUtils.remove(request.getRequestURL().toString(), request.getServletPath());
    if (referer != null && !referer.isEmpty()) {
        return REDIRECT_PREFIX + referer;
    }/* w w w . j  a v  a2s .c o m*/
    return REDIRECT_PREFIX + '/';
}