001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.kernel.util.MethodCache;
022    import com.liferay.portal.kernel.util.ReferenceRegistry;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import java.io.File;
026    import java.io.InputStream;
027    
028    import java.util.Date;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     */
033    public class DLLocalServiceUtil {
034    
035            public static void addDirectory(
036                            long companyId, long repositoryId, String dirName)
037                    throws PortalException, SystemException {
038    
039                    getService().addDirectory(companyId, repositoryId, dirName);
040            }
041    
042            public static void addFile(
043                            long companyId, String portletId, long groupId, long repositoryId,
044                            String fileName, boolean validateFileExtension, long fileEntryId,
045                            String properties, Date modifiedDate, ServiceContext serviceContext,
046                            InputStream is)
047                    throws PortalException, SystemException {
048    
049                    getService().addFile(
050                            companyId, portletId, groupId, repositoryId, fileName,
051                            validateFileExtension, fileEntryId, properties, modifiedDate,
052                            serviceContext, is);
053            }
054    
055            public static void addFile(
056                            long companyId, String portletId, long groupId, long repositoryId,
057                            String fileName, long fileEntryId, String properties,
058                            Date modifiedDate, ServiceContext serviceContext, byte[] bytes)
059                    throws PortalException, SystemException {
060    
061                    getService().addFile(
062                            companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
063                            properties, modifiedDate, serviceContext, bytes);
064            }
065    
066            public static void addFile(
067                            long companyId, String portletId, long groupId, long repositoryId,
068                            String fileName, long fileEntryId, String properties,
069                            Date modifiedDate, ServiceContext serviceContext, File file)
070                    throws PortalException, SystemException {
071    
072                    getService().addFile(
073                            companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
074                            properties, modifiedDate, serviceContext, file);
075            }
076    
077            public static void checkRoot(long companyId) throws SystemException {
078                    getService().checkRoot(companyId);
079            }
080    
081            public static void deleteDirectory(
082                            long companyId, String portletId, long repositoryId, String dirName)
083                    throws PortalException, SystemException {
084    
085                    getService().deleteDirectory(
086                            companyId, portletId, repositoryId, dirName);
087            }
088    
089            public static void deleteFile(
090                            long companyId, String portletId, long repositoryId,
091                            String fileName)
092                    throws PortalException, SystemException {
093    
094                    getService().deleteFile(
095                            companyId, portletId, repositoryId, fileName);
096            }
097    
098            public static void deleteFile(
099                            long companyId, String portletId, long repositoryId,
100                            String fileName, String versionNumber)
101                    throws PortalException, SystemException {
102    
103                    getService().deleteFile(
104                            companyId, portletId, repositoryId, fileName, versionNumber);
105            }
106    
107            public static byte[] getFile(
108                            long companyId, long repositoryId, String fileName)
109                    throws PortalException, SystemException {
110    
111                    return getService().getFile(companyId, repositoryId, fileName);
112            }
113    
114            public static byte[] getFile(
115                            long companyId, long repositoryId, String fileName,
116                            String versionNumber)
117                    throws PortalException, SystemException {
118    
119                    return getService().getFile(
120                            companyId, repositoryId, fileName, versionNumber);
121            }
122    
123            public static InputStream getFileAsStream(
124                            long companyId, long repositoryId, String fileName)
125                    throws PortalException, SystemException {
126    
127                    return getService().getFileAsStream(companyId, repositoryId, fileName);
128            }
129    
130            public static InputStream getFileAsStream(
131                            long companyId, long repositoryId, String fileName,
132                            String versionNumber)
133                    throws PortalException, SystemException {
134    
135                    return getService().getFileAsStream(
136                            companyId, repositoryId, fileName, versionNumber);
137            }
138    
139            public static String[] getFileNames(
140                            long companyId, long repositoryId, String dirName)
141                    throws PortalException, SystemException {
142    
143                    return getService().getFileNames(companyId, repositoryId, dirName);
144            }
145    
146            public static long getFileSize(
147                            long companyId, long repositoryId, String fileName)
148                    throws PortalException, SystemException {
149    
150                    return getService().getFileSize(companyId, repositoryId, fileName);
151            }
152    
153            public static DLLocalService getService() {
154                    if (_service == null) {
155                            _service = (DLLocalService)PortalBeanLocatorUtil.locate(
156                                    DLLocalService.class.getName());
157    
158                            ReferenceRegistry.registerReference(
159                                    DLLocalServiceUtil.class, "_service");
160    
161                            MethodCache.remove(DLLocalService.class);
162                    }
163    
164                    return _service;
165            }
166    
167            public static boolean hasFile(
168                            long companyId, long repositoryId, String fileName,
169                            String versionNumber)
170                    throws PortalException, SystemException {
171    
172                    return getService().hasFile(
173                            companyId, repositoryId, fileName, versionNumber);
174            }
175    
176            public static void move(String srcDir, String destDir)
177                    throws SystemException {
178    
179                    getService().move(srcDir, destDir);
180            }
181    
182            public static Hits search(
183                            long companyId, String portletId, long groupId,
184                            long userId, long[] repositoryIds, String keywords, int start,
185                            int end)
186                    throws SystemException {
187    
188                    return getService().search(
189                            companyId, portletId, groupId, userId, repositoryIds, keywords,
190                            start, end);
191            }
192    
193            public static void updateFile(
194                            long companyId, String portletId, long groupId, long repositoryId,
195                            long newRepositoryId, String fileName, long fileEntryId)
196                    throws PortalException, SystemException {
197    
198                    getService().updateFile(
199                            companyId, portletId, groupId, repositoryId, newRepositoryId,
200                            fileName, fileEntryId);
201            }
202    
203            public static void updateFile(
204                            long companyId, String portletId, long groupId, long repositoryId,
205                            String fileName, String newFileName, boolean reindex)
206                    throws PortalException, SystemException {
207    
208                    getService().updateFile(
209                            companyId, portletId, groupId, repositoryId, fileName, newFileName,
210                            reindex);
211            }
212    
213            public static void updateFile(
214                            long companyId, String portletId, long groupId, long repositoryId,
215                            String fileName, String fileExtension,
216                            boolean validateFileExtension, String versionNumber,
217                            String sourceFileName, long fileEntryId, String properties,
218                            Date modifiedDate, ServiceContext serviceContext, InputStream is)
219                    throws PortalException, SystemException {
220    
221                    getService().updateFile(
222                            companyId, portletId, groupId, repositoryId, fileName,
223                            fileExtension, validateFileExtension, versionNumber, sourceFileName,
224                            fileEntryId, properties, modifiedDate, serviceContext, is);
225            }
226    
227            public static void updateFile(
228                            long companyId, String portletId, long groupId, long repositoryId,
229                            String fileName, String versionNumber, String sourceFileName,
230                            long fileEntryId, String properties, Date modifiedDate,
231                            ServiceContext serviceContext, byte[] bytes)
232                    throws PortalException, SystemException {
233    
234                    getService().updateFile(
235                            companyId, portletId, groupId, repositoryId, fileName,
236                            versionNumber, sourceFileName, fileEntryId, properties,
237                            modifiedDate, serviceContext, bytes);
238            }
239    
240            public static void updateFile(
241                            long companyId, String portletId, long groupId, long repositoryId,
242                            String fileName, String versionNumber, String sourceFileName,
243                            long fileEntryId, String properties, Date modifiedDate,
244                            ServiceContext serviceContext, File file)
245                    throws PortalException, SystemException {
246    
247                    getService().updateFile(
248                            companyId, portletId, groupId, repositoryId, fileName,
249                            versionNumber, sourceFileName, fileEntryId, properties,
250                            modifiedDate, serviceContext, file);
251            }
252    
253            public static void validate(String fileName, boolean validateFileExtension)
254                    throws PortalException, SystemException {
255    
256                    getService().validate(fileName, validateFileExtension);
257            }
258    
259            public static void validate(
260                            String fileName, boolean validateFileExtension, byte[] bytes)
261                    throws PortalException, SystemException {
262    
263                    getService().validate(fileName, validateFileExtension, bytes);
264            }
265    
266            public static void validate(
267                            String fileName, boolean validateFileExtension, File file)
268                    throws PortalException, SystemException {
269    
270                    getService().validate(fileName, validateFileExtension, file);
271            }
272    
273            public static void validate(
274                            String fileName, boolean validateFileExtension, InputStream is)
275                    throws PortalException, SystemException {
276    
277                    getService().validate(fileName, validateFileExtension, is);
278            }
279    
280            public static void validate(
281                            String fileName, String fileExtension, String sourceFileName,
282                            boolean validateFileExtension, InputStream is)
283                    throws PortalException, SystemException {
284    
285                    getService().validate(
286                            fileName, fileExtension, sourceFileName, validateFileExtension, is);
287            }
288    
289            public void setService(DLLocalService service) {
290                    _service = service;
291    
292                    ReferenceRegistry.registerReference(
293                            DLLocalServiceUtil.class, "_service");
294    
295                    MethodCache.remove(DLLocalService.class);
296            }
297    
298            private static DLLocalService _service;
299    
300    }