001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }