1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.documentlibrary.service;
21  
22  import com.liferay.portal.PortalException;
23  import com.liferay.portal.SystemException;
24  
25  import java.io.File;
26  
27  import java.util.Date;
28  
29  /**
30   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   *
34   */
35  public class DLServiceUtil {
36  
37      public static void addDirectory(
38              long companyId, long repositoryId, String dirName)
39          throws PortalException, SystemException {
40  
41          _service.addDirectory(companyId, repositoryId, dirName);
42      }
43  
44      public static void addFile(
45              long companyId, String portletId, long groupId, long repositoryId,
46              String fileName, long fileEntryId, String properties,
47              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
48              File file)
49          throws PortalException, SystemException {
50  
51          _service.addFile(
52              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
53              properties, modifiedDate, tagsCategories, tagsEntries, file);
54      }
55  
56      public static void addFile(
57              long companyId, String portletId, long groupId, long repositoryId,
58              String fileName, long fileEntryId, String properties,
59              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
60              byte[] bytes)
61          throws PortalException, SystemException {
62  
63          _service.addFile(
64              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
65              properties, modifiedDate, tagsCategories, tagsEntries, bytes);
66      }
67  
68      public static void deleteDirectory(
69              long companyId, String portletId, long repositoryId, String dirName)
70          throws PortalException, SystemException {
71  
72          DLService _service = DLServiceFactory.getService();
73  
74          _service.deleteDirectory(companyId, portletId, repositoryId, dirName);
75      }
76  
77      public static void deleteFile(
78              long companyId, String portletId, long repositoryId,
79              String fileName)
80          throws PortalException, SystemException {
81  
82          _service.deleteFile(companyId, portletId, repositoryId, fileName);
83      }
84  
85      public static void deleteFile(
86              long companyId, String portletId, long repositoryId,
87              String fileName, double versionNumber)
88          throws PortalException, SystemException {
89  
90          _service.deleteFile(
91              companyId, portletId, repositoryId, fileName, versionNumber);
92      }
93  
94      public static byte[] getFile(
95              long companyId, long repositoryId, String fileName)
96          throws PortalException, SystemException {
97  
98          return _service.getFile(companyId, repositoryId, fileName);
99      }
100 
101     public static byte[] getFile(
102             long companyId, long repositoryId, String fileName,
103             double versionNumber)
104         throws PortalException, SystemException {
105 
106         DLService _service = DLServiceFactory.getService();
107 
108         return _service.getFile(
109             companyId, repositoryId, fileName, versionNumber);
110     }
111 
112     public static String[] getFileNames(
113             long companyId, long repositoryId, String dirName)
114         throws PortalException, SystemException {
115 
116         return _service.getFileNames(companyId, repositoryId, dirName);
117     }
118 
119     public static long getFileSize(
120             long companyId, long repositoryId, String fileName)
121         throws PortalException, SystemException {
122 
123         return _service.getFileSize(companyId, repositoryId, fileName);
124     }
125 
126     public static void reIndex(String[] ids) throws SystemException {
127         _service.reIndex(ids);
128     }
129 
130     public static void updateFile(
131             long companyId, String portletId, long groupId, long repositoryId,
132             String fileName, double versionNumber, String sourceFileName,
133             long fileEntryId, String properties, Date modifiedDate,
134             String[] tagsCategories, String[] tagsEntries, File file)
135         throws PortalException, SystemException {
136 
137         _service.updateFile(
138             companyId, portletId, groupId, repositoryId, fileName,
139             versionNumber, sourceFileName, fileEntryId, properties,
140             modifiedDate, tagsCategories, tagsEntries, file);
141     }
142 
143     public static void updateFile(
144             long companyId, String portletId, long groupId, long repositoryId,
145             String fileName, double versionNumber, String sourceFileName,
146             long fileEntryId, String properties, Date modifiedDate,
147             String[] tagsCategories, String[] tagsEntries, byte[] bytes)
148         throws PortalException, SystemException {
149 
150         DLService _service = DLServiceFactory.getService();
151 
152         _service.updateFile(
153             companyId, portletId, groupId, repositoryId, fileName,
154             versionNumber, sourceFileName, fileEntryId, properties,
155             modifiedDate, tagsCategories, tagsEntries, bytes);
156     }
157 
158     public static void updateFile(
159             long companyId, String portletId, long groupId, long repositoryId,
160             long newRepositoryId, String fileName, long fileEntryId)
161         throws PortalException, SystemException {
162 
163         _service.updateFile(
164             companyId, portletId, groupId, repositoryId, newRepositoryId,
165             fileName, fileEntryId);
166     }
167 
168     public void setService(DLService service) {
169         _service = service;
170     }
171 
172     private static DLService _service;
173 
174 }