001    /**
002     * Copyright (c) 2000-2010 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.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    }