[Registry-dev] svn commit r6676 - trunk/registry/java/modules/core/src/main/java/org/wso2/registry/servlet/actions

svn at wso2.org svn at wso2.org
Wed Aug 29 02:49:27 PDT 2007


Author: chathura
Date: Wed Aug 29 02:49:19 2007
New Revision: 6676

Added:
   trunk/registry/java/modules/core/src/main/java/org/wso2/registry/servlet/actions/GetResourceActionProcessor.java
Removed:
   trunk/registry/java/modules/core/src/main/java/org/wso2/registry/servlet/actions/GetActionProcessor.java
Log:

Renamed the get action processor for resources.



Added: trunk/registry/java/modules/core/src/main/java/org/wso2/registry/servlet/actions/GetResourceActionProcessor.java
==============================================================================
--- (empty file)
+++ trunk/registry/java/modules/core/src/main/java/org/wso2/registry/servlet/actions/GetResourceActionProcessor.java	Wed Aug 29 02:49:19 2007
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.wso2.registry.servlet.actions;
+
+import org.wso2.registry.servlet.ActionProcessor;
+import org.wso2.registry.Actions;
+import org.wso2.registry.Registry;
+import org.wso2.registry.RegistryException;
+import org.wso2.registry.resources.Resource;
+import org.wso2.registry.resources.Directory;
+import org.wso2.registry.engine.Session;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * Processes the get requests for resources. If the target resource is a normal resource with a
+ * content, resource content is sent as the response. If the target resource is a collection
+ * resource, child resource paths of the collection is serailazied in to a xml and sent as the
+ * response.
+ *
+ * Action: http://www.wso2.org/projects/registry/actions/get
+ */
+public class GetResourceActionProcessor implements ActionProcessor {
+
+    Registry registry = null;
+
+    public GetResourceActionProcessor(Registry registry) {
+        this.registry = registry;
+    }
+
+    public boolean process(
+            String action, String path, Session session,
+            HttpServletRequest request, HttpServletResponse response) {
+
+        if (action.equals(Actions.GET)) {
+
+            try {
+                Resource resource = registry.get(path, session);
+
+                if (resource instanceof Directory) {
+
+                    Directory directory = (Directory) resource;
+                    String[] childPaths = directory.getChildNames();
+
+                } else {
+
+                    // serailize the resource content
+
+                }
+
+            } catch (RegistryException e) {
+                e.printStackTrace();
+            }
+
+            return true;
+        }
+        
+        return false;
+    }
+}



More information about the Registry-dev mailing list