]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.server.jackrabbit/src/org/argeo/jackrabbit/remote/IOHandlerWrapper.java
Merge adaptations related to the new third parties.
[lgpl/argeo-commons.git] / org.argeo.server.jackrabbit / src / org / argeo / jackrabbit / remote / IOHandlerWrapper.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.jackrabbit.remote;
17
18 import java.io.IOException;
19
20 import org.apache.jackrabbit.server.io.ExportContext;
21 import org.apache.jackrabbit.server.io.IOHandler;
22 import org.apache.jackrabbit.server.io.IOManager;
23 import org.apache.jackrabbit.server.io.ImportContext;
24 import org.apache.jackrabbit.webdav.DavResource;
25 import org.argeo.ArgeoException;
26
27 /** Wraps an IOHandler so that it can be injected a posteriori */
28 public class IOHandlerWrapper implements IOHandler {
29 private IOManager ioManager = null;
30 private IOHandler ioHandler = null;
31
32 public void setIOHandler(IOHandler ioHandler) {
33 if ((this.ioHandler != null) && (ioHandler != null))
34 throw new ArgeoException(
35 "There is already an IO Handler registered");
36 this.ioHandler = ioHandler;
37 if (ioManager != null && this.ioHandler != null)
38 ioHandler.setIOManager(ioManager);
39 }
40
41 public IOHandler getIOHandler() {
42 return ioHandler;
43 }
44
45 public IOManager getIOManager() {
46 return ioManager;
47 }
48
49 public void setIOManager(IOManager ioManager) {
50 this.ioManager = ioManager;
51 if (ioHandler != null)
52 ioHandler.setIOManager(ioManager);
53 }
54
55 public String getName() {
56 if (ioHandler != null)
57 return ioHandler.getName();
58 else
59 return "Empty IOHandler Wrapper";
60 }
61
62 public boolean canImport(ImportContext context, boolean isCollection) {
63 if (ioHandler != null)
64 return ioHandler.canImport(context, isCollection);
65 return false;
66 }
67
68 public boolean canImport(ImportContext context, DavResource resource) {
69 if (ioHandler != null)
70 return ioHandler.canImport(context, resource);
71 return false;
72 }
73
74 public boolean importContent(ImportContext context, boolean isCollection)
75 throws IOException {
76 if (ioHandler != null)
77 ioHandler.importContent(context, isCollection);
78 return false;
79 }
80
81 public boolean importContent(ImportContext context, DavResource resource)
82 throws IOException {
83 if (ioHandler != null)
84 ioHandler.importContent(context, resource);
85 return false;
86 }
87
88 public boolean canExport(ExportContext context, boolean isCollection) {
89 if (ioHandler != null)
90 ioHandler.canExport(context, isCollection);
91 return false;
92 }
93
94 public boolean canExport(ExportContext context, DavResource resource) {
95 if (ioHandler != null)
96 ioHandler.canExport(context, resource);
97 return false;
98 }
99
100 public boolean exportContent(ExportContext context, boolean isCollection)
101 throws IOException {
102 if (ioHandler != null)
103 ioHandler.exportContent(context, isCollection);
104 return false;
105 }
106
107 public boolean exportContent(ExportContext context, DavResource resource)
108 throws IOException {
109 if (ioHandler != null)
110 ioHandler.exportContent(context, resource);
111 return false;
112 }
113
114 }