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:com.continuent.tungsten.common.commands.DirectoryCommands.java
/** * Returns a listing of files in a directory matching a pattern. * //from w w w . j a va 2 s. c o m * @param directoryPath the directory to get a file listing of; * listingPattern the pattern to search for in the file listing * @return the contents of the directory that match the pattern */ public static List<String> fileList(String directoryPath, boolean includeFullPath) { List<String> fileList = new ArrayList<String>(); String dir = directoryPath.substring(0, directoryPath.lastIndexOf(File.separator)); String pattern = StringUtils.substringAfterLast(directoryPath, File.separator); File directory = new File(dir); if (directory.isDirectory()) { File[] files = directory.listFiles(); for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isFile()) { String fileName = f.getName(); String fullPath = dir + File.separator + fileName; // CONT-93 // The list of files is coming from the directoryPath, we only need to check the pattern against the filename. if (fileName.matches(convertGlobToRegEx(pattern))) { if (includeFullPath) { fileList.add(fullPath); } else { fileList.add(fileName); } } } } } return fileList; }
From source file:eu.europa.esig.dss.applet.wizard.signature.SaveStep.java
private File prepareTargetFileName(final File file, final SignaturePackaging signaturePackaging, final String signatureLevel) { final File parentDir = file.getParentFile(); final String originalName = StringUtils.substringBeforeLast(file.getName(), "."); final String originalExtension = "." + StringUtils.substringAfterLast(file.getName(), "."); final String level = signatureLevel.toUpperCase(); if (((SignaturePackaging.ENVELOPING == signaturePackaging) || (SignaturePackaging.DETACHED == signaturePackaging)) && level.startsWith("XADES")) { final String form = "xades"; final String levelOnly = DSSUtils.replaceStrStr(level, "XADES-", "").toLowerCase(); final String packaging = signaturePackaging.name().toLowerCase(); return new File(parentDir, originalName + "-" + form + "-" + packaging + "-" + levelOnly + ".xml"); }//from w w w . j a v a 2 s. co m if (level.startsWith("CADES") && !originalExtension.toLowerCase().equals(".p7m")) { return new File(parentDir, originalName + originalExtension + ".p7m"); } if (level.startsWith("ASIC_S")) { return new File(parentDir, originalName + originalExtension + ".asics"); } if (level.startsWith("ASIC_E")) { return new File(parentDir, originalName + originalExtension + ".asice"); } return new File(parentDir, originalName + "-signed" + originalExtension); }
From source file:com.thistech.spotlink.engine.AbstractPlacementDecisionEngine.java
/** * Build a Content from an Ad (for the PlacementResponse) * @param placementRequest The original PlacementRequest * @param ad The Ad/* ww w . j a v a2 s.c om*/ * @return A Content */ protected ContentType buildContent(PlacementRequestType placementRequest, Ad ad) { if (ad == null || ad.getMediaFiles().isEmpty()) { return null; } MediaFile mediaFile = ad.getMediaFiles().get(0); String providerId = StringUtils.substringBeforeLast(mediaFile.getUrl(), "/"); String assetId = StringUtils.substringAfterLast(mediaFile.getUrl(), "/"); return new ContentBuilder().withTracking(ad.getTrackingEvents().getId()).withAssetRef(providerId, assetId) .build(); }
From source file:de.xirp.io.logging.XirpTextFieldAppender.java
/** * Extracts the robot name and the original message from the given * message./*ww w . j a v a2 s . c o m*/ * * @param message * the original message to extract the robot name and * original message from * @return a string array with the robot name and original message */ private String[] extractRobot(String message) { String robot = StringUtils.substringBetween(message, RobotLogger.ROBOT_IDENTIFIER, RobotLogger.ROBOT_DELIMITER); if (StringUtils.isEmpty(robot)) { return null; } String origMessage = StringUtils.substringBefore(message, RobotLogger.ROBOT_IDENTIFIER); origMessage += StringUtils.substringAfterLast(message, RobotLogger.ROBOT_DELIMITER); return new String[] { robot, origMessage }; }
From source file:edu.ku.brc.specify.utilapps.ERDTable.java
/** * @param p// w w w . j ava2 s.c o m * @param f * @param font * @param y * @param all */ public void build(final PanelBuilder p, final DBFieldInfo f, final Font font, final int y, boolean all) { String typ = StringUtils.substringAfterLast(f.getType(), "."); if (StringUtils.isEmpty(typ)) { typ = f.getType(); } String lenStr = f.getLength() > 0 && f.getLength() < 65000 ? Integer.toString(f.getLength()) : ""; CellConstraints cc = new CellConstraints(); p.add(ERDVisualizer.mkLabel(font, f.getTitle(), SwingConstants.LEFT), cc.xy(1, y)); p.add(ERDVisualizer.mkLabel(font, typ, SwingConstants.CENTER), cc.xy(3, y)); p.add(ERDVisualizer.mkLabel(font, lenStr, SwingConstants.CENTER), cc.xy(5, y)); if (all) { p.add(ERDVisualizer.mkLabel(font, f.isRequired() ? yesStr : "", SwingConstants.CENTER), cc.xy(7, y)); p.add(ERDVisualizer.mkLabel(font, f.isRequired() ? yesStr : "", SwingConstants.CENTER), cc.xy(9, y)); } }
From source file:com.perficient.aem.weretail.datalayer.DefaultPageDataElement.java
@Override public void updateDataLayer(DataLayer dataLayer) { EventInfo event = new EventInfo(); event.setEventAction("pageLoad"); event.setEventName("Page Load"); dataLayer.getEvents().add(event);/*from ww w .j a va2s . c o m*/ Page page = dataLayer.getPage(); PageInfo pageInfo = new PageInfo(); if (dataLayer.getConfig().getSetAuthor() == true) { pageInfo.setAuthor(dataLayer.getAEMPage().getLastModifiedBy()); } List<String> breadcrumbs = new ArrayList<String>(); com.day.cq.wcm.api.Page currentPage = dataLayer.getAEMPage(); while (currentPage != null && currentPage.getDepth() > dataLayer.getConfig().getSiteRootLevel()) { breadcrumbs.add(currentPage.getTitle()); currentPage = currentPage.getParent(); } Collections.reverse(breadcrumbs); pageInfo.setBreadcrumbs(breadcrumbs.toArray(new String[breadcrumbs.size()])); currentPage = dataLayer.getAEMPage(); ValueMap properties = currentPage.getContentResource().getValueMap(); String path = DataLayerUtil.getSiteSubpath(currentPage, dataLayer.getConfig()); pageInfo.setDestinationUrl(DataLayerUtil.getSiteUrl(currentPage, dataLayer.getConfig())); if (currentPage.getOnTime() != null) { pageInfo.setEffectiveDate(currentPage.getOnTime().getTime()); } else if (properties.containsKey(JcrConstants.JCR_CREATED)) { pageInfo.setEffectiveDate(properties.get(JcrConstants.JCR_CREATED, Date.class)); } if (currentPage.getOffTime() != null) { pageInfo.setExpiryDate(currentPage.getOffTime().getTime()); } if (properties.containsKey(JcrConstants.JCR_CREATED)) { pageInfo.setIssueDate(properties.get(JcrConstants.JCR_CREATED, Date.class)); } pageInfo.setLanguage(currentPage.getLanguage(false).toString()); pageInfo.setPageId(path); pageInfo.setPageName(currentPage.getTitle()); if (StringUtils.isNotEmpty(dataLayer.getConfig().getPublisher())) { pageInfo.setPublisher(dataLayer.getConfig().getPublisher()); } pageInfo.setSysEnv(dataLayer.getConfig().getEnvironment()); page.setPageInfo(pageInfo); String templateName = StringUtils .substringAfterLast(properties.get(NameConstants.NN_TEMPLATE, String.class), "/"); List<String> tags = new ArrayList<String>(); Category category = new Category(); category.setPrimaryCategory(templateName); for (int i = 0; i < currentPage.getTags().length; i++) { category.put("tag" + i, currentPage.getTags()[i].getTitle()); tags.add(currentPage.getTags()[i].getTitle()); } page.setCategory(category); Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("tags", tags.toArray(new String[tags.size()])); attributes.put("template", templateName); page.setAttributes(attributes); }
From source file:com.dp2345.plugin.oss.OssPlugin.java
@Override public List<FileInfo> browser(String path) { List<FileInfo> fileInfos = new ArrayList<FileInfo>(); PluginConfig pluginConfig = getPluginConfig(); if (pluginConfig != null) { String accessId = pluginConfig.getAttribute("accessId"); String accessKey = pluginConfig.getAttribute("accessKey"); String bucketName = pluginConfig.getAttribute("bucketName"); String urlPrefix = pluginConfig.getAttribute("urlPrefix"); try {//from w w w . jav a2 s . co m OSSClient ossClient = new OSSClient(accessId, accessKey); ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName); listObjectsRequest.setPrefix(StringUtils.removeStart(path, "/")); listObjectsRequest.setDelimiter("/"); ObjectListing objectListing = ossClient.listObjects(listObjectsRequest); for (String commonPrefix : objectListing.getCommonPrefixes()) { FileInfo fileInfo = new FileInfo(); fileInfo.setName(StringUtils.substringAfterLast(StringUtils.removeEnd(commonPrefix, "/"), "/")); fileInfo.setUrl(urlPrefix + "/" + commonPrefix); fileInfo.setIsDirectory(true); fileInfo.setSize(0L); fileInfos.add(fileInfo); } for (OSSObjectSummary ossObjectSummary : objectListing.getObjectSummaries()) { if (ossObjectSummary.getKey().endsWith("/")) { continue; } FileInfo fileInfo = new FileInfo(); fileInfo.setName(StringUtils.substringAfterLast(ossObjectSummary.getKey(), "/")); fileInfo.setUrl(urlPrefix + "/" + ossObjectSummary.getKey()); fileInfo.setIsDirectory(false); fileInfo.setSize(ossObjectSummary.getSize()); fileInfo.setLastModified(ossObjectSummary.getLastModified()); fileInfos.add(fileInfo); } } catch (Exception e) { e.printStackTrace(); } } return fileInfos; }
From source file:info.magnolia.cms.module.ModuleUtil.java
public static void registerProperties(HierarchyManager hm, Map map) throws AccessDeniedException, PathNotFoundException, RepositoryException { for (Iterator iter = map.keySet().iterator(); iter.hasNext();) { String key = (String) iter.next(); String value = (String) map.get(key); String name = StringUtils.substringAfterLast(key, "."); //$NON-NLS-1$ String path = StringUtils.substringBeforeLast(key, ".").replace('.', '/'); //$NON-NLS-1$ Content node = ContentUtil.createPath(hm, path); node.createNodeData(name).setValue(value); }// w ww . jav a 2s. c om }
From source file:ddf.content.plugin.video.VideoThumbnailPlugin.java
public VideoThumbnailPlugin(final BundleContext bundleContext) throws IOException { final String bundledFFmpegBinaryPath = getBundledFFmpegBinaryPath(); final String ffmpegBinaryName = StringUtils.substringAfterLast(bundledFFmpegBinaryPath, "/"); final String ffmpegFolderPath = FilenameUtils.concat(System.getProperty("ddf.home"), "bin_third_party/ffmpeg"); ffmpegPath = FilenameUtils.concat(ffmpegFolderPath, ffmpegBinaryName); try (final InputStream inputStream = bundleContext.getBundle().getEntry(bundledFFmpegBinaryPath) .openStream()) {/* w w w . ja va 2s. c om*/ copyFFmpegBinary(inputStream); } limitFFmpegProcessesSemaphore = new Semaphore(MAX_FFMPEG_PROCESSES, true); }
From source file:edu.ku.brc.specify.tools.datamodelgenerator.DataModelToCSV.java
protected void processTables(final Element table) { pw.println("" + sep + sep + sep + sep); pw.println("TABLE" + sep + sep + sep); Element nameElement = (Element) table.selectSingleNode("nameDesc"); String name = nameElement != null ? nameElement.getText() : StringUtils.substringAfterLast(getAttr(table, "classname", null), "."); System.out.println(name);/* w w w. ja v a 2 s . c o m*/ Element descElement = (Element) table.selectSingleNode("desc"); String desc = descElement != null ? fixText(descElement.getText()) : ""; pw.print(name); pw.print(sep); pw.print(desc); pw.print(sep); pw.print(sep); pw.println(); pw.println("FIELDS" + sep + sep + sep); processId((Element) table.selectSingleNode("id")); for (Iterator<?> iter = table.selectNodes("field").iterator(); iter.hasNext();) { processField((Element) iter.next()); } pw.println("RELATIONSHIPS" + sep + sep + sep); for (Iterator<?> iter = table.selectNodes("relationship").iterator(); iter.hasNext();) { processRelationship((Element) iter.next()); } }