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