001: package org.enhydra.shark.webclient.presentation;
002:
003: import org.enhydra.shark.api.admin.UserGroupManagerAdmin;
004: import org.enhydra.shark.client.utilities.SharkInterfaceWrapper;
005: import org.enhydra.shark.webclient.business.SharkUtils;
006: import org.enhydra.shark.webclient.business.XMLGroupUsersBuilder;
007: import org.enhydra.shark.webclient.presentation.utils.NavigConsts;
008: import org.enhydra.shark.webclient.spec.utils.ParamConsts;
009: import org.w3c.dom.Node;
010:
011: import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
012: import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
013:
014: public class GroupUsersHandlerPO extends BasePO {
015:
016: public Node handleDefault() throws HttpPresentationException {
017: return showPage();
018: }
019:
020: public Node handleBack() throws HttpPresentationException {
021: String from_element = myComms.request.getParameter("from");
022: String sortCriterion = myComms.request
023: .getParameter("sortCriterion");
024: String sortOrder = myComms.request.getParameter("sortAsc");
025:
026: if (sortCriterion == null) {
027: sortCriterion = "";
028: }
029: String sortAsc = "true";
030: if (sortOrder != null
031: && (sortOrder.equalsIgnoreCase("true") || sortOrder
032: .equalsIgnoreCase("false"))) {
033: sortAsc = sortOrder;
034: }
035: throw new ClientPageRedirectException(NavigConsts.GROUP_HANDLER
036: + "?from=" + from_element + "&sortCriterion="
037: + sortCriterion + "&sortAsc=" + sortAsc);
038: }
039:
040: public Node handleRefresh() throws HttpPresentationException {
041: return showPage();
042: }
043:
044: public Node handleDelete() throws HttpPresentationException {
045:
046: String from_element = myComms.request.getParameter("from");
047: String sortCriterion = myComms.request
048: .getParameter("sortCriterion");
049: String sortOrder = myComms.request.getParameter("sortAsc");
050: String username = myComms.request.getParameter("username");
051: String name = myComms.request.getParameter("name");
052:
053: if (sortCriterion == null) {
054: sortCriterion = "";
055: }
056: String sortAsc = "true";
057: if (sortOrder != null
058: && (sortOrder.equalsIgnoreCase("true") || sortOrder
059: .equalsIgnoreCase("false"))) {
060: sortAsc = sortOrder;
061: }
062: try {
063: UserGroupManagerAdmin ugma = SharkInterfaceWrapper
064: .getUserGroupAdmin();
065:
066: if (ugma != null) {
067: ugma.removeUserFromGroup(name, username);
068: }
069: } catch (Exception e) {
070: e.printStackTrace();
071: }
072: throw new ClientPageRedirectException(
073: NavigConsts.GROUP_USERS_HANDLER + "?from="
074: + from_element + "&sortCriterion="
075: + sortCriterion + "&sortAsc=" + sortAsc
076: + "&name=" + name);
077:
078: }
079:
080: public Node handleAdd() throws HttpPresentationException {
081:
082: String from_element = myComms.request.getParameter("from");
083: String sortCriterion = myComms.request
084: .getParameter("sortCriterion");
085: String sortOrder = myComms.request.getParameter("sortAsc");
086: String username = myComms.request.getParameter("ch_user");
087: String name = myComms.request.getParameter("name");
088:
089: if (sortCriterion == null) {
090: sortCriterion = "";
091: }
092: String sortAsc = "true";
093: if (sortOrder != null
094: && (sortOrder.equalsIgnoreCase("true") || sortOrder
095: .equalsIgnoreCase("false"))) {
096: sortAsc = sortOrder;
097: }
098:
099: if (username != null) {
100: try {
101: UserGroupManagerAdmin ugma = SharkInterfaceWrapper
102: .getUserGroupAdmin();
103:
104: if (ugma != null) {
105: ugma.addUserToGroup(name, username);
106: }
107: } catch (Exception e) {
108: e.printStackTrace();
109: }
110:
111: }
112: throw new ClientPageRedirectException(
113: NavigConsts.GROUP_USERS_HANDLER + "?from="
114: + from_element + "&sortCriterion="
115: + sortCriterion + "&sortAsc=" + sortAsc
116: + "&name=" + name);
117: }
118:
119: protected Node showPage() throws HttpPresentationException {
120:
121: try {
122:
123: String name = myComms.request.getParameter("name");
124: String from_element = myComms.request.getParameter("from");
125: String sortCriterion = myComms.request
126: .getParameter("sortCriterion");
127: String sortOrder = myComms.request.getParameter("sortAsc");
128: if (sortCriterion == null) {
129: sortCriterion = "";
130: }
131: String sortAsc = "true";
132: if (sortOrder != null
133: && (sortOrder.equalsIgnoreCase("true") || sortOrder
134: .equalsIgnoreCase("false"))) {
135: sortAsc = sortOrder;
136: }
137:
138: XMLGroupUsersBuilder xmlImp = new XMLGroupUsersBuilder(
139: getUsername(), myComms.application.getConfig(),
140: from_element, sortCriterion, sortAsc, name);
141: Node toRet = xmlImp.getResult(xsltParamMap);
142: xsltParamMap.put("plg_name",
143: SharkUtils.userGroupPlugginName);
144: return toRet;
145: } catch (Exception ex) {
146: ex.printStackTrace();
147: throw new PresentationException("Can't show page", ex);
148: }
149: }
150:
151: public String getXSLTransformation() throws Exception {
152: return getXSLTTransformation(ParamConsts.PROPERTY_PREFIX_GROUP_USERS);
153: }
154:
155: }
|