List of usage examples for org.apache.commons.lang StringUtils substringAfterLast
public static String substringAfterLast(String str, String separator)
Gets the substring after the last occurrence of a separator.
From source file:info.magnolia.test.mock.jcr.MockSession.java
@Override public Property getProperty(String absPath) throws RepositoryException { Node node = getNode(StringUtils.substringBeforeLast(absPath, "/")); return node.getProperty(StringUtils.substringAfterLast(absPath, "/")); }
From source file:com.michelin.cio.hudson.plugins.copytoslave.MyFilePath.java
/** * Full copy/paste of Hudson's {@link FilePath#readFromTar} method with * some tweaking (mainly the flatten behavior). * * @see hudson.FilePath#readFromTar(java.lang.String, java.io.File, java.io.InputStream) *///from w w w. j a v a 2s .c om public static void readFromTar(File baseDir, boolean flatten, InputStream in) throws IOException { Chmod chmodTask = null; // HUDSON-8155 TarInputStream t = new TarInputStream(in); try { TarEntry tarEntry; while ((tarEntry = t.getNextEntry()) != null) { File f = null; if (!flatten || (!tarEntry.getName().contains("/") && !tarEntry.getName().contains("\\"))) { f = new File(baseDir, tarEntry.getName()); } else { String fileName = StringUtils.substringAfterLast(tarEntry.getName(), "/"); if (StringUtils.isBlank(fileName)) { fileName = StringUtils.substringAfterLast(tarEntry.getName(), "\\"); } f = new File(baseDir, fileName); } // dir processing if (!flatten && tarEntry.isDirectory()) { f.mkdirs(); } // file processing else { if (!flatten && f.getParentFile() != null) { f.getParentFile().mkdirs(); } IOUtils.copy(t, f); f.setLastModified(tarEntry.getModTime().getTime()); // chmod int mode = tarEntry.getMode() & 0777; if (mode != 0 && !Functions.isWindows()) // be defensive try { LIBC.chmod(f.getPath(), mode); } catch (NoClassDefFoundError ncdfe) { // be defensive. see http://www.nabble.com/-3.0.6--Site-copy-problem%3A-hudson.util.IOException2%3A--java.lang.NoClassDefFoundError%3A-Could-not-initialize-class--hudson.util.jna.GNUCLibrary-td23588879.html } catch (UnsatisfiedLinkError ule) { // HUDSON-8155: use Ant's chmod task if (chmodTask == null) { chmodTask = new Chmod(); } chmodTask.setProject(new Project()); chmodTask.setFile(f); chmodTask.setPerm(Integer.toOctalString(mode)); chmodTask.execute(); } } } } catch (IOException e) { throw new IOException2("Failed to extract to " + baseDir.getAbsolutePath(), e); } finally { t.close(); } }
From source file:cz.incad.kramerius.rest.api.k5.client.search.SearchResource.java
private void checkFieldSettings(String value) { List<String> filters = Arrays.asList(KConfiguration.getInstance().getAPISolrFilter()); String[] vals = value.split(","); for (String v : vals) { // remove field alias v = StringUtils.substringAfterLast(v, ":"); if (filters.contains(v)) throw new BadRequestException("requesting filtering field"); }// w w w. j ava 2 s . c o m }
From source file:info.magnolia.init.DefaultMagnoliaInitPaths.java
protected String determineWebappFolderName(String determinedRootPath, ServletContext context) { final String retroCompatMethodCall = magnoliaServletContextListener.initWebappName(determinedRootPath); if (retroCompatMethodCall != null) { DeprecationUtil.isDeprecated(//from w ww . j ava 2s.c o m "You should update your code and override determineWebappFolderName(String, ServletContext) instead of initWebappName(String)"); return retroCompatMethodCall; } return StringUtils.substringAfterLast(determinedRootPath, "/"); }
From source file:de.griffel.confluence.plugins.plantuml.type.ConfluenceLink.java
/** * Returns only the Blog title of this link (w/o the date string). * //ww w .j a v a 2s .c o m * If this link is not a Blog post, the result is undefined. * * @return only the Blog title of this link (w/o the date string). */ public String getBlogPostTitle() { return StringUtils.substringAfterLast(getPageTitle(), "/"); }
From source file:de.pdark.dsmp.RequestHandler.java
public File getPatchFile(URL url) { File dir = config.getPatchesDirectory(); File f = getCacheFile(url, dir); if (!f.exists()) { String ext = StringUtils.substringAfterLast(url.getPath(), ".").toLowerCase(); if ("md5".equals(ext) || "sha1".equals(ext)) { File source = new File(StringUtils.substringBeforeLast(f.getAbsolutePath(), ".")); if (source.exists()) { generateChecksum(source, f, ext); }/*from w ww . j av a 2 s . c o m*/ } } return f; }
From source file:br.usp.ime.lapessc.xflow2.core.VCSMiner.java
private List<Folder> getEntryFolders(CommitDTO dto) { List<Folder> folders = new ArrayList<Folder>(); for (FolderArtifactDTO folderDTO : dto.getFolderArtifacts()) { Folder folder = new Folder(); folder.setPath(folderDTO.getPath()); folder.setOperationType(folderDTO.getOperationType()); String folderName = StringUtils.substringAfterLast(folder.getPath(), "/"); folder.setName(folderName);//from www . jav a2s . co m folders.add(folder); } return folders; }
From source file:com.adobe.ac.pmd.rules.core.Violation.java
private String extractShortName(final String name) { return StringUtils.substringAfterLast(name, "."); }
From source file:info.magnolia.importexport.BootstrapUtil.java
/** * I.e. given a resource path like <code>/mgnl-bootstrap/foo/config.server.i18n.xml</code> and <code>.xml</code> extension it will return <code>config.server.i18n</code> (no trailing dot). * If extension is <code>null</code>, it defaults to <code>.xml</code>. *///from w w w .java 2 s . com public static String getFilenameFromResource(final String resourcePath, final String extension) { String ext = StringUtils.defaultIfEmpty(extension, ".xml"); String tmpResourcePath = resourcePath; if (resourcePath.contains("/")) { tmpResourcePath = StringUtils.substringAfterLast(resourcePath, "/"); } return StringUtils.removeEnd(tmpResourcePath, ext.startsWith(".") ? ext : "." + ext); }
From source file:eu.annocultor.converters.time.OntologyToHtmlGenerator.java
String makeTermDefinitionFile(RepositoryConnection connection, ValueFactory factory, StringInStack url) throws RepositoryException, FileNotFoundException, IOException { List<String> term = new ArrayList<String>(); term.add(//from w ww . jav a2 s .c om "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); term.add("<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"); term.add("<head>"); term.add("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"); term.add("<link rel=\"stylesheet\" href=\"terms.css\" type=\"text/css\" />"); List<String> pref = collectLabels(connection, factory, Concepts.SKOS.LABEL_PREFERRED.getUri(), url); List<String> alt = collectLabels(connection, factory, Concepts.SKOS.LABEL_ALT.getUri(), url); List<String> beginDate = collectLabels(connection, factory, Concepts.ANNOCULTOR.DATE_BEGIN.getUri(), url); List<String> endDate = collectLabels(connection, factory, Concepts.ANNOCULTOR.DATE_END.getUri(), url); String prefLabel = null; if (!pref.isEmpty()) { prefLabel = StringUtils.join(pref.toArray(), ", "); } if (prefLabel == null && !alt.isEmpty()) { prefLabel = alt.get(0); } if (prefLabel == null) { prefLabel = "Time"; } term.add("<title>" + prefLabel + "</title>"); term.add("</head>"); term.add("<body>"); term.add("<p><a href=\"http://annocultor.eu/\">Back to AnnoCultor</a></p>"); formatLabels(term, pref, alt); formatDates(term, beginDate, endDate); term.add("</body>"); term.add("</html>"); FileOutputStream os = new FileOutputStream( new File(outputDir, StringUtils.substringAfterLast(url.getString(), "/"))); IOUtils.writeLines(term, "\n", os, "UTF-8"); os.close(); return prefLabel; }