001
014
015 package com.liferay.portal.repository.liferayrepository;
016
017 import com.liferay.document.library.kernel.service.DLAppHelperLocalServiceUtil;
018 import com.liferay.portal.kernel.exception.PortalException;
019 import com.liferay.portal.kernel.repository.Repository;
020 import com.liferay.portal.kernel.repository.model.FileEntry;
021 import com.liferay.portal.kernel.service.ServiceContext;
022 import com.liferay.portal.repository.capabilities.WorkflowSupport;
023 import com.liferay.portal.repository.util.RepositoryWrapper;
024
025 import java.io.File;
026 import java.io.InputStream;
027
028
031 public class LiferayWorkflowRepositoryWrapper extends RepositoryWrapper {
032
033 public LiferayWorkflowRepositoryWrapper(
034 Repository repository, WorkflowSupport workflowSupport) {
035
036 super(repository);
037
038 _workflowSupport = workflowSupport;
039 }
040
041 @Override
042 public FileEntry addFileEntry(
043 long userId, long folderId, String sourceFileName, String mimeType,
044 String title, String description, String changeLog, File file,
045 ServiceContext serviceContext)
046 throws PortalException {
047
048 FileEntry fileEntry = super.addFileEntry(
049 userId, folderId, sourceFileName, mimeType, title, description,
050 changeLog, file, serviceContext);
051
052 DLAppHelperLocalServiceUtil.updateAsset(
053 userId, fileEntry, fileEntry.getFileVersion(),
054 serviceContext.getAssetCategoryIds(),
055 serviceContext.getAssetTagNames(),
056 serviceContext.getAssetLinkEntryIds());
057
058 _workflowSupport.addFileEntry(userId, fileEntry, serviceContext);
059
060 return fileEntry;
061 }
062
063 @Override
064 public FileEntry addFileEntry(
065 long userId, long folderId, String sourceFileName, String mimeType,
066 String title, String description, String changeLog, InputStream is,
067 long size, ServiceContext serviceContext)
068 throws PortalException {
069
070 FileEntry fileEntry = super.addFileEntry(
071 userId, folderId, sourceFileName, mimeType, title, description,
072 changeLog, is, size, serviceContext);
073
074 DLAppHelperLocalServiceUtil.updateAsset(
075 userId, fileEntry, fileEntry.getFileVersion(),
076 serviceContext.getAssetCategoryIds(),
077 serviceContext.getAssetTagNames(),
078 serviceContext.getAssetLinkEntryIds());
079
080 _workflowSupport.addFileEntry(userId, fileEntry, serviceContext);
081
082 return fileEntry;
083 }
084
085 @Override
086 public void checkInFileEntry(
087 long userId, long fileEntryId, boolean majorVersion,
088 String changeLog, ServiceContext serviceContext)
089 throws PortalException {
090
091 super.checkInFileEntry(
092 userId, fileEntryId, majorVersion, changeLog, serviceContext);
093
094 FileEntry fileEntry = super.getFileEntry(fileEntryId);
095
096 _workflowSupport.checkInFileEntry(
097 userId, fileEntry, majorVersion, serviceContext);
098 }
099
100 @Override
101 public void checkInFileEntry(
102 long userId, long fileEntryId, String lockUuid,
103 ServiceContext serviceContext)
104 throws PortalException {
105
106 super.checkInFileEntry(userId, fileEntryId, lockUuid, serviceContext);
107
108 FileEntry fileEntry = super.getFileEntry(fileEntryId);
109
110 _workflowSupport.checkInFileEntry(
111 userId, fileEntry, false, serviceContext);
112 }
113
114 @Override
115 public FileEntry copyFileEntry(
116 long userId, long groupId, long fileEntryId, long destFolderId,
117 ServiceContext serviceContext)
118 throws PortalException {
119
120 FileEntry fileEntry = super.copyFileEntry(
121 userId, groupId, fileEntryId, destFolderId, serviceContext);
122
123 DLAppHelperLocalServiceUtil.updateAsset(
124 userId, fileEntry, fileEntry.getFileVersion(),
125 serviceContext.getAssetCategoryIds(),
126 serviceContext.getAssetTagNames(),
127 serviceContext.getAssetLinkEntryIds());
128
129 _workflowSupport.addFileEntry(userId, fileEntry, serviceContext);
130
131 return fileEntry;
132 }
133
134 @Override
135 public void revertFileEntry(
136 long userId, long fileEntryId, String version,
137 ServiceContext serviceContext)
138 throws PortalException {
139
140 super.revertFileEntry(userId, fileEntryId, version, serviceContext);
141
142 FileEntry fileEntry = super.getFileEntry(fileEntryId);
143
144 _workflowSupport.revertFileEntry(userId, fileEntry, serviceContext);
145 }
146
147 @Override
148 public FileEntry updateFileEntry(
149 long userId, long fileEntryId, String sourceFileName,
150 String mimeType, String title, String description, String changeLog,
151 boolean majorVersion, File file, ServiceContext serviceContext)
152 throws PortalException {
153
154 FileEntry fileEntry = super.updateFileEntry(
155 userId, fileEntryId, sourceFileName, mimeType, title, description,
156 changeLog, majorVersion, file, serviceContext);
157
158 _workflowSupport.updateFileEntry(
159 userId, fileEntry, majorVersion, serviceContext);
160
161 return super.getFileEntry(fileEntryId);
162 }
163
164 @Override
165 public FileEntry updateFileEntry(
166 long userId, long fileEntryId, String sourceFileName,
167 String mimeType, String title, String description, String changeLog,
168 boolean majorVersion, InputStream is, long size,
169 ServiceContext serviceContext)
170 throws PortalException {
171
172 FileEntry fileEntry = super.updateFileEntry(
173 userId, fileEntryId, sourceFileName, mimeType, title, description,
174 changeLog, majorVersion, is, size, serviceContext);
175
176 _workflowSupport.updateFileEntry(
177 userId, fileEntry, majorVersion, serviceContext);
178
179 return super.getFileEntry(fileEntryId);
180 }
181
182 private final WorkflowSupport _workflowSupport;
183
184 }