Author: deepal
Date: Fri Dec 21 01:05:39 2007
New Revision: 11649

Log:

get the UI working with the remote registry 

Modified:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/RegistryConstants.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/AtomRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/servlet/RegistryServlet.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceHandler.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignInAction.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignOutAction.java

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
  Fri Dec 21 01:05:39 2007
@@ -127,6 +127,7 @@
     public static final String PARAMETER_COMMENTS = "comments";
     public static final String PARAMETER_LOGS = "logs";
     public static final String PARAMETER_QUERY = "query";
+    public static final String PARAMETER_RESOURCE_EXIST = "resourceExists";
 
 
     public static final String RESOURCES_JSP = "/admin/registry-resources.jsp";

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
   Fri Dec 21 01:05:39 2007
@@ -343,6 +343,12 @@
                     } 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 {
                     return createErrorResponse();
                 }
@@ -435,7 +441,8 @@
         String href = baseURI + "atom" + path;
         feed.addLink(href);
         feed.addLink(href, "path");
-
+        feed.addSimpleExtension(new QName("createdTime"),
+                "" + resource.getCreatedTime().getTime());
         //if the content type is comment then the resource will contains ,
         // String array of comments
         if (resource.isDirectory()) {
@@ -833,4 +840,29 @@
         return feed;
     }
 
+    /**
+     * This method to get a feed element representing , whether a feed exist 
or not
+     *
+     * @param abdera : An instance  of Abdera
+     * @param path   : Resource path
+     * @return : Feed object
+     */
+    private Feed getFeedResourceExist(Abdera abdera, String path) {
+        try {
+            boolean isResourceExsit = registry.resourceExists(path);
+            Factory factory = abdera.getFactory();
+            Feed feed = factory.newFeed();
+            feed.setUpdated(new Date());
+            feed.setId("http://wso2.org/registry:resourceExist"; + path);
+            if (isResourceExsit) {
+                feed.setText("True");
+            } else {
+                feed.setText("False");
+            }
+            return feed;
+        } catch (RegistryException e) {
+            return null;
+        }
+    }
+
 }

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
 Fri Dec 21 01:05:39 2007
@@ -95,6 +95,10 @@
             resource.setAuthorUserName(feed.getAuthor().getName());
         }
         resource.setLastModified(feed.getUpdated());
+        String cretedDate = feed.getSimpleExtension(new QName("createdTime"));
+        if (cretedDate != null) {
+            resource.setCreatedTime(new Date(Long.parseLong(cretedDate)));
+        }
         resource.setPath(feed.getTitle());
         resource.setDescription(feed.getText());
         String state = feed.getSimpleExtension(new QName("state"));
