KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > repository > commonimpl > schema > RepositorySchemaImpl


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

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 JavaDoc name) {
34         return createDocumentType(name);
35     }
36
37     public DocumentType createDocumentType(String JavaDoc 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 JavaDoc name, ValueType valueType) {
46         return createFieldType(name, valueType);
47     }
48
49     public FieldType createFieldType(String JavaDoc name, ValueType valueType) {
50         return createFieldType(name, valueType, false);
51     }
52
53     public FieldType createFieldType(String JavaDoc 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 JavaDoc name, String JavaDoc mimeTypes) {
62         return createPartType(name, mimeTypes);
63     }
64
65     public PartType createPartType(String JavaDoc name, String JavaDoc 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 JavaDoc 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 JavaDoc 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 JavaDoc name, boolean updateable) throws RepositoryException {
106         return delegate.getDocumentTypeByName(name, updateable, user);
107     }
108
109     public DocumentType getDocumentType(String JavaDoc nameOrId, boolean updateable) throws RepositoryException {
110         if (nameOrId == null || nameOrId.length() == 0)
111             throw new IllegalArgumentException JavaDoc("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 JavaDoc 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