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  
21  import java.io.File;
22  
23  import java.util.Date;
24  
25  /**
26   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class DLServiceUtil {
31  
32      public static void addDirectory(
33              long companyId, long repositoryId, String dirName)
34          throws PortalException, SystemException {
35  
36          getService().addDirectory(companyId, repositoryId, dirName);
37      }
38  
39      public static void addFile(
40              long companyId, String portletId, long groupId, long repositoryId,
41              String fileName, long fileEntryId, String properties,
42              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
43              File file)
44          throws PortalException, SystemException {
45  
46          getService().addFile(
47              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
48              properties, modifiedDate, tagsCategories, tagsEntries, file);
49      }
50  
51      public static void addFile(
52              long companyId, String portletId, long groupId, long repositoryId,
53              String fileName, long fileEntryId, String properties,
54              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
55              byte[] bytes)
56          throws PortalException, SystemException {
57  
58          getService().addFile(
59              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
60              properties, modifiedDate, tagsCategories, tagsEntries, bytes);
61      }
62  
63      public static void deleteDirectory(
64              long companyId, String portletId, long repositoryId, String dirName)
65          throws PortalException, SystemException {
66  
67          getService().deleteDirectory(
68              companyId, portletId, repositoryId, dirName);
69      }
70  
71      public static void deleteFile(
72              long companyId, String portletId, long repositoryId,
73              String fileName)
74          throws PortalException, SystemException {
75  
76          getService().deleteFile(companyId, portletId, repositoryId, fileName);
77      }
78  
79      public static void deleteFile(
80              long companyId, String portletId, long repositoryId,
81              String fileName, double versionNumber)
82          throws PortalException, SystemException {
83  
84          getService().deleteFile(
85              companyId, portletId, repositoryId, fileName, versionNumber);
86      }
87  
88      public static byte[] getFile(
89              long companyId, long repositoryId, String fileName)
90          throws PortalException, SystemException {
91  
92          return getService().getFile(companyId, repositoryId, fileName);
93      }
94  
95      public static byte[] getFile(
96              long companyId, long repositoryId, String fileName,
97              double versionNumber)
98          throws PortalException, SystemException {
99  
100         return getService().getFile(
101             companyId, repositoryId, fileName, versionNumber);
102     }
103 
104     public static String[] getFileNames(
105             long companyId, long repositoryId, String dirName)
106         throws PortalException, SystemException {
107 
108         return getService().getFileNames(companyId, repositoryId, dirName);
109     }
110 
111     public static long getFileSize(
112             long companyId, long repositoryId, String fileName)
113         throws PortalException, SystemException {
114 
115         return getService().getFileSize(companyId, repositoryId, fileName);
116     }
117 
118     public static DLService getService() {
119         if (_service == null) {
120             _service = (DLService)PortalBeanLocatorUtil.locate(
121                 DLService.class.getName());
122         }
123 
124         return _service;
125     }
126 
127     public static void reIndex(String[] ids) throws SystemException {
128         getService().reIndex(ids);
129     }
130 
131     public static void updateFile(
132             long companyId, String portletId, long groupId, long repositoryId,
133             String fileName, double versionNumber, String sourceFileName,
134             long fileEntryId, String properties, Date modifiedDate,
135             String[] tagsCategories, String[] tagsEntries, File file)
136         throws PortalException, SystemException {
137 
138         getService().updateFile(
139             companyId, portletId, groupId, repositoryId, fileName,
140             versionNumber, sourceFileName, fileEntryId, properties,
141             modifiedDate, tagsCategories, tagsEntries, file);
142     }
143 
144     public static void updateFile(
145             long companyId, String portletId, long groupId, long repositoryId,
146             String fileName, double versionNumber, String sourceFileName,
147             long fileEntryId, String properties, Date modifiedDate,
148             String[] tagsCategories, String[] tagsEntries, byte[] bytes)
149         throws PortalException, SystemException {
150 
151         getService().updateFile(
152             companyId, portletId, groupId, repositoryId, fileName,
153             versionNumber, sourceFileName, fileEntryId, properties,
154             modifiedDate, tagsCategories, tagsEntries, bytes);
155     }
156 
157     public static void updateFile(
158             long companyId, String portletId, long groupId, long repositoryId,
159             long newRepositoryId, String fileName, long fileEntryId)
160         throws PortalException, SystemException {
161 
162         getService().updateFile(
163             companyId, portletId, groupId, repositoryId, newRepositoryId,
164             fileName, fileEntryId);
165     }
166 
167     public void setService(DLService service) {
168         _service = service;
169     }
170 
171     private static DLService _service;
172 
173 }