Author: jonathan
Date: Thu Jul 10 15:03:25 2008
New Revision: 19109
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=19109

Log:
MASHUP-915 and redone MASHUP-784 fix.

Modified:
   
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
   trunk/mashup/java/modules/www/search.jsp

Modified: 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java?rev=19109&r1=19108&r2=19109&view=diff
==============================================================================
--- 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
        (original)
+++ 
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
        Thu Jul 10 15:03:25 2008
@@ -106,19 +106,19 @@
         } else if (path.equals(MashupConstants.CUSTOM_QUERY_PATH) ||
                 path.equals(MashupConstants.MY_CUSTOM_QUERY_PATH)) {
             queryString = "query=mashups";
-            int tokenIndex = 2;
             if (path.equals(MashupConstants.MY_CUSTOM_QUERY_PATH)) {
                 queryString += "&scope=" + params[3];
             }
 
-            tokenIndex = 1;
-
             // Extract the search value from the first of descriptions, 
titles, tags, that
             if (!params[0].equals(MashupConstants.IMPOSSIBLE_VALUE)) {
-                queryString += "&for=" + params[0].split("\\%")[tokenIndex];
+                // param[0] is the title, in the form /mashup/%/%searchterm% - 
extract 'searchterm'
+                queryString += "&for=" + params[0].split("\\%")[2];
             } else if (!params[1].equals(MashupConstants.IMPOSSIBLE_VALUE)) {
-                queryString += "&for=" + params[1].split("\\%")[tokenIndex];
+                // param[1] is the description, in the form %searchterm% - 
extract 'searchterm'
+                queryString += "&for=" + params[1].split("\\%")[1];
             } else if (!params[2].equals(MashupConstants.IMPOSSIBLE_VALUE)) {
+                // param[2] is the tags - no % since we always look for exact 
matches for tags.
                 queryString += "&for=" + params[2];
             }
 

Modified: trunk/mashup/java/modules/www/search.jsp
URL: 
http://wso2.org/svn/browse/wso2/trunk/mashup/java/modules/www/search.jsp?rev=19109&r1=19108&r2=19109&view=diff
==============================================================================
--- trunk/mashup/java/modules/www/search.jsp    (original)
+++ trunk/mashup/java/modules/www/search.jsp    Thu Jul 10 15:03:25 2008
@@ -134,50 +134,28 @@
             queryPath = MashupConstants.MY_MASHUPS_QUERY_PATH;
             queryParams = new String[] { searchScope };
 
-        } else if (query.equalsIgnoreCase("mashups") && 
searchScope.equals("")) {
-
-            // Set up the customized query within all mashups as defined by 
the search phrase and locations
-            queryTitle = "Mashups ";
-            queryPath = MashupConstants.CUSTOM_QUERY_PATH;
-
+        } else if (query.equalsIgnoreCase("mashups")) {
             // todo: suboptimal query.  Better would be to leave out clauses 
that don't apply
-            String[] params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
-                    MashupConstants.IMPOSSIBLE_VALUE,
-                    MashupConstants.IMPOSSIBLE_VALUE }; // prevent matches by 
default
 
-            if (includeTags) {
-                queryTitle += "tagged '" + searchFor + "' ";
-                params[2] = searchFor;
-                if (includeTitles || includeDescriptions) {
-                    queryTitle += "or ";
-                }
-            }
-            if (includeTitles || includeDescriptions) {
-                queryTitle += "containing '" + searchFor + "' in ";
-            }
-            if (includeTitles) {
-                queryTitle += "titles";
-                if (includeDescriptions) queryTitle += " or ";
-                params[0] = MashupConstants.ALL_MASHUPS_PATH + "/%/%" + 
searchFor + '%';
-            }
-            if (includeDescriptions) {
-                queryTitle += "descriptions";
-                params[1] = '%' + searchFor + '%';
+            String[] params;
+            // Set up the customized query within all mashups as defined by 
the search phrase and locations
+            if (searchScope.equals("")) {
+                queryTitle = "Mashups ";
+                queryPath = MashupConstants.CUSTOM_QUERY_PATH;
+                params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
+                        MashupConstants.IMPOSSIBLE_VALUE,
+                        MashupConstants.IMPOSSIBLE_VALUE }; // prevent matches 
by default
+            } else {
+                queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? 
"My" :
+                        RegistryUtils.getFullName(request, searchScope) + 
"'s") + " mashups ";
+                queryPath = MashupConstants.MY_CUSTOM_QUERY_PATH;
+                params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
+                        MashupConstants.IMPOSSIBLE_VALUE,
+                        MashupConstants.IMPOSSIBLE_VALUE,
+                        searchScope}; // prevent matches by default
             }
 
-            queryParams = params;
-
-        } else if (query.equalsIgnoreCase("mashups")) {
-
-            // Set up the customized query within the mashups of a certain 
user as defined by the search phrase and locations
-            queryTitle = ((currentUser.equals(searchScope) && !isFeed) ? "My" :
-                    RegistryUtils.getFullName(request, searchScope) + "'s") + 
" mashups ";
-            queryPath = MashupConstants.MY_CUSTOM_QUERY_PATH;
 
-            // todo: suboptimal query.  Better would be to leave out clauses 
that don't apply
-            String[] params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
-                    MashupConstants.IMPOSSIBLE_VALUE, 
MashupConstants.IMPOSSIBLE_VALUE,
-                    searchScope };
             if (includeTags) {
                 queryTitle += "tagged '" + searchFor + "' ";
                 params[2] = searchFor;
@@ -191,7 +169,7 @@
             if (includeTitles) {
                 queryTitle += "titles";
                 if (includeDescriptions) queryTitle += " or ";
-                params[0] = "/mashups/%" + searchFor + '%';
+                params[0] = MashupConstants.ALL_MASHUPS_PATH + "/%/%" + 
searchFor + '%';
             }
             if (includeDescriptions) {
                 queryTitle += "descriptions";

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

Reply via email to