Author: chathura
Date: Mon Jan 21 02:54:43 2008
New Revision: 12609

Log:


More improvements to the version UIs.



Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/HSQLDBInitializer.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AjaxRatingAction.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
   trunk/registry/modules/webapps/src/main/webapp/admin/ajax_rating.jsp
   trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
==============================================================================
--- 
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
  Mon Jan 21 02:54:43 2008
@@ -603,6 +603,7 @@
     public Tag[] getTags(String resourcePath) throws RegistryException {
 
         resourcePath = preparePath(resourcePath);
+        resourcePath = getCurrentPath(resourcePath);
 
         Connection conn = getConnection();
 
@@ -756,6 +757,7 @@
     public Comment[] getComments(String resourcePath) throws RegistryException 
{
 
         resourcePath = preparePath(resourcePath);
+        resourcePath = getCurrentPath(resourcePath);
 
         Connection conn = getConnection();
 
@@ -859,6 +861,7 @@
     public float getAverageRating(String resourcePath) throws 
RegistryException {
 
         resourcePath = preparePath(resourcePath);
+        resourcePath = getCurrentPath(resourcePath);
 
         Connection conn = getConnection();
 
@@ -886,6 +889,7 @@
     public int getRating(String path, String userName) throws 
RegistryException {
 
         path = preparePath(path);
+        path = getCurrentPath(path);
 
         Connection conn = getConnection();
 
@@ -997,6 +1001,17 @@
 
     }
 
+    private String getCurrentPath(String resourcePath) {
+        String currentPath = resourcePath;
+        if (resourcePath.indexOf("?") > 0) {
+            currentPath = resourcePath.split("\\?")[0];
+        } else if (resourcePath.indexOf(";")>0) {
+            currentPath = resourcePath.split("\\;")[0];
+        }
+
+        return currentPath;
+    }
+
     private String preparePath(String rawPath) {
 
         String path = rawPath;

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/HSQLDBInitializer.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/HSQLDBInitializer.java
   (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/HSQLDBInitializer.java
   Mon Jan 21 02:54:43 2008
@@ -20,7 +20,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.RegistryException;
 import org.wso2.usermanager.UserManagerException;
-import org.wso2.usermanager.readwrite.DefaultDatabaseUtil;
+import org.wso2.usermanager.readwrite.util.DefaultDatabaseUtil;
 
 import javax.sql.DataSource;
 import java.sql.Connection;

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AjaxRatingAction.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AjaxRatingAction.java
    (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AjaxRatingAction.java
    Mon Jan 21 02:54:43 2008
@@ -30,6 +30,8 @@
     private String[] userStars = new String[5];
     private String[] averageStars = new String[5];
 
+    private boolean versionView = false;
+
     public void execute(HttpServletRequest request) throws RegistryException {
 
         setRequest(request);
@@ -91,6 +93,13 @@
                 }
             }
         }
+
+        String[] q = resourcePath.split("\\?");
+        if (q.length == 2) {
+            if (q[1].startsWith("v=")) {
+                versionView = true;
+            }
+        }
     }
 
     public String getResourcePath() {
@@ -132,4 +141,8 @@
     public void setAverageStars(String[] averageStars) {
         this.averageStars = averageStars;
     }
+
+    public boolean isVersionView() {
+        return versionView;
+    }
 }

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceDetailsAction.java
==============================================================================
--- 
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
       Mon Jan 21 02:54:43 2008
@@ -21,7 +21,6 @@
 import org.wso2.registry.secure.SecureRegistry;
 import org.wso2.registry.web.actions.utils.Permission;
 import org.wso2.registry.web.actions.utils.ResourcePath;
-import org.wso2.registry.web.actions.utils.VersionPath;
 import org.wso2.usermanager.Realm;
 import org.wso2.usermanager.UserManagerException;
 import org.wso2.usermanager.UserManagerConstants;
@@ -46,6 +45,7 @@
     private boolean deleteAllowed;
     private boolean authorizeAllowed;
     private Properties properties;
+    private boolean versionView;
 
     private List tags = new ArrayList();
     private List comments = new ArrayList();
@@ -107,7 +107,24 @@
             String[] parts = 
preparedPath.split(RegistryConstants.PATH_SEPARATOR);
             for (int i = 0; i < parts.length; i++) {
                 ResourcePath resourcePath = new ResourcePath();
-                resourcePath.setNavigateName(parts[i]);
+
+                if (i == parts.length - 1) {
+                    String[] q = parts[i].split("\\?");
+                    if (q.length == 2) {
+                        if (q[1].startsWith("v=")) {
+                            String versionNumber = 
q[1].substring("v=".length());
+                            String navName = q[0] + " (version " + 
versionNumber + ")";
+                            resourcePath.setNavigateName(navName);
+                            this.versionView = true;
+                        } else {
+                            resourcePath.setNavigateName(parts[i]);
+                        }
+                    } else {
+                        resourcePath.setNavigateName(parts[i]);
+                    }
+                } else {
+                    resourcePath.setNavigateName(parts[i]);
+                }
 
                 String tempPath = "";
                 for (int j = 0; j < i + 1; j++) {
@@ -210,15 +227,22 @@
                 roleNames.add(rolesArray[i]);
             }
 
-            if (UserUtil.isPutAllowed(getUserName(), path, request)) {
+            String authorizationPath = path;
+            if (path.indexOf("?") > 0) {
+                authorizationPath = path.split("\\?")[0];
+            } else if (path.indexOf(";")>0) {
+                authorizationPath = path.split("\\;")[0];
+            }
+
+            if (UserUtil.isPutAllowed(getUserName(), authorizationPath, 
request)) {
                 putAllowed = true;
             }
 
-            if (UserUtil.isDeleteAllowed(getUserName(), path, request)) {
+            if (UserUtil.isDeleteAllowed(getUserName(), authorizationPath, 
request)) {
                 deleteAllowed = true;
             }
 
-            if (UserUtil.isAuthorizeAllowed(getUserName(), path, request)) {
+            if (UserUtil.isAuthorizeAllowed(getUserName(), authorizationPath, 
request)) {
                 authorizeAllowed = true;
             }
 
@@ -637,4 +661,8 @@
     public void setNavigatablePaths(List navigatablePaths) {
         this.navigatablePaths = navigatablePaths;
     }
+
+    public boolean isVersionView() {
+        return versionView;
+    }
 }

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
  (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/utils/ResourceData.java
  Mon Jan 21 02:54:43 2008
@@ -51,12 +51,13 @@
     }
 
     public void setName(String name) {
-
+        this.name = name;
         String[] q = name.split("\\?");
         if (q.length == 2) {
             if (q[1].startsWith("v=")) {
-                String versionNumber = q[1].substring("v=".length());
-                name = q[0] + " (version " + versionNumber + ")";
+                //String versionNumber = q[1].substring("v=".length());
+                //name = q[0] + " (version " + versionNumber + ")";
+                name = q[0];
             }
         }
 

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/ajax_rating.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax_rating.jsp        
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax_rating.jsp        
Mon Jan 21 02:54:43 2008
@@ -20,54 +20,76 @@
 
 
 <table cellpadding="0" cellspacing="0" border="0" class="simple-data-table">
-<% if (ajaxRatingAction.isLoggedIn()) { %>
-<tr>
-       <th valign="top" style="width:140px;">User Rating:</th>
-       <td>
-               <div id="ratingDivUser">
-                   <span initialState="<%=userStars[0]%> <%=userStars[1]%> 
<%=userStars[2]%> <%=userStars[3]%> <%=userStars[4]%>" />
-               
-                   <img src="/wso2registry/admin/images/r<%=userStars[0]%>.gif"
-                        onclick="setRating(1)"
-                        onmouseover="previewRating('ratingDivUser', 1)"
-                        onmouseout="clearPreview('ratingDivUser')" />
-                   <img src="/wso2registry/admin/images/r<%=userStars[1]%>.gif"
-                        onclick="setRating(2)"
-                        onmouseover="previewRating('ratingDivUser', 2)"
-                        onmouseout="clearPreview('ratingDivUser')" />
-                   <img src="/wso2registry/admin/images/r<%=userStars[2]%>.gif"
-                        onclick="setRating(3)"
-                        onmouseover="previewRating('ratingDivUser', 3)"
-                        onmouseout="clearPreview('ratingDivUser')" />
-                   <img src="/wso2registry/admin/images/r<%=userStars[3]%>.gif"
-                        onclick="setRating(4)"
-                        onmouseover="previewRating('ratingDivUser', 4)"
-                        onmouseout="clearPreview('ratingDivUser')" />
-                   <img src="/wso2registry/admin/images/r<%=userStars[4]%>.gif"
-                        onclick="setRating(5)"
-                        onmouseover="previewRating('ratingDivUser', 5)"
-                        onmouseout="clearPreview('ratingDivUser')" />
-               </div>
-       </td>
-       <th></th>
-       <td></td>
-</tr>
-<% } %>    
-<tr>
-       <th valign="top" style="width:140px;">Average Rating:</th>
-       <td>
-               <div id="ratingDivAvg">
-
-                   <img 
src="/wso2registry/admin/images/r<%=averageStars[0]%>.gif"  />
-                   <img 
src="/wso2registry/admin/images/r<%=averageStars[1]%>.gif"  />
-                   <img 
src="/wso2registry/admin/images/r<%=averageStars[2]%>.gif"  />
-                   <img 
src="/wso2registry/admin/images/r<%=averageStars[3]%>.gif"  />
-                   <img 
src="/wso2registry/admin/images/r<%=averageStars[4]%>.gif"  />
-                   <br/>
-               
-               </div>
-       </td>
-       <td>(<%=averageRating%>)</td>
-       <td></td>
-</tr>
+    <%
+        if (ajaxRatingAction.isLoggedIn()) {
+            if (ajaxRatingAction.isVersionView()) {
+    %>
+
+    <tr>
+        <th valign="top" style="width:140px;">User Rating:</th>
+        <td>
+            <div>
+                <img src="/wso2registry/admin/images/r<%=userStars[0]%>.gif"/>
+                <img src="/wso2registry/admin/images/r<%=userStars[1]%>.gif"/>
+                <img src="/wso2registry/admin/images/r<%=userStars[2]%>.gif"/>
+                <img src="/wso2registry/admin/images/r<%=userStars[3]%>.gif"/>
+                <img src="/wso2registry/admin/images/r<%=userStars[4]%>.gif"/>
+            </div>
+        </td>
+        <th></th>
+        <td></td>
+    </tr>
+
+    <%
+    } else {
+    %>
+    <tr>
+        <th valign="top" style="width:140px;">User Rating:</th>
+        <td>
+            <div id="ratingDivUser">
+                <span initialState="<%=userStars[0]%> <%=userStars[1]%> 
<%=userStars[2]%> <%=userStars[3]%> <%=userStars[4]%>" />
+
+                <img src="/wso2registry/admin/images/r<%=userStars[0]%>.gif"
+                     onclick="setRating(1)"
+                     onmouseover="previewRating('ratingDivUser', 1)"
+                     onmouseout="clearPreview('ratingDivUser')" />
+                <img src="/wso2registry/admin/images/r<%=userStars[1]%>.gif"
+                     onclick="setRating(2)"
+                     onmouseover="previewRating('ratingDivUser', 2)"
+                     onmouseout="clearPreview('ratingDivUser')" />
+                <img src="/wso2registry/admin/images/r<%=userStars[2]%>.gif"
+                     onclick="setRating(3)"
+                     onmouseover="previewRating('ratingDivUser', 3)"
+                     onmouseout="clearPreview('ratingDivUser')" />
+                <img src="/wso2registry/admin/images/r<%=userStars[3]%>.gif"
+                     onclick="setRating(4)"
+                     onmouseover="previewRating('ratingDivUser', 4)"
+                     onmouseout="clearPreview('ratingDivUser')" />
+                <img src="/wso2registry/admin/images/r<%=userStars[4]%>.gif"
+                     onclick="setRating(5)"
+                     onmouseover="previewRating('ratingDivUser', 5)"
+                     onmouseout="clearPreview('ratingDivUser')" />
+            </div>
+        </td>
+        <th></th>
+        <td></td>
+    </tr>
+    <% } } %>
+    <tr>
+        <th valign="top" style="width:140px;">Average Rating:</th>
+        <td>
+            <div id="ratingDivAvg">
+
+                <img 
src="/wso2registry/admin/images/r<%=averageStars[0]%>.gif"  />
+                <img 
src="/wso2registry/admin/images/r<%=averageStars[1]%>.gif"  />
+                <img 
src="/wso2registry/admin/images/r<%=averageStars[2]%>.gif"  />
+                <img 
src="/wso2registry/admin/images/r<%=averageStars[3]%>.gif"  />
+                <img 
src="/wso2registry/admin/images/r<%=averageStars[4]%>.gif"  />
+                <br/>
+
+            </div>
+        </td>
+        <td>(<%=averageRating%>)</td>
+        <td></td>
+    </tr>
 </table>
\ 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 
Mon Jan 21 02:54:43 2008
@@ -99,7 +99,7 @@
     <table cellpadding="0" cellspacing="0" border="0" 
class="simple-data-table">
         <tr><th style="width:140px;">Created:</th><td 
style="width:170px;"><%=details.getCreatedOn().toString()%></td><th>Author:</th><td><%=details.getAuthor()%></td></tr>
         <tr><th>Last 
Updated:</th><td><%=details.getLastModified().toString()%></td><th>By:</th><td><%=details.getLastUpdater()%></td></tr>
-        <tr><th>Versions</th><td colspan="3"><a 
href="/wso2registry/versions<%=details.getPath()%>">View versions</a></td> </tr>
+        <% if (!details.isVersionView()) { %><tr><th>Versions</th><td 
colspan="3"><a href="/wso2registry/versions<%=details.getPath()%>">View 
versions</a></td> </tr><% } %>
     </table>
     <div id="ratingDiv"><img src="/wso2registry/admin/images/ajax-loader.gif" 
/></div>
 
@@ -114,15 +114,18 @@
                        Properties
                </th>
                <td>
-                <% if (details.isPutAllowed()) { %>
-                <a onclick="showHideCommon('propertiesAddDiv');" href="#">
-                               <img border="0" title="Add New Property" 
style="margin-top: -10px;" valign="top" 
src="/wso2registry/admin/images/universal-add.gif"/>
-               </a>
+                <% if (!details.isPutAllowed()) { %>
+                               <span class="helpText">Sorry. You don't have 
permisions to add new properties.</span>
                 <%
-                }
-                else{
+                } else if (details.isVersionView()) {
                 %>
-                    <span class="helpText">Sorry. You don't have permisions to 
add new properties.</span>
+                <span class="helpText">Go to the current version to add or 
edit properties.</span>          
+                <%
+                } else {
+                %>
+                    <a onclick="showHideCommon('propertiesAddDiv');" href="#">
+                    <img border="0" title="Add New Property" 
style="margin-top: -10px;" valign="top" 
src="/wso2registry/admin/images/universal-add.gif"/>
+                    </a>
                 <% } %>
 
                </td>
@@ -176,7 +179,7 @@
                <td><%=name%></td>
                <td><%=value%></td>
                <td>
-            <% if (details.isPutAllowed()) { %>
+            <% if (details.isPutAllowed() && !details.isVersionView()) { %>
             <a href="#" 
onclick="showHideCommon('propViewPanel_<%=i%>');showHideCommon('propEditPanel_<%=i%>')"><img
 title="Edit" border="0" align="top" 
src="/wso2registry/admin/images/icon-edit.gif" /></a>
                        <a href="#" onclick="removeProperty('<%=name%>')" 
style="margin-left:5px;"><img title="Remove" border="0" align="top" 
src="/wso2registry/admin/images/icon-trash.gif" /></a>
                        <% } %>
@@ -198,7 +201,7 @@
         <tr>
             <th style="width:120px; padding-bottom:10px; " 
valign="top">Description:</th>
             <td valign="top" style="width:17px;">
-                <% if (details.isPutAllowed()) { %>
+                <% if (details.isPutAllowed() && !details.isVersionView()) { %>
                 <a href="#editButton" id="editButton" name="editButton" 
title="Edit Description" onclick="processDescription();"><img 
src="/wso2registry/admin/images/icon-edit.gif" name="editButtonImage" 
border="0" align="top" id="mainIconExpanded" /></a>
                 <% } %>
             </td>
@@ -239,7 +242,7 @@
 
                 <table cellpadding="0" cellspacing="0" border="0" 
class="toolBarTable">
                     <tr>
-                        <% if (details.isCollection() && 
details.isPutAllowed()) { %>
+                        <% if (details.isCollection() && 
details.isPutAllowed() && !details.isVersionView()) { %>
                         <td>
                             <a href="#resources" title="Add Resource" 
onclick="showHide('add-resource-div');expandIfNot('entries');"><img 
src="/wso2registry/admin/images/icon-add-resource.gif" border="0" align="top" 
style="margin-top:-5px;"  /></a>
                         </td>
@@ -360,15 +363,6 @@
 </div>
 
 
-
-<% if(collection.getResourceDataList().isEmpty())  { %>
-<div class="helpText">No Entries are defined yet. </div>
-<%  } %>
-
-<% if (details.isCollection() && !details.isPutAllowed()) { %>
-<div class="helpText">Sorry. You don't have permisions to add new resources. 
</div>
-<% } %>
-
 <table cellpadding="0" cellspacing="0" border="0" style="width:100%" 
class="data-table">
     <%
         if(!collection.getResourceDataList().isEmpty())  {
@@ -400,7 +394,7 @@
             (<%=resourceData.getAverageRating()%>)
         </td>
         <td>
-            <% if (resourceData.isDeleteAllowed()) { %><a 
href="/wso2registry/system/deleteResource?resourcePath=<%=resourceData.getResourcePath()%>"
 title="Delete" style="margin-left:5px;"><img 
src="/wso2registry/admin/images/icon-trash.gif" border="0" /></a> <% } %>
+            <% if (resourceData.isDeleteAllowed() && !details.isVersionView()) 
{ %><a 
href="/wso2registry/system/deleteResource?resourcePath=<%=resourceData.getResourcePath()%>"
 title="Delete" style="margin-left:5px;"><img 
src="/wso2registry/admin/images/icon-trash.gif" border="0" /></a> <% } %>
         </td>
 
     </tr>
@@ -439,7 +433,7 @@
 
 <!-- Start Permisions -->
 <!-- Hear comes the box1 table -->
-<% if (details.isAuthorizeAllowed()) { %>
+<% if (details.isAuthorizeAllowed() && !details.isVersionView()) { %>
 <div class="box1-head">
     <table cellspacing="0" cellpadding="0" border="0" style="width:100%">
         <tr>
@@ -512,7 +506,12 @@
         <% } %>
     </div>
 
-    <% if (details.isLoggedIn()) { %>
+    <% if (!details.isLoggedIn()) { %>
+        Sign in to add tags
+    <% } else if (details.isVersionView()) { %>
+        Go to the current version to add tags
+    <% } else { %>
+
     <table cellpadding="0" cellspacing="0" border="0" style="width:100%" 
class="form-table">
         <tr>
             <td>
@@ -529,8 +528,6 @@
             </td>
         </tr>
     </table>
-    <% } else { %>
-    Sign in to add tags
     <% } %>
 
 </div>
@@ -551,7 +548,7 @@
             <td align="right" valign="top">
                 <table cellpadding="0" cellspacing="0" border="0" 
class="toolBarTable">
                     <tr>
-                        <td><% if (details.isLoggedIn()) { %><a href="#" 
onclick="showHideCommon('add-comment-div');expandIfNot('comments');"><img 
src="/wso2registry/admin/images/universal-add.gif" border="0" valign="top" 
style="margin-top:-10px;_margin-top:5px;" title="Add New Comment" /></a><% } 
%></td>
+                        <td><% if (details.isLoggedIn() && 
!details.isVersionView()) { %><a href="#" 
onclick="showHideCommon('add-comment-div');expandIfNot('comments');"><img 
src="/wso2registry/admin/images/universal-add.gif" border="0" valign="top" 
style="margin-top:-10px;_margin-top:5px;" title="Add New Comment" /></a><% } 
%></td>
                         <td>
                             <a href="#" 
onclick="showHideCommon('commentsIconExpanded');showHideCommon('commentsIconMinimized');showHideCommon('commentsExpanded');showHideCommon('commentsMinimized');">
                                 <img 
src="/wso2registry/admin/images/icon-expanded.gif" border="0" align="top" 
id="commentsIconExpanded" style="margin-top:-4px;" />

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

Reply via email to