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