[Registry-dev] svn commit r19118 - in trunk/registry: . modules/core/src/main/java/org/wso2/registry modules/core/src/main/java/org/wso2/registry/config modules/core/src/main/java/org/wso2/registry/jdbc modules/core/src/main/java/org/wso2/registry/jdbc/handlers modules/core/src/main/java/org/wso2/registry/servlet modules/extensions/src/org/wso2/registry/servlet modules/samples/collection-handler-sample modules/webapps/src/main/java/org/wso2/registry/web/actions modules/webapps/src/main/webapp/admin

chathura at wso2.com chathura at wso2.com
Thu Jul 10 22:59:52 PDT 2008


Author: chathura
Date: Thu Jul 10 22:59:51 2008
New Revision: 19118
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19118

Log:

Implementing the custom UI support for collections. Some more stuff has to be done make this really nice.

Implemented UI support for displaying resources with text content.

Added a collection custom UI sample (a collection type to manage server information).



Added:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/TextEditProcessor.java
   trunk/registry/modules/samples/collection-handler-sample/
Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/Collection.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/CollectionImpl.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java
   trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
   trunk/registry/pom.xml

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Collection.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/Collection.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Collection.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Collection.java	Thu Jul 10 22:59:51 2008
@@ -19,6 +19,10 @@
 
 public interface Collection extends Resource {
 
+    public static final String ALLOW_ALL = "ALLOW_ALL";
+    public static final String ALLOW_SELECTED = "ALLOW_SELECTED";
+    public static final String DENY_SELECTED = "DENY_SELECTED";
+
     String [] getChildren() throws RegistryException;
 
     String [] getChildren(int start, int pageLen) throws RegistryException;
@@ -26,4 +30,14 @@
     int getChildCount() throws RegistryException;
 
     void setChildCount(int count);
+
+    //void setChildPolicy(String policy);
+    //
+    //String getChildPolicy();
+    //
+    //void addChildMediaType(String mediaType);
+    //
+    //void removeChildMediaType(String mediaType);
+    //
+    //String[] getChildMediaTypes();
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/CollectionImpl.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/CollectionImpl.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/CollectionImpl.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/CollectionImpl.java	Thu Jul 10 22:59:51 2008
@@ -44,11 +44,17 @@
     }
 
     public void setContent(Object content) {
-        if (content instanceof String[] || content instanceof Resource[]) {
+
+        // note that string contents are allowed in collection to support custom generated UIs.
+        if (content instanceof String[] ||
+                content instanceof Resource[] ||
+                content instanceof String) {
             super.setContent(content);
             return;
         }
-        throw new IllegalArgumentException("Collections can only contain paths (String[])!");
+        throw new IllegalArgumentException("Invalid content for collection. " +
+                "Content of type " + content.getClass().toString() +
+                " is not allowed for collections.");
     }
 
     public String[] getChildren() throws RegistryException {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- 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	Thu Jul 10 22:59:51 2008
@@ -138,6 +138,9 @@
     public static final String UI_XML = "UI.XML";
     public static final String UI_NONE = "UI.none";
 
+    public static final String TEXT_INPUT_NAME = "generic-text-input";
+    public static final String TEXT_EDIT_PROCESSOR_KEY = "system.text.edit.processor";
+
     public static final String CUSTOM_EDIT_PROCESSOR_KEY = "edit-processor";
 
     public static final String RESOURCES_PATH = "resources";

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryConfigurationProcessor.java	Thu Jul 10 22:59:51 2008
@@ -317,12 +317,12 @@
                     setter.invoke(filter, propValue);
                 }
 
-
-                HandlerConfiguration handlerConfiguration = new HandlerConfiguration();
-                handlerConfiguration.setHandler(handler);
-                handlerConfiguration.setFilter(filter);
-
-                registryContext.addHandlerConfiguration(handlerConfiguration);
+                registryContext.getHandlerManager().addHandler(0, filter, handler);
+                //HandlerConfiguration handlerConfiguration = new HandlerConfiguration();
+                //handlerConfiguration.setHandler(handler);
+                //handlerConfiguration.setFilter(filter);
+                //
+                //registryContext.addHandlerConfiguration(handlerConfiguration);
             }
 
         } catch (Exception e) {

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java	Thu Jul 10 22:59:51 2008
@@ -133,8 +133,8 @@
 
         if (registryContext == null) {
             registryContext = new RegistryContext();
-            RegistryContext.setSingleton(registryContext);
         }
+        RegistryContext.setSingleton(registryContext);
         registryContext.setRepository(repository);
 
         resourceDAO = new ResourceDAO();

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java	Thu Jul 10 22:59:51 2008
@@ -32,6 +32,12 @@
 
     private Map <String, EditProcessor> editProcessors = new HashMap <String, EditProcessor> ();
 
+    public CustomEditManager() {
+
+        // we should register built in edit processors here
+        editProcessors.put(RegistryConstants.TEXT_EDIT_PROCESSOR_KEY, new TextEditProcessor());
+    }
+
     public void addProcessor(String processorKey, EditProcessor editProcessor) {
         editProcessors.put(processorKey, editProcessor);
     }

Added: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/TextEditProcessor.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/TextEditProcessor.java?pathrev=19118
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/TextEditProcessor.java	Thu Jul 10 22:59:51 2008
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2006, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed 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.jdbc.handlers;
+
+import org.wso2.registry.exceptions.RegistryException;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.Registry;
+import org.wso2.registry.Resource;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class TextEditProcessor extends EditProcessor {
+
+    public void processEdit(String path, HttpServletRequest request, HttpServletResponse response)
+            throws RegistryException {
+
+        String textContent = request.getParameter(RegistryConstants.TEXT_INPUT_NAME);
+
+        Registry registry = getRegistry(request);
+        Resource resource = registry.get(path);
+        resource.setContent(textContent);
+
+        registry.put(path, resource);
+    }
+}

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- 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	Thu Jul 10 22:59:51 2008
@@ -87,13 +87,14 @@
                     RegistryConstants.SYSTEM_USER, RegistryConstants.SYSTEM_PASSWORD);
 
             // add configured handers to the jdbc registry
