View Javadoc

1   /**
2    * This file Copyright (c) 2013 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
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   * Wrapper for JCR workspace.
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      // Delegating method stubs
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         return getWrappedWorkspace().getQueryManager();
135     }
136 
137     @Override
138     public NamespaceRegistry getNamespaceRegistry() throws RepositoryException {
139         return getWrappedWorkspace().getNamespaceRegistry();
140     }
141 
142     @Override
143     public NodeTypeManager getNodeTypeManager() throws RepositoryException {
144         return getWrappedWorkspace().getNodeTypeManager();
145     }
146 
147     @Override
148     public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException, RepositoryException {
149         return getWrappedWorkspace().getObservationManager();
150     }
151 
152     @Override
153     public VersionManager getVersionManager() throws UnsupportedRepositoryOperationException, RepositoryException {
154         return getWrappedWorkspace().getVersionManager();
155     }
156 
157     @Override
158     public String[] getAccessibleWorkspaceNames() throws RepositoryException {
159         return getWrappedWorkspace().getAccessibleWorkspaceNames();
160     }
161 
162     @Override
163     public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, AccessDeniedException, RepositoryException {
164         return getWrappedWorkspace().getImportContentHandler(parentAbsPath, uuidBehavior);
165     }
166 
167     @Override
168     public void importXML(String parentAbsPath, InputStream in, int uuidBehavior) throws IOException, VersionException, PathNotFoundException, ItemExistsException, ConstraintViolationException, InvalidSerializedDataException, LockException, AccessDeniedException, RepositoryException {
169         getWrappedWorkspace().importXML(parentAbsPath, in, uuidBehavior);
170     }
171 
172     @Override
173     public void createWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
174         getWrappedWorkspace().createWorkspace(name);
175     }
176 
177     @Override
178     public void createWorkspace(String name, String srcWorkspace) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
179         getWrappedWorkspace().createWorkspace(name, srcWorkspace);
180     }
181 
182     @Override
183     public void deleteWorkspace(String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
184         getWrappedWorkspace().deleteWorkspace(name);
185     }
186 
187 }