View Javadoc
1   /**
2    * This file Copyright (c) 2015 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 javax.jcr.AccessDeniedException;
37  import javax.jcr.InvalidItemStateException;
38  import javax.jcr.ItemExistsException;
39  import javax.jcr.MergeException;
40  import javax.jcr.NoSuchWorkspaceException;
41  import javax.jcr.Node;
42  import javax.jcr.NodeIterator;
43  import javax.jcr.PathNotFoundException;
44  import javax.jcr.RepositoryException;
45  import javax.jcr.UnsupportedRepositoryOperationException;
46  import javax.jcr.lock.LockException;
47  import javax.jcr.nodetype.ConstraintViolationException;
48  import javax.jcr.version.Version;
49  import javax.jcr.version.VersionException;
50  import javax.jcr.version.VersionHistory;
51  import javax.jcr.version.VersionManager;
52  
53  /**
54   * Wrapper for JCR version manager.
55   */
56  public class DelegateVersionManagerWrapper implements VersionManager {
57  
58      private VersionManager wrapped;
59  
60      protected DelegateVersionManagerWrapper(VersionManager versionManager) {
61          this.wrapped = versionManager;
62      }
63  
64      public VersionManager getWrappedVersionManager() {
65          return wrapped;
66      }
67  
68      public void setWrappedVersionManager(VersionManager versionManager) {
69          this.wrapped = versionManager;
70      }
71  
72      @Override
73      public String toString() {
74          return wrapped != null ? wrapped.toString() : "";
75      }
76  
77      @Override
78      public Version checkin(String absPath) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
79          return getWrappedVersionManager().checkin(absPath);
80      }
81  
82      @Override
83      public void checkout(String absPath) throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
84          getWrappedVersionManager().checkout(absPath);
85      }
86  
87      @Override
88      public Version checkpoint(String absPath) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
89          return getWrappedVersionManager().checkpoint(absPath);
90      }
91  
92      @Override
93      public boolean isCheckedOut(String absPath) throws RepositoryException {
94          return getWrappedVersionManager().isCheckedOut(absPath);
95      }
96  
97      @Override
98      public VersionHistory getVersionHistory(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
99          return getWrappedVersionManager().getVersionHistory(absPath);
100     }
101 
102     @Override
103     public Version getBaseVersion(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
104         return getWrappedVersionManager().getBaseVersion(absPath);
105     }
106 
107     @Override
108     public void restore(Version[] versions, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
109         getWrappedVersionManager().restore(versions, removeExisting);
110     }
111 
112     @Override
113     public void restore(String absPath, String versionName, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
114         getWrappedVersionManager().restore(absPath, versionName, removeExisting);
115     }
116 
117     @Override
118     public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, InvalidItemStateException, UnsupportedRepositoryOperationException, LockException, RepositoryException {
119         getWrappedVersionManager().restore(version, removeExisting);
120     }
121 
122     @Override
123     public void restore(String absPath, Version version, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
124         getWrappedVersionManager().restore(absPath, version, removeExisting);
125     }
126 
127     @Override
128     public void restoreByLabel(String absPath, String versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
129         getWrappedVersionManager().restoreByLabel(absPath, versionLabel, removeExisting);
130     }
131 
132     @Override
133     public NodeIterator merge(String absPath, String srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
134         return getWrappedVersionManager().merge(absPath, srcWorkspace, bestEffort);
135     }
136 
137     @Override
138     public NodeIterator merge(String absPath, String srcWorkspace, boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
139         return getWrappedVersionManager().merge(absPath, srcWorkspace, bestEffort, isShallow);
140     }
141 
142     @Override
143     public void doneMerge(String absPath, Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
144         getWrappedVersionManager().doneMerge(absPath, version);
145     }
146 
147     @Override
148     public void cancelMerge(String absPath, Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
149         getWrappedVersionManager().cancelMerge(absPath, version);
150     }
151 
152     @Override
153     public Node createConfiguration(String absPath) throws UnsupportedRepositoryOperationException, RepositoryException {
154         return getWrappedVersionManager().createConfiguration(absPath);
155     }
156 
157     @Override
158     public Node setActivity(Node activity) throws UnsupportedRepositoryOperationException, RepositoryException {
159         return getWrappedVersionManager().setActivity(activity);
160     }
161 
162     @Override
163     public Node getActivity() throws UnsupportedRepositoryOperationException, RepositoryException {
164         return getWrappedVersionManager().getActivity();
165     }
166 
167     @Override
168     public Node createActivity(String title) throws UnsupportedRepositoryOperationException, RepositoryException {
169         return getWrappedVersionManager().createActivity(title);
170     }
171 
172     @Override
173     public void removeActivity(Node activityNode) throws UnsupportedRepositoryOperationException, VersionException, RepositoryException {
174         getWrappedVersionManager().removeActivity(activityNode);
175     }
176 
177     @Override
178     public NodeIterator merge(Node activityNode) throws VersionException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
179         return getWrappedVersionManager().merge(activityNode);
180     }
181 }