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.rmi.RemoteException;
24  
25  import java.util.Date;
26  
27  /**
28   * <a href="DLServiceUtil.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class DLServiceUtil {
33  
34      public static void addDirectory(
35              long companyId, long repositoryId, String dirName)
36          throws PortalException, RemoteException, SystemException {
37  
38          getService().addDirectory(companyId, repositoryId, dirName);
39      }
40  
41      public static void addFile(
42              long companyId, String portletId, long groupId, long repositoryId,
43              String fileName, String properties, Date modifiedDate,
44              String[] tagsEntries, byte[] bytes)
45          throws PortalException, RemoteException, SystemException {
46  
47          getService().addFile(
48              companyId, portletId, groupId, repositoryId, fileName, properties,
49              modifiedDate, tagsEntries, bytes);
50      }
51  
52      public static void addFile(
53              long companyId, String portletId, long groupId, long repositoryId,
54              String fileName, String properties, Date modifiedDate,
55              String[] tagsEntries, File file)
56          throws PortalException, RemoteException, SystemException {
57  
58          getService().addFile(
59              companyId, portletId, groupId, repositoryId, fileName, properties,
60              modifiedDate, tagsEntries, file);
61      }
62  
63      public static void deleteDirectory(
64              long companyId, String portletId, long repositoryId, String dirName)
65          throws PortalException, RemoteException, 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, RemoteException, 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, RemoteException, 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, RemoteException, 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, RemoteException, 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, RemoteException, 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, RemoteException, 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)
128         throws RemoteException, SystemException {
129 
130         getService().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             String properties, Date modifiedDate, String[] tagsEntries,
137             byte[] bytes)
138         throws PortalException, RemoteException, SystemException {
139 
140         getService().updateFile(
141             companyId, portletId, groupId, repositoryId, fileName,
142             versionNumber, sourceFileName, properties, modifiedDate,
143             tagsEntries, bytes);
144     }
145 
146     public static void updateFile(
147             long companyId, String portletId, long groupId, long repositoryId,
148             String fileName, double versionNumber, String sourceFileName,
149             String properties, Date modifiedDate, String[] tagsEntries,
150             File file)
151         throws PortalException, RemoteException, SystemException {
152 
153         getService().updateFile(
154             companyId, portletId, groupId, repositoryId, fileName,
155             versionNumber, sourceFileName, properties, modifiedDate,
156             tagsEntries, file);
157     }
158 
159     public static void updateFile(
160             long companyId, String portletId, long groupId, long repositoryId,
161             long newRepositoryId, String fileName)
162         throws PortalException, RemoteException, SystemException {
163 
164         getService().updateFile(
165             companyId, portletId, groupId, repositoryId, newRepositoryId,
166             fileName);
167     }
168 
169     public void setService(DLService service) {
170         _service = service;
171     }
172 
173     private static DLService _service;
174 
175 }