001    /**
002     * Copyright (c) 2000-2011 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.dynamicdatamapping.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.ServiceContext;
021    import com.liferay.portlet.dynamicdatamapping.model.DDMStructureLink;
022    import com.liferay.portlet.dynamicdatamapping.service.base.DDMStructureLinkServiceBaseImpl;
023    import com.liferay.portlet.dynamicdatamapping.service.permission.DDMPermission;
024    import com.liferay.portlet.dynamicdatamapping.service.permission.DDMStructurePermission;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     * @author Bruno Basto
029     */
030    public class DDMStructureLinkServiceImpl
031            extends DDMStructureLinkServiceBaseImpl {
032    
033            public DDMStructureLink addStructureLink(
034                            long classNameId, long classPK, long structureId,
035                            ServiceContext serviceContext)
036                    throws PortalException, SystemException {
037    
038                    DDMPermission.check(
039                            getPermissionChecker(), serviceContext.getScopeGroupId(),
040                            ActionKeys.ADD_STRUCTURE);
041    
042                    return ddmStructureLinkLocalService.addStructureLink(
043                            classNameId, classPK, structureId, serviceContext);
044            }
045    
046            public void deleteStructureLink(long structureLinkId)
047                    throws PortalException, SystemException {
048    
049                    DDMStructureLink structureLink =
050                            ddmStructureLinkPersistence.findByPrimaryKey(structureLinkId);
051    
052                    DDMStructurePermission.check(
053                            getPermissionChecker(), structureLink.getStructureId(),
054                            ActionKeys.DELETE);
055    
056                    ddmStructureLinkLocalService.deleteStructureLink(structureLinkId);
057            }
058    
059            public DDMStructureLink getStructureLink(long structureLinkId)
060                    throws PortalException, SystemException {
061    
062                    DDMStructureLink structureLink =
063                            ddmStructureLinkPersistence.findByPrimaryKey(structureLinkId);
064    
065                    DDMStructurePermission.check(
066                            getPermissionChecker(), structureLink.getStructureId(),
067                            ActionKeys.VIEW);
068    
069                    return structureLink;
070            }
071    
072            public DDMStructureLink updateStructureLink(
073                            long structureLinkId, long classNameId, long classPK,
074                            long structureId)
075                    throws PortalException, SystemException {
076    
077                    DDMStructurePermission.check(
078                            getPermissionChecker(), structureId, ActionKeys.UPDATE);
079    
080                    return ddmStructureLinkLocalService.updateStructureLink(
081                            structureLinkId, classNameId, classPK, structureId);
082            }
083    
084    }