List of usage examples for java.lang UnsupportedOperationException getMessage
public String getMessage()
From source file:org.codice.pubsub.stomp.SubscriptionQueryMessageListener.java
private boolean createSubscription(SearchQueryMessage queryMsg) { boolean success = false; String subscriptionId = queryMsg.getSubscriptionId(); //Build Query String cqlText = queryMsg.getQueryString(); if (StringUtils.isNotEmpty(cqlText)) { Filter filter = null;/*w w w . j av a 2 s . c o m*/ try { filter = CQL.toFilter(cqlText); } catch (CQLException e) { LOGGER.error("Fatal error while trying to build CQL-based Filter from cqlText : " + cqlText); return success; } //Add CSW Record Mapper Filter Visitor for more CQL filtering options try { FilterVisitor f = new CswRecordMapperFilterVisitor(); filter = (Filter) filter.accept(f, null); } catch (UnsupportedOperationException ose) { try { throw new CswException(ose.getMessage(), CswConstants.INVALID_PARAMETER_VALUE, null); } catch (CswException e) { LOGGER.error(e.getMessage()); return success; } } if (catalogFramework != null && filter != null) { LOGGER.trace("Catalog Frameowork: " + catalogFramework.getVersion()); //Set creation and last modified date times Calendar now = Calendar.getInstance(); queryMsg.setCreationDate(now.getTimeInMillis()); queryMsg.setLastModifiedDate(now.getTimeInMillis()); //Starts this class in a thread ExecutorService executor = Executors.newFixedThreadPool(NUM_QUERY_SEND_THREADS); QueryAndSend qasInst = queryAndSend.newInstance(); qasInst.setEnterprise(DEFAULT_IS_ENTERPRISE); qasInst.setFilter(filter); qasInst.setSubscriptionId(subscriptionId); Callable worker = qasInst; executor.submit(worker); //Add to Subscription Map ObjectMapper mapper = new ObjectMapper(); String jsonMsg = null; try { jsonMsg = mapper.writeValueAsString(queryMsg); } catch (JsonProcessingException e) { LOGGER.error(e.getMessage()); return success; } LOGGER.debug("Store Subscription: " + jsonMsg); Dictionary subMap = getSubscriptionMap(); subMap.put(subscriptionId, jsonMsg); setSubscriptionMap(subMap); //Set TTL (time to live) for subscription int ttlType = Calendar.MILLISECOND; String queryTtlType = queryMsg.getSubscriptionTtlType(); //If Query TTL Type is null, assume Milliseconds if (StringUtils.isBlank(queryTtlType)) { LOGGER.debug("Query TTL Type is null"); queryTtlType = TTL_TYPE_MILLISECONDS; } if (queryTtlType.equals(TTL_TYPE_MILLISECONDS)) { ttlType = Calendar.MILLISECOND; } else if (queryTtlType.equals(TTL_TYPE_SECONDS)) { ttlType = Calendar.SECOND; } else if (queryTtlType.equals(TTL_TYPE_MINUTES)) { ttlType = Calendar.MINUTE; } else if (queryTtlType.equals(TTL_TYPE_HOURS)) { ttlType = Calendar.HOUR; } else if (queryTtlType.equals(TTL_TYPE_MONTHS)) { ttlType = Calendar.MONTH; } else if (queryTtlType.equals(TTL_TYPE_YEARS)) { ttlType = Calendar.YEAR; } int queryTtl = queryMsg.getSubscriptionTtl(); LOGGER.debug("Query TTL: {}", queryTtl); if (queryTtl == -9 || queryTtl == 0) { //No TTL chosen; make it close to forever queryTtl = 9999; ttlType = Calendar.YEAR; } //Set TTL from creation time to TTL specified long creationTime = queryMsg.getCreationDate(); Calendar ttl = Calendar.getInstance(); ttl.setTimeInMillis(creationTime); ttl.add(ttlType, queryTtl); subscriptionTtlMap.put(subscriptionId, ttl); success = true; } else { LOGGER.trace("Catalog Framework or filter is NULL"); } } else { LOGGER.debug("Subscription ID is null: Subscription ID= {}", subscriptionId); } return success; }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractController.java
/** * Handle exception./* ww w. ja v a 2 s .c om*/ * * @param response the response * @param request the request * @param ex the ex * @return the model and view */ @ExceptionHandler(UnsupportedOperationException.class) @ResponseBody public CTS2Exception handleException(HttpServletResponse response, HttpServletRequest request, UnsupportedOperationException ex) { int status = HttpServletResponse.SC_NOT_IMPLEMENTED; response.setStatus(status); return ExceptionFactory.createUnknownException( "Method not implemented. " + ex.getMessage() != null ? ex.getMessage() : "", getUrlString(request), getParameterString(request)); }
From source file:org.drools.guvnor.server.files.WebDAVImplIntegrationTest.java
private void createResourceTry(WebDAVImpl webDAV, String path) { try {/*w ww . j av a 2s .c om*/ webDAV.createResource(new TransactionMock(), path); fail("Should not be allowed"); } catch (UnsupportedOperationException e) { assertNotNull(e.getMessage()); } }
From source file:org.drools.guvnor.server.files.WebDAVImplIntegrationTest.java
private void createFolderTry(WebDAVImpl webDAV, String path) { try {/*from w ww . ja v a2 s.c om*/ webDAV.createFolder(new TransactionMock(), path); fail("should not be allowed"); } catch (UnsupportedOperationException e) { assertNotNull(e.getMessage()); } }
From source file:org.drools.guvnor.server.files.WebDAVImplIntegrationTest.java
@Test public void testCreateFolder() throws Exception { String[] children = webDAV.getChildrenNames(new TransactionMock(), "/packages"); int packageCount = children.length; webDAV.createFolder(new TransactionMock(), "/packages/testCreateWebDavFolder"); children = webDAV.getChildrenNames(new TransactionMock(), "/packages"); assertEquals(packageCount + 1, children.length); assertContains("testCreateWebDavFolder", children); ModuleItem pkg = rulesRepository.loadModule("testCreateWebDavFolder"); assertNotNull(pkg);// w w w . j av a 2s . c o m pkg.addAsset("someAsset", ""); try { webDAV.createFolder(new TransactionMock(), "/somethingElse"); fail("this should not work !"); } catch (UnsupportedOperationException e) { assertNotNull(e.getMessage()); } }
From source file:org.structr.rest.servlet.GraphQLServlet.java
private void handleGraphQLRequest(final HttpServletRequest request, final HttpServletResponse response, final String query) throws IOException, FrameworkException { final SecurityContext securityContext; final Authenticator authenticator; try {/*from w w w. j a va 2s . c o m*/ // isolate request authentication in a transaction try (final Tx tx = StructrApp.getInstance().tx()) { authenticator = config.getAuthenticator(); securityContext = authenticator.initializeAndExamineRequest(request, response); tx.success(); } final App app = StructrApp.getInstance(securityContext); if (securityContext != null) { // isolate write output try (final Tx tx = app.tx()) { final Document doc = GraphQLRequest.parse(new Parser(), query); if (doc != null) { final List<ValidationError> errors = new Validator() .validateDocument(SchemaService.getGraphQLSchema(), doc); if (errors.isEmpty()) { // no validation errors in query, do request final GraphQLWriter graphQLWriter = new GraphQLWriter(true); // no trailing semicolon so we dont trip MimeTypes.getContentTypeWithoutCharset response.setContentType("application/json; charset=utf-8"); final Writer writer = response.getWriter(); graphQLWriter.stream(securityContext, writer, new GraphQLRequest(securityContext, doc, query)); writer.append("\n"); // useful newline } else { final Map<String, Object> map = new LinkedHashMap<>(); final Writer writer = response.getWriter(); final Gson gson = getGson(); map.put("errors", errors); gson.toJson(map, writer); writer.append("\n"); // useful newline // send 422 status response.setStatus(422); } } tx.success(); } } } catch (FrameworkException frameworkException) { // set status & write JSON output response.setStatus(frameworkException.getStatus()); getGson().toJson(frameworkException, response.getWriter()); response.getWriter().println(); } catch (IllegalStateException | IllegalArgumentException iex) { final Map<String, Object> map = new LinkedHashMap<>(); map.put("code", 422); map.put("message", iex.getMessage()); // set status & write JSON output response.setStatus(422); getGson().toJson(map, response.getWriter()); response.getWriter().println(); } catch (UnsupportedOperationException uoe) { logger.warn("POST not supported"); int code = HttpServletResponse.SC_BAD_REQUEST; response.setStatus(code); response.getWriter() .append(RestMethodResult.jsonError(code, "POST not supported: " + uoe.getMessage())); } catch (Throwable t) { logger.warn("Exception in POST", t); int code = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; response.setStatus(code); response.getWriter() .append(RestMethodResult.jsonError(code, "JsonSyntaxException in POST: " + t.getMessage())); } finally { try { //response.getWriter().flush(); response.getWriter().close(); } catch (Throwable t) { logger.warn("Unable to flush and close response: {}", t.getMessage()); } } }
From source file:org.drools.guvnor.server.files.WebDAVImplIntegrationTest.java
@Test public void testCreateResourceAndCreatedDate() throws Exception { webDAV.createFolder(new TransactionMock(), "/packages/testCreateResourceAndCreatedDate"); Thread.sleep(100);/*from w w w .j a v a 2s . c o m*/ webDAV.createResource(new TransactionMock(), "/packages/testCreateResourceAndCreatedDate/asset.drl"); String[] resources = webDAV.getChildrenNames(new TransactionMock(), "/packages/testCreateResourceAndCreatedDate"); assertEquals(1, resources.length); assertEquals("asset.drl", resources[0]); //should be ignored webDAV.createResource(new TransactionMock(), "/packages/testCreateResourceAndCreatedDate/._asset.drl"); webDAV.createResource(new TransactionMock(), "/packages/.DS_Store"); ModuleItem pkg = rulesRepository.loadModule("testCreateResourceAndCreatedDate"); assertFalse(pkg.containsAsset("._asset")); assertTrue(pkg.containsAsset("asset")); Iterator<AssetItem> it = pkg.getAssets(); AssetItem ass = it.next(); assertEquals("asset", ass.getName()); assertEquals("drl", ass.getFormat()); Date create = webDAV.getCreationDate("/packages/testCreateResourceAndCreatedDate"); assertNotNull(create); assertTrue(create.after(new Date("10-Jul-1974"))); Date assetCreate = webDAV.getCreationDate("/packages/testCreateResourceAndCreatedDate/asset.drl"); assertTrue(assetCreate.after(create)); Date lm = webDAV.getLastModified("/packages/testCreateResourceAndCreatedDate"); assertNotNull(lm); assertTrue(lm.after(new Date("10-Jul-1974"))); Date alm = webDAV.getLastModified("/packages/testCreateResourceAndCreatedDate/asset.drl"); assertTrue(alm.after(lm)); try { webDAV.createResource(new TransactionMock(), "/hummer.drl"); fail("Shouldn't be able to do this"); } catch (UnsupportedOperationException e) { assertNotNull(e.getMessage()); } }
From source file:org.apache.metamodel.elasticsearch.rest.ElasticSearchRestDataContextIT.java
@Test public void testDeleteUnsupportedQueryType() throws Exception { final Schema schema = dataContext.getDefaultSchema(); final CreateTable createTable = new CreateTable(schema, "testCreateTable"); createTable.withColumn("foo").ofType(ColumnType.STRING); createTable.withColumn("bar").ofType(ColumnType.NUMBER); dataContext.executeUpdate(createTable); final Table table = schema.getTableByName("testCreateTable"); dataContext.executeUpdate(new UpdateScript() { @Override/*from w w w.j a v a 2 s .c o m*/ public void run(UpdateCallback callback) { callback.insertInto(table).value("foo", "hello").value("bar", 42).execute(); callback.insertInto(table).value("foo", "world").value("bar", 43).execute(); } }); // greater than is not supported try { dataContext.executeUpdate(new DeleteFrom(table).where("bar").gt(40)); fail("Exception expected"); } catch (UnsupportedOperationException e) { assertEquals("Could not push down WHERE items to delete by query request: [testCreateTable.bar > 40]", e.getMessage()); } }
From source file:info.magnolia.cms.core.DefaultContent.java
@Override public String getUUID() { try {//w w w .j a v a 2s . c o m return this.node.getUUID(); } catch (UnsupportedOperationException e) { log.error(e.getMessage()); } catch (RepositoryException re) { log.error("Exception caught", re); } return StringUtils.EMPTY; }
From source file:org.meresco.triplestore.TransactionLogTest.java
@Test public void testAddUnsupporedFormat() throws Exception { try {//from w w w . j a v a 2s . c o m transactionLog.add("testRecord", "ignored", RDFFormat.NTRIPLES); fail(); } catch (UnsupportedOperationException e) { assertEquals("Only RDFXML supported with transactionLog", e.getMessage()); } ArrayList<String> files = transactionLog.getTransactionItemFiles(); assertEquals(1, files.size()); assertEquals("", Utils.read(new File(transactionLog.getTransactionLogDir(), files.get(0)))); }