/** * Check for the resteasy builtin JAXBContext implementation. * @param type * @param annotations * @param mediaType * @return * @throws IOException */ private JAXBContext getJAXBContextFinder(Class<Object> type, Annotation[] annotations, MediaType mediaType) throws IOException { try { LogMessages.LOGGER.debugf("Provider : %s, Method : getJAXBContextFinder", getClass().getName()); ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } JAXBContext jaxb = finder.findCacheXmlTypeContext(mediaType, annotations, type); return jaxb; } catch (JAXBException e) { throw new JAXBUnmarshalException(e); } }
/** * Check for a user provided JAXBContext implementation. It takes priority over our builtin one. * @param type * @param mediaType * @return * @throws IOException */ private javax.xml.bind.JAXBContext getJAXBContext(Class<Object> type, MediaType mediaType) throws IOException { LogMessages.LOGGER.debugf("Provider : %s, Method : getJAXBContext", getClass().getName()); ContextResolver<javax.xml.bind.JAXBContext> resolver = providers.getContextResolver( javax.xml.bind.JAXBContext.class, mediaType); javax.xml.bind.JAXBContext finder = null; if (resolver != null) { finder = resolver.getContext(type); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindUsersJAXBContext(mediaType)); } } return finder; }
throw new JAXBUnmarshalException(e);
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), e); } }
throw new JAXBUnmarshalException(e);
throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e);
public Feed readFrom(Class<Feed> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Feed.class, mediaType, annotations); Feed feed = (Feed) ctx.createUnmarshaller().unmarshal(entityStream); for (Entry entry : feed.getEntries()) { entry.setFinder(finder); if (entry.getContent() != null) entry.getContent().setFinder(finder); } return feed; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), e); } }
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType));
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedLocalPart(wrapped.map(), ele.getName().getLocalPart())); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI())); throw new JAXBUnmarshalException(Messages.MESSAGES.mapWrappedFailedKeyAttribute()); for (int j = 0; j < attributeMap.getLength(); j++) throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e);
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedLocalPart(wrapped.element(), ele.getName().getLocalPart())); throw new JAXBUnmarshalException(Messages.MESSAGES.collectionWrappingFailedNamespace(wrapped.namespace(), ele.getName().getNamespaceURI())); throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e);
if (finder == null) throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType));
@Override public JAXBContext findJAXBContext(Class<?> type, Annotation[] annotations, MediaType mediaType, boolean reader) throws JAXBException { ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { if (reader) throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); else throw new JAXBMarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } XmlSeeAlso seeAlso = type.getAnnotation(XmlSeeAlso.class); return finder.findCacheContext(mediaType, annotations, seeAlso.value()); }
public JAXBContext findJAXBContext(Class<?> type, Annotation[] annotations, MediaType mediaType, boolean reader) throws JAXBException { ContextResolver<JAXBContextFinder> resolver = providers.getContextResolver(JAXBContextFinder.class, mediaType); JAXBContextFinder finder = resolver.getContext(type); if (finder == null) { if (reader) throw new JAXBUnmarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); else throw new JAXBMarshalException(Messages.MESSAGES.couldNotFindJAXBContextFinder(mediaType)); } return finder.findCachedContext(type, mediaType, annotations); }
throw new JAXBUnmarshalException(e); throw new JAXBUnmarshalException(e);
protected static char eatWhitspace(Reader buffer, boolean reset) throws IOException { int i; char c; do { buffer.mark(2); i = buffer.read(); if (i == -1) throw new JAXBUnmarshalException(Messages.MESSAGES.unexpectedEndOfJsonInput()); c = (char) i; } while (Character.isWhitespace(c)); if (reset) buffer.reset(); return c; } }
/** * @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 RDF readFrom(Class<RDF> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { if (rdfContext == null) throw new JAXBUnmarshalException(Messages.i18n.format("UNABLE_TO_MARSHAL", mediaType), //$NON-NLS-1$ new NullPointerException(Messages.i18n.format("FAILED_TO_CREATE_ONT_JAXBCTX"))); //$NON-NLS-1$ try { RDF entry = (RDF) rdfContext.createUnmarshaller().unmarshal(entityStream); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.i18n.format("UNABLE_TO_MARSHAL")); //$NON-NLS-1$ } }
/** * @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 AuditEntry readFrom(Class<AuditEntry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { if (auditEntryContext == null) throw new JAXBUnmarshalException(Messages.i18n.format("UNABLE_TO_MARSHAL", mediaType), //$NON-NLS-1$ new NullPointerException(Messages.i18n.format("FAILED_TO_CREATE_AUDIT_JAXBCTX"))); //$NON-NLS-1$ try { AuditEntry entry = (AuditEntry) auditEntryContext.createUnmarshaller().unmarshal(entityStream); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.i18n.format("UNABLE_TO_MARSHAL", mediaType), e); //$NON-NLS-1$ } }
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e); } }
public Feed readFrom(Class<Feed> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException("Unable to find JAXBContext for media type: " + mediaType); } try { JAXBContext ctx = finder.findCachedContext(Feed.class, mediaType, annotations); Feed feed = (Feed) ctx.createUnmarshaller().unmarshal(entityStream); for (Entry entry : feed.getEntries()) { if (entry.getContent() != null) entry.getContent().setFinder(finder); } return feed; } catch (JAXBException e) { throw new JAXBUnmarshalException("Unable to unmarshal: " + mediaType, e); } }
public Entry readFrom(Class<Entry> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { LogMessages.LOGGER.debugf("Provider : %s, Method : readFrom", getClass().getName()); JAXBContextFinder finder = getFinder(mediaType); if (finder == null) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToFindJAXBContext(mediaType)); } try { JAXBContext ctx = finder.findCachedContext(Entry.class, mediaType, annotations); Entry entry = (Entry) ctx.createUnmarshaller().unmarshal(entityStream); if (entry.getContent() != null) entry.getContent().setFinder(finder); entry.setFinder(finder); return entry; } catch (JAXBException e) { throw new JAXBUnmarshalException(Messages.MESSAGES.unableToUnmarshal(mediaType), e); } }