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.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.java
/** * Like term, this would mark a key date for deletion. If it's newly added, just deletes it. * * @param academicCalendarForm/* w w w . j a va 2 s. c o m*/ * @param result * @param request * @param response * @return */ @RequestMapping(method = RequestMethod.POST, params = "methodToCall=deleteKeyDate") public ModelAndView deleteKeyDate(@ModelAttribute("KualiForm") AcademicCalendarForm academicCalendarForm, BindingResult result, HttpServletRequest request, HttpServletResponse response) { academicCalendarForm.setFieldsToSave(processDirtyFields(academicCalendarForm)); String selectedCollectionPath = academicCalendarForm .getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH); if (StringUtils.isBlank(selectedCollectionPath)) { throw new RuntimeException("unable to determine the selected collection path"); } int selectedLineIndex = KSControllerHelper.getSelectedCollectionLineIndex(academicCalendarForm); String selectedTermIndex = StringUtils.substringBetween(selectedCollectionPath, "termWrapperList[", "]"); String selectedKeyDateGroup = StringUtils.substringBetween(selectedCollectionPath, "keyDatesGroupWrappers[", "]"); AcademicTermWrapper termWrapper = academicCalendarForm.getTermWrapperList() .get(Integer.parseInt(selectedTermIndex)); KeyDatesGroupWrapper keydateGroup = termWrapper.getKeyDatesGroupWrappers() .get(Integer.parseInt(selectedKeyDateGroup)); KeyDateWrapper keyDateWrapper = keydateGroup.getKeydates().get(selectedLineIndex); if (StringUtils.isNotBlank(keyDateWrapper.getKeyDateInfo().getId())) { termWrapper.getKeyDatesToDeleteOnSave().add(keyDateWrapper); } keydateGroup.getKeydates().remove(selectedLineIndex); academicCalendarForm.getAddedCollectionItems().remove(keyDateWrapper); return getUIFModelAndView(academicCalendarForm); }
From source file:org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.java
/** * Like term, this would mark an exam period for deletion. * * @param academicCalendarForm//from w w w. java2 s . c om * @param result * @param request * @param response * @return */ @RequestMapping(method = RequestMethod.POST, params = "methodToCall=markExamPeriodtoDelete") public ModelAndView markExamPeriodtoDelete( @ModelAttribute("KualiForm") AcademicCalendarForm academicCalendarForm, BindingResult result, HttpServletRequest request, HttpServletResponse response) { academicCalendarForm.setFieldsToSave(processDirtyFields(academicCalendarForm)); String selectedCollectionPath = academicCalendarForm .getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH); if (StringUtils.isBlank(selectedCollectionPath)) { throw new RuntimeException("unable to determine the selected collection path"); } int selectedLineIndex = KSControllerHelper.getSelectedCollectionLineIndex(academicCalendarForm); String selectedTermIndex = StringUtils.substringBetween(selectedCollectionPath, "termWrapperList[", "]"); AcademicTermWrapper termWrapper = academicCalendarForm.getTermWrapperList() .get(Integer.parseInt(selectedTermIndex)); ExamPeriodWrapper examPeriodWrapper = termWrapper.getExamdates().get(selectedLineIndex); if (StringUtils.isNotBlank(examPeriodWrapper.getExamPeriodInfo().getId())) { termWrapper.getExamPeriodsToDeleteOnSave().add(examPeriodWrapper); } termWrapper.getExamdates().remove(selectedLineIndex); return getUIFModelAndView(academicCalendarForm); }
From source file:org.kuali.student.enrollment.class2.acal.controller.AcademicCalendarController.java
@RequestMapping(params = "methodToCall=deleteKeyDateGroup") public ModelAndView deleteKeyDateGroup(@ModelAttribute("KualiForm") AcademicCalendarForm academicCalendarForm, BindingResult result, HttpServletRequest request, HttpServletResponse response) { academicCalendarForm.setFieldsToSave(processDirtyFields(academicCalendarForm)); String selectedCollectionPath = academicCalendarForm .getActionParamaterValue(UifParameters.SELECTED_COLLECTION_PATH); if (StringUtils.isBlank(selectedCollectionPath)) { throw new RuntimeException("unable to determine the selected collection path"); }/* w w w . j a v a2 s . c o m*/ int selectedLineIndex = KSControllerHelper.getSelectedCollectionLineIndex(academicCalendarForm); String selectedTermIndex = StringUtils.substringBetween(selectedCollectionPath, "termWrapperList[", "]"); AcademicTermWrapper termWrapper = academicCalendarForm.getTermWrapperList() .get(Integer.parseInt(selectedTermIndex)); KeyDatesGroupWrapper keydateGroup = termWrapper.getKeyDatesGroupWrappers().get(selectedLineIndex); for (KeyDateWrapper keyDateWrapper : keydateGroup.getKeydates()) { if (StringUtils.isNotBlank(keyDateWrapper.getKeyDateInfo().getId())) { termWrapper.getKeyDatesToDeleteOnSave().add(keyDateWrapper); } } termWrapper.getKeyDatesGroupWrappers().remove(keydateGroup); return getUIFModelAndView(academicCalendarForm); }
From source file:org.mule.modules.jive.api.JiveClient.java
/**Executes an operation and extract the response from the xml from the given tagName. * @param uri The resource uri to make the request * @param method The http method to use//from w w w . ja va 2 s .c o m * @param tagName The tagName that holds the answer * @return */ public String doRequestAndExtractTagBetween(final String uri, final String method, final String tagName) { final String response = resource.path(uri).method(method, String.class); return StringUtils.substringBetween(response, "<" + tagName + ">", "</" + tagName + ">"); }
From source file:org.mule.modules.salesforce.automation.testcases.BatchResultStreamTestCases.java
@Category({ RegressionTests.class }) @Test//from w ww . j a v a 2s . c o m public void testBatchResultStream() { BatchInfo batchInfo; String[] results; String id; String success; boolean isSuccess = true; List<String> sObjectsIds = new ArrayList<String>(); try { batchInfo = getBatchInfoByOperation(createBatchFlow); do { Thread.sleep(BATCH_PROCESSING_DELAY); testObjects.put("batchInfoRef", batchInfo); batchInfo = getBatchInfoByOperation(batchInfoFlow); } while (batchInfo.getState().equals(com.sforce.async.BatchStateEnum.InProgress) || batchInfo.getState().equals(com.sforce.async.BatchStateEnum.Queued)); assertTrue(batchInfo.getState().equals(com.sforce.async.BatchStateEnum.Completed)); MuleEvent response = (MuleEvent) batchResultStreamFlow.process(getTestEvent(testObjects)); String operationResponse = IOUtils.toString((InputStream) response.getMessage().getPayload()); results = StringUtils.substringsBetween(operationResponse, "<result>", "</result>"); for (int index = 0; index < results.length; index++) { id = StringUtils.substringBetween(results[index], "<id>", "</id>"); success = StringUtils.substringBetween(results[index], "<success>", "</success>"); if (success.equals("true")) { sObjectsIds.add(id); } else { isSuccess = false; } } testObjects.put("idsToDeleteFromMessage", sObjectsIds); assertTrue(isSuccess); } catch (Exception e) { e.printStackTrace(); fail(); } }
From source file:org.mule.modules.salesforce.automation.testcases.QueryResultStreamTestCases.java
@Category({ RegressionTests.class }) @Test/*from ww w . ja v a 2s.co m*/ public void testQueryResultStream() { BatchInfo batchInfo; String[] results; String id; String success; boolean isSuccess = true; List<String> sObjectsIds = new ArrayList<String>(); try { batchInfo = getBatchInfoByOperation(createBatchFlow); do { Thread.sleep(BATCH_PROCESSING_DELAY); testObjects.put("batchInfoRef", batchInfo); batchInfo = getBatchInfoByOperation(batchInfoFlow); } while (batchInfo.getState().equals(com.sforce.async.BatchStateEnum.InProgress) || batchInfo.getState().equals(com.sforce.async.BatchStateEnum.Queued)); assertTrue(batchInfo.getState().equals(com.sforce.async.BatchStateEnum.Completed)); MuleEvent response = (MuleEvent) batchQueryStreamFlow.process(getTestEvent(testObjects)); String operationResponse = IOUtils.toString((InputStream) response.getMessage().getPayload()); results = StringUtils.substringsBetween(operationResponse, "<result>", "</result>"); for (int index = 0; index < results.length; index++) { id = StringUtils.substringBetween(results[index], "<id>", "</id>"); success = StringUtils.substringBetween(results[index], "<success>", "</success>"); if (success.equals("true")) { sObjectsIds.add(id); } else { isSuccess = false; } } testObjects.put("idsToDeleteFromMessage", sObjectsIds); assertTrue(isSuccess); } catch (Exception e) { e.printStackTrace(); fail(); } }
From source file:org.ojbc.processor.person.query.IncidentReportRequestProcessor.java
public String invokeRequest(DetailsRequest incidentReportRequest, String federatedQueryID, Element samlToken) throws Exception { if (allowQueriesWithoutSAMLToken) { if (samlToken == null) { //Add SAML token to request call samlToken = SAMLTokenUtils.createStaticAssertionAsElement( "https://idp.ojbc-local.org:9443/idp/shibboleth", SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS, SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1, true, true, null); }//from ww w. jav a 2 s .c o m } if (samlToken == null) { throw new Exception("No SAML token provided. Unable to perform query."); } //The details request object does not accommodate an incident category code required by the Spillman system //The XSLT will create an Incident ID like this: {IncidentCategoryCode}IncidentID //Thus for non-spillman entities, we remove the incident category code and enclosing curly braces prior to calling //those systems. String incidentCategoryCode = ""; log.debug("Incident ID from web portal: " + incidentReportRequest.getIdentificationID()); log.debug("Incident Source Text from web portal: " + incidentReportRequest.getIdentificationSourceText()); if (incidentReportRequest.getIdentificationSourceText().equals( "{http://ojbc.org/Services/WSDL/IncidentReportRequestService/1.0}SubmitIncidentIdentiferIncidentReportRequest-DPS")) { if (incidentReportRequest.getIdentificationID().startsWith("{Citation}")) { incidentCategoryCode = "Citation"; } else if (incidentReportRequest.getIdentificationID().startsWith("{Law}")) { incidentCategoryCode = "Law"; } else if (incidentReportRequest.getIdentificationID().startsWith("{Warning}")) { incidentCategoryCode = "Warning"; } else { throw new IllegalStateException("Incident Category Code not specified. It is set to: " + incidentReportRequest.getIdentificationID()); } } String incidentIDCategoryCode = StringUtils.substringBetween(incidentReportRequest.getIdentificationID(), "{", "}"); String incidentIDwithCategoryCodeRemoved = StringUtils.remove(incidentReportRequest.getIdentificationID(), "{" + incidentIDCategoryCode + "}"); //POJO to XML Request String personToIncidentRequestPayload = RequestMessageBuilderUtilities.createIncidentReportRequest( incidentIDwithCategoryCodeRemoved, incidentReportRequest.getIdentificationSourceText(), incidentCategoryCode); //Create exchange Exchange senderExchange = new DefaultExchange(camelContext, ExchangePattern.InOnly); //Set exchange body to XML Request message senderExchange.getIn().setBody(personToIncidentRequestPayload); //Set reply to and WS-Addressing message ID senderExchange.getIn().setHeader("federatedQueryRequestGUID", federatedQueryID); senderExchange.getIn().setHeader("WSAddressingReplyTo", this.getReplyToAddress()); //Set the token header so that CXF can retrieve this on the outbound call String tokenID = senderExchange.getExchangeId(); senderExchange.getIn().setHeader("tokenID", tokenID); OJBSamlMap.putToken(tokenID, samlToken); incidentReportRequestMessageProcessor.sendResponseMessage(camelContext, senderExchange); //Put message ID and "noResponse" place holder. putRequestInMap(federatedQueryID); String response = pollMap(federatedQueryID); if (response.length() > 500) { log.debug("Here is the response (truncated): " + response.substring(0, 500)); } else { log.debug("Here is the response: " + response); } //return response here return response; }
From source file:org.ojbc.util.camel.helper.NDexUtils.java
public String getIncidentIDFromFileName(@Header(value = "CamelFileName") String camelFileName) { String agencyOri = StringUtils.substringBetween(camelFileName, "INCIDENT_", "_DATE"); if (StringUtils.isBlank(agencyOri)) { return "UnknownIncidentID"; }/*from w ww .j a v a 2s . co m*/ return agencyOri; }
From source file:org.ojbc.util.camel.helper.TestNDexUtils.java
@Test public void testCreateNdexFormatFileName() throws Exception { //Expected file name: ME306000_20140422_1024_0001.xml String ndexFileName = ndexUtils.createNdexFormatFileName("ME306000"); assertTrue(ndexFileName.startsWith("ME306000")); assertTrue(ndexFileName.endsWith("0001.xml")); String between = StringUtils.substringBetween(ndexFileName, "ME306000", "0001.xml"); assertEquals(15, between.length());/* ww w .ja v a 2 s.co m*/ ndexFileName = ndexUtils.createNDexTestFileName(ndexFileName); assertTrue(ndexFileName.startsWith("TESTME306000")); assertTrue(ndexFileName.endsWith("0001.xml")); between = StringUtils.substringBetween(ndexFileName, "ME306000", "0001.xml"); assertEquals(15, between.length()); }
From source file:org.onehippo.forge.embargo.repository.modules.EmbargoWorkflowEventsProcessingModule.java
private String getUuidFromReturnValue(final String returnValue) { return StringUtils.substringBetween(returnValue, "uuid=", ","); }