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

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

Introduction

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

Prototype

public static String substringAfter(String str, String separator) 

Source Link

Document

Gets the substring after the first occurrence of a separator.

Usage

From source file:com.btobits.automator.fix.comparator.MailComparator.java

public static final String getFixField(final String inName, final SMTPMessage inSmtpMessage) {
    final List<Object> lines = inSmtpMessage.getDataLines();
    int index = 0;
    final String header = inName;
    for (final Object obj : lines) {
        final String val = (String) obj;
        if (!StringUtils.isBlank(val)) {
            if (StringUtils.startsWith(val, header)) {
                break;
            }/*from   w ww .jav a2  s  .  com*/
        }
        index++;
    }

    if (index == lines.size()) {
        return null;
    }

    final StringBuilder sb = new StringBuilder();
    for (int i = index; i < lines.size(); i++) {
        final String line = lines.get(i) + "";
        if (i == index) {
            sb.append(StringUtils.substringAfter(line, header));
        } else {
            if (StringUtils.isBlank(line)) {
                break; // end email message
            }
            sb.append(line.trim());
        }
    }

    return sb.toString().replaceAll("/u0001", "\u0001");
}

From source file:ips1ap101.lib.core.util.JS.java

public static String getOpenWindowJavaScript(String url, String rpl, String window, String session) {
    if (url == null) {
        return null;
    }//from w  w  w  .  j a  v  a2  s.c o  m
    if (StringUtils.isNotBlank(rpl)) {
        AbstractPageBean paginaActual = ThreadContext.getPaginaActual();
        if (paginaActual instanceof PaginaBasica) {
            String opcionCampoRetorno = null;
            String dominioRetorno = null;
            String[] tokens = StringUtils.split(rpl, "?&");
            for (String token : tokens) {
                if (token != null) {
                    if (token.startsWith(CPP.ID_OPCION_CAMPO_RETORNO + "=")) {
                        opcionCampoRetorno = StringUtils.substringAfter(token, "=");
                    }
                    if (token.startsWith(CPP.ID_DOMINIO_RETORNO + "=")) {
                        dominioRetorno = StringUtils.substringAfter(token, "=");
                    }
                }
            }
            if (opcionCampoRetorno != null) {
                PaginaBasica paginaBasica = (PaginaBasica) paginaActual;
                paginaBasica.getContextoSesion().setValorRetorno(opcionCampoRetorno, dominioRetorno, null);
            }
        }
    }
    String ventana = StringUtils.isBlank(window) ? Global.DEFAULT_WINDOW_NAME : window;
    VelocityContext context = new VelocityContext();
    context.put("url", StringUtils.trimToNull(url));
    context.put("rpl", StringUtils.trimToNull(rpl));
    context.put("window", StringUtils.trimToNull(ventana));
    context.put("sesion", StringUtils.trimToNull(session));
    return merge("js-open-window", context);
}

From source file:info.magnolia.jcr.wrapper.InheritanceNodeWrapper.java

/**
 * Returns the inner path of the this node up to the anchor.
 *//*from   w  w  w .  j a v  a2 s.  co m*/
protected String resolveInnerPath() throws RepositoryException {
    final String path;
    InheritanceNodeWrapper anchor = findAnchor();
    // if no anchor left we are relative to the root
    if (anchor == null) {
        path = this.getPath();
    } else {
        path = StringUtils.substringAfter(this.getPath(), anchor.getPath());
    }
    return StringUtils.removeStart(path, "/");
}

From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.TaskHealthCachingAgent.java

