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.util.Constants;
30 import com.liferay.portal.kernel.util.ParamUtil;
31 import com.liferay.portal.model.Company;
32 import com.liferay.portal.security.auth.PrincipalException;
33 import com.liferay.portal.service.CompanyServiceUtil;
34 import com.liferay.portal.struts.PortletAction;
35 import com.liferay.portal.util.PortalUtil;
36 import com.liferay.util.servlet.SessionErrors;
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 config,
55 ActionRequest req, ActionResponse res)
56 throws Exception {
57
58 String cmd = ParamUtil.getString(req, Constants.CMD);
59
60 try {
61 if (cmd.equals(Constants.ADD) || cmd.equals(Constants.UPDATE)) {
62 updateCompany(req);
63 updateDisplay(req);
64 }
65
66 sendRedirect(req, res);
67 }
68 catch (Exception e) {
69 if (e instanceof PrincipalException) {
70 SessionErrors.add(req, e.getClass().getName());
71
72 setForward(req, "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(req, e.getClass().getName(), e);
80
81 setForward(req, "portlet.enterprise_admin.view");
82 }
83 else {
84 throw e;
85 }
86 }
87 }
88
89 protected void updateCompany(ActionRequest req) throws Exception {
90 long companyId = PortalUtil.getCompanyId(req);
91
92 String virtualHost = ParamUtil.getString(req, "virtualHost");
93 String mx = ParamUtil.getString(req, "mx");
94 String name = ParamUtil.getString(req, "name");
95 String legalName = ParamUtil.getString(req, "legalName");
96 String legalId = ParamUtil.getString(req, "legalId");
97 String legalType = ParamUtil.getString(req, "legalType");
98 String sicCode = ParamUtil.getString(req, "sicCode");
99 String tickerSymbol = ParamUtil.getString(req, "tickerSymbol");
100 String industry = ParamUtil.getString(req, "industry");
101 String type = ParamUtil.getString(req, "type");
102 String size = ParamUtil.getString(req, "size");
103
104 CompanyServiceUtil.updateCompany(
105 companyId, virtualHost, mx, name, legalName, legalId, legalType,
106 sicCode, tickerSymbol, industry, type, size);
107 }
108
109 protected void updateDisplay(ActionRequest req) throws Exception {
110 Company company = PortalUtil.getCompany(req);
111
112 String languageId = ParamUtil.getString(req, "languageId");
113 String timeZoneId = ParamUtil.getString(req, "timeZoneId");
114 boolean communityLogo = ParamUtil.getBoolean(req, "communityLogo");
115
116 CompanyServiceUtil.updateDisplay(
117 company.getCompanyId(), languageId, timeZoneId);
118
119 CompanyServiceUtil.updateSecurity(
120 company.getCompanyId(), company.getAuthType(),
121 company.isAutoLogin(), company.isSendPassword(),
122 company.isStrangers(), company.isStrangersWithMx(),
123 company.isStrangersVerify(), communityLogo);
124 }
125
126 }