blob: 99a0c634334d654520e72ac637f62ee4425555dd [file] [log] [blame]
/*
* Copyright 2005 The Apache Software Foundation.
*
* 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 org.apache.jackrabbit.server.io;
import org.apache.jackrabbit.webdav.DavResource;
import java.io.IOException;
/**
* <code>IOHandler</code>...
*/
public interface IOHandler {
/**
* Returns the <code>IOManager</code> that called this handler or <code>null</code>.
*
* @return
*/
public IOManager getIOManager();
/**
* Returns a human readable name for this <code>IOHandler</code>
*
* @return
*/
public String getName();
/**
* Returns true, if this handler can run a successful import based on the
* specified context.
*
* @param context
* @param isCollection
* @return
*/
public boolean canImport(ImportContext context, boolean isCollection);
/**
* Returns true, if this handler can run a successful import based on
* the specified context and resource. A simple implementation may choose
* to return the same as {@link #canImport(ImportContext, boolean)} where
* the isCollection flag is determined by {@link DavResource#isCollection()}.
*
* @param context
* @param resource
* @return
*/
public boolean canImport(ImportContext context, DavResource resource);
/**
* Runs the import for the given context and indicates by a boolean return
* value, if the import could be completed successfully. If the specified
* <code>ImportContext</code> does not provide a {@link ImportContext#hasStream() stream}
* the implementation is free, to only import properties of to refuse the
* import.<br>
*
* Please note, that it is the responsibility of the specified
* <code>ImportContext</code> to assert, that its stream is not consumed
* multiple times when being passed to a chain of <code>IOHandler</code>s.
*
* @param context
* @param isCollection
* @return true if the import was successful.
* @throws IOException if an unexpected error occurs or if this method has
* been called although {@link #canImport(ImportContext, boolean)} returns
* false.
*/
public boolean importContent(ImportContext context, boolean isCollection) throws IOException;
/**
* Runs the import for the given context and resource. It indicates by a boolean return
* value, if the import could be completed successfully. If the specified
* <code>ImportContext</code> does not provide a {@link ImportContext#hasStream() stream}
* the implementation is free, to only import properties of to refuse the
* import. A simple implementation may return the same as
* {@link #importContent(ImportContext, boolean)} where the isCollection flag
* is determined by {@link DavResource#isCollection()}<br>
*
* Please note, that it is the responsibility of the specified
* <code>ImportContext</code> to assert, that its stream is not consumed
* multiple times when being passed to a chain of <code>IOHandler</code>s.
*
* @param context
* @param resource
* @return
* @throws IOException if an unexpected error occurs or if this method has
* been called although {@link #canImport(ImportContext, DavResource)} returns
* false.
* @see #importContent(ImportContext, boolean)
*/
public boolean importContent(ImportContext context, DavResource resource) throws IOException;
/**
* Returns true, if this handler can run a successful export based on the
* specified context.
*
* @param context
* @param isCollection
* @return
*/
public boolean canExport(ExportContext context, boolean isCollection);
/**
* Returns true, if this handler can run a successful export based on
* the specified context and resource. A simple implementation may choose
* to return the same as {@link #canExport(ExportContext, boolean)} where
* the isCollection flag is determined by {@link DavResource#isCollection()}.
*
* @param context
* @param resource
* @return
*/
public boolean canExport(ExportContext context, DavResource resource);
/**
* Runs the export for the given context. It indicates by a boolean return
* value, if the export could be completed successfully. If the specified
* <code>ExportContext</code> does not provide a {@link ExportContext#hasStream() stream}
* the implementation should set the properties only and ignore the content to
* be exported. A simple implementation may return the same as
* {@link #exportContent(ExportContext, boolean)} where the isCollection flag
* is determined by {@link DavResource#isCollection()}<br>
*
* Please note, that it is the responsibility of the specified
* <code>ExportContext</code> to assert, that its stream is not written
* multiple times when being passed to a chain of <code>IOHandler</code>s.
*
* @param context
* @param isCollection
* @return
* @throws IOException if an unexpected error occurs or if this method has
* been called although {@link #canExport(ExportContext, boolean)} returns
* false.
*/
public boolean exportContent(ExportContext context, boolean isCollection) throws IOException;
/**
* Runs the export for the given context and resource. It indicates by a boolean return
* value, if the export could be completed successfully. If the specified
* <code>ExportContext</code> does not provide a {@link ExportContext#hasStream() stream}
* the implementation should set the properties only and ignore the content to
* be exported. A simple implementation may return the same as
* {@link #exportContent(ExportContext, boolean)} where the isCollection flag
* is determined by {@link DavResource#isCollection()}<br>
*
* Please note, that it is the responsibility of the specified
* <code>ExportContext</code> to assert, that its stream is not written
* multiple times when being passed to a chain of <code>IOHandler</code>s.
*
* @param context
* @param resource
* @return
* @throws IOException if an unexpected error occurs or if this method has
* been called although {@link #canExport(ExportContext, DavResource)} returns
* false.
*/
public boolean exportContent(ExportContext context, DavResource resource) throws IOException;
}