]> git.argeo.org Git - lgpl/argeo-commons.git/blob - remote/IOHandlerWrapper.java
Prepare next development cycle
[lgpl/argeo-commons.git] / remote / IOHandlerWrapper.java
1 package org.argeo.jackrabbit.remote;
2
3 import java.io.IOException;
4
5 import org.apache.jackrabbit.server.io.ExportContext;
6 import org.apache.jackrabbit.server.io.IOHandler;
7 import org.apache.jackrabbit.server.io.IOManager;
8 import org.apache.jackrabbit.server.io.ImportContext;
9 import org.apache.jackrabbit.webdav.DavResource;
10 import org.argeo.ArgeoException;
11
12 /** Wraps an IOHandler so that it can be injected a posteriori */
13 public class IOHandlerWrapper implements IOHandler {
14 private IOManager ioManager = null;
15 private IOHandler ioHandler = null;
16
17 public void setIOHandler(IOHandler ioHandler) {
18 if ((this.ioHandler != null) && (ioHandler != null))
19 throw new ArgeoException(
20 "There is already an IO Handler registered");
21 this.ioHandler = ioHandler;
22 if (ioManager != null && this.ioHandler != null)
23 ioHandler.setIOManager(ioManager);
24 }
25
26 public IOHandler getIOHandler() {
27 return ioHandler;
28 }
29
30 public IOManager getIOManager() {
31 return ioManager;
32 }
33
34 public void setIOManager(IOManager ioManager) {
35 this.ioManager = ioManager;
36 if (ioHandler != null)
37 ioHandler.setIOManager(ioManager);
38 }
39
40 public String getName() {
41 if (ioHandler != null)
42 return ioHandler.getName();
43 else
44 return "Empty IOHandler Wrapper";
45 }
46
47 public boolean canImport(ImportContext context, boolean isCollection) {
48 if (ioHandler != null)
49 return ioHandler.canImport(context, isCollection);
50 return false;
51 }
52
53 public boolean canImport(ImportContext context, DavResource resource) {
54 if (ioHandler != null)
55 return ioHandler.canImport(context, resource);
56 return false;
57 }
58
59 public boolean importContent(ImportContext context, boolean isCollection)
60 throws IOException {
61 if (ioHandler != null)
62 ioHandler.importContent(context, isCollection);
63 return false;
64 }
65
66 public boolean importContent(ImportContext context, DavResource resource)
67 throws IOException {
68 if (ioHandler != null)
69 ioHandler.importContent(context, resource);
70 return false;
71 }
72
73 public boolean canExport(ExportContext context, boolean isCollection) {
74 if (ioHandler != null)
75 ioHandler.canExport(context, isCollection);
76 return false;
77 }
78
79 public boolean canExport(ExportContext context, DavResource resource) {
80 if (ioHandler != null)
81 ioHandler.canExport(context, resource);
82 return false;
83 }
84
85 public boolean exportContent(ExportContext context, boolean isCollection)
86 throws IOException {
87 if (ioHandler != null)
88 ioHandler.exportContent(context, isCollection);
89 return false;
90 }
91
92 public boolean exportContent(ExportContext context, DavResource resource)
93 throws IOException {
94 if (ioHandler != null)
95 ioHandler.exportContent(context, resource);
96 return false;
97 }
98
99 }