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  import com.liferay.portal.kernel.search.Hits;
28  
29  import java.io.File;
30  import java.io.InputStream;
31  
32  /**
33   * <a href="DLLocalServiceUtil.java.html"><b><i>View Source</i></b></a>
34   *
35   * @author Brian Wing Shun Chan
36   *
37   */
38  public class DLLocalServiceUtil {
39  
40      public static void addFile(
41              long companyId, String portletId, long groupId, long repositoryId,
42              String fileName, String properties, InputStream is)
43          throws PortalException, SystemException {
44  
45          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
46  
47          dlLocalService.addFile(
48              companyId, portletId, groupId, repositoryId, fileName, properties,
49              is);
50      }
51  
52      public static void checkRoot(long companyId) throws SystemException {
53          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
54  
55          dlLocalService.checkRoot(companyId);
56      }
57  
58      public static InputStream getFileAsStream(
59              long companyId, long repositoryId, String fileName)
60          throws PortalException, SystemException {
61  
62          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
63  
64          return dlLocalService.getFileAsStream(
65              companyId, repositoryId, fileName);
66      }
67  
68      public static InputStream getFileAsStream(
69              long companyId, long repositoryId, String fileName,
70              double versionNumber)
71          throws PortalException, SystemException {
72  
73          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
74  
75          return dlLocalService.getFileAsStream(
76              companyId, repositoryId, fileName, versionNumber);
77      }
78  
79      public static boolean hasFile(
80              long companyId, long repositoryId, String fileName,
81              double versionNumber)
82          throws PortalException, SystemException {
83  
84          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
85  
86          return dlLocalService.hasFile(
87              companyId, repositoryId, fileName, versionNumber);
88      }
89  
90      public static void move(String srcDir, String destDir)
91          throws SystemException {
92  
93          DLLocalService dlLocalService = DLLocalServiceFactory.getService();
94  
95          dlLocalService.move(srcDir, destDir);
96      }
97  
98      public static Hits search(
99              long companyId, String portletId, long groupId,
100             long[] repositoryIds, String keywords)
101         throws SystemException {
102 
103         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
104 
105         return dlLocalService.search(
106             companyId, portletId, groupId, repositoryIds, keywords);
107     }
108 
109     public static void updateFile(
110             long companyId, String portletId, long groupId, long repositoryId,
111             String fileName, double versionNumber, String sourceFileName,
112             String properties, InputStream is)
113         throws PortalException, SystemException {
114 
115         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
116 
117         dlLocalService.updateFile(
118             companyId, portletId, groupId, repositoryId, fileName,
119             versionNumber, sourceFileName, properties, is);
120     }
121 
122     public static void validate(String fileName, File file)
123         throws PortalException {
124 
125         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
126 
127         dlLocalService.validate(fileName, file);
128     }
129 
130     public static void validate(String fileName, byte[] byteArray)
131         throws PortalException {
132 
133         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
134 
135         dlLocalService.validate(fileName, byteArray);
136     }
137 
138     public static void validate(String fileName, InputStream is)
139         throws PortalException {
140 
141         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
142 
143         dlLocalService.validate(fileName, is);
144     }
145 
146     public static void validate(
147             String fileName, String sourceFileName, InputStream is)
148         throws PortalException {
149 
150         DLLocalService dlLocalService = DLLocalServiceFactory.getService();
151 
152         dlLocalService.validate(fileName, sourceFileName, is);
153     }
154 
155 }