001    /**
002     * Copyright (c) 2000-2010 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.documentlibrary.service;
016    
017    import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
018    import com.liferay.portal.kernel.exception.PortalException;
019    import com.liferay.portal.kernel.exception.SystemException;
020    import com.liferay.portal.kernel.search.Hits;
021    import com.liferay.portal.service.ServiceContext;
022    
023    import java.io.File;
024    import java.io.InputStream;
025    
026    import java.util.Date;
027    
028    /**
029     * @author Brian Wing Shun Chan
030     */
031    public class DLLocalServiceUtil {
032    
033            public static void addFile(
034                            long companyId, String portletId, long groupId, long repositoryId,
035                            String fileName, boolean validateFileExtension, long fileEntryId,
036                            String properties, Date modifiedDate, ServiceContext serviceContext,
037                            InputStream is)
038                    throws PortalException, SystemException {
039    
040                    getService().addFile(
041                            companyId, portletId, groupId, repositoryId, fileName,
042                            validateFileExtension, fileEntryId, properties, modifiedDate,
043                            serviceContext, is);
044            }
045    
046            public static void checkRoot(long companyId) throws SystemException {
047                    getService().checkRoot(companyId);
048            }
049    
050            public static InputStream getFileAsStream(
051                            long companyId, long repositoryId, String fileName)
052                    throws PortalException, SystemException {
053    
054                    return getService().getFileAsStream(companyId, repositoryId, fileName);
055            }
056    
057            public static InputStream getFileAsStream(
058                            long companyId, long repositoryId, String fileName,
059                            String versionNumber)
060                    throws PortalException, SystemException {
061    
062                    return getService().getFileAsStream(
063                            companyId, repositoryId, fileName, versionNumber);
064            }
065    
066            public static DLLocalService getService() {
067                    if (_service == null) {
068                            _service = (DLLocalService)PortalBeanLocatorUtil.locate(
069                                    DLLocalService.class.getName());
070                    }
071    
072                    return _service;
073            }
074    
075            public static boolean hasFile(
076                            long companyId, long repositoryId, String fileName,
077                            String versionNumber)
078                    throws PortalException, SystemException {
079    
080                    return getService().hasFile(
081                            companyId, repositoryId, fileName, versionNumber);
082            }
083    
084            public static void move(String srcDir, String destDir)
085                    throws SystemException {
086    
087                    getService().move(srcDir, destDir);
088            }
089    
090            public static Hits search(
091                            long companyId, String portletId, long groupId,
092                            long userId, long[] repositoryIds, String keywords, int start,
093                            int end)
094                    throws SystemException {
095    
096                    return getService().search(
097                            companyId, portletId, groupId, userId, repositoryIds, keywords,
098                            start, end);
099            }
100    
101            public static void updateFile(
102                            long companyId, String portletId, long groupId, long repositoryId,
103                            String fileName, String fileExtension,
104                            boolean validateFileExtension, String versionNumber,
105                            String sourceFileName, long fileEntryId, String properties,
106                            Date modifiedDate, ServiceContext serviceContext, InputStream is)
107                    throws PortalException, SystemException {
108    
109                    getService().updateFile(
110                            companyId, portletId, groupId, repositoryId, fileName,
111                            fileExtension, validateFileExtension, versionNumber, sourceFileName,
112                            fileEntryId, properties, modifiedDate, serviceContext, is);
113            }
114    
115            public static void validate(
116                            String fileName, boolean validateFileExtension, byte[] bytes)
117                    throws PortalException, SystemException {
118    
119                    getService().validate(fileName, validateFileExtension, bytes);
120            }
121    
122            public static void validate(
123                            String fileName, boolean validateFileExtension, File file)
124                    throws PortalException, SystemException {
125    
126                    getService().validate(fileName, validateFileExtension, file);
127            }
128    
129            public static void validate(
130                            String fileName, boolean validateFileExtension, InputStream is)
131                    throws PortalException, SystemException {
132    
133                    getService().validate(fileName, validateFileExtension, is);
134            }
135    
136            public static void validate(
137                            String fileName, String fileExtension, String sourceFileName,
138                            boolean validateFileExtension, InputStream is)
139                    throws PortalException, SystemException {
140    
141                    getService().validate(
142                            fileName, fileExtension, sourceFileName, validateFileExtension, is);
143            }
144    
145            public void setService(DLLocalService service) {
146                    _service = service;
147            }
148    
149            private static DLLocalService _service;
150    
151    }