1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package info.magnolia.jcr.wrapper;
35
36 import java.io.IOException;
37 import java.io.InputStream;
38
39 import javax.jcr.AccessDeniedException;
40 import javax.jcr.InvalidItemStateException;
41 import javax.jcr.InvalidSerializedDataException;
42 import javax.jcr.ItemExistsException;
43 import javax.jcr.NamespaceRegistry;
44 import javax.jcr.NoSuchWorkspaceException;
45 import javax.jcr.PathNotFoundException;
46 import javax.jcr.RepositoryException;
47 import javax.jcr.Session;
48 import javax.jcr.UnsupportedRepositoryOperationException;
49 import javax.jcr.Workspace;
50 import javax.jcr.lock.LockException;
51 import javax.jcr.lock.LockManager;
52 import javax.jcr.nodetype.ConstraintViolationException;
53 import javax.jcr.nodetype.NodeTypeManager;
54 import javax.jcr.observation.ObservationManager;
55 import javax.jcr.query.QueryManager;
56 import javax.jcr.version.Version;
57 import javax.jcr.version.VersionException;
58 import javax.jcr.version.VersionManager;
59
60 import org.xml.sax.ContentHandler;
61
62
63
64
65 public abstract class DelegateWorkspaceWrapper implements Workspace {
66
67 protected Workspace wrapped;
68
69 protected DelegateWorkspaceWrapper(Workspace workspace) {
70 this.wrapped = workspace;
71 }
72
73 public Workspace getWrappedWorkspace() {
74 return wrapped;
75 }
76
77 public void setWrappedWorkspace(Workspace workspace) {
78 this.wrapped = workspace;
79 }
80
81 @Override
82 public String toString() {
83 return wrapped != null ? wrapped.toString() : "";
84 }
85
86
87
88
89
90
91
92 @Override
93 public Session getSession() {
94 return getWrappedWorkspace().getSession();
95 }
96
97 @Override
98 public String getName() {
99 return getWrappedWorkspace().getName();
100 }
101
102 @Override
103 public void copy(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
104 getWrappedWorkspace().copy(srcAbsPath, destAbsPath);
105 }
106
107 @Override
108 public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
109 getWrappedWorkspace().copy(srcWorkspace, srcAbsPath, destAbsPath);
110 }
111
112 @Override
113 public void clone(String srcWorkspace, String srcAbsPath, String destAbsPath, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
114 getWrappedWorkspace().clone(srcWorkspace, srcAbsPath, destAbsPath, removeExisting);
115 }
116
117 @Override
118 public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
119 getWrappedWorkspace().move(srcAbsPath, destAbsPath);
120 }
121
122 @Override
123 public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
124 getWrappedWorkspace().restore(versions, removeExisting);
125 }
126
127 @Override
128 public LockManager getLockManager() throws UnsupportedRepositoryOperationException, RepositoryException {
129 return getWrappedWorkspace().getLockManager();
130 }
131
132 @Override
133 public QueryManager getQueryManager() throws RepositoryException {
134 try {
135 return getWrappedWorkspace().getQueryManager();
136 } catch (UnsupportedRepositoryOperationException e) {
137 throw e;
138 } catch (RepositoryException e) {
139 throw new UnsupportedRepositoryOperationException("Workspace " + getName() + " does not support querying.", e);
140 }
141 }
142
143 @Override
144 public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
145 return getWrappedWorkspace().getNamespaceRegistry();
146 }
147
148 @Override
149 public NodeTypeManager getNodeTypeManager() throws RepositoryException {
150 return getWrappedWorkspace().getNodeTypeManager();
151 }
152
153 @Override
154 public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException, RepositoryException {
155 return getWrappedWorkspace().getObservationManager();
156 }
157
158 @Override
159 public VersionManager getVersionManager() throws UnsupportedRepositoryOperationException, RepositoryException {
160 return getWrappedWorkspace().getVersionManager();
161 }
162
163 @Override
164 public String[] getAccessibleWorkspaceNames() throws RepositoryException {
165 return getWrappedWorkspace().getAccessibleWorkspaceNames();
166 }
167
168 @Override
169 public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, AccessDeniedException, RepositoryException {
170 return getWrappedWorkspace().getImportContentHandler(parentAbsPath, uuidBehavior);
171 }
172
173 @Override
174 public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, VersionException, PathNotFoundException, ItemExistsException, ConstraintViolationException, InvalidSerializedDataException, LockException, AccessDeniedException, RepositoryException {
175 getWrappedWorkspace().importXML(parentAbsPath, in, uuidBehavior);
176 }
177
178 @Override
179 public void createWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
180 getWrappedWorkspace().createWorkspace(name);
181 }
182
183 @Override
184 public void createWorkspace(String name, String srcWorkspace) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
185 getWrappedWorkspace().createWorkspace(name, srcWorkspace);
186 }
187
188 @Override
189 public void deleteWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
190 getWrappedWorkspace().deleteWorkspace(name);
191 }
192
193 }