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