From e0bd01316e348b9b3d1fcab627f8cd7c72a0a467 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Mon, 24 Feb 2014 14:48:33 +0000 Subject: [PATCH] Fix file download on the JCR explorer for stable branch. This mechanism is commented out in commens 2.x. See tickets https://www.argeo.org/bugzilla/show_bug.cgi?id=188 and https://www.argeo.org/bugzilla/show_bug.cgi?id=209 git-svn-id: https://svn.argeo.org/commons/trunk@6849 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../eclipse/ui/jcr/utils/JcrFileProvider.java | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/base/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/utils/JcrFileProvider.java b/base/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/utils/JcrFileProvider.java index 5a0854e60..47cab6d6a 100644 --- a/base/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/utils/JcrFileProvider.java +++ b/base/runtime/org.argeo.eclipse.ui.jcr/src/main/java/org/argeo/eclipse/ui/jcr/utils/JcrFileProvider.java @@ -149,19 +149,27 @@ public class JcrFileProvider implements FileProvider { if (result == null) throw new ArgeoException("File node not found for ID" + fileId); - // Ensure that the node have the correct type. - if (!result.isNodeType(NodeType.NT_FILE)) + Node child = null; + + boolean isValid = true; + if (!result.isNodeType(NodeType.NT_FILE)) + // useless: mandatory child node + // || !result.hasNode(Property.JCR_CONTENT)) + isValid = false; + else { + child = result.getNode(Property.JCR_CONTENT); + if (!(child.isNodeType(NodeType.NT_RESOURCE) || child + .hasProperty(Property.JCR_DATA))) + isValid = false; + } + + if (!isValid) throw new ArgeoException( - "Cannot open file children Node that are not of '" - + NodeType.NT_RESOURCE + "' type."); - - // Get the usefull part of the Node - Node child = result.getNodes().nextNode(); - if (child == null || !child.isNodeType(NodeType.NT_RESOURCE)) - throw new ArgeoException( - "ERROR: IN the current implemented model, '" + "ERROR: In the current implemented model, '" + NodeType.NT_FILE - + "' file node must have one and only one child of the nt:ressource, where actual data is stored"); + + "' file node must have a child node named jcr:content " + + "that has a BINARY Property named jcr:data " + + "where the actual data is stored"); return child; } catch (RepositoryException re) { -- 2.30.2