All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.webdav.spi.IWebdavStore Maven / Gradle / Ivy

/**
 * Copyright (C) 2006-2017 Apache Software Foundation (https://sourceforge.net/p/webdav-servlet, https://github.com/Commonjava/webdav-handler)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.sf.webdav.spi;

import java.io.InputStream;
import java.security.Principal;

import net.sf.webdav.StoredObject;
import net.sf.webdav.exceptions.WebdavException;

/**
 * Interface for simple implementation of any store for the WebdavServlet
 * 

* based on the BasicWebdavStore from Oliver Zeigermann, that was part of the * Webdav Construcktion Kit from slide * */ public interface IWebdavStore { /** * Indicates that a new request or transaction with this store involved has * been started. The request will be terminated by either * {@link #commit(ITransaction transaction)} or * {@link #rollback(ITransaction transaction)}. If only non-read methods * have been called, the request will be terminated by a * {@link #commit(ITransaction transaction)}. This method will be * called by (@link WebdavStoreAdapter} at the beginning of each request. * * * @param principal * the principal that started this request or null if * there is non available * * @throws WebdavException */ ITransaction begin( Principal principal ) throws WebdavException; /** * Checks if authentication information passed in is valid. If not throws an * exception. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction */ void checkAuthentication( ITransaction transaction ) throws WebdavException; /** * Indicates that all changes done inside this request shall be made * permanent and any transactions, connections and other temporary resources * shall be terminated. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * * @throws WebdavException * if something goes wrong on the store level */ void commit( ITransaction transaction ) throws WebdavException; /** * Indicates that all changes done inside this request shall be undone and * any transactions, connections and other temporary resources shall be * terminated. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * * @throws WebdavException * if something goes wrong on the store level */ void rollback( ITransaction transaction ) throws WebdavException; /** * Creates a folder at the position specified by folderUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param folderUri * URI of the folder * @throws WebdavException * if something goes wrong on the store level */ void createFolder( ITransaction transaction, String folderUri ) throws WebdavException; /** * Creates a content resource at the position specified by * resourceUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param resourceUri * URI of the content resource * @throws WebdavException * if something goes wrong on the store level */ void createResource( ITransaction transaction, String resourceUri ) throws WebdavException; /** * Gets the content of the resource specified by resourceUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param resourceUri * URI of the content resource * @return input stream you can read the content of the resource from * @throws WebdavException * if something goes wrong on the store level */ InputStream getResourceContent( ITransaction transaction, String resourceUri ) throws WebdavException; /** * Sets / stores the content of the resource specified by * resourceUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param resourceUri * URI of the resource where the content will be stored * @param content * input stream from which the content will be read from * @param contentLength The length of the content. * @return lenght of resource * @throws WebdavException * if something goes wrong on the store level */ long setResourceContent(ITransaction transaction, String resourceUri, InputStream content, long contentLength) throws WebdavException; /** * Gets the names of the children of the folder specified by * folderUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param folderUri * URI of the folder * @return a (possibly empty) list of children, or null if the * uri points to a file * @throws WebdavException * if something goes wrong on the store level */ String[] getChildrenNames( ITransaction transaction, String folderUri ) throws WebdavException; /** * Gets the length of the content resource specified by * resourceUri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param resourceUri * URI of the content resource * @return length of the resource in bytes, -1 declares this * value as invalid and asks the adapter to try to set it from the * properties if possible * @throws WebdavException * if something goes wrong on the store level */ long getResourceLength( ITransaction transaction, String resourceUri ) throws WebdavException; /** * Removes the object specified by uri. * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param uri * URI of the object, i.e. content resource or folder * @throws WebdavException * if something goes wrong on the store level */ void removeObject( ITransaction transaction, String uri ) throws WebdavException; /** * Gets the storedObject specified by uri * * @param transaction * indicates that the method is within the scope of a WebDAV * transaction * @param uri * URI * @return StoredObject */ StoredObject getStoredObject( ITransaction transaction, String uri ) throws WebdavException; }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy