Author: deepal
Date: Sun Dec 16 23:15:22 2007
New Revision: 11210

Log:

remote registry clean up and added support for i18n for APP and will do the 
rest soon

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/RegistryAtomProvider.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
   
trunk/registry/modules/core/src/main/resources/org/wso2/registry/i18n/resource.properties
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/app/JettyBasedServerTest.java

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
      Sun Dec 16 23:15:22 2007
@@ -26,7 +26,6 @@
     public RegistryAPPTargetResolver() {
         setPattern("/atom(\\?[^#]*)?", TargetType.TYPE_COLLECTION);
         setPattern("/atom/([^/#?]*)", TargetType.TYPE_COLLECTION);
-        //Working
         setPattern("/atom/(.*)/([^/#?]+)(\\?[^#]*)?", 
TargetType.TYPE_COLLECTION);
         setPattern("/atom/(.*)([^/#?]+)(\\?[^#]*)?", 
TargetType.TYPE_COLLECTION);
         setPattern("/feed(\\?[^#]*)?", TargetType.TYPE_ENTRY);

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAtomProvider.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAtomProvider.java
   (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RegistryAtomProvider.java
   Sun Dec 16 23:15:22 2007
@@ -36,6 +36,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.Comment;
 import org.wso2.registry.*;
+import org.wso2.registry.i18n.Messages;
 
 import javax.activation.MimeType;
 import javax.xml.namespace.QName;
@@ -56,23 +57,6 @@
     public RegistryAtomProvider() {
         super(10);
         registry = (Registry) 
System.getProperties().get(RegistryConstants.REGISTRY);
-//        try {
-//            Resource r1 = new Resource();
-//            r1.setDirectory(true);
-//            r1.setAuthorUserName("Deepal");
-//            registry.put("/wso2/wsas", r1);
-//            registry.put("/wso2/esb", r1);
-//            registry.put("/wso2/wsas/esb", r1);
-//            Resource r2 = new Resource();
-//            r2.setDirectory(false);
-//            byte[] r1content = "R1 content".getBytes();
-//            r2.setContent(r1content);
-//            r2.setMediaType("text/xml");
-//            r2.setAuthorUserName("Glen");
-//            registry.put("/wso2/esb/r1", r2);
-//        } catch (RegistryException e) {
-//            e.printStackTrace();
-//        }
     }
 
     private Document<Service> init_service_doc(Abdera abdera) {
@@ -184,7 +168,7 @@
                     Factory factory = abdera.getFactory();
                     Feed feed = factory.newFeed();
                     feed.setId("http://wso2.org/registry,2007:feed";);
-                    feed.setText("Resource Version for the resource" + path);
+                    feed.setText(Messages.getMessage("resource.version",path));
                     feed.setTitle("versions for " + path);
                     feed.setUpdated(new Date());
                     feed.addLink(request.getBaseUri() + "atom" + path);
@@ -254,9 +238,8 @@
                 rc.setEntityTag(calculateEntityTag(feed.getRoot()));
                 return rc;
             } else {
-                //Server error
                 EmptyResponseContext responseContext = new 
EmptyResponseContext(500);
-                responseContext.setStatusText("Resource Not found");
+                
responseContext.setStatusText(Messages.getMessage("resource.not.found"));
                 return responseContext;
             }
         }
@@ -323,7 +306,7 @@
             Factory factory = abdera.getFactory();
             Feed feed = factory.newFeed();
             Resource resource = registry.get(path);
-            return createFeedFromResource(resource, feed, path, baseURI, 
abdera , false);
+            return createFeedFromResource(resource, feed, path, baseURI, 
abdera, false);
         } catch (RegistryException e) {
             return null;
         }
@@ -333,7 +316,7 @@
                                         Feed feed,
                                         String path,
                                         String baseURI,
-                                        Abdera abdera ,
+                                        Abdera abdera,
                                         boolean executeQuery) throws 