@Override
protected List<TaskHealth> getItems(AmazonECS ecs, ProviderCache providerCache) {
    TaskCacheClient taskCacheClient = new TaskCacheClient(providerCache, objectMapper);
    ServiceCacheClient serviceCacheClient = new ServiceCacheClient(providerCache, objectMapper);

    AmazonElasticLoadBalancing amazonloadBalancing = amazonClientProvider
            .getAmazonElasticLoadBalancingV2(account, region, false);

    ContainerInstanceCacheClient containerInstanceCacheClient = new ContainerInstanceCacheClient(providerCache);

    List<TaskHealth> taskHealthList = new LinkedList<>();
    taskEvicitions = new LinkedList<>();
    serviceEvicitions = new LinkedList<>();
    taskDefEvicitions = new LinkedList<>();

    Collection<Task> tasks = taskCacheClient.getAll(accountName, region);
    if (tasks != null) {
        for (Task task : tasks) {
            String containerInstanceCacheKey = Keys.getContainerInstanceKey(accountName, region,
                    task.getContainerInstanceArn());
            ContainerInstance containerInstance = containerInstanceCacheClient.get(containerInstanceCacheKey);

            String serviceName = StringUtils.substringAfter(task.getGroup(), "service:");
            String serviceKey = Keys.getServiceKey(accountName, region, serviceName);
            Service service = serviceCacheClient.get(serviceKey);
            if (service == null) {
                String taskEvictionKey = Keys.getTaskKey(accountName, region, task.getTaskId());
                taskEvicitions.add(taskEvictionKey);
                continue;
            }/*from  w ww  .  j a  v a 2 s .com*/

            if (task.getContainers().size() == 0 || task.getContainers().get(0).getNetworkBindings() == null
                    || task.getContainers().get(0).getNetworkBindings().size() == 0
                    || task.getContainers().get(0).getNetworkBindings().get(0) == null) {
                continue;
            }

            int port = task.getContainers().get(0).getNetworkBindings().get(0).getHostPort();

            List<LoadBalancer> loadBalancers = service.getLoadBalancers();

            for (LoadBalancer loadBalancer : loadBalancers) {
                if (loadBalancer.getTargetGroupArn() == null || containerInstance.getEc2InstanceId() == null) {
                    continue;
                }

                DescribeTargetHealthResult describeTargetHealthResult;
                describeTargetHealthResult = amazonloadBalancing.describeTargetHealth(
                        new DescribeTargetHealthRequest().withTargetGroupArn(loadBalancer.getTargetGroupArn())
                                .withTargets(new TargetDescription()
                                        .withId(containerInstance.getEc2InstanceId()).withPort(port)));

                if (describeTargetHealthResult.getTargetHealthDescriptions().size() == 0) {
                    String serviceEvictionKey = Keys.getTaskDefinitionKey(accountName, region,
                            service.getServiceName());
                    serviceEvicitions.add(serviceEvictionKey);
                    String taskEvictionKey = Keys.getTaskKey(accountName, region, task.getTaskId());
                    taskEvicitions.add(taskEvictionKey);

                    String taskDefArn = service.getTaskDefinition();
                    String taskDefKey = Keys.getTaskDefinitionKey(accountName, region, taskDefArn);
                    taskDefEvicitions.add(taskDefKey);
                    continue;
                }

                String targetHealth = describeTargetHealthResult.getTargetHealthDescriptions().get(0)
                        .getTargetHealth().getState();
                // TODO - Return better values, and think of a better strategy at defining health
                targetHealth = targetHealth.equals("healthy") ? "Up" : "Unknown";

                TaskHealth taskHealth = new TaskHealth();
                taskHealth.setType("loadBalancer");
                taskHealth.setState(targetHealth);
                taskHealth.setServiceName(serviceName);
                taskHealth.setTaskId(task.getTaskId());
                taskHealth.setTaskArn(task.getTaskArn());
                taskHealth.setInstanceId(task.getTaskArn());

                taskHealthList.add(taskHealth);
            }
        }
    }

    return taskHealthList;
}

From source file:com.baoqilai.core.util.WebUtils.java

/**
 * ?contentTypeheaders.//from  w w  w  .  java 2 s.co m
 */
private static HttpServletResponse initResponseHeader(final String contentType, final String... headers) {
    // ?headers?
    String encoding = DEFAULT_ENCODING;
    boolean noCache = DEFAULT_NOCACHE;
    for (String header : headers) {
        String headerName = StringUtils.substringBefore(header, ":");
        String headerValue = StringUtils.substringAfter(header, ":");

        if (StringUtils.equalsIgnoreCase(headerName, HEADER_ENCODING)) {
            encoding = headerValue;
        } else if (StringUtils.equalsIgnoreCase(headerName, HEADER_NOCACHE)) {
            noCache = Boolean.parseBoolean(headerValue);
        } else {
            throw new IllegalArgumentException(headerName + "??header");
        }
    }

    HttpServletResponse response = ServletActionContext.getResponse();

    // headers?
    String fullContentType = contentType + ";charset=" + encoding;
    response.setContentType(fullContentType);
    if (noCache) {
        setDisableCacheHeader(response);
    }

    return response;
}

