001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: /*
019: * AtomAdminService.java
020: *
021: * Created on January 17, 2006, 12:44 PM
022: */
023: package org.apache.roller.webservices.adminapi.sdk;
024:
025: import java.util.ArrayList;
026: import java.util.Iterator;
027: import java.util.List;
028:
029: import org.jdom.Document;
030: import org.jdom.Element;
031: import org.jdom.Namespace;
032: import org.jdom.filter.Filter;
033:
034: /**
035: * This class describes an AAPP service (introspection document).
036: * A Service is a set of workspaces, which is a set of
037: * collections.
038: *
039: * @author jtb
040: */
041:
042: public class Service extends EntrySet {
043: /** This class describes a service workspace. */
044: public static class Workspace extends EntrySet {
045: /** This class describes a workspace collection. */
046: public static class Collection extends Entry {
047: private static interface Tags {
048: public static final String MEMBER_TYPE = "member-type";
049: }
050:
051: private static interface Attributes {
052: public static final String TITLE = "title";
053: }
054:
055: private String title;
056: private String memberType;
057:
058: public Collection() {
059: // nothing
060: }
061:
062: public String getType() {
063: return Types.COLLECTION;
064: }
065:
066: public String getTitle() {
067: return title;
068: }
069:
070: public void setTitle(String title) {
071: this .title = title;
072: }
073:
074: public Document toDocument() {
075: Document doc = new Document();
076: Element element = new Element(Types.COLLECTION,
077: NAMESPACE);
078: doc.setRootElement(element);
079:
080: element.setAttribute(Attributes.TITLE, getTitle());
081: element.setAttribute(Entry.Attributes.HREF, getHref());
082:
083: Element memberType = new Element(Tags.MEMBER_TYPE,
084: NAMESPACE);
085: memberType.setText(getMemberType());
086: element.addContent(memberType);
087:
088: return doc;
089: }
090:
091: public String getMemberType() {
092: return memberType;
093: }
094:
095: public void setMemberType(String memberType) {
096: this .memberType = memberType;
097: }
098:
099: }
100:
101: private static interface Attributes {
102: public static final String TITLE = "title";
103: }
104:
105: private String title = null;
106:
107: public Workspace() {
108: }
109:
110: public String getType() {
111: return Types.WORKSPACE;
112: }
113:
114: public String getTitle() {
115: return title;
116: }
117:
118: public void setTitle(String title) {
119: this .title = title;
120: }
121:
122: public Document toDocument() {
123: Document doc = new Document();
124: Element element = new Element(EntrySet.Types.WORKSPACE,
125: NAMESPACE);
126: doc.setRootElement(element);
127:
128: element.setAttribute(Attributes.TITLE, getTitle());
129: for (int i = 0; i < getEntries().length; i++) {
130: Entry entry = getEntries()[i];
131: element.addContent(entry.toDocument()
132: .detachRootElement());
133: }
134:
135: return doc;
136: }
137: }
138:
139: public Service(String href) {
140: setHref(href);
141: }
142:
143: public String getType() {
144: return Types.SERVICE;
145: }
146:
147: public Document toDocument() {
148: Document doc = new Document();
149: Element root = new Element(Types.SERVICE, NAMESPACE);
150: doc.setRootElement(root);
151:
152: for (int i = 0; i < getEntries().length; i++) {
153: Entry entry = getEntries()[i];
154: root.addContent(entry.toDocument().detachRootElement());
155: }
156:
157: return doc;
158: }
159: }
|