List of usage examples for org.apache.commons.lang3 StringUtils startsWith
public static boolean startsWith(final CharSequence str, final CharSequence prefix)
Check if a CharSequence starts with a specified prefix.
null s are handled without exceptions.
From source file:com.glaf.dts.bean.TransformBean.java
public boolean transformAllQueryToTable() { boolean result = true; QueryDefinitionQuery q = new QueryDefinitionQuery(); q.locked(0);//w ww .jav a 2 s. c om List<QueryDefinition> queries = getQueryDefinitionService().list(q); if (queries != null && !queries.isEmpty()) { for (QueryDefinition queryDefinition : queries) { String tableName = queryDefinition.getTargetTableName(); if (StringUtils.isNotEmpty(tableName)) { tableName = tableName.toLowerCase(); if (StringUtils.startsWith(tableName, "mx_") || StringUtils.startsWith(tableName, "sys_") || StringUtils.startsWith(tableName, "act_") || StringUtils.startsWith(tableName, "jbpm_")) { continue; } MxTransformManager manager = new MxTransformManager(); TableDefinition tableDefinition = null; if (!StringUtils.equalsIgnoreCase(queryDefinition.getRotatingFlag(), "R2C")) { try { tableDefinition = manager.toTableDefinition(queryDefinition); tableDefinition.setTableName(tableName); tableDefinition.setType("DTS"); tableDefinition.setNodeId(queryDefinition.getNodeId()); TransformTable tbl = new TransformTable(); tbl.createOrAlterTable(tableDefinition); } catch (Exception ex) { ex.printStackTrace(); logger.error(ex); } } Long databaseId = queryDefinition.getDatabaseId(); TransformTable transformTable = new TransformTable(); try { Database db = getDatabaseService().getDatabaseById(databaseId); if (db != null) { transformTable.transformQueryToTable(tableName, queryDefinition.getId(), db.getName()); } else { transformTable.transformQueryToTable(tableName, queryDefinition.getId(), Environment.DEFAULT_SYSTEM_NAME); } } catch (Exception ex) { result = false; ex.printStackTrace(); logger.error(ex); } } } } return result; }
From source file:io.wcm.devops.conga.resource.ResourceLoader.java
/** * Removes resource type prefix if a prefix is given. * @param path Path// ww w .j a v a 2s . c o m * @return Path without prefix */ private static String removePrefix(String path) { for (ResourceType resourceType : ResourceType.values()) { if (StringUtils.startsWith(path, resourceType.getPrefix())) { return StringUtils.substringAfter(path, resourceType.getPrefix()); } } return path; }
From source file:com.conversantmedia.mapreduce.tool.ExpressionEvaluator.java
/** * * @param rootObj root object for the OGNL context * @param context set of properties fed into evaluation * @param expr the expression to evaluate. Expects an OGNL expression. * @return the result of the expression's evaluation * @throws ToolException if something goes wrong *///from w w w .j a v a 2s .c om @SuppressWarnings("rawtypes") public Object evaluate(Object rootObj, Map<String, Object> context, String expr) throws ToolException { Object value = expr; Object expressionValue = null; Map ognlContext = buildOgnlContext(rootObj, context); try { Matcher matcher = pattern.matcher(expr); while (matcher.matches()) { expr = matcher.group(2); // remove the enclosing ${ and } // If it doesn't start with 'context.' or 'this.' then prepend the // expression with 'this.' if (!(StringUtils.startsWith(expr, OgnlContext.THIS_CONTEXT_KEY + ".") || StringUtils.startsWith(expr, "context."))) { expr = "this." + expr; } else { expr = StringUtils.replace(expr, "context", TOOL_CONTEXT_KEY); } expressionValue = Ognl.getValue(expr, ognlContext); if (StringUtils.isNotBlank(matcher.group(1)) || StringUtils.isNotBlank(matcher.group(3))) { value = matcher.group(1) + expressionValue + matcher.group(3); } else { value = expressionValue; } matcher = pattern.matcher(value.toString()); } } catch (OgnlException e) { throw new ToolException("Failed to evaluate [" + expr + "]", e); } return value; }
From source file:io.wcm.config.core.override.impl.RequestHeaderOverrideProvider.java
private Map<String, String> buildMapFromHeaders(SlingHttpServletRequest request) { Map<String, String> map = new HashMap<>(); Enumeration keys = request.getHeaderNames(); while (keys.hasMoreElements()) { Object keyObject = keys.nextElement(); if (keyObject instanceof String) { String key = (String) keyObject; if (StringUtils.startsWith(key, REQUEST_HEADER_PREFIX)) { map.put(StringUtils.substringAfter(key, REQUEST_HEADER_PREFIX), request.getHeader(key)); }//from ww w . j a v a 2s . c om } } return map; }
From source file:com.adobe.cq.social.samples.scf.gamification.impl.ScoresAndBadgesSocialComponentImpl.java
private void getUserProps(ClientUtilities clientUtils) { String authId = null;//from www . jav a 2 s. c o m Resource propertyNode = null; UserProperties userProperties = null; UserPropertiesManager upm = resolver.adaptTo(UserPropertiesManager.class); final String authPath = clientUtils.getRequest().getRequestPathInfo().getSuffix(); if (StringUtils.startsWith(authPath, User.SOCIAL_AUTHORS_PREFIX)) { authId = authPath.substring(User.SOCIAL_AUTHORS_PREFIX.length()); } else if (!StringUtils.isEmpty(authPath)) { // pass in user profile path propertyNode = resolver.resolve(authPath); } try { if (upm != null) { if (!StringUtils.isEmpty(authId)) { userProperties = upm.getUserProperties(authId, "profile"); } else if (propertyNode != null) { userProperties = upm.getUserProperties(propertyNode.adaptTo(Node.class)); } else { userProperties = null; } } else { userProperties = null; } } catch (RepositoryException e) { LOG.error("Can't obtain user properties for {}", authId != null ? authId : propertyNode.getPath()); } if (userProperties != null) { userid = userProperties.getAuthorizableID(); } }
From source file:com.francetelecom.clara.cloud.deployment.rules.CheckMavenReferenceRule.java
@Override public Set<RuleValidationMessage> validate(DeployableMavenArtifactDto providedArtifact, ProcessingNode node) throws TechnicalException { Set<RuleValidationMessage> messages = new HashSet<RuleValidationMessage>(); MavenReference expectedMavenReference = node.getSoftwareReference(); logger.debug("Checking GAV"); if (!StringUtils.equals(expectedMavenReference.getGroupId(), providedArtifact.getGroupId())) { messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId() + "] not allowed : provided groupId [" + providedArtifact.getGroupId() + "] does not match expected groupId [" + expectedMavenReference.getGroupId() + "]", WARNING)); }//from ww w . ja v a 2 s . c o m if (!StringUtils.equals(expectedMavenReference.getArtifactId(), providedArtifact.getArtifactId())) { messages.add(new RuleValidationMessage("Deployment of " + providedArtifact.getArtifactId() + " not allowed : provided artifactId [" + providedArtifact.getArtifactId() + "] does not match expected artifactId [" + expectedMavenReference.getArtifactId() + "]", WARNING)); } // Classifier null or empty ("") should be considered equals if ((StringUtils.isNotEmpty(expectedMavenReference.getClassifier()) || StringUtils.isNotEmpty(providedArtifact.getClassifier())) && !StringUtils.equals(expectedMavenReference.getClassifier(), providedArtifact.getClassifier())) { messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId() + "] not allowed : provided classifier [" + providedArtifact.getClassifier() + "] does not match expected classifier [" + expectedMavenReference.getClassifier() + "]", WARNING)); } if (!StringUtils.equals(expectedMavenReference.getType(), providedArtifact.getType())) { messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId() + "] not allowed : provided type [" + providedArtifact.getType() + "] does not match expected type [" + expectedMavenReference.getType() + "]", WARNING)); } if (!StringUtils.startsWith(providedArtifact.getVersion(), expectedMavenReference.getVersion())) { messages.add(new RuleValidationMessage("Deployment of [" + providedArtifact.getArtifactId() + "] not allowed : provided version [" + providedArtifact.getVersion() + "] does not match expected version [" + expectedMavenReference.getVersion() + "]", WARNING)); } return messages; }
From source file:com.thoughtworks.go.security.GoCipher.java
public boolean passwordEquals(String p1, String p2) { if (Objects.equals(p1, p2)) { return true; }/*from ww w . j ava 2 s .c o m*/ try { if (StringUtils.startsWith(p1, "AES:") && StringUtils.startsWith(p2, "AES:")) { return decrypt(p1).equals(decrypt(p2)); } } catch (Exception e) { return false; } return false; }
From source file:com.quatico.base.aem.test.api.setup.Pages.java
@Override public Resource aPageWithParents(Resource parent, String relativePath, Object... properties) throws Exception { if (relativePath == null) { relativePath = StringUtils.EMPTY; }// w ww . ja v a 2 s . co m if (StringUtils.isNotEmpty(relativePath) && !StringUtils.startsWith(relativePath, "/")) { relativePath += "/"; } return aPageWithParents(parent.getPath() + relativePath, properties); }
From source file:com.erudika.para.storage.LocalFileStore.java
@Override public boolean delete(String path) { if (StringUtils.startsWith(path, File.separator)) { path = path.substring(1);/*from w w w. j a va2 s . c o m*/ } if (!StringUtils.isBlank(path)) { File f = new File(folder + File.separator + path); return f.canWrite() && f.delete(); } return false; }
From source file:de.micromata.genome.util.runtime.jndi.SimpleNamingContext.java
private String fixJavaCompName(String name) { if (StringUtils.startsWith(name, "java:comp") == false) { return name; }/*from www. j a va 2 s . com*/ name = "java:" + name.substring("java:".length()); return name; }