Author: deepal
Date: Tue Dec 18 03:09:04 2007
New Revision: 11395

Log:

code clean up

Removed:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/ConsoleURLMapper.java
Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ActionInvoker.java

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
  (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
  Tue Dec 18 03:09:04 2007
@@ -129,4 +129,10 @@
     public static final String PARAMETER_LOGS= "resourceLogs";
     public static final String PARAMETER_QUERY= "resourceQuery";
 
+
+    public static final String RESOURCES_JSP = "/admin/registry-resources.jsp";
+    public static final String RESOURCE_DETAILS_JSP = 
"/admin/resources_details.jsp";
+    public static final String PATH_ATTR = "path";
+
+
 }

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
    (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
    Tue Dec 18 03:09:04 2007
@@ -55,14 +55,12 @@
 
     private static final Log log = LogFactory.getLog(RegistryServlet.class);
     protected transient ServletConfig servletConfig;
-    private ConsoleURLMapper consoleURLMapper;
 
     //To store the conetxt path
     private String contextRoot = null;
 
     public void init(ServletConfig config) throws ServletException {
         super.init(config);
-        servletConfig = config;
         RegistryRealm registryRealm;
         Registry coreRegistry;
         try {
@@ -132,9 +130,8 @@
     }
 
     public void init() throws ServletException {
-        super.init();
-        if (servletConfig == null) {
-            init(getServletConfig());
+        if (servletConfig != null) {
+            init(servletConfig);
         }
     }
 
@@ -157,7 +154,6 @@
         if (p1.equals("/web/addResource")) {
             handleFileUpload(httpServletRequest, httpServletResponse);
         }
-        // throw error!
     }
 
     private void handleFileUpload(HttpServletRequest request, 
HttpServletResponse response)
@@ -172,7 +168,7 @@
                     "Resource " + path +
                             " is sucessfully added to the registry.");
             response.setContentType("text/html");
-            request.getRequestDispatcher(ConsoleURLMapper.RESOURCES_JSP)
+            request.getRequestDispatcher(RegistryConstants.RESOURCES_JSP)
                     .forward(request, response);
 
         } catch (RegistryException e) {
@@ -181,7 +177,7 @@
             
request.getSession().setAttribute(RegistryConstants.STATUS_MESSAGE_NAME,
                     e.getMessage());
             response.setContentType("text/html");
-            request.getRequestDispatcher(ConsoleURLMapper.RESOURCES_JSP)
+            request.getRequestDispatcher(RegistryConstants.RESOURCES_JSP)
                     .forward(request, response);
         }
     }
@@ -189,16 +185,7 @@
     protected void doGet(HttpServletRequest request,
                          HttpServletResponse response)
             throws ServletException, IOException {
-
         initContextRoot(request);
-        if (consoleURLMapper.mapAndForward(request, response)) {
-            return;
-        }
-        if (processMetadataView(request, response)) {
-            return;
-        }
-        if (processResourceView(request, response)) {
-        }
     }
 
     /**
@@ -216,7 +203,6 @@
             contextPath = "/";
         }
         this.contextRoot = contextPath;
-        consoleURLMapper = new ConsoleURLMapper(contextRoot);
     }
 
     protected void renderView(String jspName,
@@ -227,97 +213,4 @@
         httpServletRequest.getRequestDispatcher(jspName)
                 .include(httpServletRequest, httpServletResponse);
     }
-
-    private boolean processResourceView(HttpServletRequest request, 
HttpServletResponse response)
-            throws ServletException, IOException {
-
-        String uri = request.getRequestURI();
-        String query = request.getQueryString();
-        if (query != null && !query.startsWith("v=")) {
-            return false;
-        }
-
-        if (query == null) {
-            query = "";
-        } else {
-            query = "?" + query;
-        }
-        // we process only the URL in the form /wso2registry/view/...
-        String viewPart = uri.substring(contextRoot.length());
-        if (!viewPart.startsWith("/view")) {
-            return false;
-        }
-
-        if (uri.endsWith("view") || uri.endsWith("view/")) {
-            response.setContentType("text/html");
-            request.getSession().setAttribute("path", "/" + query);
-            request.getRequestDispatcher("/admin/rest.jsp")
-                    .include(request, response);
-            return true;
-        }
-        String path = uri.substring((contextRoot + 
RegistryConstants.TAG_REGISTRY).length(),
-                uri.length());
-        path = path + query;
-
-        try {
-            Registry registry = Utils.getSecureRegistry(request);
-            Resource resource = registry.get(path);
-
-            if (resource != null && !resource.isDirectory()) {
-                Object content = resource.getContent();
-                if (content != null) {
-                    if (content instanceof byte[]) {
-                        response.setContentType(resource.getMediaType());
-                        response.getOutputStream().write((byte[]) content);
-                        response.flushBuffer();
-                    } else {
-                        response.setContentType(resource.getMediaType());
-                        response.getWriter().write(content.toString());
-                    }
-                }
-
-                response.getWriter().flush();
-            } else {
-                request.getSession().setAttribute("path", path);
-                response.setContentType("text/html");
-                request.getRequestDispatcher("/admin/rest.jsp")
-                        .forward(request, response);
-            }
-        } catch (RegistryException e) {
-            request.getSession().setAttribute("error_message", e.getMessage());
-            response.setContentType("text/html");
-            request.getRequestDispatcher("/admin/error.jsp")
-                    .forward(request, response);
-        }
-        return true;
-    }
-
-    private boolean processMetadataView(HttpServletRequest request, 
HttpServletResponse response)
-            throws ServletException, IOException {
-        String query = request.getQueryString();
-        if (query != null) {
-            if (query.equalsIgnoreCase("tags")) {
-                String uri = request.getRequestURI();
-                String path = uri.substring(
-                        (contextRoot + 
RegistryConstants.TAG_REGISTRY).length(), uri.length());
-
-                request.getSession().setAttribute(RegistryConstants.PATH, 
path);
-                response.setContentType("text/html");
-                request.getRequestDispatcher("/admin/tags.jsp")
-                        .forward(request, response);
-                return true;
-            } else if (query.equalsIgnoreCase("comments")) {
-                String uri = request.getRequestURI();
-                String path = uri.substring(
-                        (contextRoot + 
RegistryConstants.TAG_REGISTRY).length(), uri.length());
-
-                request.getSession().setAttribute(RegistryConstants.PATH, 
path);
-                response.setContentType("text/html");
-                request.getRequestDispatcher("/admin/comments.jsp")
-                        .forward(request, response);
-                return true;
-            }
-        }
-        return false;
-    }
 }

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ActionInvoker.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ActionInvoker.java
       (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ActionInvoker.java
       Tue Dec 18 03:09:04 2007
@@ -17,7 +17,7 @@
 package org.wso2.registry.web;
 
 import org.wso2.registry.RegistryException;
-import org.wso2.registry.servlet.ConsoleURLMapper;
+import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.web.actions.AddCollectionAction;
 
 import javax.servlet.http.HttpServletRequest;
@@ -32,7 +32,7 @@
         String contextRoot = getContextRoot(request);
 
         String regAction = request.getParameter("regAction");
-        String path = (String) 
request.getSession().getAttribute(ConsoleURLMapper.PATH_ATTR);
+        String path = (String) 
request.getSession().getAttribute(RegistryConstants.PATH_ATTR);
 
         if (regAction != null) {
             if (regAction.equals("addCollection")) {

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to