/** * Constructor. * @param msg * @param stackTrace */ public SrampAtomException(String msg, String stackTrace) { super(msg); setStackTrace(parseStackTrace(stackTrace)); }
/** * @see javax.ws.rs.ext.MessageBodyReader#readFrom(java.lang.Class, java.lang.reflect.Type, java.lang.annotation.Annotation[], javax.ws.rs.core.MediaType, javax.ws.rs.core.MultivaluedMap, java.io.InputStream) */ @Override public SrampAtomException readFrom(Class<SrampAtomException> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { List<String> lines = IOUtils.readLines(entityStream); StringBuilder buffer = new StringBuilder(); for (String line : lines) { buffer.append(line).append("\n"); //$NON-NLS-1$ } String stackTrace = buffer.toString(); String msg = httpHeaders == null ? null : httpHeaders.getFirst("Error-Message"); //$NON-NLS-1$ if (msg == null) { msg = Messages.i18n.format("UNKNOWN_SRAMP_ERROR"); //$NON-NLS-1$ } SrampAtomException error = new SrampAtomException(msg, stackTrace); return error; }
/** * Test method for {@link SrampAtomApiClient#uploadArtifact(java.lang.String, java.lang.String, java.io.InputStream, java.lang.String)}. */ @Test public void testQueryError() throws Exception { SrampAtomApiClient client = new SrampAtomApiClient(generateURL("/s-ramp")); //$NON-NLS-1$ try { QueryResultSet rset = client.query("12345", 0, 20, "name", false); //$NON-NLS-1$ //$NON-NLS-2$ fail("Expected a remote exception from the s-ramp server, but got: " + rset); //$NON-NLS-1$ } catch (SrampAtomException e) { Assert.assertEquals("Invalid artifact set (step 2).", e.getMessage()); //$NON-NLS-1$ } }
SrampAtomException error = new SrampAtomException(Messages.i18n.format("ENDPOINT_NOT_FOUND")); //$NON-NLS-1$ throw error; SrampAtomException error = new SrampAtomException(Messages.i18n.format("AUTHORIZATION_FAILED")); //$NON-NLS-1$ throw error; SrampAtomException error = new SrampAtomException(Messages.i18n.format("AUTHENTICATION_FAILED")); //$NON-NLS-1$ throw error;
/** * Adds a new audit entry on the artifact with the given UUID. * @param artifactUuid * @param auditEntry * @throws SrampClientException * @throws SrampAtomException */ public AuditEntry addAuditEntry(String artifactUuid, AuditEntry auditEntry) throws SrampClientException, SrampAtomException { assertFeatureEnabled("audit"); //$NON-NLS-1$ ClientResponse<Entry> response = null; try { String atomUrl = String.format("%1$s/audit/artifact/%2$s", this.endpoint, artifactUuid); //$NON-NLS-1$ ClientRequest request = createClientRequest(atomUrl); request.body(MediaType.APPLICATION_AUDIT_ENTRY_XML_TYPE, auditEntry); response = request.post(Entry.class); Entry entry = response.getEntity(); if (entry == null) throw new SrampAtomException(Messages.i18n.format("AUDIT_ENTRY_ADD_FAILED")); //$NON-NLS-1$ return SrampAtomUtils.unwrap(entry, AuditEntry.class); } catch (SrampAtomException e) { throw e; } catch (Throwable e) { throw new SrampClientException(e); } finally { closeQuietly(response); } }
} else { String errorReason = (String) rbean.getBody(); SrampAtomException exception = new SrampAtomException(errorReason); rval.put(path, exception); SrampAtomException exception = new SrampAtomException(Messages.i18n.format("BAD_RETURN_CODE", rbean.getCode(), contentId)); //$NON-NLS-1$ rval.put(path, exception);