List of usage examples for org.apache.commons.lang StringUtils removeStart
public static String removeStart(String str, String remove)
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
From source file:info.magnolia.jcr.wrapper.InheritanceNodeWrapper.java
/** * This method returns null if no node has been found. *//*w ww .ja va2 s. c om*/ protected Node getNodeSafely(String relPath) throws RepositoryException { if (getWrappedNode().hasNode(relPath)) { return wrapNode(getWrappedNode().getNode(relPath)); } String innerPath = resolveInnerPath() + "/" + relPath; innerPath = StringUtils.removeStart(innerPath, "/"); Node inherited = getNodeSafely(findNextAnchor(), innerPath); return inherited; }
From source file:com.amalto.core.storage.StorageWrapper.java
private Select getSelectTypeById(ComplexTypeMetadata type, String uniqueID) { ComplexTypeMetadata typeForSelect = type; while (typeForSelect.getSuperTypes() != null && !typeForSelect.getSuperTypes().isEmpty() && typeForSelect.getSuperTypes().size() > 0) { typeForSelect = (ComplexTypeMetadata) typeForSelect.getSuperTypes().iterator().next(); }//from www . j a va 2 s .com String[] splitUniqueID = uniqueID.split("\\."); //$NON-NLS-1$ UserQueryBuilder qb = UserQueryBuilder.from(typeForSelect); Collection<FieldMetadata> keyFields = type.getKeyFields(); if (splitUniqueID.length < (2 + keyFields.size())) { throw new IllegalArgumentException("ID '" + uniqueID //$NON-NLS-1$ + "' does not contain all required values for key of type '" + type.getName()); //$NON-NLS-1$ } if (keyFields.size() == 1) { String uniqueIDPrefix = splitUniqueID[0] + '.' + splitUniqueID[1] + '.'; String key = StringUtils.removeStart(uniqueID, uniqueIDPrefix); qb.where(eq(keyFields.iterator().next(), key)); } else { int currentIndex = 2; for (FieldMetadata keyField : keyFields) { qb.where(eq(keyField, splitUniqueID[currentIndex++])); } } return qb.getSelect(); }
From source file:info.magnolia.templating.inheritance.DefaultInheritanceContentDecorator.java
private String getPathRelativeToParent(Node parent, Node child) throws RepositoryException { String childPath = child.getPath(); if (parent.getDepth() == 0) { return childPath; }// w w w . j a va 2s . co m String parentPathWithTrailingSlash = parent.getPath() + "/"; if (!childPath.startsWith(parentPathWithTrailingSlash)) { return null; } return StringUtils.removeStart(childPath, parentPathWithTrailingSlash); }
From source file:info.magnolia.cms.beans.config.URI2RepositoryMapping.java
public String getURI(Link uuidLink) { String uri = uuidLink.getPath(); if (StringUtils.isNotEmpty(this.handlePrefix)) { uri = StringUtils.removeStart(uri, this.handlePrefix); }/*ww w . ja va2 s. c o m*/ if (StringUtils.isNotEmpty(this.URIPrefix)) { uri = this.URIPrefix + "/" + uri; } String nodeDataName = uuidLink.getNodeDataName(); String fileName = uuidLink.getFileName(); String extension = uuidLink.getExtension(); if (StringUtils.isNotEmpty(nodeDataName)) { uri += "/" + nodeDataName; } if (StringUtils.isNotEmpty(fileName)) { uri += "/" + fileName; } if (StringUtils.isNotEmpty(uri) && StringUtils.isNotEmpty(extension) && !StringUtils.endsWith(uri, "/")) { uri += "." + extension; } return cleanHandle(uri); }
From source file:energy.usef.core.service.business.ParticipantDiscoveryService.java
/** * Find the unsealing public key of the message sender. * * @param incomingMessage - {@link Message} * @return a Base64 encoded public key ( {@link String} ) * @throws BusinessException// www .j av a2 s .c o m */ public String findUnsealingPublicKey(SignedMessage incomingMessage) throws BusinessException { String value; String senderDomain = incomingMessage.getSenderDomain(); USEFRole senderRole = incomingMessage.getSenderRole(); if (byPassDNSCheck()) { checkSenderDomainAndRoleAvailable(incomingMessage); value = findLocalParticipantUnsigningPublicKey(senderDomain, senderRole); } else { value = getPublicUnsealingKey(senderDomain, senderRole); } return StringUtils.removeStart(value, PUBLIC_KEY_PREFIX); }
From source file:edu.mayo.qdm.webapp.rest.store.Md5HashFileSystemResolver.java
private File getStorageDir(String id, boolean create) { String hash = this.getMd5Hash(id); String splitHash = this.splitHash(hash); splitHash = StringUtils.removeStart(splitHash, File.separator); splitHash = StringUtils.removeEnd(splitHash, File.separator); String directoryPath = this.getDataDir() + File.separator + splitHash; File dir = new File(directoryPath); if (!dir.exists() && !create) { throw new ExecutionNotFoundException(); } else {/* w w w . j a va 2s .com*/ dir.mkdirs(); } return dir; }
From source file:info.magnolia.test.mock.jcr.MockSession.java
@Override public Node getNode(String absPath) throws PathNotFoundException, RepositoryException { if ("/".equals(absPath)) { return rootNode; }/*w ww . ja va 2s . c om*/ return rootNode.getNode(StringUtils.removeStart(absPath, "/")); }
From source file:info.magnolia.cms.util.InheritanceContentWrapper.java
/** * Returns the inner path of the this node up to the anchor. *//*from w ww . j a v a 2 s. co m*/ 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:info.magnolia.jcr.util.ContentMap.java
private boolean isSpecialProperty(String strKey) { if (!strKey.startsWith("@")) { return false; }//from w w w . j a v a2s .c o m strKey = convertDeprecatedProps(strKey); return specialProperties.containsKey(StringUtils.removeStart(strKey, "@")); }
From source file:gov.nih.nci.cabig.caaers.web.admin.AgentImporter.java
/** * This method accepts a String which should be like * "723227","(161-180)ESO-1 Peptide" /* w w w . ja v a 2s .c om*/ * It splits the string into 2 tokens and creates a Agent object. * If the number of token are less than 2 the record/line is rejected. * @param agentString * @param lineNumber * @return */ protected DomainObjectImportOutcome<Agent> processAgent(String agentString, int lineNumber) { DomainObjectImportOutcome<Agent> agentImportOutcome = null; Agent agent = null; StringTokenizer st = null; String nscNumber; String agentName; if (StringUtils.isNotEmpty(agentString)) { logger.debug("Orginial line from file -- >>> " + agentString); agentString = agentString.trim(); //Replace ", with "| //This is done to set a delimiter other than , agentString = StringUtils.replace(agentString, "\",", "\"|"); logger.debug("Modified line -- >>> " + agentString); //Generate tokens from input String. st = new StringTokenizer(agentString, "|"); //If there are 2 tokens as expected, process the record. Create a Agent object. if (st.hasMoreTokens() && st.countTokens() == 2) { agentImportOutcome = new DomainObjectImportOutcome<Agent>(); agent = new Agent(); nscNumber = StringUtils.removeStart(st.nextToken(), "\"").trim(); nscNumber = StringUtils.removeEnd(nscNumber, "\""); agentName = StringUtils.removeStart(st.nextToken(), "\"").trim(); agentName = StringUtils.removeEnd(agentName, "\""); agent.setNscNumber(nscNumber); agent.setName(agentName); agentImportOutcome.setImportedDomainObject(agent); agentImportOutcome.setSavable(Boolean.TRUE); } else { logger.debug("Error in record -- >>> " + agentString); agentImportOutcome = new DomainObjectImportOutcome<Agent>(); StringBuilder msgBuilder = new StringBuilder("Invalid agent record found at line ::: "); msgBuilder.append(lineNumber); agentImportOutcome.addErrorMessage(msgBuilder.toString(), Severity.ERROR); } } return agentImportOutcome; }