-            Iterator<HandlerConfiguration> handlers =
-                    registryContext.getHandlerConfigurations().iterator();
-            while (handlers.hasNext()) {
-                HandlerConfiguration handlerConfiguration = handlers.next();
-                registryContext.getHandlerManager().addHandler(0,
-                        handlerConfiguration.getFilter(), handlerConfiguration.getHandler());
-            }
+            // note: no need to do this here. this is done inside the registry context
+            //Iterator<HandlerConfiguration> handlers =
+            //        registryContext.getHandlerConfigurations().iterator();
+            //while (handlers.hasNext()) {
+            //    HandlerConfiguration handlerConfiguration = handlers.next();
+            //    registryContext.getHandlerManager().addHandler(0,
+            //            handlerConfiguration.getFilter(), handlerConfiguration.getHandler());
+            //}
 
             // create system resources
             if (!systemRegistry.resourceExists("/system")) {

Modified: trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml	(original)
+++ trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml	Thu Jul 10 22:59:51 2008
@@ -108,5 +108,19 @@
         <!--<edit processor="application/aff+xml">org.wso2.registry.jdbc.handlers.samples.custom.AFEditProcessor</edit>-->
     <!--</handler>-->
 
+     <!--handler class="org.wso2.registry.samples.handlers.servers.ServerDetailsHandler">
+        <filter class="org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher">
+            <property name="mediaType">application/vnd.server-info</property>
+        </filter>
+
+        <edit processor="application/vnd.server-info">org.wso2.registry.samples.handlers.servers.ServerDetailsEditProcessor</edit>
+    </handler>
+
+     <handler class="org.wso2.registry.samples.handlers.servers.ServerCollectionHandler">
+        <filter class="org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher">
+            <property name="mediaType">application/vnd.server-collection</property>
+        </filter>
+    </handler-->
+
     <aspect name="Lifecycle" class="org.wso2.registry.aspects.Lifecycle"/>
 </wso2regsitry>
\ No newline at end of file

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionPagesViewAction.java	Thu Jul 10 22:59:51 2008
@@ -51,7 +51,7 @@
                 Resource child = registry.get(childPath);
 
                 ResourceData resourceData = new ResourceData();
-                resourceData.setResourcePath(childPath);
+                resourceData.setResourcePath(childPath + RegistryConstants.VIEW_ACTION);
 
                 if (childPath != null) {
                     String[] parts = childPath.split(RegistryConstants.PATH_SEPARATOR);

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java	Thu Jul 10 22:59:51 2008
@@ -79,6 +79,7 @@
 
     private String UIContent;
     private String contentString;
+    private String UIAction;
 
     /**
      * Used to populate the users in the userPermissions section
@@ -189,8 +190,15 @@
         //    contentPath = path + "?content";
         //}
 
-        if (!(path.endsWith(RegistryConstants.VIEW_ACTION) || path.endsWith(RegistryConstants.EDIT_ACTION))) {
-            path = path + RegistryConstants.VIEW_ACTION;
+        //if (!(path.endsWith(RegistryConstants.VIEW_ACTION) || path.endsWith(RegistryConstants.EDIT_ACTION))) {
+        //    path = path + RegistryConstants.VIEW_ACTION;
+        //}
+
+        if (path.endsWith(RegistryConstants.VIEW_ACTION)) {
+            UIAction = RegistryConstants.VIEW_PROPERTY;
+
+        } else if (path.endsWith(RegistryConstants.EDIT_ACTION)) {
+            UIAction = RegistryConstants.EDIT_PROPERTY;
         }
 
         resource = registry.get(path);
@@ -774,4 +782,8 @@
     public String getContentString() {
         return contentString;
     }
+
+    public String getUIAction() {
+        return UIAction;
+    }
 }

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp	Thu Jul 10 22:59:51 2008
@@ -550,6 +550,19 @@
 
 <% if (details.isCollection()) { %>
 
+<% if (RegistryConstants.UI_HTML.equals(details.getUIContent())) { %>
+
+<a href="/wso2registry/web<%=details.getPath()%>">List view</a>
+
+<hr /><br/>
+<%=details.getContentString()%>
+
+<% } else { %>
+
+<% if (!RegistryConstants.VIEW_PROPERTY.equals(details.getUIAction())) { %>
+<a href="/wso2registry/web<%=details.getPath()%>;view">Customized view</a>
+<% } %>
+
 <!-- Add resource div -->
 <div class="add-resource-div" id="add-resource-div" style="display:none;">
     <form onsubmit="return submitResourceAddForm();" method="post" name="resourceupload" id="resourceupload"
@@ -981,6 +994,8 @@
 </table>
 </div>
 
+<% } %>
+
 <% } else { %>
 
 <% if (RegistryConstants.UI_HTML.equals(details.getUIContent())) { %>
@@ -988,8 +1003,10 @@
 <hr /><br/>
 <%=details.getContentString()%>
 
+<% if (!RegistryConstants.EDIT_PROPERTY.equals(details.getUIAction())) { %>
 <br/>
 <a href="/wso2registry/web<%=details.getPath()%>;edit">Edit</a>
+<% } %>>
 
 <% } else if (RegistryConstants.UI_XML.equals(details.getUIContent())) { %>
 
@@ -1001,21 +1018,34 @@
 
 <% } else if (RegistryConstants.UI_TEXT.equals(details.getUIContent())) { %>
 
-This should go inside a text viewer.
+<% if (RegistryConstants.VIEW_PROPERTY.equals(details.getUIAction())) { %>
 <%=details.getContentString()%>
 
 <br/>
 <a href="/wso2registry/web<%=details.getPath()%>;edit">Edit</a>
 
+<% } else if (RegistryConstants.EDIT_PROPERTY.equals(details.getUIAction())) { %>
+
+<form method="post" action="/wso2registry/custom<%=details.getPath()%>">
+    <input type="hidden" name="edit-processor" value="<%=RegistryConstants.TEXT_EDIT_PROCESSOR_KEY%>"/>
+    <input type="text" name="<%=RegistryConstants.TEXT_INPUT_NAME%>" value="<%=details.getContentString()%>"/>
+    <input type="submit" value="Save"/>
+</form>
+
+<% } %>
+
 <% } %>
 
 <br/>
 <br/>
 
+<% if (!RegistryConstants.EDIT_PROPERTY.equals(details.getUIAction())) { %>
 <a href="/wso2registry/resources<%=details.getContentPath()%>" target="_blank" class="download-link"><img
         src="/wso2registry/admin/images/icon-download.jpg" border="0" align="top"/> Download</a>
 
 <% } %>
+
+<% } %>
 <!-- End box1-mid div -->
 </div>
 

Modified: trunk/registry/pom.xml
URL: http://wso2.org/svn/browse/wso2/trunk/registry/pom.xml?rev=19118&r1=19117&r2=19118&view=diff
==============================================================================
--- trunk/registry/pom.xml	(original)
+++ trunk/registry/pom.xml	Thu Jul 10 22:59:51 2008
@@ -115,6 +115,12 @@
             <email>chanaka AT wso2.com</email>
             <organization>WSO2</organization>
         </developer>
+        <developer>
+            <name>Krishantha Samaraweera</name>
+            <id>krishantha</id>
+            <email>krishantha AT wso2.com</email>
+            <organization>WSO2</organization>
+        </developer>
     </developers>
 
     <modules>



More information about the Registry-dev mailing list