KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > store > mem > TransientDescriptorStore


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/stores/org/apache/slide/store/mem/TransientDescriptorStore.java,v 1.3 2004/07/28 09:34:05 ib Exp $
3  * $Revision: 1.3 $
4  * $Date: 2004/07/28 09:34:05 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23 package org.apache.slide.store.mem;
24
25 import org.apache.slide.common.ServiceAccessException;
26 import org.apache.slide.common.Uri;
27 import org.apache.slide.content.NodeRevisionDescriptor;
28 import org.apache.slide.content.NodeRevisionNumber;
29 import org.apache.slide.content.RevisionDescriptorNotFoundException;
30 import org.apache.slide.store.RevisionDescriptorStore;
31
32
33 /**
34  */

35 public class TransientDescriptorStore extends AbstractTransientStore implements
36       RevisionDescriptorStore
37 {
38    // Note: we don't clone the descriptors because ExtendedStore does
39

40    public NodeRevisionDescriptor retrieveRevisionDescriptor(Uri uri,
41          NodeRevisionNumber revisionNumber) throws ServiceAccessException,
42          RevisionDescriptorNotFoundException
43    {
44       debug("retrieveRevisionDescriptor {0} {1}", uri, revisionNumber);
45       NodeRevisionDescriptor descriptor =
46          (NodeRevisionDescriptor)get(new VersionedUriKey(uri, revisionNumber));
47       if (descriptor != null) {
48          return descriptor;
49       } else {
50          throw new RevisionDescriptorNotFoundException(uri.toString());
51       }
52    }
53
54    public void createRevisionDescriptor(Uri uri,
55          NodeRevisionDescriptor revisionDescriptor)
56          throws ServiceAccessException
57    {
58       debug("createRevisionDescriptor {0} {1}", uri, revisionDescriptor.getRevisionNumber());
59       put(new VersionedUriKey(uri, revisionDescriptor.getRevisionNumber()),
60             revisionDescriptor);
61    }
62
63    public void storeRevisionDescriptor(Uri uri,
64          NodeRevisionDescriptor revisionDescriptor)
65          throws ServiceAccessException, RevisionDescriptorNotFoundException
66    {
67       debug("createRevisionDescriptor {0} {1}", uri, revisionDescriptor.getRevisionNumber());
68       VersionedUriKey key = new VersionedUriKey(uri,
69             revisionDescriptor.getRevisionNumber());
70       NodeRevisionDescriptor descriptor = (NodeRevisionDescriptor)get(key);
71       if (descriptor != null) {
72          put(key, revisionDescriptor);
73       } else {
74          throw new RevisionDescriptorNotFoundException(uri.toString());
75       }
76    }
77
78    public void removeRevisionDescriptor(Uri uri,
79          NodeRevisionNumber revisionNumber) throws ServiceAccessException
80    {
81       debug("removeRevisionDescriptor {0} {1}", uri, revisionNumber);
82       remove(new VersionedUriKey(uri, revisionNumber));
83    }
84 }
85
Popular Tags