[Registry-dev] svn commit r16664 - in trunk/registry/modules:
core/src/main/java/org/wso2/registry
webapps/src/main/java/org/wso2/registry/web
webapps/src/main/java/org/wso2/registry/web/actions
webapps/src/main/java/org/wso2/registry/web/beans
webapps/src/main/java/org/wso2/registry/web/utils
webapps/src/main/webapp/admin
svn at wso2.org
svn at wso2.org
Wed May 7 23:28:30 PDT 2008
Author: chathura
Date: Wed May 7 23:28:13 2008
New Revision: 16664
Log:
Implementing versioning support in the UI.
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.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/beans/VersionsBean.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java
trunk/registry/modules/webapps/src/main/webapp/admin/registry-resources.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/versions.jsp
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java Wed May 7 23:28:13 2008
@@ -258,15 +258,17 @@
public void setMatchingSnapshotID(long matchingSnapshotID) {
this.matchingSnapshotID = matchingSnapshotID;
+
+ if (matchingSnapshotID == -1) {
+ permanentPath = null;
+ } else {
+ permanentPath =
+ path + RegistryConstants.URL_SEPARATOR + "version=" + matchingSnapshotID;
+ }
}
public String getPermanentPath() {
- if (permanentPath == null) {
- permanentPath = path + RegistryConstants.URL_SEPARATOR +
- "version=" + matchingSnapshotID;
- }
-
return permanentPath;
}
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 Wed May 7 23:28:13 2008
@@ -457,10 +457,10 @@
// if user is browsing an old version of the resource, we append it to the path, so that
// the backend userRegistry gives the details of the version
- String qPart = request.getQueryString();
- if (qPart != null && qPart.startsWith("v")) {
- path = path + "?" + qPart;
- }
+ //String qPart = request.getQueryString();
+ //if (qPart != null && qPart.startsWith("v")) {
+ // path = path + "?" + qPart;
+ //}
VersionsBean versionsBean ;
try {
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 Wed May 7 23:28:13 2008
@@ -127,10 +127,10 @@
ResourcePath resourcePath = new ResourcePath();
if (i == parts.length - 1) {
- String[] q = parts[i].split("\\?");
+ String[] q = parts[i].split(RegistryConstants.URL_SEPARATOR);
if (q.length == 2) {
- if (q[1].startsWith("v=")) {
- String versionNumber = q[1].substring("v=".length());
+ if (q[1].startsWith("version=")) {
+ String versionNumber = q[1].substring("version=".length());
String navName = q[0] + " (version " + versionNumber + ")";
resourcePath.setNavigateName(navName);
this.versionView = true;
@@ -187,10 +187,7 @@
Resource resource = registry.get(path);
if (!versionView) {
- String[] versionPaths = registry.getVersions(path);
- if (versionPaths.length > 0) {
- permalink = versionPaths[0];
- }
+ permalink = resource.getPermanentPath();
} else {
permalink = path;
}
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/beans/VersionsBean.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/beans/VersionsBean.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/beans/VersionsBean.java Wed May 7 23:28:13 2008
@@ -24,6 +24,7 @@
public class VersionsBean {
private String resourcePath = "";
+ private String permalink;
private List versionPaths = new ArrayList();
public String getResourcePath() {
@@ -34,6 +35,14 @@
this.resourcePath = resourcePath;
}
+ public String getPermalink() {
+ return permalink;
+ }
+
+ public void setPermalink(String permalink) {
+ this.permalink = permalink;
+ }
+
public List getVersionPaths() {
return versionPaths;
}
Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java (original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/ResourcesUtil.java Wed May 7 23:28:13 2008
@@ -57,6 +57,9 @@
VersionsBean versionsBean = new VersionsBean();
versionsBean.setResourcePath(path);
+ Resource currentResource = userRegistry.get(path);
+ versionsBean.setPermalink(currentResource.getPermanentPath());
+
String[] versions = userRegistry.getVersions(path);
for (String version : versions) {
VersionPath versionPath = new VersionPath();
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 Wed May 7 23:28:13 2008
@@ -197,13 +197,16 @@
<tr>
<th valign="top">Permalink:</th>
<td colspan="3">
- <% if (!details.isVersionView()) { %>
+ <% if (details.getPermalink() == null) { %>
+ No versions are created for this resource.
+ <% } else {
+ if (!details.isVersionView()) { %>
<a href="/wso2registry/web<%=details.getPermalink()%>"><%=details.getServerBaseURL()%>
/wso2registry/web<%=details.getPermalink()%>
</a>
<% } else { %>
/wso2registry/web<%=details.getPermalink()%>
- <% } %>
+ <% } } %>
</td>
</tr>
<% } else { %>
Modified: trunk/registry/modules/webapps/src/main/webapp/admin/versions.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/versions.jsp (original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/versions.jsp Wed May 7 23:28:13 2008
@@ -28,75 +28,80 @@
<div class="page-sizer">
<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">
-
- <h1 class="headding-resource">Versions of <%=versionBean.getResourcePath()%></h1>
-
-
- <div class="box1-mid">
- <!-- all the content goes here -->
-
-
- <table cellpadding="0" cellspacing="0" border="0" class="data-table" style="width:650px;">
- <tr>
- <th>Version </th>
- <th>Last Modified</th>
- <th>By</th>
- <th style="width:150px;"></th>
- </tr>
- <%
- List versionList = versionBean.getVersionPaths();
-
- if (versionList.size() > 0) {
- VersionPath currentVersion = (VersionPath) versionList.get(0);
- %>
-
- <tr>
- <td><%=currentVersion.getVersionNumber()%> (Current version)</td>
- <td><%=CommonUtil.formatDate(currentVersion.getUpdatedOn())%></td>
- <td><%=currentVersion.getUpdater()%></td>
- <td>
- <a href="/wso2registry/web<%=currentVersion.getActiveResourcePath()%>" title="Details">Details <img src="/wso2registry/admin/images/icon-details.jpg" border="0" hspace="3" align="top" /></a>
- </td>
- </tr>
-
-
- <%
- }
-
- for (int i = 1; i < versionList.size(); i++) {
- VersionPath versionPath = (VersionPath) versionList.get(i);
- %>
- <tr>
- <td><%=versionPath.getVersionNumber()%></td>
- <td><%=CommonUtil.formatDate(versionPath.getUpdatedOn())%></td>
- <td><%=versionPath.getUpdater()%></td>
- <td>
- <a href="/wso2registry/web<%=versionPath.getCompleteVersionPath()%>" title="Details">Details <img src="/wso2registry/admin/images/icon-details.jpg" border="0" hspace="3" /></a>
- <a href="/wso2registry/system/restore?versionPath=<%=versionPath.getCompleteVersionPath()%>" title="Restore" style="margin-left:5px;">Restore <img src="/wso2registry/admin/images/icon-restore.gif" border="0" /></a>
- </td>
- </tr>
-
-
- <% } %>
- </table>
-
- <!-- End box1-mid div -->
- </div>
-
- </div>
-
-
-</td>
-</tr>
-</table>
+ <!--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">
+
+ <h1 class="headding-resource">Versions of <%=versionBean.getResourcePath()%></h1>
+
+
+ <div class="box1-mid">
+ <!-- all the content goes here -->
+
+
+ <table cellpadding="0" cellspacing="0" border="0" class="data-table" style="width:650px;">
+ <tr>
+ <th>Version </th>
+ <th>Last Modified</th>
+ <th>By</th>
+ <th style="width:150px;"></th>
+ </tr>
+
+ <%
+ List versionList = versionBean.getVersionPaths();
+
+ for (int i = 0; i < versionList.size(); i++) {
+ VersionPath versionPath = (VersionPath) versionList.get(i);
+
+ if (versionBean.getPermalink() != null &&
+ versionBean.getPermalink().equals(
+ versionPath.getCompleteVersionPath())) {
+
+ VersionPath currentVersion = versionPath;
+ %>
+
+ <tr>
+ <td><%=currentVersion.getVersionNumber()%> (Current version)</td>
+ <td><%=CommonUtil.formatDate(currentVersion.getUpdatedOn())%></td>
+ <td><%=currentVersion.getUpdater()%></td>
+ <td>
+ <a href="/wso2registry/web<%=currentVersion.getActiveResourcePath()%>" title="Details">Details <img src="/wso2registry/admin/images/icon-details.jpg" border="0" hspace="3" align="top" /></a>
+ </td>
+ </tr>
+
+ <% } else { %>
+
+ <tr>
+ <td><%=versionPath.getVersionNumber()%></td>
+ <td><%=CommonUtil.formatDate(versionPath.getUpdatedOn())%></td>
+ <td><%=versionPath.getUpdater()%></td>
+ <td>
+ <a href="/wso2registry/web<%=versionPath.getCompleteVersionPath()%>" title="Details">Details <img src="/wso2registry/admin/images/icon-details.jpg" border="0" hspace="3" /></a>
+ <a href="/wso2registry/system/restore?versionPath=<%=versionPath.getCompleteVersionPath()%>" title="Restore" style="margin-left:5px;">Restore <img src="/wso2registry/admin/images/icon-restore.gif" border="0" /></a>
+ </td>
+ </tr>
+
+
+ <%
+ }
+ }
+ %>
+ </table>
+
+ <!-- End box1-mid div -->
+ </div>
+
+ </div>
+
+
+ </td>
+ </tr>
+ </table>
<!-- START footer content -->
<jsp:include page="footer.jsp" />
More information about the Registry-dev
mailing list