1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.service.impl;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  import com.liferay.portal.model.Company;
25  import com.liferay.portal.model.RoleConstants;
26  import com.liferay.portal.security.auth.PrincipalException;
27  import com.liferay.portal.service.base.CompanyServiceBaseImpl;
28  
29  import java.io.File;
30  
31  /**
32   * <a href="CompanyServiceImpl.java.html"><b><i>View Source</i></b></a>
33   *
34   * @author Brian Wing Shun Chan
35   *
36   */
37  public class CompanyServiceImpl extends CompanyServiceBaseImpl {
38  
39      /**
40       * @deprecated
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 addCompany(
53              String webId, String virtualHost, String mx, String shardName,
54              boolean system)
55          throws PortalException, SystemException {
56  
57          if (!getPermissionChecker().isOmniadmin()) {
58              throw new PrincipalException();
59          }
60  
61          return companyLocalService.addCompany(
62              webId, virtualHost, mx, shardName, system);
63      }
64  
65      public Company updateCompany(long companyId, String virtualHost, String mx)
66          throws PortalException, SystemException {
67  
68          if (!getPermissionChecker().isOmniadmin()) {
69              throw new PrincipalException();
70          }
71  
72          return companyLocalService.updateCompany(companyId, virtualHost, mx);
73      }
74  
75      public Company updateCompany(
76              long companyId, String virtualHost, String mx, String name,
77              String legalName, String legalId, String legalType, String sicCode,
78              String tickerSymbol, String industry, String type, String size)
79          throws PortalException, SystemException {
80  
81          if (!roleLocalService.hasUserRole(
82                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
83  
84              throw new PrincipalException();
85          }
86  
87          return companyLocalService.updateCompany(
88              companyId, virtualHost, mx, name, legalName, legalId, legalType,
89              sicCode, tickerSymbol, industry, type, size);
90      }
91  
92      public void updateDisplay(
93              long companyId, String languageId, String timeZoneId)
94          throws PortalException, SystemException {
95  
96          if (!roleLocalService.hasUserRole(
97                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
98  
99              throw new PrincipalException();
100         }
101 
102         companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
103     }
104 
105     public void updateLogo(long companyId, File file)
106         throws PortalException, SystemException {
107 
108         if (!roleLocalService.hasUserRole(
109                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
110 
111             throw new PrincipalException();
112         }
113 
114         companyLocalService.updateLogo(companyId, file);
115     }
116 
117     public void updateSecurity(
118             long companyId, String authType, boolean autoLogin,
119             boolean sendPassword, boolean strangers, boolean strangersWithMx,
120             boolean strangersVerify, boolean communityLogo)
121         throws PortalException, SystemException {
122 
123         if (!roleLocalService.hasUserRole(
124                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
125 
126             throw new PrincipalException();
127         }
128 
129         companyLocalService.updateSecurity(
130             companyId, authType, autoLogin, sendPassword, strangers,
131             strangersWithMx, strangersVerify, communityLogo);
132     }
133 
134 }