Fix file download on the JCR explorer for stable branch. This mechanism is commented...
[lgpl/argeo-commons.git] / base / runtime / org.argeo.eclipse.ui.jcr / src / main / java / org / argeo / eclipse / ui / jcr / utils / JcrFileProvider.java
index 5a0854e60e4ef0c7a3409396bcc0bf1a39a910c9..47cab6d6affd5279ae4d09196c0cc9087a4d914a 100644 (file)
@@ -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) {