1 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 35 public class TransientDescriptorStore extends AbstractTransientStore implements 36 RevisionDescriptorStore 37 { 38 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 |