1
22
23 package com.liferay.portlet.enterpriseadmin.action;
24
25 import com.liferay.portal.AccountNameException;
26 import com.liferay.portal.CompanyMxException;
27 import com.liferay.portal.CompanyVirtualHostException;
28 import com.liferay.portal.CompanyWebIdException;
29 import com.liferay.portal.kernel.servlet.SessionErrors;
30 import com.liferay.portal.kernel.util.Constants;
31 import com.liferay.portal.kernel.util.ParamUtil;
32 import com.liferay.portal.model.Company;
33 import com.liferay.portal.security.auth.PrincipalException;
34 import com.liferay.portal.service.CompanyServiceUtil;
35 import com.liferay.portal.struts.PortletAction;
36 import com.liferay.portal.util.PortalUtil;
37
38 import javax.portlet.ActionRequest;
39 import javax.portlet.ActionResponse;
40 import javax.portlet.PortletConfig;
41
42 import org.apache.struts.action.ActionForm;
43 import org.apache.struts.action.ActionMapping;
44
45
51 public class EditCompanyAction extends PortletAction {
52
53 public void processAction(
54 ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
55 ActionRequest actionRequest, ActionResponse actionResponse)
56 throws Exception {
57
58 String cmd = ParamUtil.getString(actionRequest, Constants.CMD);
59
60 try {
61 if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
62 updateCompany(actionRequest);
63 updateDisplay(actionRequest);
64 }
65
66 sendRedirect(actionRequest, actionResponse);
67 }
68 catch (Exception e) {
69 if (e instanceof PrincipalException) {
70 SessionErrors.add(actionRequest, e.getClass().getName());
71
72 setForward(actionRequest, "portlet.enterprise_admin.error");
73 }
74 else if (e instanceof AccountNameException ||
75 e instanceof CompanyMxException ||
76 e instanceof CompanyVirtualHostException ||
77 e instanceof CompanyWebIdException) {
78
79 SessionErrors.add(actionRequest, e.getClass().getName(), e);
80
81 setForward(actionRequest, "portlet.enterprise_admin.view");
82 }
83 else {
84 throw e;
85 }
86 }
87 }
88
89 protected void updateCompany(ActionRequest actionRequest) throws Exception {
90 long companyId = PortalUtil.getCompanyId(actionRequest);
91
92 String virtualHost = ParamUtil.getString(actionRequest, "virtualHost");
93 String mx = ParamUtil.getString(actionRequest, "mx");
94 String homeURL = ParamUtil.getString(actionRequest, "homeURL");
95 String name = ParamUtil.getString(actionRequest, "name");
96 String legalName = ParamUtil.getString(actionRequest, "legalName");
97 String legalId = ParamUtil.getString(actionRequest, "legalId");
98 String legalType = ParamUtil.getString(actionRequest, "legalType");
99 String sicCode = ParamUtil.getString(actionRequest, "sicCode");
100 String tickerSymbol = ParamUtil.getString(
101 actionRequest, "tickerSymbol");
102 String industry = ParamUtil.getString(actionRequest, "industry");
103 String type = ParamUtil.getString(actionRequest, "type");
104 String size = ParamUtil.getString(actionRequest, "size");
105
106 CompanyServiceUtil.updateCompany(
107 companyId, virtualHost, mx, homeURL, name, legalName, legalId,
108 legalType, sicCode, tickerSymbol, industry, type, size);
109 }
110
111 protected void updateDisplay(ActionRequest actionRequest) throws Exception {
112 Company company = PortalUtil.getCompany(actionRequest);
113
114 String languageId = ParamUtil.getString(actionRequest, "languageId");
115 String timeZoneId = ParamUtil.getString(actionRequest, "timeZoneId");
116 boolean communityLogo = ParamUtil.getBoolean(
117 actionRequest, "communityLogo");
118
119 CompanyServiceUtil.updateDisplay(
120 company.getCompanyId(), languageId, timeZoneId);
121
122 CompanyServiceUtil.updateSecurity(
123 company.getCompanyId(), company.getAuthType(),
124 company.isAutoLogin(), company.isSendPassword(),
125 company.isStrangers(), company.isStrangersWithMx(),
126 company.isStrangersVerify(), communityLogo);
127 }
128
129 }