public void writeTo(Object o, Class<?> cls, Type genericType, Annotation[] annotations, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException { boolean isFeed = isFeedRequested(mt); boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(cls); if (isFeed && isCollection) { reportError("Atom feed can only be created from a collection wrapper", null); } else if (!isFeed && isCollection) { reportError("Atom entry can only be created from a single object", null); } Factory factory = Abdera.getNewFactory(); Element atomElement = null; try { if (isFeed && !isCollection) { atomElement = createFeedFromCollectionWrapper(factory, o, cls); } else if (!isFeed && !isCollection) { atomElement = createEntryFromObject(factory, o, cls); } } catch (Exception ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } try { writeAtomElement(atomElement, os); } catch (IOException ex) { reportError("Atom element can not be serialized", ex); } }
public void writeTo(Object o, Class<?> cls, Type genericType, Annotation[] annotations, MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os) throws IOException { boolean isFeed = isFeedRequested(mt); boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(cls); if (isFeed && isCollection) { reportError("Atom feed can only be created from a collection wrapper", null); } else if (!isFeed && isCollection) { reportError("Atom entry can only be created from a single object", null); } Factory factory = Abdera.getNewFactory(); Element atomElement = null; try { if (isFeed && !isCollection) { atomElement = createFeedFromCollectionWrapper(factory, o, cls); } else if (!isFeed && !isCollection) { atomElement = createEntryFromObject(factory, o, cls); } } catch (Exception ex) { throw ExceptionUtils.toInternalServerErrorException(ex, null); } try { writeAtomElement(atomElement, os); } catch (IOException ex) { reportError("Atom element can not be serialized", ex); } }
try { if (isFeed && !isCollection) { atomElement = createFeedFromCollectionWrapper(factory, o, cls); } else if (!isFeed && !isCollection) { atomElement = createEntryFromObject(factory, o, cls);