List of usage examples for org.apache.commons.lang StringUtils substringBetween
public static String substringBetween(String str, String open, String close)
Gets the String that is nested in between two Strings.
From source file:org.jahia.services.workflow.jbpm.custom.email.JBPMMailProducer.java
protected void fillRecipients(AddressTemplate addressTemplate, Message email, Message.RecipientType recipientType, WorkItem workItem, JCRSessionWrapper session) throws Exception { // resolve and parse addresses String addresses = addressTemplate.getAddresses(); if (addresses != null) { addresses = evaluateExpression(workItem, addresses, session); // non-strict parsing applies to a list of mail addresses entered by a human email.addRecipients(recipientType, InternetAddress.parse(addresses, false)); }//from ww w .j a v a2 s. c o m // resolve and tokenize users String userList = addressTemplate.getUsers(); if (userList != null) { String[] userIds = tokenizeActors(userList, workItem, session); List<User> users = new ArrayList<User>(); for (String userId : userIds) { if (userId.startsWith("assignableFor(")) { String task = StringUtils.substringBetween(userId, "assignableFor(", ")"); WorkflowDefinition definition = WorkflowService.getInstance() .getWorkflow("jBPM", Long.toString(workItem.getProcessInstanceId()), null) .getWorkflowDefinition(); List<JahiaPrincipal> principals = WorkflowService.getInstance().getAssignedRole(definition, task, Long.toString(workItem.getProcessInstanceId()), session); for (JahiaPrincipal principal : principals) { if (principal instanceof JahiaUser) { if (!UserPreferencesHelper.areEmailNotificationsDisabled((JahiaUser) principal)) { users.add(taskIdentityService.getUserById(((JahiaUser) principal).getUserKey())); } } else if (principal instanceof JahiaGroup) { JCRGroupNode groupNode = groupManagerService .lookupGroupByPath(principal.getLocalPath()); if (groupNode != null) { for (JCRUserNode user : groupNode.getRecursiveUserMembers()) { if (!UserPreferencesHelper.areEmailNotificationsDisabled(user)) { users.add(taskIdentityService.getUserById(user.getPath())); } } } } } } else { User userById = taskIdentityService.getUserById(userId); if (userById instanceof JBPMTaskIdentityService.UserImpl && !((JBPMTaskIdentityService.UserImpl) userById).areEmailNotificationsDisabled()) { users.add(userById); } } } email.addRecipients(recipientType, getAddresses(users)); } // resolve and tokenize groups String groupList = addressTemplate.getGroups(); if (groupList != null) { for (String groupId : tokenizeActors(groupList, workItem, session)) { org.kie.api.task.model.Group group = taskIdentityService.getGroupById(groupId); email.addRecipients(recipientType, getAddresses(group)); } } }
From source file:org.jahia.utils.osgi.parsers.cnd.Name.java
public Name(String qualifiedName, Map<String, String> namespaceMapping) { if (qualifiedName.startsWith("{")) { int endUri = qualifiedName.indexOf("}"); if (endUri != -1 && qualifiedName.length() > endUri) { uri = StringUtils.substringBetween(qualifiedName, "{", "}"); for (Map.Entry<String, String> entry : namespaceMapping.entrySet()) { if (entry.getValue().equals(uri)) { prefix = entry.getKey(); break; }/*ww w . j ava 2 s.c o m*/ } localName = qualifiedName.substring(endUri + 1); } else { localName = qualifiedName; prefix = ""; uri = namespaceMapping.get(""); } } if (localName == null) { String s[] = Patterns.COLON.split(qualifiedName); if (s.length == 2) { prefix = s[0]; localName = s[1]; uri = namespaceMapping.get(prefix); } else { prefix = ""; localName = s[0]; uri = namespaceMapping.get(""); } } }
From source file:org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.java
public static IAnnotation addMethodAnnotation(IMethod method, String annotationStmt, boolean useWorkingCopy) throws JavaModelException { ICompilationUnit compilationUnit = method.getCompilationUnit(); ICompilationUnit unit = getCompilationUnit(compilationUnit, useWorkingCopy); ISourceRange sourceRange = method.getSourceRange(); IBuffer buffer = ((IOpenable) unit).getBuffer(); buffer.replace(sourceRange.getOffset(), 0, annotationStmt + "\n"); saveAndClose(unit);/* w ww .ja v a2s . c om*/ method = (IMethod) compilationUnit.getElementAt(method.getSourceRange().getOffset()); String annotationName = StringUtils.substringBetween(annotationStmt, "@", "("); for (IAnnotation annotation : method.getAnnotations()) { if (annotation.getElementName().equals(annotationName)) { return annotation; } } Assert.fail("SimpleAnnotation '" + annotationName + "'not found on method " + method.getSource()); return null; }
From source file:org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.java
public static IAnnotation addTypeAnnotation(IType type, String annotationStmt, boolean useWorkingCopy) throws JavaModelException, CoreException { LOGGER.info("Adding annotation " + annotationStmt + " on type " + type.getElementName()); insertCodeAtLocation(type.getCompilationUnit(), annotationStmt, type.getSourceRange().getOffset(), useWorkingCopy);/*from w w w .j a va 2 s.c om*/ String annotationName = StringUtils.substringBetween(annotationStmt, "@", "("); for (IAnnotation annotation : type.getAnnotations()) { if (annotation.getElementName().equals(annotationName)) { return annotation; } } return null; }
From source file:org.jboss.tools.ws.jaxrs.core.WorkbenchUtils.java
public static IAnnotation addFieldAnnotation(IField field, String annotationStmt, boolean useWorkingCopy) throws CoreException { LOGGER.info("Adding annotation " + annotationStmt + " on type " + field.getElementName()); insertCodeAtLocation(field.getCompilationUnit(), annotationStmt, field.getSourceRange().getOffset(), useWorkingCopy);//from w ww.j ava 2s .c om String annotationName = StringUtils.substringBetween(annotationStmt, "@", "("); for (IAnnotation annotation : field.getAnnotations()) { if (annotation.getElementName().equals(annotationName)) { return annotation; } } return null; }
From source file:org.jmesa.limit.LimitActionFactory.java
public SortSet getSortSet() { SortSet sortSet = new SortSet(); for (Object param : parameters.keySet()) { String parameter = (String) param; if (parameter.startsWith(prefixId + Action.SORT.toParam())) { String value = LimitUtils.getValue(parameters.get(parameter)); if (StringUtils.isNotBlank(value)) { String position = StringUtils.substringBetween(parameter, prefixId + Action.SORT.toParam(), "_"); String property = StringUtils.substringAfter(parameter, prefixId + Action.SORT.toParam() + position + "_"); Order order = Order.valueOfParam(value); Sort sort = new Sort(new Integer(position), property, order); sortSet.addSort(sort);/*from w w w . java 2 s. co m*/ } } } return sortSet; }
From source file:org.jvnet.hudson.plugins.mavendepsupdate.util.SnapshotTransfertListener.java
public void transferSucceeded(TransferEvent transferEvent) { if (transferEvent != null && transferEvent.getResource() != null) { File file = transferEvent.getResource().getFile(); if (file != null && transferEvent.getResource().getResourceName().contains("SNAPSHOT")) { // filtering on maven metadata boolean isArtifact = !isMetaData(file); if (isArtifact) { if (MavenDependencyUpdateTrigger.debug) { LOGGER.info("download " + file.getName()); }/*from ww w.ja va2 s. c o m*/ snapshots.add(file.getName()); snapshotDownloaded = true; } else { try { String fileContents = FileUtils.readFileToString(file); String lastUpdatedString = StringUtils.substringBetween(fileContents, "<lastUpdated>", "</lastUpdated>"); long lastUpdated = Long.valueOf(lastUpdatedString); if (lastUpdated >= this.lastBuild) { snapshots.add(file.getName()); snapshotDownloaded = true; } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
From source file:org.kuali.kfs.fp.document.authorization.ProcurementCardAccountingLineAuthorizer.java
protected String getLineContainerIndex(String accountingLineProperty) { String lineContainer = this.getLineContainer(accountingLineProperty); return StringUtils.substringBetween(lineContainer, "[", "]"); }
From source file:org.kuali.kfs.fp.document.validation.impl.AuxiliaryVoucherAccountingLineAmountValidation.java
/** * This method looks at the current full key path that exists in the MessageMap structure to determine how to build the error map * for the special journal voucher credit and debit fields since they don't conform to the standard pattern of accounting lines. * /* w w w .j a v a 2 s .com*/ * @param isDebit boolean to determine whether or not value isDebit or not * @return String represents error map key to use */ protected String buildMessageMapKeyPathForDebitCreditAmount(boolean isDebit) { // determine if we are looking at a new line add or an update boolean isNewLineAdd = GlobalVariables.getMessageMap().getErrorPath() .contains(NEW_SOURCE_ACCT_LINE_PROPERTY_NAME); isNewLineAdd |= GlobalVariables.getMessageMap().getErrorPath().contains(NEW_SOURCE_ACCT_LINE_PROPERTY_NAME); if (isNewLineAdd) { if (isDebit) { return DEBIT_AMOUNT_PROPERTY_NAME; } else { return CREDIT_AMOUNT_PROPERTY_NAME; } } else { String index = StringUtils.substringBetween(GlobalVariables.getMessageMap().getKeyPath("", true), SQUARE_BRACKET_LEFT, SQUARE_BRACKET_RIGHT); String indexWithParams = SQUARE_BRACKET_LEFT + index + SQUARE_BRACKET_RIGHT; if (isDebit) { return AUXILIARY_LINE_HELPER_PROPERTY_NAME + indexWithParams + VOUCHER_LINE_HELPER_DEBIT_PROPERTY_NAME; } else { return AUXILIARY_LINE_HELPER_PROPERTY_NAME + indexWithParams + VOUCHER_LINE_HELPER_CREDIT_PROPERTY_NAME; } } }
From source file:org.kuali.kfs.fp.document.validation.impl.JournalVoucherAccountingLineAmountValidation.java
/** * This method looks at the current full key path that exists in the MessageMap structure to determine how to build * the error map for the special journal voucher credit and debit fields since they don't conform to the standard * pattern of accounting lines./*from ww w . ja va 2 s . co m*/ * * The error map key path is also dependent on whether or not the accounting line containing an error is a new * accounting line or an existing line that is being updated. This determination is made by searching for * NEW_SOURCE_ACCT_LINE_PROPERTY_NAME in the error path of the global error map. * * @param isDebit Identifies whether or not the line we are returning an error path for is a debit accounting line or not. * @return The full error map key path for the appropriate amount type. */ protected String buildMessageMapKeyPathForDebitCreditAmount(boolean isDebit) { // determine if we are looking at a new line add or an update boolean isNewLineAdd = GlobalVariables.getMessageMap().getErrorPath() .contains(NEW_SOURCE_ACCT_LINE_PROPERTY_NAME); isNewLineAdd |= GlobalVariables.getMessageMap().getErrorPath().contains(NEW_SOURCE_ACCT_LINE_PROPERTY_NAME); if (isNewLineAdd) { return isDebit ? DEBIT_AMOUNT_PROPERTY_NAME : CREDIT_AMOUNT_PROPERTY_NAME; } else { String index = StringUtils.substringBetween(GlobalVariables.getMessageMap().getKeyPath("", true), SQUARE_BRACKET_LEFT, SQUARE_BRACKET_RIGHT); String indexWithParams = SQUARE_BRACKET_LEFT + index + SQUARE_BRACKET_RIGHT; return isDebit ? (JOURNAL_LINE_HELPER_PROPERTY_NAME + indexWithParams + VOUCHER_LINE_HELPER_DEBIT_PROPERTY_NAME) : (JOURNAL_LINE_HELPER_PROPERTY_NAME + indexWithParams + VOUCHER_LINE_HELPER_CREDIT_PROPERTY_NAME); } }