Author: deepal
Date: Tue Feb  5 03:57:42 2008
New Revision: 13267

Log:

-fixing the build error
 - removing code duplicate 

Modified:
   
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
   
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java

Modified: 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
==============================================================================
--- 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
    (original)
+++ 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
    Tue Feb  5 03:57:42 2008
@@ -486,8 +486,7 @@
                               String path,
                               Resource resource,
                               boolean exceuteQuery) {
-        Factory factory = abdera.getFactory();
-        Feed feed = factory.newFeed();
+        Feed feed = getFeedInstance(abdera);
         //Properties in the resource will be send as attributes in the feed 
object
         RemoteRegistry.addPropertyExtensionElement(resource.getProperties(),
                                                    abdera,
@@ -657,8 +656,7 @@
     }
 
     private Document<Feed> get_feed_doc(Abdera abdera, String baseUri) {
-        Factory factory = abdera.getFactory();
-        Feed feed = factory.newFeed();
+        Feed feed = getFeedInstance(abdera);
         try {
             feed.setId("http://wso2.org/jdbcregistry,2007:feed";);
             feed.setTitle("WSO2 Registry");
@@ -742,8 +740,7 @@
                                 String baseUri,
                                 RequestContext request) {
         try {
-            Factory factory = abdera.getFactory();
-            Feed feed = factory.newFeed();
+            Feed feed = getFeedInstance(abdera);
             Tag tags[] = getSecureRegistry(request).getTags(path);
             feed.setId("http://wso2.org/jdbcregistry:tags"; + path);
             feed.setTitle("Tags for " + path);
@@ -767,6 +764,16 @@
     }
 
     /**
+     * This method will give a feed object instance
+     * @param abdera : Instance to Abdera
+     * @return created Feed object
+     */
+    private Feed getFeedInstance(Abdera abdera) {
+        Factory factory = abdera.getFactory();
+        return factory.newFeed();
+    }
+
+    /**
      * Get an Atom feed for the ratings of a given resource.  This feed will 
contain an extension
      * "AverageRating", and entries for each individual rating.
      *
@@ -777,8 +784,7 @@
      */
     private Feed getRatingsFeed(Abdera abdera, String path, String baseUri) {
         try {
-            Factory factory = abdera.getFactory();
-            Feed feed = factory.newFeed();
+            Feed feed = getFeedInstance(abdera);
             feed.setUpdated(new Date());
             feed.setId("http://wso2.org/jdbcregistry:averageRating";);
             feed.setTitle("Average Rating for the resource " + path);
@@ -806,8 +812,7 @@
      */
     private Feed getFeedForComments(Abdera abdera, String path, RequestContext 
request) {
         try {
-            Factory factory = abdera.getFactory();
-            Feed feed = factory.newFeed();
+            Feed feed = getFeedInstance(abdera);
             feed.addSimpleExtension(new QName(NAMESPACE ,"directory"), "true");
             feed.addSimpleExtension(COMMENTS_QNAME, "true");
             Comment comments[] = getSecureRegistry(request).getComments(path);
@@ -850,8 +855,7 @@
                                     String baseUri,
                                     RequestContext request) {
         try {
-            Factory factory = abdera.getFactory();
-            Feed feed = factory.newFeed();
+            Feed feed = getFeedInstance(abdera);
             TaggedResourcePath tagpaths[] = 
getSecureRegistry(request).getResourcePathsWithTag(tag);
             feed.setId("http://wso2.org/jdbcregistry/TagPaths";);
             feed.setUpdated(new Date());
@@ -929,8 +933,7 @@
                                 RequestContext request) throws 
RegistryException {
         LogEntry[] entries = getSecureRegistry(request).getLogs(
                 path, Integer.parseInt(action), author, from, to, true);
-        Factory factory = abdera.getFactory();
-        Feed feed = factory.newFeed();
+        Feed feed = getFeedInstance(abdera);
         feed.setId("http://wso2.org/jdbcregistry,2007:logs";);
         feed.setTitle("Logs for the resource" + path);
         feed.addLink("", "self");
@@ -962,8 +965,7 @@
                                       RequestContext request) {
         try {
             boolean isResourceExsit = 
getSecureRegistry(request).resourceExists(path);
-            Factory factory = abdera.getFactory();
-            Feed feed = factory.newFeed();
+            Feed feed = getFeedInstance(abdera);
             feed.setUpdated(new Date());
             feed.setId("http://wso2.org/jdbcregistry:resourceExist"; + path);
             if (isResourceExsit) {

Modified: 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
==============================================================================
--- 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
  (original)
+++ 
branches/registry/1_0/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
  Tue Feb  5 03:57:42 2008
@@ -42,7 +42,7 @@
 import java.net.URLConnection;
 import java.util.*;
 
-public class RemoteRegistry implements Registry, RegistryConstants, 
APPConstants {
+public class RemoteRegistry  implements  Registry, APPConstants {
 
     private String baseURI;
     private Log log = LogFactory.getLog(RemoteRegistry.class);
@@ -146,7 +146,7 @@
         resource.setDescription(feed.getSubtitle());
         String state = feed.getSimpleExtension(new QName(NAMESPACE, "state"));
         if (state != null && "Deleted".equals(state)) {
-            resource.setState(DELETED_STATE);
+            resource.setState(RegistryConstants.DELETED_STATE);
         }
 
         if (isDirectory != null && "true".equals(isDirectory)) {
@@ -347,7 +347,7 @@
         Entry entry = abdera.getFactory().newEntry();
         entry.setContent(newPath);
         ClientResponse resp = abderaClient.post(baseURI + 
encodeURL(currentPath +
-                                                                    
URL_SEPARATOR +
+                                                                    
RegistryConstants.URL_SEPARATOR +
                                                                     
PARAMETER_RENAME),
                                                 entry,
                                                 getAuthorization());
@@ -364,7 +364,7 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(baseURI + 
encodeURL(path +
-                                                                             
URL_SEPARATOR +
+                                                                             
RegistryConstants.URL_SEPARATOR +
                                                                              
PARAMETER_VERSION),
                                                          getAuthorization());
         Document introspection =
@@ -387,7 +387,7 @@
         AbderaClient abderaClient = new AbderaClient(abdera);
         Entry entry = abdera.getFactory().newEntry();
         ClientResponse resp = abderaClient.put(baseURI + encodeURL(versionPath 
+
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_RESTORE),
                                                entry,
                                                getAuthorization());
@@ -405,7 +405,7 @@
         Entry entry = abdera.getFactory().newEntry();
         entry.setContent(tag);
         ClientResponse resp = abderaClient.put(baseURI + 
encodeURL(resourcePath +
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_TAGS),
                                                entry,
                                                getAuthorization());
@@ -427,7 +427,7 @@
             taggingUri = baseURI + "/";
         }
         ClientResponse clientResponse = abderaClient.get(taggingUri +
-                                                         URL_SEPARATOR +
+                                                         
RegistryConstants.URL_SEPARATOR +
                                                          PARAMETER_TAG_PATHS +
                                                          ":" + tag, 
getAuthorization());
         Document introspection =
@@ -466,7 +466,7 @@
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(baseURI +
                                                          
encodeURL(resourcePath +
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_TAGS),
                                                          getAuthorization());
         Document introspection =
@@ -494,7 +494,7 @@
         Entry entry = abdera.getFactory().newEntry();
         entry.setContent(tag);
         ClientResponse resp = abderaClient.put(baseURI + encodeURL(path +
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_TAGS_REMOVED),
                                                entry,
                                                getAuthorization());
@@ -514,7 +514,7 @@
         entry.addAuthor(comment.getUser());
         entry.setContent(comment.getText());
         ClientResponse resp = abderaClient.post(baseURI + 
encodeURL(resourcePath +
-                                                                    
URL_SEPARATOR +
+                                                                    
RegistryConstants.URL_SEPARATOR +
                                                                     
PARAMETER_COMMENTS),
                                                 entry,
                                                 getAuthorization());
@@ -534,7 +534,7 @@
         Entry entry = abdera.getFactory().newEntry();
         entry.setContent(text);
         ClientResponse resp = abderaClient.put(baseURI + encodeURL(commentPath 
+
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_COMMENTS),
                                                entry,
                                                getAuthorization());
@@ -550,7 +550,7 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(baseURI + 
encodeURL(resourcePath +
-                                                                             
URL_SEPARATOR +
+                                                                             
RegistryConstants.URL_SEPARATOR +
                                                                              
PARAMETER_COMMENTS),
                                                          getAuthorization());
         Document introspection = clientResponse.getDocument();
@@ -589,7 +589,7 @@
         entry.setContent("" + rating);
         entry.setSummary(PARAMETER_RATINGS);
         ClientResponse resp = abderaClient.put(baseURI + 
encodeURL(resourcePath +
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_RATINGS),
                                                entry,
                                                getAuthorization());
@@ -605,7 +605,7 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse = abderaClient.get(baseURI + 
encodeURL(resourcePath +
-                                                                             
URL_SEPARATOR +
+                                                                             
RegistryConstants.URL_SEPARATOR +
                                                                              
PARAMETER_RATINGS),
                                                          getAuthorization());
         Document introspection = clientResponse.getDocument();
@@ -618,7 +618,7 @@
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);
         ClientResponse clientResponse =
-                abderaClient.get(baseURI + encodeURL(path + URL_SEPARATOR +
+                abderaClient.get(baseURI + encodeURL(path + 
RegistryConstants.URL_SEPARATOR +
                                                      PARAMETER_RATINGS + ":" + 
userName),
                                  getAuthorization());
         Document introspection =
@@ -634,7 +634,7 @@
         RequestOptions requestOptions = getAuthorization();
         requestOptions.setHeader("parameters", 
encodeParametersAsString(parameters));
         ClientResponse resp = abderaClient.get(baseURI + encodeURL(path +
-                                                                   
URL_SEPARATOR +
+                                                                   
RegistryConstants.URL_SEPARATOR +
                                                                    
PARAMETER_QUERY),
                                                requestOptions);
         Document introspection =
@@ -694,7 +694,7 @@
         requestOptions.addHeader("Action", "" + action);
         requestOptions.addHeader("Author", userName);
         ClientResponse resp = abderaClient.get(baseURI + 
encodeURL(resourcePath +
-                                                                   
URL_SEPARATOR + PARAMETER_LOGS),
+                                                                   
RegistryConstants.URL_SEPARATOR + PARAMETER_LOGS),
                                                requestOptions);
         Document introspection =
                 resp.getDocument();

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

Reply via email to