[Registry-dev] svn commit r9499 - in trunk/registry/modules:
core/src/main/java/org/wso2/registry
core/src/main/java/org/wso2/registry/inmemory
core/src/main/java/org/wso2/registry/jdbc
core/src/main/java/org/wso2/registry/jdbc/dao
core/src/main/java/org/wso2/registry/jdbc/mediatypes
core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin
core/src/main/java/org/wso2/registry/jdbc/queries
core/src/main/java/org/wso2/registry/jdbc/urlhandlers
core/src/main/java/org/wso2/registry/secure
core/src/main/java/org/wso2/registry/servlet
core/src/main/java/org/wso2/registry/versions
core/src/main/resources/org/wso2/registry/i18n
core/src/test/java/org/wso2/registry/inmemory
core/src/test/java/org/wso2/registry/jdbc
core/src/test/java/org/wso2/registry/secure webapps/conf
webapps/src/main/java/org/wso2/registry/rest
webapps/src/main/java/org/wso2/registry/web/actions
webapps/src/main/webapp/admin webapps/src/main/webapp/rest
svn at wso2.org
svn at wso2.org
Tue Nov 6 15:54:36 PST 2007
Author: chathura
Date: Tue Nov 6 15:54:07 2007
New Revision: 9499
Added:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java
- copied, changed from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/Artifact.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java
- copied, changed from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ArtifactDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
- copied, changed from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedArtifactDAO.java
Removed:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Artifact.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ArtifactDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedArtifactDAO.java
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImporter.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/DatabaseConstants.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/CommentsDAO.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RatingsDAO.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/jdbc/mediatypes/MediaTypeHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
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/SQLQueryMediaTypeHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SynapseRepositoryMediaTypeHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessor.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/SQLQueryProcessor.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/CommentCollectionURLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/CommentURLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/RatingsCollectionURLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/TagURLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/URLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/URLHandlerManager.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/EditProcessor.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/FileUploadUtil.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/versions/VersionHandler.java
trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties
trunk/registry/modules/core/src/test/java/org/wso2/registry/inmemory/InMemoryRegistryTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/secure/SecureRegistryTest.java
trunk/registry/modules/webapps/conf/web.xml
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/rest/RestUtil.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AddCollectionAction.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/AddResourceAction.java
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/CollectionViewAction.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/SearchCollectionViewAction.java
trunk/registry/modules/webapps/src/main/webapp/admin/comments.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/edit_resource.jsp
trunk/registry/modules/webapps/src/main/webapp/admin/rest.jsp
trunk/registry/modules/webapps/src/main/webapp/rest/index.jsp
Log:
Refactored Artifact to Resource.
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 6 15:54:07 2007
@@ -34,7 +34,7 @@
* @throws RegistryException is thrown if the resource is not in the
* registry
*/
- Artifact get(String path) throws RegistryException;
+ Resource get(String path) throws RegistryException;
/**
* Check whether a resource exist in the given path
@@ -51,10 +51,10 @@
* the new resource.
*
* @param path Path of the new resource
- * @param artifact Resource instance for the new resource
+ * @param resource Resource instance for the new resource
* @throws org.wso2.registry.RegistryException is thrown if the storage exception is encountered.
*/
- void put(String path, Artifact artifact) throws RegistryException;
+ void put(String path, Resource resource) throws RegistryException;
/**
* Deletes the resource in the given path. If the path refers to a directory, all child
@@ -181,7 +181,7 @@
* @return RowSet containing the fields specified in the query.
* @throws RegistryException depends on the implementation.
*/
- Artifact executeQuery (String path, Object[] parameters) throws RegistryException;
+ Resource executeQuery (String path, Object[] parameters) throws RegistryException;
/**
* Returns the logs of the activities occured in the registy.
Copied: trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java (from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/Artifact.java)
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Artifact.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Resource.java Tue Nov 6 15:54:07 2007
@@ -23,7 +23,7 @@
import java.util.Date;
import java.util.Properties;
-public class Artifact {
+public class Resource {
private long id;
private String authorUserName;
@@ -51,7 +51,7 @@
private boolean directory = false;
- public Artifact() {
+ public Resource() {
this.properties = new Properties();
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImporter.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImporter.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImporter.java Tue Nov 6 15:54:07 2007
@@ -91,7 +91,7 @@
private void putDirectory(String rootPath, File directory, String toPath)
throws RegistryException {
- Artifact collection = new Artifact();
+ Resource collection = new Resource();
collection.setDirectory(true);
String targetPath =
@@ -109,12 +109,12 @@
outputStream.write(b);
}
- Artifact artifact = new Artifact();
- artifact.setContent(outputStream.toByteArray());
+ Resource resource = new Resource();
+ resource.setContent(outputStream.toByteArray());
String targetPath =
toPath + file.getAbsolutePath().substring(rootPath.length());
- registry.put(targetPath, artifact);
+ registry.put(targetPath, resource);
} catch (Exception e) {
String msg = "Could not read from the file " + file.getPath();
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 6 15:54:07 2007
@@ -49,20 +49,20 @@
private Map resourceMap = new ResourceMap();
public InMemoryRegistry() {
- Artifact root = new Artifact();
+ Resource root = new Resource();
root.setPath(RegistryConstants.ROOT_PATH);
root.setDirectory(true);
resourceMap.put(RegistryConstants.ROOT_PATH, root);
}
- public Artifact get(String path) throws RegistryException {
+ public Resource get(String path) throws RegistryException {
- Artifact artifact = (Artifact) resourceMap.get(path);
- if (artifact == null) {
+ Resource resource = (Resource) resourceMap.get(path);
+ if (resource == null) {
throw new RegistryException("Requested resource " + path + " does not exist");
}
- return artifact;
+ return resource;
}
public boolean resourceExists(String path) throws RegistryException {
@@ -74,14 +74,14 @@
*
* @param path Path of the resource. e.g. foo/bar/myresource. In this case Directories foo and
* foo/bar should exists in the resourceMap. If they do not exists they will be created.
- * @param artifact Resource to be placed in the given path. It can be a normal resource
+ * @param resource Resource to be placed in the given path. It can be a normal resource
* (resource containing content), a general directory or a special directory (e.g. synapse
* repository)
*/
- public synchronized void put(String path, Artifact artifact) throws RegistryException {
+ public synchronized void put(String path, Resource resource) throws RegistryException {
- artifact.setPath(path);
- artifact.setLastModified(new Date());
+ resource.setPath(path);
+ resource.setLastModified(new Date());
String[] parts = path.split(RegistryConstants.PATH_SEPARATOR);
@@ -93,25 +93,25 @@
// exists create directories for them. If there is a non-directory resource
// corresponding to any of those parts, we can't add the resource.
String currentPath = RegistryConstants.ROOT_PATH;
- Artifact currentDirectory =(Artifact) resourceMap.get(RegistryConstants.ROOT_PATH);
+ Resource currentDirectory =(Resource) resourceMap.get(RegistryConstants.ROOT_PATH);
for (int i = 1; i < parts.length - 1; i++) {
// check if a Directory with current Path is already in the resourceMap
currentPath = (currentPath.equals(RegistryConstants.ROOT_PATH)) ? RegistryConstants.ROOT_PATH +
parts[i] : currentPath + RegistryConstants.PATH_SEPARATOR + parts[i];
- Artifact r = (Artifact) resourceMap.get(currentPath);
+ Resource r = (Resource) resourceMap.get(currentPath);
if (r == null) {
// there is no Directory for the current path. Let's create and add it to the
// resourceMap
- Artifact directoryArtifact = new Artifact();
- directoryArtifact.setPath(currentPath);
- directoryArtifact.setLastModified(new Date());
- directoryArtifact.setDirectory(true);
+ Resource directoryResource = new Resource();
+ directoryResource.setPath(currentPath);
+ directoryResource.setLastModified(new Date());
+ directoryResource.setDirectory(true);
- resourceMap.put(currentPath, directoryArtifact);
+ resourceMap.put(currentPath, directoryResource);
updateArtifact(currentDirectory, currentPath);
- currentDirectory = directoryArtifact;
+ currentDirectory = directoryResource;
} else {
if (r.isDirectory()) {
@@ -124,20 +124,20 @@
}
}
}
- updateArtifact(currentDirectory, artifact.getPath());
+ updateArtifact(currentDirectory, resource.getPath());
// now we have the parent directory for the new resource. add the new resource to
// the resourceMap and make it a child of the parent directory
- resourceMap.put(path, artifact);
+ resourceMap.put(path, resource);
} else {
- Artifact root =(Artifact) resourceMap.get(RegistryConstants.ROOT_PATH);
+ Resource root =(Resource) resourceMap.get(RegistryConstants.ROOT_PATH);
updateArtifact(root, path);
// new resource is a top level resource. just add it to the resourceMap
- resourceMap.put(path, artifact);
+ resourceMap.put(path, resource);
}
}
- private void updateArtifact(Artifact currentDirectory, String currentPath) {
+ private void updateArtifact(Resource currentDirectory, String currentPath) {
if (currentDirectory != null && currentDirectory.isDirectory()) {
String oldPaths[] = (String[]) currentDirectory.getContent();
int count;
@@ -168,24 +168,24 @@
* @param path Path of the resource to be deleted.
*/
public synchronized void delete(String path) throws RegistryException {
- Artifact artifact = (Artifact) resourceMap.get(path);
- if (artifact == null) {
+ Resource resource = (Resource) resourceMap.get(path);
+ if (resource == null) {
String message = Messages.getMessage("resource.delete.error", path);
log.error(message);
throw new RegistryException(message);
}
-// Object o = artifact.getContent();
- if (artifact.isDirectory()) {
+// Object o = resource.getContent();
+ if (resource.isDirectory()) {
// remove all descendent resources
- removeDescendents(artifact);
+ removeDescendents(resource);
// remove the directory
- removeResource(artifact.getPath());
+ removeResource(resource.getPath());
} else {
- removeResource(artifact.getPath());
+ removeResource(resource.getPath());
}
// remove all comments of the deleted resource
@@ -237,7 +237,7 @@
"User level rating are not supported in HashMap based in-memory registry.");
}
- public Artifact executeQuery(String path, Object[] parameters) throws RegistryException {
+ public Resource executeQuery(String path, Object[] parameters) throws RegistryException {
throw new UnsupportedOperationException(
"Custom queries are not supported in HashMap based in-memory registry.");
}
@@ -249,11 +249,11 @@
/**
* Removes descendents (child directories and resources) from the given directory.
*
- * @param artifact Resource object with a CollectionContent
+ * @param resource Resource object with a CollectionContent
*/
- private void removeDescendents(Artifact artifact) {
+ private void removeDescendents(Resource resource) {
- String[] childPaths = (String[]) artifact.getContent();
+ String[] childPaths = (String[]) resource.getContent();
if (childPaths == null) {
return;
}
@@ -261,15 +261,15 @@
for (int i = 0; i < childPaths.length; i++) {
String childPath = childPaths[i];
- Artifact childArtifact = (Artifact) resourceMap.get(childPath);
+ Resource childResource = (Resource) resourceMap.get(childPath);
- if (childArtifact.isDirectory()) {
+ if (childResource.isDirectory()) {
- removeDescendents(childArtifact);
- removeResource(childArtifact.getPath());
+ removeDescendents(childResource);
+ removeResource(childResource.getPath());
} else {
- removeResource(childArtifact.getPath());
+ removeResource(childResource.getPath());
}
}
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/DatabaseConstants.java Tue Nov 6 15:54:07 2007
@@ -25,7 +25,7 @@
public static final String DATASOURCE_NAME = "java:comp/env/jdbc/WSO2RegistryDB";
public static final String HSQL_DRIVER_NAME = "org.hsqldb.jdbcDriver";
- // Field names of Artifact table
+ // Field names of Resource table
public static final String AID_FIELD = "AID";
public static final String PATH_FIELD = "PATH";
public static final String DIRECTORY_FIELD = "DIRECTORY";
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 6 15:54:07 2007
@@ -26,7 +26,7 @@
import org.wso2.registry.jdbc.dao.CommentsDAO;
import org.wso2.registry.jdbc.dao.RatingsDAO;
import org.wso2.registry.jdbc.dao.TagsDAO;
-import org.wso2.registry.jdbc.dao.VersionedArtifactDAO;
+import org.wso2.registry.jdbc.dao.VersionedResourceDAO;
import org.wso2.registry.jdbc.dataobjects.TagDO;
import org.wso2.registry.jdbc.mediatypes.MediaTypeManager;
import org.wso2.registry.jdbc.queries.QueryProcessor;
@@ -54,7 +54,7 @@
private ConnectionFactory connectionFactory = null;
private URLHandlerManager urlHandlerManager;
private MediaTypeManager mediaTypeManager;
- private VersionedArtifactDAO artifactDAO = null;
+ private VersionedResourceDAO resourceDAO = null;
private TagsDAO tagsDAO = null;
private CommentsDAO commentsDAO = null;
private RatingsDAO ratingsDAO = null;
@@ -64,7 +64,7 @@
urlHandlerManager = new URLHandlerManager(connectionFactory);
mediaTypeManager = new MediaTypeManager(connectionFactory, realm);
- this.artifactDAO = new VersionedArtifactDAO();
+ this.resourceDAO = new VersionedResourceDAO();
this.tagsDAO = new TagsDAO();
this.commentsDAO = new CommentsDAO();
this.ratingsDAO = new RatingsDAO();
@@ -75,16 +75,16 @@
try {
conn.setAutoCommit(false);
- Artifact root = artifactDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
+ Resource root = resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
if (root == null) {
- root = new Artifact();
+ root = new Resource();
root.setPath(RegistryConstants.ROOT_PATH);
root.setDirectory(true);
- artifactDAO.add(RegistryConstants.ROOT_PATH, root, conn);
+ resourceDAO.add(RegistryConstants.ROOT_PATH, root, conn);
//authorizationUtil.setDefaultAuthorizations(realm, RegistryConstants.ROOT_PATH, );
- root = artifactDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
- artifactDAO.addResourceVersion(root, conn);
+ root = resourceDAO.getLatestVersion(RegistryConstants.ROOT_PATH, conn);
+ resourceDAO.addResourceVersion(root, conn);
}
conn.commit();
@@ -119,25 +119,25 @@
* @throws RegistryException ResourceNotFound exception is thrown if the resource is not in the
* registry
*/
- public Artifact get(String path) throws RegistryException {
+ public Resource get(String path) throws RegistryException {
path = preparePath(path);
- Artifact artifact;
+ Resource resource;
// check if this path referes to a resource referred by a URL query (e.g. comment)
- artifact = urlHandlerManager.handleURL(path);
+ resource = urlHandlerManager.handleURL(path);
// check if the resource in the path has a mediatype handler
- if (artifact == null) {
- artifact = mediaTypeManager.get(path);
+ if (resource == null) {
+ resource = mediaTypeManager.get(path);
}
- if (artifact == null) {
+ if (resource == null) {
String message = Messages.getMessage("artifact.get.error", path);
throw new RegistryException(message);
}
- return artifact;
+ return resource;
}
public boolean resourceExists(String path) throws RegistryException {
@@ -147,7 +147,7 @@
boolean resourceExist = false;
try {
- resourceExist = artifactDAO.artifactExist(path, conn);
+ resourceExist = resourceDAO.resourceExist(path, conn);
} catch (SQLException e) {
String msg = "Failed to check the exsitence of a resource at path " + path;
@@ -172,13 +172,13 @@
* concurrency issues.
*
* @param path Path of the new resource
- * @param artifact Resource instance for the new resource
+ * @param resource Resource instance for the new resource
* @throws org.wso2.registry.RegistryException
* : if the user is not authorized
*/
- public synchronized void put(String path, Artifact artifact) throws RegistryException {
+ public synchronized void put(String path, Resource resource) throws RegistryException {
path = preparePath(path);
- mediaTypeManager.put(path, artifact);
+ mediaTypeManager.put(path, resource);
}
/**
@@ -203,8 +203,8 @@
Connection conn = connectionFactory.getConnection();
try {
- long artifactID = artifactDAO.getArtifactID(path, conn);
- String[] versionIDs = artifactDAO.getVersionNumbers(artifactID, conn);
+ long artifactID = resourceDAO.getResourceID(path, conn);
+ String[] versionIDs = resourceDAO.getVersionNumbers(artifactID, conn);
versionPaths = new String[versionIDs.length];
for (int i = 0; i < versionIDs.length; i++) {
@@ -253,10 +253,10 @@
try {
conn.setAutoCommit(false);
- long artifactID = artifactDAO.getArtifactID(plainPath, conn);
+ long artifactID = resourceDAO.getResourceID(plainPath, conn);
- artifactDAO.restore(artifactID, versionNumber, conn);
- //artifactDAO.restore(artifactID, versionNumber, conn);
+ resourceDAO.restore(artifactID, versionNumber, conn);
+ //resourceDAO.restore(artifactID, versionNumber, conn);
//VersionHandler.revert(artifactID, versionNumber, conn);
conn.commit();
@@ -309,11 +309,11 @@
try {
conn.setAutoCommit(false);
- if (!artifactDAO.artifactExist(resourcePath, conn)) {
+ if (!resourceDAO.resourceExist(resourcePath, conn)) {
throw new RegistryException(
"Cannot tag on a non-existing resource " + resourcePath);
}
- Artifact artifact = artifactDAO.getLatestVersion(resourcePath, conn);
+ Resource resource = resourceDAO.getLatestVersion(resourcePath, conn);
for (int i = 0; i < tags.length; i++) {
@@ -327,14 +327,14 @@
TagDO tagDO = tagsDAO.getTag(tags[i], conn);
- if (tagsDAO.taggingExist(tagDO.getId(), artifact.getId(), userID, conn)) {
+ if (tagsDAO.taggingExist(tagDO.getId(), resource.getId(), userID, conn)) {
String msg =
Messages.getMessage("resource.already.tagged", resourcePath, tags[i], userID);
log.error(msg);
throw new RegistryException(msg);
}
- tagsDAO.addTagging(tagDO.getId(), artifact.getId(), userID, conn);
+ tagsDAO.addTagging(tagDO.getId(), resource.getId(), userID, conn);
}
conn.commit();
@@ -461,9 +461,9 @@
conn.setAutoCommit(false);
- Artifact artifact = artifactDAO.getLatestVersion(resourcePath, conn);
- if (artifact != null) {
- commentsDAO.addComment(artifact.getId(), userID, comment, conn);
+ Resource resource = resourceDAO.getLatestVersion(resourcePath, conn);
+ if (resource != null) {
+ commentsDAO.addComment(resource.getId(), userID, comment, conn);
} else {
String msg = Messages.getMessage("comment.on.null.artfact", resourcePath);
@@ -553,15 +553,15 @@
try {
conn.setAutoCommit(false);
- Artifact artifact = artifactDAO.getLatestVersion(resourcePath, conn);
+ Resource resource = resourceDAO.getLatestVersion(resourcePath, conn);
- if (artifact != null) {
- if (ratingsDAO.ratingExist(artifact.getId(), userID, conn)) {
- ratingsDAO.updateRating(artifact.getId(), userID, rating, conn);
+ if (resource != null) {
+ 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);
} else {
- ratingsDAO.addRating(artifact.getId(), userID, rating, conn);
+ ratingsDAO.addRating(resource.getId(), userID, rating, conn);
}
} else {
String msg = Messages.getMessage("rate.on.null.artfact", resourcePath);
@@ -677,18 +677,18 @@
conn.setAutoCommit(false);
- Artifact queryArtifact = new Artifact();
- queryArtifact.setPath(queryPath);
- queryArtifact.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
- queryArtifact.setAuthorUserName(userID);
- queryArtifact.setContent(query.getBytes());
-
- Artifact artifact = artifactDAO.getLatestVersion(queryPath, conn);
- if (artifact != null) {
- artifactDAO.update(queryPath, queryArtifact, conn);
+ Resource queryResource = new Resource();
+ queryResource.setPath(queryPath);
+ queryResource.setMediaType(RegistryConstants.SQL_QUERY_MEDIA_TYPE);
+ queryResource.setAuthorUserName(userID);
+ queryResource.setContent(query.getBytes());
+
+ Resource resource = resourceDAO.getLatestVersion(queryPath, conn);
+ if (resource != null) {
+ resourceDAO.update(queryPath, queryResource, conn);
log.info("Updated the predefined query: " + queryPath);
} else {
- artifactDAO.add(queryPath, queryArtifact, conn);
+ resourceDAO.add(queryPath, queryResource, conn);
}
conn.commit();
@@ -716,10 +716,10 @@
}
- public Artifact executeQuery (String path, Object[] parameters) throws RegistryException {
+ public Resource executeQuery (String path, Object[] parameters) throws RegistryException {
Connection conn = connectionFactory.getConnection();
try {
- Artifact query = get(path);
+ Resource query = get(path);
QueryProcessor queryProcessor =
new QueryProcessorFactory().getQueryProcessor(query.getMediaType());
if (queryProcessor == null) {
@@ -759,7 +759,7 @@
List logEntryList = new ArrayList();
try {
- List artifactLogs = new VersionedArtifactDAO().getLogs(resourcePath,userName,from,to,
+ List artifactLogs = new VersionedResourceDAO().getLogs(resourcePath,userName,from,to,
conn);
//logEntryList.addAll(artifactLogs);
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 Nov 6 15:54:07 2007
@@ -21,7 +21,6 @@
import org.wso2.registry.Comment;
import org.wso2.registry.LogEntry;
-import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.DatabaseConstants;
import java.sql.*;
@@ -124,10 +123,10 @@
java.util.Date from, java.util.Date to, Connection conn)
throws SQLException {
- ArtifactDAO artifactDAO = new ArtifactDAO();
+ ResourceDAO resourceDAO = new ResourceDAO();
long aid = -1;
- aid = artifactDAO.getArtifactID(resourcePath, conn);
+ aid = resourceDAO.getArtifactID(resourcePath, conn);
String sql = "SELECT A.PATH, C.USER_ID, C.COMMENTED_TIME, C.COMMENT_TEXT FROM ARTIFACTS A, COMMENTS C WHERE A.AID=C.AID";
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RatingsDAO.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RatingsDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/RatingsDAO.java Tue Nov 6 15:54:07 2007
@@ -149,10 +149,10 @@
java.util.Date from, java.util.Date to, Connection conn)
throws SQLException {
- ArtifactDAO artifactDAO = new ArtifactDAO();
+ ResourceDAO resourceDAO = new ResourceDAO();
long aid = -1;
- aid = artifactDAO.getArtifactID(resourcePath, conn);
+ aid = resourceDAO.getArtifactID(resourcePath, conn);
String sql = "SELECT A.PATH, R.USER_ID, R.RATED_TIME, R.RATING FROM ARTIFACTS A, RATINGS R WHERE A.AID=R.AID";
Copied: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java (from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ArtifactDAO.java)
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ArtifactDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/ResourceDAO.java Tue Nov 6 15:54:07 2007
@@ -19,26 +19,23 @@
package org.wso2.registry.jdbc.dao;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryConstants;
-import org.wso2.registry.LogEntry;
-import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.DatabaseConstants;
import org.wso2.registry.versions.VersionHandler;
import java.sql.*;
-import java.sql.Date;
import java.util.*;
-public class ArtifactDAO {
+public class ResourceDAO {
- public Artifact get(String path, Connection conn) throws SQLException {
+ public Resource get(String path, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.PATH=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -47,27 +44,27 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(result.getString(DatabaseConstants.PATH_FIELD));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- artifact.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
- artifact.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
- artifact.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ resource.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
+ resource.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ resource.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact != null && artifact.isDirectory()) {
+ if (resource != null && resource.isDirectory()) {
String childrenSQL = "SELECT A.PATH FROM ARTIFACTS A, CHILDREN C WHERE A.AID=C.CHILD_ID AND C.PARENT_ID=?";
PreparedStatement s2 = conn.prepareStatement(childrenSQL);
- s2.setLong(1, artifact.getId());
+ s2.setLong(1, resource.getId());
ResultSet childrenResults = s2.executeQuery();
List childrenList = new ArrayList();
@@ -77,16 +74,16 @@
String[] children =
(String[]) childrenList.toArray(new String[childrenList.size()]);
- artifact.setContent(children);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
- if (artifact != null) {
+ if (resource != null) {
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -95,19 +92,19 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
+ resource.setProperties(props);
}
- return artifact;
+ return resource;
}
- public Artifact get(String path, long versionNumber, Connection conn) throws SQLException {
+ public Resource get(String path, long versionNumber, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.PATH=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -116,42 +113,42 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(path + "?v=" + versionNumber);
- artifact.setParentPath(VersionHandler.getParentPath(artifact.getId(), versionNumber, conn));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- //artifact.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
- //artifact.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
- //artifact.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(path + "?v=" + versionNumber);
+ resource.setParentPath(VersionHandler.getParentPath(resource.getId(), versionNumber, conn));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ //resource.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
+ //resource.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ //resource.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
}
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, versionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact != null && artifact.isDirectory()) {
+ if (resource != null && resource.isDirectory()) {
//String childrenSQL = "SELECT A.PATH FROM ARTIFACTS A, CHILDREN C WHERE A.AID=C.CHILD_ID AND C.PARENT_ID=?";
//PreparedStatement s2 = conn.prepareStatement(childrenSQL);
- //s2.setLong(1, artifact.getId());
+ //s2.setLong(1, resource.getId());
//ResultSet childrenResults = s2.executeQuery();
//
//List childrenList = new ArrayList();
@@ -163,17 +160,17 @@
// (String[]) childrenList.toArray(new String[childrenList.size()]);
String[] children = VersionHandler.
- getChildrenPath(artifact.getId(), versionNumber, conn);
- artifact.setContent(children);
+ getChildrenPath(resource.getId(), versionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
- if (artifact != null) {
+ if (resource != null) {
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -182,19 +179,19 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
+ resource.setProperties(props);
}
- return artifact;
+ return resource;
}
- public Artifact getArtifactByID(long artifactID, long versionNumber, Connection conn) throws SQLException {
+ public Resource getArtifactByID(long artifactID, long versionNumber, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.AID=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -203,16 +200,16 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(result.getString(DatabaseConstants.PATH_FIELD));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
}
if (versionNumber == -1) {
@@ -220,31 +217,31 @@
}
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, versionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact.isDirectory()) {
+ if (resource.isDirectory()) {
String[] children = VersionHandler.
- getChildrenPath(artifact.getId(), versionNumber, conn);
- artifact.setContent(children);
+ getChildrenPath(resource.getId(), versionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -253,17 +250,17 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
- return artifact;
+ resource.setProperties(props);
+ return resource;
}
- public Artifact getLatestVersion(String path, Connection conn) throws SQLException {
+ public Resource getLatestVersion(String path, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.PATH=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -272,44 +269,44 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(result.getString(DatabaseConstants.PATH_FIELD));
- artifact.setParentPath(getParentPath(artifact.getPath()));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- //artifact.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
- //artifact.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
- //artifact.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
+ resource.setParentPath(getParentPath(resource.getPath()));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ //resource.setLastUpdaterUserName(result.getString(DatabaseConstants.LAST_UPDATER_FIELD));
+ //resource.setLastModified(result.getTimestamp(DatabaseConstants.LAST_UPDATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ //resource.setContent(result.getBytes(DatabaseConstants.CONTENT_FIELD));
}
- long latestVersionNumber = VersionHandler.getLatestVerison(artifact.getId(), conn);
+ long latestVersionNumber = VersionHandler.getLatestVerison(resource.getId(), conn);
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, latestVersionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact.isDirectory()) {
+ if (resource.isDirectory()) {
//String childrenSQL = "SELECT A.PATH FROM ARTIFACTS A, CHILDREN C WHERE A.AID=C.CHILD_ID AND C.PARENT_ID=?";
//PreparedStatement s2 = conn.prepareStatement(childrenSQL);
- //s2.setLong(1, artifact.getId());
+ //s2.setLong(1, resource.getId());
//ResultSet childrenResults = s2.executeQuery();
//
//List childrenList = new ArrayList();
@@ -321,14 +318,14 @@
// (String[]) childrenList.toArray(new String[childrenList.size()]);
String[] children = VersionHandler.
- getLatestChildrenPath(artifact.getId(), latestVersionNumber, conn);
- artifact.setContent(children);
+ getLatestChildrenPath(resource.getId(), latestVersionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -337,20 +334,20 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
- return artifact;
+ resource.setProperties(props);
+ return resource;
}
/**
- * Adds the given artifact to the database.
+ * Adds the given resource to the database.
*
- * @param path Path of the new artifact
- * @param artifact New artifact
+ * @param path Path of the new resource
+ * @param resource New resource
* @param conn : Connection to DB
*/
- public void add (String path, Artifact artifact, Connection conn) throws SQLException {
+ public void add (String path, Resource resource, Connection conn) throws SQLException {
- // first add the artifact data into the artifacts table
+ // first add the resource data into the artifacts table
String sql = "INSERT INTO ARTIFACTS (PATH, MEDIA_TYPE, DIRECTORY, STATE, CREATED_TIME, AUTHOR, LAST_UPDATER, LAST_UPDATED_TIME, DESCRIPTION, CONTENT)" +
"VALUES (?,?,?,?,?,?,?,?,?,?)";
@@ -358,31 +355,31 @@
long now = System.currentTimeMillis();
PreparedStatement s = conn.prepareStatement(sql);
- s.setString(1, artifact.getPath());
- s.setString(2, artifact.getMediaType());
- s.setInt(3, artifact.isDirectory()? 1: 0);
+ s.setString(1, resource.getPath());
+ s.setString(2, resource.getMediaType());
+ s.setInt(3, resource.isDirectory()? 1: 0);
s.setInt(4, RegistryConstants.ACTIVE_STATE);
s.setTimestamp(5, new Timestamp(now));
- s.setString(6, artifact.getAuthorUserName());
- s.setString(7, artifact.getLastUpdaterUserName());
+ s.setString(6, resource.getAuthorUserName());
+ s.setString(7, resource.getLastUpdaterUserName());
s.setTimestamp(8, new Timestamp(now));
- s.setString(9, artifact.getDescription());
+ s.setString(9, resource.getDescription());
- if (artifact.getContent() != null && artifact.getContent() instanceof byte[]) {
- s.setBytes(10, (byte[]) artifact.getContent());
+ if (resource.getContent() != null && resource.getContent() instanceof byte[]) {
+ s.setBytes(10, (byte[]) resource.getContent());
} else {
s.setBytes(10, null);
}
s.executeUpdate();
- long newArtifactID = this.getArtifactID(artifact.getPath(), conn);
+ long newArtifactID = this.getArtifactID(resource.getPath(), conn);
- // now add artifact properties to the properties table
- addProperties(newArtifactID, artifact.getProperties(), conn);
+ // now add resource properties to the properties table
+ addProperties(newArtifactID, resource.getProperties(), conn);
}
- public void update(String path, Artifact artifact, Connection conn) throws SQLException{
+ public void update(String path, Resource resource, Connection conn) throws SQLException{
// first update the artifacts table
@@ -392,16 +389,16 @@
PreparedStatement s = conn.prepareStatement(sql);
- s.setString(1, artifact.getMediaType());
- s.setInt(2, artifact.isDirectory()? 1: 0);
- s.setInt(3, artifact.getState());
- s.setString(4, artifact.getAuthorUserName());
- s.setString(5, artifact.getLastUpdaterUserName());
+ s.setString(1, resource.getMediaType());
+ s.setInt(2, resource.isDirectory()? 1: 0);
+ s.setInt(3, resource.getState());
+ s.setString(4, resource.getAuthorUserName());
+ s.setString(5, resource.getLastUpdaterUserName());
s.setTimestamp(6, new Timestamp(now));
- s.setString(7, artifact.getDescription());
+ s.setString(7, resource.getDescription());
- if (artifact.getContent() != null && artifact.getContent() instanceof byte[]) {
- s.setBytes(8, (byte[]) artifact.getContent());
+ if (resource.getContent() != null && resource.getContent() instanceof byte[]) {
+ s.setBytes(8, (byte[]) resource.getContent());
} else {
s.setBytes(8, null);
}
@@ -411,10 +408,10 @@
s.executeUpdate();
// remove existing properties for the updated artfact
- removeProperties(artifact.getId(), conn);
+ removeProperties(resource.getId(), conn);
// now add the updated properties to the properties table
- addProperties(artifact.getId(), artifact.getProperties(), conn);
+ addProperties(resource.getId(), resource.getProperties(), conn);
}
public void delete(String path, Connection conn) throws SQLException {
@@ -477,7 +474,7 @@
ResultSet result = s.executeQuery();
while (result.next()) {
- Artifact child = new Artifact();
+ Resource child = new Resource();
child.setId(result.getLong(DatabaseConstants.AID_FIELD));
child.setPath(result.getString(DatabaseConstants.PATH_FIELD));
child.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
@@ -511,7 +508,7 @@
ResultSet pathResult = ps.executeQuery();
if (pathResult.next()) {
- Artifact child = new Artifact();
+ Resource child = new Resource();
child.setId(pathResult.getLong(DatabaseConstants.AID_FIELD));
child.setPath(pathResult.getString(DatabaseConstants.PATH_FIELD));
child.setDirectory(pathResult.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
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 6 15:54:07 2007
@@ -76,7 +76,7 @@
return count == 1;
}
- public void addTagging(long tagID, long artifactID, String userID, Connection conn) throws SQLException {
+ public void addTagging(long tagID, long resourceID, String userID, Connection conn) throws SQLException {
String sql = "INSERT INTO TAGGINGS (TAG_ID, AID, USER_ID, TAGGED_TIME) VALUES (?,?,?,?)";
@@ -84,21 +84,21 @@
PreparedStatement s = conn.prepareStatement(sql);
s.setLong(1, tagID);
- s.setLong(2, artifactID);
+ s.setLong(2, resourceID);
s.setString(3, userID);
s.setDate(4, new Date(now));
s.executeUpdate();
}
- public boolean taggingExist(long tagID, long artifactID, String userID, Connection conn)
+ public boolean taggingExist(long tagID, long resourceID, String userID, Connection conn)
throws SQLException {
String sql = "SELECT COUNT(TN.TAG_ID) FROM TAGGINGS TN WHERE TN.TAG_ID=? AND TN.AID=? AND TN.USER_ID=?";
PreparedStatement s = conn.prepareStatement(sql);
s.setLong(1, tagID);
- s.setLong(2, artifactID);
+ s.setLong(2, resourceID);
s.setString(3, userID);
ResultSet result = s.executeQuery();
@@ -110,12 +110,12 @@
return count == 1? true: false;
}
- public void removeTaggings(long artifactID, Connection conn) throws SQLException {
+ public void removeTaggings(long resourceID, Connection conn) throws SQLException {
String sql = "DELETE FROM TAGGINGS WHERE AID=?";
PreparedStatement s = conn.prepareStatement(sql);
- s.setLong(1, artifactID);
+ s.setLong(1, resourceID);
s.executeUpdate();
}
Copied: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java (from r9498, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedArtifactDAO.java)
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedArtifactDAO.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java Tue Nov 6 15:54:07 2007
@@ -16,7 +16,7 @@
package org.wso2.registry.jdbc.dao;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.LogEntry;
import org.wso2.registry.RegistryConstants;
import org.wso2.registry.RegistryException;
@@ -28,23 +28,23 @@
import java.util.List;
import java.util.Properties;
-public class VersionedArtifactDAO {
+public class VersionedResourceDAO {
/**
* Returns the given version of the artifact. If artifact is a collection all child paths will
* be added as versioned paths in the form /a/b?v=12
*
* @param path : path of the artifact
- * @return Artifact for the given version number
+ * @return Resource for the given version number
* @throws SQLException
*/
- public Artifact get(String path, long versionNumber, Connection conn) throws SQLException {
+ public Resource get(String path, long versionNumber, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.PATH=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -53,49 +53,49 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(path + "?v=" + versionNumber);
- artifact.setParentPath(getParentPath(artifact.getId(), versionNumber, conn));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(path + "?v=" + versionNumber);
+ resource.setParentPath(getParentPath(resource.getId(), versionNumber, conn));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
}
- if (artifact == null) {
+ if (resource == null) {
return null;
}
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, versionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact.isDirectory()) {
+ if (resource.isDirectory()) {
- String[] children = getChildPaths(artifact.getId(), versionNumber, conn);
- artifact.setContent(children);
+ String[] children = getChildPaths(resource.getId(), versionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -104,18 +104,18 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
+ resource.setProperties(props);
- return artifact;
+ return resource;
}
- public Artifact getArtifactByID(long artifactID, long versionNumber, Connection conn) throws SQLException {
+ public Resource getResourceByID(long artifactID, long versionNumber, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.AID=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -124,19 +124,19 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(result.getString(DatabaseConstants.PATH_FIELD));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
}
- if (artifact == null) {
+ if (resource == null) {
return null;
}
@@ -145,30 +145,30 @@
}
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, versionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
+ // get resource chidren
- if (artifact.isDirectory()) {
+ if (resource.isDirectory()) {
- String[] children = getChildPaths(artifact.getId(), versionNumber, conn);
- artifact.setContent(children);
+ String[] children = getChildPaths(resource.getId(), versionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -177,9 +177,9 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
+ resource.setProperties(props);
- return artifact;
+ return resource;
}
/**
@@ -191,13 +191,13 @@
* @return : Result artifcat
* @throws SQLException : if somthing went wrong
*/
- public Artifact getLatestVersion(String path, Connection conn) throws SQLException {
+ public Resource getLatestVersion(String path, Connection conn) throws SQLException {
- Artifact artifact = null;
+ Resource resource = null;
ResultSet result;
- // get the artifact data from the artifact table
+ // get the resource data from the resource table
String sql = "SELECT * FROM ARTIFACTS A WHERE A.PATH=?";
PreparedStatement statement = conn.prepareStatement(sql);
@@ -206,48 +206,48 @@
result = statement.executeQuery();
if (result.next()) {
- artifact = new Artifact();
+ resource = new Resource();
- artifact.setId(result.getLong(DatabaseConstants.AID_FIELD));
- artifact.setPath(result.getString(DatabaseConstants.PATH_FIELD));
- artifact.setParentPath(getParentPath(artifact.getPath()));
- artifact.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
- artifact.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
- artifact.setState(result.getInt(DatabaseConstants.STATE_FIELD));
- artifact.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
- artifact.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
- artifact.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
+ resource.setId(result.getLong(DatabaseConstants.AID_FIELD));
+ resource.setPath(result.getString(DatabaseConstants.PATH_FIELD));
+ resource.setParentPath(getParentPath(resource.getPath()));
+ resource.setDirectory(result.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
+ resource.setMediaType(result.getString(DatabaseConstants.MEDIA_TYPE_FIELD));
+ resource.setState(result.getInt(DatabaseConstants.STATE_FIELD));
+ resource.setAuthorUserName(result.getString(DatabaseConstants.AUTHOR_FIELD));
+ resource.setCreatedTime(result.getTimestamp(DatabaseConstants.CREATED_TIME_FIELD));
+ resource.setDescription(result.getString(DatabaseConstants.DESCRIPTION_FIELD));
}
- if (artifact == null) {
+ if (resource == null) {
return null;
}
- long latestVersionNumber = getLatestVerisonNumber(artifact.getId(), conn);
+ long latestVersionNumber = getLatestVerisonNumber(resource.getId(), conn);
String sqlVersionedFields = "SELECT * FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement versionQuery = conn.prepareStatement(sqlVersionedFields);
- versionQuery.setLong(1, artifact.getId());
+ versionQuery.setLong(1, resource.getId());
versionQuery.setLong(2, latestVersionNumber);
ResultSet versionResults = versionQuery.executeQuery();
if (versionResults.next()) {
- artifact.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
- artifact.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
- artifact.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
+ resource.setLastUpdaterUserName(versionResults.getString(DatabaseConstants.VERSION_AUTHOR_FIELD));
+ resource.setLastModified(versionResults.getTimestamp(DatabaseConstants.VERSION_UPDATED_TIME));
+ resource.setContent(versionResults.getBytes(DatabaseConstants.VERSION_CONTENT_FIELD));
}
- // get artifact chidren
- if (artifact.isDirectory()) {
+ // get resource chidren
+ if (resource.isDirectory()) {
- String[] children = getLatestChildPaths(artifact.getId(), latestVersionNumber, conn);
- artifact.setContent(children);
+ String[] children = getLatestChildPaths(resource.getId(), latestVersionNumber, conn);
+ resource.setContent(children);
}
- // get artifact properties
+ // get resource properties
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, artifact.getId());
+ s3.setLong(1, resource.getId());
ResultSet propResults = s3.executeQuery();
Properties props = new Properties();
@@ -256,8 +256,8 @@
String value = propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
props.put(key, value);
}
- artifact.setProperties(props);
- return artifact;
+ resource.setProperties(props);
+ return resource;
}
public String[] getChildPaths(long artifcatID, long versionNumber,
@@ -287,18 +287,18 @@
return (String[]) (dependencyPathList.toArray(new String[dependencyPathList.size()]));
}
- public String getParentPath(long artifcatID, long versionNumber,
+ public String getParentPath(long resourceID, long versionNumber,
Connection connection) throws SQLException {
if (versionNumber == -1) {
- versionNumber = getLatestVerisonNumber(artifcatID, connection);
+ versionNumber = getLatestVerisonNumber(resourceID, connection);
}
if (versionNumber == -1) {
return null;
}
String selectSql = "SELECT AID , VN FROM DEPENDENCY WHERE DAID=? AND DVN=?";
PreparedStatement s = connection.prepareStatement(selectSql);
- s.setLong(1, artifcatID);
+ s.setLong(1, resourceID);
s.setLong(2, versionNumber);
ResultSet result = s.executeQuery();
@@ -320,12 +320,12 @@
return parentPath;
}
- public String[] getLatestChildPaths(long artifcatID, long versionNumber,
+ public String[] getLatestChildPaths(long resourceID, long versionNumber,
Connection connection) throws SQLException {
String selectSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE AID=? AND VN=?";
PreparedStatement s = connection.prepareStatement(selectSql);
- s.setLong(1, artifcatID);
+ s.setLong(1, resourceID);
s.setLong(2, versionNumber);
ResultSet result = s.executeQuery();
@@ -346,16 +346,16 @@
return (String[]) (dependencyPathList.toArray(new String[dependencyPathList.size()]));
}
- public List getChildren(long artifcatID, long versionNumber,
+ public List getChildren(long resourceID, long versionNumber,
Connection connection) throws SQLException {
if (versionNumber == -1) {
- versionNumber = getLatestVerisonNumber(artifcatID, connection);
+ versionNumber = getLatestVerisonNumber(resourceID, connection);
}
String selectSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE AID=? AND VN=?";
PreparedStatement s = connection.prepareStatement(selectSql);
- s.setLong(1, artifcatID);
+ s.setLong(1, resourceID);
s.setLong(2, versionNumber);
ResultSet result = s.executeQuery();
@@ -371,7 +371,7 @@
ResultSet pathResult = ps.executeQuery();
if (pathResult.next()) {
- Artifact child = new Artifact();
+ Resource child = new Resource();
child.setId(pathResult.getLong(DatabaseConstants.AID_FIELD));
child.setPath(pathResult.getString(DatabaseConstants.PATH_FIELD));
child.setDirectory(pathResult.getInt(DatabaseConstants.DIRECTORY_FIELD) == 1);
@@ -382,15 +382,15 @@
}
/**
- * Adds the given artifact to the database.
+ * Adds the given resource to the database.
*
- * @param path Path of the new artifact
- * @param artifact New artifact
+ * @param path Path of the new resource
+ * @param resource New resource
* @param conn : Connection to Db
*/
- public void add(String path, Artifact artifact, Connection conn) throws SQLException {
+ public void add(String path, Resource resource, Connection conn) throws SQLException {
- // first add the artifact data into the artifacts table
+ // first add the resource data into the artifacts table
String sql = "INSERT INTO ARTIFACTS (PATH, MEDIA_TYPE, DIRECTORY, STATE, CREATED_TIME, AUTHOR, LAST_UPDATER, LAST_UPDATED_TIME, DESCRIPTION, CONTENT)" +
"VALUES (?,?,?,?,?,?,?,?,?,?)";
@@ -398,18 +398,18 @@
long now = System.currentTimeMillis();
PreparedStatement s = conn.prepareStatement(sql);
- s.setString(1, artifact.getPath());
- s.setString(2, artifact.getMediaType());
- s.setInt(3, artifact.isDirectory() ? 1 : 0);
+ s.setString(1, resource.getPath());
+ s.setString(2, resource.getMediaType());
+ s.setInt(3, resource.isDirectory() ? 1 : 0);
s.setInt(4, RegistryConstants.ACTIVE_STATE);
s.setTimestamp(5, new Timestamp(now));
- s.setString(6, artifact.getAuthorUserName());
- s.setString(7, artifact.getLastUpdaterUserName());
+ s.setString(6, resource.getAuthorUserName());
+ s.setString(7, resource.getLastUpdaterUserName());
s.setTimestamp(8, new Timestamp(now));
- s.setString(9, artifact.getDescription());
+ s.setString(9, resource.getDescription());
- if (artifact.getContent() != null && artifact.getContent() instanceof byte[]) {
- s.setBytes(10, (byte[]) artifact.getContent());
+ if (resource.getContent() != null && resource.getContent() instanceof byte[]) {
+ s.setBytes(10, (byte[]) resource.getContent());
} else {
s.setBytes(10, null);
}
@@ -417,13 +417,13 @@
s.executeUpdate();
- long newArtifactID = this.getArtifactID(artifact.getPath(), conn);
+ long newArtifactID = this.getResourceID(resource.getPath(), conn);
- // now add artifact properties to the properties table
- addProperties(newArtifactID, artifact.getProperties(), conn);
+ // now add resource properties to the properties table
+ addProperties(newArtifactID, resource.getProperties(), conn);
}
- public void update(String path, Artifact artifact, Connection conn) throws SQLException {
+ public void update(String path, Resource resource, Connection conn) throws SQLException {
// first update the artifacts table
@@ -433,16 +433,16 @@
PreparedStatement s = conn.prepareStatement(sql);
- s.setString(1, artifact.getMediaType());
- s.setInt(2, artifact.isDirectory() ? 1 : 0);
- s.setInt(3, artifact.getState());
- s.setString(4, artifact.getAuthorUserName());
- s.setString(5, artifact.getLastUpdaterUserName());
+ s.setString(1, resource.getMediaType());
+ s.setInt(2, resource.isDirectory() ? 1 : 0);
+ s.setInt(3, resource.getState());
+ s.setString(4, resource.getAuthorUserName());
+ s.setString(5, resource.getLastUpdaterUserName());
s.setTimestamp(6, new Timestamp(now));
- s.setString(7, artifact.getDescription());
+ s.setString(7, resource.getDescription());
- if (artifact.getContent() != null && artifact.getContent() instanceof byte[]) {
- s.setBytes(8, (byte[]) artifact.getContent());
+ if (resource.getContent() != null && resource.getContent() instanceof byte[]) {
+ s.setBytes(8, (byte[]) resource.getContent());
} else {
s.setBytes(8, null);
}
@@ -452,10 +452,10 @@
s.executeUpdate();
// remove existing properties for the updated artfact
- removeProperties(artifact.getId(), conn);
+ removeProperties(resource.getId(), conn);
// now add the updated properties to the properties table
- addProperties(artifact.getId(), artifact.getProperties(), conn);
+ addProperties(resource.getId(), resource.getProperties(), conn);
}
public void markDeleted(String path, Connection conn) throws SQLException {
@@ -468,7 +468,7 @@
s.executeUpdate();
}
- public void addProperties(long artifactID, Properties props, Connection conn)
+ public void addProperties(long resourceID, Properties props, Connection conn)
throws SQLException {
String propSQL = "INSERT INTO PROPERTIES (AID, PKEY, PVALUE) VALUES (?,?,?)";
@@ -481,7 +481,7 @@
String key = (String) i.next();
String value = (String) props.get(key);
- s2.setLong(1, artifactID);
+ s2.setLong(1, resourceID);
s2.setString(2, key);
s2.setString(3, value);
@@ -491,15 +491,15 @@
}
}
- public void removeProperties(long artifactID, Connection conn) throws SQLException {
+ public void removeProperties(long resourceID, Connection conn) throws SQLException {
String removePropsSQL = "DELETE FROM PROPERTIES WHERE AID=?";
PreparedStatement s2 = conn.prepareStatement(removePropsSQL);
- s2.setLong(1, artifactID);
+ s2.setLong(1, resourceID);
s2.executeUpdate();
}
- public boolean artifactExist(String path, Connection conn) throws SQLException {
+ public boolean resourceExist(String path, Connection conn) throws SQLException {
String sql = "SELECT COUNT(A.AID) FROM ARTIFACTS A WHERE A.PATH=?";
@@ -515,7 +515,7 @@
return count == 1;
}
- public long getArtifactID(String path, Connection conn) throws SQLException {
+ public long getResourceID(String path, Connection conn) throws SQLException {
String sql = "SELECT A.AID FROM ARTIFACTS A WHERE A.PATH=?";
@@ -530,7 +530,7 @@
return -1;
}
- public String getArtifactPath(long id, Connection conn) throws SQLException {
+ public String getResourcePath(long id, Connection conn) throws SQLException {
String sql = "SELECT A.PATH FROM ARTIFACTS A WHERE A.AID=?";
@@ -544,29 +544,29 @@
return null;
}
- public void addResourceVersion(Artifact artifact, Connection connection) throws SQLException {
+ public void addResourceVersion(Resource resource, Connection connection) throws SQLException {
- if (artifact.getLastModified() == null) {
- artifact.setLastModified(new java.util.Date());
+ if (resource.getLastModified() == null) {
+ resource.setLastModified(new java.util.Date());
}
- long versionNumber = insertToVersionTable(artifact, connection);
+ long versionNumber = insertToVersionTable(resource, connection);
//updating max version table
- updateDependency(artifact, versionNumber, false, connection);
+ updateDependency(resource, versionNumber, false, connection);
}
- private long insertToVersionTable(Artifact artifact, Connection connection)
+ private long insertToVersionTable(Resource resource, Connection connection)
throws SQLException {
String sql = "INSERT INTO VERSIONS (AID, VN ,CONTENT , AUTHOR, UPDATED_TIME) VALUES (?,?,?,?,?)";
PreparedStatement statement = connection.prepareStatement(sql);
- statement.setLong(1, artifact.getId());
+ statement.setLong(1, resource.getId());
// Need to getthe old version and increment that
// Selecet VID from latest table ,
// if it is there then find from that , if it is not there then we need ti start from 0
- long versionNumber = getLatestVerisonNumber(artifact.getId(), connection);
+ long versionNumber = getLatestVerisonNumber(resource.getId(), connection);
if (versionNumber == -1) {
versionNumber = 1;
} else {
@@ -575,28 +575,28 @@
}
statement.setLong(2, versionNumber);
- Object content = artifact.getContent();
+ Object content = resource.getContent();
if (content != null && content instanceof byte[]) {
statement.setBytes(3, (byte[]) content);
} else {
statement.setBytes(3, null);
}
- statement.setString(4, artifact.getLastUpdaterUserName());
+ statement.setString(4, resource.getLastUpdaterUserName());
statement.setTimestamp(5, new Timestamp(System.currentTimeMillis()));
statement.executeUpdate();
return versionNumber;
}
- private void updateDependency(Artifact artifact,
+ private void updateDependency(Resource resource,
long versionNumber,
boolean delete, Connection connection) throws SQLException {
// updating dependency table , so that we can rollback to a particular version
- // updating for the current artifact
+ // updating for the current resource
long parentNextVersionNumber =
- updateDependencyTable(artifact, versionNumber, delete, connection);
+ updateDependencyTable(resource, versionNumber, delete, connection);
// a/b/c/r1.wsdl
// Next a/b/c
@@ -605,12 +605,12 @@
if (parentNextVersionNumber != -1) {
// updating its parent
- String path = artifact.getPath();
+ String path = resource.getPath();
while (path != null && path.indexOf("/") > -1) {
int lastIndex = path.lastIndexOf("/");
String parentPath = path.substring(0, lastIndex);
- Artifact parentArtifact = getLatestVersion(parentPath, connection);
+ Resource parentArtifact = getLatestVersion(parentPath, connection);
if (parentArtifact != null) {
path = parentArtifact.getPath();
@@ -628,14 +628,14 @@
}
/**
- * @param artifact : Artifcat we need to update itslef and its immediate parent
+ * @param resource : Artifcat we need to update itslef and its immediate parent
* @param versionNumber : Version number of the artifcat
* @param delete : delete or adding
* @param connection : DB connetion
- * @return : Will retuen the artifact version of the parent artifact
+ * @return : Will retuen the resource version of the parent resource
* @throws SQLException : if something went wrong
*/
- private long updateDependencyTable(Artifact artifact,
+ private long updateDependencyTable(Resource resource,
long versionNumber,
boolean delete, Connection connection) throws SQLException {
/**
@@ -646,9 +646,9 @@
* First fine D1 V0
*/
// Checking whether the path is null or top most directory
- // Checking whether artifact is root node or not
+ // Checking whether resource is root node or not
- String path = artifact.getPath();
+ String path = resource.getPath();
// Checking whether the path is null or top most directory
// if (path != null && path.indexOf("/") > -1) {
@@ -665,18 +665,18 @@
} else {
- long parentId = getArtifactID(parentPath, connection);
+ long parentId = getResourceID(parentPath, connection);
- if (artifact.getLastModified() == null) {
- artifact.setLastModified(new java.util.Date());
+ if (resource.getLastModified() == null) {
+ resource.setLastModified(new java.util.Date());
}
// Need to get the parent's parent and update the and update the
long artifactversionNumber = getLatestVerisonNumber(parentId, connection);
long nextVersionNumber = createNextVersion(parentId,
- artifact.getLastUpdaterUserName(),
- artifact.getLastModified().getTime(), connection);
+ resource.getLastUpdaterUserName(),
+ resource.getLastModified().getTime(), connection);
String selectSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE AID=? AND VN=?";
PreparedStatement s = connection.prepareStatement(selectSql);
@@ -691,7 +691,7 @@
long daid = result.getLong("DAID");
- if (daid != artifact.getId()) {
+ if (daid != resource.getId()) {
long dvn = result.getLong("DVN");
PreparedStatement ps = getStatementForDependencyTable(connection,
parentId, nextVersionNumber, daid, dvn);
@@ -701,7 +701,7 @@
if (!delete) {
PreparedStatement ds = getStatementForDependencyTable(connection,
- parentId, nextVersionNumber, artifact.getId(), versionNumber);
+ parentId, nextVersionNumber, resource.getId(), versionNumber);
dependeyMap.add(ds);
}
@@ -721,11 +721,11 @@
return -1;
}
- public long getLatestVerisonNumber(long artifactId, Connection connection) throws SQLException {
+ public long getLatestVerisonNumber(long resourceId, Connection connection) throws SQLException {
String sql = "SELECT MAX(VN) FROM VERSIONS WHERE AID=?";
PreparedStatement s = connection.prepareStatement(sql);
- s.setLong(1, artifactId);
+ s.setLong(1, resourceId);
ResultSet result = s.executeQuery();
if (result.next()) {
@@ -735,11 +735,11 @@
return -1;
}
- public String[] getVersionNumbers(long artifactId, Connection connection) throws SQLException {
+ public String[] getVersionNumbers(long resourceId, Connection connection) throws SQLException {
String SQL = "SELECT VN FROM VERSIONS WHERE AID=?";
PreparedStatement s = connection.prepareStatement(SQL);
- s.setLong(1, artifactId);
+ s.setLong(1, resourceId);
ResultSet result = s.executeQuery();
ArrayList versionNumbers = new ArrayList();
while (result.next()) {
@@ -748,9 +748,9 @@
return (String[]) versionNumbers.toArray(new String[versionNumbers.size()]);
}
- public void restore(long artifactId, long toVersion, Connection connection) throws SQLException {
+ public void restore(long resourceId, long toVersion, Connection connection) throws SQLException {
- Artifact oldArtifact = getArtifactByID(artifactId, toVersion, connection);
+ Resource oldArtifact = getResourceByID(resourceId, toVersion, connection);
String plainPath = oldArtifact.getPath();
if (oldArtifact.getPath().indexOf("?v=") != -1) {
@@ -765,7 +765,7 @@
String selectChildSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE AID=? AND VN=?";
PreparedStatement selectps = connection.prepareStatement(selectChildSql);
- selectps.setLong(1, artifactId);
+ selectps.setLong(1, resourceId);
selectps.setLong(2, toVersion);
ResultSet childResult = selectps.executeQuery();
ArrayList dependencyList = new ArrayList();
@@ -774,9 +774,9 @@
long daid = childResult.getLong("DAID");
long dvn = childResult.getLong("DVN");
- long versionNumber = getLatestVerisonNumber(artifactId, connection);
+ long versionNumber = getLatestVerisonNumber(resourceId, connection);
PreparedStatement ps = getStatementForDependencyTable(connection,
- artifactId, versionNumber, daid, dvn);
+ resourceId, versionNumber, daid, dvn);
dependencyList.add(ps);
}
@@ -790,36 +790,36 @@
/**
* To restoreVersion or rollback artifcat to a given version number
*
- * @param artifactId : Artifact ID
+ * @param resourceId : Resource ID
* @param connection : Connection to DB
* @param toVersion : to which version we need to restoreVersion
* @throws SQLException : If something went wrong
*/
- public void restore2(long artifactId, long toVersion, Connection connection) throws SQLException {
+ public void restore2(long resourceId, long toVersion, Connection connection) throws SQLException {
String SQL = "SELECT CONTENT, AUTHOR, UPDATED_TIME FROM VERSIONS WHERE AID=? AND VN=?";
PreparedStatement statement = connection.prepareStatement(SQL);
- statement.setLong(1, artifactId);
+ statement.setLong(1, resourceId);
statement.setLong(2, toVersion);
ResultSet result = statement.executeQuery();
long versionNumber = 0;
if (result.next()) {
- Artifact artifactToRestore = new Artifact();
+ Resource artifactToRestore = new Resource();
artifactToRestore.setContent(result.getObject(1));
artifactToRestore.setAuthorUserName(result.getString(2));
artifactToRestore.setLastModified(result.getDate(3));
versionNumber = insertToVersionTable(artifactToRestore, connection);
}
- Artifact artifact = getArtifactByID(artifactId, toVersion, connection);
+ Resource resource = getResourceByID(resourceId, toVersion, connection);
// updating max version table
- updateDependency(artifact, versionNumber, false, connection);
- if (artifact.isDirectory()) {
+ updateDependency(resource, versionNumber, false, connection);
+ if (resource.isDirectory()) {
String selectChildSql = "SELECT DAID, DVN FROM DEPENDENCY WHERE AID=? AND VN=?";
PreparedStatement selectps = connection.prepareStatement(selectChildSql);
- selectps.setLong(1, artifactId);
+ selectps.setLong(1, resourceId);
selectps.setLong(2, toVersion);
ResultSet childResult = selectps.executeQuery();
ArrayList dependencyList = new ArrayList();
@@ -827,7 +827,7 @@
long daid = childResult.getLong("DAID");
long dvn = childResult.getLong("DVN");
PreparedStatement ps = getStatementForDependencyTable(connection,
- artifactId, versionNumber, daid, dvn);
+ resourceId, versionNumber, daid, dvn);
dependencyList.add(ps);
}
@@ -840,25 +840,25 @@
}
/**
- * To delete a artifact , what actualy happen here is that update the version table with the new data
- * and artifact will not actualy removed from the table
+ * To delete a resource , what actualy happen here is that update the version table with the new data
+ * and resource will not actualy removed from the table
*
- * @param artifact : Artifact to be deleted
+ * @param resource : Resource to be deleted
* @param connection : Connection to the DB
* @throws java.sql.SQLException : if something went wrong
*/
- public void deleteResource(Artifact artifact,
+ public void deleteResource(Resource resource,
Connection connection) throws SQLException {
- long versionNumber = getLatestVerisonNumber(artifact.getId(), connection);
- updateDependency(artifact, versionNumber, true, connection);
+ long versionNumber = getLatestVerisonNumber(resource.getId(), connection);
+ updateDependency(resource, versionNumber, true, connection);
}
- private long createNextVersion(long artifactID,
+ private long createNextVersion(long resourceID,
String lastUpdaterUserName,
long lastModifiedTime,
Connection connection) throws SQLException {
- long maxVersion = getLatestVerisonNumber(artifactID, connection);
+ long maxVersion = getLatestVerisonNumber(resourceID, connection);
if (maxVersion == -1) {
maxVersion = 0;
}
@@ -866,11 +866,11 @@
// here maxVersion is always >0
maxVersion = maxVersion + 1;
- Artifact artifact = new Artifact();
- artifact.setId(artifactID);
- artifact.setLastUpdaterUserName(lastUpdaterUserName);
- artifact.setLastModified(new Date(lastModifiedTime));
- insertToVersionTable(artifact, connection);
+ Resource resource = new Resource();
+ resource.setId(resourceID);
+ resource.setLastUpdaterUserName(lastUpdaterUserName);
+ resource.setLastModified(new Date(lastModifiedTime));
+ insertToVersionTable(resource, connection);
return maxVersion;
}
@@ -927,8 +927,8 @@
String SQL = "SELECT UPDATED_TIME , AUTHOR , AID FROM VERSIONS ";
long aid = 0;
if (resourcePath != null) {
- ArtifactDAO artifactDAO = new ArtifactDAO();
- aid = artifactDAO.getArtifactID(resourcePath, conn);
+ ResourceDAO resourceDAO = new ResourceDAO();
+ aid = resourceDAO.getArtifactID(resourcePath, conn);
}
boolean where = false;
String whereStatment = "";
@@ -988,7 +988,7 @@
logEntry.setDate(result.getTime("UPDATED_TIME"));
logEntry.setUserName(result.getString("AUTHOR"));
aid = result.getLong("AID");
- logEntry.setResourcePath(getArtifactPath(aid, conn));
+ logEntry.setResourcePath(getResourcePath(aid, conn));
logevents.add(logEntry);
}
return logevents;
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeHandler.java Tue Nov 6 15:54:07 2007
@@ -16,10 +16,10 @@
package org.wso2.registry.jdbc.mediatypes;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.ConnectionFactory;
-import org.wso2.registry.jdbc.dao.VersionedArtifactDAO;
+import org.wso2.registry.jdbc.dao.VersionedResourceDAO;
import org.wso2.registry.jdbc.utils.AuthorizationUtil;
import org.wso2.usermanager.Realm;
@@ -58,10 +58,10 @@
protected MediaTypeManager mediaTypeManager;
/**
- * ArtifactDAO for directly accessing resources.
+ * ResourceDAO for directly accessing resources.
*/
- //protected ArtifactDAO artifactDAO = new ArtifactDAO();
- protected VersionedArtifactDAO artifactDAO = new VersionedArtifactDAO();
+ //protected ResourceDAO resourceDAO = new ResourceDAO();
+ protected VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
/**
* Some common authorization tasks are implemented in this util.
@@ -86,21 +86,21 @@
* database. This can be used by media type handlers, which need to alter contents of the
* raw artifact, etc.
*
- * @return Artifact instance if the media type handler processes the GET action. If artifact is
+ * @return Resource instance if the media type handler processes the GET action. If resource is
* returned it should perform all tasks to fulfill the GET request. Returns null if the
* media type handler does not process the GET action. If null is returned, get(...) method of
* the DefaultMediaTypeHandler will be invoked.
*
* @throws RegistryException
*/
- public abstract Artifact get(String path, Artifact rawArtifact) throws RegistryException;
+ public abstract Resource get(String path, Resource rawArtifact) throws RegistryException;
/**
* Processes the PUT action of the media type.
*
* @param path to put the resource.
*
- * @param artifact to put.
+ * @param resource to put.
*
* @return true if the media type handler processes the PUT action. If true is returned it
* should perform all tasks to fulfill the PUT request. Returns false if the media type handler
@@ -109,7 +109,7 @@
*
* @throws RegistryException
*/
- public abstract boolean put(String path, Artifact artifact) throws RegistryException;
+ public abstract boolean put(String path, Resource resource) throws RegistryException;
/**
* Processes the DELETE action of the media type.
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/MediaTypeManager.java Tue Nov 6 15:54:07 2007
@@ -18,13 +18,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryConstants;
import org.wso2.registry.RegistryException;
import org.wso2.registry.i18n.Messages;
import org.wso2.registry.jdbc.ConnectionFactory;
import org.wso2.registry.jdbc.JDBCRegistry;
-import org.wso2.registry.jdbc.dao.VersionedArtifactDAO;
+import org.wso2.registry.jdbc.dao.VersionedResourceDAO;
import org.wso2.registry.jdbc.mediatypes.builtin.DefaultMediaTypeHandler;
import org.wso2.registry.jdbc.mediatypes.builtin.SQLQueryMediaTypeHandler;
import org.wso2.registry.jdbc.mediatypes.builtin.SynapseRepositoryMediaTypeHandler;
@@ -47,7 +47,7 @@
private ConnectionFactory connectionFactory;
- private VersionedArtifactDAO artifactDAO = new VersionedArtifactDAO();
+ private VersionedResourceDAO resourceDAO = new VersionedResourceDAO();
private Map mediaTypeHandlers = new HashMap();
private DefaultMediaTypeHandler defaultMediaTypeHandler;
@@ -68,61 +68,61 @@
RegistryConstants.SYNPASE_REPOSITORY_MEDIA_TYPE, synRepoMediaTypeHandler);
}
- public Artifact get(String path) throws RegistryException {
+ public Resource get(String path) throws RegistryException {
- Artifact artifact = defaultMediaTypeHandler.get(path, null);
+ Resource resource = defaultMediaTypeHandler.get(path, null);
- Artifact processedArtifact = null;
+ Resource processedArtifact = null;
- if (artifact == null) {
+ if (resource == null) {
throw new RegistryException("No resource found at path " + path);
}
- if (artifact.getMediaType() != null) {
+ if (resource.getMediaType() != null) {
MediaTypeHandler mediaTypeHandler =
- (MediaTypeHandler) mediaTypeHandlers.get(artifact.getMediaType());
+ (MediaTypeHandler) mediaTypeHandlers.get(resource.getMediaType());
if (mediaTypeHandler != null) {
- processedArtifact = mediaTypeHandler.get(path, artifact);
+ processedArtifact = mediaTypeHandler.get(path, resource);
}
}
if (processedArtifact != null) {
return processedArtifact;
} else {
- return artifact;
+ return resource;
}
}
- public void put(String path, Artifact artifact) throws RegistryException {
+ public void put(String path, Resource resource) throws RegistryException {
- if (artifact.getMediaType() != null) {
+ if (resource.getMediaType() != null) {
MediaTypeHandler mediaTypeHandler =
- (MediaTypeHandler) mediaTypeHandlers.get(artifact.getMediaType());
+ (MediaTypeHandler) mediaTypeHandlers.get(resource.getMediaType());
if (mediaTypeHandler != null) {
- if (!mediaTypeHandler.put(path, artifact)) {
- defaultMediaTypeHandler.put(path, artifact);
+ if (!mediaTypeHandler.put(path, resource)) {
+ defaultMediaTypeHandler.put(path, resource);
}
} else {
- defaultMediaTypeHandler.put(path, artifact);
+ defaultMediaTypeHandler.put(path, resource);
}
} else {
- defaultMediaTypeHandler.put(path, artifact);
+ defaultMediaTypeHandler.put(path, resource);
}
}
public void delete(String path) throws RegistryException {
- Artifact artifact = getRawArtifact(path);
+ Resource resource = getRawArtifact(path);
- if (artifact == null) {
+ if (resource == null) {
throw new RegistryException("Could not delete a non-existing resource.");
}
- if (artifact.getMediaType() != null) {
+ if (resource.getMediaType() != null) {
MediaTypeHandler mediaTypeHandler =
- (MediaTypeHandler) mediaTypeHandlers.get(artifact.getMediaType());
+ (MediaTypeHandler) mediaTypeHandlers.get(resource.getMediaType());
if (mediaTypeHandler != null) {
if (!mediaTypeHandler.delete(path)) {
@@ -144,13 +144,13 @@
return defaultMediaTypeHandler;
}
- private Artifact getRawArtifact(String path) throws RegistryException {
+ private Resource getRawArtifact(String path) throws RegistryException {
- Artifact artifact;
+ Resource resource;
Connection conn = connectionFactory.getConnection();
try {
- artifact = artifactDAO.getLatestVersion(path, conn);
+ resource = resourceDAO.getLatestVersion(path, conn);
} catch (SQLException e) {
@@ -166,6 +166,6 @@
}
}
- return artifact;
+ return resource;
}
}
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 Nov 6 15:54:07 2007
@@ -18,7 +18,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryConstants;
import org.wso2.registry.RegistryException;
import org.wso2.registry.User;
@@ -43,7 +43,7 @@
super(connectionFactory, realm, mediaTypeManager);
}
- public Artifact get(String path, Artifact artifact) throws RegistryException {
+ public Resource get(String path, Resource resource) throws RegistryException {
String plainPath = path;
long versionNumber = -1;
@@ -55,12 +55,12 @@
Connection conn = connectionFactory.getConnection();
try {
- //artifact = artifactDAO.get(path, conn);
+ //resource = resourceDAO.get(path, conn);
if (versionNumber == -1) {
- artifact = artifactDAO.getLatestVersion(plainPath, conn);
+ resource = resourceDAO.getLatestVersion(plainPath, conn);
} else {
- artifact = artifactDAO.get(plainPath, versionNumber, conn);
+ resource = resourceDAO.get(plainPath, versionNumber, conn);
}
} catch (SQLException e) {
@@ -77,10 +77,10 @@
}
}
- return artifact;
+ return resource;
}
- public boolean put(String path, Artifact artifact) throws RegistryException {
+ public boolean put(String path, Resource resource) throws RegistryException {
String userID = User.getCurrentUser();
@@ -89,23 +89,23 @@
try {
conn.setAutoCommit(false);
- Artifact a = artifactDAO.getLatestVersion(path, conn);
+ Resource a = resourceDAO.getLatestVersion(path, conn);
if (a != null) {
- // given artifact already exist. update it.
- artifact.setId(a.getId());
+ // given resource already exist. update it.
+ resource.setId(a.getId());
// if client has not explicitly set the author, keep the original author name.
- if (artifact.getAuthorUserName() == null) {
- artifact.setAuthorUserName(a.getAuthorUserName());
+ if (resource.getAuthorUserName() == null) {
+ resource.setAuthorUserName(a.getAuthorUserName());
}
- artifact.setLastUpdaterUserName(userID);
- artifactDAO.update(path, artifact, conn);
- artifactDAO.addResourceVersion(artifact, conn);
+ resource.setLastUpdaterUserName(userID);
+ resourceDAO.update(path, resource, conn);
+ resourceDAO.addResourceVersion(resource, conn);
} else {
- // given artifact does not exist. add it as a new artifact.
+ // given resource does not exist. add it as a new resource.
// first create all ascendant collections
String[] parts = path.split(RegistryConstants.PATH_SEPARATOR);
@@ -113,25 +113,25 @@
String currentPath = RegistryConstants.ROOT_PATH + parts[1];
for (int i = 2; i < parts.length; i++) {
- Artifact currentCollection = artifactDAO.getLatestVersion(currentPath, conn);
+ Resource currentCollection = resourceDAO.getLatestVersion(currentPath, conn);
if (currentCollection == null) {
- currentCollection = new Artifact();
+ currentCollection = new Resource();
currentCollection.setPath(currentPath);
currentCollection.setDirectory(true);
currentCollection.setAuthorUserName(userID);
currentCollection.setLastUpdaterUserName(userID);
- artifactDAO.add(currentPath, currentCollection, conn);
+ resourceDAO.add(currentPath, currentCollection, conn);
authorizationUtil.setDefaultAuthorizations(realm, currentPath, userID);
- currentCollection = artifactDAO.getLatestVersion(currentPath, conn);
+ currentCollection = resourceDAO.getLatestVersion(currentPath, conn);
} else {
if (!currentCollection.isDirectory()) {
String message =
- Messages.getMessage("artifact.adding.error", currentPath, path);
+ Messages.getMessage("resource.adding.error", currentPath, path);
throw new RegistryException(message);
}
}
@@ -139,21 +139,21 @@
currentPath = currentPath + RegistryConstants.PATH_SEPARATOR + parts[i];
}
- // now add the required artifact
- artifact.setPath(path);
- if (artifact.getAuthorUserName() == null) {
- artifact.setAuthorUserName(userID);
+ // now add the required resource
+ resource.setPath(path);
+ if (resource.getAuthorUserName() == null) {
+ resource.setAuthorUserName(userID);
}
- artifact.setLastUpdaterUserName(userID);
+ resource.setLastUpdaterUserName(userID);
- artifactDAO.add(path, artifact, conn);
+ resourceDAO.add(path, resource, conn);
authorizationUtil.setDefaultAuthorizations(realm, path, userID);
- artifact.setId(artifactDAO.getArtifactID(path, conn));
- artifactDAO.addResourceVersion(artifact, conn);
+ resource.setId(resourceDAO.getResourceID(path, conn));
+ resourceDAO.addResourceVersion(resource, conn);
- // add new artifact as a child of the current parent
- //artifactDAO.addChild(currentParent.getId(), artifact.getId(), conn);
+ // add new resource as a child of the current parent
+ //resourceDAO.addChild(currentParent.getId(), resource.getId(), conn);
}
conn.commit();
@@ -183,15 +183,15 @@
Connection conn = connectionFactory.getConnection();
try {
conn.setAutoCommit(false);
- Artifact artifact = artifactDAO.getLatestVersion(path, conn);
- if (artifact != null) {
- if (artifact.isDirectory()) {
- deleteDirectory(artifact, conn);
+ Resource resource = resourceDAO.getLatestVersion(path, conn);
+ if (resource != null) {
+ if (resource.isDirectory()) {
+ deleteDirectory(resource, conn);
} else {
- artifactDAO.markDeleted(path, conn);
- artifactDAO.deleteResource(artifact, conn);
- //prepareToDelete(artifact.getId(), conn);
- //artifactDAO.delete(artifact.getPath(), conn);
+ resourceDAO.markDeleted(path, conn);
+ resourceDAO.deleteResource(resource, conn);
+ //prepareToDelete(resource.getId(), conn);
+ //resourceDAO.delete(resource.getPath(), conn);
}
} else {
String msg = Messages.getMessage("delete.null.resource", path);
@@ -218,19 +218,19 @@
return true;
}
- private void deleteDirectory(Artifact collection, Connection conn) throws SQLException {
- List childList = artifactDAO.getChildren(collection.getId(), -1, conn);
+ private void deleteDirectory(Resource collection, Connection conn) throws SQLException {
+ List childList = resourceDAO.getChildren(collection.getId(), -1, conn);
Iterator i = childList.iterator();
while (i.hasNext()) {
- Artifact child = (Artifact) i.next();
+ Resource child = (Resource) i.next();
if (child.isDirectory()) {
deleteDirectory(child, conn);
} else {
- artifactDAO.markDeleted(child.getPath(), conn);
- artifactDAO.deleteResource(child, conn);
+ resourceDAO.markDeleted(child.getPath(), conn);
+ resourceDAO.deleteResource(child, conn);
}
}
- artifactDAO.markDeleted(collection.getPath(), conn);
- artifactDAO.deleteResource(collection, conn);
+ resourceDAO.markDeleted(collection.getPath(), conn);
+ resourceDAO.deleteResource(collection, conn);
}
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SQLQueryMediaTypeHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SQLQueryMediaTypeHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SQLQueryMediaTypeHandler.java Tue Nov 6 15:54:07 2007
@@ -16,7 +16,7 @@
package org.wso2.registry.jdbc.mediatypes.builtin;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.ConnectionFactory;
import org.wso2.registry.jdbc.mediatypes.MediaTypeHandler;
@@ -32,26 +32,26 @@
super(connectionFactory, realm, mediaTypeManager);
}
- public Artifact get(String path, Artifact artifact) throws RegistryException {
+ public Resource get(String path, Resource resource) throws RegistryException {
- Object content = artifact.getContent();
+ Object content = resource.getContent();
if (content instanceof byte[]) {
- artifact.setContent(new String((byte[])content));
+ resource.setContent(new String((byte[])content));
}
- return artifact;
+ return resource;
}
- public boolean put(String path, Artifact artifact) throws RegistryException {
+ public boolean put(String path, Resource resource) throws RegistryException {
- Object content = artifact.getContent();
+ Object content = resource.getContent();
if (content instanceof String) {
String textContent = (String) content;
- artifact.setContent(textContent.getBytes());
+ resource.setContent(textContent.getBytes());
}
MediaTypeHandler defaultMediaTypeHandler = mediaTypeManager.getDefaultMediaTypeHandler();
- defaultMediaTypeHandler.put(path, artifact);
+ defaultMediaTypeHandler.put(path, resource);
return true;
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SynapseRepositoryMediaTypeHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SynapseRepositoryMediaTypeHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes/builtin/SynapseRepositoryMediaTypeHandler.java Tue Nov 6 15:54:07 2007
@@ -16,7 +16,7 @@
package org.wso2.registry.jdbc.mediatypes.builtin;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryConstants;
import org.wso2.registry.RegistryException;
import org.wso2.registry.jdbc.ConnectionFactory;
@@ -32,18 +32,18 @@
super(connectionFactory, realm, mediaTypeManager);
}
- public Artifact get(String path, Artifact artifact) throws RegistryException {
+ public Resource get(String path, Resource resource) throws RegistryException {
return null;
}
- public boolean put(String path, Artifact artifact) throws RegistryException {
+ public boolean put(String path, Resource resource) throws RegistryException {
MediaTypeHandler defaultMediaTypeHandler = mediaTypeManager.getDefaultMediaTypeHandler();
- defaultMediaTypeHandler.put(path, artifact);
+ defaultMediaTypeHandler.put(path, resource);
String confPath = path +
RegistryConstants.PATH_SEPARATOR + RegistryConstants.SYNAPSE_CONF_COLLECTION_NAME;
- Artifact confCollection = new Artifact();
+ Resource confCollection = new Resource();
confCollection.setDirectory(true);
confCollection.setPath(confPath);
confCollection.setMediaType(RegistryConstants.SYNAPSE_CONF_COLLECTION_MEDIA_TYPE);
@@ -51,7 +51,7 @@
String seqPath = path + RegistryConstants.PATH_SEPARATOR +
RegistryConstants.SYNAPSE_SEQUENCES_COLLECTION_NAME;
- Artifact seqCollection = new Artifact();
+ Resource seqCollection = new Resource();
seqCollection.setDirectory(true);
seqCollection.setPath(seqPath);
seqCollection.setMediaType(RegistryConstants.SYNAPSE_SEQUENCE_COLLECTION_MEDIA_TYPE);
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessor.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessor.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessor.java Tue Nov 6 15:54:07 2007
@@ -16,13 +16,13 @@
package org.wso2.registry.jdbc.queries;
-import org.wso2.registry.Artifact;
+import org.wso2.registry.Resource;
import org.wso2.registry.RegistryException;
import java.sql.Connection;
public interface QueryProcessor {
- p