KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > publisher > serverimpl > requestmodel > PrepareDocumentRequest


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.publisher.serverimpl.requestmodel;
17
18 import org.xml.sax.ContentHandler JavaDoc;
19 import org.outerj.daisy.publisher.serverimpl.docpreparation.ContentProcessor;
20 import org.outerj.daisy.publisher.serverimpl.docpreparation.PreparationPipe;
21 import org.outerj.daisy.publisher.serverimpl.docpreparation.PreparedDocuments;
22 import org.outerj.daisy.publisher.PublisherException;
23 import org.outerj.daisy.repository.Document;
24 import org.outerj.daisy.repository.Version;
25
26 import java.util.Set JavaDoc;
27
28 public class PrepareDocumentRequest implements Request {
29     private final Set JavaDoc inlineParts;
30
31     public PrepareDocumentRequest(Set JavaDoc inlineParts) {
32         this.inlineParts = inlineParts;
33     }
34
35     public void process(ContentHandler JavaDoc contentHandler, PublisherContext publisherContext) throws Exception JavaDoc {
36         PreparedDocuments preparedDocuments = publisherContext.getPreparedDocuments();
37         if (preparedDocuments == null)
38             throw new PublisherException("prepareDocument was used outside the context of a preparedDocuments request");
39
40         Document document = publisherContext.getDocument();
41         Version version = publisherContext.getVersion();
42         if (document == null || version == null)
43             return;
44
45         ContentProcessor contentProcessor = publisherContext.getContentProcessor();
46         PreparationPipe preparationPipe;
47         if (contentProcessor == null) {
48             preparationPipe = new PreparationPipe(publisherContext.getRepository(),
49                     publisherContext.getLogger(), publisherContext.getLocale(),
50                     preparedDocuments.getNavigationDoc(), publisherContext.getVersionMode());
51         } else {
52             // for prepareDocument requests of included documents
53
preparationPipe = contentProcessor.getPreparationPipe();
54         }
55         preparationPipe.process(contentProcessor, document, version, publisherContext, inlineParts, contentHandler);
56     }
57 }
58
Popular Tags