@@ -134,7 +138,20 @@
     }
 
     public boolean resourceExists(String path) throws RegistryException {
-        throw new UnsupportedOperationException(" Use get(path) instead");
+        Abdera abdera = new Abdera();
+        AbderaClient abderaClient = new AbderaClient(abdera);
+        ClientResponse clientResponse = abderaClient.get(baseURI + path +
+                RegistryConstants.URL_SEPARATER +
+                RegistryConstants.PARAMETER_RESOURCE_EXIST);
+        Document introspection =
+                clientResponse.getDocument();
+        Feed feed = (Feed) introspection.getRoot();
+        String boolValue = feed.getText();
+        if ("True".equals(boolValue)) {
+            return true;
+        } else {
+            return false;
+        }
     }
 
     public void put(String path, Resource resource) throws RegistryException {

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
    Fri Dec 21 01:05:39 2007
@@ -26,6 +26,7 @@
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.RegistryException;
 import org.wso2.registry.Resource;
+import org.wso2.registry.app.RemoteRegistry;
 import org.wso2.registry.config.DataBaseConfiguration;
 import org.wso2.registry.config.RegistryConfiguration;
 import org.wso2.registry.i18n.Messages;
@@ -47,6 +48,8 @@
 import javax.sql.DataSource;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.net.URL;
+import java.net.MalformedURLException;
 
 /** Servlet for providing REST API for the registry. */
 public class RegistryServlet extends HttpServlet {
@@ -114,7 +117,13 @@
                                        coreRegistry,
                                        registryRealm);
 
-            
config.getServletContext().setAttribute(RegistryConstants.REGISTRY, 
coreRegistry);
+            try {
+                RemoteRegistry remote = new RemoteRegistry(new 
URL("http://localhost:8080/wso2registry/atom";));
+                
config.getServletContext().setAttribute(RegistryConstants.REGISTRY, remote);
+            } catch (MalformedURLException e) {
+                
config.getServletContext().setAttribute(RegistryConstants.REGISTRY, 
coreRegistry);
+                e.printStackTrace();
+            }
             config.getServletContext()
                     .setAttribute(RegistryConstants.REGISTRY_REALM, 
registryRealm);
             System.getProperties().put(RegistryConstants.REGISTRY, 
coreRegistry);

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceHandler.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceHandler.java
     (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/ResourceHandler.java
     Fri Dec 21 01:05:39 2007
@@ -19,6 +19,7 @@
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.RegistryException;
 import org.wso2.registry.Resource;
+import org.wso2.registry.Registry;
 import org.wso2.registry.jdbc.JDBCRegistry;
 import org.wso2.registry.jdbc.realm.RegistryRealm;
 import org.wso2.registry.secure.SecureRegistry;
@@ -59,8 +60,8 @@
             ServletContext context =
                     request.getSession().getServletContext();
 
-            JDBCRegistry jdbcRegistry =
-                    (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+            Registry jdbcRegistry =
+                    (Registry) 
context.getAttribute(RegistryConstants.REGISTRY);
 
             RegistryRealm realm = (RegistryRealm) 
request.getSession().getServletContext().
                     getAttribute(RegistryConstants.REGISTRY_REALM);

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignInAction.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignInAction.java
        (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignInAction.java
        Fri Dec 21 01:05:39 2007
@@ -18,6 +18,7 @@
 
 import org.wso2.registry.RegistryConstants;
 import org.wso2.registry.RegistryException;
+import org.wso2.registry.Registry;
 import org.wso2.registry.jdbc.JDBCRegistry;
 import org.wso2.registry.jdbc.realm.RegistryRealm;
 import org.wso2.registry.secure.SecureRegistry;
@@ -43,8 +44,8 @@
 
         ServletContext context =
                 request.getSession().getServletContext();
-        JDBCRegistry jdbcRegistry =
-                (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+        Registry jdbcRegistry =
+                (Registry) context.getAttribute(RegistryConstants.REGISTRY);
 
         RegistryRealm realm = (RegistryRealm) 
request.getSession().getServletContext().
                 getAttribute(RegistryConstants.REGISTRY_REALM);

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignOutAction.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignOutAction.java
       (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SignOutAction.java
       Fri Dec 21 01:05:39 2007
@@ -18,6 +18,7 @@
 
 
 import org.wso2.registry.RegistryConstants;
+import org.wso2.registry.Registry;
 import org.wso2.registry.jdbc.JDBCRegistry;
 import org.wso2.registry.jdbc.realm.RegistryRealm;
 import org.wso2.registry.secure.SecureRegistry;
@@ -30,7 +31,7 @@
     public String execute() throws Exception {
 
         ServletContext context = request.getSession().getServletContext();
-        JDBCRegistry jdbcRegistry = (JDBCRegistry) 
context.getAttribute(RegistryConstants.REGISTRY);
+        Registry jdbcRegistry = (Registry) 
context.getAttribute(RegistryConstants.REGISTRY);
 
         RegistryRealm realm = (RegistryRealm) 
request.getSession().getServletContext().
                 getAttribute(RegistryConstants.REGISTRY_REALM);

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

Reply via email to