[Bedework-commit] caldavimpl r28 - trunk/bwcaldav/src/org/bedework/caldav/bwserver

svnadmin at bedework.org svnadmin at bedework.org
Mon Mar 15 00:22:13 EDT 2010


Author: douglm
Date: 2010-03-15 00:22:12 -0400 (Mon, 15 Mar 2010)
New Revision: 28

Modified:
   trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwCalDAVResource.java
Log:
1. Unprefix principal urls in getPrincipal method for AccessUtil

2. Changed type of content length from int to long - affects nodes and interfaces. Needed for resources.
    Also means a schema change, stored length needs to be a bigint rather than int. Also content must be stored as a blob.
    Schema was broken anyway, resources limited to 255 bytes. Not being used other than by tests so schema change should be OK.

3. CalDavBwIntf canPut method needs to take account of resource nodes.

4. Null changes to CalDAVCalNode, CalDavComponentNode - finals and @override

5. For resources use streams rather than byte arrays. Avoids copying.


Modified: trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwCalDAVResource.java
===================================================================
--- trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwCalDAVResource.java	2010-03-15 04:21:34 UTC (rev 27)
+++ trunk/bwcaldav/src/org/bedework/caldav/bwserver/BwCalDAVResource.java	2010-03-15 04:22:12 UTC (rev 28)
@@ -33,6 +33,9 @@
 import edu.rpi.cct.webdav.servlet.shared.WebdavException;
 import edu.rpi.cmt.access.AccessPrincipal;
 
+import java.io.InputStream;
+import java.sql.Blob;
+
 /**
  *
  * @author douglm
@@ -48,7 +51,7 @@
    * @param rsrc
    * @throws WebdavException
    */
-  BwCalDAVResource(BwSysIntfImpl intf, BwResource rsrc) throws WebdavException {
+  BwCalDAVResource(final BwSysIntfImpl intf, final BwResource rsrc) throws WebdavException {
     this.intf = intf;
     this.rsrc = rsrc;
   }
@@ -60,6 +63,7 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdEntity#isAlias()
    */
+  @Override
   public boolean isAlias() throws WebdavException {
     return false;
   }
@@ -67,6 +71,7 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdEntity#getAliasTarget()
    */
+  @Override
   public WdEntity getAliasTarget() throws WebdavException {
     return this;
   }
@@ -74,11 +79,13 @@
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.CalDAVEvent#getNewEvent()
    */
+  @Override
   public boolean isNew() throws WebdavException {
     return getRsrc().unsaved();
   }
 
-  public void setBinaryContent(byte[] val) throws WebdavException {
+  @Override
+  public void setBinaryContent(final InputStream val) throws WebdavException {
     BwResource r = getRsrc();
 
     BwResourceContent rc = r.getContent();
@@ -95,14 +102,19 @@
       }
     }
 
-    rc.setValue(val);
-    r.setContentLength(val.length);
+    try {
+      rc.setContent(val);
+      r.setContentLength(rc.getValue().length());
+    } catch (Throwable t) {
+      throw new WebdavException(t);
+    }
   }
 
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.CalDAVResource#getBinaryContent()
    */
-  public byte[] getBinaryContent() throws WebdavException {
+  @Override
+  public InputStream getBinaryContent() throws WebdavException {
     if (rsrc == null) {
       return null;
     }
@@ -111,13 +123,30 @@
       intf.getFileContent(this);
     }
 
-    return rsrc.getContent().getValue();
+    BwResourceContent bwrc = rsrc.getContent();
+
+    if (bwrc == null) {
+      return null;
+    }
+
+    Blob b = bwrc.getValue();
+
+    if (b == null) {
+      return null;
+    }
+
+    try {
+      return b.getBinaryStream();
+    } catch (Throwable t) {
+      throw new WebdavException(t);
+    }
   }
 
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.CalDAVResource#getContentLen()
    */
