Author: glen
Date: Sat Dec 22 19:44:27 2007
New Revision: 11687

Log:

Reformatting, no code changes.


Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java

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
   Sat Dec 22 19:44:27 2007
@@ -55,7 +55,7 @@
 
     public AtomRegistry() {
         super(10);
-        registry = (Registry) 
System.getProperties().get(RegistryConstants.REGISTRY);
+        registry = 
(Registry)System.getProperties().get(RegistryConstants.REGISTRY);
     }
 
     /**
@@ -66,15 +66,14 @@
      * as "/reoures;operation" ,the entry value differ one to another
      *
      * @param request : RequestContext
-     * @return EmptyResponseContext(200) if everything has gone well else
-     *         EmptyResponseContext(500)
+     * @return EmptyResponseContext(200) if everything has gone well else 
EmptyResponseContext(500)
      */
     public ResponseContext createEntry(RequestContext request) {
         Abdera abdera = request.getAbdera();
         Parser parser = abdera.getParser();
         String entry_id = getRealPath(request);
         try {
-            Document<Entry> entry_doc = (Document<Entry>) 
request.getDocument(parser).clone();
+            Document<Entry> entry_doc = 
(Document<Entry>)request.getDocument(parser).clone();
             if (entry_doc != null) {
                 if ("".equals(entry_id)) {
                     //seems like path is emtry , what we should do in this case
@@ -109,7 +108,7 @@
                         String attValue = entry.getSimpleExtension(new 
QName("directory"));
                         List attributes = entry.getAttributes();
                         for (Object attribute : attributes) {
-                            QName attName = (QName) attribute;
+                            QName attName = (QName)attribute;
                             String key = attName.getLocalPart();
                             if (!"mediaType".equals(key)) {
                                 resource.setProperty(key, 
entry.getAttributeValue(key));
@@ -127,7 +126,8 @@
                         } else {
                             // Resource
                             String content1 = entry.getContent();
-                            if (content1 != null && 
!Content.Type.TEXT.equals(entry.getContentType())) {
+                            if (content1 != null &&
+                                
!Content.Type.TEXT.equals(entry.getContentType())) {
                                 byte[] content = Base64.decode(content1);
                                 resource.setContent(content);
                             } else {
@@ -188,7 +188,7 @@
             if (contentType != null && 
!MimeTypeHelper.isAtom(contentType.toString()))
                 return new EmptyResponseContext(415);
             Document<Entry> entry_doc =
-                    (Document<Entry>) request.getDocument(parser).clone();
+                    (Document<Entry>)request.getDocument(parser).clone();
             if (entry_doc != null) {
                 Entry entry = entry_doc.getRoot();
                 String entry_id = getRealPath(request);
@@ -228,8 +228,8 @@
 
 
     /**
-     * This method used to get an atom feed representing the regsitry
-     * and the depending on the url the format of the feed will differ
+     * This method used to get an atom feed representing the regsitry and the 
depending on the url
+     * the format of the feed will differ
      *
      * @param request : RequestContext
      * @return : Will contains the response feed.
@@ -239,137 +239,137 @@
         AbstractResponseContext rc;
         String baseURI = request.getBaseUri().toString();
         String entry_id = getRealPath(request);
-            String values[] = splitPath(entry_id);
-            if (values.length > 1) {
-                // seems like some we need to do some filtering
-                String resourcePath = values[0];
-                String operation = values[1];
-                //Checking whether the parameter is there in the operation , 
like tags:foo
-                String parameter = null;
-                if (operation.indexOf(":") > 0) {
-                    String parts[] = operation.split("\\:");
-                    parameter = parts[1];
-                    operation = parts[0];
-                }
-                if (RegistryConstants.PARAMETER_VERSION.equals(operation)) {
-                    // Need to retuen list of version for the given resource , 
[resourcePath]
-                    try {
-                        String[] versions = registry.getVersions(resourcePath);
-                        Factory factory = abdera.getFactory();
-                        Feed feed = factory.newFeed();
-                        feed.setId("http://wso2.org/registry,atom:version";);
-                        feed.setTitle("Available versions for " + 
resourcePath);
-                        
feed.setSubtitle(Messages.getMessage("resource.version", resourcePath));
-                        feed.setUpdated(new Date());
-                        feed.addLink(request.getBaseUri() + "atom" + 
resourcePath);
-                        //Versions will be added as entries
-                        createEntriesFromStringArray(versions, 
request.getBaseUri().toString(),
-                                abdera, "versionLink",
-                                feed);
-                        Document<Feed> docfeed = feed.getDocument();
-                        rc = new BaseResponseContext<Document<Feed>>(docfeed);
-                        rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
-                        return rc;
-                    } catch (RegistryException e) {
-                        return new EmptyResponseContext(500);
-                    }
-                } else if (RegistryConstants.PARAMETER_TAGS.equals(operation)) 
{
-                    // if the user [parameter]  name is null then need to 
return all the
-                    // tags for the given path
-                    if (parameter == null) {
-                        Feed feed = getFeedForTags(abdera, resourcePath, 
baseURI);
-                        Document<Feed> docfeed = feed.getDocument();
-                        rc = new BaseResponseContext<Document<Feed>>(docfeed);
-                        rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
-                        return rc;
-                    } else {
-                        // Need to return only the tags which are doen by 
giving user
-                        // TODO registry need to provide this feature
-                    }
-
-                } else if 
(RegistryConstants.PARAMETER_AVERAGE_RATINGS.equals(operation)) {
-                    Feed feed = getFeedForAvarageRating(abdera, resourcePath, 
baseURI);
-                    Document<Feed> docfeed = feed.getDocument();
-                    rc = new BaseResponseContext<Document<Feed>>(docfeed);
-                    rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
-                    return rc;
-                } else if 
(RegistryConstants.PARAMETER_RATINGS.equals(operation)) {
-                    Feed feed = getFeedForRating(abdera, resourcePath, 
parameter);
+        String values[] = splitPath(entry_id);
+        if (values.length > 1) {
+            // seems like some we need to do some filtering
+            String resourcePath = values[0];
+            String operation = values[1];
+            //Checking whether the parameter is there in the operation , like 
tags:foo
+            String parameter = null;
+            if (operation.indexOf(":") > 0) {
+                String parts[] = operation.split("\\:");
+                parameter = parts[1];
+                operation = parts[0];
+            }
+            if (RegistryConstants.PARAMETER_VERSION.equals(operation)) {
+                // Need to retuen list of version for the given resource , 
[resourcePath]
+                try {
+                    String[] versions = registry.getVersions(resourcePath);
+                    Factory factory = abdera.getFactory();
+                    Feed feed = factory.newFeed();
+                    feed.setId("http://wso2.org/registry,atom:version";);
+                    feed.setTitle("Available versions for " + resourcePath);
+                    feed.setSubtitle(Messages.getMessage("resource.version", 
resourcePath));
+                    feed.setUpdated(new Date());
+                    feed.addLink(request.getBaseUri() + "atom" + resourcePath);
+                    //Versions will be added as entries
+                    createEntriesFromStringArray(versions, 
request.getBaseUri().toString(),
+                                                 abdera, "versionLink",
+                                                 feed);
                     Document<Feed> docfeed = feed.getDocument();
                     rc = new BaseResponseContext<Document<Feed>>(docfeed);
                     rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
                     return rc;
-                } else if 
(RegistryConstants.PARAMETER_COMMENTS.equals(operation)) {
-                    Feed feed = getFeedForComments(abdera, resourcePath);
+                } catch (RegistryException e) {
+                    return new EmptyResponseContext(500);
+                }
+            } else if (RegistryConstants.PARAMETER_TAGS.equals(operation)) {
+                // if the user [parameter]  name is null then need to return 
all the
+                // tags for the given path
+                if (parameter == null) {
+                    Feed feed = getFeedForTags(abdera, resourcePath, baseURI);
                     Document<Feed> docfeed = feed.getDocument();
                     rc = new BaseResponseContext<Document<Feed>>(docfeed);
                     rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
                     return rc;
-                } else if 
(RegistryConstants.PARAMETER_TAG_PATHS.equals(operation)) {
-                    Feed feed = getFeedForTagPaths(abdera, parameter, baseURI);
+                } else {
+                    // Need to return only the tags which are doen by giving 
user
+                    // TODO registry need to provide this feature
+                }
+
+            } else if 
(RegistryConstants.PARAMETER_AVERAGE_RATINGS.equals(operation)) {
+                Feed feed = getFeedForAvarageRating(abdera, resourcePath, 
baseURI);
+                Document<Feed> docfeed = feed.getDocument();
+                rc = new BaseResponseContext<Document<Feed>>(docfeed);
+                rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
+                return rc;
+            } else if (RegistryConstants.PARAMETER_RATINGS.equals(operation)) {
+                Feed feed = getFeedForRating(abdera, resourcePath, parameter);
+                Document<Feed> docfeed = feed.getDocument();
+                rc = new BaseResponseContext<Document<Feed>>(docfeed);
+                rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
+                return rc;
+            } else if (RegistryConstants.PARAMETER_COMMENTS.equals(operation)) 
{
+                Feed feed = getFeedForComments(abdera, resourcePath);
+                Document<Feed> docfeed = feed.getDocument();
+                rc = new BaseResponseContext<Document<Feed>>(docfeed);
+                rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
+                return rc;
+            } else if 
(RegistryConstants.PARAMETER_TAG_PATHS.equals(operation)) {
+                Feed feed = getFeedForTagPaths(abdera, parameter, baseURI);
+                Document<Feed> docfeed = feed.getDocument();
+                rc = new BaseResponseContext<Document<Feed>>(docfeed);
+                rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
+                return rc;
+            } else if (RegistryConstants.PARAMETER_LOGS.equals(operation)) {
+                Date to = request.getDateHeader("ToDate");
+                Date from = request.getDateHeader("FromDate");
+                String action = request.getHeader("Action");
+                String author = request.getHeader("Author");
+                try {
+                    Feed feed = getFeedForLogs(abdera, resourcePath, from, to, 
author, action);
                     Document<Feed> docfeed = feed.getDocument();
                     rc = new BaseResponseContext<Document<Feed>>(docfeed);
                     rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
                     return rc;
-                } else if (RegistryConstants.PARAMETER_LOGS.equals(operation)) 
{
-                    Date to = request.getDateHeader("ToDate");
-                    Date from = request.getDateHeader("FromDate");
-                    String action = request.getHeader("Action");
-                    String author = request.getHeader("Author");
-                    try {
-                        Feed feed = getFeedForLogs(abdera, resourcePath, from, 
to, author, action);
-                        Document<Feed> docfeed = feed.getDocument();
-                        rc = new BaseResponseContext<Document<Feed>>(docfeed);
-                        rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
-                        return rc;
-                    } catch (RegistryException e) {
-                        return new EmptyResponseContext(500);
-                    }
-                } else if 
(RegistryConstants.PARAMETER_QUERY.equals(operation)) {
-                    try {
-                        // Trying to excute a query for a given path for a 
given paramater
-                        String parms = request.getHeader("parameters");
-                        String[] parameters =
-                                RemoteRegistry.decodeParametesAsString(parms);
-                        Resource resource = 
registry.executeQuery(resourcePath, parameters);
-                        Feed feed = populateFeed(abdera, baseURI, 
resourcePath, resource, true);
-                        Document<Feed> docfeed = feed.getDocument();
-                        rc = new BaseResponseContext<Document<Feed>>(docfeed);
-                        rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
-                        return rc;
-                    } catch (RegistryException e) {
-                        return new EmptyResponseContext(500);
-                    }
-                } else if 
(RegistryConstants.PARAMETER_RESOURCE_EXIST.equals(operation)) {
-                    Feed feed = getFeedResourceExist(abdera, resourcePath);
+                } catch (RegistryException e) {
+                    return new EmptyResponseContext(500);
+                }
+            } else if (RegistryConstants.PARAMETER_QUERY.equals(operation)) {
+                try {
+                    // Trying to excute a query for a given path for a given 
paramater
+                    String parms = request.getHeader("parameters");
+                    String[] parameters =
+                            RemoteRegistry.decodeParametesAsString(parms);
+                    Resource resource = registry.executeQuery(resourcePath, 
parameters);
+                    Feed feed = populateFeed(abdera, baseURI, resourcePath, 
resource, true);
                     Document<Feed> docfeed = feed.getDocument();
                     rc = new BaseResponseContext<Document<Feed>>(docfeed);
                     rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
                     return rc;
-                } else {
-                    return createErrorResponse();
+                } catch (RegistryException e) {
+                    return new EmptyResponseContext(500);
                 }
+            } else if 
(RegistryConstants.PARAMETER_RESOURCE_EXIST.equals(operation)) {
+                Feed feed = getFeedResourceExist(abdera, resourcePath);
+                Document<Feed> docfeed = feed.getDocument();
+                rc = new BaseResponseContext<Document<Feed>>(docfeed);
+                rc.setEntityTag(calculateEntityTag(docfeed.getRoot()));
+                return rc;
             } else {
-                //need to return a feed representing resource.
-                if ("atom".equals(entry_id) || entry_id == null || 
"".equals(entry_id)) {
-                    entry_id = "/";
-                }
-                Document<Feed> feed;
-                try {
-                    Resource resource = registry.get(entry_id);
-                    Feed feedObj = populateFeed(abdera, baseURI, entry_id, 
resource, false);
-                    if (feedObj != null) {
-                        feed = feedObj.getDocument();
-                        rc = new BaseResponseContext<Document<Feed>>(feed);
-                        rc.setEntityTag(calculateEntityTag(feed.getRoot()));
-                        return rc;
-                    } else {
-                        return createErrorResponse();
-                    }
-                } catch (RegistryException e) {
+                return createErrorResponse();
+            }
+        } else {
+            //need to return a feed representing resource.
+            if ("atom".equals(entry_id) || entry_id == null || 
"".equals(entry_id)) {
+                entry_id = "/";
+            }
+            Document<Feed> feed;
+            try {
+                Resource resource = registry.get(entry_id);
+                Feed feedObj = populateFeed(abdera, baseURI, entry_id, 
resource, false);
+                if (feedObj != null) {
+                    feed = feedObj.getDocument();
+                    rc = new BaseResponseContext<Document<Feed>>(feed);
+                    rc.setEntityTag(calculateEntityTag(feed.getRoot()));
+                    return rc;
+                } else {
                     return createErrorResponse();
                 }
+            } catch (RegistryException e) {
+                return createErrorResponse();
             }
+        }
         return null;
     }
 
@@ -386,22 +386,22 @@
 
     /**
      * This method will serialized Resource for the given path into a Atom 
feed. If the resource is
-     * a directory , then there will be mutiple entry inside that representing 
the child nodes.
-     * Here there will be special simpleExtension to represent called 
"directory" and the value would be
+     * a directory , then there will be mutiple entry inside that representing 
the child nodes. Here
+     * there will be special simpleExtension to represent called "directory" 
and the value would be
      * "true"
      * <p/>
      * If the return resource is a resource which contains commenet then the 
same thing will happen
      * <p/>
-     * if the resource is actual resource then there will be one entry inside 
the feed and that entery
-     * will have the content of the resource as byte array and when serialize 
, which will become
-     * base64 , if the content is String then that will appear as it is.
+     * if the resource is actual resource then there will be one entry inside 
the feed and that
+     * entery will have the content of the resource as byte array and when 
serialize , which will
+     * become base64 , if the content is String then that will appear as it is.
      *
      * @param abdera       : Reference to Abdera object
      * @param baseURI      : BaseURI of the registry
      * @param path         : resource path
      * @param resource     : Resource object that we need to generate feed
-     * @param exceuteQuery : To indicate whether the method call is for query 
exceute
-     *                     result or something else
+     * @param exceuteQuery : To indicate whether the method call is for query 
exceute result or
+     *                     something else
      * @return Feed : which represent the atom feed of the resource.
      */
     private Feed populateFeed(Abdera abdera,
@@ -416,8 +416,8 @@
         if (properties != null) {
             Iterator keys = properties.keySet().iterator();
             while (keys.hasNext()) {
-                String key = (String) keys.next();
-                feed.setAttributeValue(key, (String) properties.get(key));
+                String key = (String)keys.next();
+                feed.setAttributeValue(key, (String)properties.get(key));
             }
         }
         //if the resourse is deleted then there will be comment saying that 
the resource is
@@ -435,9 +435,9 @@
             feed.setUpdated(new Date());
         }
 //        resource.getCreatedTime()
-        if (resource.getCreatedTime() !=null) {
+        if (resource.getCreatedTime() != null) {
             feed.addSimpleExtension(new QName("createdTime"),
-                    "" + resource.getCreatedTime().getTime());
+                                    "" + resource.getCreatedTime().getTime());
         }
         String href = baseURI + "atom" + path;
         feed.addLink(href);
@@ -449,7 +449,7 @@
             feed.addSimpleExtension(new QName("directory"), "true");
         }
         if (exceuteQuery) {
-            String values[] = (String[]) resource.getContent();
+            String values[] = (String[])resource.getContent();
             for (String value : values) {
                 Entry entry = abdera.getFactory().newEntry();
                 //adding child node as and setting the ref as path
@@ -460,14 +460,14 @@
         } else {
             if ("comments".equals(resource.getMediaType())) {
                 String rel = "commentLink";
-                createEntriesFromStringArray((String[]) resource.getContent(),
-                        baseURI, abdera, rel, feed);
+                createEntriesFromStringArray((String[])resource.getContent(),
+                                             baseURI, abdera, rel, feed);
                 return feed;
             }
             if (resource.isDirectory()) {
                 String rel = "path";
-                createEntriesFromStringArray((String[]) resource.getContent(),
-                        baseURI, abdera, rel, feed);
+                createEntriesFromStringArray((String[])resource.getContent(),
+                                             baseURI, abdera, rel, feed);
                 return feed;
             } else {
                 //Now the resource is a actual resource , so need to send the 
content
@@ -482,7 +482,7 @@
                 entry.setUpdated(resource.getLastModified());
                 entry.setPublished(resource.getCreatedTime());
                 if (content != null && content instanceof byte[]) {
-                    ByteArrayInputStream in = new 
ByteArrayInputStream((byte[]) content);
+                    ByteArrayInputStream in = new 
ByteArrayInputStream((byte[])content);
                     entry.setContent(in);
                 } else {
                     if (content != null) {
@@ -592,8 +592,7 @@
 
     /**
      * This method will split the path into two part by the path separator , 
here the path separator
-     * is ";"
-     * if the path is r1;rate , then the return array would contains r1 and 
rate
+     * is ";" if the path is r1;rate , then the return array would contains r1 
and rate
      *
      * @param path : url path
      * @return String array of the splited string
@@ -606,19 +605,19 @@
         String id = null;
         String modified = null;
         if (base instanceof Entry) {
-            id = ((Entry) base).getId().toString();
-            modified = ((Entry) base).getUpdatedElement().getText();
+            id = ((Entry)base).getId().toString();
+            modified = ((Entry)base).getUpdatedElement().getText();
         } else if (base instanceof Feed) {
-            id = ((Feed) base).getId().toString();
-            modified = ((Feed) base).getUpdatedElement().getText();
+            id = ((Feed)base).getId().toString();
+            modified = ((Feed)base).getUpdatedElement().getText();
         }
         return EntityTag.generate(id, modified);
     }
 
     /**
-     * This will generate Feed element represnting all the tags for the given 
path
-     * Title of the entry will be the tag name and the there will be an 
extension element
-     * called "taggings" to represent the tag count
+     * This will generate Feed element represnting all the tags for the given 
path Title of the
+     * entry will be the tag name and the there will be an extension element 
called "taggings" to
+     * represent the tag count
      *
      * @param abdera  : Instance of Abdera objcet
      * @param path    : Path of which need to get the tags
@@ -635,8 +634,8 @@
             feed.setId("http://wso2.org/registry:tags"; + path);
             feed.setTitle("Tags for " + path);
             String nodeLink = baseUri + "atom" + path +
-                    RegistryConstants.URL_SEPARATER +
-                    RegistryConstants.PARAMETER_TAGS;
+                              RegistryConstants.URL_SEPARATER +
+                              RegistryConstants.PARAMETER_TAGS;
             feed.addLink(nodeLink);
             feed.setUpdated(new Date());
 
@@ -672,8 +671,8 @@
             feed.setId("http://wso2.org/registry:avarageRating";);
             feed.setTitle("Avarage Rating for the resource " + path);
             String nodeLink = baseUri + "atom" + path +
-                    RegistryConstants.URL_SEPARATER +
-                    RegistryConstants.PARAMETER_AVERAGE_RATINGS;
+                              RegistryConstants.URL_SEPARATER +
+                              RegistryConstants.PARAMETER_AVERAGE_RATINGS;
             feed.addLink(nodeLink);
             feed.setSubtitle("" + registry.getAverageRating(path));
             return feed;
@@ -683,9 +682,8 @@
     }
 
     /**
-     * This method will create a feed elemenet to representing rating value 
for a given path by given
-     * user.
-     * The rating value will be there in the text of the feed
+     * This method will create a feed elemenet to representing rating value 
for a given path by
+     * given user. The rating value will be there in the text of the feed
      *
      * @param abdera   : An instance of Abder
      * @param path     : Resource path
@@ -707,11 +705,9 @@
     }
 
     /**
-     * To get the collection of comments for a given path a feed element will 
be generted with a
-     * set of entry . And each entry will represent
-     * - commented Author
-     * - Commented Time
-     * - And the conent
+     * To get the collection of comments for a given path a feed element will 
be generted with a set
+     * of entry . And each entry will represent - commented Author - Commented 
Time - And the
+     * conent
      *
      * @param abdera : An instance of Abder
      * @param path   : Resource path
@@ -795,13 +791,9 @@
     }
 
     /**
-     * Will creat a feed element for user asked logs , there will be separate 
entry for log
-     * and each entry will contain
-     * - edited date : Log date
-     * - content : log action data
-     * - Author : Log author
-     * - Extenion element for action
-     * - Extension element for path
+     * Will creat a feed element for user asked logs , there will be separate 
entry for log and each
+     * entry will contain - edited date : Log date - content : log action data 
- Author : Log author
+     * - Extenion element for action - Extension element for path
      *
      * @param abdera : An instance of an Abdera
      * @param path   : Resource path

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

Reply via email to