1   /**
2    * Copyright (c) 2000-2009 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.RoleConstants;
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      /**
43       * @deprecated
44       */
45      public Company addCompany(String webId, String virtualHost, String mx)
46          throws PortalException, SystemException {
47  
48          if (!getPermissionChecker().isOmniadmin()) {
49              throw new PrincipalException();
50          }
51  
52          return companyLocalService.addCompany(webId, virtualHost, mx);
53      }
54  
55      public Company addCompany(
56              String webId, String virtualHost, String mx, String shardName,
57              boolean system)
58          throws PortalException, SystemException {
59  
60          if (!getPermissionChecker().isOmniadmin()) {
61              throw new PrincipalException();
62          }
63  
64          return companyLocalService.addCompany(
65              webId, virtualHost, mx, shardName, system);
66      }
67  
68      public Company updateCompany(long companyId, String virtualHost, String mx)
69          throws PortalException, SystemException {
70  
71          if (!getPermissionChecker().isOmniadmin()) {
72              throw new PrincipalException();
73          }
74  
75          return companyLocalService.updateCompany(companyId, virtualHost, mx);
76      }
77  
78      public Company updateCompany(
79              long companyId, String virtualHost, String mx, String name,
80              String legalName, String legalId, String legalType, String sicCode,
81              String tickerSymbol, String industry, String type, String size)
82          throws PortalException, SystemException {
83  
84          if (!roleLocalService.hasUserRole(
85                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
86  
87              throw new PrincipalException();
88          }
89  
90          return companyLocalService.updateCompany(
91              companyId, virtualHost, mx, name, legalName, legalId, legalType,
92              sicCode, tickerSymbol, industry, type, size);
93      }
94  
95      public void updateDisplay(
96              long companyId, String languageId, String timeZoneId)
97          throws PortalException, SystemException {
98  
99          if (!roleLocalService.hasUserRole(
100                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
101 
102             throw new PrincipalException();
103         }
104 
105         companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
106     }
107 
108     public void updateLogo(long companyId, File file)
109         throws PortalException, SystemException {
110 
111         if (!roleLocalService.hasUserRole(
112                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
113 
114             throw new PrincipalException();
115         }
116 
117         companyLocalService.updateLogo(companyId, file);
118     }
119 
120     public void updateSecurity(
121             long companyId, String authType, boolean autoLogin,
122             boolean sendPassword, boolean strangers, boolean strangersWithMx,
123             boolean strangersVerify, boolean communityLogo)
124         throws PortalException, SystemException {
125 
126         if (!roleLocalService.hasUserRole(
127                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
128 
129             throw new PrincipalException();
130         }
131 
132         companyLocalService.updateSecurity(
133             companyId, authType, autoLogin, sendPassword, strangers,
134             strangersWithMx, strangersVerify, communityLogo);
135     }
136 
137 }