KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > adminapi > sdk > Service


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /*
19  * AtomAdminService.java
20  *
21  * Created on January 17, 2006, 12:44 PM
22  */

23 package org.apache.roller.webservices.adminapi.sdk;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28
29 import org.jdom.Document;
30 import org.jdom.Element;
31 import org.jdom.Namespace;
32 import org.jdom.filter.Filter;
33
34 /**
35  * This class describes an AAPP service (introspection document).
36  * A Service is a set of workspaces, which is a set of
37  * collections.
38  *
39  * @author jtb
40  */

41
42 public class Service extends EntrySet {
43     /** This class describes a service workspace. */
44     public static class Workspace extends EntrySet {
45         /** This class describes a workspace collection. */
46         public static class Collection extends Entry {
47             private static interface Tags {
48                 public static final String JavaDoc MEMBER_TYPE = "member-type";
49             }
50             
51             private static interface Attributes {
52                 public static final String JavaDoc TITLE = "title";
53             }
54             
55             private String JavaDoc title;
56             private String JavaDoc memberType;
57             
58             public Collection() {
59                 // nothing
60
}
61             
62             public String JavaDoc getType() {
63                 return Types.COLLECTION;
64             }
65             
66             public String JavaDoc getTitle() {
67                 return title;
68             }
69             
70             public void setTitle(String JavaDoc title) {
71                 this.title = title;
72             }
73             
74             
75             public Document toDocument() {
76                 Document doc = new Document();
77                 Element element = new Element(Types.COLLECTION, NAMESPACE);
78                 doc.setRootElement(element);
79                 
80                 element.setAttribute(Attributes.TITLE, getTitle());
81                 element.setAttribute(Entry.Attributes.HREF, getHref());
82                 
83                 Element memberType = new Element(Tags.MEMBER_TYPE, NAMESPACE);
84                 memberType.setText(getMemberType());
85                 element.addContent(memberType);
86                 
87                 return doc;
88             }
89             
90             public String JavaDoc getMemberType() {
91                 return memberType;
92             }
93             
94             public void setMemberType(String JavaDoc memberType) {
95                 this.memberType = memberType;
96             }
97             
98         }
99         
100         private static interface Attributes {
101             public static final String JavaDoc TITLE = "title";
102         }
103         
104         private String JavaDoc title = null;
105         
106         public Workspace() {
107         }
108         
109         public String JavaDoc getType() {
110             return Types.WORKSPACE;
111         }
112         
113         public String JavaDoc getTitle() {
114             return title;
115         }
116         
117         public void setTitle(String JavaDoc title) {
118             this.title = title;
119         }
120         
121         
122         public Document toDocument() {
123             Document doc = new Document();
124             Element element = new Element(EntrySet.Types.WORKSPACE, NAMESPACE);
125             doc.setRootElement(element);
126             
127             element.setAttribute(Attributes.TITLE, getTitle());
128             for (int i = 0; i < getEntries().length; i++) {
129                 Entry entry = getEntries()[i];
130                 element.addContent(entry.toDocument().detachRootElement());
131             }
132             
133             return doc;
134         }
135     }
136     
137     public Service(String JavaDoc href) {
138         setHref(href);
139     }
140     
141     public String JavaDoc getType() {
142         return Types.SERVICE;
143     }
144     
145     public Document toDocument() {
146         Document doc = new Document();
147         Element root = new Element(Types.SERVICE, NAMESPACE);
148         doc.setRootElement(root);
149         
150         for (int i = 0; i < getEntries().length; i++) {
151             Entry entry = getEntries()[i];
152             root.addContent(entry.toDocument().detachRootElement());
153         }
154         
155         return doc;
156     }
157 }
158
Popular Tags