/** * @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; }
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;
} 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);
/** * 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); } }