1   /**
2    * Copyright (c) 2000-2007 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.rmi.RemoteException;
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, RemoteException, SystemException {
43  
44          DLService dlService = DLServiceFactory.getService();
45  
46          dlService.addDirectory(companyId, repositoryId, dirName);
47      }
48  
49      public static void addFile(
50              long companyId, String portletId, long groupId, long repositoryId,
51              String fileName, String properties, File file)
52          throws PortalException, RemoteException, SystemException {
53  
54          DLService dlService = DLServiceFactory.getService();
55  
56          dlService.addFile(
57              companyId, portletId, groupId, repositoryId, fileName, properties,
58              file);
59      }
60  
61      public static void addFile(
62              long companyId, String portletId, long groupId, long repositoryId,
63              String fileName, String properties, byte[] byteArray)
64          throws PortalException, RemoteException, SystemException {
65  
66          DLService dlService = DLServiceFactory.getService();
67  
68          dlService.addFile(
69              companyId, portletId, groupId, repositoryId, fileName, properties,
70              byteArray);
71      }
72  
73      public static void deleteDirectory(
74              long companyId, String portletId, long repositoryId, String dirName)
75          throws PortalException, RemoteException, SystemException {
76  
77          DLService dlService = DLServiceFactory.getService();
78  
79          dlService.deleteDirectory(companyId, portletId, repositoryId, dirName);
80      }
81  
82      public static void deleteFile(
83              long companyId, String portletId, long repositoryId,
84              String fileName)
85          throws PortalException, RemoteException, SystemException {
86  
87          DLService dlService = DLServiceFactory.getService();
88  
89          dlService.deleteFile(companyId, portletId, repositoryId, fileName);
90      }
91  
92      public static void deleteFile(
93              long companyId, String portletId, long repositoryId,
94              String fileName, double versionNumber)
95          throws PortalException, RemoteException, SystemException {
96  
97          DLService dlService = DLServiceFactory.getService();
98  
99          dlService.deleteFile(
100             companyId, portletId, repositoryId, fileName, versionNumber);
101     }
102 
103     public static byte[] getFile(
104             long companyId, long repositoryId, String fileName)
105         throws PortalException, RemoteException, SystemException {
106 
107         DLService dlService = DLServiceFactory.getService();
108 
109         return dlService.getFile(companyId, repositoryId, fileName);
110     }
111 
112     public static byte[] getFile(
113             long companyId, long repositoryId, String fileName,
114             double versionNumber)
115         throws PortalException, RemoteException, SystemException {
116 
117         DLService dlService = DLServiceFactory.getService();
118 
119         return dlService.getFile(
120             companyId, repositoryId, fileName, versionNumber);
121     }
122 
123     public static String[] getFileNames(
124             long companyId, long repositoryId, String dirName)
125         throws PortalException, RemoteException, SystemException {
126 
127         DLService dlService = DLServiceFactory.getService();
128 
129         return dlService.getFileNames(companyId, repositoryId, dirName);
130     }
131 
132     public static long getFileSize(
133             long companyId, long repositoryId, String fileName)
134         throws PortalException, RemoteException, SystemException {
135 
136         DLService dlService = DLServiceFactory.getService();
137 
138         return dlService.getFileSize(companyId, repositoryId, fileName);
139     }
140 
141     public static void reIndex(String[] ids)
142         throws PortalException, RemoteException, SystemException {
143 
144         DLService dlService = DLServiceFactory.getService();
145 
146         dlService.reIndex(ids);
147     }
148 
149     public static void updateFile(
150             long companyId, String portletId, long groupId, long repositoryId,
151             String fileName, double versionNumber, String sourceFileName,
152             String properties, File file)
153         throws PortalException, RemoteException, SystemException {
154 
155         DLService dlService = DLServiceFactory.getService();
156 
157         dlService.updateFile(
158             companyId, portletId, groupId, repositoryId, fileName,
159             versionNumber, sourceFileName, properties, file);
160     }
161 
162     public static void updateFile(
163             long companyId, String portletId, long groupId, long repositoryId,
164             String fileName, double versionNumber, String sourceFileName,
165             String properties, byte[] byteArray)
166         throws PortalException, RemoteException, SystemException {
167 
168         DLService dlService = DLServiceFactory.getService();
169 
170         dlService.updateFile(
171             companyId, portletId, groupId, repositoryId, fileName,
172             versionNumber, sourceFileName, properties, byteArray);
173     }
174 
175     public static void updateFile(
176             long companyId, String portletId, long groupId, long repositoryId,
177             long newRepositoryId, String fileName)
178         throws PortalException, RemoteException, SystemException {
179 
180         DLService dlService = DLServiceFactory.getService();
181 
182         dlService.updateFile(
183             companyId, portletId, groupId, repositoryId, newRepositoryId,
184             fileName);
185     }
186 
187 }