-  public int getContentLen() throws WebdavException {
+  @Override
+  public long getContentLen() throws WebdavException {
     if (rsrc == null) {
       return 0;
     }
@@ -128,13 +157,15 @@
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.CalDAVResource#setContentType(java.lang.String)
    */
-  public void setContentType(String val) throws WebdavException {
+  @Override
+  public void setContentType(final String val) throws WebdavException {
     getRsrc().setContentType(val);
   }
 
   /* (non-Javadoc)
    * @see org.bedework.caldav.server.CalDAVResource#getContentType()
    */
+  @Override
   public String getContentType() throws WebdavException {
     if (rsrc == null) {
       return null;
@@ -150,13 +181,15 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#setName(java.lang.String)
    */
-  public void setName(String val) throws WebdavException {
+  @Override
+  public void setName(final String val) throws WebdavException {
     getRsrc().setName(val);
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#getName()
    */
+  @Override
   public String getName() throws WebdavException {
     return getRsrc().getName();
   }
@@ -164,13 +197,15 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#setDisplayName(java.lang.String)
    */
-  public void setDisplayName(String val) throws WebdavException {
+  @Override
+  public void setDisplayName(final String val) throws WebdavException {
     // No display name
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdEntity#getDisplayName()
    */
+  @Override
   public String getDisplayName() throws WebdavException {
     return getRsrc().getName();
   }
@@ -178,13 +213,15 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#setPath(java.lang.String)
    */
-  public void setPath(String val) throws WebdavException {
+  @Override
+  public void setPath(final String val) throws WebdavException {
     // Not actually saved
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#getPath()
    */
+  @Override
   public String getPath() throws WebdavException {
     return getRsrc().getColPath() + "/" + getRsrc().getName();
   }
@@ -192,13 +229,15 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#setParentPath(java.lang.String)
    */
-  public void setParentPath(String val) throws WebdavException {
+  @Override
+  public void setParentPath(final String val) throws WebdavException {
     getRsrc().setColPath(val);
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#getParentPath()
    */
+  @Override
   public String getParentPath() throws WebdavException {
     return getRsrc().getColPath();
   }
@@ -206,36 +245,44 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#setOwner(edu.rpi.cmt.access.AccessPrincipal)
    */
-  public void setOwner(AccessPrincipal val) throws WebdavException {
+  @Override
+  public void setOwner(final AccessPrincipal val) throws WebdavException {
     getRsrc().setOwnerHref(val.getPrincipalRef());
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdCollection#getOwner()
    */
+  @Override
   public AccessPrincipal getOwner() throws WebdavException {
     return intf.getPrincipal(getRsrc().getOwnerHref());
   }
 
-  public void setCreated(String val) throws WebdavException {
+  @Override
+  public void setCreated(final String val) throws WebdavException {
     getRsrc().setCreated(val);
   }
 
+  @Override
   public String getCreated() throws WebdavException {
     return getRsrc().getCreated();
   }
 
-  public void setLastmod(String val) throws WebdavException {
+  @Override
+  public void setLastmod(final String val) throws WebdavException {
     getRsrc().setLastmod(val);
   }
 
+  @Override
   public String getLastmod() throws WebdavException {
     return getRsrc().getLastmod();
   }
 
-  public void setSequence(int val) throws WebdavException {
+  @Override
+  public void setSequence(final int val) throws WebdavException {
   }
 
+  @Override
   public int getSequence() throws WebdavException {
     return 1;
   }
@@ -243,13 +290,15 @@
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdEntity#setDescription(java.lang.String)
    */
-  public void setDescription(String val) throws WebdavException {
+  @Override
+  public void setDescription(final String val) throws WebdavException {
     // No description
   }
 
   /* (non-Javadoc)
    * @see edu.rpi.cct.webdav.servlet.shared.WdEntity#getDescription()
    */
+  @Override
   public String getDescription() throws WebdavException {
     return getRsrc().getName();
   }



More information about the Bedework-commit mailing list