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:eionet.cr.util.FolderUtil.java

/**
 * Returns the path after the special folder. For example if uri is "http://127.0.0.1:8080/cr/project/newFolder/newFile.txt" the
 * result is "newFolder/newFile.txt"./*from  www  .j  a v a2 s. co m*/
 *
 * @param uri
 * @param mainFolder special main folder name
 * @return String
 */
public static String extractPathInSpecialFolder(String uri, String mainFolder) {

    String result = null;
    String appHome = GeneralConfig.getRequiredProperty(GeneralConfig.APPLICATION_HOME_URL);
    if (uri.startsWith(appHome + "/" + mainFolder + "/")) {
        result = StringUtils.substringAfter(uri, appHome + "/" + mainFolder + "/");
    }
    return result;
}

From source file:com.hangum.tadpole.rdb.core.editors.main.function.MainEditorBrowserFunctionService.java

@Override
protected void f4DMLOpen(Object[] arguments) {
    String strObject = parseLastObject((String) arguments[1]);
    if (StringUtils.contains(strObject, "."))
        strObject = StringUtils.substringAfter(strObject, ".");
    if (logger.isDebugEnabled())
        logger.debug("select editor content is '" + strObject + "'");

    DialogUtil.popupDMLDialog(editor.getUserDB(), strObject);
}

From source file:eu.annocultor.tagger.server.controllers.SolrTaggerController.java

private List<String[]> readFile(String url) throws IOException {
    FileInputStream fStream = new FileInputStream(new File(url));
    StringBuffer sb = new StringBuffer();
    BufferedInputStream bin = new BufferedInputStream(fStream);
    byte[] contents = new byte[1024];
    int bytesRead = 0;
    while ((bytesRead = bin.read(contents)) != -1) {
        sb.append(new String(contents, 0, bytesRead));
    }/*w ww. jav  a2 s .co  m*/
    String toImport = StringUtils.substringBetween(sb.toString(), "Import\n", "Delete\n");
    List<String[]> collections = new ArrayList<String[]>();
    String[] collectionsToImport = StringUtils.split(toImport, "\n");
    collections.add(collectionsToImport);
    String toDelete = StringUtils.substringAfter(sb.toString(), "Delete\n");
    String[] collectionsToDelete = StringUtils.split(toDelete, "\n");
    collections.add(collectionsToDelete);
    return collections;
}

From source file:fr.dutra.confluence2wordpress.core.metadata.DefaultMetadataManager.java

public Metadata createMetadata(ContentEntityObject page, Set<WordpressUser> users,
        Set<WordpressCategory> categories) {
    Metadata metadata = new Metadata();
    String pageTitle = page.getTitle();
    Matcher matcher = DRAFT_PREFIX_PATTERN.matcher(pageTitle);
    if (matcher.matches()) {
        String prefix = matcher.group(1);
        metadata.setPageTitle(StringUtils.substringAfter(pageTitle, prefix));
    } else {/*from w  w  w . j  a v  a2  s . c om*/
        metadata.setPageTitle(pageTitle);
    }
    if (StringUtils.containsIgnoreCase(metadata.getPageTitle(), RDP_CATEGORY_NAME)) {
        metadata.setPageTitle(RDP_PAGE_TITLE); // to normalize the title
        if (categories != null) {
            for (WordpressCategory category : categories) {
                if (StringUtils.containsIgnoreCase(category.getCategoryName(), RDP_CATEGORY_NAME)) {
                    metadata.setCategoryNames(Collections.singletonList(category.getCategoryName()));
                    break;
                }
            }
        }
        Calendar now = Calendar.getInstance();
        metadata.setPostSlug(
                String.format(RDP_POST_SLUG_FORMAT, now.getTime(), now.get(Calendar.WEEK_OF_YEAR)));
        if (users != null) {
            for (WordpressUser user : users) {
                if (XEBIA_FRANCE_LOGIN.equals(user.getLogin())) {
                    metadata.setAuthorId(user.getId());
                    break;
                }
            }
        }
    } else {
        String creatorName = page.getCreatorName();
        if (creatorName != null && users != null) {
            for (WordpressUser wordpressUser : users) {
                if (creatorName.equals(wordpressUser.getLogin())) {
                    metadata.setAuthorId(wordpressUser.getId());
                    break;
                }
            }
        }
    }
    return metadata;
}

