1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  public class CompanyServiceImpl extends CompanyServiceBaseImpl {
40  
41      /**
42       * @deprecated
43       */
44      public Company addCompany(String webId, String virtualHost, String mx)
45          throws PortalException, SystemException {
46  
47          if (!getPermissionChecker().isOmniadmin()) {
48              throw new PrincipalException();
49          }
50  
51          return companyLocalService.addCompany(webId, virtualHost, mx);
52      }
53  
54      public Company addCompany(
55              String webId, String virtualHost, String mx, String shardName,
56              boolean system)
57          throws PortalException, SystemException {
58  
59          if (!getPermissionChecker().isOmniadmin()) {
60              throw new PrincipalException();
61          }
62  
63          return companyLocalService.addCompany(
64              webId, virtualHost, mx, shardName, system);
65      }
66  
67      public Company updateCompany(long companyId, String virtualHost, String mx)
68          throws PortalException, SystemException {
69  
70          if (!getPermissionChecker().isOmniadmin()) {
71              throw new PrincipalException();
72          }
73  
74          return companyLocalService.updateCompany(companyId, virtualHost, mx);
75      }
76  
77      public Company updateCompany(
78              long companyId, String virtualHost, String mx, String name,
79              String legalName, String legalId, String legalType, String sicCode,
80              String tickerSymbol, String industry, String type, String size)
81          throws PortalException, SystemException {
82  
83          if (!roleLocalService.hasUserRole(
84                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
85  
86              throw new PrincipalException();
87          }
88  
89          return companyLocalService.updateCompany(
90              companyId, virtualHost, mx, name, legalName, legalId, legalType,
91              sicCode, tickerSymbol, industry, type, size);
92      }
93  
94      public void updateDisplay(
95              long companyId, String languageId, String timeZoneId)
96          throws PortalException, SystemException {
97  
98          if (!roleLocalService.hasUserRole(
99                  getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
100 
101             throw new PrincipalException();
102         }
103 
104         companyLocalService.updateDisplay(companyId, languageId, timeZoneId);
105     }
106 
107     public void updateLogo(long companyId, File file)
108         throws PortalException, SystemException {
109 
110         if (!roleLocalService.hasUserRole(
111                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
112 
113             throw new PrincipalException();
114         }
115 
116         companyLocalService.updateLogo(companyId, file);
117     }
118 
119     public void updateSecurity(
120             long companyId, String authType, boolean autoLogin,
121             boolean sendPassword, boolean strangers, boolean strangersWithMx,
122             boolean strangersVerify, boolean communityLogo)
123         throws PortalException, SystemException {
124 
125         if (!roleLocalService.hasUserRole(
126                 getUserId(), companyId, RoleConstants.ADMINISTRATOR, true)) {
127 
128             throw new PrincipalException();
129         }
130 
131         companyLocalService.updateSecurity(
132             companyId, authType, autoLogin, sendPassword, strangers,
133             strangersWithMx, strangersVerify, communityLogo);
134     }
135 
136 }