1
22
23 package com.liferay.documentlibrary.service.impl;
24
25 import com.liferay.documentlibrary.DirectoryNameException;
26 import com.liferay.documentlibrary.service.DLLocalService;
27 import com.liferay.documentlibrary.service.DLService;
28 import com.liferay.documentlibrary.util.Hook;
29 import com.liferay.documentlibrary.util.HookFactory;
30 import com.liferay.documentlibrary.util.Indexer;
31 import com.liferay.portal.PortalException;
32 import com.liferay.portal.SystemException;
33 import com.liferay.portal.kernel.annotation.BeanReference;
34 import com.liferay.portal.kernel.search.SearchException;
35
36 import java.io.File;
37
38 import java.util.Date;
39
40
47 public class DLServiceImpl implements DLService {
48
49 public static final String GROUP_NAME = DLServiceImpl.class.getName();
50
51 public static final String[] GROUP_NAME_ARRAY = new String[] { GROUP_NAME };
52
53 public static final String VERSION = "_VERSION_";
54
55 public void addDirectory(long companyId, long repositoryId, String dirName)
56 throws PortalException, SystemException {
57
58 if ((dirName == null || dirName.equals("/")) ||
59 (dirName.indexOf("\\\\") != -1) ||
60 (dirName.indexOf("//") != -1) ||
61 (dirName.indexOf(":") != -1) ||
62 (dirName.indexOf("*") != -1) ||
63 (dirName.indexOf("?") != -1) ||
64 (dirName.indexOf("\"") != -1) ||
65 (dirName.indexOf("<") != -1) ||
66 (dirName.indexOf(">") != -1) ||
67 (dirName.indexOf("|") != -1) ||
68 (dirName.indexOf("&") != -1) ||
69 (dirName.indexOf("[") != -1) ||
70 (dirName.indexOf("]") != -1) ||
71 (dirName.indexOf("'") != -1)) {
72
73 throw new DirectoryNameException(dirName);
74 }
75
76 Hook hook = HookFactory.getInstance();
77
78 hook.addDirectory(companyId, repositoryId, dirName);
79 }
80
81 public void addFile(
82 long companyId, String portletId, long groupId, long repositoryId,
83 String fileName, long fileEntryId, String properties,
84 Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
85 File file)
86 throws PortalException, SystemException {
87
88 dlLocalService.validate(fileName, file);
89
90 Hook hook = HookFactory.getInstance();
91
92 hook.addFile(
93 companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
94 properties, modifiedDate, tagsCategories, tagsEntries, file);
95 }
96
97 public void addFile(
98 long companyId, String portletId, long groupId, long repositoryId,
99 String fileName, long fileEntryId, String properties,
100 Date modifiedDate, String[] tagsCategories, String[] tagsEntries,
101 byte[] bytes)
102 throws PortalException, SystemException {
103
104 dlLocalService.validate(fileName, bytes);
105
106 Hook hook = HookFactory.getInstance();
107
108 hook.addFile(
109 companyId, portletId, groupId, repositoryId, fileName, fileEntryId,
110 properties, modifiedDate, tagsCategories, tagsEntries, bytes);
111 }
112
113 public void deleteDirectory(
114 long companyId, String portletId, long repositoryId, String dirName)
115 throws PortalException, SystemException {
116
117 Hook hook = HookFactory.getInstance();
118
119 hook.deleteDirectory(companyId, portletId, repositoryId, dirName);
120 }
121
122 public void deleteFile(
123 long companyId, String portletId, long repositoryId,
124 String fileName)
125 throws PortalException, SystemException {
126
127 Hook hook = HookFactory.getInstance();
128
129 hook.deleteFile(companyId, portletId, repositoryId, fileName);
130 }
131
132 public void deleteFile(
133 long companyId, String portletId, long repositoryId,
134 String fileName, double versionNumber)
135 throws PortalException, SystemException {
136
137 Hook hook = HookFactory.getInstance();
138
139 hook.deleteFile(
140 companyId, portletId, repositoryId, fileName, versionNumber);
141 }
142
143 public byte[] getFile(long companyId, long repositoryId, String fileName)
144 throws PortalException, SystemException {
145
146 Hook hook = HookFactory.getInstance();
147
148 return hook.getFile(companyId, repositoryId, fileName);
149 }
150
151 public byte[] getFile(
152 long companyId, long repositoryId, String fileName,
153 double versionNumber)
154 throws PortalException, SystemException {
155
156 Hook hook = HookFactory.getInstance();
157
158 return hook.getFile(companyId, repositoryId, fileName, versionNumber);
159 }
160
161 public String[] getFileNames(
162 long companyId, long repositoryId, String dirName)
163 throws PortalException, SystemException {
164
165 Hook hook = HookFactory.getInstance();
166
167 return hook.getFileNames(companyId, repositoryId, dirName);
168 }
169
170 public long getFileSize(
171 long companyId, long repositoryId, String fileName)
172 throws PortalException, SystemException {
173
174 Hook hook = HookFactory.getInstance();
175
176 return hook.getFileSize(companyId, repositoryId, fileName);
177 }
178
179 public void reIndex(String[] ids) throws SystemException {
180 try {
181 Indexer indexer = new Indexer();
182
183 indexer.reIndex(ids);
184 }
185 catch (SearchException se) {
186 throw new SystemException(se);
187 }
188 }
189
190 public void updateFile(
191 long companyId, String portletId, long groupId, long repositoryId,
192 String fileName, double versionNumber, String sourceFileName,
193 long fileEntryId, String properties, Date modifiedDate,
194 String[] tagsCategories, String[] tagsEntries, File file)
195 throws PortalException, SystemException {
196
197 dlLocalService.validate(fileName, file);
198
199 Hook hook = HookFactory.getInstance();
200
201 hook.updateFile(
202 companyId, portletId, groupId, repositoryId, fileName,
203 versionNumber, sourceFileName, fileEntryId, properties,
204 modifiedDate, tagsCategories, tagsEntries, file);
205 }
206
207 public void updateFile(
208 long companyId, String portletId, long groupId, long repositoryId,
209 String fileName, double versionNumber, String sourceFileName,
210 long fileEntryId, String properties, Date modifiedDate,
211 String[] tagsCategories, String[] tagsEntries, byte[] bytes)
212 throws PortalException, SystemException {
213
214 dlLocalService.validate(fileName, bytes);
215
216 Hook hook = HookFactory.getInstance();
217
218 hook.updateFile(
219 companyId, portletId, groupId, repositoryId, fileName,
220 versionNumber, sourceFileName, fileEntryId, properties,
221 modifiedDate, tagsCategories, tagsEntries, bytes);
222 }
223
224 public void updateFile(
225 long companyId, String portletId, long groupId, long repositoryId,
226 long newRepositoryId, String fileName, long fileEntryId)
227 throws PortalException, SystemException {
228
229 Hook hook = HookFactory.getInstance();
230
231 hook.updateFile(
232 companyId, portletId, groupId, repositoryId, newRepositoryId,
233 fileName, fileEntryId);
234 }
235
236 @BeanReference(name = _DL_LOCAL_SERVICE)
237 protected DLLocalService dlLocalService;
238
239 private static final String _DL_LOCAL_SERVICE =
240 "com.liferay.documentlibrary.service.DLLocalService.impl";
241
242 }