public Entry readFrom()

in taverna-server-webapp/src/main/java/org/apache/taverna/server/master/rest/handler/EntryHandler.java [86:116]


	public Entry readFrom(Class<Entry> type, Type genericType,
			Annotation[] annotations, MediaType mediaType,
			MultivaluedMap<String, String> httpHeaders, InputStream entityStream)
			throws IOException, WebApplicationException {
		Charset cs = UTF8;
		try {
			String charset = mediaType.getParameters().get("charset");
			if (charset != null)
				cs = Charset.forName(charset);
		} catch (IllegalCharsetNameException e) {
			throw new WebApplicationException(notAcceptable(asList(VARIANT))
					.entity("bad charset name").build());
		} catch (UnsupportedCharsetException e) {
			throw new WebApplicationException(notAcceptable(asList(VARIANT))
					.entity("unsupportd charset name").build());
		}
		try {
			Document<Entry> doc = parser.parse(new InputStreamReader(
					entityStream, cs));
			if (!Entry.class.isAssignableFrom(doc.getRoot().getClass())) {
				throw new WebApplicationException(
						notAcceptable(asList(VARIANT)).entity(
								"not really a feed entry").build());
			}
			return doc.getRoot();
		} catch (ClassCastException e) {
			throw new WebApplicationException(notAcceptable(asList(VARIANT))
					.entity("not really a feed entry").build());

		}
	}