Author: chathura
Date: Sun Jan 13 21:03:04 2008
New Revision: 12177

Log:


Removed the media type based search method from the Registry API and from all 
implementations.
We need more general search method to cover all attribute base searches.



Removed:
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/dao/MediaTypeDAO.java
Modified:
   trunk/registry/modules/core/src/main/java/org/wso2/registry/Registry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/app/RemoteRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/jdbc/JDBCRegistry.java
   
trunk/registry/modules/core/src/main/java/org/wso2/registry/secure/SecureRegistry.java
   
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
   
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
   trunk/registry/modules/webapps/src/main/webapp/admin/user.jsp

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   
Sun Jan 13 21:03:04 2008
@@ -196,15 +196,6 @@
     int getRating(String path, String userName) throws RegistryException;
 
     /**
-     * Returns a collection resource containing the paths of the resources of 
the given media type.
-     *
-     * @param mediaType Media type to search for (e.g. image/gif, text/html)
-     * @return Collection resource containing the resources matching the given 
media type
-     * @throws RegistryException
-     */
-    Resource getResourcesOfMediaType(String mediaType) throws 
RegistryException;
-
-    /**
      * Executes a custom query defined by users. Returned RowSet contains 
fields of tables specified
      * by the custom query.
      *

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 Jan 13 21:03:04 2008
@@ -446,11 +446,6 @@
         return Integer.parseInt(intvalue);
     }
 
-    public Resource getResourcesOfMediaType(String mediaType) throws 
RegistryException {
-        // TODO: implement media type based search in APP
-        return null;
-    }
-
     public Resource executeQuery(String path, Object[] parameters) throws 
RegistryException {
         Abdera abdera = new Abdera();
         AbderaClient abderaClient = new AbderaClient(abdera);

Modified: 
trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
==============================================================================
--- 
trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
  (original)
+++ 
trunk/registry/modules/core/src/main/java/org/wso2/registry/inmemory/InMemoryRegistry.java
  Sun Jan 13 21:03:04 2008
@@ -245,11 +245,6 @@
                                                                     "User 
level rating"));
     }
 
-    public Resource getResourcesOfMediaType(String mediaType) throws 
RegistryException {
-        throw new 
UnsupportedOperationException(Messages.getMessage("unsupported.exception",
-                                                                    "Search 
for resources of media type"));
-    }
-
     public Resource executeQuery(String path, Object[] parameters) throws 
RegistryException {
         throw new 
UnsupportedOperationException(Messages.getMessage("unsupported.exception",
                                                                     "Custom 
queries"));

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
  Sun Jan 13 21:03:04 2008
@@ -59,7 +59,6 @@
     private TagsDAO tagsDAO = null;
     private CommentsDAO commentsDAO = null;
     private RatingsDAO ratingsDAO = null;
-    private MediaTypeDAO mediaTypeDAO = null;
     private LogsDAO logsDAO = null;
 
     private Realm defaultRealm = null;
@@ -125,7 +124,6 @@
         tagsDAO = new TagsDAO();
         commentsDAO = new CommentsDAO();
         ratingsDAO = new RatingsDAO();
-        mediaTypeDAO = new MediaTypeDAO();
         logsDAO = new LogsDAO();
 
         // check if root is added. if not add it.
@@ -957,32 +955,6 @@
 
     }
 
-    public Resource getResourcesOfMediaType(String mediaType) throws 
RegistryException {
-
-        Connection conn = getConnection();
-
-        Resource resultCollection = new Resource();
-        resultCollection.setDirectory(true);
-
-        try {
-            String[] resultPaths = mediaTypeDAO.getPathsOfMediaType(mediaType, 
conn);
-            resultCollection.setContent(resultPaths);
-
-        } catch (SQLException e) {
-
-            String msg = "Could not get the resources of media type: " + 
mediaType;
-            log.error(msg, e);
-            throw new RegistryException(msg, e);
-
-        } finally {
-            try {
-                conn.close();
-            } catch (SQLException ignore) {}
-        }
-
-        return resultCollection;
-    }
-
     public Resource executeQuery(String path, Object[] parameters) throws 
RegistryException {
 
         Connection conn = getConnection();

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
      Sun Jan 13 21:03:04 2008
@@ -601,11 +601,6 @@
         return registry.getRating(resourcePath, userName);
     }
 
-    public Resource getResourcesOfMediaType(String mediaType) throws 
RegistryException {
-        User.setCurrentUser(userID);
-        return registry.getResourcesOfMediaType(mediaType);
-    }
-
     public Resource executeQuery(String path, Object[] parameters) throws 
RegistryException {
         User.setCurrentUser(userID);
         return registry.executeQuery(path, parameters);

Modified: 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
==============================================================================
--- 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      (original)
+++ 
trunk/registry/modules/core/src/test/java/org/wso2/registry/jdbc/JDBCRegistryTest.java
      Sun Jan 13 21:03:04 2008
@@ -943,61 +943,6 @@
 
     }
 
-    // TODO: uncomment this test after media type search is implemented in the 
remote registry
-    //public void testMediaTypeSearch() {
-    //
-    //    String r1Content = "this is the r1 content.";
-    //    Resource r1 = new Resource();
-    //    r1.setContent(r1Content.getBytes());
-    //    try {
-    //        registry.put("/r101", r1);
-    //    } catch (RegistryException e) {
-    //        fail("Couldn't put a content resource in to path /r101");
-    //    }
-    //
-    //    String r2Content = "this is the r2 content.";
-    //    Resource r2 = new Resource();
-    //    r2.setMediaType("text/plain");
-    //    r2.setContent(r2Content.getBytes());
-    //    try {
-    //        registry.put("/r102", r2);
-    //    } catch (RegistryException e) {
-    //        fail("Couldn't put a content resource in to path /r102");
-    //    }
-    //
-    //    String r3Content = "this is the r3 content.";
-    //    Resource r3 = new Resource();
-    //    r3.setContent(r3Content.getBytes());
-    //    r3.setMediaType("text/plain");
-    //    try {
-    //        registry.put("/c10022/r3", r3);
-    //    } catch (RegistryException e) {
-    //        fail("Couldn't put a content resource in to path /c10022/r3");
-    //    }
-    //
-    //    String r4Content = "this is the r4 content.";
-    //    Resource r4 = new Resource();
-    //    r4.setContent(r4Content.getBytes());
-    //    try {
-    //        registry.put("/c1222/r4", r4);
-    //    } catch (RegistryException e) {
-    //        fail("Couldn't put a content resource in to path /c1222/r4");
-    //    }
-    //
-    //    try {
-    //        Resource results = 
registry.getResourcesOfMediaType("text/plain");
-    //        String[] resultPaths = (String[]) results.getContent();
-    //
-    //        assertTrue(containsString(resultPaths, "/r102"));
-    //        assertTrue(containsString(resultPaths, "/c10022/r3"));
-    //        assertTrue(!containsString(resultPaths, "/r101"));
-    //        assertTrue(!containsString(resultPaths, "/c1222/r4"));
-    //
-    //    } catch (RegistryException e) {
-    //        e.printStackTrace();
-    //    }
-    //}
-
     public void testCombinedScenario() throws RegistryException {
         // put a content resource in to the root
         String r1Content = "this is the r1 content.";

Modified: 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
==============================================================================
--- 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
   (original)
+++ 
trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/UserDetailsAction.java
   Sun Jan 13 21:03:04 2008
@@ -29,6 +29,7 @@
 public class UserDetailsAction extends AbstractRegistryAction {
 
     private String userName;
+    private String friendlyName = "";
     private List userActivity = new ArrayList();
     private List userRoles = new ArrayList();
     private List allRoles = new ArrayList();
@@ -36,18 +37,24 @@
     public String execute(HttpServletRequest request) throws RegistryException 
{
 
         setRequest(request);
-        
+
         SecureRegistry secureRegistry = (SecureRegistry) getRegistry();
         Realm realm = secureRegistry.getUserRealm();
 
         try {
+            friendlyName = (String) realm.
+                    
getUserStoreAdmin().getUserProperties(userName).get("friendlyName");
+            if (friendlyName == null) {
+                friendlyName = "";
+            }
+
             String[] rolesArray = 
realm.getUserStoreReader().getUserRoles(userName);
             for (int i = 0; i < rolesArray.length; i++) {
                 userRoles.add(rolesArray[i]);
             }
         } catch (UserManagerException e) {
             String msg = "Could not get the user information. Caused by: " + 
e.getMessage();
-            throw new RegistryException(msg);
+            throw new RegistryException(msg, e);
         }
 
         try {
@@ -82,7 +89,7 @@
                 userActivity.add(entry);
 
             }
-        }        
+        }
 
         return SUCCESS;
     }
@@ -95,6 +102,10 @@
         this.userName = userName;
     }
 
+    public String getFriendlyName() {
+        return friendlyName;
+    }
+
     public List getUserActivity() {
         return userActivity;
     }

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/user.jsp
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/user.jsp       
(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/user.jsp       Sun Jan 
13 21:03:04 2008
@@ -56,7 +56,7 @@
     <div class="box1-mid" id="userExpanded">
         <!-- all the content goes here -->
 
-
+        Friendly name: <%=userDetailsAction.getFriendlyName()%><br/>
 
         <h3>Add roles to <%=userDetailsAction.getUserName()%></h3>
 

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

Reply via email to