001    /**
002     * Copyright (c) 2000-2011 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.ResourceCode;
020    import com.liferay.portal.service.ResourceCodeLocalServiceUtil;
021    
022    /**
023     * Represents a permissionable resource in permissions versions < 6.
024     *
025     * @author Brian Wing Shun Chan
026     */
027    public class ResourceImpl extends ResourceBaseImpl {
028    
029            public ResourceImpl() {
030            }
031    
032            public long getCompanyId() throws PortalException, SystemException {
033                    if (_companyId != 0) {
034                            return _companyId;
035                    }
036                    else {
037                            ResourceCode resourceCode =
038                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
039    
040                            return resourceCode.getCompanyId();
041                    }
042            }
043    
044            public String getName() throws PortalException, SystemException {
045                    if (_name != null) {
046                            return _name;
047                    }
048                    else {
049                            ResourceCode resourceCode =
050                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
051    
052                            return resourceCode.getName();
053                    }
054            }
055    
056            public int getScope() throws PortalException, SystemException {
057                    if (_scope != 0) {
058                            return _scope;
059                    }
060                    else {
061                            ResourceCode resourceCode =
062                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
063    
064                            return resourceCode.getScope();
065                    }
066            }
067    
068            public void setCompanyId(long companyId) {
069                    _companyId = companyId;
070            }
071    
072            public void setName(String name) {
073                    _name = name;
074            }
075    
076            public void setScope(int scope) {
077                    _scope = scope;
078            }
079    
080            private long _companyId;
081            private String _name;
082            private int _scope;
083    
084    }