KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > jcr > version > VersionHistoryImpl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.jcr.version;
18
19 import java.io.InputStream JavaDoc;
20 import java.util.ArrayList JavaDoc;
21 import java.util.Calendar JavaDoc;
22 import java.util.Collection JavaDoc;
23 import java.util.List JavaDoc;
24
25 import javax.jcr.AccessDeniedException;
26 import javax.jcr.InvalidItemStateException;
27 import javax.jcr.Item;
28 import javax.jcr.ItemExistsException;
29 import javax.jcr.ItemNotFoundException;
30 import javax.jcr.ItemVisitor;
31 import javax.jcr.MergeException;
32 import javax.jcr.NoSuchWorkspaceException;
33 import javax.jcr.Node;
34 import javax.jcr.NodeIterator;
35 import javax.jcr.PathNotFoundException;
36 import javax.jcr.Property;
37 import javax.jcr.PropertyIterator;
38 import javax.jcr.ReferentialIntegrityException;
39 import javax.jcr.RepositoryException;
40 import javax.jcr.Session;
41 import javax.jcr.UnsupportedRepositoryOperationException;
42 import javax.jcr.Value;
43 import javax.jcr.ValueFormatException;
44 import javax.jcr.lock.Lock;
45 import javax.jcr.lock.LockException;
46 import javax.jcr.nodetype.ConstraintViolationException;
47 import javax.jcr.nodetype.NoSuchNodeTypeException;
48 import javax.jcr.nodetype.NodeDefinition;
49 import javax.jcr.nodetype.NodeType;
50 import javax.jcr.version.Version;
51 import javax.jcr.version.VersionException;
52 import javax.jcr.version.VersionHistory;
53 import javax.jcr.version.VersionIterator;
54
55 import org.alfresco.jcr.session.SessionImpl;
56 import org.alfresco.jcr.util.JCRProxyFactory;
57
58
59 /**
60  * Alfresco Implementation of a JCR Version History
61  *
62  * @author David Caruana
63  */

