Author: chathura
Date: Fri Jan 25 05:40:56 2008
New Revision: 12911
Log:
Added activity log messages for restore and rename.
Fixed a db connection handling issue of resource rename.
Changed abdera version to snapshot.
Modified:
trunk/registry/modules/core/pom.xml
trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.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/dao/VersionedResourceDAO.java
trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
trunk/registry/pom.xml
Modified: trunk/registry/modules/core/pom.xml
==============================================================================
--- trunk/registry/modules/core/pom.xml (original)
+++ trunk/registry/modules/core/pom.xml Fri Jan 25 05:40:56 2008
@@ -105,6 +105,10 @@
<artifactId>abdera-server</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-i18n</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</dependency>
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java
(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java
Fri Jan 25 05:40:56 2008
@@ -29,6 +29,8 @@
public static final int TAG = 3;
public static final int RATING = 4;
public static final int DELETE_RESOURCE = 5;
+ public static final int RESTORE = 6;
+ public static final int RENAME = 7;
/** Path of the resource on which the action is performed. */
private String resourcePath;
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
Fri Jan 25 05:40:56 2008
@@ -140,8 +140,8 @@
resourceDAO.add(root, conn);
AuthorizationUtil.setDefaultAuthorizations(defaultRealm,
-
RegistryConstants.ROOT_PATH,
-
RegistryConstants.SYSTEM_USER);
+ RegistryConstants.ROOT_PATH,
+ RegistryConstants.SYSTEM_USER);
root =
resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
root.setLastUpdaterUserName(RegistryConstants.SYSTEM_USER);
@@ -243,7 +243,7 @@
throws RegistryException {
suggestedPath = preparePath(suggestedPath);
- String actualPath = null;
+ String actualPath;
actualPath = urlHandlerManager.put(suggestedPath, resource);
@@ -327,12 +327,49 @@
public String rename(String currentPath, String newPath) throws
RegistryException {
- if (resourceExists(currentPath)) {
- resourceDAO.renameResource(currentPath,
- newPath,
- getConnection(),
- User.getCurrentUser(),
- defaultRealm);
+
+ if (currentPath == null || currentPath.length() == 0 ||
+ newPath == null || newPath.length() == 0) {
+ String msg = "Invlaid resource paths. Current path: " +
+ currentPath + ". New path: " + newPath;
+ throw new RegistryException(msg);
+ }
+
+ String userID = User.getCurrentUser();
+
+ Connection conn = getConnection();
+
+ if (resourceExists(currentPath) && !currentPath.equals(newPath)) {
+
+ if (!resourceExists(newPath)) {
+
+ try {
+
+ long resourceID = resourceDAO.getResourceID(currentPath,
conn);
+
+ resourceDAO.renameResource(currentPath,
+ newPath,
+ getConnection(),
+ User.getCurrentUser(),
+ defaultRealm);
+
+ logsDAO.addLog(resourceID, userID, LogEntry.RENAME,
currentPath, conn);
+
+ } catch (SQLException e) {
+
+ String msg = "Failed to rename the resource: " +
+ currentPath + " to the name: " + newPath;
+ log.error(msg, e);
+ throw new RegistryException(msg, e);
+
+ } finally {
+ if (conn != null) {
+ try {
+ conn.close();
+ } catch (SQLException ignore) {}
+ }
+ }
+ }
return newPath;
} else {
throw new ResourceNotFoundException(currentPath);
@@ -410,7 +447,7 @@
}
String msg = "Could not get the version paths of the resource " +
- path + ". Caused by: " + e.getMessage();
+ path + ". Caused by: " + e.getMessage();
log.error(msg, e);
throw new RegistryException(msg, e);
@@ -448,6 +485,8 @@
throw new RegistryException(msg);
}
+ String userID = User.getCurrentUser();
+
Connection conn = getConnection();
try {
@@ -456,13 +495,16 @@
long artifactID = resourceDAO.getResourceID(plainPath, conn);
resourceDAO.restore(artifactID, versionNumber, conn);
+
+ logsDAO.addLog(
+ artifactID, userID, LogEntry.RESTORE,
Long.toString(versionNumber), conn);
conn.commit();
} catch (SQLException e) {
String msg = "Could not restore the version " +
- versionPath + ". Caused by: " + e.getMessage();
+ versionPath + ". Caused by: " + e.getMessage();
log.error(msg, e);
try {
@@ -478,7 +520,7 @@
conn.close();
} catch (SQLException ignore) {
log.info("Exception while closing the DB connection in " +
- "restoreVersion method of JDBCRegistry");
+ "restoreVersion method of JDBCRegistry");
}
}
}
@@ -669,7 +711,7 @@
} catch (SQLException e) {
String msg = "Could not remove the tag: " + tag + " from the
resource at path: " +
- path + ".";
+ path + ".";
log.error(msg, e);
try {
@@ -831,13 +873,13 @@
if (ratingsDAO.ratingExist(resource.getId(), userID, conn)) {
ratingsDAO.updateRating(resource.getId(), userID, rating,
conn);
log.info("Updated the rating on the resource " +
- resourcePath + " by user " + userID);
+ resourcePath + " by user " + userID);
} else {
ratingsDAO.addRating(resource.getId(), userID, rating,
conn);
}
logsDAO.addLog(resource.getId(),
- userID, LogEntry.RATING,
Integer.toString(rating), conn);
+ userID, LogEntry.RATING, Integer.toString(rating),
conn);
} else {
String msg = Messages.getMessage("rate.on.null.artfact",
resourcePath);
@@ -919,7 +961,7 @@
} catch (SQLException e) {
String msg = "Could not get the rating of the resource " + path +
- " given by the user " + userName + ". Caused by: " +
e.getMessage();
+ " given by the user " + userName + ". Caused by: " +
e.getMessage();
log.error(msg, e);
throw new RegistryException(msg, e);
@@ -946,9 +988,9 @@
// make the path of the query (e.g. /users/chathura/queries/myquery1 )
String queryPath = RegistryConstants.ROOT_PATH +
RegistryConstants.USERS_COLLECTION_NAME +
- RegistryConstants.PATH_SEPARATOR + userID +
RegistryConstants
+ RegistryConstants.PATH_SEPARATOR + userID + RegistryConstants
.PATH_SEPARATOR +
- RegistryConstants.QUERIES_COLLECTION_NAME +
RegistryConstants
+ RegistryConstants.QUERIES_COLLECTION_NAME + RegistryConstants
.PATH_SEPARATOR + name;
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
Fri Jan 25 05:40:56 2008
@@ -684,8 +684,8 @@
String newPath,
Connection conn,
String userId,
- Realm realm) throws RegistryException {
- try {
+ Realm realm) throws SQLException,
RegistryException {
+
Resource resource = getLatestVersion(oldPath, conn);
String resourcePath = resource.getPath();
long resourceID = resource.getId();
@@ -715,9 +715,6 @@
deleteResource(resource, conn);
//prepareToDelete(resource.getId(), conn);
//resourceDAO.delete(resource.getResourcePath(), conn);
- } catch (SQLException e) {
- throw new RegistryException(e.getMessage());
- }
}
public long addResourceVersion(Resource resource, Connection connection)
Modified:
trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/ajax/entry-list.jsp
Fri Jan 25 05:40:56 2008
@@ -54,8 +54,9 @@
<a
href="/wso2registry/web/<%=resourceData.getRelativePath()%>"
id="resourceView<%=entryNumber%>"><%=resourceData.getName()%></a>
<input type="text" id="resourceEdit<%=entryNumber%>"
style="display:none" value="<%=resourceData.getName()%>" />
| <a
href="/wso2registry/resources<%=resourceData.getResourcePath()%>"
target="_blank" title="Download" ><img
src="/wso2registry/admin/images/icon-download.jpg" border="0" align="top" /></a>
- | <a href="#" title="Edit Resource Name"
onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>');
showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
id="resourceEditButton<%=entryNumber%>"><img
src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top"
id="resourceEditButton" /></a>
+ <% if (resourceData.isDeleteAllowed()) { %>| <a href="#"
title="Edit Resource Name"
onclick="showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>');
showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
id="resourceEditButton<%=entryNumber%>"><img
src="/wso2registry/admin/images/icon-edit.gif" border="0" align="top"
id="resourceEditButton" /></a>
<a href="#" onclick="renameResource('<%=details.getPath()%>',
'<%=resourceData.getResourcePath()%>',
'resourceEdit<%=entryNumber%>');showHideCommon('resourceEdit<%=entryNumber%>');showHideCommon('resourceView<%=entryNumber%>');
showHideCommon('resourceSaveButton<%=entryNumber%>');showHideCommon('resourceEditButton<%=entryNumber%>');"
id="resourceSaveButton<%=entryNumber%>" style="display:none;"><img border="0"
align="top" title="Save" src="/wso2registry/admin/images/save-button.gif"
/></a>
+ <% } %>
</div>
<% } %>
</td>
Modified: trunk/registry/pom.xml
==============================================================================
--- trunk/registry/pom.xml (original)
+++ trunk/registry/pom.xml Fri Jan 25 05:40:56 2008
@@ -235,6 +235,11 @@
<version>${abdera.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.abdera</groupId>
+ <artifactId>abdera-i18n</artifactId>
+ <version>${abdera.version}</version>
+ </dependency>
+ <dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>${httpclient.version}</version>
@@ -379,7 +384,7 @@
<!--<opensymphony.version>2.6.11</opensymphony.version>-->
<hsqldb.version>1.8.0</hsqldb.version>
<!--For Abdera-->
- <abdera.version>0.39</abdera.version>
+ <abdera.version>0.4.0-incubating-SNAPSHOT</abdera.version>
<httpclient.version>3.0.1</httpclient.version>
<axiom.version>1.2.5</axiom.version>
<stax.version>1.0.1</stax.version>
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev