1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.documentlibrary.service;
16  
17  import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
18  import com.liferay.portal.kernel.exception.PortalException;
19  import com.liferay.portal.kernel.exception.SystemException;
20  import com.liferay.portal.service.ServiceContext;
21  
22  import java.io.File;
23  
24  import java.util.Date;
25  
26  /**
27   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
28   *
29   * @author Brian Wing Shun Chan
30   */
31  public class DLServiceUtil {
32  
33      public static void addDirectory(
34              long companyId, long repositoryId, String dirName)
35          throws PortalException, SystemException {
36  
37          getService().addDirectory(companyId, repositoryId, dirName);
38      }
39  
40      public static void addFile(
41              long companyId, String portletId, long groupId, long repositoryId,
42              String fileName, long fileEntryId, String properties,
43              Date modifiedDate, ServiceContext serviceContext, byte[] bytes)
44          throws PortalException, SystemException {
45  
46          getService().addFile(
47              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
48              properties, modifiedDate, serviceContext, bytes);
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, ServiceContext serviceContext, File file)
55          throws PortalException, SystemException {
56  
57          getService().addFile(
58              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
59              properties, modifiedDate, serviceContext, file);
60      }
61  
62      public static void deleteDirectory(
63              long companyId, String portletId, long repositoryId, String dirName)
64          throws PortalException, SystemException {
65  
66          getService().deleteDirectory(
67              companyId, portletId, repositoryId, dirName);
68      }
69  
70      public static void deleteFile(
71              long companyId, String portletId, long repositoryId,
72              String fileName)
73          throws PortalException, SystemException {
74  
75          getService().deleteFile(companyId, portletId, repositoryId, fileName);
76      }
77  
78      public static void deleteFile(
79              long companyId, String portletId, long repositoryId,
80              String fileName, String versionNumber)
81          throws PortalException, SystemException {
82  
83          getService().deleteFile(
84              companyId, portletId, repositoryId, fileName, versionNumber);
85      }
86  
87      public static byte[] getFile(
88              long companyId, long repositoryId, String fileName)
89          throws PortalException, SystemException {
90  
91          return getService().getFile(companyId, repositoryId, fileName);
92      }
93  
94      public static byte[] getFile(
95              long companyId, long repositoryId, String fileName,
96              String versionNumber)
97          throws PortalException, SystemException {
98  
99          return getService().getFile(
100             companyId, repositoryId, fileName, versionNumber);
101     }
102 
103     public static String[] getFileNames(
104             long companyId, long repositoryId, String dirName)
105         throws PortalException, SystemException {
106 
107         return getService().getFileNames(companyId, repositoryId, dirName);
108     }
109 
110     public static long getFileSize(
111             long companyId, long repositoryId, String fileName)
112         throws PortalException, SystemException {
113 
114         return getService().getFileSize(companyId, repositoryId, fileName);
115     }
116 
117     public static DLService getService() {
118         if (_service == null) {
119             _service = (DLService)PortalBeanLocatorUtil.locate(
120                 DLService.class.getName());
121         }
122 
123         return _service;
124     }
125 
126     public static void updateFile(
127             long companyId, String portletId, long groupId, long repositoryId,
128             long newRepositoryId, String fileName, long fileEntryId)
129         throws PortalException, SystemException {
130 
131         getService().updateFile(
132             companyId, portletId, groupId, repositoryId, newRepositoryId,
133             fileName, fileEntryId);
134     }
135 
136     public static void updateFile(
137             long companyId, String portletId, long groupId, long repositoryId,
138             String fileName, String versionNumber, String sourceFileName,
139             long fileEntryId, String properties, Date modifiedDate,
140             ServiceContext serviceContext, byte[] bytes)
141         throws PortalException, SystemException {
142 
143         getService().updateFile(
144             companyId, portletId, groupId, repositoryId, fileName,
145             versionNumber, sourceFileName, fileEntryId, properties,
146             modifiedDate, serviceContext, bytes);
147     }
148 
149     public static void updateFile(
150             long companyId, String portletId, long groupId, long repositoryId,
151             String fileName, String versionNumber, String sourceFileName,
152             long fileEntryId, String properties, Date modifiedDate,
153             ServiceContext serviceContext, File file)
154         throws PortalException, SystemException {
155 
156         getService().updateFile(
157             companyId, portletId, groupId, repositoryId, fileName,
158             versionNumber, sourceFileName, fileEntryId, properties,
159             modifiedDate, serviceContext, file);
160     }
161 
162     public static void updateFile(
163             long companyId, String portletId, long groupId, long repositoryId,
164             String fileName, String newFileName, boolean reindex)
165         throws PortalException, SystemException {
166 
167         getService().updateFile(
168             companyId, portletId, groupId, repositoryId, fileName, newFileName,
169             reindex);
170     }
171 
172     public void setService(DLService service) {
173         _service = service;
174     }
175 
176     private static DLService _service;
177 
178 }