From source file:com.googlecode.jtiger.modules.ecside.table.limit.AbstractLimitFactory.java

public Map getSortedOrFilteredParameters(String parameter) {
    Map subset = new HashMap();

    String find = prefixWithTableId + parameter;

    Set set = registry.getParameterMap().keySet();
    for (Iterator iter = set.iterator(); iter.hasNext();) {
        String key = (String) iter.next();
        if (key.startsWith(find)) {
            String value = registry.getParameter(key);
            if (StringUtils.isNotBlank(value)) {
                String propertyOrAlias = StringUtils.substringAfter(key, find);
                subset.put(propertyOrAlias, value);
            }//w w  w  .ja  v  a 2s .  c om
        }
    }

    return subset;
}

From source file:com.opengamma.component.factory.engine.EngineConfigurationComponentFactory.java

protected void buildConfiguration(final ComponentRepository repo, final Map<String, String> configuration,
        final Map<String, Object> map) {
    map.put(LOGICAL_SERVER_UNIQUE_IDENTIFIER, getLogicalServerId());
    for (final String key : configuration.keySet()) {
        final String valueStr = configuration.get(key);
        Object targetValue = valueStr;
        if (valueStr.contains("::")) {
            final String type = StringUtils.substringBefore(valueStr, "::");
            final String classifier = StringUtils.substringAfter(valueStr, "::");
            final ComponentInfo info = repo.findInfo(type, classifier);
            if (info == null) {
                throw new IllegalArgumentException("Component not found: " + valueStr);
            }//from   ww  w . j a va2s  .c o  m
            final Object instance = repo.getInstance(info);
            if ((instance instanceof CalcNodeSocketConfiguration) || (instance instanceof Supplier)) {
                targetValue = instance;
            } else {
                if (info.getUri() == null) {
                    throw new OpenGammaRuntimeException(
                            "Unable to add component to configuration as it has not been published by REST: "
                                    + valueStr);
                }
                targetValue = new UriEndPointDescriptionProvider(info.getUri().toString());
            }
        }
        buildMap(map, key, targetValue);
    }
}

From source file:fr.dutra.tools.maven.deptree.extras.VelocityRenderer.java

protected void copyResources() throws IOException {
    String staticPath = staticDir.getAbsolutePath();
    final Collection<File> files = getFilesToCopy();
    final byte data[] = new byte[2048];
    for (final File src : files) {
        InputStream is = null;//www . j  a v a  2  s  .  com
        FileOutputStream fos = null;
        try {
            is = new FileInputStream(src);
            String relativePath = StringUtils.substringAfter(src.getAbsolutePath(), staticPath);
            final File dest = new File(getOutputDir(), relativePath);
            final File parentFile = dest.getParentFile();
            parentFile.mkdirs();
            fos = new FileOutputStream(dest);
            int count;
            while ((count = is.read(data, 0, 2048)) != -1) {
                fos.write(data, 0, count);
            }
            fos.flush();
        } finally {
            if (fos != null) {
                fos.close();
            }
            if (is != null) {
                is.close();
            }
        }
    }
}

From source file:com.adguard.compiler.LocaleUtils.java

private static String findMessage(String[] messages, String key) {
    for (String message : messages) {
        if (message.startsWith(key + "=")) {
            return StringUtils.substringAfter(message, key + "=");
        }/*  w  w w.  j  ava 2  s.  c  om*/
    }
    throw new IllegalStateException("Can't find message " + key);
}

From source file:com.cndatacom.core.orm.PropertyFilter.java

public String getHqltemp(String filterName) {
    if (filterName.split(LEFT_JION).length > 1) {
        tempJion = StringUtils.substringAfter(filterName, LEFT_JION);
    }//from   w w  w . ja v a  2  s. com

    return tempJion;

}