]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUrlStreamHandler.java
3 import java
.io
.IOException
;
4 import java
.io
.InputStream
;
6 import java
.net
.URLConnection
;
7 import java
.net
.URLStreamHandler
;
9 import javax
.jcr
.Binary
;
10 import javax
.jcr
.Item
;
11 import javax
.jcr
.Node
;
12 import javax
.jcr
.Property
;
13 import javax
.jcr
.PropertyType
;
14 import javax
.jcr
.RepositoryException
;
15 import javax
.jcr
.Session
;
16 import javax
.jcr
.nodetype
.NodeType
;
18 /** URL stream handler able to deal with nt:file node and properties. NOT FINISHED */
19 public class JcrUrlStreamHandler
extends URLStreamHandler
{
20 private final Session session
;
22 public JcrUrlStreamHandler(Session session
) {
23 this.session
= session
;
27 protected URLConnection
openConnection(final URL u
) throws IOException
{
28 // TODO Auto-generated method stub
29 return new URLConnection(u
) {
32 public void connect() throws IOException
{
33 String itemPath
= u
.getPath();
35 if (!session
.itemExists(itemPath
))
36 throw new IOException("No item under " + itemPath
);
38 Item item
= session
.getItem(u
.getPath());
40 // this should be a nt:file node
41 Node node
= (Node
) item
;
42 if (!node
.getPrimaryNodeType().isNodeType(
44 throw new IOException("Node " + node
+ " is not a "
48 Property property
= (Property
) item
;
49 if(property
.getType()==PropertyType
.BINARY
){
50 Binary binary
= property
.getBinary();
54 } catch (RepositoryException e
) {
55 IOException ioe
= new IOException(
56 "Unexpected JCR exception");
63 public InputStream
getInputStream() throws IOException
{
64 // TODO Auto-generated method stub
65 return super.getInputStream();