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.portlet.softwarecatalog.service.impl;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.security.permission.ActionKeys;
020    import com.liferay.portal.service.permission.PortalPermissionUtil;
021    import com.liferay.portlet.softwarecatalog.model.SCLicense;
022    import com.liferay.portlet.softwarecatalog.service.base.SCLicenseServiceBaseImpl;
023    import com.liferay.portlet.softwarecatalog.service.permission.SCLicensePermission;
024    
025    /**
026     * @author Jorge Ferrer
027     * @author Brian Wing Shun Chan
028     */
029    public class SCLicenseServiceImpl extends SCLicenseServiceBaseImpl {
030    
031            public SCLicense addLicense(
032                            String name, String url, boolean openSource, boolean active,
033                            boolean recommended)
034                    throws PortalException, SystemException {
035    
036                    PortalPermissionUtil.check(
037                            getPermissionChecker(), ActionKeys.ADD_LICENSE);
038    
039                    return scLicenseLocalService.addLicense(
040                            name, url, openSource, active, recommended);
041            }
042    
043            public void deleteLicense(long licenseId)
044                    throws PortalException, SystemException {
045    
046                    SCLicensePermission.check(
047                            getPermissionChecker(), licenseId, ActionKeys.DELETE);
048    
049                    scLicenseLocalService.deleteLicense(licenseId);
050            }
051    
052            public SCLicense getLicense(long licenseId)
053                    throws PortalException, SystemException {
054    
055                    return scLicenseLocalService.getLicense(licenseId);
056            }
057    
058            public SCLicense updateLicense(
059                            long licenseId, String name, String url, boolean openSource,
060                            boolean active, boolean recommended)
061                    throws PortalException, SystemException {
062    
063                    SCLicensePermission.check(
064                            getPermissionChecker(), licenseId, ActionKeys.UPDATE);
065    
066                    return scLicenseLocalService.updateLicense(
067                            licenseId, name, url, openSource, active, recommended);
068            }
069    
070    }