1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.documentlibrary.service;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
20  import com.liferay.portal.kernel.util.MethodCache;
21  import com.liferay.portal.kernel.util.ReferenceRegistry;
22  
23  import java.io.File;
24  
25  import java.util.Date;
26  
27  /**
28   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class DLServiceUtil {
33  
34      public static void addDirectory(
35              long companyId, long repositoryId, String dirName)
36          throws PortalException, SystemException {
37  
38          getService().addDirectory(companyId, repositoryId, dirName);
39      }
40  
41      public static void addFile(
42              long companyId, String portletId, long groupId, long repositoryId,
43              String fileName, long fileEntryId, String properties,
44              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
45              File file)
46          throws PortalException, SystemException {
47  
48          getService().addFile(
49              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
50              properties, modifiedDate, tagsCategories, tagsEntries, file);
51      }
52  
53      public static void addFile(
54              long companyId, String portletId, long groupId, long repositoryId,
55              String fileName, long fileEntryId, String properties,
56              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
57              byte[] bytes)
58          throws PortalException, SystemException {
59  
60          getService().addFile(
61              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
62              properties, modifiedDate, tagsCategories, tagsEntries, bytes);
63      }
64  
65      public static void deleteDirectory(
66              long companyId, String portletId, long repositoryId, String dirName)
67          throws PortalException, SystemException {
68  
69          getService().deleteDirectory(
70              companyId, portletId, repositoryId, dirName);
71      }
72  
73      public static void deleteFile(
74              long companyId, String portletId, long repositoryId,
75              String fileName)
76          throws PortalException, SystemException {
77  
78          getService().deleteFile(companyId, portletId, repositoryId, fileName);
79      }
80  
81      public static void deleteFile(
82              long companyId, String portletId, long repositoryId,
83              String fileName, double versionNumber)
84          throws PortalException, SystemException {
85  
86          getService().deleteFile(
87              companyId, portletId, repositoryId, fileName, versionNumber);
88      }
89  
90      public static byte[] getFile(
91              long companyId, long repositoryId, String fileName)
92          throws PortalException, SystemException {
93  
94          return getService().getFile(companyId, repositoryId, fileName);
95      }
96  
97      public static byte[] getFile(
98              long companyId, long repositoryId, String fileName,
99              double versionNumber)
100         throws PortalException, SystemException {
101 
102         return getService().getFile(
103             companyId, repositoryId, fileName, versionNumber);
104     }
105 
106     public static String[] getFileNames(
107             long companyId, long repositoryId, String dirName)
108         throws PortalException, SystemException {
109 
110         return getService().getFileNames(companyId, repositoryId, dirName);
111     }
112 
113     public static long getFileSize(
114             long companyId, long repositoryId, String fileName)
115         throws PortalException, SystemException {
116 
117         return getService().getFileSize(companyId, repositoryId, fileName);
118     }
119 
120     public static DLService getService() {
121         if (_service == null) {
122             _service = (DLService)PortalBeanLocatorUtil.locate(
123                 DLService.class.getName());
124 
125             ReferenceRegistry.registerReference(
126                 DLServiceUtil.class, "_service");
127 
128             MethodCache.remove(DLService.class);
129         }
130 
131         return _service;
132     }
133 
134     public static void reIndex(String[] ids) throws SystemException {
135         getService().reIndex(ids);
136     }
137 
138     public static void updateFile(
139             long companyId, String portletId, long groupId, long repositoryId,
140             String fileName, double versionNumber, String sourceFileName,
141             long fileEntryId, String properties, Date modifiedDate,
142             String[] tagsCategories, String[] tagsEntries, File file)
143         throws PortalException, SystemException {
144 
145         getService().updateFile(
146             companyId, portletId, groupId, repositoryId, fileName,
147             versionNumber, sourceFileName, fileEntryId, properties,
148             modifiedDate, tagsCategories, tagsEntries, file);
149     }
150 
151     public static void updateFile(
152             long companyId, String portletId, long groupId, long repositoryId,
153             String fileName, double versionNumber, String sourceFileName,
154             long fileEntryId, String properties, Date modifiedDate,
155             String[] tagsCategories, String[] tagsEntries, byte[] bytes)
156         throws PortalException, SystemException {
157 
158         getService().updateFile(
159             companyId, portletId, groupId, repositoryId, fileName,
160             versionNumber, sourceFileName, fileEntryId, properties,
161             modifiedDate, tagsCategories, tagsEntries, bytes);
162     }
163 
164     public static void updateFile(
165             long companyId, String portletId, long groupId, long repositoryId,
166             long newRepositoryId, String fileName, long fileEntryId)
167         throws PortalException, SystemException {
168 
169         getService().updateFile(
170             companyId, portletId, groupId, repositoryId, newRepositoryId,
171             fileName, fileEntryId);
172     }
173 
174     public void setService(DLService service) {
175         _service = service;
176 
177         ReferenceRegistry.registerReference(DLServiceUtil.class, "_service");
178 
179         MethodCache.remove(DLService.class);
180     }
181 
182     private static DLService _service;
183 
184 }