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.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            @Override
035            public DLFileEntryType addFileEntryType(
036                            long groupId, String name, String description,
037                            long[] ddmStructureIds, ServiceContext serviceContext)
038                    throws PortalException, SystemException {
039    
040                    DLPermission.check(
041                            getPermissionChecker(), groupId, ActionKeys.ADD_DOCUMENT_TYPE);
042    
043                    return dlFileEntryTypeLocalService.addFileEntryType(
044                            getUserId(), groupId, name, description, ddmStructureIds,
045                            serviceContext);
046            }
047    
048            @Override
049            public void deleteFileEntryType(long fileEntryTypeId)
050                    throws PortalException, SystemException {
051    
052                    DLFileEntryTypePermission.check(
053                            getPermissionChecker(), fileEntryTypeId, ActionKeys.DELETE);
054    
055                    dlFileEntryTypeLocalService.deleteFileEntryType(fileEntryTypeId);
056            }
057    
058            @Override
059            public DLFileEntryType getFileEntryType(long fileEntryTypeId)
060                    throws PortalException, SystemException {
061    
062                    DLFileEntryTypePermission.check(
063                            getPermissionChecker(), fileEntryTypeId, ActionKeys.VIEW);
064    
065                    return dlFileEntryTypeLocalService.getFileEntryType(fileEntryTypeId);
066            }
067    
068            @Override
069            public List<DLFileEntryType> getFileEntryTypes(long[] groupIds)
070                    throws SystemException {
071    
072                    return dlFileEntryTypePersistence.filterFindByGroupId(groupIds);
073            }
074    
075            @Override
076            public int getFileEntryTypesCount(long[] groupIds) throws SystemException {
077                    return dlFileEntryTypePersistence.filterCountByGroupId(groupIds);
078            }
079    
080            @Override
081            public List<DLFileEntryType> search(
082                            long companyId, long[] groupIds, String keywords,
083                            boolean includeBasicFileEntryType, int start, int end,
084                            OrderByComparator orderByComparator)
085                    throws SystemException {
086    
087                    return dlFileEntryTypeFinder.filterFindByKeywords(
088                            companyId, groupIds, keywords, includeBasicFileEntryType, start,
089                            end, orderByComparator);
090            }
091    
092            @Override
093            public int searchCount(
094                            long companyId, long[] groupIds, String keywords,
095                            boolean includeBasicFileEntryType)
096                    throws SystemException {
097    
098                    return dlFileEntryTypeFinder.filterCountByKeywords(
099                            companyId, groupIds, keywords, includeBasicFileEntryType);
100            }
101    
102            @Override
103            public void updateFileEntryType(
104                            long fileEntryTypeId, String name, String description,
105                            long[] ddmStructureIds, ServiceContext serviceContext)
106                    throws PortalException, SystemException {
107    
108                    DLFileEntryTypePermission.check(
109                            getPermissionChecker(), fileEntryTypeId, ActionKeys.UPDATE);
110    
111                    dlFileEntryTypeLocalService.updateFileEntryType(
112                            getUserId(), fileEntryTypeId, name, description, ddmStructureIds,
113                            serviceContext);
114            }
115    
116    }