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

chathura at wso2.com chathura at wso2.com
Thu Jul 3 05:10:49 PDT 2008


Author: chathura
Date: Thu Jul  3 05:10:49 2008
New Revision: 18828
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=18828

Log:

Implemented the first phase of custom UIs for media types (as discussed in registry-dev list).
Handler author should extend the UIEnabledHanlder to get the custom UI support.
UIEnabledHandler.getView(...) should provide the HTML for viewing the resource content.
UIEnabledHandler.getEdit(...) should provide the HTML for editing the resource content.
Handler author should also implement a EditProcessor to convert the custom HTML form input to a valid resource content.

There is some more work to be done on this.
1) Provide build in support to use XSLT to convert XML contents to HTML (currently this requires some code in handlers).
2) Improve the viewing of generated custom UIs in the registry UI.
3) Implement some good samples to demonstrate the custom UIs.



Added:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/EditProcessor.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/UIEnabledHandler.java
Modified:
   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/config/RegistryContext.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/BasicRegistry.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/HandlerManager.java
   trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryUtils.java
   trunk/registry/modules/extensions/src/org/wso2/registry/servlet/registry.xml
   trunk/registry/modules/samples/handler-sample/resources/registry.xml
   trunk/registry/modules/webapps/conf/web.xml
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java
   trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-properties.jsp
   trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp

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=18828&r1=18827&r2=18828&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  3 05:10:49 2008
@@ -126,6 +126,20 @@
     // Separator used to access Registry metadata - i.e. "/resource$tags"
     public static final String URL_SEPARATOR = ";";
 
+    public static final String VIEW_ACTION = ";view";
+    public static final String VIEW_PROPERTY = "view";
+
+    public static final String EDIT_ACTION = ";edit";
+    public static final String EDIT_PROPERTY = "edit";
+
+    public static final String UI_CONTENT_PROPERTY = "UI.content";
+    public static final String UI_HTML = "UI.HTML";
+    public static final String UI_TEXT = "UI.text";
+    public static final String UI_XML = "UI.XML";
+    public static final String UI_NONE = "UI.none";
+
+    public static final String CUSTOM_EDIT_PROCESSOR_KEY = "edit-processor";
+
     public static final String RESOURCES_PATH = "resources";
 
     public static final String REGISTRY_NAMESPACE = "http://wso2.org/registry";

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=18828&r1=18827&r2=18828&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  3 05:10:49 2008
@@ -26,6 +26,8 @@
 import org.wso2.registry.exceptions.RegistryException;
 import org.wso2.registry.i18n.Messages;
 import org.wso2.registry.jdbc.handlers.Handler;
+import org.wso2.registry.jdbc.handlers.EditProcessor;
+import org.wso2.registry.jdbc.handlers.CustomEditManager;
 import org.wso2.registry.jdbc.handlers.filters.Filter;
 
 import javax.xml.namespace.QName;
@@ -108,7 +110,7 @@
 
                 String currentConfigName = currentConfigElement.getText();
                 registryContext.selectDBConfig(currentConfigName);
-                
+
                 initializeHandlers(configElement, registryContext);
 
                 // process media type handler config
@@ -253,13 +255,13 @@
 
         // process handler configurations
 
