KickJava   Java API By Example, From Geeks To Geeks.

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


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.Collection JavaDoc;
21
22 import org.alfresco.service.cmr.repository.ContentData;
23 import org.alfresco.service.cmr.repository.NodeRef;
24 import org.alfresco.service.cmr.security.AccessPermission;
25 import org.alfresco.service.cmr.view.ExportPackageHandler;
26 import org.alfresco.service.cmr.view.Exporter;
27 import org.alfresco.service.cmr.view.ExporterContext;
28 import org.alfresco.service.namespace.QName;
29 import org.alfresco.util.ParameterCheck;
30
31
32 /**
33  * Exporter that transforms content properties to URLs.
34  *
35  * All other Repository information is exported using the delegated exporter.
36  *
37  * @author David Caruana
38  */

39 /*package*/ class URLExporter
40     implements Exporter
41 {
42     private Exporter exporter;
43     private ExportPackageHandler streamHandler;
44
45     
46     /**
47      * Construct
48      * @param exporter exporter to delegate to
49      * @param streamHandler the handler for transforming content streams to URLs
50      */

51     public URLExporter(Exporter exporter, ExportPackageHandler streamHandler)
52     {
53         ParameterCheck.mandatory("Exporter", exporter);
54         ParameterCheck.mandatory("Stream Handler", streamHandler);
55         
56         this.exporter = exporter;
57         this.streamHandler = streamHandler;
58     }
59
60     
61     /* (non-Javadoc)
62      * @see org.alfresco.service.cmr.view.Exporter#start()
63      */

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

72     public void startNamespace(String JavaDoc prefix, String JavaDoc uri)
73     {
74         exporter.startNamespace(prefix, uri);
75     }
76
77     /* (non-Javadoc)
78      * @see org.alfresco.service.cmr.view.Exporter#endNamespace(java.lang.String)
79      */

80     public void endNamespace(String JavaDoc prefix)
81     {
82         exporter.endNamespace(prefix);
83     }
84
85     /* (non-Javadoc)
86      * @see org.alfresco.service.cmr.view.Exporter#startNode(org.alfresco.service.cmr.repository.NodeRef)
87      */

88     public void startNode(NodeRef nodeRef)
89     {
90         exporter.startNode(nodeRef);
91     }
92
93     /* (non-Javadoc)
94      * @see org.alfresco.service.cmr.view.Exporter#endNode(org.alfresco.service.cmr.repository.NodeRef)
95      */

96     public void endNode(NodeRef nodeRef)
97     {
98         exporter.endNode(nodeRef);
99     }
100
101     /* (non-Javadoc)
102      * @see org.alfresco.service.cmr.view.Exporter#startAspects(org.alfresco.service.cmr.repository.NodeRef)
103      */

104     public void startAspects(NodeRef nodeRef)
105     {
106         exporter.startAspects(nodeRef);
107     }
108
109     /* (non-Javadoc)
110      * @see org.alfresco.service.cmr.view.Exporter#endAspects(org.alfresco.service.cmr.repository.NodeRef)
111      */

112     public void endAspects(NodeRef nodeRef)
113     {
114         exporter.endAspects(nodeRef);
115     }
116
117     /* (non-Javadoc)
118      * @see org.alfresco.service.cmr.view.Exporter#startAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
119      */

120     public void startAspect(NodeRef nodeRef, QName aspect)
121     {
122         exporter.startAspect(nodeRef, aspect);
123     }
124
125     /* (non-Javadoc)
126      * @see org.alfresco.service.cmr.view.Exporter#endAspect(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
127      */

128     public void endAspect(NodeRef nodeRef, QName aspect)
129     {
130         exporter.endAspect(nodeRef, aspect);
131     }
132
133     /* (non-Javadoc)
134      * @see org.alfresco.service.cmr.view.Exporter#startACL(org.alfresco.service.cmr.repository.NodeRef)
135      */

136     public void startACL(NodeRef nodeRef)
137     {
138         exporter.startACL(nodeRef);
139     }
140
141     /* (non-Javadoc)
142      * @see org.alfresco.service.cmr.view.Exporter#permission(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.security.AccessPermission)
143      */

144     public void permission(NodeRef nodeRef, AccessPermission permission)
145     {
146         exporter.permission(nodeRef, permission);
147     }
148
149     /* (non-Javadoc)
150      * @see org.alfresco.service.cmr.view.Exporter#endACL(org.alfresco.service.cmr.repository.NodeRef)
151      */

152     public void endACL(NodeRef nodeRef)
153     {
154         exporter.endACL(nodeRef);
155     }
156     
157     /* (non-Javadoc)
158      * @see org.alfresco.service.cmr.view.Exporter#startProperties(org.alfresco.service.cmr.repository.NodeRef)
159      */

160     public void startProperties(NodeRef nodeRef)
161     {
162         exporter.startProperties(nodeRef);
163     }
164
165     /* (non-Javadoc)
166      * @see org.alfresco.service.cmr.view.Exporter#endProperties(org.alfresco.service.cmr.repository.NodeRef)
167      */

168     public void endProperties(NodeRef nodeRef)
169     {
170         exporter.endProperties(nodeRef);
171     }
172     
173     /* (non-Javadoc)
174      * @see org.alfresco.service.cmr.view.Exporter#startProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
175      */

176     public void startProperty(NodeRef nodeRef, QName property)
177     {
178         exporter.startProperty(nodeRef, property);
179     }
180
181     /* (non-Javadoc)
182      * @see org.alfresco.service.cmr.view.Exporter#endProperty(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
183      */

184     public void endProperty(NodeRef nodeRef, QName property)
185     {
186         exporter.endProperty(nodeRef, property);
187     }
188
189     /* (non-Javadoc)
190      * @see org.alfresco.service.cmr.view.Exporter#value(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.io.Serializable)
191      */

192     public void value(NodeRef nodeRef, QName property, Object JavaDoc value)
193     {
194         exporter.value(nodeRef, property, value);
195     }
196
197     /* (non-Javadoc)
198      * @see org.alfresco.service.cmr.view.Exporter#value(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.util.Collection)
199      */

200     public void value(NodeRef nodeRef, QName property, Collection JavaDoc values)
201     {
202         exporter.value(nodeRef, property, values);
203     }
204     
205     /* (non-Javadoc)
206      * @see org.alfresco.service.cmr.view.Exporter#content(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.io.InputStream)
207      */

208     public void content(NodeRef nodeRef, QName property, InputStream JavaDoc content, ContentData contentData)
209     {
210         // Handle the stream by converting it to a URL and export the URL
211
ContentData exportedContentData = streamHandler.exportContent(content, contentData);
212         value(nodeRef, property, exportedContentData.toString());
213     }
214
215     /* (non-Javadoc)
216      * @see org.alfresco.service.cmr.view.Exporter#startAssoc(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
217      */

218     public void startAssoc(NodeRef nodeRef, QName assoc)
219     {
220         exporter.startAssoc(nodeRef, assoc);
221     }
222
223     /* (non-Javadoc)
224      * @see org.alfresco.service.cmr.view.Exporter#endAssoc(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
225      */

226     public void endAssoc(NodeRef nodeRef, QName assoc)
227     {
228         exporter.endAssoc(nodeRef, assoc);
229     }
230
231     /* (non-Javadoc)
232      * @see org.alfresco.service.cmr.view.Exporter#startAssocs(org.alfresco.service.cmr.repository.NodeRef)
233      */

234     public void startAssocs(NodeRef nodeRef)
235     {
236         exporter.startAssocs(nodeRef);
237     }
238
239     /* (non-Javadoc)
240      * @see org.alfresco.service.cmr.view.Exporter#endAssocs(org.alfresco.service.cmr.repository.NodeRef)
241      */

242     public void endAssocs(NodeRef nodeRef)
243     {
244         exporter.endAssocs(nodeRef);
245     }
246
247     /* (non-Javadoc)
248      * @see org.alfresco.service.cmr.view.Exporter#startReference(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName)
249      */

250     public void startReference(NodeRef nodeRef, QName childName)
251     {
252         exporter.startReference(nodeRef, childName);
253     }
254
255     /*
256      * (non-Javadoc)
257      * @see org.alfresco.service.cmr.view.Exporter#endReference(org.alfresco.service.cmr.repository.NodeRef)
258      */

259     public void endReference(NodeRef nodeRef)
260     {
261         exporter.endReference(nodeRef);
262     }
263
264     /* (non-Javadoc)
265      * @see org.alfresco.service.cmr.view.Exporter#warning(java.lang.String)
266      */

267     public void warning(String JavaDoc warning)
268     {
269         exporter.warning(warning);
270     }
271
272     /* (non-Javadoc)
273      * @see org.alfresco.service.cmr.view.Exporter#end()
274      */

275     public void end()
276     {
277         exporter.end();
278     }
279
280 }
281
Popular Tags