You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by oz...@apache.org on 2004/10/13 22:36:14 UTC

cvs commit: jakarta-slide/proposals/wck/src/org/apache/slide/simple/reference WebdavFileStore.java

ozeigermann    2004/10/13 13:36:14

  Modified:    proposals/wck/src/org/apache/slide/simple/store
                        WebdavStoreAdapter.java BasicWebdavStore.java
               proposals/wck/src/org/apache/slide/simple/reference
                        WebdavFileStore.java
  Log:
  - added content type and character encoding as information for storing of content
  - allowed getResourceLength to mark its return value as invalid to use property instread
  
  Revision  Changes    Path
  1.2       +24 -12    jakarta-slide/proposals/wck/src/org/apache/slide/simple/store/WebdavStoreAdapter.java
  
  Index: WebdavStoreAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/wck/src/org/apache/slide/simple/store/WebdavStoreAdapter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebdavStoreAdapter.java	12 Oct 2004 20:19:02 -0000	1.1
  +++ WebdavStoreAdapter.java	13 Oct 2004 20:36:14 -0000	1.2
  @@ -45,7 +45,8 @@
   import org.apache.slide.util.logger.*;
   
   /**
  - * Driving adapter for call back interfaces {@link BasicWebdavStore} and extensions.
  + * Driving adapter for call back interfaces {@link BasicWebdavStore}and
  + * extensions.
    * 
    * @see BasicWebdavStore
    * @see WebdavStoreLockExtension
  @@ -483,16 +484,14 @@
                   NodeRevisionContent revisionContent) throws ServiceAccessException, RevisionAlreadyExistException {
               try {
                   store.createResource(uri.toString());
  -                store.setResourceContent(uri.toString(), revisionContent.streamContent());
  +                storeRevisionContent(uri, revisionDescriptor, revisionContent);
                   tentativeResourceCreated.add(uri.toString());
                   toBeCreated.remove(uri.toString());
               } catch (ObjectAlreadyExistsException e) {
                   throw new RevisionAlreadyExistException(uri.toString(), revisionDescriptor.getRevisionNumber());
  -            } catch (IOException e) {
  -                throw new RevisionAlreadyExistException(uri.toString(), revisionDescriptor.getRevisionNumber());
               } catch (AccessDeniedException e) {
                   throw new ServiceAccessException(service, e);
  -            } catch (ObjectNotFoundException e) {
  +            } catch (RevisionNotFoundException e) {
                   throw new ServiceAccessException(service, e);
               }
           }
  @@ -500,7 +499,17 @@
           public void storeRevisionContent(Uri uri, NodeRevisionDescriptor revisionDescriptor,
                   NodeRevisionContent revisionContent) throws ServiceAccessException, RevisionNotFoundException {
               try {
  -                store.setResourceContent(uri.toString(), revisionContent.streamContent());
  +                String contentType = null;
  +                String characterEncoding = null;
  +                if (revisionDescriptor != null) {
  +                    NodeProperty property = revisionDescriptor.getProperty("characterEncoding");
  +                    if (property != null) {
  +                        characterEncoding = property.getValue().toString();
  +                    }
  +                    contentType = revisionDescriptor.getContentType();
  +                }
  +                store.setResourceContent(uri.toString(), revisionContent.streamContent(), contentType,
  +                        characterEncoding);
               } catch (ObjectNotFoundException e) {
                   throw new RevisionNotFoundException(uri.toString(), revisionDescriptor.getRevisionNumber());
               } catch (IOException e) {
  @@ -608,7 +617,10 @@
                           if (store.isFolder(uri.toString())) {
                               descriptor.setResourceType(NodeRevisionDescriptor.COLLECTION_TYPE);
                           } else {
  -                            descriptor.setContentLength(store.getResourceLength(uri.toString()));
  +                            long length = store.getResourceLength(uri.toString());
  +                            if (length != -1) {
  +                                descriptor.setContentLength(length);
  +                            }
                           }
                       } catch (ObjectNotFoundException e) {
                           throw new RevisionDescriptorNotFoundException(uri.toString());
  @@ -819,4 +831,4 @@
   
           }
       }
  -}
  +}
  \ No newline at end of file
  
  
  
  1.2       +25 -17    jakarta-slide/proposals/wck/src/org/apache/slide/simple/store/BasicWebdavStore.java
  
  Index: BasicWebdavStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/wck/src/org/apache/slide/simple/store/BasicWebdavStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BasicWebdavStore.java	12 Oct 2004 20:19:02 -0000	1.1
  +++ BasicWebdavStore.java	13 Oct 2004 20:36:14 -0000	1.2
  @@ -43,8 +43,9 @@
    * 
    * <p>
    * For each WebDAV request an object of this interface is being created. Each
  - * request will call the {@link #begin(Service, Principal, Object, LoggerFacade, Hashtable)} method and will
  - * either be ended with a call to the {@link #commit()} or the
  + * request will call the
  + * {@link #begin(Service, Principal, Object, LoggerFacade, Hashtable)}method
  + * and will either be ended with a call to the {@link #commit()}or the
    * {@link #rollback()}method. For the whole duration of such a request it will
    * be this only and only this object that is being called back. This means you
    * can store all kinds of object variables in your implementation and be very
  @@ -60,13 +61,13 @@
    * To indicate your system denies permission to perform certain requests on
    * certain Uris you should throw a
    * {@link org.apache.slide.security.AccessDeniedException}. This will be caught
  - * by the {@link org.apache.slide.simple.store.WebdavStoreAdapter adapter} code
  + * by the {@link org.apache.slide.simple.store.WebdavStoreAdapter adapter}code
    * and transformed into a <em>FORBIDDEN</em> response. Any fatal stuff that
    * goes wrong in your code should issue a
    * {@link org.apache.slide.common.ServiceAccessException}. Finally, if the
    * adapter asks for any kind of object that is not there throw a
  - * {@link org.apache.slide.structure.ObjectNotFoundException} or a
  - * {@link org.apache.slide.structure.ObjectAlreadyExistsException} if the
  + * {@link org.apache.slide.structure.ObjectNotFoundException}or a
  + * {@link org.apache.slide.structure.ObjectAlreadyExistsException}if the
    * adapter tries to create anything that is already there.
    * </p>
    * 
  @@ -75,11 +76,11 @@
    * of the Slide's WebDAV layer. This means if you implement these methods
    * meaningful your system will be able to work with MS Windows Explorer, MS
    * Office, Netdrive and the Mac Finder. You will however need additional stores
  - * to take care of locking and security informations or implement the
  - * extended interfaces that have additional locking
  - * and property methods. Implementing this interface will not store any custom
  - * properties. Have a look at the {@link WebdavFileStore} reference
  - * implementation to the file system and the configuration given there.
  + * to take care of locking and security informations or implement the extended
  + * interfaces that have additional locking and property methods. Implementing
  + * this interface will not store any custom properties. Have a look at the
  + * {@link WebdavFileStore}reference implementation to the file system and the
  + * configuration given there.
    * </p>
    * 
    * <p>
  @@ -232,6 +233,11 @@
        *            URI of the content resource
        * @param content
        *            input stream the content of the resource can be read from
  +     * @param contentType
  +     *            content type of the resource or <code>null</code> if unknown
  +     * @param characterEncoding
  +     *            character encoding of the resource or <code>null</code> if
  +     *            unknown or not applicable
        * @throws ServiceAccessException
        *             if any kind of internal error or any unexpected state occurs
        * @throws AccessDeniedException
  @@ -239,8 +245,8 @@
        * @throws ObjectNotFoundException
        *             if there is no object at <code>resourceUri</code>
        */
  -    void setResourceContent(String resourceUri, InputStream content) throws ServiceAccessException,
  -            AccessDeniedException, ObjectNotFoundException;
  +    void setResourceContent(String resourceUri, InputStream content, String contentType, String characterEncoding)
  +            throws ServiceAccessException, AccessDeniedException, ObjectNotFoundException;
   
       /**
        * Gets the date of the last modiciation of the object specified by
  @@ -312,7 +318,9 @@
        * 
        * @param resourceUri
        *            URI of the content resource
  -     * @return length of the resource in bytes
  +     * @return length of the resource in bytes,
  +     *         <code>-1</code> declares this value as invalid and asks the
  +     *         adapter to try to set it from the properties if possible
        * @throws ServiceAccessException
        *             if any kind of internal error or any unexpected state occurs
        * @throws AccessDeniedException
  
  
  
  1.2       +5 -5      jakarta-slide/proposals/wck/src/org/apache/slide/simple/reference/WebdavFileStore.java
  
  Index: WebdavFileStore.java
  ===================================================================
  RCS file: /home/cvs/jakarta-slide/proposals/wck/src/org/apache/slide/simple/reference/WebdavFileStore.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WebdavFileStore.java	12 Oct 2004 20:19:02 -0000	1.1
  +++ WebdavFileStore.java	13 Oct 2004 20:36:14 -0000	1.2
  @@ -289,7 +289,7 @@
           }
       }
   
  -    public void setResourceContent(String resourceUri, InputStream content) throws ServiceAccessException,
  +    public void setResourceContent(String resourceUri, InputStream content, String contentType, String characterEncoding) throws ServiceAccessException,
               AccessDeniedException, ObjectNotFoundException {
           try {
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org