KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > webservices > adminapi > IntrospectionHandler


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 package org.apache.roller.webservices.adminapi;
19
20 import java.io.Reader JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.List JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24
25 import org.apache.roller.webservices.adminapi.sdk.Entry;
26 import org.apache.roller.webservices.adminapi.sdk.EntrySet;
27 import org.apache.roller.webservices.adminapi.sdk.MissingElementException;
28 import org.apache.roller.webservices.adminapi.sdk.Service;
29 import org.apache.roller.webservices.adminapi.sdk.UnexpectedRootElementException;
30 import org.jdom.Document;
31
32 /**
33  * This class handles requests for the AAPP introspection document.
34  * It only processes HTTP GET requests.
35  *
36  * @author jtb
37  */

38 class IntrospectionHandler extends Handler {
39     public IntrospectionHandler(HttpServletRequest JavaDoc request) throws HandlerException {
40         super(request);
41     }
42     
43     protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException {
44         throw new UnsupportedOperationException JavaDoc();
45     }
46     
47     public EntrySet processGet() throws HandlerException {
48         if (getUri().isIntrospection()) {
49             return getIntrospection(getRequest());
50         } else {
51             throw new BadRequestException("ERROR: Unknown GET URI type");
52         }
53     }
54     
55     public EntrySet processPost(Reader JavaDoc r) {
56         throw new UnsupportedOperationException JavaDoc("ERROR: POST not supported in this handler");
57     }
58     
59     public EntrySet processPut(Reader JavaDoc r) {
60         throw new UnsupportedOperationException JavaDoc("ERROR: PUT not supported in this handler");
61     }
62     
63     public EntrySet processDelete() {
64         throw new UnsupportedOperationException JavaDoc("ERROR: DELETE not supported in this handler");
65     }
66     
67     private Service getIntrospection(HttpServletRequest JavaDoc req) {
68         String JavaDoc href = getUrlPrefix();
69         Service service = new Service(href);
70         
71         Service.Workspace workspace = new Service.Workspace();
72         workspace.setTitle("Workspace: Collections for administration");
73         workspace.setHref(service.getHref());
74         service.setEntries(new Entry[] { workspace });
75         
76         List JavaDoc workspaceCollections = new ArrayList JavaDoc();
77         
78         Service.Workspace.Collection weblogCol = new Service.Workspace.Collection();
79         weblogCol.setTitle("Collection: Weblog administration entries");
80         weblogCol.setMemberType(org.apache.roller.webservices.adminapi.sdk.Entry.Types.WEBLOG);
81         weblogCol.setHref(service.getHref() + "/" + org.apache.roller.webservices.adminapi.sdk.EntrySet.Types.WEBLOGS);
82         workspaceCollections.add(weblogCol);
83         
84         Service.Workspace.Collection userCol = new Service.Workspace.Collection();
85         userCol.setTitle("Collection: User administration entries");
86         userCol.setMemberType("user");
87         userCol.setHref(service.getHref() + "/" + org.apache.roller.webservices.adminapi.sdk.EntrySet.Types.USERS);
88         workspaceCollections.add(userCol);
89         
90         Service.Workspace.Collection memberCol = new Service.Workspace.Collection();
91         memberCol.setTitle("Collection: Member administration entries");
92         memberCol.setMemberType("member");
93         memberCol.setHref(service.getHref() + "/" + org.apache.roller.webservices.adminapi.sdk.EntrySet.Types.MEMBERS);
94         workspaceCollections.add(memberCol);
95         
96         workspace.setEntries((Entry[])workspaceCollections.toArray(new Entry[0]));
97         
98         return service;
99     }
100 }
101
102
Popular Tags