Author: prasad
Date: Thu Dec 6 03:20:14 2007
New Revision: 10629
Log:
Fixed defects in activity search.
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
trunk/mashup/java/modules/www/org/search.jsp
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/QueryParamUtils.java
==============================================================================
---
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 Dec 6 03:20:14 2007
@@ -41,7 +41,7 @@
} else if (path.equals(MashupConstants.MY_TOP_MASHUPS_QUERY_PATH)) {
queryString = "query=mytopmashups&scope=" + params[0];
}else if (path.equals(MashupConstants.ACTIVITY_QUERY_PATH)) {
- queryString = "query=recentactivity&resourcePath=" + params[0]
+"&filter="+ params[1] + "&activityScope="+ params[2]+ "&fromDate="+ params[3]+
"&toDate="+ params[4];
+ queryString = "query=recentactivity&resourcePath=" + params[0]
+"&filter="+ params[1] + "&activityScope="+ params[2]+ "&period="+ params[3];
}
if (path.equals(MashupConstants.CUSTOM_QUERY_PATH) ||
path.equals(MashupConstants.MY_CUSTOM_QUERY_PATH)) {
Modified:
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
==============================================================================
---
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
(original)
+++
trunk/mashup/java/modules/core/src/org/wso2/mashup/webapp/utils/RegistryUtils.java
Thu Dec 6 03:20:14 2007
@@ -32,6 +32,9 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
+import java.util.Date;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
public class RegistryUtils {
@@ -189,29 +192,34 @@
params[2] = null;
}
if (params[3] != null && params[3].equals("null")) {
- params[3] = null;
- }
- if (params[4] != null && params[4].equals("null")) {
- params[4] = null;
+ params[3] = "30 days";
}
int filterValue = -1;
- if (params[1] != null && params[1].equals("-1")) {
- // filterValue = LogEntry.UPDATE;
- filterValue = -1;
-
+ if (params[1] != null && params[1].equals("1")) {
+ filterValue = LogEntry.UPDATE;
} else if (params[1] != null && params[1].equals("2")) {
filterValue = LogEntry.COMMENT;
-
} else if (params[1] != null && params[1].equals("3")) {
filterValue = LogEntry.TAG;
-
} else if (params[1] != null && params[1].equals("4")) {
filterValue = LogEntry.RATING;
+ }
+ int days = 0;
+ if (params[3].equals("6 months")) {
+ days = -180;
+ } else {
+ days = -30;
}
+
+ Calendar today = new GregorianCalendar();
+ Date toDate = today.getTime();
+ today.add(Calendar.DATE, days);
+ Date fromDate = today.getTime();
+
// System.out.println(Arrays.toString(params));
- LogEntry[] logs = registry.getLogs(params[0], filterValue,
params[2], null, null);
+ LogEntry[] logs = registry.getLogs(params[0], filterValue,
params[2], fromDate, toDate);
for (int i = 0; i < logs.length; i++) {
QueryResult queryResult = new QueryResult();
@@ -223,11 +231,13 @@
if
(!logEntry.getUserName().equals(RegistryConstants.ANONYMOUS_USER)) {
if (logEntry.getAction() == LogEntry.UPDATE) {
- /* entry = logEntry.getUserName() + " has updated
the resource '" +
- logEntry.getResourcePath() + "' on " +
logEntry.getDate().toString() +
- ".";
- */
- continue;
+ if (!logEntry.getResourcePath().contains("/users/")) {
+ entry = logEntry.getUserName() + " has updated the
resource '" +
+ logEntry.getResourcePath() + "' on " +
logEntry.getDate().toString() +
+ ".";
+ } else {
+ continue;
+ }
} else if (logEntry.getAction() == LogEntry.COMMENT) {
entry = logEntry.getUserName() + " has commented on
resource '" +
logEntry.getResourcePath() + "' on " +
logEntry.getDate().toString() +
Modified: trunk/mashup/java/modules/www/org/search.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/search.jsp (original)
+++ trunk/mashup/java/modules/www/org/search.jsp Thu Dec 6 03:20:14 2007
@@ -14,23 +14,39 @@
* limitations under the License.
--%>
<%@ page import="com.sun.syndication.feed.synd.SyndContent"
-%><%@ page import="com.sun.syndication.feed.synd.SyndContentImpl"
-%><%@ page import="com.sun.syndication.feed.synd.SyndEntry"
-%><%@ page import="com.sun.syndication.feed.synd.SyndEntryImpl"
-%><%@ page import="com.sun.syndication.feed.synd.SyndFeed"
-%><%@ page import="com.sun.syndication.feed.synd.SyndFeedImpl"
-%><%@ page import="com.sun.syndication.io.SyndFeedOutput"
-%><%@ page import="org.wso2.mashup.MashupConstants"
-%><%@ page import="org.wso2.mashup.utils.QueryResult"
-%><%@ page import="org.wso2.mashup.utils.QueryResults"
-%><%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler"
-%><%@ page import="org.wso2.mashup.webapp.identity.Registration"
-%><%@ page import="org.wso2.mashup.webapp.userprofile.User"
-%><%@ page import="org.wso2.mashup.webapp.userprofile.UserQuery"
-%><%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils"
-%><%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils"
-%><%@ page import="org.wso2.registry.Comment"
-%>
+ %>
+<%@ page import="com.sun.syndication.feed.synd.SyndContentImpl"
+ %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntry"
+ %>
+<%@ page import="com.sun.syndication.feed.synd.SyndEntryImpl"
+ %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeed"
+ %>
+<%@ page import="com.sun.syndication.feed.synd.SyndFeedImpl"
+ %>
+<%@ page import="com.sun.syndication.io.SyndFeedOutput"
+ %>
+<%@ page import="org.wso2.mashup.MashupConstants"
+ %>
+<%@ page import="org.wso2.mashup.utils.QueryResult"
+ %>
+<%@ page import="org.wso2.mashup.utils.QueryResults"
+ %>
+<%@ page import="org.wso2.mashup.webapp.identity.InfoCardHandler"
+ %>
+<%@ page import="org.wso2.mashup.webapp.identity.Registration"
+ %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.User"
+ %>
+<%@ page import="org.wso2.mashup.webapp.userprofile.UserQuery"
+ %>
+<%@ page import="org.wso2.mashup.webapp.utils.QueryParamUtils"
+ %>
+<%@ page import="org.wso2.mashup.webapp.utils.RegistryUtils"
+ %>
+<%@ page import="org.wso2.registry.Comment"
+ %>
<%@ page import="org.wso2.registry.LogEntry" %>
<%@ page import="org.wso2.registry.Registry" %>
<%@ page import="org.wso2.registry.RegistryConstants" %>
@@ -121,7 +137,7 @@
String queryTitle = "";
String queryPath = "";
- String[] queryParams = new String[] { };
+ String[] queryParams = new String[]{};
QueryResults results = null;
if (query != null) {
@@ -136,7 +152,7 @@
queryTitle = (currentUser.equals(searchScope) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" mashups";
queryPath = MashupConstants.MY_MASHUPS_QUERY_PATH;
- queryParams = new String[] { searchScope };
+ queryParams = new String[]{searchScope};
} else if (query.equalsIgnoreCase("topmashups")) {
// Run the predefined query for "Highest Rated Mashups"
@@ -149,14 +165,14 @@
queryTitle = (currentUser.equals(searchScope) ? "My" :
RegistryUtils.getFullName(request, searchScope) + "'s") +
" highest rated mashups";
queryPath = MashupConstants.MY_TOP_MASHUPS_QUERY_PATH;
- queryParams = new String[] { searchScope };
+ queryParams = new String[]{searchScope};
} else if (query.equalsIgnoreCase("custom") &&
searchScope.equalsIgnoreCase("all")) {
// Run a customized query within all mashups as defined by the
search phrase and locations
// todo: suboptimal query. Better would be to leave out clauses
that don't apply
- String[] params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
+ String[] params = new String[]{MashupConstants.IMPOSSIBLE_VALUE,
MashupConstants.IMPOSSIBLE_VALUE,
- MashupConstants.IMPOSSIBLE_VALUE }; // prevent matches by
default
+ MashupConstants.IMPOSSIBLE_VALUE}; // prevent matches by
default
queryTitle = "Mashups ";
if (includeTags) {
queryTitle += "tagged '" + searchFor + "' ";
@@ -184,9 +200,9 @@
} else if (query.equalsIgnoreCase("custom")) {
// Run a customized query within the mashups of a certain user as
defined by the search phrase and locations
// todo: suboptimal query. Better would be to leave out clauses
that don't apply
- String[] params = new String[] { MashupConstants.IMPOSSIBLE_VALUE,
+ String[] params = new String[]{MashupConstants.IMPOSSIBLE_VALUE,
MashupConstants.IMPOSSIBLE_VALUE,
MashupConstants.IMPOSSIBLE_VALUE,
- searchScope };
+ searchScope};
queryTitle = RegistryUtils.getFullName(request, searchScope) + "'s
mashups ";
if (includeTags) {
queryTitle += "tagged '" + searchFor + "' ";
@@ -214,22 +230,25 @@
} else if (query.equalsIgnoreCase("activity")) {
// Run with a dummy query path to search activity log
String resourcePath = null;
- String fromDate = null;
- String toDate = null;
queryPath = MashupConstants.ACTIVITY_QUERY_PATH;
- if(paramActivityScope== null || paramActivityScope.equals("null")){
queryTitle ="All ";}else{queryTitle = RegistryUtils.getFullName(request,
searchScope)+"'s "; }
- queryTitle += "activity for last " + paramPeriod + " on ";
- if(paramFilter.equals("-1")){
+ if (paramActivityScope == null ||
paramActivityScope.equals("null")) {
+ queryTitle = "All ";
+ } else {
+ queryTitle = RegistryUtils.getFullName(request,
paramActivityScope) + "'s ";
+ }
+ queryTitle += "activity for last " + paramPeriod + " on ";
+ if (paramFilter.equals("-1")) {
queryTitle += "any";
- }else if(paramFilter.equals("2")){
+ } else if (paramFilter.equals("1")) {
+ queryTitle += "mashups";
+ } else if (paramFilter.equals("2")) {
queryTitle += "comments";
- } else if(paramFilter.equals("3")){
+ } else if (paramFilter.equals("3")) {
queryTitle += "taggings";
- }else if(paramFilter.equals("4")){
- queryTitle += "rating";
+ } else if (paramFilter.equals("4")) {
+ queryTitle += "rating";
}
-
- queryParams = new String[]{resourcePath, paramFilter,
paramActivityScope, fromDate, toDate};
+ queryParams = new String[]{resourcePath, paramFilter,
paramActivityScope, paramPeriod};
} else {
@@ -241,7 +260,7 @@
}
results = RegistryUtils.doQuery(registry, queryTitle, queryPath,
queryParams,
- MashupConstants.MAX_RESULTS_COUNT);
+ MashupConstants.MAX_RESULTS_COUNT);
}
if (format != null) {
@@ -256,11 +275,11 @@
if (query == null) {
queryTitle = "All Mashups";
queryPath = MashupConstants.ALL_MASHUPS_QUERY_PATH;
- queryParams = new String[] { };
+ queryParams = new String[]{};
results = RegistryUtils.doQuery(registry, queryTitle, queryPath,
queryParams,
- MashupConstants.MAX_RESULTS_COUNT);
+ MashupConstants.MAX_RESULTS_COUNT);
- }
+ }
//Setting the feed type according to the user request
if (format.equalsIgnoreCase("rss")) {
@@ -281,14 +300,14 @@
file += '?' + request.getQueryString();
}
URL reconstructedURL = new URL(request.getScheme(),
- request.getServerName(),
- request.getServerPort(),
- file);
+ request.getServerName(),
+ request.getServerPort(),
+ file);
feed.setLink(reconstructedURL.toString());
if (results != null) {
Iterator iter = results.getResults().iterator();
-
+
while (iter.hasNext()) {
QueryResult result = (QueryResult) iter.next();
@@ -296,7 +315,7 @@
entry.setTitle(result.getName());
entry.setPublishedDate(today);
entry.setAuthor("WSO2 Mashup Server");
-
+
SyndContent description = new SyndContentImpl();
description.setType("text/html");
description.setValue(result.getDescription());
@@ -510,8 +529,14 @@
</select>
for last
<select name="period" id="period">
- <option value="30 days" <% if (paramPeriod == null ||
paramPeriod.equals("30 days")) { %>selected="selected"<% } %>>30 days</option>
- <option value="6 months" <% if (paramPeriod != null &&
paramPeriod.equals("6 months")) { %>selected="selected"<% } %>>6 months</option>
+ <option value="30 days"
+ <% if (paramPeriod == null ||
paramPeriod.equals("30 days")) { %>selected="selected"<% } %>>
+ 30 days
+ </option>
+ <option value="6 months"
+ <% if (paramPeriod != null &&
paramPeriod.equals("6 months")) { %>selected="selected"<% } %>>
+ 6 months
+ </option>
</select>
on
<select name="filter" id="RecentActivity_filter">
@@ -519,6 +544,10 @@
<% if (paramFilter == null ||
paramFilter.equals("-1")) { %>selected="selected"<% } %>>
Any
</option>
+ <option value="1"
+ <% if (paramFilter != null &&
paramFilter.equals("1")) { %>selected="selected"<% } %>>
+ Mashups
+ </option>
<option value="2"
<% if (paramFilter != null &&
paramFilter.equals("2")) { %>selected="selected"<% } %>>
Comments
@@ -550,6 +579,7 @@
<%
+
boolean isNewQuery = true;
String pathString = QueryParamUtils.paramsFromQuery(queryPath,
queryParams);
User user = RegistryUtils.getUserProfile(currentUser, registry);
@@ -563,17 +593,20 @@
}
}
+
%>
<div class="heading"><%= queryTitle%>
<span class="edit-link" title="RSS feed">[<a
- href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath,
queryParams)%>&format=rss" target="_blank">RSS</a>]</span>
+ href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath,
queryParams)%>&format=rss" target="_blank">RSS</a>]</span>
<span class="edit-link" title="Atom feed">[<a
- href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath,
queryParams)%>&format=atom" target="_blank">Atom</a>]</span>
+ href="search.jsp?<%=QueryParamUtils.paramsFromQuery(queryPath,
queryParams)%>&format=atom" target="_blank">Atom</a>]</span>
</div>
<%
+
if(results.getResultsType().equals("activity")){
+
%>
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="data">
@@ -610,7 +643,7 @@
<td width="10" valign="top"><img src="images/ra.gif"/></td>
<td valign="top" width="100%">
<%= result.getContentString() %>
-
+
</td>
</tr>
@@ -623,7 +656,7 @@
<td nowrap>
<a class="updatableName"
href="user.jsp?name=<%=result.getAuthor()%>"><%=RegistryUtils.getFullName(request,
-
result.getAuthor())%>
+ result.getAuthor())%>
</a>
</td>
<td><%=result.getDescription() %>
_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev