[Registry-dev] svn commit r15769 - in trunk/registry: .
modules/core modules/core/src/main/java/org/wso2/registry
modules/core/src/main/java/org/wso2/registry/app
modules/core/src/main/java/org/wso2/registry/app/targets
modules/core/src/main/java/org/wso2/registry/aspects
modules/core/src/main/java/org/wso2/registry/jdbc
modules/core/src/main/java/org/wso2/registry/jdbc/dao
modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin
modules/core/src/main/java/org/wso2/registry/jdbc/mediatypes
modules/core/src/main/java/org/wso2/registry/jdbc/queries
modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers
modules/core/src/main/java/org/wso2/registry/jdbc/utils
modules/core/src/main/java/org/wso2/registry/secure
modules/core/src/main/java/org/wso2/registry/servlet
modules/core/src/main/java/org/wso2/registry/users/def
modules/core/src/main/resources/org/wso2/registry/i18n
modules/core/src/test/java/org/wso2/registry
modules/core/src/test/java/org/wso2/registry/app
modules/core/src/test/java/org/wso2/registry/jdbc
modules/core/src/test/resources modules/documentation
modules/documentation/xdocs modules/webapps/conf
modules/webapps/src/main/java/org/wso2/registry/web/utils
svn at wso2.org
svn at wso2.org
Thu Apr 17 20:56:22 PDT 2008
Author: glen
Date: Thu Apr 17 20:55:57 2008
New Revision: 15769
Log:
** WORK IN PROGRESS - I wanted to check in so that everyone could get a look at
the new structure, and the build does pass... but the APP tests are currently
commented out. Many of them do actually work, but I'm not going to uncomment
them until finished (hopefully by the weekend). Consider things in a somewhat
unstable state until then. The plan is to get Chathura's changes integrated
and then do a careful walk through to make sure everything works after that.
* Upgrade to Abdera 0.4.0, converting what was AtomRegistry into an Abdera CollectionAdapter, specifically one extending AbstractEntityCollectionAdapter. So basically everything comes down to using the RegistryResolver to figure out which Target type is being referenced - for regular resources/collections, we use the standard Abdera mechanisms for filling in the entries/feeds, and for everything else (comments, tags, or our other metadata) we use a custom TargetType and end up calling our own code in RegistryAdapter.extensionRequest().
* Bunch of protocol changes to get closer to https://wso2.org/wiki/display/registry/Registry+Protocol. Use POST not PUT for various things, don't use HTTP headers to carry query parameters, etc. URL structures are closer to "right" now, I think.
* Stop using System properties! Getting all the data coupled to the right places isn't quite there yet, but we need all this to work without depending on static data or system properties.
Will be cleaning this up (a bunch of the code needs JavaDocs / comments, etc) and finishing the transition in the next little while.
Added:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPUtils.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StackTraceResponseContext.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/targets/
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagCollectionURLHandler.java
- copied, changed from r15635, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependencyTest.java
- copied, changed from r15635, trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependecyTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedPropertyTest.java
- copied, changed from r15635, trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java
Removed:
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAPPServiceContext.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAtomProviderManager.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependecyTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java
Modified:
trunk/registry/modules/core/pom.xml
trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java
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/ResourceImpl.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPConstants.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/RegistryAPPTargetResolver.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StringResponseContext.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryJDBCRegistry.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/handlers/builtin/CommentCollectionURLHandler.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentURLHandler.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/queries/QueryProcessorManager.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/jdbc/utils/RegistryDataSource.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/RegistryServlet.java
trunk/registry/modules/core/src/main/java/org/wso2/registry/users/def/DefaultAuthorizer.java
trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties
trunk/registry/modules/core/src/test/java/org/wso2/registry/FactoryTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedLifeCycleTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedTagTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedVersionHandlingTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPProtocolTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/AbstractAPPTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/RegistryServer.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/ResourceHandling.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/TaggingTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/LifeCycleTest.java
trunk/registry/modules/core/src/test/resources/regtest.properties
trunk/registry/modules/documentation/pom.xml
trunk/registry/modules/documentation/xdocs/userguide.xml
trunk/registry/modules/webapps/conf/web.xml
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/utils/LifecycleUtil.java
trunk/registry/pom.xml
Modified: trunk/registry/modules/core/pom.xml
==============================================================================
--- trunk/registry/modules/core/pom.xml (original)
+++ trunk/registry/modules/core/pom.xml Thu Apr 17 20:55:57 2008
@@ -34,6 +34,7 @@
<argLine>-enableassertions</argLine>
<testFailureIgnore>false</testFailureIgnore>
<excludes>
+ <exclude>**/app/*Test.java</exclude>
<exclude>**/AbstractAPPTest.java</exclude>
</excludes>
</configuration>
@@ -98,10 +99,6 @@
</dependency>
<dependency>
<groupId>org.apache.abdera</groupId>
- <artifactId>abdera-protocol</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
<artifactId>abdera-parser</artifactId>
</dependency>
<dependency>
@@ -152,12 +149,12 @@
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty</artifactId>
- <scope>test</scope>
+ <!--<scope>test</scope>-->
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
- <scope>test</scope>
+ <!--<scope>test</scope>-->
</dependency>
</dependencies>
</project>
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/Comment.java Thu Apr 17 20:55:57 2008
@@ -60,6 +60,7 @@
public Comment(String commentText) {
this.text = commentText;
+ time = new Date();
}
public String getText() {
@@ -94,6 +95,10 @@
this.resourcePath = resourcePath;
}
+ public Object getContent() throws RegistryException {
+ return getText();
+ }
+
public String getCommentPath() {
return commentPath;
}
@@ -101,4 +106,16 @@
public void setCommentPath(String commentPath) {
this.commentPath = commentPath;
}
+
+ public String getMediaType() {
+ return "application/atom+xml";
+ }
+
+ public String getAuthorUserName() {
+ return user;
+ }
+
+ public Date getLastModified() {
+ return time;
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/LogEntry.java Thu Apr 17 20:55:57 2008
@@ -24,6 +24,8 @@
*/
public class LogEntry {
+ // Filters for log queries - these represent the possible actions that get logged.
+ public static final int ALL = -1;
public static final int UPDATE = 1;
public static final int COMMENT = 2;
public static final int TAG = 3;
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 Thu Apr 17 20:55:57 2008
@@ -19,6 +19,8 @@
package org.wso2.registry;
+import org.wso2.registry.config.RegistryContext;
+
import java.util.Date;
import java.util.Map;
@@ -247,9 +249,12 @@
/**
* Returns the logs of the activities occured in the registy.
*
+ * @see LogEntry Accepted values for action parameter
+ *
* @param resourcePath If given, only the logs related to the resource path will be returned. If
* null, logs for all resources will be returned.
- * @param action Only the logs pertaining to this action will be returned.
+ * @param action Only the logs pertaining to this action will be returned. For
+ * acceptable values, see LogEntry.
* @param userName If given, only the logs for activities done by the given user will be
* returned. If null, logs for all users will be returned.
* @param from If given, logs for activities occured after the given date will be
@@ -324,4 +329,11 @@
* @throws RegistryException If an error occurs while rolling back a transaction
*/
void rollbackTransaction() throws RegistryException;
+
+ /**
+ * Get the configuration for this Registry
+ *
+ * @return the currently active RegistryContext, or null
+ */
+ RegistryContext getRegistryContext();
}
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 Thu Apr 17 20:55:57 2008
@@ -31,7 +31,6 @@
public static final String STATUS_MESSAGE_NAME = "edit_status";
public static final String REGISTRY_CONFIG_PATH = "registry.config.path";
- public static final String REGISTRY_CONTEXT = "registry.context";
/** Built in user names */
public static final String SYSTEM_USER = "system";
@@ -130,6 +129,8 @@
public static final String RESOURCES_PATH = "resources";
+ public static final String REGISTRY_NAMESPACE = "http://wso2.org/registry";
+
private RegistryConstants() {
}
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/ResourceImpl.java Thu Apr 17 20:55:57 2008
@@ -235,6 +235,9 @@
public String getParentPath() {
return parentPath;
+// if ((path == null) || path.length() == 1) return null;
+// int i = path.lastIndexOf('/');
+// return path.substring(0, i);
}
public void setParentPath(String parentPath) {
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPConstants.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPConstants.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPConstants.java Thu Apr 17 20:55:57 2008
@@ -18,6 +18,8 @@
import javax.xml.namespace.QName;
public interface APPConstants {
+ static final String ATOM = "/atom";
+
// Custom elements in Atom feeds and entries
static final String NAMESPACE = "http://wso2.org/registry";
static final QName QNAME_AVGRATING = new QName(NAMESPACE, "AverageRating", "wso2");
@@ -25,7 +27,7 @@
static final QName COMMENTID_QNAME = new QName(NAMESPACE, "commentID");
static final String IMPORT_MEDIATYPE = "application/resource-import";
- static final String PARAMETER_VERSION = "version";
+ static final String PARAMETER_VERSION = "versions";
static final String PARAMETER_RESTORE = "restore";
static final String PARAMETER_RENAME = "rename";
static final String PARAMETER_ADD_USER = "adduser";
@@ -40,7 +42,9 @@
static final String PARAMETER_QUERY = "query";
static final String PARAMETER_RESOURCE_EXIST = "resourceExists";
- //Lifecycle
+ // Aspects
+ static final String ASPECTS = "aspects";
+ static final String ASPECT = "aspect";
static final String PARAMETER_ASSOCIATE_ASPECT = "associateAspect";
static final String PARAMETER_INVOKE_ASPECT = "invokeAspect";
static final String PARAMETER_GET_ASPECT_ACTIONS = "getAspectActions";
@@ -48,4 +52,8 @@
static final String PARAMETER_ADD_ASSOCIATION = "associate";
static final String PARAMETER_GET_ALL_ASSOCIATION = "getAllassociations";
static final String PARAMETER_GET_ALL_ASSOCIATION_FOR_TYPE = "getAssociations";
+
+ static final String ASSOCIATIONS = "associations";
+ static final QName QNAME_ASSOC = new QName(NAMESPACE, "association");
+ static final String ASSOC_TYPE = "type";
}
Added: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPUtils.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/APPUtils.java Thu Apr 17 20:55:57 2008
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2007, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.registry.app;
+
+public class APPUtils {
+ public static String generateID(String base, String suffix) {
+ return "tag:" + base + suffix;
+ }
+}
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 Thu Apr 17 20:55:57 2008
@@ -22,13 +22,11 @@
import org.apache.abdera.factory.Factory;
import org.apache.abdera.model.*;
import org.apache.abdera.parser.Parser;
-import org.apache.abdera.protocol.server.Provider;
import org.apache.abdera.protocol.server.RequestContext;
import org.apache.abdera.protocol.server.ResponseContext;
-import org.apache.abdera.protocol.server.impl.AbstractProvider;
-import org.apache.abdera.protocol.server.impl.AbstractResponseContext;
-import org.apache.abdera.protocol.server.impl.BaseResponseContext;
-import org.apache.abdera.protocol.server.impl.EmptyResponseContext;
+import org.apache.abdera.protocol.server.context.EmptyResponseContext;
+import org.apache.abdera.protocol.server.context.BaseResponseContext;
+import org.apache.abdera.protocol.server.context.AbstractResponseContext;
import org.apache.abdera.util.EntityTag;
import org.apache.abdera.util.MimeTypeHelper;
import org.apache.axiom.om.util.Base64;
@@ -53,7 +51,7 @@
import java.util.Iterator;
import java.util.Map;
-public class AtomRegistry extends AbstractProvider implements Provider, APPConstants {
+public class AtomRegistry implements APPConstants {
private Log log = LogFactory.getLog(AtomRegistry.class);
public static final String SECURE_REGISTRY = "secureRegistry";
@@ -117,7 +115,7 @@
importURL,
metadata);
} catch (RegistryException e) {
- return new StringResponseContext(abdera, e, 500);
+ return new StringResponseContext(e, 500);
}
rc = new EmptyResponseContext(200);
rc.setLocation(location);
@@ -183,7 +181,7 @@
rc = new EmptyResponseContext(200);
rc.setLocation(location);
} catch (Exception e) {
- rc = new StringResponseContext(abdera, e, 500);
+ rc = new StringResponseContext(e, 500);
}
return rc;
}
@@ -237,7 +235,7 @@
return new EmptyResponseContext(500);
}
} catch (Exception e) {
- return new StringResponseContext(abdera, e, 500);
+ return new StringResponseContext(e, 500);
}
return new EmptyResponseContext(200); // For now...
@@ -250,7 +248,7 @@
getSecureRegistry(request).delete(entry_id);
return new EmptyResponseContext(204);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else {
return new EmptyResponseContext(500);
@@ -322,7 +320,7 @@
}
return new EmptyResponseContext(200);
} catch (Exception pe) {
- return new StringResponseContext(request.getAbdera(), pe, 500);
+ return new StringResponseContext(pe, 500);
}
}
@@ -358,7 +356,7 @@
response.setHeader("WWW-Authenticate", "Basic realm=\"WSO2-Registry\"");
return response;
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
Feed feed;
@@ -391,7 +389,7 @@
abdera, "versionLink",
feed);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_TAGS.equals(operation)) {
// if the user [parameter] name is null then need to return all the
@@ -407,7 +405,7 @@
feed = populateFeed(abdera, baseURI, entry_id, resource, false);
}
} catch (RegistryException e) {
- return new StringResponseContext(abdera, e, 500);
+ return new StringResponseContext(e, 500);
}
}
@@ -424,7 +422,7 @@
} catch (ResourceNotFoundException e) {
return new EmptyResponseContext(404);
} catch (RegistryException e) {
- return new StringResponseContext(abdera, e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_COMMENTS.equals(operation)) {
if (parameter == null) {
@@ -433,12 +431,12 @@
try {
resource = getSecureRegistry(request).get(entry_id);
} catch (RegistryException e) {
- return new StringResponseContext(abdera, e, 500);
+ return new StringResponseContext(e, 500);
}
try {
feed = populateFeed(abdera, baseURI, entry_id, resource, false);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
}
} else if (PARAMETER_TAG_PATHS.equals(operation)) {
@@ -451,7 +449,7 @@
try {
feed = getFeedForLogs(abdera, resourcePath, from, to, author, action, request);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_QUERY.equals(operation)) {
try {
@@ -461,7 +459,7 @@
resource = getSecureRegistry(request).executeQuery(resourcePath, parameters);
feed = populateFeed(abdera, baseURI, resourcePath, resource, true);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_RESOURCE_EXIST.equals(operation)) {
@@ -470,13 +468,13 @@
try {
feed = getFeedAllAssociation(abdera, resourcePath, null ,request);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_GET_ALL_ASSOCIATION_FOR_TYPE.equals(operation)) {
try {
feed = getFeedAllAssociation(abdera, resourcePath , parameter, request);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else if (PARAMETER_GET_ASPECT_ACTIONS.equals(operation)) {
try {
@@ -495,7 +493,7 @@
abdera, "aspectActionsLink",
feed);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
} else {
return createErrorResponse();
@@ -505,7 +503,7 @@
try {
feed = populateFeed(abdera, baseURI, entry_id, resource, false);
} catch (RegistryException e) {
- return new StringResponseContext(request.getAbdera(), e, 500);
+ return new StringResponseContext(e, 500);
}
}
@@ -561,7 +559,7 @@
Feed feed = getFeedInstance(abdera);
//Properties in the resource will be send as attributes in the feed object
RemoteRegistry.addPropertyExtensionElement(resource.getProperties(),
- abdera,
+ abdera.getFactory(),
feed,
PropertyExtensionFactory.PROPERTIES,
PropertyExtensionFactory.PROPERTY);
@@ -893,10 +891,10 @@
for (Comment comment : comments) {
Entry entry = abdera.getFactory().newEntry();
entry.addLink(comment.getResourcePath(), "path");
- entry.addLink(comment.getCommentPath(), "direct");
- entry.addLink(comment.getCommentPath(), "self");
+ entry.addLink(comment.getPath(), "direct");
+ entry.addLink(comment.getPath(), "self");
entry.setTitle(comment.getResourcePath());
- entry.setId("http://wso2.org/registry" + comment.getCommentPath());
+ entry.setId("http://wso2.org/registry" + comment.getPath());
entry.addAuthor(comment.getUser());
entry.setUpdated(comment.getTime());
entry.setContent(comment.getText());
@@ -946,7 +944,7 @@
properties.put(key, count);
}
RemoteRegistry.addPropertyExtensionElement(properties,
- abdera,
+ abdera.getFactory(),
entry,
PropertyExtensionFactory.TAGS,
PropertyExtensionFactory.TAG);
@@ -1042,12 +1040,11 @@
feed.addLink("", "self");
feed.setUpdated(new Date());
- for (int i = 0; i < associations.length; i++) {
- Association association = associations[i];
+ for (Association association : associations) {
Entry entry = abdera.getFactory().newEntry();
entry.setContent(association.getDestinationPath());
- if(associateType == null) {
- entry.setSummary(association.getAssociationType()) ;
+ if (associateType == null) {
+ entry.setSummary(association.getAssociationType());
}
feed.addEntry(entry);
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAPPTargetResolver.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAPPTargetResolver.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAPPTargetResolver.java Thu Apr 17 20:55:57 2008
@@ -23,7 +23,7 @@
import org.apache.abdera.protocol.server.RequestContext;
import org.apache.abdera.protocol.server.Target;
import org.apache.abdera.protocol.server.TargetType;
-import org.apache.abdera.protocol.server.impl.DefaultTarget;
+import org.apache.abdera.protocol.server.impl.SimpleTarget;
public class RegistryAPPTargetResolver implements Resolver<Target> {
public Target resolve(Request request) {
@@ -49,7 +49,7 @@
return null;
}
- public static class RegistryTarget extends DefaultTarget {
+ public static class RegistryTarget extends SimpleTarget {
public RegistryTarget(TargetType type, RequestContext context) {
super(type, context);
}
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 Thu Apr 17 20:55:57 2008
@@ -31,6 +31,7 @@
import org.wso2.registry.Comment;
import org.wso2.registry.*;
import org.wso2.registry.Collection;
+import org.wso2.registry.config.RegistryContext;
import org.wso2.registry.exceptions.ResourceNotFoundException;
import org.wso2.registry.i18n.Messages;
@@ -38,18 +39,20 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.MalformedURLException;
+import java.net.URLEncoder;
import java.util.*;
public class RemoteRegistry implements Registry, APPConstants {
-
private String baseURI;
private Log log = LogFactory.getLog(RemoteRegistry.class);
//This will keep the value of username and the password for authorization
private String authorizationString = null;
private String username = null;
+ Abdera abdera = new Abdera();
/**
* To create a remote registry need to provide a URL of a remote registry and the URL should be
@@ -105,21 +108,28 @@
}
public Resource get(String path) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(path), getAuthorization());
+ abderaClient.get(baseURI + "/atom" + encodeURL(path), getAuthorization());
if (clientResponse.getType() == Response.ResponseType.CLIENT_ERROR ||
clientResponse.getType() == Response.ResponseType.SERVER_ERROR) {
throw new ResourceNotFoundException(path);
}
- Document introspection = clientResponse.getDocument();
- Feed feed = (Feed)introspection.getRoot();
- String state = feed.getSimpleExtension(new QName(NAMESPACE, "state"));
- if (state != null && state.equals("Deleted")) {
- throw new ResourceNotFoundException(path);
+ Element introspection = clientResponse.getDocument().getRoot();
+ if (introspection instanceof Feed) {
+ // This is a collection
+ Feed feed = (Feed)introspection;
+ String state = feed.getSimpleExtension(new QName(NAMESPACE, "state"));
+ if (state != null && state.equals("Deleted")) {
+ throw new ResourceNotFoundException(path);
+ }
+ return createResourceFromFeed(feed, false);
}
- return createResourceFromFeed(feed, false);
+
+ Entry entry = (Entry)introspection;
+ ResourceImpl resource = createResourceFromEntry(entry);
+ resource.setPath(path);
+ return resource;
}
/**
@@ -133,10 +143,9 @@
* @throws org.wso2.registry.RegistryException
* : If user is unable to open the URL connection
*/
- private Resource createResourceFromFeed(Feed feed, boolean isQuery) throws RegistryException {
- String directoryStr = feed.getSimpleExtension(new QName(NAMESPACE, "directory"));
- boolean isDirectory = directoryStr != null && "true".equals(directoryStr);
- ResourceImpl resource = isDirectory ? new CollectionImpl() : new ResourceImpl();
+ private ResourceImpl createResourceFromFeed(Feed feed, boolean isQuery)
+ throws RegistryException {
+ CollectionImpl resource = new CollectionImpl();
Properties properties = feed.getExtension(PropertyExtensionFactory.PROPERTIES);
RemoteRegistry.createPropertiesFromExtensionElement(properties, resource);
if (feed.getAuthor() != null) {
@@ -157,10 +166,6 @@
if (mediaType != null) {
resource.setMediaType(mediaType);
}
- String parentPath = feed.getSimpleExtension(new QName(NAMESPACE, "parentPath"));
- if (parentPath != null) {
- resource.setParentPath(parentPath);
- }
resource.setPath(feed.getTitle());
resource.setDescription(feed.getSubtitle());
String state = feed.getSimpleExtension(new QName(NAMESPACE, "state"));
@@ -168,93 +173,115 @@
resource.setState(RegistryConstants.DELETED_STATE);
}
- if (isDirectory) {
- String isComments = feed.getSimpleExtension(COMMENTS_QNAME);
- if (isComments != null) {
- resource.setContent(getCommentsFromFeed(feed));
- } else {
- List entries = feed.getEntries();
- if (entries != null) {
- String[] childNodes = new String[entries.size()];
- for (int i = 0; i < entries.size(); i++) {
- Entry entry = (Entry)entries.get(i);
- if (isQuery) {
- childNodes[i] = entry.getLink("queryResult").getHref().toString();
- } else {
- childNodes[i] = entry.getLink("path").getHref().toString();
- }
-
- }
- resource.setContent(childNodes);
- }
- }
+ String isComments = feed.getSimpleExtension(COMMENTS_QNAME);
+ if (isComments != null) {
+ resource.setContent(getCommentsFromFeed(feed));
} else {
List entries = feed.getEntries();
- // if the resource is not a directory then we have only one entry
- Entry entry = (Entry)entries.get(0);
- Link link = entry.getLink("edit-media");
- if (link != null) {
- try {
- URL url = new URL(link.getHref().toString());
- URLConnection uc = url.openConnection();
- if (authorizationString != null) {
- uc.setRequestProperty("Authorization", authorizationString);
+ if (entries != null) {
+ String[] childNodes = new String[entries.size()];
+ for (int i = 0; i < entries.size(); i++) {
+ Entry entry = (Entry)entries.get(i);
+ if (isQuery) {
+ childNodes[i] = entry.getLink("queryResult").getHref().toString();
+ } else {
+ childNodes[i] = entry.getLink("path").getHref().toString();
}
- InputStream in = url.openStream();
- //int read;
- //ByteArrayOutputStream out = new ByteArrayOutputStream();
- //while ((read = in.read()) > 0) {
- // out.write(read);
- //}
- //out.flush();
- resource.setContentStream(in);
- return resource;
- } catch (IOException e) {
- throw new RegistryException(Messages.getMessage("unable.to.receive",
- link.getHref().toString()));
+
+ }
+ resource.setContent(childNodes);
+ }
+ }
+
+ return resource;
+ }
+
+ private ResourceImpl createResourceFromEntry(Entry entry) throws RegistryException {
+ ResourceImpl resource = new ResourceImpl();
+
+ // TODO -
+ resource.setPath(entry.getId().toString());
+
+ Properties properties = entry.getExtension(PropertyExtensionFactory.PROPERTIES);
+ RemoteRegistry.createPropertiesFromExtensionElement(properties, resource);
+ if (entry.getAuthor() != null) {
+ resource.setAuthorUserName(entry.getAuthor().getName());
+ }
+ resource.setLastModified(entry.getUpdated());
+ String createdDate = entry.getSimpleExtension(new QName(NAMESPACE, "createdTime"));
+ if (createdDate != null) {
+ resource.setCreatedTime(new Date(Long.parseLong(createdDate)));
+ }
+
+ String lastUpdatedUser = entry.getSimpleExtension(new QName(NAMESPACE,
+ "lastUpdatedUser"));
+ if (lastUpdatedUser != null) {
+ resource.setLastUpdaterUserName(lastUpdatedUser);
+ }
+
+ // TODO - get content-type in an Atom-appropriate way
+// String mediaType = entry.getSimpleExtension(new QName(NAMESPACE, "mediaType"));
+
+ resource.setDescription(entry.getSummary());
+
+ Link link = entry.getLink("edit-media");
+ if (link != null) {
+ try {
+ URL url = new URL(new URL(baseURI), link.getHref().toString());
+ URLConnection uc = url.openConnection();
+ if (authorizationString != null) {
+ uc.setRequestProperty("Authorization", authorizationString);
}
+ InputStream in = url.openStream();
+ resource.setContentStream(in);
+ return resource;
+ } catch (IOException e) {
+ throw new RegistryException(Messages.getMessage("unable.to.receive",
+ link.getHref().toString()));
}
- String content1 = entry.getContent();
- resource.setContent(content1);
}
+ String content1 = entry.getContent();
+ resource.setContent(content1);
return resource;
}
public boolean resourceExists(String path) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- ClientResponse response = abderaClient.head(baseURI + encodeURL(path), getAuthorization());
+ ClientResponse response = abderaClient.head(baseURI + APPConstants.ATOM + encodeURL(path),
+ getAuthorization());
return (response.getType() == Response.ResponseType.SUCCESS);
}
public String put(String suggestedPath, Resource resource) throws RegistryException {
- // Figure out where we're POSTing to...
+ // Does the resource already exist? If so this is an update (PUT) not a create (POST)
+ boolean alreadyExists = resourceExists(suggestedPath);
int idx = suggestedPath.lastIndexOf("/");
String relativePath = suggestedPath.substring(idx + 1);
String parentPath = idx > 1 ? suggestedPath.substring(0, idx) : "/";
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setSummary(resource.getDescription());
- if (resource.getAuthorUserName() != null) {
- entry.addAuthor(resource.getAuthorUserName());
- } else {
+ final Factory factory = abdera.getFactory();
+ boolean isCollection = resource instanceof Collection;
+
+ ExtensibleElement element;
+ if (isCollection) {
+ Feed feed = factory.newFeed();
+ feed.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
+// feed.setId(encodeURL(suggestedPath));
+ feed.setTitle(suggestedPath);
+ feed.setSubtitle(resource.getDescription());
+ feed.addAuthor(username);
+ feed.setUpdated(new Date());
+ element = feed;
+ } else {
+ Entry entry = factory.newEntry();
+ entry.setId(baseURI + APPConstants.ATOM + encodeURL(suggestedPath));
+// entry.setId(encodeURL(suggestedPath));
+ entry.setTitle(suggestedPath);
+ entry.setSummary(resource.getDescription());
entry.addAuthor(username);
- }
- java.util.Properties properties = resource.getProperties();
- addPropertyExtensionElement(properties, abdera, entry, PropertyExtensionFactory.PROPERTIES,
- PropertyExtensionFactory.PROPERTY);
- entry.addSimpleExtension(new QName(NAMESPACE, "mediaType"), resource.getMediaType());
- entry.addSimpleExtension(new QName(NAMESPACE, "parentPath"), resource.getParentPath());
- if (((ResourceImpl)resource).isContentModified()) {
- entry.addSimpleExtension(new QName(NAMESPACE, "contentModified"), "true");
- }
- if (resource instanceof Collection) {
- entry.addSimpleExtension(new QName(NAMESPACE, "directory"), "true");
- } else {
- entry.addSimpleExtension(new QName(NAMESPACE, "directory"), "false");
+ entry.setUpdated(new Date());
Object content = resource.getContent();
if (content != null && content instanceof byte[]) {
ByteArrayInputStream in = new ByteArrayInputStream((byte[])content);
@@ -264,25 +291,44 @@
} else {
entry.setContent((String)content);
}
+ element = entry;
+ }
+ java.util.Properties properties = resource.getProperties();
+ addPropertyExtensionElement(properties, factory, element,
+ PropertyExtensionFactory.PROPERTIES,
+ PropertyExtensionFactory.PROPERTY);
+ element.addSimpleExtension(new QName(NAMESPACE, "mediaType"), resource.getMediaType());
+ element.addSimpleExtension(new QName(NAMESPACE, "parentPath"), resource.getParentPath());
+ if (((ResourceImpl)resource).isContentModified()) {
+ element.addSimpleExtension(new QName(NAMESPACE, "contentModified"), "true");
}
RequestOptions requestOptions = getAuthorization();
requestOptions.setSlug(relativePath);
- ClientResponse resp =
- abderaClient.post(baseURI + encodeURL(parentPath), entry, requestOptions);
+ ClientResponse resp;
+ if (!alreadyExists) {
+ resp = abderaClient.post(baseURI + APPConstants.ATOM + encodeURL(parentPath),
+ element, requestOptions);
+ } else {
+ resp = abderaClient.put(baseURI + APPConstants.ATOM + encodeURL(suggestedPath),
+ element, requestOptions);
+ }
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.add", suggestedPath));
} else {
log.error(Messages.getMessage("add.resource.fail", suggestedPath));
throw new RegistryException(Messages.getMessage("add.resource.fail", suggestedPath));
}
- String resultPath = resp.getLocation().getASCIIPath();
- ResourceImpl impl = (ResourceImpl)resource;
- impl.setPath(resultPath);
- // todo - fix this to use util routine?
- int i = resultPath.lastIndexOf('/');
- impl.setParentPath(i == 0 ? "/" : resultPath.substring(0, i));
+ String resultPath = suggestedPath;
+ if (!alreadyExists) {
+ resultPath = resp.getLocation().getASCIIPath();
+ }
+// ResourceImpl impl = (ResourceImpl)resource;
+// impl.setPath(resultPath);
+// // todo - fix this to use util routine?
+// int i = resultPath.lastIndexOf('/');
+// impl.setParentPath(i == 0 ? "/" : resultPath.substring(0, i));
return resultPath;
}
@@ -310,18 +356,17 @@
* </node1name>
*
* @param properties : List of Name value pairs
- * @param abdera : Abdera instance
+ * @param factory : Abdera Factory
* @param entry : Instanc of entery where extension element need to add
* @param node1name : Name of node 1
* @param node2Name : Name of node 2
*/
public static void addPropertyExtensionElement(java.util.Properties properties,
- Abdera abdera,
+ Factory factory,
ExtensibleElement entry,
QName node1name,
QName node2Name) {
if (properties != null) {
- Factory factory = abdera.getFactory();
Properties propertyElement = factory.newExtensionElement(node1name);
Iterator keys = properties.keySet().iterator();
while (keys.hasNext()) {
@@ -367,7 +412,6 @@
public String importResource(String suggestedPath, String sourceURL, Resource metadata)
throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
String postData = "?importURL=" + sourceURL;
@@ -375,14 +419,17 @@
RequestOptions opts = getAuthorization();
opts.setSlug(suggestedPath);
opts.setContentType(IMPORT_MEDIATYPE);
- ClientResponse response = abderaClient.post(baseURI + encodeURL(postData), bis, opts);
+ ClientResponse response =
+ abderaClient.post(baseURI + APPConstants.ATOM + encodeURL(postData),
+ bis,
+ opts);
return response.getLocation().toString();
}
public void delete(String path) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- ClientResponse resp = abderaClient.delete(baseURI + encodeURL(path), getAuthorization());
+ ClientResponse resp = abderaClient.delete(baseURI + APPConstants.ATOM + encodeURL(path),
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.deleted", path));
} else {
@@ -393,15 +440,14 @@
public String rename(String currentPath, String newPath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setContent(newPath);
+ ByteArrayInputStream is = new ByteArrayInputStream(newPath.getBytes());
ClientResponse resp =
- abderaClient.post(baseURI + encodeURL(currentPath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_RENAME),
- entry,
+ abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(currentPath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_RENAME),
+ is,
getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.rename", currentPath));
@@ -413,15 +459,14 @@
}
public String[] getVersions(String path) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(path +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_VERSION),
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(path +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_VERSION),
getAuthorization());
- Document introspection =
- clientResponse.getDocument();
+ Document introspection = clientResponse.getDocument();
Feed feed = (Feed)introspection.getRoot();
List entries = feed.getEntries();
if (entries != null) {
@@ -436,14 +481,14 @@
}
public void restoreVersion(String versionPath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(versionPath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_RESTORE),
- entry,
- getAuthorization());
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(versionPath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_RESTORE),
+ entry,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.restoreded", versionPath));
} else {
@@ -454,16 +499,17 @@
public void addAssociation(String associationType, String sourcePath, String associationPaths)
throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setContent(associationPaths);
- entry.setSummary(associationType);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(sourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_ADD_ASSOCIATION),
- entry,
- getAuthorization());
+ final Factory factory = abdera.getFactory();
+ Element el = factory.newElement(QNAME_ASSOC);
+ el.setAttributeValue(ASSOC_TYPE, associationType);
+ el.setText(associationPaths);
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(sourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ ASSOCIATIONS),
+ el,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.associated", sourcePath));
} else {
@@ -474,16 +520,18 @@
public Association[] getAllAssociations(String resourcePath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- ClientResponse clientResponse = abderaClient.get(baseURI +
- encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_GET_ALL_ASSOCIATION),
- getAuthorization());
- Document introspection =
- clientResponse.getDocument();
+ ClientResponse clientResponse = abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ ASSOCIATIONS),
+ getAuthorization());
+ Document introspection = clientResponse.getDocument();
Feed feed = (Feed)introspection.getRoot();
+ return getAssociationsFromFeed(feed, resourcePath);
+ }
+
+ public static Association [] getAssociationsFromFeed(Feed feed, String resourcePath) {
List entries = feed.getEntries();
Association associations[] = null;
if (entries != null) {
@@ -501,15 +549,14 @@
}
public Association[] getAssociations(String resourcePath, String associationType) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- ClientResponse clientResponse = abderaClient.get(baseURI +
- encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_GET_ALL_ASSOCIATION_FOR_TYPE + ":" + associationType),
- getAuthorization());
- Document introspection =
- clientResponse.getDocument();
+ ClientResponse clientResponse =
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath + RegistryConstants.URL_SEPARATOR +
+ ASSOCIATIONS + ":" +
+ associationType),
+ getAuthorization());
+ Document introspection = clientResponse.getDocument();
Feed feed = (Feed)introspection.getRoot();
List entries = feed.getEntries();
Association associations[] = null;
@@ -528,17 +575,17 @@
}
public void applyTag(String resourcePath, String tag) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
entry.setContent(tag);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_TAGS),
- entry,
- getAuthorization());
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_TAGS),
+ entry,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
- log.info(Messages.getMessage("resource.tagged", resourcePath));
+ log.debug(Messages.getMessage("resource.tagged", resourcePath));
} else {
log.error(Messages.getMessage("resource.tag.fails", resourcePath));
throw new RegistryException(Messages.getMessage("resource.tag.fails", resourcePath));
@@ -546,18 +593,9 @@
}
public TaggedResourcePath[] getResourcePathsWithTag(String tag) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- String taggingUri;
- if (baseURI.endsWith("/")) {
- taggingUri = baseURI;
- } else {
- taggingUri = baseURI + "/";
- }
- ClientResponse clientResponse = abderaClient.get(taggingUri +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_TAG_PATHS +
- ":" + tag, getAuthorization());
+ ClientResponse clientResponse = abderaClient.get(baseURI + "/tags/" + tag,
+ getAuthorization());
Document introspection =
clientResponse.getDocument();
Feed feed = (Feed)introspection.getRoot();
@@ -590,9 +628,8 @@
}
public Tag[] getTags(String resourcePath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- ClientResponse clientResponse = abderaClient.get(baseURI +
+ ClientResponse clientResponse = abderaClient.get(baseURI + APPConstants.ATOM +
encodeURL(resourcePath +
RegistryConstants.URL_SEPARATOR +
PARAMETER_TAGS),
@@ -617,13 +654,13 @@
}
public void removeTag(String path, String tag) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
entry.setContent(tag);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(path +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_TAGS_REMOVED),
+ ClientResponse resp = abderaClient.put(baseURI + APPConstants.ATOM +
+ encodeURL(path +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_TAGS_REMOVED),
entry,
getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
@@ -635,16 +672,18 @@
}
public String addComment(String resourcePath, Comment comment) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
+ entry.setId("tag:commentID"); // TODO - generate real ID
+ entry.setTitle("Comment");
entry.setUpdated(comment.getTime());
entry.addAuthor(comment.getUser());
entry.setContent(comment.getText());
ClientResponse resp =
- abderaClient.post(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_COMMENTS),
+ abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_COMMENTS),
entry,
getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
@@ -658,13 +697,13 @@
public void editComment(String commentPath, String text) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
entry.setContent(text);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(commentPath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_COMMENTS),
+ ClientResponse resp = abderaClient.put(baseURI + APPConstants.ATOM +
+ encodeURL(commentPath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_COMMENTS),
entry,
getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
@@ -676,12 +715,12 @@
}
public Comment[] getComments(String resourcePath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_COMMENTS),
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_COMMENTS),
getAuthorization());
Document introspection = clientResponse.getDocument();
Element element = introspection.getRoot();
@@ -698,12 +737,14 @@
Entry entry = (Entry)entries.get(i);
Comment comment = new Comment();
comment.setTime(entry.getUpdated());
- if (entry.getLink("path") != null) {
- comment.setResourcePath(entry.getLink("path").getHref().toString());
+ final Link resourceLink = entry.getLink("resourcePath");
+ if (resourceLink != null) {
+ comment.setResourcePath(resourceLink.getHref().toString());
}
if (entry.getLink("direct") != null) {
- comment.setCommentPath(entry.getLink("direct").getHref().toString());
+ comment.setPath(entry.getLink("direct").getHref().toString());
}
+ comment.setPath(entry.getId().toString());
comment.setText(entry.getContent());
comment.setUser(entry.getAuthor().getName());
comments[i] = comment;
@@ -713,16 +754,14 @@
}
public void rateResource(String resourcePath, int rating) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setContent("" + rating);
- entry.setSummary(PARAMETER_RATINGS);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_RATINGS),
- entry,
- getAuthorization());
+ ByteArrayInputStream is = new ByteArrayInputStream(Integer.toString(rating).getBytes());
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_RATINGS),
+ is,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.rated", resourcePath));
} else {
@@ -732,12 +771,12 @@
}
public float getAverageRating(String resourcePath) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_RATINGS),
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_RATINGS),
getAuthorization());
// TODO!!! Otherwise we get a ClassCastException below...
@@ -752,11 +791,11 @@
}
public int getRating(String path, String userName) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI + encodeURL(path + RegistryConstants.URL_SEPARATOR +
- PARAMETER_RATINGS + ":" + userName),
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(path + RegistryConstants.URL_SEPARATOR +
+ PARAMETER_RATINGS + ":" + userName),
getAuthorization());
Document introspection =
clientResponse.getDocument();
@@ -766,34 +805,40 @@
}
public Collection executeQuery(String path, Map parameters) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
RequestOptions requestOptions = getAuthorization();
- requestOptions.setHeader("parameters", encodeParametersAsString(parameters));
- ClientResponse resp = abderaClient.get(baseURI + encodeURL(path +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_QUERY),
+ ClientResponse resp = abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(path +
+ "?" +
+ buildQueryString(parameters)),
requestOptions);
- Document introspection =
- resp.getDocument();
+ Document introspection = resp.getDocument();
Feed feed = (Feed)introspection.getRoot();
return (Collection)createResourceFromFeed(feed, true);
}
- public static String encodeParametersAsString(Map parameters) {
- String value = "";
+ public static String buildQueryString(Map parameters) {
+ StringBuffer buffer = new StringBuffer();
+ boolean first = true;
Iterator iParams = parameters.keySet().iterator();
while (iParams.hasNext()) {
- String paramNumber = (String)iParams.next();
- String paramValue = (String)parameters.get(paramNumber);
-
- if (iParams.hasNext()) {
- value = value + paramNumber + ":" + paramValue + "#";
+ String name = (String)iParams.next();
+ String value = (String)parameters.get(name);
+ if (!first) {
+ buffer.append("&");
} else {
- value = value + paramNumber + ":" + paramValue;
+ first = false;
+ }
+ try {
+ buffer.append(URLEncoder.encode(name, "utf-8"));
+ buffer.append("=");
+ buffer.append(URLEncoder.encode(value, "utf-8"));
+ } catch (UnsupportedEncodingException e) {
+ // What the heck?? :)
+ return "";
}
}
- return value;
+ return buffer.toString();
}
public static Map decodeParametesAsString(String value) {
@@ -820,7 +865,6 @@
Date to,
boolean recentFirst) throws RegistryException {
- Abdera abdera = new Abdera();
if (resourcePath == null || "".equals(resourcePath)) {
resourcePath = "/";
}
@@ -830,9 +874,10 @@
requestOptions.addDateHeader("FromDate", from);
requestOptions.addHeader("Action", "" + action);
requestOptions.addHeader("Author", userName);
- ClientResponse resp = abderaClient.get(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_LOGS),
+ ClientResponse resp = abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ PARAMETER_LOGS),
requestOptions);
Document introspection =
resp.getDocument();
@@ -878,7 +923,6 @@
String confirmpassword ,
String roleName ,
String friendlyName) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
Entry entry = abdera.getFactory().newEntry();
entry.addSimpleExtension(new QName(NAMESPACE, "username"), userName);
@@ -887,24 +931,23 @@
entry.addSimpleExtension(new QName(NAMESPACE, "rolename"), roleName);
entry.addSimpleExtension(new QName(NAMESPACE, "friendlyName"), friendlyName);
- abderaClient.post(baseURI + encodeURL(RegistryConstants.URL_SEPARATOR +
-
- PARAMETER_ADD_USER),
- entry,
- getAuthorization());
+ abderaClient.post(baseURI + APPConstants.ATOM + encodeURL(RegistryConstants.URL_SEPARATOR +
+ PARAMETER_ADD_USER),
+ entry,
+ getAuthorization());
}
public void associateAspect(String resourcePath, String aspect) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setContent("" + aspect);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_ASSOCIATE_ASPECT),
- entry,
- getAuthorization());
+ // POST as text to "<resource>;aspects"
+ ByteArrayInputStream is = new ByteArrayInputStream(aspect.getBytes());
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ ASPECTS),
+ is,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("resource.associated", resourcePath , aspect));
} else {
@@ -914,16 +957,19 @@
}
public void invokeAspect(String resourcePath, String aspectName, String action) throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
- Entry entry = abdera.getFactory().newEntry();
- entry.setContent("" + aspectName);
- entry.setSummary(action);
- ClientResponse resp = abderaClient.put(baseURI + encodeURL(resourcePath +
- RegistryConstants.URL_SEPARATOR +
- PARAMETER_INVOKE_ASPECT),
- entry,
- getAuthorization());
+
+ // The content doesn't really matter here, so this is a placeholder for now.
+ // Later on we'll likely want to support parameterized invocations, so we'll likely
+ // enable posting form-encoded data.
+ ByteArrayInputStream is = new ByteArrayInputStream("invoke".getBytes());
+ ClientResponse resp = abderaClient.post(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath +
+ RegistryConstants.URL_SEPARATOR +
+ ASPECT + "(" + aspectName + ")" +
+ action),
+ is,
+ getAuthorization());
if (resp.getType() == Response.ResponseType.SUCCESS) {
log.info(Messages.getMessage("invokeAspect", resourcePath , aspectName , action));
} else {
@@ -949,14 +995,13 @@
public String[] getAspectActions(String resourcePath, String aspectName)
throws RegistryException {
- Abdera abdera = new Abdera();
AbderaClient abderaClient = new AbderaClient(abdera);
ClientResponse clientResponse =
- abderaClient.get(baseURI +encodeURL(resourcePath + RegistryConstants.URL_SEPARATOR +
- PARAMETER_GET_ASPECT_ACTIONS + ":" + aspectName),
- getAuthorization());
- Document introspection =
- clientResponse.getDocument();
+ abderaClient.get(baseURI + APPConstants.ATOM +
+ encodeURL(resourcePath + RegistryConstants.URL_SEPARATOR +
+ ASPECTS + ":" + aspectName),
+ getAuthorization());
+ Document introspection = clientResponse.getDocument();
Feed feed = (Feed)introspection.getRoot();
List entries = feed.getEntries();
if (entries != null) {
@@ -969,4 +1014,8 @@
}
return new String[0];
}
+
+ public RegistryContext getRegistryContext() {
+ return null;
+ }
}
Added: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StackTraceResponseContext.java
==============================================================================
--- (empty file)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StackTraceResponseContext.java Thu Apr 17 20:55:57 2008
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2007, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wso2.registry.app;
+
+import org.apache.abdera.protocol.server.context.SimpleResponseContext;
+import org.wso2.registry.secure.AuthorizationFailedException;
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class StackTraceResponseContext extends SimpleResponseContext {
+ /** Set this to false to squelch stack traces */
+ public static boolean emitStackTraces = true;
+
+ Exception e;
+
+ public StackTraceResponseContext(Exception e) {
+ this.e = e;
+ if (e instanceof AuthorizationFailedException) {
+ setStatus(401);
+ setHeader("WWW-Authenticate", "Basic realm=\"WSO2-Registry\"");
+ } else {
+ setStatus(500);
+ }
+ }
+
+ /**
+ * Write either the full stack trace or just the Exception message, depending on config
+ *
+ * @param writer the Writer connected to the HTTP response
+ * @throws IOException
+ */
+ protected void writeEntity(Writer writer) throws IOException {
+ if (emitStackTraces) {
+ e.printStackTrace(new PrintWriter(writer));
+ } else {
+ writer.write(e.getMessage());
+ }
+ writer.flush();
+ }
+
+ public boolean hasEntity() {
+ return true;
+ }
+}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StringResponseContext.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StringResponseContext.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/app/StringResponseContext.java Thu Apr 17 20:55:57 2008
@@ -16,7 +16,7 @@
package org.wso2.registry.app;
import org.apache.abdera.Abdera;
-import org.apache.abdera.protocol.server.impl.AbstractResponseContext;
+import org.apache.abdera.protocol.server.context.AbstractResponseContext;
import java.io.*;
@@ -25,17 +25,14 @@
* element, with a specified response code.
*/
public class StringResponseContext extends AbstractResponseContext {
- Abdera abdera;
String message;
- public StringResponseContext(Abdera abdera, String message, int status) {
- this.abdera = abdera;
+ public StringResponseContext(String message, int status) {
this.message = message;
setStatus(status);
}
- public StringResponseContext(Abdera abdera, Exception e, int status) {
- this.abdera = abdera;
+ public StringResponseContext(Exception e, int status) {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
message = writer.getBuffer().toString();
@@ -52,8 +49,8 @@
public void writeTo(Writer writer) throws IOException {
if (hasEntity()) {
- abdera.newStreamWriter().setWriter(writer).startElement("result")
- .writeElementText(message).endElement().flush();
+ writer.write(message);
+ writer.flush();
}
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/aspects/DefaultLifecycle.java Thu Apr 17 20:55:57 2008
@@ -103,8 +103,7 @@
// There has got to be a better way of doing this. Do we really need to be messing
// around with VersionedResourceDAO and realms in here?
- RegistryContext registryContext = (RegistryContext)System.
- getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
+ RegistryContext registryContext = context.getRegistry().getRegistryContext();
VersionedResourceDAO versionedResourceDAO =
new VersionedResourceDAO(registryContext.getDataSource());
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryJDBCRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryJDBCRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/InMemoryJDBCRegistry.java Thu Apr 17 20:55:57 2008
@@ -17,8 +17,6 @@
package org.wso2.registry.jdbc;
import org.wso2.registry.RegistryException;
-import org.wso2.registry.RegistryConstants;
-import org.wso2.registry.config.RegistryContext;
import org.wso2.registry.i18n.Messages;
import org.wso2.registry.jdbc.hsql.DBUtils;
import org.wso2.registry.jdbc.realm.RegistryRealm;
@@ -71,9 +69,7 @@
INMEMORY_DB_PASSWORD);
startInProcessDatabase(dataSource);
- RegistryContext registryContext = (RegistryContext)System.
- getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
- if (registryContext !=null) {
+ if (registryContext != null) {
registryContext.setDataSource(dataSource);
}
super.configure(dataSource, registryRealm);
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 Thu Apr 17 20:55:57 2008
@@ -67,10 +67,11 @@
private RatingsDAO ratingsDAO = null;
private LogsDAO logsDAO = null;
- private HandlerManager handlerManager;
- private Repository repository;
+ protected HandlerManager handlerManager;
+ protected Repository repository;
private UserRealm defaultRealm = null;
+ protected RegistryContext registryContext;
/**
* Default constructor. JDBC registry should be configured using the configure(...) method, if
@@ -131,7 +132,7 @@
//urlHandlerManager = new URLHandlerManager(dataSource, realm, this);
//mediaTypeManager = new MediaTypeManager(dataSource, realm, this);
- queryProcessorManager = new QueryProcessorManager(dataSource, realm);
+ queryProcessorManager = new QueryProcessorManager(dataSource, realm, this);
resourceDAO = new VersionedResourceDAO(dataSource);
tagsDAO = new TagsDAO(dataSource);
@@ -1316,10 +1317,10 @@
ratingCollectionURLMatcher.setGetPattern(".+;ratings");
handlerManager.addHandler(0, ratingCollectionURLMatcher, ratingCollectionURLHandler);
- TagURLHandler tagURLHandler = new TagURLHandler();
+ TagCollectionURLHandler tagCollectionURLHandler = new TagCollectionURLHandler();
URLMatcher tagURLMatcher = new URLMatcher();
- tagURLMatcher.setGetPattern(".+;.+:.+:.+");
- handlerManager.addHandler(0, tagURLMatcher, tagURLHandler);
+ tagURLMatcher.setGetPattern(".+;tags");
+ handlerManager.addHandler(0, tagURLMatcher, tagCollectionURLHandler);
}
@@ -1337,8 +1338,6 @@
private Aspect getAspect(String name) throws RegistryException {
Aspect aspect = aspects.get(name);
if (aspect == null) {
- RegistryContext registryContext = (RegistryContext)System.
- getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
aspect = registryContext.getAspect(name);
}
if (aspect == null) {
@@ -1410,4 +1409,17 @@
//TODO: Method implementation
}
+
+ public void setRegistryContext(RegistryContext registryContext) {
+ // TODO - ** HACK ALERT **! This should all get initialized much more cleanly.
+ if (registryContext.getDataSource() == null) {
+ registryContext.setDataSource(dataSource);
+ }
+
+ this.registryContext = registryContext;
+ }
+
+ public RegistryContext getRegistryContext() {
+ return registryContext;
+ }
}
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 Thu Apr 17 20:55:57 2008
@@ -107,7 +107,8 @@
comment.setResourcePath(path);
String commentPath = path + ";comments:" +
results.getInt(DatabaseConstants.COMMENT_ID_FIELD);
- comment.setCommentPath(commentPath);
+ comment.setPath(commentPath);
+ comment.setParentPath(path + ";comments");
commentList.add(comment);
}
@@ -143,7 +144,8 @@
comment.setUser(result.getString(DatabaseConstants.COMMENTED_USER_ID_FIELD));
comment.setTime(result.getTimestamp(DatabaseConstants.COMMENTED_TIME_FIELD));
comment.setResourcePath(resourcePath);
- comment.setCommentPath(commentPath);
+ comment.setPath(commentPath);
+ comment.setParentPath(resourcePath + ";comments");
return comment;
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentCollectionURLHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentCollectionURLHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentCollectionURLHandler.java Thu Apr 17 20:55:57 2008
@@ -45,6 +45,7 @@
Comment[] comments = registry.getComments(parts[0]);
CollectionImpl resource = new CollectionImpl();
+ resource.setPath(parts[0]);
resource.setContent(comments);
requestContext.setProcessingComplete(true);
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentURLHandler.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentURLHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/CommentURLHandler.java Thu Apr 17 20:55:57 2008
@@ -113,16 +113,8 @@
throw new RegistryException(msg);
}
- ResourceImpl resource = new ResourceImpl();
- resource.setPath(url);
- resource.setMediaType(RegistryConstants.COMMENT_MEDIA_TYPE);
- resource.setContent(comment.getText());
- resource.setAuthorUserName(comment.getUser());
- resource.setCreatedTime(comment.getTime());
- resource.addProperty("resourcePath", resourcePath);
-
requestContext.setProcessingComplete(true);
- return resource;
+ return comment;
}
public void put(RequestContext requestContext) throws RegistryException {
Copied: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagCollectionURLHandler.java (from r15635, trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java)
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagURLHandler.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/handlers/builtin/TagCollectionURLHandler.java Thu Apr 17 20:55:57 2008
@@ -20,19 +20,16 @@
import org.wso2.registry.jdbc.handlers.RequestContext;
import org.wso2.registry.jdbc.dao.TagsDAO;
import org.wso2.registry.jdbc.dataobjects.TaggingDO;
-import org.wso2.registry.Resource;
-import org.wso2.registry.RegistryException;
-import org.wso2.registry.ResourceImpl;
-import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.sql.Connection;
import java.sql.SQLException;
-public class TagURLHandler extends Handler {
+public class TagCollectionURLHandler extends Handler {
- private static final Log log = LogFactory.getLog(TagURLHandler.class);
+ private static final Log log = LogFactory.getLog(TagCollectionURLHandler.class);
public Resource get(RequestContext requestContext) throws RegistryException {
@@ -48,15 +45,7 @@
return null;
}
- String[] queries = parts[1].split(":");
-
- if (queries.length != 3) {
- return null;
- }
-
String resourcePath = parts[0];
- String tagName = queries[1];
- String userName = queries[2];
Connection conn;
try {
@@ -67,14 +56,17 @@
try {
TagsDAO tagsDAO = new TagsDAO(dataSource);
- TaggingDO taggingDO = tagsDAO.getTagging(resourcePath, tagName, userName, conn);
+ String [] tags = tagsDAO.getTags(resourcePath, conn);
+ String tagStr = "";
+ for (String tag : tags) {
+ tagStr += tag;
+ }
ResourceImpl resource = new ResourceImpl();
resource.setMediaType(RegistryConstants.TAG_MEDIA_TYPE);
- resource.setContent(taggingDO.getTagName());
- resource.setAuthorUserName(taggingDO.getTaggedUserName());
- resource.setCreatedTime(taggingDO.getTaggedTime());
- resource.addProperty("resourcePath", taggingDO.getResourcePath());
+ resource.setContent(tagStr);
+ resource.setPath(resourcePath);
+ resource.addProperty("resourcePath", resourcePath);
return resource;
@@ -105,4 +97,4 @@
public void importChild(RequestContext requestContext) throws RegistryException {
}
-}
+}
\ No newline at end of file
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 Thu Apr 17 20:55:57 2008
@@ -66,8 +66,7 @@
new SQLQueryMediaTypeHandler(dataSource, realm, this, registry);
mediaTypeHandlers.put(RegistryConstants.SQL_QUERY_MEDIA_TYPE, sqlMediaTypeHandler);
- RegistryContext registryContext =
- (RegistryContext)System.getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
+ RegistryContext registryContext = registry.getRegistryContext();
if (registryContext != null) {
List mediaTypeConfigs = registryContext.getMediaTypeHandlers();
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessorManager.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessorManager.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/queries/QueryProcessorManager.java Thu Apr 17 20:55:57 2008
@@ -31,14 +31,14 @@
private Map queryProcessors = new HashMap();
- public QueryProcessorManager(DataSource dataSource, UserRealm realm) throws RegistryException {
- queryProcessors.put(
- RegistryConstants.SQL_QUERY_MEDIA_TYPE, new SQLQueryProcessor(dataSource, realm));
+ public QueryProcessorManager(DataSource dataSource, UserRealm realm, Registry registry)
+ throws RegistryException {
+ queryProcessors.put(RegistryConstants.SQL_QUERY_MEDIA_TYPE,
+ new SQLQueryProcessor(dataSource, realm));
// add run-time query processors configured using registry.xml
- RegistryContext registryContext = (RegistryContext)System.
- getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
+ RegistryContext registryContext = registry.getRegistryContext();
if (registryContext != null) {
Iterator iQueryProcessors = registryContext.getQueryProcessors().iterator();
@@ -51,8 +51,8 @@
Constructor constructor =
qpClass.getConstructor(new Class[]{DataSource.class, UserRealm.class});
- QueryProcessor queryProcessor = (QueryProcessor)constructor.
- newInstance(new Object[]{dataSource, realm});
+ QueryProcessor queryProcessor =
+ (QueryProcessor)constructor.newInstance(dataSource, realm);
queryProcessors.put(configuration.getQueryType(), queryProcessor);
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/URLHandlerManager.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/URLHandlerManager.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/urlhandlers/URLHandlerManager.java Thu Apr 17 20:55:57 2008
@@ -39,8 +39,7 @@
urlHandlers.add(new RatingsCollectionURLHandler(dataSource, realm));
urlHandlers.add(new TagURLHandler(dataSource, realm));
- RegistryContext registryContext = (RegistryContext)System.
- getProperties().get(RegistryConstants.REGISTRY_CONTEXT);
+ RegistryContext registryContext = registry.getRegistryContext();
if (registryContext != null) {
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/RegistryDataSource.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/RegistryDataSource.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/utils/RegistryDataSource.java Thu Apr 17 20:55:57 2008
@@ -61,4 +61,12 @@
public int getLoginTimeout() throws SQLException {
return dataSource.getLoginTimeout();
}
+
+ public <T> T unwrap(Class<T> iface) throws SQLException {
+ return null;
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException {
+ return false;
+ }
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java Thu Apr 17 20:55:57 2008
@@ -24,6 +24,7 @@
import org.wso2.authenticator.Authenticator;
import org.wso2.authenticator.AuthenticatorException;
import org.wso2.registry.*;
+import org.wso2.registry.config.RegistryContext;
import org.wso2.registry.exceptions.ResourceNotFoundException;
import org.wso2.registry.users.Authorizer;
import org.wso2.registry.users.UserRealm;
@@ -769,6 +770,9 @@
public void rollbackTransaction() throws RegistryException {
//TODO: Method implementation
+ }
+ public RegistryContext getRegistryContext() {
+ return registry.getRegistryContext();
}
}
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java Thu Apr 17 20:55:57 2008
@@ -76,7 +76,6 @@
return config.getServletContext().getRealPath("/WEB-INF");
}
});
- System.getProperties().put(RegistryConstants.REGISTRY_CONTEXT, registryContext);
if (configPath != null) {
RegistryConfigurationProcessor.populateRegistryConfig(configPath, registryContext);
} else {
@@ -119,7 +118,7 @@
registryContext.setDataSource(dataSource);
registryRealm = new RegistryRealm(dataSource);
coreRegistry = new JDBCRegistry(dataSource, registryRealm);
-
+ coreRegistry.setRegistryContext(registryContext);
// add configured handers to the jdbc registry
Iterator<HandlerConfiguration> handlers =
Modified: trunk/registry/modules/core/src/main/java/org/wso2/registry/users/def/DefaultAuthorizer.java
==============================================================================
--- trunk/registry/modules/core/src/main/java/org/wso2/registry/users/def/DefaultAuthorizer.java (original)
+++ trunk/registry/modules/core/src/main/java/org/wso2/registry/users/def/DefaultAuthorizer.java Thu Apr 17 20:55:57 2008
@@ -54,11 +54,7 @@
throws UserStoreException {
Boolean isAuthorized = getRoleAuthorized(roleName, resourceId, action);
- if (isAuthorized == null) {
- return false;
- } else {
- return isAuthorized.booleanValue();
- }
+ return isAuthorized != null && isAuthorized;
}
public boolean isUserAuthorized(String userName, String resourceId, String action)
@@ -71,11 +67,7 @@
isAuthorized = getUserAuthorizationConsideringRoles(userName, resourceId, action);
}
- if (isAuthorized == null) {
- return false;
- } else {
- return isAuthorized.booleanValue();
- }
+ return isAuthorized != null && isAuthorized;
}
public String[] getAllowedUsersForResource(String resourceId, String action)
@@ -264,11 +256,10 @@
}
}
- for (int i = 0; i < roles.length; i++) {
- String roleName = roles[i];
+ for (String roleName : roles) {
Boolean roleAuth = getRoleAuthorized(roleName, resourceId, action);
if (roleAuth != null) {
- if (roleAuth.booleanValue() == false) {
+ if (!roleAuth) {
isAuthorized = roleAuth;
break;
} else {
@@ -278,8 +269,8 @@
}
}
- if (isAuthorized == null && onceAllowed == true) {
- isAuthorized = new Boolean(true);
+ if (isAuthorized == null && onceAllowed) {
+ isAuthorized = true;
}
return isAuthorized;
@@ -302,8 +293,7 @@
isRoleAuthorizedStmt.setString(3, roleName);
ResultSet rs = isRoleAuthorizedStmt.executeQuery();
if (rs.next()) {
- boolean isAuth = rs.getBoolean(DefaultRealmConstants.COLUMN_NAME_IS_ALLOWED);
- isAuthorized = Boolean.valueOf(isAuth);
+ isAuthorized = rs.getBoolean(DefaultRealmConstants.COLUMN_NAME_IS_ALLOWED);
}
isRoleAuthorizedStmt.close();
} catch (SQLException e) {
@@ -338,8 +328,7 @@
isUserAuthorizedStmt.setString(3, userName);
ResultSet rs = isUserAuthorizedStmt.executeQuery();
if (rs.next()) {
- result = Boolean.valueOf(rs
- .getBoolean(DefaultRealmConstants.COLUMN_NAME_IS_ALLOWED));
+ result = rs.getBoolean(DefaultRealmConstants.COLUMN_NAME_IS_ALLOWED);
}
isUserAuthorizedStmt.close();
} catch (SQLException e) {
Modified: trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties
==============================================================================
--- trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties (original)
+++ trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties Thu Apr 17 20:55:57 2008
@@ -90,7 +90,7 @@
resource.associated.fails=Resource {0} associate with {1} failled.
invokeAspect=Resource {0} invoke aspect {1} with action {2}.
invokeAspect.fails=Resource {0} invoke aspect {1} with action {2}.
-resource.associated.fail=Resource {0} associate with {1}.
+resource.associated.fail=Could not associate aspect ''{1}'' with resource {0}.
add.resource.fail=Failed to add the resource to the path : {0}.
rename.resource.fail=Failed to add the resource to the path : {0}.
resource.tag.fails=Failed to tag the resource to the path : {0}.
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/FactoryTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/FactoryTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/FactoryTest.java Thu Apr 17 20:55:57 2008
@@ -44,7 +44,7 @@
assertTrue(caughtException);
props.setProperty(RemoteRegistryFactory.REMOTE_URL,
- "http://localhost:8080/wso2registry/atom");
+ "http://localhost:8080/wso2registry");
reg = RegistryFactory.newInstance(props).getRegistry();
assertNotNull(reg);
assertTrue(reg instanceof RemoteRegistry);
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedLifeCycleTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedLifeCycleTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedLifeCycleTest.java Thu Apr 17 20:55:57 2008
@@ -15,7 +15,6 @@
*/
package org.wso2.registry.app;
-import org.wso2.registry.Registry;
import org.wso2.registry.jdbc.LifeCycleTest;
import java.net.URL;
@@ -28,7 +27,7 @@
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8082/wso2registry"),
"admin", "admin");
}
} catch (Exception e) {
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedTagTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedTagTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedTagTest.java Thu Apr 17 20:55:57 2008
@@ -27,7 +27,7 @@
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry"),
"admin", "admin");
}
} catch (Exception e) {
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedVersionHandlingTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedVersionHandlingTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPBasedVersionHandlingTest.java Thu Apr 17 20:55:57 2008
@@ -29,7 +29,7 @@
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry"),
"admin", "admin");
}
} catch (Exception e) {
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPProtocolTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPProtocolTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPProtocolTest.java Thu Apr 17 20:55:57 2008
@@ -17,6 +17,10 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.params.HttpClientParams;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
import org.apache.commons.httpclient.methods.StringRequestEntity;
@@ -34,7 +38,8 @@
HttpClient client = new HttpClient();
public String buildURL(String path) {
- return BASEURL + path;
+// return baseURL + path;
+ return "http://localhost:8008/atom/" + path;
}
/**
@@ -44,6 +49,11 @@
* @throws Exception if there's a problem
*/
public void testProtocol() throws Exception {
+ client.getParams().setAuthenticationPreemptive(true);
+ Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin");
+ client.getState().setCredentials(new AuthScope("localhost", 8008, AuthScope.ANY_REALM),
+ defaultcreds);
+
// Note - every URL below is rooted at our Registry's atom root
// GET the root - empty dir
@@ -52,6 +62,7 @@
assertEquals(200, responseCode);
method.getResponseBody();
+ method.releaseConnection();
// GET /d1 - 404
method = new GetMethod(buildURL("d1"));
@@ -63,13 +74,13 @@
method = new GetMethod(buildURL("foo" + RegistryConstants.URL_SEPARATOR + "tags"));
responseCode = client.executeMethod(method);
assertEquals(404, responseCode);
+ method.releaseConnection();
-/*
// POST / with d1 content
// TODO - fix this up.
String atomContent =
- "<entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:ns=\"tag:wso2.org,2008:foo\"><summary type=\"text\" /><author><name>system</name></author><ns:properties /><mediaType xmlns=\"http://wso2.org/registry\" /><parentPath xmlns=\"http://wso2.org/registry\" /><directory xmlns=\"http://wso2.org/registry\">true</directory></entry>";
- String location = doPost(buildURL(""), atomContent, "d1");
+ "<feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:ns=\"tag:wso2.org,2008:foo\"><summary type=\"text\" /><author><name>system</name></author><ns:properties /></feed>";
+ String location = doPost(buildURL(""), atomContent, "d1", "application/atom+xml");
assertNotNull(location);
//assertEquals("correct header value", location);
@@ -77,19 +88,21 @@
method = new GetMethod(buildURL("d1"));
responseCode = client.executeMethod(method);
assertEquals(200, responseCode);
+ method.releaseConnection();
// GET /d1;tags - empty tags (or 404?)
method = new GetMethod(buildURL("d1;tags"));
responseCode = client.executeMethod(method);
assertEquals(200, responseCode);
+ method.releaseConnection();
// POST / with no slug - text file
String textContent = "hi there here's some text";
- location = doPost("", textContent, null);
+ location = doPost(buildURL(""), textContent, null, null);
assertNotNull(location);
- // GET /<newname> -
- method = new GetMethod(buildURL(location));
+ // GET of the returned location should return something reasonable...
+ method = new GetMethod(location);
responseCode = client.executeMethod(method);
assertEquals(200, responseCode);
// We should have here an Atom entry pointing to the actual media. Parse
@@ -98,43 +111,61 @@
// POST /d1 with bad slug "&test?"
// Should return /d1/test (sanitized name)
- //assertEquals("d1/test", location);
+ textContent = "hi there here's some text";
+ location = doPost(buildURL("d1"), textContent, ";test?", null);
+ assertNotNull(location);
+ assertTrue(location.endsWith("d1/test"));
// GET /d1/test - content
+ method = new GetMethod(location);
+ responseCode = client.executeMethod(method);
+ assertEquals(200, responseCode);
+ String responseBody = method.getResponseBodyAsString();
+ assertEquals(textContent, responseBody);
// POST /d1 with existing slug "test"
- // Should return /d1/test2 (edited name)
- assertFalse("test".equals(location));
-
- // GET /d1/test2 - content
+ location = doPost(buildURL("d1"), textContent, "test", null);
+ assertNotNull(location);
+ // Should return /d1/test2 (or some sort of edited name)
+ assertFalse(location.endsWith("d1/test"));
// Tags
// GET /d1/test;tags - empty tags (or 404?)
// POST /d1/test;tags tag=blue
+ doPost(buildURL("/d1/test;tags"), "blue", null, null);
// GET /d1/test;tags - "blue"
+ method = new GetMethod(buildURL("/d1/test;tags"));
+ responseCode = client.executeMethod(method);
+ assertEquals(200, responseCode);
+ responseBody = method.getResponseBodyAsString();
+ assertTrue(responseBody.indexOf("blue") > -1);
// Ratings
// Comments
-*/
}
- private String doPost(String url, String content, String slug) throws Exception {
+ private String doPost(String url, String content, String slug, String contentType)
+ throws Exception {
+ if (contentType == null) contentType = "text/plain";
+
PostMethod writeMethod = new PostMethod(url);
if (slug != null)
writeMethod.addRequestHeader("Slug", slug);
- StringRequestEntity myRequest = new StringRequestEntity(content);
+ StringRequestEntity myRequest = new StringRequestEntity(content, contentType, null);
writeMethod.setRequestEntity(myRequest);
int responseCode = client.executeMethod(writeMethod);
- assertEquals(200, responseCode);
+ assertEquals(201, responseCode);
// Get the location header
String location = writeMethod.getResponseHeader("Location").getValue();
assertNotNull(location);
+ writeMethod.releaseConnection();
+
// Parse out result path
return location;
}
Copied: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependencyTest.java (from r15635, trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependecyTest.java)
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependecyTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedDependencyTest.java Thu Apr 17 20:55:57 2008
@@ -19,14 +19,14 @@
import java.net.URL;
-public class APPbasedDependecyTest extends DependencyTest {
+public class APPbasedDependencyTest extends DependencyTest {
RegistryServer server = new RegistryServer();
public void setUp() {
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry"),
"admin", "admin");
}
} catch (Exception e) {
Copied: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedPropertyTest.java (from r15635, trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java)
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedProertyTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/APPbasedPropertyTest.java Thu Apr 17 20:55:57 2008
@@ -19,7 +19,7 @@
import java.net.URL;
-public class APPbasedProertyTest extends PropertiesTest {
+public class APPbasedPropertyTest extends PropertiesTest {
RegistryServer server = new RegistryServer();
@@ -27,7 +27,7 @@
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry"),
"admin", "admin");
}
} catch (Exception e) {
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/AbstractAPPTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/AbstractAPPTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/AbstractAPPTest.java Thu Apr 17 20:55:57 2008
@@ -27,16 +27,16 @@
Registry registry;
int clientPort = 8081; // Default client port. Change prior to setUp() to debug with tcpmon.
- String BASEURL;
+ String baseURL;
protected void setUp() throws Exception {
- BASEURL = "http://localhost:" + clientPort + "/wso2registry/atom/";
+ baseURL = "http://localhost:" + clientPort + "/wso2registry/";
if (server == null) {
server = new RegistryServer(Integer.parseInt(PORT));
server.setPort(Integer.parseInt(PORT));
server.start();
}
- registry = new RemoteRegistry(new URL(BASEURL), "admin", "admin");
+ registry = new RemoteRegistry(new URL(baseURL), "admin", "admin");
}
protected void tearDown() throws Exception {
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/CommentTest.java Thu Apr 17 20:55:57 2008
@@ -68,7 +68,7 @@
List commentTexts = new ArrayList();
for (Comment comment : comments) {
- Resource commentResource = registry.get(comment.getCommentPath());
+ Resource commentResource = registry.get(comment.getPath());
commentTexts.add(commentResource.getContent());
}
@@ -86,7 +86,7 @@
public void testAddCommentToCollection() throws Exception {
- Registry author1Reg = new RemoteRegistry(BASEURL, "author1", "author1");
+ Registry author1Reg = new RemoteRegistry(baseURL, "author1", "author1");
Resource r1 = author1Reg.newCollection();
r1.setDescription("this is a collection to add comment");
@@ -161,7 +161,7 @@
List commentTexts = new ArrayList();
for (Comment comment : comments) {
- Resource commentResource = registry.get(comment.getCommentPath());
+ Resource commentResource = registry.get(comment.getPath());
commentTexts.add(commentResource.getContent());
}
@@ -259,7 +259,7 @@
List commentTexts = new ArrayList();
for (Comment comment : comments) {
- Resource commentResource = registry.get(comment.getCommentPath());
+ Resource commentResource = registry.get(comment.getPath());
commentTexts.add(commentResource.getContent());
}
@@ -321,16 +321,16 @@
List commentTexts = new ArrayList();
for (Comment comment : comments) {
- Resource commentResource = registry.get(comment.getCommentPath());
+ Resource commentResource = registry.get(comment.getPath());
commentTexts.add(commentResource.getContent());
}
assertTrue(c1.getText() + " is not associated for resource /c10/c11/r1.",
commentTexts.contains(c1.getText()));
- registry.editComment(comments[0].getCommentPath(), "This is the edited comment");
+ registry.editComment(comments[0].getPath(), "This is the edited comment");
comments = registry.getComments("/c10/c11/r1");
// System.out.println(comments);
- Resource resource = registry.get(comments[0].getCommentPath());
+ Resource resource = registry.get(comments[0].getPath());
assertEquals("This is the edited comment",resource.getContent());
} catch (RegistryException e) {
e.printStackTrace();
Modified: trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java
==============================================================================
--- trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java (original)
+++ trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java Thu Apr 17 20:55:57 2008
@@ -34,7 +34,7 @@
try {
if (registry == null) {
server.start();
- registry = new RemoteRegistry(new URL("http://localhost:8081/wso2registry/atom"),
+ registry = new RemoteRegistry(new URL("http://localhost:8082/wso2registry"),
"admin&q