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