1   /**
2    * Copyright (c) 2000-2010 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   *
12   * 
13   */
14  
15  package com.liferay.portal.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.model.Company;
20  import com.liferay.portal.model.RoleConstants;
21  import com.liferay.portal.security.auth.PrincipalException;
22  import com.liferay.portal.service.base.CompanyServiceBaseImpl;
23  
24  import java.io.File;
25  
26  /**
27   * <a href="CompanyServiceImpl.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class CompanyServiceImpl extends CompanyServiceBaseImpl {
32  
33      /**
34       * @deprecated
35       */
36      public Company addCompany(String webId, String virtualHost, String mx)
37          throws PortalException, SystemException {
38  
39          if (!getPermissionChecker().isOmniadmin()) {
40              throw new PrincipalException();
41          }
42  
43          return companyLocalService.addCompany(webId, virtualHost, mx);
44      }
45  
46      public Company addCompany(
47              String webId, String virtualHost, String mx, String shardName,
48              boolean system)
49          throws PortalException, SystemException {
50  
51          if (!getPermissionChecker().isOmniadmin()) {
52              throw new PrincipalException();
53          }
54  
55          return companyLocalService.addCompany(
56              webId, virtualHost, mx, shardName, system);
57      }
58  
59      public Company updateCompany(long companyId, String virtualHost, String mx)
60          throws PortalException, SystemException {
61  
62          if (!getPermissionChecker().isOmniadmin()) {
63              throw new PrincipalException();
64          }
65  
66          return companyLocalService.updateCompany(companyId, virtualHost, mx);
67      }
68  
69      public Company updateCompany(
70              long companyId, String virtualHost, String mx, String name,
71              String legalName, String legalId, String legalType, String sicCode,
72              String tickerSymbol, String industry, String type, String size)
73          throws PortalException, SystemException {
74  
75          if (!roleLocalService.hasUserRole(
76                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
77  
78              throw new PrincipalException();
79          }
80  
81          return companyLocalService.updateCompany(
82              companyId, virtualHost, mx, name, legalName, legalId, legalType,
83              sicCode, tickerSymbol, industry, type, size);
84      }
85  
86      public void updateDisplay(
87              long companyId, String languageId, String timeZoneId)
88          throws PortalException, SystemException {
89  
90          if (!roleLocalService.hasUserRole(
91                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
92  
93              throw new PrincipalException();
94          }
95  
96          companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
97      }
98  
99      public void updateLogo(long companyId, File file)
100         throws PortalException, SystemException {
101 
102         if (!roleLocalService.hasUserRole(
103                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
104 
105             throw new PrincipalException();
106         }
107 
108         companyLocalService.updateLogo(companyId, file);
109     }
110 
111     public void updateSecurity(
112             long companyId, String authType, boolean autoLogin,
113             boolean sendPassword, boolean strangers, boolean strangersWithMx,
114             boolean strangersVerify, boolean communityLogo)
115         throws PortalException, SystemException {
116 
117         if (!roleLocalService.hasUserRole(
118                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
119 
120             throw new PrincipalException();
121         }
122 
123         companyLocalService.updateSecurity(
124             companyId, authType, autoLogin, sendPassword, strangers,
125             strangersWithMx, strangersVerify, communityLogo);
126     }
127 
128 }