1 18 package org.apache.roller.webservices.adminapi; 19 20 import java.io.Reader ; 21 import java.util.ArrayList ; 22 import java.util.List ; 23 import javax.servlet.http.HttpServletRequest ; 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 38 class IntrospectionHandler extends Handler { 39 public IntrospectionHandler(HttpServletRequest request) throws HandlerException { 40 super(request); 41 } 42 43 protected EntrySet getEntrySet(Document d) throws MissingElementException, UnexpectedRootElementException { 44 throw new UnsupportedOperationException (); 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 r) { 56 throw new UnsupportedOperationException ("ERROR: POST not supported in this handler"); 57 } 58 59 public EntrySet processPut(Reader r) { 60 throw new UnsupportedOperationException ("ERROR: PUT not supported in this handler"); 61 } 62 63 public EntrySet processDelete() { 64 throw new UnsupportedOperationException ("ERROR: DELETE not supported in this handler"); 65 } 66 67 private Service getIntrospection(HttpServletRequest req) { 68 String 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 workspaceCollections = new ArrayList (); 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 |