001    /**
002     * Copyright (c) 2000-2012 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.documentlibrary.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.documentlibrary.model.DLFileEntryType;
022    import com.liferay.portlet.documentlibrary.service.base.DLFileEntryTypeServiceBaseImpl;
023    import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryTypePermission;
024    import com.liferay.portlet.documentlibrary.service.permission.DLPermission;
025    
026    import java.util.List;
027    
028    /**
029     * @author Alexander Chow
030     */
031    public class DLFileEntryTypeServiceImpl extends DLFileEntryTypeServiceBaseImpl {
032    
033            public DLFileEntryType addFileEntryType(
034                            long groupId, String name, String description,
035                            long[] ddmStructureIds, ServiceContext serviceContext)
036                    throws PortalException, SystemException {
037    
038                    DLPermission.check(
039                            getPermissionChecker(), groupId, ActionKeys.ADD_DOCUMENT_TYPE);
040    
041                    return dlFileEntryTypeLocalService.addFileEntryType(
042                            getUserId(), groupId, name, description, ddmStructureIds,
043                            serviceContext);
044            }
045    
046            public void deleteFileEntryType(long fileEntryTypeId)
047                    throws PortalException, SystemException {
048    
049                    DLFileEntryTypePermission.check(
050                            getPermissionChecker(), fileEntryTypeId, ActionKeys.DELETE);
051    
052                    dlFileEntryTypeLocalService.deleteFileEntryType(fileEntryTypeId);
053            }
054    
055            public DLFileEntryType getFileEntryType(long fileEntryTypeId)
056                    throws PortalException, SystemException {
057    
058                    DLFileEntryTypePermission.check(
059                            getPermissionChecker(), fileEntryTypeId, ActionKeys.VIEW);
060    
061                    return dlFileEntryTypeLocalService.getFileEntryType(fileEntryTypeId);
062            }
063    
064            public List<DLFileEntryType> getFileEntryTypes(long[] groupIds)
065                    throws SystemException {
066    
067                    return dlFileEntryTypePersistence.filterFindByGroupId(groupIds);
068            }
069    
070            public int getFileEntryTypesCount(long[] groupIds) throws SystemException {
071                    return dlFileEntryTypePersistence.filterCountByGroupId(groupIds);
072            }
073    
074            public void updateFileEntryType(
075                            long fileEntryTypeId, String name, String description,
076                            long[] ddmStructureIds, ServiceContext serviceContext)
077                    throws PortalException, SystemException {
078    
079                    DLFileEntryTypePermission.check(
080                            getPermissionChecker(), fileEntryTypeId, ActionKeys.UPDATE);
081    
082                    dlFileEntryTypeLocalService.updateFileEntryType(
083                            getUserId(), fileEntryTypeId, name, description, ddmStructureIds,
084                            serviceContext);
085            }
086    
087    }