[Registry-dev] svn commit r16713 - in trunk/registry/modules/webapps/src/main: java/org/wso2/registry/web java/org/wso2/registry/web/actions webapp/admin webapp/admin/ajax

svn at wso2.org svn at wso2.org
Thu May 8 19:44:18 PDT 2008


Author: chanaka
Date: Thu May  8 19:44:00 2008
New Revision: 16713

Log:

Association Tree page only up to 2 levels with no styling

Added:
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java
   trunk/registry/modules/webapps/src/main/webapp/admin/association-tree.jsp
Modified:
   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/webapp/admin/ajax/association-list.jsp
   trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
==============================================================================
--- 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 May  8 19:44:00 2008
@@ -547,6 +547,10 @@
 
                 forwardToActivity(request, response);
 
+            } else if (command.equals("/associationTree")) {
+
+                forwardToAssociation(request, response,path);
+
             } else if (command.equals("/admin")) {
 
                 forwardToAdmin(request, response);
@@ -886,7 +890,46 @@
             e.printStackTrace();
         }
     }
+    private void forwardToAssociation(HttpServletRequest request, HttpServletResponse response,String path) {
+
+
+        try {
+            ResourceDetailsAction details = new ResourceDetailsAction();
+            details.setPath(path);
+            details.execute(request);
+
+            AssociationTreeViewAction associationTreeViewAction = new AssociationTreeViewAction();
+            associationTreeViewAction.execute(request);
+            
+            CollectionViewAction collection = null;
+            if (details.isCollection()) {
+                collection = new CollectionViewAction();
+                collection.setPath(path);
+                collection.execute(request);
+            }
+
+            request.getSession().setAttribute(UIConstants.RESOURCE_BEAN, details);
+            request.getSession().setAttribute(UIConstants.COLLECTION_BEAN, collection);
+            request.getSession().setAttribute(UIConstants.ASSOCIATION_TREE_BEAN, associationTreeViewAction);
 
+
+        } catch (Exception e) {
+            setErrorMessage(request, e.getMessage());
+            e.printStackTrace();
+        }
+
+
+        setAnnouncementsBean(request);
+
+        try {
+            request.getRequestDispatcher(UIConstants.ASSOCIATION_TREE_JSP).forward(request, response);
+
+        } catch (ServletException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
     private void forwardToAdmin(HttpServletRequest request, HttpServletResponse response) {
 
         AdminBean adminBean = AdminUtil.getAdminBean(request);

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/UIConstants.java
==============================================================================
--- 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 May  8 19:44:00 2008
@@ -20,6 +20,7 @@
 
     public static final String RESOURCE_BEAN = "resource";
     public static final String COLLECTION_BEAN = "collection";
+    public static final String ASSOCIATION_TREE_BEAN="associationTree";
     public static final String USER_MANAGEMENT_BEAN = "user_management";
     public static final String ACTIVITY_BEAN = "activity";
     public static final String ADMIN_BEAN = "admin";
@@ -50,6 +51,7 @@
 
     public static final String RESOURCES_JSP = "/admin/registry-resources.jsp";
     public static final String USER_MANAGEMENT_JSP = "/admin/people.jsp";
+    public static final String ASSOCIATION_TREE_JSP = "/admin/association-tree.jsp";
     public static final String ACTIVITY_JSP = "/admin/recent-activity.jsp";
     public static final String ADMIN_JSP = "/admin/admin.jsp";
     public static final String ADVANCED_SEARCH_JSP = "/admin/advanced-search.jsp";

Added: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AssociationTreeViewAction.java	Thu May  8 19:44:00 2008
@@ -0,0 +1,67 @@
+package org.wso2.registry.web.actions;
+
+import org.wso2.registry.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: chanaka jayasena
+ * Date: May 8, 2008
+ * Time: 1:55:35 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AssociationTreeViewAction extends AbstractRegistryAction {
+   private String resourcePath;
+
+    private String test;
+
+
+    public void execute(HttpServletRequest request) throws RegistryException {
+
+        setRequest(request);
+        test="test";
+
+    }
+    public String calculateRelativePath(String resourcePath) {
+
+        String givenPath = resourcePath;
+        String relativePath=givenPath;
+
+        if (RegistryConstants.ROOT_PATH.equals(givenPath)) {
+            relativePath = "";
+        } else {
+            if (resourcePath.startsWith(RegistryConstants.PATH_SEPARATOR)) {
+                relativePath = givenPath.substring(1, givenPath.length());
+            }
+        }
+        return relativePath;
+    }
+    public List provideChildAssociations(String resourcePath) throws RegistryException{
+        List associations = new ArrayList();
+        Registry registry= getRegistry();
+        Resource resource = registry.get(resourcePath);
+        Association[] asso = registry.getAllAssociations(resource.getPath());
+        associations.addAll(Arrays.asList(asso));
+
+        return associations;
+    }
+    public String getResourcePath() {
+        return resourcePath;
+    }
+
+    public void setResourcePath(String resourcePath) {
+        this.resourcePath = resourcePath;
+    }
+
+     public String getTest() {
+        return test;
+    }
+
+    public void setTest(String test) {
+        this.test = test;
+    }
+}

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/ajax/association-list.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax/association-list.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/association-list.jsp	Thu May  8 19:44:00 2008
@@ -3,6 +3,7 @@
 <%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
 <%@ page import="java.util.Iterator" %>
 <%@ page import="java.util.List" %>
+<%@ page import="org.wso2.registry.Registry" %>
 <%--
   Created by IntelliJ IDEA.
   User: chanaka jayasena
@@ -43,7 +44,7 @@
            <%=association.getAssociationType()%>
         </td>
         <td>
-            <%=association.getDestinationPath()%>
+           <a href="" <%=association.getDestinationPath()%>
         </td>
         </tr>
         <%
@@ -53,3 +54,4 @@
         <%
            }
         %>
+<a href="/wso2registry/system/associationTree"><img src="/wso2registry/admin/images/icon-associationTree.jpg" alt="Association Tree" border="0" /></a>
\ No newline at end of file

Added: trunk/registry/modules/webapps/src/main/webapp/admin/association-tree.jsp
==============================================================================
--- (empty file)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/association-tree.jsp	Thu May  8 19:44:00 2008
@@ -0,0 +1,124 @@
+<%@ page import="org.wso2.registry.Association" %>
+<%@ page import="org.wso2.registry.web.UIConstants" %>
+<%@ page import="org.wso2.registry.web.actions.AssociationTreeViewAction" %>
+<%@ page import="org.wso2.registry.web.actions.CollectionViewAction" %>
+<%@ page import="org.wso2.registry.web.actions.ResourceDetailsAction" %>
+<%@ page import="java.util.Iterator" %>
+<%@ page import="java.util.List" %>
+<%--
+  Created by IntelliJ IDEA.
+  User: chanaka jayasena
+  Date: May 8, 2008
+  Time: 4:56:19 PM
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    AssociationTreeViewAction associationTreeViewAction = (AssociationTreeViewAction) request.getSession().getAttribute(UIConstants.ASSOCIATION_TREE_BEAN);
+    ResourceDetailsAction details = (ResourceDetailsAction) request.getSession().getAttribute(UIConstants.RESOURCE_BEAN);
+    CollectionViewAction collection = (CollectionViewAction) request.getSession().getAttribute(UIConstants.COLLECTION_BEAN);
+
+    String errorMessage = (String) request.getSession().getAttribute(UIConstants.ERROR_MESSAGE);
+    if (errorMessage != null) {
+        request.getSession().setAttribute(UIConstants.ERROR_MESSAGE, null);
+    }
+%>
+<html>
+<head>
+    <title>Simple jsp page</title>
+    <script language="JavaScript" type="text/JavaScript" src="/wso2registry/admin/js/common.js"></script>
+    <link type="text/css" href="/wso2registry/admin/css/main.css" rel="stylesheet"/>
+</head>
+<body>
+<div class="page-sizer">
+    <!-- START header content -->
+
+    <jsp:include page="header.jsp"/>
+
+    <!--This is the START of main table which seperates 2 coloums for promotions and content of the site -->
+    <table cellpadding="0" cellspacing="0" border="0" style="width:100%;">
+        <tr>
+            <td class="promotionDiv" valign="top">
+                <jsp:include page="promotion.jsp"/>
+            </td>
+            <td valign="top">
+                <div class="content">
+
+                    <% if (errorMessage != null) { %>
+                    <div class="error-message"><%=errorMessage%>
+                    </div>
+                    <% } %>
+
+                    <h1 class="headding-resource">Association Tree</h1>
+                    <%
+
+                        List depList = details.getAssociations();
+                        Iterator deps = depList.iterator();
+                        if (depList.size() != 0) {
+
+                    %>
+                    <table cellpadding="0" cellspacing="0" border="0" style="width:100%" class="data-table">
+                        <tr>
+                            <th>
+                                Association Type
+                            </th>
+                            <th>
+                                Association Path
+                            </th>
+                        </tr>
+                        <%
+                            while (deps.hasNext()) {
+                                Association association = (Association) deps.next();
+                        %>
+                        <tr>
+                            <td>
+                                <%=association.getAssociationType()%>
+                            </td>
+                            <td>
+                                <a href="/wso2registry/web/<%=associationTreeViewAction.calculateRelativePath(association.getDestinationPath())%>"><%=association.getDestinationPath()%>
+                                </a>
+                            </td>
+                        </tr>
+                        <%
+                            List childAssoList = associationTreeViewAction.provideChildAssociations(association.getDestinationPath());
+                            Iterator childAssoIterator = childAssoList.iterator();
+                            if (childAssoList.size() != 0) {
+                                while (childAssoIterator.hasNext()) {
+                                    Association childAssociation = (Association) childAssoIterator.next();
+                        %>
+                        <tr>
+                            <td>
+                                <%=childAssociation.getAssociationType()%>
+                            </td>
+                            <td>
+                                <a href="/wso2registry/web/<%=associationTreeViewAction.calculateRelativePath(childAssociation.getDestinationPath())%>"><%=childAssociation.getDestinationPath()%>
+                                </a>
+                            </td>
+                        </tr>
+                        <%
+                                    }
+                                }
+                            }
+                        %>
+                    </table>
+
+                    <%
+
+                        }
+
+                    %>
+
+            </td>
+
+        </tr>
+    </table>
+
+    <!--This is the END of main table which seperates 2 coloums for promotions and content of the site -->
+
+
+    <!-- START footer content -->
+    <jsp:include page="footer.jsp"/>
+
+</div>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp	Thu May  8 19:44:00 2008
@@ -1089,10 +1089,11 @@
                 }
             %>
         </table>
+
         <%
             }
         %>
-
+       <a href="/wso2registry/system/associationTree"><img src="/wso2registry/admin/images/icon-associationTree.jpg" alt="Association Tree" border="0" /></a>
     </div>
 
 </div>



More information about the Registry-dev mailing list