solved issue on specific version download

This commit is contained in:
Lucio Lelii 2021-07-26 16:07:40 +02:00
parent cb609cf51c
commit f68588e05c
3 changed files with 11 additions and 7 deletions

View File

@ -116,11 +116,12 @@ public class TrashHandler {
for (Version version: versions) {
try {
Content content = node2Item.getContent(version);
Content content = node2Item.getContentFromVersion(version);
if (content!= null && content.getStorageId()!=null)
contentSet.add(new ContentPair(content, manager.getStorageBackend()));
else log.warn("invalid version {}",version.getName());
}catch (Throwable t) {
log.warn("error retrieving version {}",version.getName(),t);
log.warn("error retrieving version content for {}",version.getName(),t);
}
}
}catch (Exception e) {

View File

@ -23,6 +23,7 @@ import javax.jcr.PropertyType;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.Value;
import javax.jcr.version.Version;
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.util.Text;
@ -77,9 +78,9 @@ public class Node2ItemConverter {
return item;
}
public Content getContent(Node node) throws RepositoryException, BackendGenericError{
public Content getContentFromVersion(Version node) throws RepositoryException, BackendGenericError{
Content content = new Content();
setGenericFields(node, Content.class, null, content);
setGenericFields(node.getFrozenNode(), Content.class, null, content);
return content;
}

View File

@ -702,11 +702,13 @@ public class ItemsManager extends Impersonable{
for (Version version: jcrVersions) {
log.debug("retrieved version id {}, name {}", version.getIdentifier(), version.getName());
if (version.getName().equals(versionName)) {
Content content = node2Item.getContent(version);
Content content = node2Item.getContentFromVersion(version);
FolderManager folderManager = folderPluginHandler.getFolderManager((AbstractFileItem) currentItem);
final InputStream streamToWrite = folderManager.getStorageBackend().download(content);
log.debug("retrieved storage id is {} with storageBackend {} (stream is null? {})",content.getStorageId(), folderManager.getStorageBackend().getClass().getSimpleName(), streamToWrite==null );
String oldfilename = FilenameUtils.getBaseName(currentItem.getTitle());
String ext = FilenameUtils.getExtension(currentItem.getTitle());