1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portal.model.Resource;
20  import com.liferay.portal.model.ResourceCode;
21  import com.liferay.portal.service.ResourceCodeLocalServiceUtil;
22  
23  /**
24   * <a href="ResourceImpl.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class ResourceImpl extends ResourceModelImpl implements Resource {
29  
30      public ResourceImpl() {
31      }
32  
33      public long getCompanyId() throws PortalException, SystemException {
34          if (_companyId != 0) {
35              return _companyId;
36          }
37          else {
38              ResourceCode resourceCode =
39                  ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
40  
41              return resourceCode.getCompanyId();
42          }
43      }
44  
45      public String getName() throws PortalException, SystemException {
46          if (_name != null) {
47              return _name;
48          }
49          else {
50              ResourceCode resourceCode =
51                  ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
52  
53              return resourceCode.getName();
54          }
55      }
56  
57      public int getScope() throws PortalException, SystemException {
58          if (_scope != 0) {
59              return _scope;
60          }
61          else {
62              ResourceCode resourceCode =
63                  ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
64  
65              return resourceCode.getScope();
66          }
67      }
68  
69      public void setCompanyId(long companyId) {
70          _companyId = companyId;
71      }
72  
73      public void setName(String name) {
74          _name = name;
75      }
76  
77      public void setScope(int scope) {
78          _scope = scope;
79      }
80  
81      private long _companyId;
82      private String _name;
83      private int _scope;
84  
85  }