RegistryException {
         Properties properties = resource.getProperties();
         if (properties != null) {
@@ -363,7 +346,7 @@
                 for (int i = 0; i < values.length; i++) {
                     String value = values[i];
                     Entry entry = abdera.getFactory().newEntry();
-                    if(executeQuery){
+                    if (executeQuery) {
                         entry.setTitle(value);
                     } else {
                         try {
@@ -485,8 +468,6 @@
         }
     }
 
-
-    @SuppressWarnings("unchecked")
     public ResponseContext createEntry(
             RequestContext request) {
         Abdera abdera = request.getAbdera();
@@ -584,7 +565,6 @@
         }
     }
 
-    @SuppressWarnings("unchecked")
     public ResponseContext updateEntry(
             RequestContext request) {
         Abdera abdera = request.getAbdera();
@@ -645,7 +625,7 @@
                             feed,
                             path,
                             request.getBaseUri().toString(),
-                            abdera , true);
+                            abdera, true);
                     Document<Feed> docfeed = feed.getDocument();
                     AbstractResponseContext rc;
                     rc = new BaseResponseContext<Document<Feed>>(docfeed);

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
 Sun Dec 16 23:15:22 2007
@@ -28,6 +28,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.wso2.registry.Comment;
 import org.wso2.registry.*;
+import org.wso2.registry.i18n.Messages;
 
 import javax.xml.namespace.QName;
 import java.io.ByteArrayInputStream;
@@ -62,14 +63,14 @@
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(collectionRoot + 
path);
         if (clientResponse.getType() == Response.ResponseType.SERVER_ERROR) {
-            throw new RegistryException("Resource Not found , please check the 
resource path" + path);
+            throw new 
RegistryException(Messages.getMessage("resource.not.found.warn",path));
         }
         Document introspection =
                 clientResponse.getDocument();
         Feed feed = (Feed) introspection.getRoot();
 
         if (feed.getSubtitle() != null && 
feed.getSubtitle().equals("Deleted")) {
-            throw new RegistryException("Resource not available.");
+            throw new 
RegistryException(Messages.getMessage("resource.not.found"));
         }
 
         return createResourceFromFeed(feed);
@@ -163,10 +164,10 @@
         }
         ClientResponse resp = abderaClient.post(collectionRoot + path, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource added " + path);
+            log.info(Messages.getMessage("resource.add",path));
         } else {
-            log.error("Failed to add the resource to the path : " + path);
-            throw new RegistryException("Failed to add the resource to the 
path : " + path);
+            log.error(Messages.getMessage("add.resource.fail",path));
+            throw new 
RegistryException(Messages.getMessage("add.resource.fail",path));
         }
     }
 
@@ -175,10 +176,10 @@
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse resp = abderaClient.delete(entryRoot + path);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource deleted " + path);
+            log.info(Messages.getMessage("resource.deleted",path));
         } else {
-            log.error("Failed to delete the resource to the path : " + path);
-            throw new RegistryException("Failed to delete the resource to the 
path : " + path);
+            log.error(Messages.getMessage("resource.delete.fail",path));
+            throw new 
RegistryException(Messages.getMessage("resource.delete.fail",path));
         }
     }
 
@@ -207,10 +208,10 @@
         entry.setAttributeValue("directory", "false");
         ClientResponse resp = abderaClient.put(entryRoot, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource restored " + versionPath);
+            log.info(Messages.getMessage("resource.restoreded",versionPath));
         } else {
-            log.error("Failed to restore the resource to the path : " + 
versionPath);
-            throw new RegistryException("Failed to restore the resource to the 
path : " + versionPath);
+            
log.error(Messages.getMessage("resource.restore.fail",versionPath));
+            throw new 
RegistryException(Messages.getMessage("resource.restore.fail",versionPath));
         }
     }
 
@@ -224,11 +225,10 @@
         entry.setAttributeValue("directory", "false");
         ClientResponse resp = abderaClient.put(entryRoot, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource tagged " + resourcePath);
+            log.info(Messages.getMessage("resource.tagged",resourcePath));
         } else {
-            log.error("Failed to tag the resource to the path : " + 
resourcePath);
-            throw new RegistryException("Failed to restore the resource to the 
path : " +
-                    "" + resourcePath);
+            log.error(Messages.getMessage("resource.tag.fails",resourcePath));
+            throw new 
RegistryException(Messages.getMessage("resource.tag.fails",resourcePath));
         }
     }
 
