001
014
015 package com.liferay.portal.service.impl;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.util.UnicodeProperties;
020 import com.liferay.portal.model.Account;
021 import com.liferay.portal.model.Address;
022 import com.liferay.portal.model.Company;
023 import com.liferay.portal.model.EmailAddress;
024 import com.liferay.portal.model.Phone;
025 import com.liferay.portal.model.RoleConstants;
026 import com.liferay.portal.model.Website;
027 import com.liferay.portal.security.auth.PrincipalException;
028 import com.liferay.portal.service.base.CompanyServiceBaseImpl;
029 import com.liferay.portlet.enterpriseadmin.util.EnterpriseAdminUtil;
030
031 import java.io.File;
032
033 import java.util.List;
034
035
039 public class CompanyServiceImpl extends CompanyServiceBaseImpl {
040
041 public Company addCompany(
042 String webId, String virtualHost, String mx, String shardName,
043 boolean system, int maxUsers)
044 throws PortalException, SystemException {
045
046 if (!getPermissionChecker().isOmniadmin()) {
047 throw new PrincipalException();
048 }
049
050 return companyLocalService.addCompany(
051 webId, virtualHost, mx, shardName, system, maxUsers);
052 }
053
054 public void deleteLogo(long companyId)
055 throws PortalException, SystemException {
056
057 if (!roleLocalService.hasUserRole(
058 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
059
060 throw new PrincipalException();
061 }
062
063 companyLocalService.deleteLogo(companyId);
064 }
065
066 public Company getCompanyById(long companyId)
067 throws PortalException, SystemException {
068
069 return companyLocalService.getCompanyById(companyId);
070 }
071
072 public Company getCompanyByLogoId(long logoId)
073 throws PortalException, SystemException {
074
075 return companyLocalService.getCompanyByLogoId(logoId);
076 }
077
078 public Company getCompanyByMx(String mx)
079 throws PortalException, SystemException {
080
081 return companyLocalService.getCompanyByMx(mx);
082 }
083
084 public Company getCompanyByVirtualHost(String virtualHost)
085 throws PortalException, SystemException {
086
087 return companyLocalService.getCompanyByVirtualHost(virtualHost);
088 }
089
090 public Company getCompanyByWebId(String webId)
091 throws PortalException, SystemException {
092
093 return companyLocalService.getCompanyByWebId(webId);
094 }
095
096 public void removePreferences(long companyId, String[] keys)
097 throws PortalException, SystemException {
098
099 if (!roleLocalService.hasUserRole(
100 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
101
102 throw new PrincipalException();
103 }
104
105 companyLocalService.removePreferences(companyId, keys);
106 }
107
108 public Company updateCompany(
109 long companyId, String virtualHost, String mx, int maxUsers)
110 throws PortalException, SystemException {
111
112 if (!getPermissionChecker().isOmniadmin()) {
113 throw new PrincipalException();
114 }
115
116 return companyLocalService.updateCompany(
117 companyId, virtualHost, mx, maxUsers);
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 }