]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.jcr/src/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
;
10 import javax
.jcr
.Node
;
11 import javax
.jcr
.Property
;
12 import javax
.jcr
.PropertyType
;
13 import javax
.jcr
.RepositoryException
;
14 import javax
.jcr
.Session
;
15 import javax
.jcr
.nodetype
.NodeType
;
17 /** URL stream handler able to deal with nt:file node and properties. NOT FINISHED */
18 public class JcrUrlStreamHandler
extends URLStreamHandler
{
19 private final Session session
;
21 public JcrUrlStreamHandler(Session session
) {
22 this.session
= session
;
26 protected URLConnection
openConnection(final URL u
) throws IOException
{
27 // TODO Auto-generated method stub
28 return new URLConnection(u
) {
31 public void connect() throws IOException
{
32 String itemPath
= u
.getPath();
34 if (!session
.itemExists(itemPath
))
35 throw new IOException("No item under " + itemPath
);
37 Item item
= session
.getItem(u
.getPath());
39 // this should be a nt:file node
40 Node node
= (Node
) item
;
41 if (!node
.getPrimaryNodeType().isNodeType(
43 throw new IOException("Node " + node
+ " is not a "
47 Property property
= (Property
) item
;
48 if(property
.getType()==PropertyType
.BINARY
){
49 //Binary binary = property.getBinary();
53 } catch (RepositoryException e
) {
54 IOException ioe
= new IOException(
55 "Unexpected JCR exception");
62 public InputStream
getInputStream() throws IOException
{
63 // TODO Auto-generated method stub
64 return super.getInputStream();