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.importexport.PropertiesImportExport.java
public void createContent(Content root, InputStream propertiesStream) throws IOException, RepositoryException { Properties properties = new OrderedProperties(); properties.load(propertiesStream);//ww w.jav a 2s . com properties = keysToInnerFormat(properties); for (Object o : properties.keySet()) { String key = (String) o; String valueStr = properties.getProperty(key); String propertyName = StringUtils.substringAfterLast(key, "."); String path = StringUtils.substringBeforeLast(key, "."); String type = null; if (propertyName.equals("@type")) { type = valueStr; } else if (properties.containsKey(path + ".@type")) { type = properties.getProperty(path + ".@type"); } type = StringUtils.defaultIfEmpty(type, ItemType.CONTENTNODE.getSystemName()); Content c = ContentUtil.createPath(root, path, new ItemType(type)); populateContent(c, propertyName, valueStr); } }
From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.EcsClusterCachingAgent.java
public static Map<String, Object> convertClusterArnToAttributes(String accountName, String region, String clusterArn) {/*from w w w. j a v a 2 s . co m*/ String clusterName = StringUtils.substringAfterLast(clusterArn, "/"); Map<String, Object> attributes = new HashMap<>(); attributes.put("account", accountName); attributes.put("region", region); attributes.put("clusterName", clusterName); attributes.put("clusterArn", clusterArn); return attributes; }
From source file:com.echosource.ada.core.AdaFile.java
/** * Returns a AdaFile if the given file is a php file and can be found in the given directories. This instance will be initialized with * inferred attribute values/* ww w .j a va2s . c o m*/ * * @param file * the file to load * @param isUnitTest * if <code>true</code> the given resource will be marked as a unit test, otherwise it will be marked has a class * @param dirs * the dirs * @return the php file */ public static AdaFile fromIOFile(File file, List<File> dirs, boolean isUnitTest) { // If the file has a valid suffix if (file == null || !Ada.INSTANCE.hasValidSuffixes(file.getName())) { return null; } String relativePath = DefaultProjectFileSystem.getRelativePath(file, dirs); // and can be found in the given directories if (relativePath != null) { String packageName = null; String className = relativePath; if (relativePath.indexOf('/') >= 0) { packageName = StringUtils.substringBeforeLast(relativePath, PATH_SEPARATOR); packageName = StringUtils.replace(packageName, PATH_SEPARATOR, PACKAGE_SEPARATOR); className = StringUtils.substringAfterLast(relativePath, PATH_SEPARATOR); } String extension = PACKAGE_SEPARATOR + StringUtils.substringAfterLast(className, PACKAGE_SEPARATOR); // className = StringUtils.substringBeforeLast(className, PACKAGE_SEPARATOR); return new AdaFile(packageName, className, extension, isUnitTest); } return null; }
From source file:au.edu.anu.portal.portlets.rss.FeedParser.java
/** * Parses the entries contained in an RSS feed, extracts the enclosures, converts them to an {@link Attachment} * adds them to the map with the entry uri as key. * <p>The RSS spec says there is only one enclosure per item so this is what we work with. We don't actually check this so it's possible * that if you have more than one enclosure attached to an item that only the latest one will be presented in the end. * * @param feed/*from w w w .j a v a 2 s .c o m*/ * @return */ public static Map<String, Attachment> parseFeedEnclosures(SyndFeed feed) { Map<String, Attachment> attachments = new HashMap<String, Attachment>(); // image mime types that are ok to be rendered as an image List<String> imageTypes = new ArrayList<String>(); imageTypes.add("image/jpeg"); imageTypes.add("image/gif"); imageTypes.add("image/png"); imageTypes.add("image/jpg"); List<SyndEntry> entries = feed.getEntries(); for (SyndEntry entry : entries) { //get entry uri, but it could be blank so if so, skip this item if (StringUtils.isBlank(entry.getUri())) { continue; } //for each enclosure attached to an entry get the first one and use that. List<SyndEnclosure> enclosures = entry.getEnclosures(); for (SyndEnclosure e : enclosures) { //convert to an Attachment Attachment a = new Attachment(); a.setUrl(e.getUrl()); a.setDisplayLength(formatLength(e.getLength())); a.setType(e.getType()); //process the url into a displayname (get just the filename from the full URL) String displayName = StringUtils.substringAfterLast(e.getUrl(), "/"); if (StringUtils.isNotBlank(displayName)) { a.setDisplayName(displayName); } else { a.setDisplayName(Messages.getString("view.attachment.default")); } //check if its an iamge we are able to display as the thumbnail for the entry if (imageTypes.contains(e.getType())) { a.setImage(true); } attachments.put(entry.getUri(), a); } } return attachments; }
From source file:com.adobe.ac.pmd.rules.architecture.UseInternalClassOutsideApiClass.java
private String extractFunctionArea(final String packageName, final String visibilityPackageName, final boolean isInImport) { return StringUtils.substringAfterLast( StringUtils.substringBeforeLast(packageName, PACKAGE_SEPARATOR + visibilityPackageName + (isInImport ? PACKAGE_SEPARATOR : "")), PACKAGE_SEPARATOR);// w ww . ja va2 s .co m }
From source file:eu.annocultor.path.Path.java
/** * Enforces a new namespace./*from w w w. j a v a 2 s .com*/ * * @param pathOne * @param pathTwo * @return */ public static Path changeNamespace(Namespace ns, Path path) throws Exception { Path newPath = new Path(); for (PathElement pe : path) { String expanded = pe.getExpanded(); String nsPrefix = StringUtils.substringAfterLast(expanded, "/"); if (expanded.contains("#")) { nsPrefix = StringUtils.substringAfterLast(expanded, "#"); } if (StringUtils.isBlank(nsPrefix)) { nsPrefix = expanded; } newPath.add(new PathElement(nsPrefix, ns.getUri(), null)); } newPath.updateCachedRepresentations(); return newPath; }
From source file:com.googlesource.gerrit.plugins.github.oauth.OAuthFilter.java
private boolean isStaticResource(HttpServletRequest httpRequest) { String pathExt = StringUtils.substringAfterLast(httpRequest.getRequestURI(), "."); if (StringUtils.isEmpty(pathExt)) { return false; }//from w w w . ja va 2s.c o m return GERRIT_STATIC_RESOURCES_EXTS.contains(pathExt.toLowerCase()); }
From source file:com.netflix.spinnaker.clouddriver.ecs.provider.agent.EcsClusterCachingAgent.java
@Override protected Map<String, Collection<CacheData>> generateFreshData(Collection<String> clusterArns) { Collection<CacheData> dataPoints = new LinkedList<>(); for (String clusterArn : clusterArns) { String clusterName = StringUtils.substringAfterLast(clusterArn, "/"); Map<String, Object> attributes = convertClusterArnToAttributes(accountName, region, clusterArn); String key = Keys.getClusterKey(accountName, region, clusterName); dataPoints.add(new DefaultCacheData(key, attributes, Collections.emptyMap())); }//w w w .j a v a 2 s.c om log.info("Caching " + dataPoints.size() + " ECS clusters in " + getAgentType()); Map<String, Collection<CacheData>> dataMap = new HashMap<>(); dataMap.put(ECS_CLUSTERS.toString(), dataPoints); return dataMap; }
From source file:com.adobe.acs.commons.mcp.impl.processes.renovator.MovingFolder.java
private void createMissingTargetFolders(ResourceResolver rr, Resource source) throws RepositoryException, PersistenceException, MovingException { if (!resourceExists(rr, getDestinationPath())) { Actions.setCurrentItem(getSourcePath() + "->" + getDestinationPath()); String targetParentPath = StringUtils.substringBeforeLast(getDestinationPath(), "/"); String targetName = StringUtils.substringAfterLast(getDestinationPath(), "/"); if (getParent() == null) { if (!resourceExists(rr, getDestinationPath())) { createFolderNode(targetParentPath, rr); }/*from w ww.j ava 2 s . c o m*/ } else { waitUntilResourceFound(rr, targetParentPath); } Resource destParent = rr.getResource(targetParentPath); Logger.getLogger(MovingFolder.class.getName()).log(Level.INFO, "Creating target for {0}", getSourcePath()); rr.create(destParent, targetName, getClonedProperties(source)); rr.commit(); rr.refresh(); } }
From source file:com.ewcms.content.resource.service.ResourceService.java
/** * ???/* ww w . ja v a 2 s . c o m*/ * * @param name ?? * @return */ String getSuffix(String name) { if (StringUtils.contains(name, ".")) { return StringUtils.substringAfterLast(name, "."); } else { return ""; } }