morciuch 2002/12/05 09:06:44
Modified: docs/site changes.html
src/java/org/apache/jetspeed/modules/actions/portlets
PsmlBrowseAction.java
webapp/WEB-INF/templates/vm/portlets/html browser-psml.vm
xdocs changes.xml
Log:
Fixed paging in Psml Browser when page size is exceeded (see Bugzilla issue #
14747). Since the window iterator is now cached, the user may have to click the
Refresh button to see any external psml changes.
Also, implemented pattern filtering.
Revision Changes Path
1.77 +6 -0 jakarta-jetspeed/docs/site/changes.html
Index: changes.html
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/docs/site/changes.html,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -r1.76 -r1.77
--- changes.html 29 Nov 2002 19:26:09 -0000 1.76
+++ changes.html 5 Dec 2002 17:06:43 -0000 1.77
@@ -133,6 +133,12 @@
</li>
-->
<li>
+ Add - 2002/12/05 - PsmlBrowser now supports pattern searches (MO)
+</li>
+<li>
+ Fixed - 2002/12/05 - PsmlBrowser portlet won't page correctly if page size is
exceeded (MO)
+</li>
+<li>
Add - 2002/11/29 - Added l10n jsp tag - JetspeedL10NTag (MO)
</li>
<li>
1.9 +83 -29
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlBrowseAction.java
Index: PsmlBrowseAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/PsmlBrowseAction.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PsmlBrowseAction.java 11 Oct 2002 20:07:17 -0000 1.8
+++ PsmlBrowseAction.java 5 Dec 2002 17:06:43 -0000 1.9
@@ -75,6 +75,9 @@
import java.util.ArrayList;
import java.util.Iterator;
+// regexp stuff
+import org.apache.regexp.RE;
+
/**
* This action enables to browse any of the psml info, for displaying
* available entries and information on these entries
@@ -96,6 +99,9 @@
/** name of the parameter that holds the filter value */
public static final String FILTER_VALUE = "filter_value";
+ /** name of the parameter that holds the regexp flag */
+ public static final String FILTER_REGEXP = "filter_regexp";
+
/** name of the parameter that holds the filter type */
public static final String FILTER_TYPE = "filter_type";
@@ -152,56 +158,78 @@
//System.out.println("start="+start+" size="+size+" next="+next+"
prev="+prev);
//check to see if resultset has changed due to PsmlUpdateAction
- //if so reconstruct the iterator and rest the flag
- /*
+ //if so reconstruct the iterator and reset the flag
+
boolean refreshFlag = (rundata.getUser().getTemp(PSML_REFRESH_FLAG,
FALSE)).equals(TRUE);
rundata.getUser().setTemp(PSML_REFRESH_FLAG, FALSE);
- */
+
//Get the iterator
DatabaseBrowserIterator windowIterator =
(DatabaseBrowserIterator) PortletSessionState.getAttribute(portlet,
rundata, PROFILE_ITERATOR);
- //if ((windowIterator == null) || refreshFlag)
+ if ((windowIterator == null) || refreshFlag)
{
int index = 0;
+ QueryLocator ql = new QueryLocator(QueryLocator.QUERY_ALL);
+ ArrayList entries = new ArrayList();
+ Iterator i = Profiler.query(ql);
// Is filtering requested?
- QueryLocator ql = null;
String filterValue =
rundata.getParameters().getString(this.FILTER_VALUE);
if (filterValue != null && !filterValue.trim().equalsIgnoreCase(""))
{
String filterType =
rundata.getParameters().getString(this.FILTER_TYPE, this.FILTER_TYPE_USER);
try
{
- if (filterType.equals(this.FILTER_TYPE_USER))
- {
- ql = new QueryLocator(QueryLocator.QUERY_USER);
- ql.setUser(JetspeedSecurity.getUser(filterValue));
- }
- else if (filterType.equals(this.FILTER_TYPE_ROLE))
- {
- ql = new QueryLocator(QueryLocator.QUERY_ROLE);
- ql.setRole(JetspeedSecurity.getRole(filterValue));
- }
- else if (filterType.equals(this.FILTER_TYPE_GROUP))
+ while (i.hasNext())
{
- ql = new QueryLocator(QueryLocator.QUERY_GROUP);
- ql.setGroup(JetspeedSecurity.getGroup(filterValue));
+ Profile profile = (Profile) i.next();
+ String compareValue = null;
+ if (filterType.equals(this.FILTER_TYPE_USER))
+ {
+ compareValue = profile.getUserName();
+ }
+ else if (filterType.equals(this.FILTER_TYPE_ROLE))
+ {
+ compareValue = profile.getRoleName();
}
+ else if (filterType.equals(this.FILTER_TYPE_GROUP))
+ {
+ compareValue = profile.getGroupName();
+ }
+
+ boolean useRE =
rundata.getParameters().getBoolean(this.FILTER_REGEXP);
+ if (useRE)
+ {
+ try
+ {
+ RE r = new RE(filterValue);
+ r.setMatchFlags(RE.MATCH_CASEINDEPENDENT);
+ if (r.match(compareValue))
+ {
+ entries.add(profile);
+ }
+ }
+ catch (Exception re)
+ {
+ Log.warn("PsmlBrowseAction: error processing
regular expression [" + filterValue + "]: " +
+ re.toString());
+ }
+ }
+ else
+ {
+ if (compareValue != null &&
compareValue.startsWith(filterValue))
+ {
+ entries.add(profile);
+ }
+ }
}
}
catch (Exception e)
{
- ql = null;
+ Log.error(e);
}
}
else
{
- ql = new QueryLocator(QueryLocator.QUERY_ALL);
- }
-
- ArrayList entries = new ArrayList();
- if (ql != null)
- {
- Iterator i = Profiler.query(ql);
while (i.hasNext())
{
Profile profile = (Profile) i.next();
@@ -210,16 +238,17 @@
index++;
}
}
+
ArrayList entryType = new ArrayList();
entryType.add("Profile");
windowIterator = new DatabaseBrowserIterator(entries, entryType,
entryType, size);
PortletSessionState.setAttribute(portlet, rundata, PROFILE_ITERATOR,
windowIterator);
- }/*
+ }
else
{
windowIterator.setTop(start);
}
- */
+
if (windowIterator != null)
{
@@ -266,6 +295,31 @@
}
}
+ buildNormalContext(portlet, context, rundata);
+ }
+
+ /**
+ * This method is to refresh psml from disk or database.
+ * @param data The turbine rundata context for this request.
+ * @param context The velocity context for this request.
+ */
+ public void doRefresh(RunData rundata, Context context)
+ {
+ VelocityPortlet portlet = (VelocityPortlet) context.get("portlet");
+ PortletSessionState.clearAttribute(portlet, rundata, PROFILE_ITERATOR);
+ rundata.getParameters().remove(this.FILTER_VALUE);
+ buildNormalContext(portlet, context, rundata);
+ }
+
+ /**
+ * This method is to enter filtering mode.
+ * @param data The turbine rundata context for this request.
+ * @param context The velocity context for this request.
+ */
+ public void doFilter(RunData rundata, Context context)
+ {
+ VelocityPortlet portlet = (VelocityPortlet) context.get("portlet");
+ PortletSessionState.clearAttribute(portlet, rundata, PROFILE_ITERATOR);
buildNormalContext(portlet, context, rundata);
}
1.12 +7 -2
jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/browser-psml.vm
Index: browser-psml.vm
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/webapp/WEB-INF/templates/vm/portlets/html/browser-psml.vm,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- browser-psml.vm 11 Oct 2002 20:07:17 -0000 1.11
+++ browser-psml.vm 5 Dec 2002 17:06:44 -0000 1.12
@@ -1,14 +1,19 @@
#set ( $filter = $data.getRequest().getParameter("filter_value") )
#set ( $filter_type = $data.getRequest().getParameter("filter_type") )
+#set ( $regexp = $data.getRequest().getParameter("filter_regexp") )
<form method="post">
-<b>Filter string (exact match):</b> <input type="Text" name="filter_value"
value="$!filter"/>
+<b>Filter string:</b> <input type="Text" name="filter_value" value="$!filter"/>
<select name="filter_type">
<option value="filter_type_user" #if ($filter_type == "filter_type_user")
selected #end>User</option>
<option value="filter_type_role" #if ($filter_type == "filter_type_role")
selected #end>Role</option>
<option value="filter_type_group" #if ($filter_type == "filter_type_group")
selected #end>Group</option>
</select>
-<input type="submit" value="Filter"/>
+<input type="submit" name="eventSubmit_doFilter" value="Filter"/>
+<INPUT TYPE="CHECKBOX" NAME="filter_regexp" #if($!regexp) checked #end/> Use
regular expressions
+</form>
+<form method="post">
+<input type="submit" name="eventSubmit_doRefresh" value="Refresh"/>
</form>
<table width=100%" border="1" cellpadding="0" cellspacing="0">
<tr>
1.98 +7 -1 jakarta-jetspeed/xdocs/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/jakarta-jetspeed/xdocs/changes.xml,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- changes.xml 29 Nov 2002 19:26:10 -0000 1.97
+++ changes.xml 5 Dec 2002 17:06:44 -0000 1.98
@@ -23,6 +23,12 @@
</li>
-->
<li>
+ Add - 2002/12/05 - PsmlBrowser now supports pattern searches (MO)
+</li>
+<li>
+ Fixed - 2002/12/05 - PsmlBrowser portlet won't page correctly if page size is
exceeded (MO)
+</li>
+<li>
Add - 2002/11/29 - Added l10n jsp tag - JetspeedL10NTag (MO)
</li>
<li>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>