001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.enterpriseadmin.action;
022:
023: import com.liferay.portal.kernel.util.ParamUtil;
024: import com.liferay.portal.model.Address;
025: import com.liferay.portal.model.EmailAddress;
026: import com.liferay.portal.model.OrgLabor;
027: import com.liferay.portal.model.Organization;
028: import com.liferay.portal.model.PasswordPolicy;
029: import com.liferay.portal.model.Phone;
030: import com.liferay.portal.model.Role;
031: import com.liferay.portal.model.UserGroup;
032: import com.liferay.portal.model.Website;
033: import com.liferay.portal.service.AddressServiceUtil;
034: import com.liferay.portal.service.EmailAddressServiceUtil;
035: import com.liferay.portal.service.OrgLaborServiceUtil;
036: import com.liferay.portal.service.OrganizationServiceUtil;
037: import com.liferay.portal.service.PasswordPolicyLocalServiceUtil;
038: import com.liferay.portal.service.PhoneServiceUtil;
039: import com.liferay.portal.service.RoleServiceUtil;
040: import com.liferay.portal.service.UserGroupServiceUtil;
041: import com.liferay.portal.service.WebsiteServiceUtil;
042: import com.liferay.portal.util.PortalUtil;
043: import com.liferay.portal.util.WebKeys;
044:
045: import javax.portlet.ActionRequest;
046: import javax.portlet.RenderRequest;
047:
048: import javax.servlet.http.HttpServletRequest;
049:
050: /**
051: * <a href="ActionUtil.java.html"><b><i>View Source</i></b></a>
052: *
053: * @author Brian Wing Shun Chan
054: * @author Alexander Chow
055: *
056: */
057: public class ActionUtil {
058:
059: public static void getAddress(ActionRequest req) throws Exception {
060: HttpServletRequest httpReq = PortalUtil
061: .getHttpServletRequest(req);
062:
063: getAddress(httpReq);
064: }
065:
066: public static void getAddress(RenderRequest req) throws Exception {
067: HttpServletRequest httpReq = PortalUtil
068: .getHttpServletRequest(req);
069:
070: getAddress(httpReq);
071: }
072:
073: public static void getAddress(HttpServletRequest req)
074: throws Exception {
075: long addressId = ParamUtil.getLong(req, "addressId");
076:
077: Address address = null;
078:
079: if (addressId > 0) {
080: address = AddressServiceUtil.getAddress(addressId);
081: }
082:
083: req.setAttribute(WebKeys.ADDRESS, address);
084: }
085:
086: public static void getEmailAddress(ActionRequest req)
087: throws Exception {
088: HttpServletRequest httpReq = PortalUtil
089: .getHttpServletRequest(req);
090:
091: getEmailAddress(httpReq);
092: }
093:
094: public static void getEmailAddress(RenderRequest req)
095: throws Exception {
096: HttpServletRequest httpReq = PortalUtil
097: .getHttpServletRequest(req);
098:
099: getEmailAddress(httpReq);
100: }
101:
102: public static void getEmailAddress(HttpServletRequest req)
103: throws Exception {
104:
105: long emailAddressId = ParamUtil.getLong(req, "emailAddressId");
106:
107: EmailAddress emailAddress = null;
108:
109: if (emailAddressId > 0) {
110: emailAddress = EmailAddressServiceUtil
111: .getEmailAddress(emailAddressId);
112: }
113:
114: req.setAttribute(WebKeys.EMAIL_ADDRESS, emailAddress);
115: }
116:
117: public static void getPhone(ActionRequest req) throws Exception {
118: HttpServletRequest httpReq = PortalUtil
119: .getHttpServletRequest(req);
120:
121: getPhone(httpReq);
122: }
123:
124: public static void getPhone(RenderRequest req) throws Exception {
125: HttpServletRequest httpReq = PortalUtil
126: .getHttpServletRequest(req);
127:
128: getPhone(httpReq);
129: }
130:
131: public static void getPhone(HttpServletRequest req)
132: throws Exception {
133: long phoneId = ParamUtil.getLong(req, "phoneId");
134:
135: Phone phone = null;
136:
137: if (phoneId > 0) {
138: phone = PhoneServiceUtil.getPhone(phoneId);
139: }
140:
141: req.setAttribute(WebKeys.PHONE, phone);
142: }
143:
144: public static void getOrganization(ActionRequest req)
145: throws Exception {
146: HttpServletRequest httpReq = PortalUtil
147: .getHttpServletRequest(req);
148:
149: getOrganization(httpReq);
150: }
151:
152: public static void getOrganization(RenderRequest req)
153: throws Exception {
154: HttpServletRequest httpReq = PortalUtil
155: .getHttpServletRequest(req);
156:
157: getOrganization(httpReq);
158: }
159:
160: public static void getOrganization(HttpServletRequest req)
161: throws Exception {
162:
163: long organizationId = ParamUtil.getLong(req, "organizationId");
164:
165: Organization organization = null;
166:
167: if (organizationId > 0) {
168: organization = OrganizationServiceUtil
169: .getOrganization(organizationId);
170: }
171:
172: req.setAttribute(WebKeys.ORGANIZATION, organization);
173: }
174:
175: public static void getOrgLabor(ActionRequest req) throws Exception {
176: HttpServletRequest httpReq = PortalUtil
177: .getHttpServletRequest(req);
178:
179: getOrgLabor(httpReq);
180: }
181:
182: public static void getOrgLabor(RenderRequest req) throws Exception {
183: HttpServletRequest httpReq = PortalUtil
184: .getHttpServletRequest(req);
185:
186: getOrgLabor(httpReq);
187: }
188:
189: public static void getOrgLabor(HttpServletRequest req)
190: throws Exception {
191: long orgLaborId = ParamUtil.getLong(req, "orgLaborId");
192:
193: OrgLabor orgLabor = null;
194:
195: if (orgLaborId > 0) {
196: orgLabor = OrgLaborServiceUtil.getOrgLabor(orgLaborId);
197: }
198:
199: req.setAttribute(WebKeys.ORG_LABOR, orgLabor);
200: }
201:
202: public static void getPasswordPolicy(ActionRequest req)
203: throws Exception {
204: HttpServletRequest httpReq = PortalUtil
205: .getHttpServletRequest(req);
206:
207: getPasswordPolicy(httpReq);
208: }
209:
210: public static void getPasswordPolicy(RenderRequest req)
211: throws Exception {
212: HttpServletRequest httpReq = PortalUtil
213: .getHttpServletRequest(req);
214:
215: getPasswordPolicy(httpReq);
216: }
217:
218: public static void getPasswordPolicy(HttpServletRequest req)
219: throws Exception {
220:
221: long passwordPolicyId = ParamUtil.getLong(req,
222: "passwordPolicyId");
223:
224: PasswordPolicy passwordPolicy = null;
225:
226: if (passwordPolicyId > 0) {
227: passwordPolicy = PasswordPolicyLocalServiceUtil
228: .getPasswordPolicy(passwordPolicyId);
229: }
230:
231: req.setAttribute(WebKeys.PASSWORD_POLICY, passwordPolicy);
232: }
233:
234: public static void getRole(ActionRequest req) throws Exception {
235: HttpServletRequest httpReq = PortalUtil
236: .getHttpServletRequest(req);
237:
238: getRole(httpReq);
239: }
240:
241: public static void getRole(RenderRequest req) throws Exception {
242: HttpServletRequest httpReq = PortalUtil
243: .getHttpServletRequest(req);
244:
245: getRole(httpReq);
246: }
247:
248: public static void getRole(HttpServletRequest req) throws Exception {
249:
250: long roleId = ParamUtil.getLong(req, "roleId");
251:
252: Role role = null;
253:
254: if (roleId > 0) {
255: role = RoleServiceUtil.getRole(roleId);
256: }
257:
258: req.setAttribute(WebKeys.ROLE, role);
259: }
260:
261: public static void getUserGroup(ActionRequest req) throws Exception {
262: HttpServletRequest httpReq = PortalUtil
263: .getHttpServletRequest(req);
264:
265: getUserGroup(httpReq);
266: }
267:
268: public static void getUserGroup(RenderRequest req) throws Exception {
269: HttpServletRequest httpReq = PortalUtil
270: .getHttpServletRequest(req);
271:
272: getUserGroup(httpReq);
273: }
274:
275: public static void getUserGroup(HttpServletRequest req)
276: throws Exception {
277:
278: long userGroupId = ParamUtil.getLong(req, "userGroupId");
279:
280: UserGroup userGroup = null;
281:
282: if (userGroupId > 0) {
283: userGroup = UserGroupServiceUtil.getUserGroup(userGroupId);
284: }
285:
286: req.setAttribute(WebKeys.USER_GROUP, userGroup);
287: }
288:
289: public static void getWebsite(ActionRequest req) throws Exception {
290: HttpServletRequest httpReq = PortalUtil
291: .getHttpServletRequest(req);
292:
293: getWebsite(httpReq);
294: }
295:
296: public static void getWebsite(RenderRequest req) throws Exception {
297: HttpServletRequest httpReq = PortalUtil
298: .getHttpServletRequest(req);
299:
300: getWebsite(httpReq);
301: }
302:
303: public static void getWebsite(HttpServletRequest req)
304: throws Exception {
305: long websiteId = ParamUtil.getLong(req, "websiteId");
306:
307: Website website = null;
308:
309: if (websiteId > 0) {
310: website = WebsiteServiceUtil.getWebsite(websiteId);
311: }
312:
313: req.setAttribute(WebKeys.WEBSITE, website);
314: }
315:
316: }
|