[Registry-dev] svn commit r19778 - in trunk/registry/modules/webapps/src/main: java/org/wso2/registry/web java/org/wso2/registry/web/actions webapp/admin

kalani at wso2.com kalani at wso2.com
Mon Jul 21 03:42:32 PDT 2008


Author: kalani
Date: Mon Jul 21 03:42:32 2008
New Revision: 19778
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19778

Log:
Integrated the content search functionality with the UI


Modified:
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
   trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
   trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp
   trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java?rev=19778&r1=19777&r2=19778&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/ControllerServlet.java	Mon Jul 21 03:42:32 2008
@@ -1159,7 +1159,11 @@
     private void forwardToSearch(HttpServletRequest request, HttpServletResponse response) {
 
         SearchAction searchAction = new SearchAction();
-        searchAction.setTag(request.getParameter("criteria"));
+        if(request.getParameter("searchType").equals("Tag")){
+            searchAction.setTag(request.getParameter("criteria"));
+        }else{
+            searchAction.setContent(request.getParameter("criteria"));
+        }
 
         try {
             searchAction.execute(request);

Modified: trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java?rev=19778&r1=19777&r2=19778&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java	(original)
+++ trunk/registry/modules/webapps/src/main/java/org/wso2/registry/web/actions/SearchAction.java	Mon Jul 21 03:42:32 2008
@@ -33,6 +33,8 @@
      */
     private String tag;
 
+    private String content;
+
     /**
      * Path of a query.
      */
@@ -91,7 +93,42 @@
 
 
             }
-        } 
+        }
+
+        if(content != null && content.length() != 0){
+            String [] paths = (String [])registry.searchContent(content).getContent();
+            for(int i=0; i<paths.length; i++){
+                ResourceData resourceData = new ResourceData();
+                resourceData.setResourcePath(paths[i]);
+
+                if (paths[i] != null) {
+                    if (paths[i].equals(RegistryConstants.ROOT_PATH)) {
+                        resourceData.setName(RegistryConstants.ROOT_PATH);
+                    } else {
+                        String[] parts = paths[i].split(RegistryConstants.PATH_SEPARATOR);
+                        resourceData.setName(parts[parts.length - 1]);
+                    }
+                }
+
+                 try {
+                    Resource child = registry.get(paths[i]);
+
+                    resourceData.setResourceType(child instanceof Collection ?
+                            ResourceData.COLLECTION : ResourceData.RESOURCE);
+                    resourceData.setAuthorUserName(child.getAuthorUserName());
+                    resourceData.setDescription(child.getDescription());
+                    resourceData.setAverageRating(registry.getAverageRating(child.getPath()));
+                    resourceData.setCreatedOn(child.getCreatedTime());
+                  //  resourceData.setTagCounts(taggedPath.getTagCounts());
+                    calculateAverageStars(resourceData);
+
+                    resourceDataList.add(resourceData);
+
+                } catch (AuthorizationFailedException e) {
+                    // do not show unauthorized resources in search results
+                }
+            }
+        }
 
         status = "success";
         return SUCCESS;
@@ -105,6 +142,14 @@
         this.tag = tag;
     }
 
+    public String getContent(){
+        return content;
+    }
+
+    public void setContent(String content){
+        this.content = content;
+    }
+
     public String getQueryPath() {
         return queryPath;
     }

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp?rev=19778&r1=19777&r2=19778&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/header.jsp	Mon Jul 21 03:42:32 2008
@@ -161,6 +161,12 @@
                         <td class="top-menu">
                             <input type="text" name="criteria" id="criteria"  class="input-text" />
                         </td>
+                        <td class="top-menu">
+                           <select name="searchType" id="searchType">
+                           <option VALUE="Tag">Tag</option>
+                               <option VALUE="Content">Content</option>
+                            </select>
+                        </td>
                         <td valign="middle" class="top-menu" style="margin-top:-50px;">
                             <a href="#" onclick="submitSearchForm();" title="Search" ><img src="/wso2registry/admin/images/icon-search.gif" border="0" /></a><!-- input type="submit" class="button" value="Search" / -->
                         </td>

Modified: trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp
URL: http://wso2.org/svn/browse/wso2/trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp?rev=19778&r1=19777&r2=19778&view=diff
==============================================================================
--- trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp	(original)
+++ trunk/registry/modules/webapps/src/main/webapp/admin/search.jsp	Mon Jul 21 03:42:32 2008
@@ -48,7 +48,7 @@
             	Iterator i = resourceDataList.iterator();
             	if(resourceDataList.isEmpty()){
             	%>
-	Your search did not match any resources tagged with <h3 style="display:inline;margin-left:0px;"><%=request.getParameter("criteria")%></h3>. 
+	Your search did not match any resources tagged with/including <h3 style="display:inline;margin-left:0px;"><%=request.getParameter("criteria")%></h3>.
 	<ul class="normalList">
 		<li>Make sure all words are spelled correctly.</li>
     		<li>Try different keywords.</li>



More information about the Registry-dev mailing list