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