1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
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.model.Company;
28  import com.liferay.portal.model.impl.RoleImpl;
29  import com.liferay.portal.security.auth.PrincipalException;
30  import com.liferay.portal.service.base.CompanyServiceBaseImpl;
31  
32  import java.io.File;
33  
34  /**
35   * <a href="CompanyServiceImpl.java.html"><b><i>View Source</i></b></a>
36   *
37   * @author Brian Wing Shun Chan
38   *
39   */
40  public class CompanyServiceImpl extends CompanyServiceBaseImpl {
41  
42      public Company addCompany(String webId, String virtualHost, String mx)
43          throws PortalException, SystemException {
44  
45          if (!getPermissionChecker().isOmniadmin()) {
46              throw new PrincipalException();
47          }
48  
49          return companyLocalService.addCompany(webId, virtualHost, mx);
50      }
51  
52      public Company updateCompany(long companyId, String virtualHost, String mx)
53          throws PortalException, SystemException {
54  
55          if (!getPermissionChecker().isOmniadmin()) {
56              throw new PrincipalException();
57          }
58  
59          return companyLocalService.updateCompany(companyId, virtualHost, mx);
60      }
61  
62      public Company updateCompany(
63              long companyId, String virtualHost, String mx, String name,
64              String legalName, String legalId, String legalType, String sicCode,
65              String tickerSymbol, String industry, String type, String size)
66          throws PortalException, SystemException {
67  
68          if (!roleLocalService.hasUserRole(
69                  getUserId(), companyId, RoleImpl.ADMINISTRATOR, true)) {
70  
71              throw new PrincipalException();
72          }
73  
74          return companyLocalService.updateCompany(
75              companyId, virtualHost, mx, name, legalName, legalId, legalType,
76              sicCode, tickerSymbol, industry, type, size);
77      }
78  
79      public void updateDisplay(
80              long companyId, String languageId, String timeZoneId)
81          throws PortalException, SystemException {
82  
83          if (!roleLocalService.hasUserRole(
84                  getUserId(), companyId, RoleImpl.ADMINISTRATOR, true)) {
85  
86              throw new PrincipalException();
87          }
88  
89          companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
90      }
91  
92      public void updateLogo(long companyId, File file)
93          throws PortalException, SystemException {
94  
95          if (!roleLocalService.hasUserRole(
96                  getUserId(), companyId, RoleImpl.ADMINISTRATOR, true)) {
97  
98              throw new PrincipalException();
99          }
100 
101         companyLocalService.updateLogo(companyId, file);
102     }
103 
104     public void updateSecurity(
105             long companyId, String authType, boolean autoLogin,
106             boolean sendPassword, boolean strangers, boolean strangersWithMx,
107             boolean strangersVerify, boolean communityLogo)
108         throws PortalException, SystemException {
109 
110         if (!roleLocalService.hasUserRole(
111                 getUserId(), companyId, RoleImpl.ADMINISTRATOR, true)) {
112 
113             throw new PrincipalException();
114         }
115 
116         companyLocalService.updateSecurity(
117             companyId, authType, autoLogin, sendPassword, strangers,
118             strangersWithMx, strangersVerify, communityLogo);
119     }
120 
121 }