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