# HG changeset patch # User Jaroslav Tulach # Date 1256478898 -3600 # Node ID 6544ad908b05fde3fb569dc85b063a60bb31312c # Parent d83dc9d624e85617648254a1cdb5b16eaf5c4e00 W3C Document reader is needed only in freemarkerdor diff -r d83dc9d624e8 -r 6544ad908b05 freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/W3CDocumentReader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/freemarkerdor/src/main/java/cz/xelfi/quoridor/freemarkerdor/W3CDocumentReader.java Sun Oct 25 14:54:58 2009 +0100 @@ -0,0 +1,46 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package cz.xelfi.quoridor.freemarkerdor; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; +import javax.ws.rs.Consumes; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.ext.Provider; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +/** + * + * @author Jaroslav Tulach + */ +@Provider +@Consumes(MediaType.TEXT_XML) +public class W3CDocumentReader implements javax.ws.rs.ext.MessageBodyReader { + public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { + return type == Document.class; + } + + public Document readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + return builder.parse(entityStream); + } catch (ParserConfigurationException ex) { + throw new WebApplicationException(ex); + } catch (SAXException ex) { + throw new WebApplicationException(ex); + } + } + +} diff -r d83dc9d624e8 -r 6544ad908b05 freemarkerdor/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/freemarkerdor/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader Sun Oct 25 14:54:58 2009 +0100 @@ -0,0 +1,1 @@ +cz.xelfi.quoridor.freemarkerdor.W3CDocumentReader diff -r d83dc9d624e8 -r 6544ad908b05 webidor/src/main/java/cz/xelfi/quoridor/webidor/W3CDocumentReader.java --- a/webidor/src/main/java/cz/xelfi/quoridor/webidor/W3CDocumentReader.java Sun Oct 25 14:51:37 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ - -package cz.xelfi.quoridor.webidor; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; -import javax.ws.rs.Consumes; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.Provider; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -/** - * - * @author Jaroslav Tulach - */ -@Provider -@Consumes(MediaType.TEXT_XML) -public class W3CDocumentReader implements javax.ws.rs.ext.MessageBodyReader { - public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return type == Document.class; - } - - public Document readFrom(Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { - try { - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - return builder.parse(entityStream); - } catch (ParserConfigurationException ex) { - throw new WebApplicationException(ex); - } catch (SAXException ex) { - throw new WebApplicationException(ex); - } - } - -} diff -r d83dc9d624e8 -r 6544ad908b05 webidor/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader --- a/webidor/src/main/resources/META-INF/services/javax.ws.rs.ext.MessageBodyReader Sun Oct 25 14:51:37 2009 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -cz.xelfi.quoridor.webidor.W3CDocumentReader