Author: chathura
Date: Tue Jan 22 21:19:09 2008
New Revision: 12729
Log:
Added comment path as a field in the comment objects returned from Registry API.
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/CommentsDAO.java
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/mediatypes/builtin/DefaultMediaTypeHandler.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
(original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
Tue Jan 22 21:19:09 2008
@@ -23,10 +23,20 @@
public class Comment {
+ /**
+ * Path of the comment. Each comment has a path in the form
+ * /projects/esb/config.xml;comments:12
+ */
+ private String commentPath;
+
private String text;
private String user;
private Date time;
- private String path;
+
+ /**
+ * Path of the resource on which this comment is made.
+ */
+ private String resourcePath;
public Comment() {
}
@@ -59,11 +69,19 @@
this.time = time;
}
- public String getPath() {
- return path;
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public String getCommentPath() {
+ return commentPath;
}
- public void setPath(String path) {
- this.path = path;
+ public void setCommentPath(String commentPath) {
+ this.commentPath = commentPath;
}
}
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
Tue Jan 22 21:19:09 2008
@@ -729,7 +729,7 @@
feed.setTitle("comments for the resource " + path);
for (Comment comment : comments) {
Entry entry = abdera.getFactory().newEntry();
- entry.addLink(comment.getPath(), "path");
+ entry.addLink(comment.getResourcePath(), "path");
entry.setId("http://wso2.org/jdbcregistry/atom/comment");
entry.addAuthor(comment.getUser());
entry.setUpdated(comment.getTime());
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
Tue Jan 22 21:19:09 2008
@@ -463,7 +463,7 @@
Comment comment = new Comment();
comment.setTime(entry.getUpdated());
if (entry.getLink("path") != null) {
-
comment.setPath(entry.getLink("path").getHref().toString());
+
comment.setResourcePath(entry.getLink("path").getHref().toString());
}
comment.setText(entry.getContent());
comment.setUser(entry.getAuthor().getName());
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/CommentsDAO.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/CommentsDAO.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/CommentsDAO.java
Tue Jan 22 21:19:09 2008
@@ -71,7 +71,7 @@
public Comment[] getComments(String path, Connection conn) throws
SQLException {
String sql =
- "SELECT C.COMMENT_TEXT, C.USER_ID, C.COMMENTED_TIME FROM
COMMENTS C, ARTIFACTS A WHERE A.PATH=? AND A.AID=C.AID";
+ "SELECT C.CM_ID, C.COMMENT_TEXT, C.USER_ID, C.COMMENTED_TIME
FROM COMMENTS C, ARTIFACTS A WHERE A.PATH=? AND A.AID=C.AID";
PreparedStatement s = conn.prepareStatement(sql);
s.setString(1, path);
@@ -83,7 +83,10 @@
comment.setText(results.getString(DatabaseConstants.COMMENT_TEXT_FIELD));
comment.setUser(results.getString(DatabaseConstants.COMMENTED_USER_ID_FIELD));
comment.setTime(results.getTimestamp(DatabaseConstants.COMMENTED_TIME_FIELD));
- comment.setPath(path);
+ comment.setResourcePath(path);
+ String commentPath = path + ";comments:" +
+ results.getInt(DatabaseConstants.COMMENT_ID_FIELD);
+ comment.setCommentPath(commentPath);
commentList.add(comment);
}
@@ -101,7 +104,7 @@
public Comment getComment(long commentID, Connection conn) throws
SQLException {
- String sql = "SELECT * FROM COMMENTS WHERE CM_ID=?";
+ String sql = "SELECT C.CM_ID, C.COMMENT_TEXT, C.USER_ID,
C.COMMENTED_TIME, A.PATH FROM COMMENTS C, ARTIFACTS A WHERE C.CM_ID=? AND
C.AID=A.AID";
PreparedStatement s = conn.prepareStatement(sql);
s.setLong(1, commentID);
@@ -109,11 +112,16 @@
ResultSet result = s.executeQuery();
if (result.next()) {
+ String resourcePath =
result.getString(DatabaseConstants.PATH_FIELD);
+ String commentPath = resourcePath + ";comments:" +
+ result.getInt(DatabaseConstants.COMMENT_ID_FIELD);
+
Comment comment = new Comment();
comment.setText(result.getString(DatabaseConstants.COMMENT_TEXT_FIELD));
comment.setUser(result.getString(DatabaseConstants.COMMENTED_USER_ID_FIELD));
comment.setTime(result.getTimestamp(DatabaseConstants.COMMENTED_TIME_FIELD));
-
+ comment.setResourcePath(resourcePath);
+ comment.setCommentPath(commentPath);
return comment;
}
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
Tue Jan 22 21:19:09 2008
@@ -650,7 +650,7 @@
markDeleted(resourcePath, conn);
deleteResource(resource, conn);
//prepareToDelete(resource.getId(), conn);
- //resourceDAO.delete(resource.getPath(), conn);
+ //resourceDAO.delete(resource.getResourcePath(), conn);
} catch (SQLException e) {
throw new RegistryException(e.getMessage());
}
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/DefaultMediaTypeHandler.java
Tue Jan 22 21:19:09 2008
@@ -253,7 +253,7 @@
resourceDAO.markDeleted(path, conn);
resourceDAO.deleteResource(resource, conn);
//prepareToDelete(resource.getId(), conn);
- //resourceDAO.delete(resource.getPath(), conn);
+ //resourceDAO.delete(resource.getResourcePath(), conn);
}
} else {
String msg = Messages.getMessage("delete.null.resource", path);
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
==============================================================================
---
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
(original)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
Tue Jan 22 21:19:09 2008
@@ -34,7 +34,7 @@
try {
Comment c1 = new Comment();
- c1.setPath("/d1/r3");
+ c1.setResourcePath("/d1/r3");
c1.setText("This is default comment");
c1.setUser("admin");
@@ -62,7 +62,7 @@
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
//break;
@@ -71,7 +71,7 @@
if (comment.getText().equals(comment2)) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
//break;
@@ -80,7 +80,7 @@
if (comment.getText().equals("This is default comment")) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
//break;
@@ -123,7 +123,6 @@
}
-
public void testAddCommentToCollection() {
try {
@@ -141,9 +140,8 @@
String comment1 = "this is qa comment 1 for collection d12";
String comment2 = "this is qa comment 2 for collection d12";
-
Comment c1 = new Comment();
- c1.setPath("/d11/d12");
+ c1.setResourcePath("/d11/d12");
c1.setText("This is default comment for d12");
c1.setUser("admin");
@@ -170,17 +168,18 @@
if (comment.getText().equals(comment1)) {
commentFound = true;
- System.out.println(comment.getText());
- System.out.println(comment.getPath());
- System.out.println(comment.getUser());
- System.out.println(comment.getTime());
- //break;
- }
+
+ System.out.println(comment.getText());
+ System.out.println(comment.getResourcePath());
+ System.out.println(comment.getUser());
+ System.out.println(comment.getTime());
+ //break;
+ }
if (comment.getText().equals(comment2)) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
//break;
@@ -189,14 +188,13 @@
if (comment.getText().equals(c1.getText())) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
//break;
}
}
-
assertTrue("comment '" + comment1 +
" is not associated with the artifact /d11/d12",
commentFound);
@@ -251,7 +249,7 @@
Comment c1 = new Comment();
- c1.setPath("/");
+ c1.setResourcePath("/");
c1.setText("This is default comment for root");
c1.setUser("admin");
@@ -279,7 +277,7 @@
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
System.out.println("\n");
@@ -289,7 +287,7 @@
if (comment.getText().equals(comment2)) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
System.out.println("\n");
@@ -299,7 +297,7 @@
if (comment.getText().equals(c1.getText())) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
System.out.println("\n");
@@ -307,7 +305,6 @@
}
}
-
assertTrue("comment '" + comment1 +
" is not associated with the artifact /", commentFound);
@@ -356,7 +353,7 @@
}
Comment c1 = new Comment();
- c1.setPath("/c10/c11/r1");
+ c1.setResourcePath("/c10/c11/r1");
c1.setText("This is default comment ");
c1.setUser("admin");
@@ -381,7 +378,7 @@
if (comment.getText().equals(c1.getText())) {
commentFound = true;
System.out.println(comment.getText());
- System.out.println(comment.getPath());
+ System.out.println(comment.getResourcePath());
System.out.println(comment.getUser());
System.out.println(comment.getTime());
System.out.println("\n");
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
==============================================================================
---
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
(original)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
Tue Jan 22 21:19:09 2008
@@ -73,7 +73,7 @@
try {
Comment c1= new Comment();
- c1.setPath("/d1/r3");
+ c1.setResourcePath("/d1/r3");
c1.setText("This is default comment");
c1.setUser("admin1");
@@ -105,7 +105,7 @@
commentFound = true;
assertEquals(comment1,comment.getText());
assertEquals("admin" , comment.getUser());
- assertEquals(comment.getPath() ,"/d1/r3" );
+ assertEquals(comment.getResourcePath() ,"/d1/r3" );
//break;
}
@@ -113,7 +113,7 @@
commentFound = true;
assertEquals(comment2,comment.getText());
assertEquals("admin" , comment.getUser());
- assertEquals(comment.getPath() ,"/d1/r3" );
+ assertEquals(comment.getResourcePath() ,"/d1/r3" );
//break;
}
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java
==============================================================================
---
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java
(original)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/UserTest.java
Tue Jan 22 21:19:09 2008
@@ -49,7 +49,7 @@
// System.out.println("File content:" + new String((byte[])
r1.getContent()));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -110,7 +110,7 @@
// System.out.println("File content:" + new String((byte[])
r1.getContent()));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -147,7 +147,7 @@
// System.out.println("File content:" + (new String((byte[])
r1.getContent())));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -229,7 +229,7 @@
//System.out.println("File content:" + new String(new String((byte[])
r1.getContent())));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -288,7 +288,7 @@
//System.out.println("File content:" + new String(new String((byte[])
r1.getContent())));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -376,7 +376,7 @@
// System.out.println("File content:" + (new String((byte[])
r1_actual.getContent())));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" + r1_actual.getDescription());
// System.out.println("Author Name:" + r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -416,7 +416,7 @@
*/
// System.out.println("File content:" + (new String((byte[])
r1_actual.getContent())));
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("File Desciption:" +
r1_actual.getDescription());
// System.out.println("Author Name:" +
r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -455,7 +455,7 @@
*/
// System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
-// System.out.println("Path:" + r1_actual.getPath());
+// System.out.println("Path:" + r1_actual.getResourcePath());
// System.out.println("Collection Desciption:" +
r1_actual.getDescription());
// System.out.println("Author Name:" +
r1_actual.getAuthorUserName());
// System.out.println("Resource Properties:" +
r1_actual.getProperties());
@@ -490,6 +490,15 @@
assertTrue("Imported file is empty",content);
+<<<<<<< .mine
+ System.out.println("File content:" + new String((byte[])
r1_actual.getContent()));
+ System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
+ System.out.println("Path:" + r1_actual.getResourcePath());
+ System.out.println("File Desciption:" + r1_actual.getDescription());
+ System.out.println("Author Name:" + r1_actual.getAuthorUserName());
+ System.out.println("Resource Properties:" +
r1_actual.getProperties());
+ System.out.println("Resource is Directory:" +
r1_actual.isDirectory());
+=======
System.out.println("File content:" + new String((byte[])
r1_actual.getContent()));
System.out.println("Updated User Name:" +
r1_actual.getLastUpdaterUserName());
System.out.println("Path:" + r1_actual.getPath());
@@ -497,6 +506,7 @@
System.out.println("Author Name:" + r1_actual.getAuthorUserName());
System.out.println("Resource Properties:" + r1_actual.getProperties());
System.out.println("Resource is Directory:" + r1_actual.isDirectory());
+>>>>>>> .r12721
assertEquals("LastUpdatedUser is not
Equal","admin",r1_actual.getLastUpdaterUserName());
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev