001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.model.Resource;
020    import com.liferay.portal.model.ResourceCode;
021    import com.liferay.portal.service.ResourceCodeLocalServiceUtil;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class ResourceImpl extends ResourceModelImpl implements Resource {
027    
028            public ResourceImpl() {
029            }
030    
031            public long getCompanyId() throws PortalException, SystemException {
032                    if (_companyId != 0) {
033                            return _companyId;
034                    }
035                    else {
036                            ResourceCode resourceCode =
037                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
038    
039                            return resourceCode.getCompanyId();
040                    }
041            }
042    
043            public String getName() throws PortalException, SystemException {
044                    if (_name != null) {
045                            return _name;
046                    }
047                    else {
048                            ResourceCode resourceCode =
049                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
050    
051                            return resourceCode.getName();
052                    }
053            }
054    
055            public int getScope() throws PortalException, SystemException {
056                    if (_scope != 0) {
057                            return _scope;
058                    }
059                    else {
060                            ResourceCode resourceCode =
061                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
062    
063                            return resourceCode.getScope();
064                    }
065            }
066    
067            public void setCompanyId(long companyId) {
068                    _companyId = companyId;
069            }
070    
071            public void setName(String name) {
072                    _name = name;
073            }
074    
075            public void setScope(int scope) {
076                    _scope = scope;
077            }
078    
079            private long _companyId;
080            private String _name;
081            private int _scope;
082    
083    }