List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:com.rackspacecloud.blueflood.io.SerializationTest.java
@Test(expected = UnexpectedStringSerializationException.class) public void testDeserializeStringDoesNotFail() throws Throwable { // this is what a string looked like previously. try {/* w w w . j a v a 2 s .c o m*/ String serialized = "AHMWVGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=="; ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(serialized.getBytes())); NumericSerializer.get(Granularity.FULL).fromByteBuffer(bb); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.SerializationTest.java
@Test(expected = SerializationException.class) public void testCannotRoundtripStringWithNullGran() throws Throwable { try {/*from w w w. ja va2s . c o m*/ String expected = "this is a string"; Granularity gran = null; ByteBuffer bb = NumericSerializer.get(gran).toByteBuffer(expected); String actual = (String) NumericSerializer.get(gran).fromByteBuffer(bb); Assert.assertEquals(expected, actual); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.SerializationTest.java
@Test(expected = SerializationException.class) public void testCannotRoundtripBytesWillNullGran() throws Throwable { try {//from ww w .java 2 s.co m byte[] expected = new byte[] { 1, 2, 3, 4, 5 }; Granularity gran = null; ByteBuffer bb = NumericSerializer.get(gran).toByteBuffer(expected); byte[] actual = (byte[]) NumericSerializer.get(gran).fromByteBuffer(bb); Assert.assertArrayEquals(expected, actual); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.SerializationTest.java
@Test(expected = SerializationException.class) public void testCannotRoundtripBytes() throws Throwable { try {//w w w . j av a 2 s . com byte[] expected = new byte[] { 1, 2, 3, 4, 5 }; Granularity gran = Granularity.FULL; NumericSerializer ser = NumericSerializer.get(gran); byte[] actual = (byte[]) ser.fromByteBuffer(ser.toByteBuffer(expected)); Assert.assertArrayEquals(expected, actual); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.gisgraphy.domain.geoloc.service.fulltextsearch.FullTextSearchEngine.java
public void executeAndSerialize(FulltextQuery query, OutputStream outputStream) throws FullTextSearchException { statsUsageService.increaseUsage(StatsUsageType.FULLTEXT); Assert.notNull(query, "Can not execute a null query"); Assert.notNull(outputStream, "Can not serialize into a null outputStream"); try {//from w ww .j a va 2 s . com logger.info(query.toString()); ModifiableSolrParams params = query.parameterize(); CommonsHttpSolrServer server = new CommonsHttpSolrServer(solrClient.getURL(), this.httpClient, new OutputstreamResponseWrapper(outputStream, params.get(Constants.OUTPUT_FORMAT_PARAMETER))); server.query(params); } catch (SolrServerException e) { logger.error("Can not execute query " + query.toQueryString() + "for URL : " + solrClient.getURL() + " : " + e.getCause().getMessage()); throw new FullTextSearchException(e.getCause().getMessage()); } catch (MalformedURLException e1) { logger.error("The URL " + solrClient.getURL() + " is incorrect"); throw new FullTextSearchException(e1); } catch (RuntimeException e2) { logger.error("An error has occurred during fulltext search of query " + query + " : " + e2.getCause().getMessage()); throw new FullTextSearchException(e2.getCause().getMessage()); } }
From source file:org.apache.shindig.protocol.BaseRequestItem.java
@Override public <T> T getTypedParameter(String parameterName, Class<T> dataTypeClass) { try {/*from w w w. j av a2 s .c o m*/ return converter.convertToObject(getParameter(parameterName), dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) { throw new AipoProtocolException(AipoErrorCode.VALIDATE_ERROR.customMessage(e.getMessage())); } throw e; } }
From source file:org.apache.shindig.protocol.BaseRequestItem.java
@Override public <T> T getTypedRequest(Class<T> dataTypeClass) { try {/*from www.jav a2 s .c o m*/ return jsonConverter.convertToObject(new JSONObject(this.parameters).toString(), dataTypeClass); } catch (RuntimeException e) { if (e.getCause() instanceof JSONException) { throw new AipoProtocolException(AipoErrorCode.VALIDATE_ERROR.customMessage(e.getMessage())); } throw e; } }
From source file:org.fcrepo.http.api.FedoraAcl.java
/** * PATCH to update an FedoraWebacACL resource using SPARQL-UPDATE * * @param requestBodyStream the request body stream * @return 204/* w w w.jav a2 s . com*/ * @throws IOException if IO exception occurred */ @PATCH @Consumes({ contentTypeSPARQLUpdate }) @Timed public Response updateSparql(final InputStream requestBodyStream) throws IOException, ItemNotFoundException { hasRestrictedPath(externalPath); if (null == requestBodyStream) { throw new BadRequestException("SPARQL-UPDATE requests must have content!"); } final FedoraResource aclResource = resource().getAcl(); if (aclResource == null) { throw new ItemNotFoundException(); } final AcquiredLock lock = lockManager.lockForWrite(aclResource.getPath(), session.getFedoraSession(), nodeService); try { final String requestBody = IOUtils.toString(requestBodyStream, UTF_8); if (isBlank(requestBody)) { throw new BadRequestException("SPARQL-UPDATE requests must have content!"); } evaluateRequestPreconditions(request, servletResponse, aclResource, session); try (final RdfStream resourceTriples = aclResource.isNew() ? new DefaultRdfStream(asNode(aclResource)) : getResourceTriples(aclResource)) { LOGGER.info("PATCH for '{}'", externalPath); patchResourcewithSparql(aclResource, requestBody, resourceTriples); } session.commit(); addCacheControlHeaders(servletResponse, aclResource, session); return noContent().build(); } catch (final IllegalArgumentException iae) { throw new BadRequestException(iae.getMessage()); } catch (final AccessDeniedException e) { throw e; } catch (final RuntimeException ex) { final Throwable cause = ex.getCause(); if (cause instanceof PathNotFoundRuntimeException) { // the sparql update referred to a repository resource that doesn't exist throw new BadRequestException(cause.getMessage()); } throw ex; } finally { lock.release(); } }
From source file:com.qualogy.qafe.gwt.server.processor.impl.EventProcessorImpl.java
public GDataObject execute(EventDataGVO eventData, ApplicationIdentifier appId, SessionContainer sessionContainer) { ApplicationContext context = ApplicationCluster.getInstance().get(appId); EventHandler eventHandler = context.getEventHandler(); StopWatch stopWatch = new StopWatch(); stopWatch.start();//from w w w .j av a 2 s. c o m GDataObject data = new GDataObject(); data.setSenderId(eventData.getSender()); data.setListenerType(eventData.getListenerType()); data.setEventId(eventData.getEventId()); data.setUuid(eventData.getUuid()); data.setParent(eventData.getParent()); ApplicationStoreIdentifier appStoreId = new ApplicationStoreIdentifier(eventData.getUuid()); String[] senderInfo = StringUtils.split(eventData.getSender(), '|'); logger.fine(eventData.toString() + ", WindowID " + senderInfo[1]); String windowId = ""; if (senderInfo.length == 2 || senderInfo.length == 3) { if (senderInfo.length == 2) {// dealing with a RootPanel only windowId = senderInfo[0]; } if (senderInfo.length == 3) { windowId = senderInfo[1]; } try { List<InputVariable> inputVariables = new ArrayList<InputVariable>(); if (eventData.getInputVariables() != null && eventData.getInputVariables().size() > 0) { for (InputVariableGVO inVar : eventData.getInputVariables()) { inputVariables.add( new InputVariable(inVar.getName(), inVar.getReference(), inVar.getDefaultValue(), inVar.getComponentValue(), convert(inVar.getDataContainerObject()))); } } EventDataObject eventDataObject = new EventDataObject(eventData.getEventId(), eventData.getSourceInfo(), appId, eventData.getListenerType(), inputVariables, eventData.getInternalVariables(), senderInfo[0], eventData.getSenderName(), windowId, eventData.getUuid(), eventData.getUserUID(), eventData.getWindowSession(), eventData.getRequest(), eventData.getParameters(), eventData.getMouse()); eventDataObject.setApplicationStoreIdentifier(appStoreId); Collection<?> builtInFunctionsToExecute = eventHandler.manage(eventDataObject); Iterator<?> itr = builtInFunctionsToExecute.iterator(); Collection<BuiltInFunctionGVO> builtInFunctions = new ArrayList<BuiltInFunctionGVO>(); while (itr.hasNext()) { BuiltInFunction builtInFunctionToExecute = (BuiltInFunction) itr.next(); BuiltInFunctionGVO builtInFunction = EventUIAssembler .convert((EventItem) builtInFunctionToExecute, eventData, context, sessionContainer); if (builtInFunction != null) { builtInFunctions.add(builtInFunction); } } data.setFunctions((BuiltInFunctionGVO[]) builtInFunctions.toArray(new BuiltInFunctionGVO[] {})); } catch (RuntimeException e) { ExceptionHelper.printStackTrace(e); throw e; } catch (ExternalException e) { ExceptionHelper.printStackTrace(e.getCause()); throw new RuntimeException(e.getMessage(), e); } } else { logger.warning("Error in sender string (is not partionable in size 2) : " + eventData.getSender()); } stopWatch.stop(); logger.warning("EventProcessorImpl uuid:[" + eventData.getUuid() + "], sender[" + eventData.getSender() + "], eventId [" + eventData.getEventName() + "] took [" + stopWatch.getTime() + "]ms "); return data; }
From source file:com.rackspacecloud.blueflood.io.SerializationTest.java
@Test public void testBadSerializationVersion() { byte[] buf = new byte[] { 99, 99 }; // hopefully we won't have 99 different serialization versions. for (Granularity g : Granularity.granularities()) { try {//from w w w. ja v a 2s . c om NumericSerializer.get(g).fromByteBuffer(ByteBuffer.wrap(buf)); Assert.fail(String.format("Should have errored out %s", g.name())); } catch (RuntimeException ex) { Assert.assertTrue(ex.getCause().getMessage().startsWith("Unexpected serialization version")); } } }