Author: glen
Date: Tue Feb 5 11:51:08 2008
New Revision: 13286
Log:
Get trunk back in sync.
PLEASE MAKE SURE ALL CHANGES ARE COMMITTED TO TRUNK!!!!!!!!!!!!!!!
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPTests.java
trunk/registry/modules/documentation/src/site/site.xml
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 Feb 5 11:51:08 2008
@@ -22,7 +22,9 @@
import java.util.Date;
import java.util.Map;
-/** API for the Registry. Java applications should use this API to access the
registry. */
+/**
+ * API for the Registry. Java applications should use this API to access the
registry.
+ */
public interface Registry extends CoreRegistry {
/**
@@ -31,13 +33,14 @@
* @param suggestedPath path where we'd like to add the new resource.
Although this path is
* specified by the caller of the method, resource
may not be actually
* added to this path.
- * @param sourceURL where to fetch the resource content
- * @param metadata a template Resource
+ * @param sourceURL where to fetch the resource content
+ * @param metadata a template Resource
* @return actual path to which the resource is added
* @throws RegistryException
*/
- String importResource(String suggestedPath, String sourceURL, Resource
metadata)
- throws RegistryException;
+ String importResource(String suggestedPath,
+ String sourceURL,
+ Resource metadata) throws RegistryException;
/**
* Deletes the resource in the given path. If the path refers to a
directory, all child
@@ -54,7 +57,7 @@
* resource 2) add the resource to the new location.
*
* @param currentPath current path of the resource
- * @param newPath where we'd like to move the reosurce
+ * @param newPath where we'd like to move the reosurce
* @return the actual path for the new resource
* @throws RegistryException : If something went wrong
*/
@@ -140,7 +143,7 @@
* Change the text of an existing comment.
*
* @param commentPath path to comment resource ("..foo/r1;comment:1")
- * @param text new text
+ * @param text new text
* @throws RegistryException
*/
void editComment(String commentPath, String text) throws RegistryException;
@@ -219,6 +222,5 @@
String userName,
Date from,
Date to,
- boolean recentFirst)
- throws RegistryException;
+ boolean recentFirst) throws RegistryException;
}
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
Tue Feb 5 11:51:08 2008
@@ -19,9 +19,7 @@
package org.wso2.registry;
-import javax.xml.namespace.QName;
-
-public interface RegistryConstants {
+public final class RegistryConstants {
/**
* These constants are used to specify the core registry to use in the
registry server. This is
* specified as a init parameter of the Registry servlet.
@@ -35,7 +33,9 @@
public static final String REGISTRY_CONFIG_PATH = "registry.config.path";
public static final String REGISTRY_CONTEXT = "registry.context";
- /** Built in user names */
+ /**
+ * Built in user names
+ */
public static final String SYSTEM_USER = "system";
public static final String SYSTEM_PASSWORD = "system";
public static final String ANONYMOUS_USER = "anonymous";
@@ -128,4 +128,7 @@
public static final String URL_SEPARATOR = ";";
public static final String RESOURCES_PATH = "resources";
+
+ private RegistryConstants() {
+ }
}
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
Tue Feb 5 11:51:08 2008
@@ -486,8 +486,7 @@
String path,
Resource resource,
boolean exceuteQuery) {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
//Properties in the resource will be send as attributes in the feed
object
RemoteRegistry.addPropertyExtensionElement(resource.getProperties(),
abdera,
@@ -657,8 +656,7 @@
}
private Document<Feed> get_feed_doc(Abdera abdera, String baseUri) {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
try {
feed.setId("http://wso2.org/jdbcregistry,2007:feed");
feed.setTitle("WSO2 Registry");
@@ -742,8 +740,7 @@
String baseUri,
RequestContext request) {
try {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
Tag tags[] = getSecureRegistry(request).getTags(path);
feed.setId("http://wso2.org/jdbcregistry:tags" + path);
feed.setTitle("Tags for " + path);
@@ -767,6 +764,16 @@
}
/**
+ * This method will give a feed object instance
+ * @param abdera : Instance to Abdera
+ * @return created Feed object
+ */
+ private Feed getFeedInstance(Abdera abdera) {
+ Factory factory = abdera.getFactory();
+ return factory.newFeed();
+ }
+
+ /**
* Get an Atom feed for the ratings of a given resource. This feed will
contain an extension
* "AverageRating", and entries for each individual rating.
*
@@ -777,8 +784,7 @@
*/
private Feed getRatingsFeed(Abdera abdera, String path, String baseUri) {
try {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
feed.setUpdated(new Date());
feed.setId("http://wso2.org/jdbcregistry:averageRating");
feed.setTitle("Average Rating for the resource " + path);
@@ -806,8 +812,7 @@
*/
private Feed getFeedForComments(Abdera abdera, String path, RequestContext
request) {
try {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
feed.addSimpleExtension(new QName(NAMESPACE ,"directory"), "true");
feed.addSimpleExtension(COMMENTS_QNAME, "true");
Comment comments[] = getSecureRegistry(request).getComments(path);
@@ -850,8 +855,7 @@
String baseUri,
RequestContext request) {
try {
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
TaggedResourcePath tagpaths[] =
getSecureRegistry(request).getResourcePathsWithTag(tag);
feed.setId("http://wso2.org/jdbcregistry/TagPaths");
feed.setUpdated(new Date());
@@ -929,8 +933,7 @@
RequestContext request) throws
RegistryException {
LogEntry[] entries = getSecureRegistry(request).getLogs(
path, Integer.parseInt(action), author, from, to, true);
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
feed.setId("http://wso2.org/jdbcregistry,2007:logs");
feed.setTitle("Logs for the resource" + path);
feed.addLink("", "self");
@@ -962,8 +965,7 @@
RequestContext request) {
try {
boolean isResourceExsit =
getSecureRegistry(request).resourceExists(path);
- Factory factory = abdera.getFactory();
- Feed feed = factory.newFeed();
+ Feed feed = getFeedInstance(abdera);
feed.setUpdated(new Date());
feed.setId("http://wso2.org/jdbcregistry:resourceExist" + path);
if (isResourceExsit) {
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
Tue Feb 5 11:51:08 2008
@@ -42,7 +42,7 @@
import java.net.URLConnection;
import java.util.*;
-public class RemoteRegistry implements Registry, RegistryConstants,
APPConstants {
+public class RemoteRegistry implements Registry, APPConstants {
private String baseURI;
private Log log = LogFactory.getLog(RemoteRegistry.class);
@@ -146,7 +146,7 @@
resource.setDescription(feed.getSubtitle());
String state = feed.getSimpleExtension(new QName(NAMESPACE, "state"));
if (state != null && "Deleted".equals(state)) {
- resource.setState(DELETED_STATE);
+ resource.setState(RegistryConstants.DELETED_STATE);
}
if (isDirectory != null && "true".equals(isDirectory)) {
@@ -347,7 +347,7 @@
Entry entry = abdera.getFactory().newEntry();
entry.setContent(newPath);
ClientResponse resp = abderaClient.post(baseURI +
encodeURL(currentPath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_RENAME),
entry,
getAuthorization());
@@ -364,7 +364,7 @@
Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse = abderaClient.get(baseURI +
encodeURL(path +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_VERSION),
getAuthorization());
Document introspection =
@@ -387,7 +387,7 @@
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
ClientResponse resp = abderaClient.put(baseURI + encodeURL(versionPath
+
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_RESTORE),
entry,
getAuthorization());
@@ -405,7 +405,7 @@
Entry entry = abdera.getFactory().newEntry();
entry.setContent(tag);
ClientResponse resp = abderaClient.put(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_TAGS),
entry,
getAuthorization());
@@ -427,7 +427,7 @@
taggingUri = baseURI + "/";
}
ClientResponse clientResponse = abderaClient.get(taggingUri +
- URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_TAG_PATHS +
":" + tag,
getAuthorization());
Document introspection =
@@ -466,7 +466,7 @@
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse = abderaClient.get(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_TAGS),
getAuthorization());
Document introspection =
@@ -494,7 +494,7 @@
Entry entry = abdera.getFactory().newEntry();
entry.setContent(tag);
ClientResponse resp = abderaClient.put(baseURI + encodeURL(path +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_TAGS_REMOVED),
entry,
getAuthorization());
@@ -514,7 +514,7 @@
entry.addAuthor(comment.getUser());
entry.setContent(comment.getText());
ClientResponse resp = abderaClient.post(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_COMMENTS),
entry,
getAuthorization());
@@ -534,7 +534,7 @@
Entry entry = abdera.getFactory().newEntry();
entry.setContent(text);
ClientResponse resp = abderaClient.put(baseURI + encodeURL(commentPath
+
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_COMMENTS),
entry,
getAuthorization());
@@ -550,7 +550,7 @@
Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse = abderaClient.get(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_COMMENTS),
getAuthorization());
Document introspection = clientResponse.getDocument();
@@ -589,7 +589,7 @@
entry.setContent("" + rating);
entry.setSummary(PARAMETER_RATINGS);
ClientResponse resp = abderaClient.put(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_RATINGS),
entry,
getAuthorization());
@@ -605,7 +605,7 @@
Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse = abderaClient.get(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_RATINGS),
getAuthorization());
Document introspection = clientResponse.getDocument();
@@ -618,7 +618,7 @@
Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(path + URL_SEPARATOR +
+ abderaClient.get(baseURI + encodeURL(path +
RegistryConstants.URL_SEPARATOR +
PARAMETER_RATINGS + ":" +
userName),
getAuthorization());
Document introspection =
@@ -634,7 +634,7 @@
RequestOptions requestOptions = getAuthorization();
requestOptions.setHeader("parameters",
encodeParametersAsString(parameters));
ClientResponse resp = abderaClient.get(baseURI + encodeURL(path +
-
URL_SEPARATOR +
+
RegistryConstants.URL_SEPARATOR +
PARAMETER_QUERY),
requestOptions);
Document introspection =
@@ -694,7 +694,7 @@
requestOptions.addHeader("Action", "" + action);
requestOptions.addHeader("Author", userName);
ClientResponse resp = abderaClient.get(baseURI +
encodeURL(resourcePath +
-
URL_SEPARATOR + PARAMETER_LOGS),
+
RegistryConstants.URL_SEPARATOR + PARAMETER_LOGS),
requestOptions);
Document introspection =
resp.getDocument();
Modified:
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
==============================================================================
---
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
(original)
+++
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/VersionedResourceDAO.java
Tue Feb 5 11:51:08 2008
@@ -106,20 +106,7 @@
// get resource properties
- String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
- PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, resource.getId());
- ResultSet propResults = s3.executeQuery();
-
- Properties props = new Properties();
- while (propResults.next()) {
- String key =
propResults.getString(DatabaseConstants.PROPERTY_KEY_FIELD);
- String value =
propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
- props.put(key, value);
- }
- resource.setProperties(props);
-
- return resource;
+ return getResourceWithProperties(conn, resource);
}
public Resource getResourceByID(long artifactID, long versionNumber,
Connection conn)
@@ -182,6 +169,10 @@
// get resource properties
+ return getResourceWithProperties(conn, resource);
+ }
+
+ private Resource getResourceWithProperties(Connection conn, Resource
resource) throws SQLException {
String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
PreparedStatement s3 = conn.prepareStatement(propSQL);
s3.setLong(1, resource.getId());
@@ -272,19 +263,7 @@
}
// get resource properties
- String propSQL = "SELECT P.PKEY, P.PVALUE FROM PROPERTIES P WHERE
P.AID=?";
- PreparedStatement s3 = conn.prepareStatement(propSQL);
- s3.setLong(1, resource.getId());
- ResultSet propResults = s3.executeQuery();
-
- Properties props = new Properties();
- while (propResults.next()) {
- String key =
propResults.getString(DatabaseConstants.PROPERTY_KEY_FIELD);
- String value =
propResults.getString(DatabaseConstants.PROPERTY_VALUE_FIELD);
- props.put(key, value);
- }
- resource.setProperties(props);
- return resource;
+ return getResourceWithProperties(conn, resource);
}
/**
Modified:
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPTests.java
==============================================================================
---
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPTests.java
(original)
+++
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPTests.java
Tue Feb 5 11:51:08 2008
@@ -30,7 +30,7 @@
* <p/>
* TODO: WORK IN PROGRESS (Glen)
*/
-public class APPTests extends AbstractAPPTest implements RegistryConstants {
+public class APPTests extends AbstractAPPTest {
HttpClient client = new HttpClient();
public String buildURL(String path) {
@@ -60,7 +60,7 @@
// GET /foo;tags - 404
// Make sure metadata indicator doesn't change error code
- method = new GetMethod(buildURL("foo" + URL_SEPARATOR + "tags"));
+ method = new GetMethod(buildURL("foo" +
RegistryConstants.URL_SEPARATOR + "tags"));
responseCode = client.executeMethod(method);
assertEquals(404, responseCode);
Modified: trunk/registry/modules/documentation/src/site/site.xml
==============================================================================
--- trunk/registry/modules/documentation/src/site/site.xml (original)
+++ trunk/registry/modules/documentation/src/site/site.xml Tue Feb 5
11:51:08 2008
@@ -9,7 +9,7 @@
<src>http://ws.apache.org/axis2/images/axis.jpg</src>
</bannerRight>
<body>
- <menu name="Documnets">
+ <menu name="Documents">
<item name="Introduction" href="WSO2Registry.html" />
</menu>
<menu name="Project Information">
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev