KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > exporter > ChainedExporter


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.repo.exporter;
18
19 import java.io.InputStream JavaDoc;
20 import java.util.ArrayList JavaDoc;
21 import java.util.Collection JavaDoc;
22 import java.util.List JavaDoc;
23
24 import org.alfresco.service.cmr.repository.ContentData;
25 import org.alfresco.service.cmr.repository.NodeRef;
26 import org.alfresco.service.cmr.security.AccessPermission;
27 import org.alfresco.service.cmr.view.Exporter;
28 import org.alfresco.service.cmr.view.ExporterContext;
29 import org.alfresco.service.namespace.QName;
30
31
32 /**
33  * Exporter that wraps one or more other exporters and invokes them in the provided order.
34  *
35  * @author David Caruana
36  */

37 /*package*/ class ChainedExporter
38     implements Exporter
39 {
40     private Exporter[] exporters;
41
42     
43     /**
44      * Construct
45      *
46      * @param exporters array of exporters to invoke
47      */

48     /*package*/ ChainedExporter(Exporter[] exporters)
49     {
50         List JavaDoc<Exporter> exporterList = new ArrayList JavaDoc<Exporter>();
51         for (Exporter exporter : exporters)
52         {
53             if (exporter != null)
54             {
55                 exporterList.add(exporter);
56             }
57         }
58         this.exporters = exporterList.toArray(new Exporter[exporterList.size()]);
59     }
60     
61     /* (non-Javadoc)
62      * @see org.alfresco.service.cmr.view.Exporter#start()
63      */

64     public void start(ExporterContext context)
65     {
66         for (Exporter exporter : exporters)
67         {
68             exporter.start(context);
69         }
70     }
71     
72     /* (non-Javadoc)
73      * @see org.alfresco.service.cmr.view.Exporter#startNamespace(java.lang.String, java.lang.String)
74      */

75     public void startNamespace(String JavaDoc prefix, String JavaDoc uri)
76     {
77         for (Exporter exporter : exporters)
78         {
79             exporter.startNamespace(prefix, uri);
80         }
81     }
82     
83     /* (non-Javadoc)
84      * @see org.alfresco.service.cmr.view.Exporter#endNamespace(java.lang.String)
85      */

86     public void endNamespace(String JavaDoc prefix)
87     {
88         for (Exporter exporter : exporters)
89         {
90             exporter.endNamespace(prefix);
91         }
92     }
93
94     /* (non-Javadoc)
95      * @see org.alfresco.service.cmr.view.Exporter#startNode(org.alfresco.service.cmr.repository.NodeRef)
96      */

97     public void startNode(NodeRef nodeRef)
98     {
99         for (Exporter exporter : exporters)
100         {
101             exporter.startNode(nodeRef);
102         }
103     }
104     
105     /* (non-Javadoc)
106      * @see org.alfresco.service.cmr.view.Exporter#endNode(org.alfresco.service.cmr.repository.NodeRef)
107      */

108     public void endNode(NodeRef nodeRef)
109     {
110         for (Exporter exporter : exporters)
111         {
112             exporter.endNode(nodeRef);
113         }
114     }
115     
116     /* (non-Javadoc)
117      * @see org.alfresco.service.cmr.view.Exporter#startAspects(org.alfresco.service.cmr.repository.NodeRef)
118      */

119     public void startAspects(NodeRef nodeRef)
120     {
121         for (Exporter exporter : exporters)
122         {
123             exporter.startAspects(nodeRef);
124         }
125     }
126
127     /* (non-Javadoc)
128      * @see org.alfresco.service.cmr.view.Exporter#endAspects(org.alfresco.service.cmr.repository.NodeRef)
129      */

130     public void endAspects(NodeRef nodeRef)
131     {
132         for (Exporter exporter : exporters)
133         {
134             exporter.endAspects(nodeRef);
135         }
136     }
137     
138     /* (non-Javadoc)
139      * @see org.alfresco.service.cmr.view.Exporter#startAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
140      */

141     public void startAspect(NodeRef nodeRef, QName aspect)
142     {
143         for (Exporter exporter : exporters)
144         {
145             exporter.startAspect(nodeRef, aspect);
146         }
147     }
148
149     /* (non-Javadoc)
150      * @see org.alfresco.service.cmr.view.Exporter#endAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
151      */

152     public void endAspect(NodeRef nodeRef, QName aspect)
153     {
154         for (Exporter exporter : exporters)
155         {
156             exporter.endAspect(nodeRef, aspect);
157         }
158     }
159
160     /* (non-Javadoc)
161      * @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
162      */

163     public void startACL(NodeRef nodeRef)
164     {
165         for (Exporter exporter : exporters)
166         {
167             exporter.startACL(nodeRef);
168         }
169     }
170
171     /* (non-Javadoc)
172      * @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
173      */

174     public void permission(NodeRef nodeRef, AccessPermission permission)
175     {
176         for (Exporter exporter : exporters)
177         {
178             exporter.permission(nodeRef, permission);
179         }
180     }
181
182     /* (non-Javadoc)
183      * @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
184      */

185     public void endACL(NodeRef nodeRef)
186     {
187         for (Exporter exporter : exporters)
188         {
189             exporter.endACL(nodeRef);
190         }
191     }
192
193     /* (non-Javadoc)
194      * @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
195      */

196     public void startProperties(NodeRef nodeRef)
197     {
198         for (Exporter exporter : exporters)
199         {
200             exporter.startProperties(nodeRef);
201         }
202     }
203
204     /* (non-Javadoc)
205      * @see org.alfresco.service.cmr.view.Exporter#endProperties(org.alfresco.service.cmr.repository.NodeRef)
206      */

207     public void endProperties(NodeRef nodeRef)
208     {
209         for (Exporter exporter : exporters)
210         {
211             exporter.endProperties(nodeRef);
212         }
213     }
214     
215     /* (non-Javadoc)
216      * @see org.alfresco.service.cmr.view.Exporter#startProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
217      */

218     public void startProperty(NodeRef nodeRef, QName property)
219     {
220         for (Exporter exporter : exporters)
221         {
222             exporter.startProperty(nodeRef, property);
223         }
224     }
225     
226     /* (non-Javadoc)
227      * @see org.alfresco.service.cmr.view.Exporter#endProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
228      */

229     public void endProperty(NodeRef nodeRef, QName property)
230     {
231         for (Exporter exporter : exporters)
232         {
233             exporter.endProperty(nodeRef, property);
234         }
235     }
236     
237     /* (non-Javadoc)
238      * @see org.alfresco.service.cmr.view.Exporter#value(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.io.Serializable)
239      */

240     public void value(NodeRef nodeRef, QName property, Object JavaDoc value)
241     {
242         for (Exporter exporter : exporters)
243         {
244             exporter.value(nodeRef, property, value);
245         }
246     }
247     
248     /* (non-Javadoc)
249      * @see org.alfresco.service.cmr.view.Exporter#value(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Collection)
250      */

251     public void value(NodeRef nodeRef, QName property, Collection JavaDoc values)
252     {
253         for (Exporter exporter : exporters)
254         {
255             exporter.value(nodeRef, property, values);
256         }
257     }
258     
259     /* (non-Javadoc)
260      * @see org.alfresco.service.cmr.view.Exporter#content(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.io.InputStream)
261      */

262     public void content(NodeRef nodeRef, QName property, InputStream JavaDoc content, ContentData contentData)
263     {
264         for (Exporter exporter : exporters)
265         {
266             exporter.content(nodeRef, property, content, contentData);
267         }
268     }
269     
270     /* (non-Javadoc)
271      * @see org.alfresco.service.cmr.view.Exporter#startAssoc(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
272      */

273     public void startAssoc(NodeRef nodeRef, QName assoc)
274     {
275         for (Exporter exporter : exporters)
276         {
277             exporter.startAssoc(nodeRef, assoc);
278         }
279     }
280     
281     /* (non-Javadoc)
282      * @see org.alfresco.service.cmr.view.Exporter#endAssoc(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
283      */

284     public void endAssoc(NodeRef nodeRef, QName assoc)
285     {
286         for (Exporter exporter : exporters)
287         {
288             exporter.endAssoc(nodeRef, assoc);
289         }
290     }
291     
292     /* (non-Javadoc)
293      * @see org.alfresco.service.cmr.view.Exporter#startAssocs(org.alfresco.service.cmr.repository.NodeRef)
294      */

295     public void startAssocs(NodeRef nodeRef)
296     {
297         for (Exporter exporter : exporters)
298         {
299             exporter.startAssocs(nodeRef);
300         }
301     }
302
303     /* (non-Javadoc)
304      * @see org.alfresco.service.cmr.view.Exporter#endAssocs(org.alfresco.service.cmr.repository.NodeRef)
305      */

306     public void endAssocs(NodeRef nodeRef)
307     {
308         for (Exporter exporter : exporters)
309         {
310             exporter.endAssocs(nodeRef);
311         }
312     }
313
314     /* (non-Javadoc)
315      * @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
316      */

317     public void startReference(NodeRef nodeRef, QName childName)
318     {
319         for (Exporter exporter : exporters)
320         {
321             exporter.startReference(nodeRef, childName);
322         }
323     }
324
325     /* (non-Javadoc)
326      * @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
327      */

328     public void endReference(NodeRef nodeRef)
329     {
330         for (Exporter exporter : exporters)
331         {
332             exporter.endReference(nodeRef);
333         }
334     }
335     
336     /* (non-Javadoc)
337      * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
338      */

339     public void warning(String JavaDoc warning)
340     {
341         for (Exporter exporter : exporters)
342         {
343             exporter.warning(warning);
344         }
345     }
346
347     /* (non-Javadoc)
348      * @see org.alfresco.service.cmr.view.Exporter#end()
349      */

350     public void end()
351     {
352         for (Exporter exporter : exporters)
353         {
354             exporter.end();
355         }
356     }
357
358 }
Popular Tags