You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2023/09/20 08:21:59 UTC
[turbine-archetypes] branch master updated: provide example pool2 parameters, search form in fluxuserlist.vm, fix criteria in fluxtools getusers method using column
This is an automated email from the ASF dual-hosted git repository.
gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-archetypes.git
The following commit(s) were added to refs/heads/master by this push:
new 29299e5 provide example pool2 parameters, search form in fluxuserlist.vm, fix criteria in fluxtools getusers method using column
29299e5 is described below
commit 29299e51cc4c1e4973f028f5acaa2c925d97bada
Author: Georg Kallidis <gk...@apache.org>
AuthorDate: Wed Sep 20 10:20:25 2023 +0200
provide example pool2 parameters, search form in fluxuserlist.vm, fix criteria in fluxtools getusers method using column
---
.../src/main/java/flux/tools/FluxTool.java | 14 ++++++++++++--
.../main/webapp/WEB-INF/conf/componentConfiguration.xml | 7 +++++++
.../webapp/templates/flux/screens/user/FluxUserList.vm | 13 +++++++++++++
3 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/src/main/resources/archetype-resources/src/main/java/flux/tools/FluxTool.java b/src/main/resources/archetype-resources/src/main/java/flux/tools/FluxTool.java
index 1bf49f5..d944228 100644
--- a/src/main/resources/archetype-resources/src/main/java/flux/tools/FluxTool.java
+++ b/src/main/resources/archetype-resources/src/main/java/flux/tools/FluxTool.java
@@ -33,7 +33,9 @@ import org.apache.fulcrum.security.torque.om.TurbineRolePermissionPeer;
import org.apache.fulcrum.security.torque.om.TurbineUserPeer;
import org.apache.fulcrum.security.util.GroupSet;
import org.apache.fulcrum.security.util.RoleSet;
+import org.apache.torque.Column;
import org.apache.torque.criteria.Criteria;
+import org.apache.torque.criteria.Criterion;
import org.apache.turbine.annotation.TurbineConfiguration;
import org.apache.turbine.annotation.TurbineService;
import org.apache.turbine.om.security.User;
@@ -243,9 +245,17 @@ public class FluxTool implements ApplicationTool, Recyclable {
if (fieldList != null) {
// This is completely database centric.
String searchField = data.getParameters().getString("searchField");
- criteria.where(fieldList, searchField, Criteria.LIKE);
+ Column searchColField =
+ fieldList.toLowerCase().contains( "username" )?
+ TurbineUserPeer.LOGIN_NAME :
+ fieldList.toLowerCase().contains( "first" )?
+ TurbineUserPeer.FIRST_NAME:
+ fieldList.toLowerCase().contains( "last" )?
+ TurbineUserPeer.LAST_NAME: TurbineUserPeer.LOGIN_NAME;
+ Criterion cond = new Criterion(searchColField, searchField,
+ (searchField.contains("%"))? Criteria.LIKE: Criteria.EQUAL);
+ criteria.where(cond);
}
-
return (List<User>) security.getUserManager().retrieveList(criteria);
} catch (Exception e) {
log.error("Could not retrieve user list: " + e.toString());
diff --git a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
index 31bbc44..cc6e8df 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
+++ b/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/conf/componentConfiguration.xml
@@ -50,6 +50,13 @@
<!-- <urlCaseFolding>lower</urlCaseFolding> -->
<parameterEncoding>utf-8</parameterEncoding>
<automaticUpload>true</automaticUpload>
+ <pool2>
+ <!-- cft. defaults in org.apache.commons.pool2.impl.BaseObjectPoolConfig and GenericKeyedObjectPoolConfig -->
+ <maxTotal>1024</maxTotal>
+ <!-- if set to false, set maxWaitMillis to zero-->
+ <blockWhenExhausted>true</blockWhenExhausted>
+ <maxWaitMillis>500</maxWaitMillis>
+ </pool2>
</parser>
<!-- defining specific inspectors -->
<json>
diff --git a/src/main/resources/archetype-resources/src/main/webapp/templates/flux/screens/user/FluxUserList.vm b/src/main/resources/archetype-resources/src/main/webapp/templates/flux/screens/user/FluxUserList.vm
index cdc0d43..504b2bc 100644
--- a/src/main/resources/archetype-resources/src/main/webapp/templates/flux/screens/user/FluxUserList.vm
+++ b/src/main/resources/archetype-resources/src/main/webapp/templates/flux/screens/user/FluxUserList.vm
@@ -1,5 +1,18 @@
#set ( $headings = ["Username","First Name", "Last Name", "Email", "Admin" ] )
+<table class="w3-table w3-striped w3-bordered">
+ <tr>
+ <td>Search:</td>
+ <td>
+ <form method="post" action="$link.setPage("user,FluxUserList.vm")">
+ $flux.getUserFieldList()
+ <input type="text" name="searchField" value="">
+ <input type="submit" name="eventSubmit_doDefault" value="Filter Users">
+ </form><br>
+ <a href="$link.setPage("user,FluxUserList.vm").addQueryData( "fieldList", "username" ).addQueryData( "searchField", "admin" )" class="w3-btn w3-round w3-blue w3-border w3-border-blue">Admin Users</a>
+ </td>
+ </tr>
+</table>
<div class="w3-container w3-padding"> <h2>Current Users</h2> </div>