@@ -287,10 +287,10 @@
         entry.setSummary(RegistryConstants.PARAMETER_TAGS_REMOVED);
         ClientResponse resp = abderaClient.put(entryRoot, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Tag removed " + path);
+            log.info(Messages.getMessage("tag.removed",path));
         } else {
-            log.error("Failed to remove the tag " + path);
-            throw new RegistryException("Failed to remove the tag" + path);
+            log.error(Messages.getMessage("tag.removed.fails",path));
+            throw new 
RegistryException(Messages.getMessage("tag.removed.fails",path));
         }
     }
 
@@ -305,11 +305,10 @@
         entry.setContent(comment.getCommentText());
         ClientResponse resp = abderaClient.put(entryRoot, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource commented " + resourcePath);
+            log.info(Messages.getMessage("resource.commented",resourcePath));
         } else {
-            log.error("Failed to comment the resource to the path : " + 
resourcePath);
-            throw new RegistryException("Failed to comment the resource to the 
path : " +
-                    "" + resourcePath);
+            
log.error(Messages.getMessage("resouce.comment.fails",resourcePath));
+            throw new 
RegistryException(Messages.getMessage("resouce.comment.fails",resourcePath));
         }
     }
 
@@ -347,10 +346,10 @@
         entry.setSummary(RegistryConstants.PARAMETER_REATINGS);
         ClientResponse resp = abderaClient.put(entryRoot, entry);
         if (resp.getType() == Response.ResponseType.SUCCESS) {
-            log.info("Resource rated " + resourcePath);
+            log.info(Messages.getMessage("resource.rated",resourcePath));
         } else {
-            log.error("Failed to rate the resoutrce  " + resourcePath);
-            throw new RegistryException("Failed to rate the resoutrce  " + 
resourcePath);
+            log.error(Messages.getMessage("resource.rate.fail",resourcePath));
+            throw new 
RegistryException(Messages.getMessage("resource.rate.fail",resourcePath));
         }
     }
 

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
   Sun Dec 16 23:15:22 2007
@@ -55,6 +55,7 @@
 resource.get.fail=Could not get the resource with path {0}.
 resource.put.fail=Could not put the resource with path {0} : exception {1}.
 resource.delete.fail=Could not delete the resource with path {0}.
+resource.restore.fail=Could not restore the resource with path {0}.
 resource.tagging.fail=Could not tag the resource with path {0} using the tag 
{1}.
 tag.search.fail.1=Could not search for the resources with tag {0}.
 tag.search.fail.2=Could not get the tags associated with the resource {0}.
@@ -64,4 +65,20 @@
 get.average.rating.fail=Could not get the average ratingDAO for the resource 
{0}.
 define.query.fail=Could not define the query {0} with SQL: {1}.
 execute.query.fail=Failed to execute the predefined query {0}.
-resource.already.tagged=Resource {0} is already tagged with tag {1} by the 
user {2}.
\ No newline at end of file
+resource.already.tagged=Resource {0} is already tagged with tag {1} by the 
user {2}.
+################################ APP Messages 
###########################################
+resource.version=Resource Version for the resource {0}
+resource.not.found=Resource Not found.
+resource.not.found.warn=Resource Not found ,please check the resource path {0}.
+resource.add=Resource added {0}.
+resource.deleted=Resource deleted {0}.
+resource.restoreded=Resource restored {0}.
+resource.tagged=Resource tagged {0}.
+tag.removed=Resource tagged {0}.
+resource.commented=Resource commented {0}
+resource.rated=Resource rated {0}.
+add.resource.fail=Failed to add the resource to the path : {0}.
+resource.tag.fails=Failed to tag the resource to the path : {0}.
+tag.removed.fails=Failed to remove the tag : {0}
+resource.comment.fails=Failed to comment the resource to the path : {0}
+resource.rate.fail=Failed to rate the resource {0}

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
   Sun Dec 16 23:15:22 2007
@@ -46,7 +46,7 @@
         try {
             if (registry == null) {
                 initJetty();
-                registry = new RemoteRegistry(new 
URL("http://localhost:8080/wso2registry/";));
+                registry = new RemoteRegistry(new 
URL("http://localhost:8080/wso2registry";));
             }
         } catch (Exception e) {
             fail("Failed to initialize the registry.");

_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev

Reply via email to