+        CustomEditManager customEditManager = registryContext.getCustomEditManager();
+
         try {
             Iterator<OMElement> handlerConfigs =
                     configElement.getChildrenWithName(new QName("handler"));
             while (handlerConfigs.hasNext()) {
 
-
-
                 OMElement handlerConfigElement =  handlerConfigs.next();
 
                 String handlerClassName = handlerConfigElement.getAttributeValue(new QName("class"));
@@ -267,6 +269,18 @@
                 Class handlerClass = Class.forName(handlerClassName);
                 Handler handler = (Handler) handlerClass.newInstance();
 
+                OMElement editElement =
+                        handlerConfigElement.getFirstChildWithName(new QName("edit"));
+                if (editElement != null) {
+                    String processorKey = editElement.getAttributeValue(new QName("processor"));
+                    String processorClassName = editElement.getText();
+                    Class editProcessotClass = Class.forName(processorClassName);
+                    EditProcessor editProcessor = (EditProcessor) editProcessotClass.newInstance();
+
+                    customEditManager.addProcessor(processorKey, editProcessor);
+                }
+
+
                 // set configured properties of the handler object
                 Iterator<OMElement> handlerProps =
                         handlerConfigElement.getChildrenWithName(new QName("property"));

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/config/RegistryContext.java	Thu Jul  3 05:10:49 2008
@@ -23,6 +23,7 @@
 import org.wso2.registry.jdbc.EmbeddedRegistry;
 import org.wso2.registry.jdbc.Repository;
 import org.wso2.registry.jdbc.handlers.HandlerManager;
+import org.wso2.registry.jdbc.handlers.CustomEditManager;
 import org.wso2.registry.jdbc.utils.RegistryDataSource;
 
 import javax.naming.Context;
@@ -45,6 +46,7 @@
             new HashMap<String, DataBaseConfiguration>();
     private List<HandlerConfiguration> handlerConfigurations = new ArrayList();
     private HandlerManager handlerManager = new HandlerManager();
+    private CustomEditManager customEditManager = new CustomEditManager();
     private List mediaTypeHandlers = new ArrayList();
     private List urlHandlers = new ArrayList();
     private List queryProcessors = new ArrayList();
@@ -224,4 +226,12 @@
     public HandlerManager getHandlerManager() {
         return handlerManager;
     }
+
+    public CustomEditManager getCustomEditManager() {
+        return customEditManager;
+    }
+
+    public void setCustomEditManager(CustomEditManager customEditManager) {
+        this.customEditManager = customEditManager;
+    }
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/BasicRegistry.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/BasicRegistry.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/BasicRegistry.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/BasicRegistry.java	Thu Jul  3 05:10:49 2008
@@ -106,6 +106,18 @@
         // check if this path refers to a resource referred by a URL query (e.g. comment)
 
         RequestContext requestContext = new RequestContext(this, repository);
+
+        if (path.endsWith(RegistryConstants.VIEW_ACTION)) {
+            path =  path.substring(0, path.length() - RegistryConstants.VIEW_ACTION.length());
+            requestContext.setProperty(
+                    RegistryConstants.UI_CONTENT_PROPERTY, RegistryConstants.VIEW_PROPERTY);
+
+        } else if (path.endsWith(RegistryConstants.EDIT_ACTION)) {
+            path = path.substring(0, path.length() - RegistryConstants.EDIT_ACTION.length());
+            requestContext.setProperty(
+                    RegistryConstants.UI_CONTENT_PROPERTY, RegistryConstants.EDIT_PROPERTY);
+        }
+
         requestContext.setResourcePath(path);
 
         Resource resource = registryContext.getHandlerManager().get(requestContext);

Added: 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?pathrev=18828
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/CustomEditManager.java	Thu Jul  3 05:10:49 2008
@@ -0,0 +1,60 @@
+/*
+ * 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.RegistryConstants;
+import org.wso2.registry.exceptions.RegistryException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import java.util.HashMap;
+
+public class CustomEditManager {
+
+    private static Log log = LogFactory.getLog(CustomEditManager.class);
+
+    private Map <String, EditProcessor> editProcessors = new HashMap <String, EditProcessor> ();
+
+    public void addProcessor(String processorKey, EditProcessor editProcessor) {
+        editProcessors.put(processorKey, editProcessor);
+    }
+
+    public void process(String path, HttpServletRequest request, HttpServletResponse response)
+            throws RegistryException {
+
+        String processorKey = request.getParameter(RegistryConstants.CUSTOM_EDIT_PROCESSOR_KEY);
+        if (processorKey == null) {
+            String msg = "Processor key is not set in the request, " +
+                    "which is generated by a custom edit UI.";
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+        EditProcessor editProcessor = editProcessors.get(processorKey);
+        if (editProcessor == null) {
+            String msg = "Edit processor is not registered for processing " +
+                    "the custom edit requests for key " + processorKey;
+            log.error(msg);
+            throw new RegistryException(msg);
+        }
+
+        editProcessor.processEdit(path, request, response);
+    }
+}

Added: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/EditProcessor.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/EditProcessor.java?pathrev=18828
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/EditProcessor.java	Thu Jul  3 05:10:49 2008
@@ -0,0 +1,58 @@
+/*
+ * 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.Registry;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.session.UserRegistry;
+import org.wso2.registry.jdbc.EmbeddedRegistry;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.ServletContext;
+
+public abstract class EditProcessor {
+
+    public abstract void processEdit(
+            String path, HttpServletRequest request, HttpServletResponse response)
+            throws RegistryException;
+
+    protected Registry getRegistry(HttpServletRequest request) throws RegistryException {
+
+        Registry registry =
+                (Registry) request.getSession().getAttribute(RegistryConstants.USER_REGISTRY);
+
+        if (registry == null) {
+
+            // user is not logged in. create a annoymous registry for the user.
+
+            ServletContext context =
+                    request.getSession().getServletContext();
+            EmbeddedRegistry embeddedRegistry =
+                    (EmbeddedRegistry)context.getAttribute(RegistryConstants.REGISTRY);
+
+            UserRegistry userRegistry = embeddedRegistry.getUserRegistry();
+
+            request.getSession().setAttribute(RegistryConstants.USER_REGISTRY, userRegistry);
+
+            registry = userRegistry;
+        }
+
+        return registry;
+    }
+}

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/Handler.java	Thu Jul  3 05:10:49 2008
@@ -27,6 +27,7 @@
  * used by handler impls.
  */
 public abstract class Handler {
+    
     /** ResourceDAO for directly accessing resources. */
     protected ResourceDAO resourceDAO = new ResourceDAO();
 
@@ -120,4 +121,5 @@
      * on the media type and if the importChild fails due a handler specific error
      */
     public abstract void importChild(RequestContext requestContext) throws RegistryException;
+
 }

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/HandlerManager.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/HandlerManager.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/HandlerManager.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/HandlerManager.java	Thu Jul  3 05:10:49 2008
@@ -19,6 +19,8 @@
 import org.wso2.registry.Registry;
 import org.wso2.registry.exceptions.RegistryException;
 import org.wso2.registry.Resource;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.utils.RegistryUtils;
 import org.wso2.registry.jdbc.Repository;
 import org.wso2.registry.jdbc.handlers.filters.Filter;
 
@@ -65,7 +67,8 @@
         while (filters.hasNext()) {
             Filter filter = filters.next();
             if (filter.handleGet(requestContext)) {
-                resource = handlerMap.get(filter).get(requestContext);
+                Handler handler = handlerMap.get(filter);
+                resource = handler.get(requestContext);
             }
 
             if (requestContext.isProcessingComplete()) {

Added: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/UIEnabledHandler.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/UIEnabledHandler.java?pathrev=18828
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/UIEnabledHandler.java	Thu Jul  3 05:10:49 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.Resource;
+import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.exceptions.RegistryException;
+
+public abstract class UIEnabledHandler extends Handler {
+
+    public Resource get(RequestContext requestContext) throws RegistryException {
+
+        // UI enabling actions should always position at the end of the resource path.
+
+        String UIAction =
+                (String) requestContext.getProperty(RegistryConstants.UI_CONTENT_PROPERTY);
+        if (UIAction != null) {
+            if (RegistryConstants.VIEW_PROPERTY.equals(UIAction)) {
+                return getView(requestContext);
+            } else if (RegistryConstants.EDIT_PROPERTY.equals(UIAction)) {
+                return getEdit(requestContext);
+            }
+        }
+
+        return getRawResource(requestContext);
+    }
+
+    public abstract Resource getRawResource(RequestContext requestContext)
+            throws RegistryException;
+
+    public abstract Resource getView(RequestContext requestContext)
+            throws RegistryException;
+
+    public abstract Resource getEdit(RequestContext requestContext)
+            throws RegistryException;
+}

Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryUtils.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryUtils.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryUtils.java	(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/utils/RegistryUtils.java	Thu Jul  3 05:10:49 2008
@@ -146,6 +146,18 @@
         return path;
     }
 
+    public static String removeUISuffixes(String path) {
+
+        if (path.endsWith(RegistryConstants.VIEW_ACTION)) {
+            return path.substring(0, path.length() - RegistryConstants.VIEW_ACTION.length());
+
+        } else if (path.endsWith(RegistryConstants.EDIT_ACTION)) {
+            return path.substring(0, path.length() - RegistryConstants.EDIT_ACTION.length());
+        }
+
+        return path;
+    }
+
     public static boolean containsString(String value, String[] array) {
         boolean found = false;
 

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=18828&r1=18827&r2=18828&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  3 05:10:49 2008
@@ -88,5 +88,13 @@
         </filter>
     </handler>
 
+    <!--<handler class="org.wso2.registry.jdbc.handlers.samples.custom.AFHandler">-->
+        <!--<filter class="org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher">-->
+            <!--<property name="mediaType">application/aff+xml</property>-->
+        <!--</filter>-->
+
+        <!--<edit processor="application/aff+xml">org.wso2.registry.jdbc.handlers.samples.custom.AFEditProcessor</edit>-->
+    <!--</handler>-->
+
     <aspect name="Lifecycle" class="org.wso2.registry.aspects.Lifecycle"/>
 </wso2regsitry>
\ No newline at end of file

Modified: trunk/registry/modules/samples/handler-sample/resources/registry.xml
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/samples/handler-sample/resources/registry.xml?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/samples/handler-sample/resources/registry.xml	(original)
+++ trunk/registry/modules/samples/handler-sample/resources/registry.xml	Thu Jul  3 05:10:49 2008
@@ -61,11 +61,18 @@
             <property name="mediaType">application/x-xsd+xml</property>
         </filter>
     </handler>
+
     <handler class="org.wso2.registry.plugins.mediatypes.pp.ProjectProposalMediaTypeHandler">
         <filter class="org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher">
              <property name="mediaType">application/vnd.project.proposal</property>
          </filter>
     </handler>
 
+    <!--<handler class="org.wso2.registry.jdbc.handlers.samples.custom.AFHandler">-->
+        <!--<filter class="org.wso2.registry.jdbc.handlers.filters.MediaTypeMatcher">-->
+            <!--<property name="mediaType">application/aff+xml</property>-->
+        <!--</filter>-->
+    <!--</handler>-->
+
     <aspect name="default" class="org.wso2.registry.aspects.DefaultLifecycle"/>
 </wso2regsitry>
\ No newline at end of file

Modified: trunk/registry/modules/webapps/conf/web.xml
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/conf/web.xml?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/webapps/conf/web.xml	(original)
+++ trunk/registry/modules/webapps/conf/web.xml	Thu Jul  3 05:10:49 2008
@@ -35,19 +35,27 @@
         <servlet-name>WebServlet</servlet-name>
         <url-pattern>/web/*</url-pattern>
     </servlet-mapping>
+
     <servlet-mapping>
         <servlet-name>WebServlet</servlet-name>
         <url-pattern>/system/*</url-pattern>
     </servlet-mapping>
+
     <servlet-mapping>
         <servlet-name>RegistryServlet</servlet-name>
         <url-pattern>/resources/*</url-pattern>
     </servlet-mapping>
+
     <servlet-mapping>
         <servlet-name>WebServlet</servlet-name>
         <url-pattern>/versions/*</url-pattern>
     </servlet-mapping>
 
+    <servlet-mapping>
+        <servlet-name>WebServlet</servlet-name>
+        <url-pattern>/custom/*</url-pattern>
+    </servlet-mapping>
+
     <welcome-file-list>
       <welcome-file>admin/index.jsp</welcome-file>
     </welcome-file-list>

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java	Thu Jul  3 05:10:49 2008
@@ -17,6 +17,9 @@
 package org.wso2.registry.web;
 
 import org.wso2.registry.*;
+import org.wso2.registry.utils.RegistryUtils;
+import org.wso2.registry.config.RegistryContext;
+import org.wso2.registry.jdbc.handlers.CustomEditManager;
 import org.wso2.registry.exceptions.RegistryException;
 import org.wso2.registry.session.UserRegistry;
 import org.wso2.registry.secure.AuthorizationFailedException;
@@ -44,6 +47,14 @@
     //To store the conetxt path
     private String contextRoot = null;
 
+    private CustomEditManager customEditManager;
+
+    public void init(ServletConfig servletConfig) throws ServletException {
+        super.init(servletConfig);
+
+        customEditManager = RegistryContext.getSingleton().getCustomEditManager();
+    }
+
     protected void doPost(HttpServletRequest request,
                           HttpServletResponse response)
             throws ServletException, IOException {
@@ -397,6 +408,19 @@
                 AdminUtil.addDBURLBasedConfiguration(request, response);
 
             }
+
+        } else if (controlPart.startsWith(RegistryConstants.PATH_SEPARATOR + UIConstants.CUSTOM_PATH)) {
+
+            String resourcePath = uri.substring((contextRoot + RegistryConstants.PATH_SEPARATOR + UIConstants.CUSTOM_PATH).
+                    length(), uri.length());
+
+            try {
+                customEditManager.process(resourcePath, request, response);
+            } catch (RegistryException e) {
+                setErrorMessage(request, e.getMessage());
+            }
+
+            response.sendRedirect("/wso2registry/web" + RegistryUtils.removeUISuffixes(path));
         }
     }
 

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java	Thu Jul  3 05:10:49 2008
@@ -42,6 +42,7 @@
     public static final String VERSIONS_PATH = "versions";
     public static final String WEB_PATH = "web";
     public static final String SYSTEM_PATH = "system";
+    public static final String CUSTOM_PATH = "custom";
     public static final String PATH_ATTR = "path";
     public static final String USER_ATTR = "currentUser";
     public static final String IS_ADMIN_ATTR = "is.admin";

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=18828&r1=18827&r2=18828&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  3 05:10:49 2008
@@ -76,6 +76,10 @@
 
     private String parentPath;
     private String[] aspectsToAdd;
+
+    private String UIContent;
+    private String contentString;
+
     /**
      * Used to populate the users in the userPermissions section
      */
@@ -185,10 +189,19 @@
         //    contentPath = path + "?content";
         //}
 
+        if (!(path.endsWith(RegistryConstants.VIEW_ACTION) || path.endsWith(RegistryConstants.EDIT_ACTION))) {
+            path = path + RegistryConstants.VIEW_ACTION;
+        }
+
         resource = registry.get(path);
 
+        UIContent = resource.getProperty(RegistryConstants.UI_CONTENT_PROPERTY);
+        if (UIContent != null && !RegistryConstants.UI_NONE.equals(UIContent)) {
+            contentString = (String) resource.getContent();
+        }
+
         if (!versionView) {
-            permalink = resource.getPermanentPath();           
+            permalink = resource.getPermanentPath();
         } else {
             permalink = path;
         }
@@ -753,4 +766,12 @@
     public void setAspectsToAdd(String[] aspectsToAdd) {
         this.aspectsToAdd = aspectsToAdd;
     }
+
+    public String getUIContent() {
+        return UIContent;
+    }
+
+    public String getContentString() {
+        return contentString;
+    }
 }

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-properties.jsp
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-properties.jsp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-properties.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/resource-properties.jsp	Thu Jul  3 05:10:49 2008
@@ -1,5 +1,3 @@
-<%@ page import="org.wso2.registry.web.UIConstants" %>
-<%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
 <%@ page import="org.wso2.registry.web.utils.PropertiesUtil" %>
 <%@ page import="org.wso2.registry.Aspect" %>
 <%@ page import="java.util.ArrayList" %>

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=18828&r1=18827&r2=18828&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  3 05:10:49 2008
@@ -983,7 +983,35 @@
 
 <% } else { %>
 
+<% if (RegistryConstants.UI_HTML.equals(details.getUIContent())) { %>
+
+This should go inside a nice border.
+<%=details.getContentString()%>
+
+<br/>
+<a href="/wso2registry/web<%=details.getPath()%>;edit">Edit</a>
+
+<% } else if (RegistryConstants.UI_XML.equals(details.getUIContent())) { %>
+
+This should go inside a xml viewer.
+<%=details.getContentString()%>
+
+<br/>
+<a href="/wso2registry/web<%=details.getPath()%>;edit">Edit</a>
+
+<% } else if (RegistryConstants.UI_TEXT.equals(details.getUIContent())) { %>
+
+This should go inside a text viewer.
+<%=details.getContentString()%>
+
+<br/>
+<a href="/wso2registry/web<%=details.getPath()%>;edit">Edit</a>
+
+<% } %>
+
 <br/>
+<br/>
+
 <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>
 



More information about the Registry-dev mailing list