1
22
23 package com.liferay.portal.service.impl;
24
25 import com.liferay.portal.PortalException;
26 import com.liferay.portal.SystemException;
27 import com.liferay.portal.kernel.util.UnicodeProperties;
28 import com.liferay.portal.model.Account;
29 import com.liferay.portal.model.Address;
30 import com.liferay.portal.model.Company;
31 import com.liferay.portal.model.EmailAddress;
32 import com.liferay.portal.model.Phone;
33 import com.liferay.portal.model.RoleConstants;
34 import com.liferay.portal.model.Website;
35 import com.liferay.portal.security.auth.PrincipalException;
36 import com.liferay.portal.service.base.CompanyServiceBaseImpl;
37 import com.liferay.portlet.enterpriseadmin.util.EnterpriseAdminUtil;
38
39 import java.io.File;
40
41 import java.util.List;
42
43
49 public class CompanyServiceImpl extends CompanyServiceBaseImpl {
50
51 public Company addCompany(
52 String webId, String virtualHost, String mx, String shardName,
53 boolean system)
54 throws PortalException, SystemException {
55
56 if (!getPermissionChecker().isOmniadmin()) {
57 throw new PrincipalException();
58 }
59
60 return companyLocalService.addCompany(
61 webId, virtualHost, mx, shardName, system);
62 }
63
64 public void deleteLogo(long companyId)
65 throws PortalException, SystemException {
66
67 if (!roleLocalService.hasUserRole(
68 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
69
70 throw new PrincipalException();
71 }
72
73 companyLocalService.deleteLogo(companyId);
74 }
75
76 public Company getCompanyById(long companyId)
77 throws PortalException, SystemException {
78
79 return companyLocalService.getCompanyById(companyId);
80 }
81
82 public Company getCompanyByLogoId(long logoId)
83 throws PortalException, SystemException {
84
85 return companyLocalService.getCompanyByLogoId(logoId);
86 }
87
88 public Company getCompanyByMx(String mx)
89 throws PortalException, SystemException {
90
91 return companyLocalService.getCompanyByMx(mx);
92 }
93
94 public Company getCompanyByVirtualHost(String virtualHost)
95 throws PortalException, SystemException {
96
97 return companyLocalService.getCompanyByVirtualHost(virtualHost);
98 }
99
100 public Company getCompanyByWebId(String webId)
101 throws PortalException, SystemException {
102
103 return companyLocalService.getCompanyByWebId(webId);
104 }
105
106 public Company updateCompany(long companyId, String virtualHost, String mx)
107 throws PortalException, SystemException {
108
109 if (!getPermissionChecker().isOmniadmin()) {
110 throw new PrincipalException();
111 }
112
113 return companyLocalService.updateCompany(companyId, virtualHost, mx);
114 }
115
116 public Company updateCompany(
117 long companyId, String virtualHost, String mx, String homeURL,
118 String name, String legalName, String legalId, String legalType,
119 String sicCode, String tickerSymbol, String industry, String type,
120 String size)
121 throws PortalException, SystemException {
122
123 if (!roleLocalService.hasUserRole(
124 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
125
126 throw new PrincipalException();
127 }
128
129 return companyLocalService.updateCompany(
130 companyId, virtualHost, mx, homeURL, name, legalName, legalId,
131 legalType, sicCode, tickerSymbol, industry, type, size);
132 }
133
134 public Company updateCompany(
135 long companyId, String virtualHost, String mx, String homeURL,
136 String name, String legalName, String legalId, String legalType,
137 String sicCode, String tickerSymbol, String industry, String type,
138 String size, String languageId, String timeZoneId,
139 List<Address> addresses, List<EmailAddress> emailAddresses,
140 List<Phone> phones, List<Website> websites,
141 UnicodeProperties properties)
142 throws PortalException, SystemException {
143
144 Company company = updateCompany(
145 companyId, virtualHost, mx, homeURL, name, legalName, legalId,
146 legalType, sicCode, tickerSymbol, industry, type, size);
147
148 updateDisplay(company.getCompanyId(), languageId, timeZoneId);
149
150 updatePreferences(company.getCompanyId(), properties);
151
152 EnterpriseAdminUtil.updateAddresses(
153 Account.class.getName(), company.getAccountId(), addresses);
154
155 EnterpriseAdminUtil.updateEmailAddresses(
156 Account.class.getName(), company.getAccountId(), emailAddresses);
157
158 EnterpriseAdminUtil.updatePhones(
159 Account.class.getName(), company.getAccountId(), phones);
160
161 EnterpriseAdminUtil.updateWebsites(
162 Account.class.getName(), company.getAccountId(), websites);
163
164 return company;
165 }
166
167 public void updateDisplay(
168 long companyId, String languageId, String timeZoneId)
169 throws PortalException, SystemException {
170
171 if (!roleLocalService.hasUserRole(
172 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
173
174 throw new PrincipalException();
175 }
176
177 companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
178 }
179
180 public void updateLogo(long companyId, File file)
181 throws PortalException, SystemException {
182
183 if (!roleLocalService.hasUserRole(
184 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
185
186 throw new PrincipalException();
187 }
188
189 companyLocalService.updateLogo(companyId, file);
190 }
191
192 public void updatePreferences(long companyId, UnicodeProperties properties)
193 throws PortalException, SystemException {
194
195 if (!roleLocalService.hasUserRole(
196 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
197
198 throw new PrincipalException();
199 }
200
201 companyLocalService.updatePreferences(companyId, properties);
202 }
203
204 public void updateSecurity(
205 long companyId, String authType, boolean autoLogin,
206 boolean sendPassword, boolean strangers, boolean strangersWithMx,
207 boolean strangersVerify, boolean communityLogo)
208 throws PortalException, SystemException {
209
210 if (!roleLocalService.hasUserRole(
211 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
212
213 throw new PrincipalException();
214 }
215
216 companyLocalService.updateSecurity(
217 companyId, authType, autoLogin, sendPassword, strangers,
218 strangersWithMx, strangersVerify, communityLogo);
219 }
220
221 }