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