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.service.ServiceContext;
021    
022    import java.io.File;
023    
024    import java.util.Date;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class DLServiceUtil {
030    
031            public static void addDirectory(
032                            long companyId, long repositoryId, String dirName)
033                    throws PortalException, SystemException {
034    
035                    getService().addDirectory(companyId, repositoryId, dirName);
036            }
037    
038            public static void addFile(
039                            long companyId, String portletId, long groupId, long repositoryId,
040                            String fileName, long fileEntryId, String properties,
041                            Date modifiedDate, ServiceContext serviceContext, byte[] bytes)
042                    throws PortalException, SystemException {
043    
044                    getService().addFile(
045                            companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
046                            properties, modifiedDate, serviceContext, bytes);
047            }
048    
049            public static void addFile(
050                            long companyId, String portletId, long groupId, long repositoryId,
051                            String fileName, long fileEntryId, String properties,
052                            Date modifiedDate, ServiceContext serviceContext, File file)
053                    throws PortalException, SystemException {
054    
055                    getService().addFile(
056                            companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
057                            properties, modifiedDate, serviceContext, file);
058            }
059    
060            public static void deleteDirectory(
061                            long companyId, String portletId, long repositoryId, String dirName)
062                    throws PortalException, SystemException {
063    
064                    getService().deleteDirectory(
065                            companyId, portletId, repositoryId, dirName);
066            }
067    
068            public static void deleteFile(
069                            long companyId, String portletId, long repositoryId,
070                            String fileName)
071                    throws PortalException, SystemException {
072    
073                    getService().deleteFile(companyId, portletId, repositoryId, fileName);
074            }
075    
076            public static void deleteFile(
077                            long companyId, String portletId, long repositoryId,
078                            String fileName, String versionNumber)
079                    throws PortalException, SystemException {
080    
081                    getService().deleteFile(
082                            companyId, portletId, repositoryId, fileName, versionNumber);
083            }
084    
085            public static byte[] getFile(
086                            long companyId, long repositoryId, String fileName)
087                    throws PortalException, SystemException {
088    
089                    return getService().getFile(companyId, repositoryId, fileName);
090            }
091    
092            public static byte[] getFile(
093                            long companyId, long repositoryId, String fileName,
094                            String versionNumber)
095                    throws PortalException, SystemException {
096    
097                    return getService().getFile(
098                            companyId, repositoryId, fileName, versionNumber);
099            }
100    
101            public static String[] getFileNames(
102                            long companyId, long repositoryId, String dirName)
103                    throws PortalException, SystemException {
104    
105                    return getService().getFileNames(companyId, repositoryId, dirName);
106            }
107    
108            public static long getFileSize(
109                            long companyId, long repositoryId, String fileName)
110                    throws PortalException, SystemException {
111    
112                    return getService().getFileSize(companyId, repositoryId, fileName);
113            }
114    
115            public static DLService getService() {
116                    if (_service == null) {
117                            _service = (DLService)PortalBeanLocatorUtil.locate(
118                                    DLService.class.getName());
119                    }
120    
121                    return _service;
122            }
123    
124            public static void updateFile(
125                            long companyId, String portletId, long groupId, long repositoryId,
126                            long newRepositoryId, String fileName, long fileEntryId)
127                    throws PortalException, SystemException {
128    
129                    getService().updateFile(
130                            companyId, portletId, groupId, repositoryId, newRepositoryId,
131                            fileName, fileEntryId);
132            }
133    
134            public static void updateFile(
135                            long companyId, String portletId, long groupId, long repositoryId,
136                            String fileName, String versionNumber, String sourceFileName,
137                            long fileEntryId, String properties, Date modifiedDate,
138                            ServiceContext serviceContext, byte[] bytes)
139                    throws PortalException, SystemException {
140    
141                    getService().updateFile(
142                            companyId, portletId, groupId, repositoryId, fileName,
143                            versionNumber, sourceFileName, fileEntryId, properties,
144                            modifiedDate, serviceContext, bytes);
145            }
146    
147            public static void updateFile(
148                            long companyId, String portletId, long groupId, long repositoryId,
149                            String fileName, String versionNumber, String sourceFileName,
150                            long fileEntryId, String properties, Date modifiedDate,
151                            ServiceContext serviceContext, File file)
152                    throws PortalException, SystemException {
153    
154                    getService().updateFile(
155                            companyId, portletId, groupId, repositoryId, fileName,
156                            versionNumber, sourceFileName, fileEntryId, properties,
157                            modifiedDate, serviceContext, file);
158            }
159    
160            public static void updateFile(
161                            long companyId, String portletId, long groupId, long repositoryId,
162                            String fileName, String newFileName, boolean reindex)
163                    throws PortalException, SystemException {
164    
165                    getService().updateFile(
166                            companyId, portletId, groupId, repositoryId, fileName, newFileName,
167                            reindex);
168            }
169    
170            public void setService(DLService service) {
171                    _service = service;
172            }
173    
174            private static DLService _service;
175    
176    }