List of usage examples for java.lang Error getMessage
public String getMessage()
From source file:org.wso2.carbon.mediation.templates.services.EndpointTemplateEditorAdmin.java
public boolean hasDuplicateTempleteEndpoint(String templateElementConfig) throws AxisFault { OMElement templateElement = null;// w ww. j a va 2 s .co m try { templateElement = AXIOMUtil.stringToOM(templateElementConfig); } catch (XMLStreamException e) { handleException("unable to Checking template Endpoint...invalid configuration element", e); } if (templateElement != null) { final Lock lock = getLock(); try { lock.lock(); if (templateElement.getLocalName().equals(XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) { String templateName = templateElement.getAttributeValue(new QName("name")); SynapseConfiguration config = getSynapseConfiguration(); if (log.isDebugEnabled()) { log.debug("Checking template : " + templateName + " with existing configuration"); } if (config.getLocalRegistry().get(templateName) != null) { return true; } } } catch (Exception fault) { handleException("Error Checking template : " + fault.getMessage(), fault); } catch (Error error) { throw new AxisFault( "Unexpected error occured while " + "Checking the template : " + error.getMessage(), error); } finally { lock.unlock(); } } return false; }
From source file:org.apache.metron.stellar.dsl.functions.resolver.ClasspathFunctionResolver.java
/** * Returns a set of classes that should undergo further interrogation for resolution * (aka discovery) of Stellar functions. *//*w w w. ja v a2s . co m*/ @Override public Set<Class<? extends StellarFunction>> resolvables() { ClassLoader[] cls = null; if (this.classLoaders.size() == 0) { LOG.warn("Using System classloader"); cls = new ClassLoader[] { getClass().getClassLoader() }; } else { cls = new ClassLoader[this.classLoaders.size()]; for (int i = 0; i < this.classLoaders.size(); ++i) { ClassLoader cl = this.classLoaders.get(i); LOG.debug("Using classloader: " + cl.getClass().getCanonicalName()); cls[i] = cl; } } FilterBuilder filterBuilder = new FilterBuilder(); excludes.forEach(excl -> { if (excl != null) { filterBuilder.exclude(excl); } }); includes.forEach(incl -> { if (incl != null) { filterBuilder.include(incl); } }); Set<String> classes = new HashSet<>(); Set<Class<? extends StellarFunction>> ret = new HashSet<>(); for (ClassLoader cl : cls) { for (Class<?> c : getStellarClasses(cl)) { try { LOG.debug("{}: Found class: {}", cl.getClass().getCanonicalName(), c.getCanonicalName()); if (includeClass(c, filterBuilder)) { String className = c.getName(); if (!classes.contains(className)) { LOG.debug("{}: Added class: {}", cl.getClass().getCanonicalName(), className); ret.add((Class<? extends StellarFunction>) c); classes.add(className); } } } catch (Error le) { //we have had some error loading a stellar function. This could mean that //the classpath is unstable (e.g. old copies of jars are on the classpath). try { LOG.error("Skipping class " + c.getName() + ": " + le.getMessage() + ", please check that there are not old versions of stellar functions on the classpath.", le); } catch (Error ie) { //it's possible that getName() will throw an exception if the class is VERY malformed. LOG.error("Skipping class: " + le.getMessage() + ", please check that there are not old versions of stellar functions on the classpath.", le); } } } } return ret; }
From source file:mobac.mapsources.loader.MapPackManager.java
public void loadMapPack(File mapPackFile, MapSourcesManager mapSourcesManager) throws CertificateException, IOException, MapSourceCreateException { // testMapPack(mapPackFile); URLClassLoader urlCl;//from ww w . j av a2 s .c o m URL url = mapPackFile.toURI().toURL(); urlCl = new MapPackClassLoader(url, ClassLoader.getSystemClassLoader()); InputStream manifestIn = urlCl.getResourceAsStream("META-INF/MANIFEST.MF"); String rev = null; if (manifestIn != null) { Manifest mf = new Manifest(manifestIn); rev = mf.getMainAttributes().getValue("MapPackRevision"); manifestIn.close(); if (rev != null) { if ("exported".equals(rev)) { rev = ProgramInfo.getRevisionStr(); } else { rev = Integer.toString(Utilities.parseSVNRevision(rev)); } } mf = null; } MapSourceLoaderInfo loaderInfo = new MapSourceLoaderInfo(LoaderType.MAPPACK, mapPackFile, rev); final Iterator<MapSource> iterator = ServiceLoader.load(MapSource.class, urlCl).iterator(); while (iterator.hasNext()) { try { MapSource ms = iterator.next(); ms.setLoaderInfo(loaderInfo); mapSourcesManager.addMapSource(ms); log.trace("Loaded map source: " + ms.toString() + " (name: " + ms.getName() + ")"); } catch (Error e) { urlCl = null; throw new MapSourceCreateException("Failed to load a map sources from map pack: " + mapPackFile.getName() + " " + e.getMessage(), e); } } }
From source file:io.instacount.client.InstacountClientTest.java
private void doNotFoundAssertions(final Errors errors) { assertThat(errors, is(not(nullValue()))); assertThat(errors.getHttpResponseCode(), is(404)); assertThat(errors.getErrors(), is(not(nullValue()))); assertThat(errors.getErrors().size(), is(1)); final Error error = errors.getErrors().get(0); assertThat(error.getMessage(), is("What you requested does not exist.")); assertThat(error.getDeveloperMessage(), is("The requested resource was not found!")); assertThat(error.getMoreInfo(), is("https://instacount.readme.io")); }
From source file:io.instacount.client.InstacountClientTest.java
@Test public void testCreateCounter_WithPayload_WithExistingCounterName() throws InstacountClientException { final String counterName = UUID.randomUUID().toString(); final CreateShardedCounterInput createCounterInput = new CreateShardedCounterInput(counterName); final CreateShardedCounterResponse actualResponse = this.client.createShardedCounter(createCounterInput); this.doBasicAssertions(actualResponse, 201); // Try again, expect an error! try {//from ww w . j av a 2s. c o m this.client.createShardedCounter(createCounterInput); } catch (InstacountClientException e) { assertThat(e.getErrors(), is(not(nullValue()))); assertThat(e.getErrors().getHttpResponseCode(), is(409)); assertThat(e.getErrors().getErrors(), is(not(nullValue()))); assertThat(e.getErrors().getErrors().size(), is(1)); final Error error = e.getErrors().getErrors().get(0); assertThat(error.getMessage(), is("This counter already exists!")); assertThat(error.getDeveloperMessage(), is("A sharded counter with the specified name already exists!")); assertThat(error.getMoreInfo(), is("https://instacount.readme.io")); } }
From source file:org.simbasecurity.core.saml.SAMLResponseHandlerImpl.java
@Override public boolean isValid(String... requestId) { try {/* ww w. ja va2 s .c o m*/ Calendar now = Calendar.getInstance(TimeZone.getTimeZone("UTC")); if (this.document == null) { throw new Exception("SAML Response is not loaded"); } if (this.currentUrl == null || this.currentUrl.isEmpty()) { throw new Exception("The URL of the current host was not established"); } // Check SAML version if (!rootElement.getAttribute("Version").equals("2.0")) { throw new Exception("Unsupported SAML Version."); } // Check ID in the response if (!rootElement.hasAttribute("ID")) { throw new Exception("Missing ID attribute on SAML Response."); } checkStatus(); if (!this.validateNumAssertions()) { throw new Exception("SAML Response must contain 1 Assertion."); } NodeList signNodes = document.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature"); ArrayList<String> signedElements = new ArrayList<>(); for (int i = 0; i < signNodes.getLength(); i++) { signedElements.add(signNodes.item(i).getParentNode().getLocalName()); } if (!signedElements.isEmpty()) { if (!this.validateSignedElements(signedElements)) { throw new Exception("Found an unexpected Signature Element. SAML Response rejected"); } } Document res = Utils.validateXML(this.document, "saml-schema-protocol-2.0.xsd"); if (res == null) { throw new Exception("Invalid SAML Response. Not match the saml-schema-protocol-2.0.xsd"); } if (rootElement.hasAttribute("InResponseTo")) { String responseInResponseTo = document.getDocumentElement().getAttribute("InResponseTo"); if (requestId.length > 0 && responseInResponseTo.compareTo(requestId[0]) != 0) { throw new Exception("The InResponseTo of the Response: " + responseInResponseTo + ", does not match the ID of the AuthNRequest sent by the SP: " + requestId[0]); } } // Validate Assertion timestamps if (!this.validateTimestamps()) { throw new Exception("Timing issues (please check your clock settings)"); } // EncryptedAttributes are not supported NodeList encryptedAttributeNodes = this .queryAssertion("/saml:AttributeStatement/saml:EncryptedAttribute"); if (encryptedAttributeNodes.getLength() > 0) { throw new Exception("There is an EncryptedAttribute in the Response and this SP not support them"); } // Check destination // TODO: lenneh: bktis: currentUrl is http:// and the destination is https:// // if (rootElement.hasAttribute("Destination")) { // String destinationUrl = rootElement.getAttribute("Destination"); // if (destinationUrl != null) { // if (!destinationUrl.equals(currentUrl)) { // throw new Exception("The response was received at " + currentUrl + " instead of " + destinationUrl); // } // } // } // Check Audience // TODO: lenneh: bktis: currentUrl is http:// and audienceUrl is https:// // Set<String> validAudiences = this.getAudiences(); // // if (validAudiences.isEmpty() || !this.audienceUrl.equals(currentUrl)) { // throw new Exception(this.audienceUrl + " is not a valid audience for this Response"); // } // Check the issuers Set<String> issuers = this.getIssuers(); for (String issuer : issuers) { if (issuer.isEmpty()) { throw new Exception("Invalid issuer in the Assertion/Response"); } } // Check the session Expiration Calendar sessionExpiration = this.getSessionNotOnOrAfter(); if (sessionExpiration != null) { if (now.equals(sessionExpiration) || now.after(sessionExpiration)) { throw new Exception( "The attributes have expired, based on the SessionNotOnOrAfter of the AttributeStatement of this Response"); } } // Check SubjectConfirmation, at least one SubjectConfirmation must be valid boolean validSubjectConfirmation = true; NodeList subjectConfirmationNodes = this.queryAssertion("/saml:Subject/saml:SubjectConfirmation"); for (int i = 0; i < subjectConfirmationNodes.getLength(); i++) { Node scn = subjectConfirmationNodes.item(i); Node method = scn.getAttributes().getNamedItem("Method"); if (method != null && !method.getNodeValue().equals(SAMLConstants.CM_BEARER)) { continue; } NodeList subjectConfirmationDataNodes = scn.getChildNodes(); for (int c = 0; c < subjectConfirmationDataNodes.getLength(); c++) { Node subjectConfirmationData = subjectConfirmationDataNodes.item(c); if (subjectConfirmationData.getNodeType() == Node.ELEMENT_NODE && subjectConfirmationData.getLocalName().equals("SubjectConfirmationData")) { // TODO: lenneh: bktis: currentUrl is http:// and the recipient is https:// // Node recipient = subjectConfirmationData.getAttributes().getNamedItem("Recipient"); // if (recipient != null && !recipient.getNodeValue().equals(currentUrl)) { // validSubjectConfirmation = false; // } Node notOnOrAfter = subjectConfirmationData.getAttributes().getNamedItem("NotOnOrAfter"); if (notOnOrAfter != null) { Calendar noa = javax.xml.bind.DatatypeConverter .parseDateTime(notOnOrAfter.getNodeValue()); if (now.equals(noa) || now.after(noa)) { validSubjectConfirmation = false; } } Node notBefore = subjectConfirmationData.getAttributes().getNamedItem("NotBefore"); if (notBefore != null) { Calendar nb = javax.xml.bind.DatatypeConverter.parseDateTime(notBefore.getNodeValue()); if (now.before(nb)) { validSubjectConfirmation = false; } } } } } if (!validSubjectConfirmation) { throw new Exception("A valid SubjectConfirmation was not found on this Response"); } if (signedElements.isEmpty()) { throw new Exception("No Signature found. SAML Response rejected"); } else { if (!Utils.validateSign(signNodes.item(0), certificate)) { throw new Exception("Signature validation failed. SAML Response rejected"); } } return true; } catch (Error e) { error.append(e.getMessage()); return false; } catch (Exception e) { e.printStackTrace(); error.append(e.getMessage()); return false; } }
From source file:com.sforce.cd.apexUnit.client.testEngine.TestStatusPollerAndResultHandler.java
public boolean waitForTestsToComplete(String parentJobId, PartnerConnection conn) { String soql = QueryConstructor.getTestExecutionStatus(parentJobId); // String soql = // QueryConstructor.getTestExecutionStatusAndTransactionTime(parentJobId); QueryResult queryResult;//from w w w .j a v a 2s . c o m boolean testsCompleted = false; try { LOG.debug(soql); int index = 0; queryResult = conn.query(soql); if (queryResult.getDone()) { SObject[] sObjects = queryResult.getRecords(); if (sObjects != null) { String status = ""; int totalTests = sObjects.length; totalTestClasses = totalTests; int remainingTests = totalTests; LOG.info("Total test classes to execute: " + totalTestClasses); String testId = ""; String testName = ""; String id = ""; StopWatch stopWatch = new StopWatch(); long startTime = 0; long endTime = 0; for (SObject sobject : sObjects) { sobject.setType("ApexTestQueueItem"); status = sobject.getField("Status").toString(); testId = sobject.getField("ApexClassId").toString(); id = sobject.getField("Id").toString(); LOG.debug("ID for ApexTestQueueItem: " + id); testName = ApexClassFetcherUtils.apexClassMap.get(testId); LOG.info("Now executing the test class: " + testName + " (" + CommandLineArguments.getOrgUrl() + "/" + testId + " ) " + "Status : " + status); stopWatch.reset(); stopWatch.start(); startTime = stopWatch.getTime(); LOG.debug("Start time: " + startTime); while (status.equals("Processing") || status.equals("Queued") || status.equals("Preparing") || !status.equals("Completed")) { // break out of the loop if the test failed if (status.equals("Failed")) { LOG.info("Test class failure for : " + testName + " (" + CommandLineArguments.getOrgUrl() + "/" + testId + " ) "); break; } else if (status.equals("Aborted")) { LOG.info("Test : " + testName + " (" + CommandLineArguments.getOrgUrl() + "/" + testId + " ) has been aborted."); totalTestClassesAborted++; break; } // Abort the long running tests based on user // input(default: 10 minutes) // stopWatch.getTime() will be in milliseconds, // hence divide by 1000 to convert to seconds // maxTestExecTimeThreshold will be in minutes, // hence multiply by 60 to convert to seconds if (CommandLineArguments.getMaxTestExecTimeThreshold() != null && stopWatch.getTime() / 1000.0 > CommandLineArguments.getMaxTestExecTimeThreshold() * 60 && status.equals("Processing")) { LOG.info("Oops! This test is a long running test. " + CommandLineArguments.getMaxTestExecTimeThreshold() + " minutes elapsed; aborting the test: " + testName); // create new sobject for updating the record SObject newSObject = new SObject(); newSObject.setType("ApexTestQueueItem"); newSObject.setField("Id", id); // abort the test using DML, set status to // "Aborted" newSObject.setField("Status", "Aborted"); totalTestClassesAborted++; // logging the status and id fields to compare // them for pre and post update call try { // TODO : up to 10 records can be updated at // a time by update() call. // add the logic to leverage this feature. // Currently only one record is being // updated(aborted) // Challenge: By the time we wait for 10 // records that needs to be aborted, the // 'to-be-aborted' test might continue to // run and might get completed // update() call- analogous to UPDATE // Statement in SQL SaveResult[] saveResults = conn.update(new SObject[] { newSObject }); LOG.debug("Stop time: " + stopWatch.getTime()); stopWatch.stop(); for (int i = 0; i < saveResults.length; i++) { if (saveResults[i].isSuccess()) { LOG.debug("The record " + saveResults[i].getId() + " was updated successfully"); LOG.info("Aborted test case: " + testName + " since the test took more time than the threshold execution time of " + CommandLineArguments.getMaxTestExecTimeThreshold() + " mins"); } else { // There were errors during the // update call, so loop through and // print them out StringBuffer errorMsg = new StringBuffer(); errorMsg.append("Record " + saveResults[i].getId() + " failed to save"); for (int j = 0; j < saveResults[i].getErrors().length; j++) { com.sforce.soap.partner.Error err = saveResults[i].getErrors()[j]; errorMsg.append("error code: " + err.getStatusCode().toString()); errorMsg.append("error message: " + err.getMessage()); } ApexUnitUtils.shutDownWithErrMsg(errorMsg.toString()); } } LOG.debug("After update--" + newSObject.getField("Status").toString()); break; } catch (ConnectionException e) { ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler.logConnectionException(e, conn, soql)); } } LOG.debug("Status of the test class: " + testName + " (" + CommandLineArguments.getOrgUrl() + "/" + testId + " ) " + " is : " + status); while (stopWatch.getTime() % 1000 != 0) { // wait, till 1 second elapses } LOG.debug("Firing polling query at " + stopWatch.getTime()); queryResult = conn.query(soql); sObjects = queryResult.getRecords(); status = sObjects[index].getField("Status").toString(); } endTime = stopWatch.getTime(); // get and log extended status for the test if (sObjects[index] != null && sObjects[index].getField("ExtendedStatus") != null) { String extendedStatus = sObjects[index].getField("ExtendedStatus").toString(); LOG.info("Test status for " + testName + ":" + extendedStatus); } LOG.info("Completed executing the test class: " + testName + ". Time taken by the test: " + endTime / 1000 / 60 + " minutes," + (endTime / 1000) % 60 + " seconds"); index++; remainingTests = totalTests - index; LOG.info("Total tests executed " + index + " , Remaining tests " + remainingTests); if (remainingTests == 0) { testsCompleted = true; } } } } } catch (ConnectionException e) { ApexUnitUtils.shutDownWithDebugLog(e, ConnectionHandler.logConnectionException(e, conn, soql)); } return testsCompleted; }
From source file:twitter4j.internal.json.DAOTest.java
public void testUnparsable() throws Exception { String str;/*from www .j a va 2 s . c o m*/ str = ""; try { DataObjectFactory.createStatus(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } try { DataObjectFactory.createStatus(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } str = "{\"in_reply_to_status_id_str\":null,\"place\":null,\"in_reply_to_user_id\":null,\"text\":\"working\",\"contributors\":null,\"retweet_count\":0,\"in_reply_to_user_id_str\":null,\"retweeted\":false,\"id_str\":\"794626207\",\"source\":\"\\u003Ca href=\\\"http:\\/\\/twitterhelp.blogspot.com\\/2008\\/05\\/twitter-via-mobile-web-mtwittercom.html\\\" rel=\\\"nofollow\\\"\\u003Emobile web\\u003C\\/a\\u003E\",\"truncated\":false,\"geo\":null,\"in_reply_to_status_id\":null,\"favorited\":false,\"user\":{\"show_all_inline_media\":false,\"geo_enabled\":false,\"profile_background_tile\":false,\"time_zone\":null,\"favourites_count\":0,\"description\":null,\"friends_count\":0,\"profile_link_color\":\"0084B4\",\"location\":null,\"profile_sidebar_border_color\":\"C0DEED\",\"id_str\":\"14481043\",\"url\":null,\"follow_request_sent\":false,\"statuses_count\":1,\"profile_use_background_image\":true,\"lang\":\"en\",\"profile_background_color\":\"C0DEED\",\"profile_image_url\":\"http:\\/\\/a3.twimg.com\\/a\\/1292975674\\/images\\/default_profile_3_normal.png\",\"profile_background_image_url\":\"http:\\/\\/a3.twimg.com\\/a\\/1292975674\\/images\\/themes\\/theme1\\/bg.png\",\"followers_count\":44,\"protected\":false,\"contributors_enabled\":false,\"notifications\":false,\"screen_name\":\"Yusuke\",\"name\":\"Yusuke\",\"is_translator\":false,\"listed_count\":1,\"following\":false,\"verified\":false,\"profile_text_color\":\"333333\",\"id\":14481043,\"utc_offset\":null,\"created_at\":\"Tue Apr 22 21:49:13 +0000 2008\",\"profile_sidebar_fill_color\":\"DDEEF6\"},\"id\":794626207,\"coordinates\":null,\"in_reply_to_screen_name\":null,\"created_at\":\"Tue Apr 2200 21:49:34 +0000 2008\""; try { DataObjectFactory.createCategory(str); fail("should fail"); } catch (TwitterException expected) { expected.printStackTrace(); } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } try { DataObjectFactory.createCategory(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } }
From source file:twitter4j.DAOTest.java
public void testUnparsable() throws Exception { String str;// w ww . ja v a2 s .c om str = ""; try { DataObjectFactory.createTweet(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } try { DataObjectFactory.createTweet(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } str = "{\"in_reply_to_status_id_str\":null,\"place\":null,\"in_reply_to_user_id\":null,\"text\":\"working\",\"contributors\":null,\"retweet_count\":0,\"in_reply_to_user_id_str\":null,\"retweeted\":false,\"id_str\":\"794626207\",\"source\":\"\\u003Ca href=\\\"http:\\/\\/twitterhelp.blogspot.com\\/2008\\/05\\/twitter-via-mobile-web-mtwittercom.html\\\" rel=\\\"nofollow\\\"\\u003Emobile web\\u003C\\/a\\u003E\",\"truncated\":false,\"geo\":null,\"in_reply_to_status_id\":null,\"favorited\":false,\"user\":{\"show_all_inline_media\":false,\"geo_enabled\":false,\"profile_background_tile\":false,\"time_zone\":null,\"favourites_count\":0,\"description\":null,\"friends_count\":0,\"profile_link_color\":\"0084B4\",\"location\":null,\"profile_sidebar_border_color\":\"C0DEED\",\"id_str\":\"14481043\",\"url\":null,\"follow_request_sent\":false,\"statuses_count\":1,\"profile_use_background_image\":true,\"lang\":\"en\",\"profile_background_color\":\"C0DEED\",\"profile_image_url\":\"http:\\/\\/a3.twimg.com\\/a\\/1292975674\\/images\\/default_profile_3_normal.png\",\"profile_background_image_url\":\"http:\\/\\/a3.twimg.com\\/a\\/1292975674\\/images\\/themes\\/theme1\\/bg.png\",\"followers_count\":44,\"protected\":false,\"contributors_enabled\":false,\"notifications\":false,\"screen_name\":\"Yusuke\",\"name\":\"Yusuke\",\"is_translator\":false,\"listed_count\":1,\"following\":false,\"verified\":false,\"profile_text_color\":\"333333\",\"id\":14481043,\"utc_offset\":null,\"created_at\":\"Tue Apr 22 21:49:13 +0000 2008\",\"profile_sidebar_fill_color\":\"DDEEF6\"},\"id\":794626207,\"coordinates\":null,\"in_reply_to_screen_name\":null,\"created_at\":\"Tue Apr 2200 21:49:34 +0000 2008\"}"; try { DataObjectFactory.createTweet(str); fail("should fail"); } catch (TwitterException expected) { expected.printStackTrace(); } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } try { DataObjectFactory.createTweet(str); fail("should fail"); } catch (TwitterException expected) { } catch (Error notExpected) { fail("failed" + notExpected.getMessage()); } }
From source file:org.wso2.carbon.mediation.templates.services.TemplateEditorAdmin.java
/** * Add a sequence into the synapseConfiguration * * @param templateElement - Sequence object to be added as an OMElement * @throws AxisFault if a sequence exists with the same name or if the * element provided is not a Sequence element *//*from w w w.ja va2 s . c o m*/ public void addTemplate(OMElement templateElement) throws AxisFault { final Lock lock = getLock(); try { lock.lock(); if (templateElement.getLocalName().equals(XMLConfigConstants.TEMPLATE_ELT.getLocalPart())) { String templateName = templateElement.getAttributeValue(new QName("name")); SynapseConfiguration config = getSynapseConfiguration(); if (log.isDebugEnabled()) { log.debug("Adding template : " + templateName + " to the configuration"); } if (config.getLocalRegistry().get(templateName) != null) { handleException("The name '" + templateName + "' is already used within the configuration"); } else { SynapseXMLConfigurationFactory.defineTemplate(config, templateElement, getSynapseConfiguration().getProperties()); if (log.isDebugEnabled()) { log.debug("Added template : " + templateName + " to the configuration"); } TemplateMediator templ = config.getSequenceTemplates().get(templateName); templ.setFileName(ServiceBusUtils.generateFileName(templateName)); templ.init(getSynapseEnvironment()); //noinspection ConstantConditions persistTemplate(templ); } } else { handleException("Invalid template definition"); } } catch (Exception fault) { handleException("Error adding template : " + fault.getMessage(), fault); } catch (Error error) { throw new AxisFault("Unexpected error occured while " + "adding the template : " + error.getMessage(), error); } finally { lock.unlock(); } }