1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights 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  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
28  
29  import java.io.File;
30  
31  import java.util.Date;
32  
33  /**
34   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   */
38  public class DLServiceUtil {
39  
40      public static void addDirectory(
41              long companyId, long repositoryId, String dirName)
42          throws PortalException, SystemException {
43  
44          getService().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          getService().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          getService().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          getService().deleteDirectory(
76              companyId, portletId, repositoryId, dirName);
77      }
78  
79      public static void deleteFile(
80              long companyId, String portletId, long repositoryId,
81              String fileName)
82          throws PortalException, SystemException {
83  
84          getService().deleteFile(companyId, portletId, repositoryId, fileName);
85      }
86  
87      public static void deleteFile(
88              long companyId, String portletId, long repositoryId,
89              String fileName, double versionNumber)
90          throws PortalException, SystemException {
91  
92          getService().deleteFile(
93              companyId, portletId, repositoryId, fileName, versionNumber);
94      }
95  
96      public static byte[] getFile(
97              long companyId, long repositoryId, String fileName)
98          throws PortalException, SystemException {
99  
100         return getService().getFile(companyId, repositoryId, fileName);
101     }
102 
103     public static byte[] getFile(
104             long companyId, long repositoryId, String fileName,
105             double versionNumber)
106         throws PortalException, SystemException {
107 
108         return getService().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 getService().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 getService().getFileSize(companyId, repositoryId, fileName);
124     }
125 
126     public static DLService getService() {
127         if (_service == null) {
128             _service = (DLService)PortalBeanLocatorUtil.locate(
129                 DLService.class.getName());
130         }
131 
132         return _service;
133     }
134 
135     public static void reIndex(String[] ids) throws SystemException {
136         getService().reIndex(ids);
137     }
138 
139     public static void updateFile(
140             long companyId, String portletId, long groupId, long repositoryId,
141             String fileName, double versionNumber, String sourceFileName,
142             long fileEntryId, String properties, Date modifiedDate,
143             String[] tagsCategories, String[] tagsEntries, File file)
144         throws PortalException, SystemException {
145 
146         getService().updateFile(
147             companyId, portletId, groupId, repositoryId, fileName,
148             versionNumber, sourceFileName, fileEntryId, properties,
149             modifiedDate, tagsCategories, tagsEntries, file);
150     }
151 
152     public static void updateFile(
153             long companyId, String portletId, long groupId, long repositoryId,
154             String fileName, double versionNumber, String sourceFileName,
155             long fileEntryId, String properties, Date modifiedDate,
156             String[] tagsCategories, String[] tagsEntries, byte[] bytes)
157         throws PortalException, SystemException {
158 
159         getService().updateFile(
160             companyId, portletId, groupId, repositoryId, fileName,
161             versionNumber, sourceFileName, fileEntryId, properties,
162             modifiedDate, tagsCategories, tagsEntries, bytes);
163     }
164 
165     public static void updateFile(
166             long companyId, String portletId, long groupId, long repositoryId,
167             long newRepositoryId, String fileName, long fileEntryId)
168         throws PortalException, SystemException {
169 
170         getService().updateFile(
171             companyId, portletId, groupId, repositoryId, newRepositoryId,
172             fileName, fileEntryId);
173     }
174 
175     public void setService(DLService service) {
176         _service = service;
177     }
178 
179     private static DLService _service;
180 
181 }