This project has retired. For details please refer to its Attic page.
ServiceDocument xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.server.impl.atompub;
20  
21  import static org.apache.chemistry.opencmis.commons.impl.Converter.convert;
22  
23  import javax.xml.bind.JAXBException;
24  import javax.xml.stream.XMLStreamException;
25  import javax.xml.stream.XMLStreamWriter;
26  
27  import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
28  import org.apache.chemistry.opencmis.commons.impl.Constants;
29  import org.apache.chemistry.opencmis.commons.impl.JaxBHelper;
30  import org.apache.chemistry.opencmis.commons.impl.jaxb.CmisRepositoryInfoType;
31  
32  /**
33   * Service document class.
34   *
35   * @author <a href="mailto:fmueller@opentext.com">Florian M&uuml;ller</a>
36   *
37   */
38  public class ServiceDocument extends AtomDocumentBase {
39  
40      public ServiceDocument() {
41      }
42  
43      public void startServiceDocument() throws XMLStreamException {
44          XMLStreamWriter xsw = getWriter();
45          xsw.writeStartElement(Constants.NAMESPACE_APP, "service");
46          writeNamespace(Constants.NAMESPACE_APP);
47          writeNamespace(Constants.NAMESPACE_ATOM);
48          writeNamespace(Constants.NAMESPACE_CMIS);
49          writeNamespace(Constants.NAMESPACE_RESTATOM);
50      }
51  
52      public void endServiceDocument() throws XMLStreamException {
53          getWriter().writeEndElement();
54      }
55  
56      public void startWorkspace(String title) throws XMLStreamException {
57          getWriter().writeStartElement(Constants.NAMESPACE_APP, "workspace");
58          writeSimpleTag(Constants.NAMESPACE_ATOM, "title", title);
59      }
60  
61      public void endWorkspace() throws XMLStreamException {
62          getWriter().writeEndElement();
63      }
64  
65      public void writeRepositoryInfo(RepositoryInfo repInfo) throws JAXBException {
66          CmisRepositoryInfoType repInfoJaxb = convert(repInfo);
67          if (repInfoJaxb == null) {
68              return;
69          }
70  
71          JaxBHelper.marshal(JaxBHelper.CMIS_EXTRA_OBJECT_FACTORY.createRepositoryInfo(repInfoJaxb), getWriter(), true);
72      }
73  
74      public void writeUriTemplate(String template, String type, String mediatype) throws XMLStreamException {
75          XMLStreamWriter xsw = getWriter();
76  
77          xsw.writeStartElement(Constants.NAMESPACE_RESTATOM, "uritemplate");
78          writeSimpleTag(Constants.NAMESPACE_RESTATOM, "template", template);
79          writeSimpleTag(Constants.NAMESPACE_RESTATOM, "type", type);
80          writeSimpleTag(Constants.NAMESPACE_RESTATOM, "mediatype", mediatype);
81          xsw.writeEndElement();
82      }
83  }