File Source: IntrospectionHandler.java

         /* 
    P/P   *  Method: org.apache.roller.weblogger.webservices.adminprotocol.IntrospectionHandler__static_init
          */
     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.weblogger.webservices.adminprotocol;
    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.weblogger.webservices.adminprotocol.sdk.Entry;
    26  import org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet;
    27  import org.apache.roller.weblogger.webservices.adminprotocol.sdk.Service;
    28  import org.apache.roller.weblogger.webservices.adminprotocol.sdk.UnexpectedRootElementException;
    29  import org.jdom.Document;
    30  
    31  /**
    32   * This class handles requests for the RAP introspection document.
    33   * It only processes HTTP GET requests.
    34   *
    35   * @author jtb
    36   */
    37  class IntrospectionHandler extends Handler {
    38      public IntrospectionHandler(HttpServletRequest request) throws HandlerException {
                 /* 
    P/P           *  Method: void org.apache.roller.weblogger.webservices.adminprotocol.IntrospectionHandler(HttpServletRequest)
                  * 
                  *  Preconditions:
                  *    request != null
                  *    (soft) org/apache/roller/weblogger/webservices/adminprotocol/Handler$URI.PATHINFO_PATTERN != null
                  * 
                  *  Postconditions:
                  *    init'ed(java.lang.String:substring(...)._tainted)
                  *    java.lang.StringBuilder:toString(...)._tainted == 0
                  *    this.request == request
                  *    this.request != null
                  *    init'ed(this.roller)
                  *    this.uri == &new Handler$URI(Handler#1)
                  *    this.urlPrefix == &java.lang.StringBuilder:toString(...)
                  *    this.userName == One-of{null, &java.lang.String:substring(...)}
                  *    this.userName in Addr_Set{null,&java.lang.String:substring(...)}
                  *    new Handler$URI(Handler#1) num objects == 1
                  *    ...
                  */
    39          super(request);
    40      }
    41      
    42      protected EntrySet getEntrySet(Document d) throws UnexpectedRootElementException {
                 /* 
    P/P           *  Method: EntrySet getEntrySet(Document)
                  *    getEntrySet fails for all possible inputs
                  */
    43          throw new UnsupportedOperationException();
    44      }
    45      
    46      public EntrySet processGet() throws HandlerException {
                 /* 
    P/P           *  Method: EntrySet processGet()
                  * 
                  *  Preconditions:
                  *    init'ed(this.request)
                  *    this.uri != null
                  *    this.uri.entryId == null
                  *    init'ed(this.urlPrefix)
                  *    (soft) this.uri.type == null
                  * 
                  *  Postconditions:
                  *    return_value == &new Service(getIntrospection#1)
                  *    new Service(getIntrospection#1) num objects == 1
                  *    init'ed(new Service(getIntrospection#1).entries)
                  *    new Service(getIntrospection#1).href == this.urlPrefix
                  *    init'ed(new Service(getIntrospection#1).href)
                  */
    47          if (getUri().isIntrospection()) {
    48              return getIntrospection(getRequest());
    49          } else {
    50              throw new BadRequestException("ERROR: Unknown GET URI type");
    51          }
    52      }
    53      
    54      public EntrySet processPost(Reader r) {
                 /* 
    P/P           *  Method: EntrySet processPost(Reader)
                  *    processPost fails for all possible inputs
                  */
    55          throw new UnsupportedOperationException("ERROR: POST not supported in this handler");
    56      }
    57      
    58      public EntrySet processPut(Reader r) {
                 /* 
    P/P           *  Method: EntrySet processPut(Reader)
                  *    processPut fails for all possible inputs
                  */
    59          throw new UnsupportedOperationException("ERROR: PUT not supported in this handler");
    60      }
    61      
    62      public EntrySet processDelete() {
                 /* 
    P/P           *  Method: EntrySet processDelete()
                  *    processDelete fails for all possible inputs
                  */
    63          throw new UnsupportedOperationException("ERROR: DELETE not supported in this handler");
    64      }
    65      
    66      private Service getIntrospection(HttpServletRequest req) {
                 /* 
    P/P           *  Method: Service getIntrospection(HttpServletRequest)
                  * 
                  *  Preconditions:
                  *    init'ed(this.urlPrefix)
                  * 
                  *  Postconditions:
                  *    return_value == &new Service(getIntrospection#1)
                  *    new Service(getIntrospection#1) num objects == 1
                  *    init'ed(return_value.entries)
                  *    return_value.href == this.urlPrefix
                  *    init'ed(return_value.href)
                  */
    67          String href = getUrlPrefix();
    68          Service service = new Service(href);
    69          
    70          Service.Workspace workspace = new Service.Workspace();
    71          workspace.setTitle("Workspace: Collections for administration");
    72          workspace.setHref(service.getHref());
    73          service.setEntries(new Entry[] { workspace });
    74          
    75          List workspaceCollections = new ArrayList();
    76          
    77          Service.Workspace.Collection weblogCol = new Service.Workspace.Collection();
    78          weblogCol.setTitle("Collection: Weblog administration entries");
    79          weblogCol.setMemberType(org.apache.roller.weblogger.webservices.adminprotocol.sdk.Entry.Types.WEBLOG);
    80          weblogCol.setHref(service.getHref() + "/" + org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet.Types.WEBLOGS);
    81          workspaceCollections.add(weblogCol);
    82          
    83          Service.Workspace.Collection userCol = new Service.Workspace.Collection();
    84          userCol.setTitle("Collection: User administration entries");
    85          userCol.setMemberType("user");
    86          userCol.setHref(service.getHref() + "/" + org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet.Types.USERS);
    87          workspaceCollections.add(userCol);
    88          
    89          Service.Workspace.Collection memberCol = new Service.Workspace.Collection();
    90          memberCol.setTitle("Collection: Member administration entries");
    91          memberCol.setMemberType("member");
    92          memberCol.setHref(service.getHref() + "/" + org.apache.roller.weblogger.webservices.adminprotocol.sdk.EntrySet.Types.MEMBERS);
    93          workspaceCollections.add(memberCol);
    94          
+   95          workspace.setEntries((Entry[])workspaceCollections.toArray(new Entry[0]));
    96          
    97          return service;
    98      }
    99  }
   100  








SofCheck Inspector Build Version : 2.18479
IntrospectionHandler.java 2009-Jan-02 14:25:26
IntrospectionHandler.class 2009-Sep-04 03:12:46