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 }
64 else if (cmd.equals("display")) {
65 updateDisplay(req);
66 }
67
68 sendRedirect(req, res);
69 }
70 catch (Exception e) {
71 if (e instanceof PrincipalException) {
72 SessionErrors.add(req, e.getClass().getName());
73
74 setForward(req, "portlet.enterprise_admin.error");
75 }
76 else if (e instanceof AccountNameException ||
77 e instanceof CompanyMxException ||
78 e instanceof CompanyVirtualHostException ||
79 e instanceof CompanyWebIdException) {
80
81 SessionErrors.add(req, e.getClass().getName(), e);
82
83 setForward(req, "portlet.enterprise_admin.view");
84 }
85 else {
86 throw e;
87 }
88 }
89 }
90
91 protected void updateCompany(ActionRequest req) throws Exception {
92 long companyId = PortalUtil.getCompanyId(req);
93
94 String virtualHost = ParamUtil.getString(req, "virtualHost");
95 String mx = ParamUtil.getString(req, "mx");
96 String name = ParamUtil.getString(req, "name");
97 String legalName = ParamUtil.getString(req, "legalName");
98 String legalId = ParamUtil.getString(req, "legalId");
99 String legalType = ParamUtil.getString(req, "legalType");
100 String sicCode = ParamUtil.getString(req, "sicCode");
101 String tickerSymbol = ParamUtil.getString(req, "tickerSymbol");
102 String industry = ParamUtil.getString(req, "industry");
103 String type = ParamUtil.getString(req, "type");
104 String size = ParamUtil.getString(req, "size");
105
106 CompanyServiceUtil.updateCompany(
107 companyId, virtualHost, mx, name, legalName, legalId, legalType,
108 sicCode, tickerSymbol, industry, type, size);
109 }
110
111 protected void updateDisplay(ActionRequest req) throws Exception {
112 Company company = PortalUtil.getCompany(req);
113
114 String languageId = ParamUtil.getString(req, "languageId");
115 String timeZoneId = ParamUtil.getString(req, "timeZoneId");
116 boolean communityLogo = ParamUtil.getBoolean(req, "communityLogo");
117
118 CompanyServiceUtil.updateDisplay(
119 company.getCompanyId(), languageId, timeZoneId);
120
121 CompanyServiceUtil.updateSecurity(
122 company.getCompanyId(), company.getAuthType(),
123 company.isAutoLogin(), company.isSendPassword(),
124 company.isStrangers(), company.isStrangersWithMx(),
125 company.isStrangersVerify(), communityLogo);
126 }
127
128 }