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)
{
int index = 0;
QueryLocator ql = new QueryLocator(QueryLocator.QUERY_ALL);
ArrayList entries = new ArrayList();
Iterator i = Profiler.query(ql);
// Is filtering requested?
String filterValue = rundata.getParameters().getString(FILTER_VALUE);
if (filterValue != null && !filterValue.trim().equalsIgnoreCase(""))
{
String filterType = rundata.getParameters().getString(FILTER_TYPE, FILTER_TYPE_USER);
boolean useRE = rundata.getParameters().getBoolean(FILTER_REGEXP);
RE r = null;
RECompiler rc = null;
if (useRE)
{
try
{
rc = new RECompiler();
r = new RE();
r.setProgram(rc.compile(filterValue));
}
catch (org.apache.regexp.RESyntaxException rex)
{
logger.warn("PsmlBrowseAction: error processing regular expression [" + filterValue + "]: " +
rex.toString());
}
}
try
{
while (i.hasNext())
{
Profile profile = (Profile) i.next();
String compareValue = null;
if (filterType.equals(FILTER_TYPE_USER))
{
compareValue = profile.getUserName();
}
else if (filterType.equals(FILTER_TYPE_ROLE))
{
compareValue = profile.getRoleName(); }
else if (filterType.equals(FILTER_TYPE_GROUP))
{
compareValue = profile.getGroupName();
}
if (compareValue != null)
{
if (useRE && r.match(compareValue))
{
entries.add(profile);
}
else if (compareValue.startsWith(filterValue))
{
entries.add(profile);
}
}
}
}
catch (Exception e)
{
logger.error("Exception", e);
}
}
else
{
while (i.hasNext())
{
Profile profile = (Profile) i.next();
//System.out.println("profile["+index+"]="+profile.getPath());
entries.add(profile);
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)
{
context.put("psml", windowIterator);
if (start > 0)
{
context.put("prev", String.valueOf(prev + 1));
}
if (next <= windowIterator.getResultSetSize())
{
context.put("next", String.valueOf(next - 1));
}
}