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  import com.liferay.portal.kernel.search.Hits;
21  import com.liferay.portal.kernel.util.MethodCache;
22  import com.liferay.portal.kernel.util.ReferenceRegistry;
23  
24  import java.io.File;
25  import java.io.InputStream;
26  
27  import java.util.Date;
28  
29  /**
30   * <a href="DLLocalServiceUtil.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Brian Wing Shun Chan
33   */
34  public class DLLocalServiceUtil {
35  
36      public static void addFile(
37              long companyId, String portletId, long groupId, long repositoryId,
38              String fileName, long fileEntryId, String properties,
39              Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
40              InputStream is)
41          throws PortalException, SystemException {
42  
43          getService().addFile(
44              companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
45              properties, modifiedDate, tagsCategories, tagsEntries, 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              double 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              ReferenceRegistry.registerReference(
74                  DLLocalServiceUtil.class, "_service");
75  
76              MethodCache.remove(DLLocalService.class);
77          }
78  
79          return _service;
80      }
81  
82      public static boolean hasFile(
83              long companyId, long repositoryId, String fileName,
84              double versionNumber)
85          throws PortalException, SystemException {
86  
87          return getService().hasFile(
88              companyId, repositoryId, fileName, versionNumber);
89      }
90  
91      public static void move(String srcDir, String destDir)
92          throws SystemException {
93  
94          getService().move(srcDir, destDir);
95      }
96  
97      public static Hits search(
98              long companyId, String portletId, long groupId,
99              long userId, long[] repositoryIds, String keywords, int start,
100             int end)
101         throws SystemException {
102 
103         return getService().search(
104             companyId, portletId, groupId, userId, repositoryIds, keywords,
105             start, end);
106     }
107 
108     public static void updateFile(
109             long companyId, String portletId, long groupId, long repositoryId,
110             String fileName, double versionNumber, String sourceFileName,
111             long fileEntryId, String properties, Date modifiedDate,
112             String[] tagsCategories, String[] tagsEntries, InputStream is)
113         throws PortalException, SystemException {
114 
115         getService().updateFile(
116             companyId, portletId, groupId, repositoryId, fileName,
117             versionNumber, sourceFileName, fileEntryId, properties,
118             modifiedDate, tagsCategories, tagsEntries, is);
119     }
120 
121     public static void validate(String fileName, File file)
122         throws PortalException, SystemException {
123 
124         getService().validate(fileName, file);
125     }
126 
127     public static void validate(String fileName, byte[] bytes)
128         throws PortalException, SystemException {
129 
130         getService().validate(fileName, bytes);
131     }
132 
133     public static void validate(String fileName, InputStream is)
134         throws PortalException, SystemException {
135 
136         getService().validate(fileName, is);
137     }
138 
139     public static void validate(
140             String fileName, String sourceFileName, InputStream is)
141         throws PortalException, SystemException {
142 
143         getService().validate(fileName, sourceFileName, is);
144     }
145 
146     public void setService(DLLocalService service) {
147         _service = service;
148 
149         ReferenceRegistry.registerReference(
150             DLLocalServiceUtil.class, "_service");
151 
152         MethodCache.remove(DLLocalService.class);
153     }
154 
155     private static DLLocalService _service;
156 
157 }