2 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
\r
4 * This library is free software; you can redistribute it and/or modify it under
\r
5 * the terms of the GNU Lesser General Public License as published by the Free
\r
6 * Software Foundation; either version 2.1 of the License, or (at your option)
\r
9 * This library is distributed in the hope that it will be useful, but WITHOUT
\r
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
\r
15 package com.liferay.portlet.documentlibrary.store;
\r
17 import com.liferay.portal.kernel.bean.PortalBeanLocatorUtil;
\r
18 import com.liferay.portal.kernel.exception.SystemException;
\r
19 import com.liferay.portal.kernel.search.Hits;
\r
20 import com.liferay.portal.kernel.util.MethodCache;
\r
21 import com.liferay.portal.kernel.util.ReferenceRegistry;
\r
22 import com.liferay.portal.model.CompanyConstants;
\r
25 * Provides methods for storing files in the portal. The file storage
\r
26 * implementation can be selected in <code>portal.properties</code> under the
\r
27 * property <code>dl.store.impl</code>. Virus checking can also be enabled under
\r
28 * the property <code>dl.store.antivirus.impl</code>.
\r
31 * The main client for this class is the Document Library portlet. It is also
\r
32 * used by other portlets like Wiki and Message Boards to store file
\r
33 * attachments. For the Document Library portlet, the <code>repositoryId</code>
\r
34 * can be obtained by calling {@link
\r
35 * com.liferay.portlet.documentlibrary.model.DLFolderConstants#getDataRepositoryId(
\r
36 * long,long)}. For all other portlets, the <code>repositoryId</code> should be
\r
37 * set to {@link CompanyConstants#SYSTEM}. These methods can be used in plugins
\r
38 * and other portlets, as shown below.
\r
43 * long repositoryId = CompanyConstants.SYSTEM;
\r
44 * String dirName = "portlet_name/1234";
\r
47 * DLStoreUtil.addDirectory(companyId, repositoryId, dirName);
\r
49 * catch (DuplicateDirectoryException dde) {
\r
52 * DLStoreUtil.addFile(
\r
53 * companyId, repositoryId, dirName + "/" + fileName, file);
\r
57 * @author Brian Wing Shun Chan
\r
58 * @author Alexander Chow
\r
59 * @author Edward Han
\r
62 public class CustomDLStoreUtil extends DLStoreUtil{
\r
64 public static Hits search(
\r
65 long companyId, long userId, String portletId, long groupId,
\r
66 long[] repositoryIds, String keywords, int start, int end)
\r
67 throws SystemException {
\r
69 return getService().search(companyId, userId, portletId, groupId, repositoryIds, keywords, start, end);
\r
72 public static Hits searchByDate(
\r
73 long companyId, String portletId, long groupId,
\r
74 long userId, long[] repositoryIds, String keywords, int start,
\r
75 int end) throws SystemException {
\r
77 return getService().searchByDate(companyId, portletId, groupId, userId, repositoryIds, keywords, start, end);
\r
81 * Returns the {@link DLStore} object. Used primarily by Spring and should
\r
82 * not be used by the client.
\r
84 * @return Returns the {@link DLStore} object
\r
86 public static CustomDLStore getService() {
\r
87 if (_service == null) {
\r
88 _service = (CustomDLStore)PortalBeanLocatorUtil.locate(
\r
89 CustomDLStore.class.getName());
\r
91 ReferenceRegistry.registerReference(DLStoreUtil.class, "_service");
\r
93 MethodCache.remove(CustomDLStore.class);
\r
100 * Set's the {@link DLStore} object. Used primarily by Spring and should not
\r
101 * be used by the client.
\r
103 * @param store the {@link DLStore} object
\r
105 public void setService(CustomDLStore service) {
\r
106 _service = service;
\r
108 ReferenceRegistry.registerReference(CustomDLStoreUtil.class, "_service");
\r
110 MethodCache.remove(CustomDLStore.class);
\r
113 private static CustomDLStore _service;
\r