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.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            @Override
032            public SCLicense addLicense(
033                            String name, String url, boolean openSource, boolean active,
034                            boolean recommended)
035                    throws PortalException, SystemException {
036    
037                    PortalPermissionUtil.check(
038                            getPermissionChecker(), ActionKeys.ADD_LICENSE);
039    
040                    return scLicenseLocalService.addLicense(
041                            name, url, openSource, active, recommended);
042            }
043    
044            @Override
045            public void deleteLicense(long licenseId)
046                    throws PortalException, SystemException {
047    
048                    SCLicensePermission.check(
049                            getPermissionChecker(), licenseId, ActionKeys.DELETE);
050    
051                    scLicenseLocalService.deleteLicense(licenseId);
052            }
053    
054            @Override
055            public SCLicense getLicense(long licenseId)
056                    throws PortalException, SystemException {
057    
058                    return scLicenseLocalService.getLicense(licenseId);
059            }
060    
061            @Override
062            public SCLicense updateLicense(
063                            long licenseId, String name, String url, boolean openSource,
064                            boolean active, boolean recommended)
065                    throws PortalException, SystemException {
066    
067                    SCLicensePermission.check(
068                            getPermissionChecker(), licenseId, ActionKeys.UPDATE);
069    
070                    return scLicenseLocalService.updateLicense(
071                            licenseId, name, url, openSource, active, recommended);
072            }
073    
074    }