[Registry-dev] svn commit r9995 - in
trunk/registry/modules/core/src/main/java/org/wso2/registry:
. client inmemory jdbc jdbc/dao secure
svn at wso2.org
svn at wso2.org
Tue Nov 20 21:59:56 PST 2007
Author: chathura
Date: Tue Nov 20 21:59:46 2007
New Revision: 9995
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.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/TagsDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
Log:
Added a removeTag(..) method to the Registry interface and implemented it in the JDBCRegistry.
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java Tue Nov 20 21:59:46 2007
@@ -117,6 +117,16 @@
*/
Tag[] getTags(String resourcePath) throws RegistryException;
+ /**
+ * Removes a tag done on a resource by a user. This does not remove all the tags with the
+ * given name.
+ *
+ * @param path Resource path tagged with the given tag.
+ * @param tag Name of the tag to be removed.
+ * @param taggedUser User who tagged the resource.
+ */
+ public void removeTag(String path, String tag, String taggedUser) throws RegistryException;
+
////////////////////////////////////////////////////////
// Comments
////////////////////////////////////////////////////////
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/client/RegistryClient.java Tue Nov 20 21:59:46 2007
@@ -121,4 +121,8 @@
throws RegistryException {
return new LogEntry[0]; //To change body of implemented methods use File | Settings | File Templates.
}
+
+ public void removeTag(String path, String tag, String taggedUser) throws RegistryException {
+ //To change body of implemented methods use File | Settings | File Templates.
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java Tue Nov 20 21:59:46 2007
@@ -215,6 +215,11 @@
return tagManager.getTags(resourcePath);
}
+ public void removeTag(String path, String tag, String taggedUser) throws RegistryException {
+ throw new UnsupportedOperationException(
+ "Removing tags is not supported in the hashmap based registry.");
+ }
+
public synchronized void addComment(String resourcePath, Comment comment) throws RegistryException {
commentManager.addComment(resourcePath, comment);
}
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 Tue Nov 20 21:59:46 2007
@@ -484,6 +484,34 @@
return tags;
}
+ public void removeTag(String path, String tag, String taggedUser) throws RegistryException {
+
+ path = preparePath(path);
+
+ Connection conn = connectionFactory.getConnection();
+
+ try {
+ conn.setAutoCommit(false);
+
+ tagsDAO.removeTag(path, tag, taggedUser, conn);
+
+ conn.commit();
+
+ } catch (SQLException e) {
+
+ try {
+ conn.rollback();
+ } catch (SQLException e1) {
+ e1.printStackTrace();
+ }
+
+ } finally {
+ try {
+ conn.close();
+ } catch (SQLException ignore) {}
+ }
+ }
+
////////////////////////////////////////////////////////
// Comments
////////////////////////////////////////////////////////
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/TagsDAO.java Tue Nov 20 21:59:46 2007
@@ -75,6 +75,22 @@
s.executeUpdate();
}
+ public void removeTag(String path, String tag, String userName, Connection conn)
+ throws SQLException {
+
+ ResourceDAO resourceDAO = new ResourceDAO();
+ long resourceID = resourceDAO.getArtifactID(path, conn);
+
+ String sql = "DELETE FROM TAGS WHERE AID=? AND TAG_NAME=? AND USER_ID=?";
+
+ PreparedStatement s = conn.prepareStatement(sql);
+ s.setLong(1, resourceID);
+ s.setString(2, tag);
+ s.setString(3, userName);
+
+ s.executeUpdate();
+ }
+
public String[] getPathsWithTag(String tag, Connection conn) throws SQLException {
String sql = "SELECT A.PATH FROM ARTIFACTS A, TAGS TN, TAGS T WHERE T.TAG_NAME=? AND T.TAG_ID=TN.TAG_ID AND TN.AID=A.AID";
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java Tue Nov 20 21:59:46 2007
@@ -244,6 +244,11 @@
return registry.getTags(resourcePath);
}
+ public void removeTag(String path, String tag, String taggedUser) throws RegistryException {
+ User.setCurrentUser(userID);
+ registry.removeTag(path, tag, taggedUser);
+ }
+
public void addComment(String resourcePath, Comment comment) throws RegistryException {
User.setCurrentUser(userID);
registry.addComment(resourcePath, comment);
More information about the Registry-dev
mailing list