001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.documentlibrary.service.impl;
022:
023: import com.liferay.documentlibrary.DirectoryNameException;
024: import com.liferay.documentlibrary.service.DLLocalServiceUtil;
025: import com.liferay.documentlibrary.service.DLService;
026: import com.liferay.documentlibrary.util.Hook;
027: import com.liferay.documentlibrary.util.HookFactory;
028: import com.liferay.documentlibrary.util.Indexer;
029: import com.liferay.portal.PortalException;
030: import com.liferay.portal.SystemException;
031: import com.liferay.portal.kernel.search.SearchException;
032:
033: import java.io.File;
034:
035: /**
036: * <a href="DLServiceImpl.java.html"><b><i>View Source</i></b></a>
037: *
038: * @author Brian Wing Shun Chan
039: * @author Michael Young
040: *
041: */
042: public class DLServiceImpl implements DLService {
043:
044: public static final String GROUP_NAME = DLServiceImpl.class
045: .getName();
046:
047: public static final String[] GROUP_NAME_ARRAY = new String[] { GROUP_NAME };
048:
049: public static final String VERSION = "_VERSION_";
050:
051: public void addDirectory(long companyId, long repositoryId,
052: String dirName) throws PortalException, SystemException {
053:
054: if ((dirName == null || dirName.equals("/"))
055: || (dirName.indexOf("\\\\") != -1)
056: || (dirName.indexOf("//") != -1)
057: || (dirName.indexOf(":") != -1)
058: || (dirName.indexOf("*") != -1)
059: || (dirName.indexOf("?") != -1)
060: || (dirName.indexOf("\"") != -1)
061: || (dirName.indexOf("<") != -1)
062: || (dirName.indexOf(">") != -1)
063: || (dirName.indexOf("|") != -1)
064: || (dirName.indexOf("&") != -1)
065: || (dirName.indexOf("[") != -1)
066: || (dirName.indexOf("]") != -1)
067: || (dirName.indexOf("'") != -1)) {
068:
069: throw new DirectoryNameException(dirName);
070: }
071:
072: Hook hook = HookFactory.getInstance();
073:
074: hook.addDirectory(companyId, repositoryId, dirName);
075: }
076:
077: public void addFile(long companyId, String portletId, long groupId,
078: long repositoryId, String fileName, String properties,
079: String[] tagsEntries, File file) throws PortalException,
080: SystemException {
081:
082: DLLocalServiceUtil.validate(fileName, file);
083:
084: Hook hook = HookFactory.getInstance();
085:
086: hook.addFile(companyId, portletId, groupId, repositoryId,
087: fileName, properties, tagsEntries, file);
088: }
089:
090: public void addFile(long companyId, String portletId, long groupId,
091: long repositoryId, String fileName, String properties,
092: String[] tagsEntries, byte[] byteArray)
093: throws PortalException, SystemException {
094:
095: DLLocalServiceUtil.validate(fileName, byteArray);
096:
097: Hook hook = HookFactory.getInstance();
098:
099: hook.addFile(companyId, portletId, groupId, repositoryId,
100: fileName, properties, tagsEntries, byteArray);
101: }
102:
103: public void deleteDirectory(long companyId, String portletId,
104: long repositoryId, String dirName) throws PortalException,
105: SystemException {
106:
107: Hook hook = HookFactory.getInstance();
108:
109: hook.deleteDirectory(companyId, portletId, repositoryId,
110: dirName);
111: }
112:
113: public void deleteFile(long companyId, String portletId,
114: long repositoryId, String fileName) throws PortalException,
115: SystemException {
116:
117: Hook hook = HookFactory.getInstance();
118:
119: hook.deleteFile(companyId, portletId, repositoryId, fileName);
120: }
121:
122: public void deleteFile(long companyId, String portletId,
123: long repositoryId, String fileName, double versionNumber)
124: throws PortalException, SystemException {
125:
126: Hook hook = HookFactory.getInstance();
127:
128: hook.deleteFile(companyId, portletId, repositoryId, fileName,
129: versionNumber);
130: }
131:
132: public byte[] getFile(long companyId, long repositoryId,
133: String fileName) throws PortalException, SystemException {
134:
135: Hook hook = HookFactory.getInstance();
136:
137: return hook.getFile(companyId, repositoryId, fileName);
138: }
139:
140: public byte[] getFile(long companyId, long repositoryId,
141: String fileName, double versionNumber)
142: throws PortalException, SystemException {
143:
144: Hook hook = HookFactory.getInstance();
145:
146: return hook.getFile(companyId, repositoryId, fileName,
147: versionNumber);
148: }
149:
150: public String[] getFileNames(long companyId, long repositoryId,
151: String dirName) throws PortalException, SystemException {
152:
153: Hook hook = HookFactory.getInstance();
154:
155: return hook.getFileNames(companyId, repositoryId, dirName);
156: }
157:
158: public long getFileSize(long companyId, long repositoryId,
159: String fileName) throws PortalException, SystemException {
160:
161: Hook hook = HookFactory.getInstance();
162:
163: return hook.getFileSize(companyId, repositoryId, fileName);
164: }
165:
166: public void reIndex(String[] ids) throws SystemException {
167: try {
168: Indexer indexer = new Indexer();
169:
170: indexer.reIndex(ids);
171: } catch (SearchException se) {
172: throw new SystemException(se);
173: }
174: }
175:
176: public void updateFile(long companyId, String portletId,
177: long groupId, long repositoryId, String fileName,
178: double versionNumber, String sourceFileName,
179: String properties, String[] tagsEntries, File file)
180: throws PortalException, SystemException {
181:
182: DLLocalServiceUtil.validate(fileName, file);
183:
184: Hook hook = HookFactory.getInstance();
185:
186: hook.updateFile(companyId, portletId, groupId, repositoryId,
187: fileName, versionNumber, sourceFileName, properties,
188: tagsEntries, file);
189: }
190:
191: public void updateFile(long companyId, String portletId,
192: long groupId, long repositoryId, String fileName,
193: double versionNumber, String sourceFileName,
194: String properties, String[] tagsEntries, byte[] byteArray)
195: throws PortalException, SystemException {
196:
197: DLLocalServiceUtil.validate(fileName, byteArray);
198:
199: Hook hook = HookFactory.getInstance();
200:
201: hook.updateFile(companyId, portletId, groupId, repositoryId,
202: fileName, versionNumber, sourceFileName, properties,
203: tagsEntries, byteArray);
204: }
205:
206: public void updateFile(long companyId, String portletId,
207: long groupId, long repositoryId, long newRepositoryId,
208: String fileName) throws PortalException, SystemException {
209:
210: Hook hook = HookFactory.getInstance();
211:
212: hook.updateFile(companyId, portletId, groupId, repositoryId,
213: newRepositoryId, fileName);
214: }
215:
216: }
|