1 16 package org.outerj.daisy.repository.commonimpl; 17 18 import org.outerj.daisy.repository.CollectionManager; 19 import org.outerj.daisy.repository.DocumentCollection; 20 import org.outerj.daisy.repository.DocumentCollections; 21 import org.outerj.daisy.repository.RepositoryException; 22 23 24 public class CollectionManagerImpl implements CollectionManager { 25 private CommonCollectionManager delegate; 26 private AuthenticatedUser user; 27 28 public CollectionManagerImpl(CommonCollectionManager delegate, AuthenticatedUser user) { 29 this.delegate = delegate; 30 this.user = user; 31 } 32 33 public DocumentCollection createCollection(String name) 34 throws RepositoryException { 35 return delegate.createCollection(name, user); 36 } 37 38 public DocumentCollection getCollection(long collectionId, boolean updateable) throws RepositoryException { 39 return delegate.getCollection(collectionId, updateable, user); 40 } 41 42 public DocumentCollection getCollection(String collection, boolean updateable) throws RepositoryException { 43 if (collection == null) 44 throw new IllegalArgumentException ("collection param can not be null"); 45 if (collection.length() == 0) 46 throw new IllegalArgumentException ("collection param cannot be an empty string"); 47 48 if (Character.isDigit(collection.charAt(0))) { 49 long id; 50 try { 51 id = Long.parseLong(collection); 52 } catch (NumberFormatException e) { 53 throw new RepositoryException("Invalid collection specification: " + collection); 54 } 55 return getCollection(id, updateable); 56 } else { 57 return getCollectionByName(collection, updateable); 58 } 59 } 60 61 public DocumentCollection getCollectionByName(String name, boolean updateable) throws RepositoryException { 62 return delegate.getCollectionByName(name, updateable, user); 63 } 64 65 public DocumentCollections getCollections(boolean updateable) throws RepositoryException { 66 return delegate.getCollections(updateable, user); 67 } 68 69 public void deleteCollection(long collectionId) throws RepositoryException { 70 delegate.deleteCollection(collectionId, user); 71 } 72 73 } 74 | Popular Tags |