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.kernel.util.OrderByComparator;
020    import com.liferay.portal.security.permission.ActionKeys;
021    import com.liferay.portal.service.ServiceContext;
022    import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
023    import com.liferay.portlet.documentlibrary.service.base.DLFileEntryTypeServiceBaseImpl;
024    import com.liferay.portlet.documentlibrary.service.permission.DLFileEntryTypePermission;
025    import com.liferay.portlet.documentlibrary.service.permission.DLPermission;
026    
027    import java.util.List;
028    
029    /**
030     * @author Alexander Chow
031     */
032    public class DLFileEntryTypeServiceImpl extends DLFileEntryTypeServiceBaseImpl {
033    
034            public DLFileEntryType addFileEntryType(
035                            long groupId, String name, String description,
036                            long[] ddmStructureIds, ServiceContext serviceContext)
037                    throws PortalException, SystemException {
038    
039                    DLPermission.check(
040                            getPermissionChecker(), groupId, ActionKeys.ADD_DOCUMENT_TYPE);
041    
042                    return dlFileEntryTypeLocalService.addFileEntryType(
043                            getUserId(), groupId, name, description, ddmStructureIds,
044                            serviceContext);
045            }
046    
047            public void deleteFileEntryType(long fileEntryTypeId)
048                    throws PortalException, SystemException {
049    
050                    DLFileEntryTypePermission.check(
051                            getPermissionChecker(), fileEntryTypeId, ActionKeys.DELETE);
052    
053                    dlFileEntryTypeLocalService.deleteFileEntryType(fileEntryTypeId);
054            }
055    
056            public DLFileEntryType getFileEntryType(long fileEntryTypeId)
057                    throws PortalException, SystemException {
058    
059                    DLFileEntryTypePermission.check(
060                            getPermissionChecker(), fileEntryTypeId, ActionKeys.VIEW);
061    
062                    return dlFileEntryTypeLocalService.getFileEntryType(fileEntryTypeId);
063            }
064    
065            public List<DLFileEntryType> getFileEntryTypes(long[] groupIds)
066                    throws SystemException {
067    
068                    return dlFileEntryTypePersistence.filterFindByGroupId(groupIds);
069            }
070    
071            public int getFileEntryTypesCount(long[] groupIds) throws SystemException {
072                    return dlFileEntryTypePersistence.filterCountByGroupId(groupIds);
073            }
074    
075            public List<DLFileEntryType> search(
076                            long companyId, long[] groupIds, String keywords,
077                            boolean includeBasicFileEntryType, int start, int end,
078                            OrderByComparator orderByComparator)
079                    throws SystemException {
080    
081                    return dlFileEntryTypeFinder.filterFindByKeywords(
082                            companyId, groupIds, keywords, includeBasicFileEntryType, start,
083                            end, orderByComparator);
084            }
085    
086            public int searchCount(
087                            long companyId, long[] groupIds, String keywords,
088                            boolean includeBasicFileEntryType)
089                    throws SystemException {
090    
091                    return dlFileEntryTypeFinder.filterCountByKeywords(
092                            companyId, groupIds, keywords, includeBasicFileEntryType);
093            }
094    
095            public void updateFileEntryType(
096                            long fileEntryTypeId, String name, String description,
097                            long[] ddmStructureIds, ServiceContext serviceContext)
098                    throws PortalException, SystemException {
099    
100                    DLFileEntryTypePermission.check(
101                            getPermissionChecker(), fileEntryTypeId, ActionKeys.UPDATE);
102    
103                    dlFileEntryTypeLocalService.updateFileEntryType(
104                            getUserId(), fileEntryTypeId, name, description, ddmStructureIds,
105                            serviceContext);
106            }
107    
108    }