From source file:com.hangum.tadpole.mongodb.erd.core.dnd.TableTransferDropTargetListener.java

@Override
protected void handleDrop() {
    String strDragSource = (String) getCurrentEvent().data;
    try {//  w  ww.j  a va2  s  .com
        String[] arrayDragSourceData = StringUtils.splitByWholeSeparator(strDragSource,
                PublicTadpoleDefine.DELIMITER);

        int sourceDBSeq = Integer.parseInt(arrayDragSourceData[0]);
        if (userDB.getSeq() != sourceDBSeq) {
            MessageDialog.openWarning(null, Messages.get().Warning,
                    Messages.get().TableTransferDropTargetListener_1); //$NON-NLS-1$
            return;
        }
    } catch (Exception e) {
        logger.error("dragger error", e); //$NON-NLS-1$
        MessageDialog.openError(null, Messages.get().Error, "Draging exception : " + e.getMessage()); //$NON-NLS-1$
        return;
    }

    final int nextTableX = getDropLocation().x;
    final int nextTableY = getDropLocation().y;

    final String strFullData = StringUtils.substringAfter(strDragSource, PublicTadpoleDefine.DELIMITER);
    final String[] arryTables = StringUtils.splitByWholeSeparator(strFullData,
            PublicTadpoleDefine.DELIMITER_DBL);
    final Map<String, List<CollectionFieldDAO>> mapTable = new HashMap<>();

    Job job = new Job("Painting model") {
        @Override
        public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Painting table object", IProgressMonitor.UNKNOWN);

            try {
                for (int i = 0; i < arryTables.length; i++) {
                    String strTable = arryTables[i];
                    monitor.subTask(String.format("Working %s/%s", i, arryTables.length));
                    String[] arryTable = StringUtils.splitByWholeSeparator(strTable,
                            PublicTadpoleDefine.DELIMITER);
                    if (arryTable.length == 0)
                        continue;

                    String tableName = arryTable[IDX_TABLE_NAME];
                    mapTable.put(tableName, getColumns(tableName));
                }

            } catch (Exception e) {
                logger.error("ERD Initialize excepiton", e);

                return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
                monitor.done();
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            return Status.OK_STATUS;
        }
    };

    // job? event  ?.
    job.addJobChangeListener(new JobChangeAdapter() {
        public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;
            Display display = mongoEditor.getEditorSite().getShell().getDisplay();
            display.syncExec(new Runnable() {
                public void run() {

                    if (jobEvent.getResult().isOK()) {
                        paintingModel(nextTableX, nextTableY, arryTables, mapTable);
                    } else {
                        MessageDialog.openError(null, Messages.get().Confirm,
                                jobEvent.getResult().getMessage());
                    }
                }
            }); // end display.asyncExec
        } // end done

    }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();

    //      super.handleDrop();
}

From source file:cn.newtouch.util.Struts2Utils.java

/**
 * ?contentTypeheaders.//from w ww.j  a  va 2s.  com
 */
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) {
        ServletUtils.setDisableCacheHeader(response);
    }

    return response;
}

From source file:com.adobe.ac.pmd.engines.AbstractFlexPmdEngine.java

private String getReportType() {
    return StringUtils.substringBefore(StringUtils.substringAfter(getClass().getName(), "FlexPmd"), "Engine");
}

From source file:info.magnolia.cms.util.InheritanceContentWrapper.java

/**
 * Returns the inner path of the this node up to the anchor.
 *///from ww w .j a  va2  s  .c  om
protected String resolveInnerPath() throws RepositoryException {
    final String path;
    InheritanceContentWrapper anchor = findAnchor();
    // if no anchor left we are relative to the root
    if (anchor == null) {
        path = this.getHandle();
    } else {
        path = StringUtils.substringAfter(this.getHandle(), anchor.getHandle());
    }
    return StringUtils.removeStart(path, "/");
}

From source file:com.shallop.codedrill.common.web.struts2.Struts2Utils.java

/**
 * ?contentTypeheaders.//www. jav  a2s .com
 */
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();
    HttpServletResponse response = null;

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

    return response;
}