64 public class VersionHistoryImpl implements VersionHistory
65 {
66     private SessionImpl session;
67     private org.alfresco.service.cmr.version.VersionHistory versionHistory;
68     private VersionHistory proxy = null;
69     
70
71     /**
72      * Construct
73      *
74      * @param context
75      * @param versionHistory
76      */

77     public VersionHistoryImpl(SessionImpl context, org.alfresco.service.cmr.version.VersionHistory versionHistory)
78     {
79         this.session = context;
80         this.versionHistory = versionHistory;
81     }
82
83     /**
84      * Get Version History Proxy
85      *
86      * @return version history proxy
87      */

88     public VersionHistory getProxy()
89     {
90         if (proxy == null)
91         {
92             proxy = (VersionHistory)JCRProxyFactory.create(this, VersionHistory.class, session);
93         }
94         return proxy;
95     }
96
97     /**
98      * Get Session
99      *
100      * @return session impl
101      */

102     /*package*/ SessionImpl getSessionImpl()
103     {
104         return session;
105     }
106     
107     /**
108      * Get Version History impl
109      *
110      * @return version history impl
111      */

112     /*package*/ org.alfresco.service.cmr.version.VersionHistory getVersionHistoryImpl()
113     {
114         return versionHistory;
115     }
116     
117     /*
118      * (non-Javadoc)
119      * @see javax.jcr.version.VersionHistory#getVersionableUUID()
120      */

121     public String JavaDoc getVersionableUUID() throws RepositoryException
122     {
123         return versionHistory.getRootVersion().getVersionedNodeRef().getId();
124     }
125
126     /*
127      * (non-Javadoc)
128      * @see javax.jcr.version.VersionHistory#getRootVersion()
129      */

130     public Version getRootVersion() throws RepositoryException
131     {
132         return new VersionImpl(this, versionHistory.getRootVersion()).getProxy();
133     }
134
135     /*
136      * (non-Javadoc)
137      * @see javax.jcr.version.VersionHistory#getAllVersions()
138      */

139     public VersionIterator getAllVersions() throws RepositoryException
140     {
141         Collection JavaDoc<org.alfresco.service.cmr.version.Version> versions = versionHistory.getAllVersions();
142         List JavaDoc<org.alfresco.service.cmr.version.Version> versionsList = new ArrayList JavaDoc<org.alfresco.service.cmr.version.Version>(versions);
143         return new VersionListIterator(this, versionsList);
144     }
145
146     /*
147      * (non-Javadoc)
148      * @see javax.jcr.version.VersionHistory#getVersion(java.lang.String)
149      */

150     public Version getVersion(String JavaDoc versionName) throws VersionException, RepositoryException
151     {
152         org.alfresco.service.cmr.version.Version version = versionHistory.getVersion(versionName);
153         return new VersionImpl(this, version).getProxy();
154     }
155
156     public Version getVersionByLabel(String JavaDoc label) throws RepositoryException
157     {
158         throw new UnsupportedRepositoryOperationException();
159     }
160
161     public void addVersionLabel(String JavaDoc versionName, String JavaDoc label, boolean moveLabel) throws VersionException, RepositoryException
162     {
163         throw new UnsupportedRepositoryOperationException();
164     }
165
166     public void removeVersionLabel(String JavaDoc label) throws VersionException, RepositoryException
167     {
168         throw new UnsupportedRepositoryOperationException();
169     }
170
171     public boolean hasVersionLabel(String JavaDoc label) throws RepositoryException
172     {
173         throw new UnsupportedRepositoryOperationException();
174     }
175
176     public boolean hasVersionLabel(Version version, String JavaDoc label) throws VersionException, RepositoryException
177     {
178         throw new UnsupportedRepositoryOperationException();
179     }
180
181     public String JavaDoc[] getVersionLabels() throws RepositoryException
182     {
183         throw new UnsupportedRepositoryOperationException();
184     }
185
186     public String JavaDoc[] getVersionLabels(Version version) throws VersionException, RepositoryException
187     {
188         throw new UnsupportedRepositoryOperationException();
189     }
190
191     public void removeVersion(String JavaDoc versionName) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException
192     {
193         throw new UnsupportedRepositoryOperationException();
194     }
195
196     
197     // Node implementation
198
// TODO: To support this set of methods will require the projection of all the JCR Version nodes.
199
// That's not simple.
200

201     public Node addNode(String JavaDoc relPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, RepositoryException
202     {
203         throw new UnsupportedRepositoryOperationException();
204     }
205
206     public Node addNode(String JavaDoc relPath, String JavaDoc primaryNodeTypeName) throws ItemExistsException, PathNotFoundException, NoSuchNodeTypeException, LockException, VersionException, ConstraintViolationException, RepositoryException
207     {
208         throw new UnsupportedRepositoryOperationException();
209     }
210
211     public void orderBefore(String JavaDoc srcChildRelPath, String JavaDoc destChildRelPath) throws UnsupportedRepositoryOperationException, VersionException, ConstraintViolationException, ItemNotFoundException, LockException, RepositoryException
212     {
213         throw new UnsupportedRepositoryOperationException();
214     }
215
216     public Property setProperty(String JavaDoc name, Value value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
217     {
218         throw new UnsupportedRepositoryOperationException();
219     }
220
221     public Property setProperty(String JavaDoc name, Value value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
222     {
223         throw new UnsupportedRepositoryOperationException();
224     }
225
226     public Property setProperty(String JavaDoc name, Value[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
227     {
228         throw new UnsupportedRepositoryOperationException();
229     }
230
231     public Property setProperty(String JavaDoc name, Value[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
232     {
233         throw new UnsupportedRepositoryOperationException();
234     }
235
236     public Property setProperty(String JavaDoc name, String JavaDoc[] values) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
237     {
238         throw new UnsupportedRepositoryOperationException();
239     }
240
241     public Property setProperty(String JavaDoc name, String JavaDoc[] values, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
242     {
243         throw new UnsupportedRepositoryOperationException();
244     }
245
246     public Property setProperty(String JavaDoc name, String JavaDoc value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
247     {
248         throw new UnsupportedRepositoryOperationException();
249     }
250
251     public Property setProperty(String JavaDoc name, String JavaDoc value, int type) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
252     {
253         throw new UnsupportedRepositoryOperationException();
254     }
255
256     public Property setProperty(String JavaDoc name, InputStream JavaDoc value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
257     {
258         throw new UnsupportedRepositoryOperationException();
259     }
260
261     public Property setProperty(String JavaDoc name, boolean value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
262     {
263         throw new UnsupportedRepositoryOperationException();
264     }
265
266     public Property setProperty(String JavaDoc name, double value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
267     {
268         throw new UnsupportedRepositoryOperationException();
269     }
270
271     public Property setProperty(String JavaDoc name, long value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
272     {
273         throw new UnsupportedRepositoryOperationException();
274     }
275
276     public Property setProperty(String JavaDoc name, Calendar JavaDoc value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
277     {
278         throw new UnsupportedRepositoryOperationException();
279     }
280
281     public Property setProperty(String JavaDoc name, Node value) throws ValueFormatException, VersionException, LockException, ConstraintViolationException, RepositoryException
282     {
283         throw new UnsupportedRepositoryOperationException();
284     }
285
286     public Node getNode(String JavaDoc relPath) throws PathNotFoundException, RepositoryException
287     {
288         throw new UnsupportedRepositoryOperationException();
289     }
290
291     public NodeIterator getNodes() throws RepositoryException
292     {
293         throw new UnsupportedRepositoryOperationException();
294     }
295
296     public NodeIterator getNodes(String JavaDoc namePattern) throws RepositoryException
297     {
298         throw new UnsupportedRepositoryOperationException();
299     }
300
301     public Property getProperty(String JavaDoc relPath) throws PathNotFoundException, RepositoryException
302     {
303         throw new UnsupportedRepositoryOperationException();
304     }
305
306     public PropertyIterator getProperties() throws RepositoryException
307     {
308         throw new UnsupportedRepositoryOperationException();
309     }
310
311     public PropertyIterator getProperties(String JavaDoc namePattern) throws RepositoryException
312     {
313         throw new UnsupportedRepositoryOperationException();
314     }
315
316     public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException
317     {
318         throw new UnsupportedRepositoryOperationException();
319     }
320
321     public String JavaDoc getUUID() throws UnsupportedRepositoryOperationException, RepositoryException
322     {
323         throw new UnsupportedRepositoryOperationException();
324     }
325
326     public int getIndex() throws RepositoryException
327     {
328         throw new UnsupportedRepositoryOperationException();
329     }
330
331     public PropertyIterator getReferences() throws RepositoryException
332     {
333         throw new UnsupportedRepositoryOperationException();
334     }
335
336     public boolean hasNode(String JavaDoc relPath) throws RepositoryException
337     {
338         throw new UnsupportedRepositoryOperationException();
339     }
340
341     public boolean hasProperty(String JavaDoc relPath) throws RepositoryException
342     {
343         throw new UnsupportedRepositoryOperationException();
344     }
345
346     public boolean hasNodes() throws RepositoryException
347     {
348         throw new UnsupportedRepositoryOperationException();
349     }
350
351     public boolean hasProperties() throws RepositoryException
352     {
353         throw new UnsupportedRepositoryOperationException();
354     }
355
356     public NodeType getPrimaryNodeType() throws RepositoryException
357     {
358         throw new UnsupportedRepositoryOperationException();
359     }
360
361     public NodeType[] getMixinNodeTypes() throws RepositoryException
362     {
363         throw new UnsupportedRepositoryOperationException();
364     }
365
366     public boolean isNodeType(String JavaDoc nodeTypeName) throws RepositoryException
367     {
368         throw new UnsupportedRepositoryOperationException();
369     }
370
371     public void addMixin(String JavaDoc mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException
372     {
373         throw new UnsupportedRepositoryOperationException();
374     }
375
376     public void removeMixin(String JavaDoc mixinName) throws NoSuchNodeTypeException, VersionException, ConstraintViolationException, LockException, RepositoryException
377     {
378         throw new UnsupportedRepositoryOperationException();
379     }
380
381     public boolean canAddMixin(String JavaDoc mixinName) throws NoSuchNodeTypeException, RepositoryException
382     {
383         throw new UnsupportedRepositoryOperationException();
384     }
385
386     public NodeDefinition getDefinition() throws RepositoryException
387     {
388         throw new UnsupportedRepositoryOperationException();
389     }
390
391     public Version checkin() throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException
392     {
393         throw new UnsupportedRepositoryOperationException();
394     }
395
396     public void checkout() throws UnsupportedRepositoryOperationException, LockException, RepositoryException
397     {
398         throw new UnsupportedRepositoryOperationException();
399     }
400
401     public void doneMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException
402     {
403         throw new UnsupportedRepositoryOperationException();
404     }
405
406     public void cancelMerge(Version version) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException
407     {
408         throw new UnsupportedRepositoryOperationException();
409     }
410
411     public void update(String JavaDoc srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException
412     {
413         throw new UnsupportedRepositoryOperationException();
414     }
415
416     public NodeIterator merge(String JavaDoc srcWorkspace, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException
417     {
418         throw new UnsupportedRepositoryOperationException();
419     }
420
421     public String JavaDoc getCorrespondingNodePath(String JavaDoc workspaceName) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException
422     {
423         throw new UnsupportedRepositoryOperationException();
424     }
425
426     public boolean isCheckedOut() throws RepositoryException
427     {
428         throw new UnsupportedRepositoryOperationException();
429     }
430
431     public void restore(String JavaDoc versionName, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException
432     {
433         throw new UnsupportedRepositoryOperationException();
434     }
435
436     public void restore(Version version, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, RepositoryException
437     {
438         throw new UnsupportedRepositoryOperationException();
439     }
440
441     public void restore(Version version, String JavaDoc relPath, boolean removeExisting) throws PathNotFoundException, ItemExistsException, VersionException, ConstraintViolationException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException
442     {
443         throw new UnsupportedRepositoryOperationException();
444     }
445
446     public void restoreByLabel(String JavaDoc versionLabel, boolean removeExisting) throws VersionException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException
447     {
448         throw new UnsupportedRepositoryOperationException();
449     }
450
451     public VersionHistory getVersionHistory() throws UnsupportedRepositoryOperationException, RepositoryException
452     {
453         throw new UnsupportedRepositoryOperationException();
454     }
455
456     public Version getBaseVersion() throws UnsupportedRepositoryOperationException, RepositoryException
457     {
458         throw new UnsupportedRepositoryOperationException();
459     }
460
461     public Lock lock(boolean isDeep, boolean isSessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException
462     {
463         throw new UnsupportedRepositoryOperationException();
464     }
465
466     public Lock getLock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException
467     {
468         throw new UnsupportedRepositoryOperationException();
469     }
470
471     public void unlock() throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, InvalidItemStateException, RepositoryException
472     {
473         throw new UnsupportedRepositoryOperationException();
474     }
475
476     public boolean holdsLock() throws RepositoryException
477     {
478         throw new UnsupportedRepositoryOperationException();
479     }
480
481     public boolean isLocked() throws RepositoryException
482     {
483         throw new UnsupportedRepositoryOperationException();
484     }
485
486     public String JavaDoc getPath() throws RepositoryException
487     {
488         throw new UnsupportedRepositoryOperationException();
489     }
490
491     public String JavaDoc getName() throws RepositoryException
492     {
493         throw new UnsupportedRepositoryOperationException();
494     }
495
496     public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException
497     {
498         throw new UnsupportedRepositoryOperationException();
499     }
500
501     public Node getParent() throws ItemNotFoundException, AccessDeniedException, RepositoryException
502     {
503         throw new UnsupportedRepositoryOperationException();
504     }
505
506     public int getDepth() throws RepositoryException
507     {
508         throw new UnsupportedRepositoryOperationException();
509     }
510
511     public Session getSession() throws RepositoryException
512     {
513         throw new UnsupportedRepositoryOperationException();
514     }
515
516     public boolean isNode()
517     {
518         return true;
519     }
520
521     public boolean isNew()
522     {
523         return false;
524     }
525
526     public boolean isModified()
527     {
528         return false;
529     }
530
531     public boolean isSame(Item otherItem) throws RepositoryException
532     {
533         throw new UnsupportedRepositoryOperationException();
534     }
535
536     public void accept(ItemVisitor visitor) throws RepositoryException
537     {
538         throw new UnsupportedRepositoryOperationException();
539     }
540
541     public void save() throws AccessDeniedException, ItemExistsException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, NoSuchNodeTypeException, RepositoryException
542     {
543         throw new UnsupportedRepositoryOperationException();
544     }
545
546     public void refresh(boolean keepChanges) throws InvalidItemStateException, RepositoryException
547     {
548         throw new UnsupportedRepositoryOperationException();
549     }
550
551     public void remove() throws VersionException, LockException, ConstraintViolationException, RepositoryException
552     {
553         throw new UnsupportedRepositoryOperationException();
554     }
555
556 }
557
Popular Tags