List of usage examples for org.apache.commons.lang StringUtils startsWith
public static boolean startsWith(String str, String prefix)
Check if a String starts with a specified prefix.
From source file:hudson.plugins.clearcase.ucm.UcmMakeBaseline.java
/** * Retrieve the read/write component list with PVOB * /* w ww .j a v a 2 s .c om*/ * @param clearToolLauncher * @param filePath * @return the read/write component like 'DeskCore@\P_ORC DeskShared@\P_ORC build_Product@\P_ORC' * @throws IOException * @throws InterruptedException * @throws Exception */ private List<String> getReadWriteComponent(ClearTool clearTool, String viewTag) throws IOException, InterruptedException { String output = clearTool.lsproject(viewTag, "%[mod_comps]Xp"); final String prefix = "component:"; if (StringUtils.startsWith(output, prefix)) { List<String> componentNames = new ArrayList<String>(); String[] componentNamesSplit = output.split(" "); for (String componentName : componentNamesSplit) { String componentNameTrimmed = StringUtils.difference(prefix, componentName).trim(); if (StringUtils.isNotEmpty(componentNameTrimmed)) { componentNames.add(componentNameTrimmed); } } return componentNames; } throw new IOException(output); }
From source file:com.adobe.acs.commons.replication.status.impl.JcrPackageReplicationStatusEventHandler.java
/** * Checks if any path in the array of paths looks like a Jcr Package path. * * Provides a very fast, String-based, in-memory check to weed out most false positives and avoid * resolving the path to a Jcr Package and ensure it is valid. * * @param paths the array of paths/* w w w.j av a 2 s.c o m*/ * @return true if at least one path looks like a Jcr Package path */ private boolean containsJcrPackagePath(final String[] paths) { for (final String path : paths) { if (StringUtils.startsWith(path, "/etc/packages/") && StringUtils.endsWith(path, ".zip")) { // At least 1 entry looks like a package return true; } } // Nothing looks like a package... return false; }
From source file:jp.primecloud.auto.process.zabbix.ElbZabbixHostProcess.java
public void deleteFarmHostgroup(Long farmNo) { Farm farm = farmDao.read(farmNo);/*w w w. j a v a2 s . c o m*/ User user = userDao.read(farm.getUserNo()); String hostgroupName = user.getUsername() + "_" + farm.getFarmName(); ZabbixProcessClient zabbixProcessClient = zabbixProcessClientFactory.createZabbixProcessClient(); Hostgroup hostgroup = zabbixProcessClient.getHostgroupByName(hostgroupName); if (hostgroup != null) { // ???? zabbixProcessClient.deleteHostgroup(hostgroup.getGroupid(), hostgroupName); } // ????? String prefix = hostgroupName + "_"; List<Hostgroup> hostgroups = zabbixProcessClient.getHostgroups(); for (Hostgroup hostgroup2 : hostgroups) { if (StringUtils.startsWith(hostgroup2.getName(), prefix)) { zabbixProcessClient.deleteHostgroup(hostgroup2.getGroupid(), hostgroup2.getName()); } } }
From source file:com.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java
/** * Load the membership details from the XML application. * * @param root the root of the XML application * @return the membership bean//from www .j a va2 s.co m */ private MembershipBean loadMembershipDetails(final Element root) { MembershipBean membership = membershipDAO.getDefaultInstance(); // Set the joined date to today (default) membership.setJoinedDate(Calendar.getInstance().getTime()); // Set the membership status ObjectTypeBean statusObject = new ObjectTypeBean(); statusObject.setObject("Status"); statusObject.setClassName("Active - within NZ"); statusObject.setName(""); membership.setField("Status", statusObject); // Set the membership type ObjectTypeBean membershipType = new ObjectTypeBean(); membershipType.setObject("Membership Type"); membershipType.setClassName("Member"); membershipType.setName("Basic Trainee"); membership.setField("Membership Type", membershipType); // Set the division String divisionValue = "Adult"; try { String div = root.getChild("masterrecord").getChildText("Division").trim(); if (StringUtils.startsWith(div, "P")) { divisionValue = "Paediatric"; } } catch (Exception e) { dataLogger.error("Error parsing Division: " + e.getMessage()); } ObjectTypeBean division = new ObjectTypeBean(); division.setObject("Division"); division.setClassName(divisionValue); division.setName(""); membership.setField("Division", division); // Set the training type ObjectTypeBean trainingType = new ObjectTypeBean(); trainingType.setObject("Training Type"); trainingType.setClassName("Trainee"); trainingType.setName(""); membership.setField("Training Type", trainingType); return membership; }
From source file:com.activecq.tools.errorpagehandler.impl.ErrorPageHandlerImpl.java
/** * Find the Error page search path that best contains the provided resource * * @param resource/*from w w w. j a v a 2s.c o m*/ * @return */ private String getErrorPagesPath(Resource resource, SortedMap<String, String> errorPagesMap) { // Path to evaluate against Root paths final String path = resource.getPath(); final ResourceResolver resourceResolver = resource.getResourceResolver(); for (final String rootPath : this.getRootPaths(errorPagesMap)) { if (StringUtils.equals(path, rootPath) || StringUtils.startsWith(path, rootPath.concat("/"))) { final String errorPagePath = getErrorPagesPath(rootPath, errorPagesMap); Resource errorPageResource = getResource(resourceResolver, errorPagePath); if (errorPageResource != null && !ResourceUtil.isNonExistingResource(errorPageResource)) { return errorPageResource.getPath(); } } } return null; }
From source file:ddf.security.expansion.impl.AbstractExpansion.java
/** * Does the work of reading the configuration file and configuring the expansion map and * attribute separator./* w w w. j a v a 2 s. c o m*/ * * @param filename * the name of the file to be read and processed */ protected void loadConfiguration(String filename) { if (filename == null) { setExpansionMap(null); return; } // first clear out the existing table if (expansionTable != null) { expansionTable.clear(); } File file = null; filename = StringUtils.strip(filename); if (!StringUtils.startsWith(filename, "/") && !StringUtils.startsWith(filename, "\\")) { // relative path String relPath = System.getProperty("ddf.home"); if (StringUtils.isBlank(relPath)) { LOGGER.warn("ddf.home property was not set or is NULL, loading of properties may be impacted."); } file = new File(relPath, filename); } else { // absolute path file = new File(filename); } try (BufferedReader br = new BufferedReader( new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8.name()))) { if (br != null) { String line; while ((line = br.readLine()) != null) { if ((line.length() > 0) && (!line.startsWith(CFG_COMMENT_STR))) { if (line.startsWith(SEPARATOR_PREFIX)) { if (line.length() > SEPARATOR_PREFIX.length()) { attributeSeparator = line.substring(SEPARATOR_PREFIX.length()); } else { attributeSeparator = DEFAULT_VALUE_SEPARATOR; } } else { addExpansionRule(line); } } } LOGGER.info("Finished loading mapping configuration file."); } } catch (IOException e) { LOGGER.warn("Unexpected exception reading mapping configuration file {} - {}", filename, e.getMessage()); setExpansionMap(null); } }
From source file:hudson.plugins.clearcase.ucm.UcmMakeBaseline.java
/** * Get the component binding to the baseline * /*from w w w . j a va 2 s .com*/ * @param clearToolLauncher * @param baselineName the baseline name like 'deskCore_3.2-146_2008-11-14_18-07-22.3543@\P_ORC' * @return the component name like 'Desk_Core@\P_ORC' * @throws InterruptedException * @throws IOException */ private String getComponentforBaseline(ClearTool clearTool, String baselineName) throws InterruptedException, IOException { String output = clearTool.lsbl(baselineName, "%[component]Xp"); String prefix = "component:"; if (StringUtils.startsWith(output, prefix)) { return StringUtils.difference(prefix, output); } throw new IOException("Incorrect output. Received " + output); }
From source file:com.nridge.ds.content.ds_content.ContentExtractor.java
/** * This method will extract the textual content from the URL * and write it to the writer stream. If a bag instance has been * registered with the class, then meta data fields will dynamically * be assigned as they are discovered./*from w w w . j a v a 2 s . c o m*/ * * @param aURL URL of the resource. * @param aWriter Output writer stream. * * @throws NSException Thrown when IOExceptions are detected. */ @SuppressWarnings("deprecation") public void process(URL aURL, Writer aWriter) throws NSException { Logger appLogger = mAppMgr.getLogger(this, "process"); appLogger.trace(mAppMgr.LOGMSG_TRACE_ENTER); if ((aURL == null) || (aWriter == null)) throw new NSException("One or more parameters are null."); String documentName = aURL.toString(); appLogger.debug(String.format("[%s] %s", detectType(aURL), documentName)); Metadata tikaMetaData = new Metadata(); int contentLimit = getCfgInteger("content_limit", Content.CONTENT_LIMIT_DEFAULT); InputStream inputStream = null; try { Parser tikaParser; ParseContext parseContext; inputStream = TikaInputStream.get(aURL); if (isCfgStringTrue("tika_fork_parser")) { ForkParser forkParser = new ForkParser(ContentExtractor.class.getClassLoader(), new AutoDetectParser()); String javaCmdStr = getCfgString("tika_fork_java_cmd"); if (StringUtils.isNotEmpty(javaCmdStr)) forkParser.setJavaCommand(javaCmdStr); int poolSize = getCfgInteger("tika_fork_pool_size", 5); if (poolSize > 0) forkParser.setPoolSize(poolSize); tikaParser = forkParser; parseContext = new ParseContext(); } else { tikaParser = new AutoDetectParser(); parseContext = new ParseContext(); Parser recursiveMetadataParser = new RecursiveMetadataParser(tikaParser); parseContext.set(Parser.class, recursiveMetadataParser); } WriteOutContentHandler writeOutContentHandler = new WriteOutContentHandler(aWriter, contentLimit); tikaParser.parse(inputStream, writeOutContentHandler, tikaMetaData, parseContext); } catch (Exception e) { String eMsg = e.getMessage(); String msgStr = String.format("%s: %s", documentName, eMsg); /* The following logic checks to see if this exception was triggered simply because the total character limit threshold was hit. If that is all it was, then return true. */ if (StringUtils.startsWith(eMsg, "Your document contained more than")) appLogger.warn(msgStr); else throw new NSException(msgStr); } finally { if (inputStream != null) IOUtils.closeQuietly(inputStream); } if ((mBag != null) && (isCfgStringTrue("content_metadata"))) { String mdValue; String[] metaDataNames = tikaMetaData.names(); for (String mdName : metaDataNames) { mdValue = tikaMetaData.get(mdName); if (StringUtils.isNotEmpty(mdValue)) addAssignField(Content.CONTENT_FIELD_METADATA + mdName, mdValue); } } appLogger.trace(mAppMgr.LOGMSG_TRACE_DEPART); }
From source file:hudson.plugins.clearcase.ucm.UcmMakeBaseline.java
private List<String> getLatestBaselineNames(ClearTool clearTool, String viewTag) throws Exception { String output = clearTool.lsstream(null, viewTag, "%[latest_bls]Xp"); String prefix = "baseline:"; if (StringUtils.startsWith(output, prefix)) { List<String> baselineNames = new ArrayList<String>(); String[] baselineNamesSplit = output.split(prefix); for (String baselineName : baselineNamesSplit) { String baselineNameTrimmed = baselineName.trim(); if (StringUtils.isNotEmpty(baselineNameTrimmed)) { // Retrict to baseline bind to read/write component String blComp = getComponentforBaseline(clearTool, baselineNameTrimmed); if (this.readWriteComponents.contains(blComp)) baselineNames.add(baselineNameTrimmed); }/* w w w . ja v a2 s. co m*/ } return baselineNames; } throw new Exception("Failed to get baselinename, reason: " + output); }
From source file:com.prowidesoftware.swift.model.Tag.java
/** * equivalent to StringUtils.startsWith(tag.getValue(), prefix) * @see StringUtils#startsWith(String, String) *///from www . jav a 2s .c om public boolean startsWith(String prefix) { return StringUtils.startsWith(getValue(), prefix); }