From source file:net.itransformers.toplogyviewer.gui.neo4j.Neo4jLoader.java

public void getNeighbourVertexes(String networkNodeId) {
    String query = "start network=node(" + networkNodeId
            + ") match network-->device-->interface-->neighbor where device.objectType='Node' and neighbor.objectType='DiscoveredNeighbor' return device.name, interface.name, neighbor.name, neighbor.Reachable?, neighbor.SNMPCommunity?,neighbor.DiscoveryMethod?,neighbor.LocalIPAddress?,neighbor.NeighborIPAddress?,neighbor.NeighborHostname?,neighbor.NeighborDeviceType?";
    String params = "";
    String output = executeCypherQuery(query, params);
    JSONObject json = null;//from  w w  w . j  a v a  2 s. co m
    try {
        json = (JSONObject) new JSONParser().parse(output);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    JSONArray data = (JSONArray) json.get("data");
    JSONArray columns = (JSONArray) json.get("columns");

    HashMap<String, HashMap<String, String>> neighborMap = new HashMap<String, HashMap<String, String>>();

    Iterator dataIter = data.iterator();
    while (dataIter.hasNext()) {
        JSONArray temp = (JSONArray) dataIter.next();
        Iterator tempIter = temp.iterator();
        Iterator columnsIter = columns.iterator();
        String neighborName = null;
        String deviceName = null;
        String interfaceName = null;
        String edgeName = null;
        //        HashMap<String, GraphMLMetadata<String>> nodeMetaData = new HashMap<String, GraphMLMetadata<String>>();
        HashMap<String, GraphMLMetadata<String>> nodePropertiesMap = new HashMap<String, GraphMLMetadata<String>>();
        HashMap<String, GraphMLMetadata<String>> graphMLPropertiesMap = new HashMap<String, GraphMLMetadata<String>>();
        while (tempIter.hasNext() & columnsIter.hasNext()) {

            String column = columnsIter.next().toString();

            String keyNodeProperty = (String) tempIter.next();

            String columnsValue = null;
            if (column.contains("neighbor.")) {
                columnsValue = StringUtils.replace(StringUtils.substringAfter(column, "neighbor."), "%20", " ");
            } else {
                columnsValue = column;
            }
            if (columnsValue.equals("device.name")) {
                deviceName = keyNodeProperty;

            } else if (columnsValue.equals("interface.name")) {
                interfaceName = keyNodeProperty;
            } else if (columnsValue.equals("name")) {

                neighborName = keyNodeProperty;
                nodePropertiesMap.put(neighborName, null);

            } else {
                if (keyNodeProperty == null) {
                    keyNodeProperty = "";
                } else if (keyNodeProperty.equals("emptyValue")) {
                    keyNodeProperty = "";
                }
                HashMap<String, String> transformerValue = new HashMap<String, String>();
                transformerValue.put(neighborName, keyNodeProperty);
                MapSettableTransformer<String, String> transfrmer = new MapSettableTransformer<String, String>(
                        transformerValue);

                GraphMLMetadata<String> t = new GraphMLMetadata<String>(null, null, transfrmer);
                nodePropertiesMap.put(columnsValue, t);

            }

        }
        String[] tempArray = { deviceName, neighborName };
        Arrays.sort(tempArray);
        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < tempArray.length; i++) {
            builder.append(tempArray[i]);
        }
        edgeName = builder.toString();
        Pair<String> endpoints = new Pair<String>(deviceName, neighborName);
        //Bogon filter
        if ((neighborName != null) && !entireGraph.containsVertex(neighborName) && (neighborName != "0.0.0.0")
                && !(StringUtils.contains(neighborName, "128.") || StringUtils.contains(neighborName, "127.")
                        || StringUtils.contains(neighborName, "169.254.")
                        || StringUtils.contains(neighborName, "0."))) {
            entireGraph.addVertex(neighborName);
            vertexMetadatas.put(neighborName, nodePropertiesMap);
            graphMetadatas.put(neighborName, graphMLPropertiesMap);

        }
        if (!entireGraph.containsEdge(edgeName)) {

            entireGraph.addEdge(edgeName, endpoints);
        }

    }

}