1 16 package org.outerj.daisy.repository.commonimpl.schema; 17 18 import org.outerj.daisy.repository.schema.*; 19 import org.outerj.daisy.repository.ValueType; 20 import org.outerj.daisy.repository.RepositoryException; 21 import org.outerj.daisy.repository.LinkExtractorInfos; 22 import org.outerj.daisy.repository.commonimpl.AuthenticatedUser; 23 24 public class RepositorySchemaImpl implements RepositorySchema { 25 private final CommonRepositorySchema delegate; 26 private final AuthenticatedUser user; 27 28 public RepositorySchemaImpl(CommonRepositorySchema delegate, AuthenticatedUser user) { 29 this.delegate = delegate; 30 this.user = user; 31 } 32 33 public DocumentType createNewDocumentType(String name) { 34 return createDocumentType(name); 35 } 36 37 public DocumentType createDocumentType(String name) { 38 return delegate.createDocumentType(name, user); 39 } 40 41 public void deleteDocumentType(long documentTypeId) throws RepositoryException { 42 delegate.deleteDocumentType(documentTypeId, user); 43 } 44 45 public FieldType createNewFieldType(String name, ValueType valueType) { 46 return createFieldType(name, valueType); 47 } 48 49 public FieldType createFieldType(String name, ValueType valueType) { 50 return createFieldType(name, valueType, false); 51 } 52 53 public FieldType createFieldType(String name, ValueType valueType, boolean multiValue) { 54 return delegate.createFieldType(name, valueType, multiValue, user); 55 } 56 57 public void deleteFieldType(long fieldTypeId) throws RepositoryException { 58 delegate.deleteFieldType(fieldTypeId, user); 59 } 60 61 public PartType createNewPartType(String name, String mimeTypes) { 62 return createPartType(name, mimeTypes); 63 } 64 65 public PartType createPartType(String name, String mimeTypes) { 66 return delegate.createPartType(name, mimeTypes, user); 67 } 68 69 public void deletePartType(long partTypeId) throws RepositoryException { 70 delegate.deletePartType(partTypeId, user); 71 } 72 73 public DocumentTypes getAllDocumentTypes(boolean updateable) throws RepositoryException { 74 return delegate.getAllDocumentTypes(updateable, user); 75 } 76 77 public FieldTypes getAllFieldTypes(boolean updateable) throws RepositoryException { 78 return delegate.getAllFieldTypes(updateable, user); 79 } 80 81 public PartTypes getAllPartTypes(boolean updateable) throws RepositoryException { 82 return delegate.getAllPartTypes(updateable, user); 83 } 84 85 public PartType getPartTypeById(long id, boolean updateable) throws RepositoryException { 86 return delegate.getPartTypeById(id, updateable, user); 87 } 88 89 public PartType getPartTypeByName(String name, boolean updateable) throws RepositoryException { 90 return delegate.getPartTypeByName(name, updateable, user); 91 } 92 93 public FieldType getFieldTypeById(long id, boolean updateable) throws RepositoryException { 94 return delegate.getFieldTypeById(id, updateable, user); 95 } 96 97 public FieldType getFieldTypeByName(String name, boolean updateable) throws RepositoryException { 98 return delegate.getFieldTypeByName(name, updateable, user); 99 } 100 101 public DocumentType getDocumentTypeById(long id, boolean updateable) throws RepositoryException { 102 return delegate.getDocumentTypeById(id, updateable, user); 103 } 104 105 public DocumentType getDocumentTypeByName(String name, boolean updateable) throws RepositoryException { 106 return delegate.getDocumentTypeByName(name, updateable, user); 107 } 108 109 public DocumentType getDocumentType(String nameOrId, boolean updateable) throws RepositoryException { 110 if (nameOrId == null || nameOrId.length() == 0) 111 throw new IllegalArgumentException ("nameOrId: null or empty"); 112 113 if (nameOrId.length() > 0 && Character.isDigit(nameOrId.charAt(0))) { 114 try { 115 long id = Long.parseLong(nameOrId); 116 return getDocumentTypeById(id, updateable); 117 } catch (NumberFormatException e) { 118 throw new RepositoryException("Invalid document type name or ID: " + nameOrId); 119 } 120 121 } else { 122 return getDocumentTypeByName(nameOrId, updateable); 123 } 124 } 125 126 public void addListener(RepositorySchemaListener listener) { 127 delegate.addListener(listener); 128 } 129 130 public void removeListener(RepositorySchemaListener listener) { 131 delegate.removeListener(listener); 132 } 133 134 public LinkExtractorInfos getLinkExtractors() throws RepositoryException { 135 return delegate.getLinkExtractors(user); 136 } 137 } 138 | Popular Tags |