001    /**
002     * Copyright (c) 2000-2013 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            @Override
033            public long getCompanyId() throws PortalException, SystemException {
034                    if (_companyId != 0) {
035                            return _companyId;
036                    }
037                    else {
038                            ResourceCode resourceCode =
039                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
040    
041                            return resourceCode.getCompanyId();
042                    }
043            }
044    
045            @Override
046            public String getName() throws PortalException, SystemException {
047                    if (_name != null) {
048                            return _name;
049                    }
050                    else {
051                            ResourceCode resourceCode =
052                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
053    
054                            return resourceCode.getName();
055                    }
056            }
057    
058            @Override
059            public int getScope() throws PortalException, SystemException {
060                    if (_scope != 0) {
061                            return _scope;
062                    }
063                    else {
064                            ResourceCode resourceCode =
065                                    ResourceCodeLocalServiceUtil.getResourceCode(getCodeId());
066    
067                            return resourceCode.getScope();
068                    }
069            }
070    
071            @Override
072            public void setCompanyId(long companyId) {
073                    _companyId = companyId;
074            }
075    
076            @Override
077            public void setName(String name) {
078                    _name = name;
079            }
080    
081            @Override
082            public void setScope(int scope) {
083                    _scope = scope;
084            }
085    
086            private long _companyId;
087            private String _name;
088            private int _scope;
089    
090    }