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