X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.server.jcr.mvc%2Fsrc%2Forg%2Fargeo%2Fjackrabbit%2Fremote%2FIOHandlerWrapper.java;fp=org.argeo.server.jcr.mvc%2Fsrc%2Forg%2Fargeo%2Fjackrabbit%2Fremote%2FIOHandlerWrapper.java;h=daf2ecb2b77621d0ad454b3289dc65e8e9907253;hb=c95ab41f84b0cf5394e1041b6ff52fd6019aa2e6;hp=0000000000000000000000000000000000000000;hpb=f3c695378b1f845acddb70ffb4ae905dc0d429f9;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java new file mode 100644 index 000000000..daf2ecb2b --- /dev/null +++ b/org.argeo.server.jcr.mvc/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * 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.argeo.jackrabbit.remote; + +import java.io.IOException; + +import org.apache.jackrabbit.server.io.ExportContext; +import org.apache.jackrabbit.server.io.IOHandler; +import org.apache.jackrabbit.server.io.IOManager; +import org.apache.jackrabbit.server.io.ImportContext; +import org.apache.jackrabbit.webdav.DavResource; +import org.argeo.ArgeoException; + +/** Wraps an IOHandler so that it can be injected a posteriori */ +public class IOHandlerWrapper implements IOHandler { + private IOManager ioManager = null; + private IOHandler ioHandler = null; + + public void setIOHandler(IOHandler ioHandler) { + if ((this.ioHandler != null) && (ioHandler != null)) + throw new ArgeoException( + "There is already an IO Handler registered"); + this.ioHandler = ioHandler; + if (ioManager != null && this.ioHandler != null) + ioHandler.setIOManager(ioManager); + } + + public IOHandler getIOHandler() { + return ioHandler; + } + + public IOManager getIOManager() { + return ioManager; + } + + public void setIOManager(IOManager ioManager) { + this.ioManager = ioManager; + if (ioHandler != null) + ioHandler.setIOManager(ioManager); + } + + public String getName() { + if (ioHandler != null) + return ioHandler.getName(); + else + return "Empty IOHandler Wrapper"; + } + + public boolean canImport(ImportContext context, boolean isCollection) { + if (ioHandler != null) + return ioHandler.canImport(context, isCollection); + return false; + } + + public boolean canImport(ImportContext context, DavResource resource) { + if (ioHandler != null) + return ioHandler.canImport(context, resource); + return false; + } + + public boolean importContent(ImportContext context, boolean isCollection) + throws IOException { + if (ioHandler != null) + ioHandler.importContent(context, isCollection); + return false; + } + + public boolean importContent(ImportContext context, DavResource resource) + throws IOException { + if (ioHandler != null) + ioHandler.importContent(context, resource); + return false; + } + + public boolean canExport(ExportContext context, boolean isCollection) { + if (ioHandler != null) + ioHandler.canExport(context, isCollection); + return false; + } + + public boolean canExport(ExportContext context, DavResource resource) { + if (ioHandler != null) + ioHandler.canExport(context, resource); + return false; + } + + public boolean exportContent(ExportContext context, boolean isCollection) + throws IOException { + if (ioHandler != null) + ioHandler.exportContent(context, isCollection); + return false; + } + + public boolean exportContent(ExportContext context, DavResource resource) + throws IOException { + if (ioHandler != null) + ioHandler.exportContent(context, resource); + return false; + } + +}