1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.chemistry.opencmis.server.impl.atompub;
20
21 import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
22 import org.apache.chemistry.opencmis.commons.impl.Constants;
23 import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
24 import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
25 import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
26
27 import javax.xml.bind.JAXBException;
28 import javax.xml.stream.XMLStreamException;
29 import javax.xml.stream.XMLStreamWriter;
30
31
32
33
34
35
36
37
38 public class ServiceDocument extends AtomDocumentBase
39 {
40 public ServiceDocument( )
41 {
42 }
43
44 public void startServiceDocument( ) throws XMLStreamException
45 {
46 XMLStreamWriter xsw = getWriter( );
47 xsw.writeStartElement( Constants.NAMESPACE_APP, "service" );
48 writeNamespace( Constants.NAMESPACE_APP );
49 writeNamespace( Constants.NAMESPACE_ATOM );
50 writeNamespace( Constants.NAMESPACE_CMIS );
51 writeNamespace( Constants.NAMESPACE_RESTATOM );
52 }
53
54 public void endServiceDocument( ) throws XMLStreamException
55 {
56 getWriter( ).writeEndElement( );
57 }
58
59 public void startWorkspace( String title ) throws XMLStreamException
60 {
61 getWriter( ).writeStartElement( Constants.NAMESPACE_APP, "workspace" );
62 writeSimpleTag( Constants.NAMESPACE_ATOM, "title", title );
63 }
64
65 public void endWorkspace( ) throws XMLStreamException
66 {
67 getWriter( ).writeEndElement( );
68 }
69
70 public void writeRepositoryInfo( RepositoryInfo repInfo )
71 throws JAXBException
72 {
73 CmisRepositoryInfoType repInfoJaxb = convert( repInfo );
74
75 if ( repInfoJaxb == null )
76 {
77 return;
78 }
79
80 JaxBHelper.marshal( JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createRepositoryInfo( repInfoJaxb ), getWriter( ),
81 true );
82 }
83
84 public void writeUriTemplate( String template, String type, String mediatype )
85 throws XMLStreamException
86 {
87 XMLStreamWriter xsw = getWriter( );
88
89 xsw.writeStartElement( Constants.NAMESPACE_RESTATOM, "uritemplate" );
90 writeSimpleTag( Constants.NAMESPACE_RESTATOM, "template", template );
91 writeSimpleTag( Constants.NAMESPACE_RESTATOM, "type", type );
92 writeSimpleTag( Constants.NAMESPACE_RESTATOM, "mediatype", mediatype );
93 xsw.writeEndElement( );
94 }
95 }