1 package org.apache.maven.doxia.siterenderer; 2 3 /* 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 */ 21 22 import java.io.File; 23 import java.io.FileNotFoundException; 24 import java.io.IOException; 25 import java.io.UnsupportedEncodingException; 26 import java.io.Writer; 27 import java.net.MalformedURLException; 28 import java.util.Collection; 29 import java.util.Locale; 30 import java.util.Map; 31 32 import org.apache.maven.artifact.Artifact; 33 import org.apache.maven.doxia.site.decoration.DecorationModel; 34 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink; 35 36 /** 37 * <p>Site Renderer interface: render a collection of documents into a site, ie decored with a site template 38 * (eventually packaged as skin).</p> 39 * 40 * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a> 41 */ 42 public interface Renderer // TODO rename to SiteRenderer 43 { 44 /** 45 * Plexus lookup role. 46 */ 47 String ROLE = Renderer.class.getName(); 48 49 /** 50 * Render a collection of documents into a site. 51 * 52 * @param documents the documents to render. 53 * @param siteRenderingContext the SiteRenderingContext to use. 54 * @param outputDirectory the output directory to write results. 55 * @throws RendererException if it bombs. 56 * @throws IOException if it bombs. 57 */ 58 void render( Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, 59 File outputDirectory ) 60 throws RendererException, IOException; 61 62 /** 63 * Generate a document output from a Doxia SiteRenderer Sink, i.e. merge the document content into 64 * the site template. 65 * 66 * @param writer the Writer to use. 67 * @param sink the Site Renderer Sink that received the Doxia events during document content rendering. 68 * @param siteRenderingContext the SiteRenderingContext to use. 69 * @throws RendererException if it bombs. 70 * @deprecated since 1.8, use mergeDocumentIntoSite 71 */ 72 void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext ) 73 throws RendererException; 74 75 /** 76 * Generate a document output integrated in a site from a document content, 77 * i.e. merge the document content into the site template. 78 * 79 * @param writer the Writer to use. 80 * @param content the document content to be merged 81 * @param siteRenderingContext the SiteRenderingContext to use. 82 * @throws RendererException if it bombs. 83 * @since 1.8 84 */ 85 void mergeDocumentIntoSite( Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext ) 86 throws RendererException; 87 88 /** 89 * Create a Site Rendering Context for a site using a skin. 90 * 91 * @param skin 92 * @param attributes 93 * @param decoration 94 * @param defaultWindowTitle 95 * @param locale 96 * @return a SiteRenderingContext. 97 * @throws java.io.IOException if it bombs. 98 * @since 1.7.3 was previously with skin as File instead of Artifact 99 */ 100 SiteRenderingContext createContextForSkin( Artifact skin, Map<String, ?> attributes, DecorationModel decoration, 101 String defaultWindowTitle, Locale locale ) 102 throws RendererException, IOException; 103 104 /** 105 * Create a Site Rendering Context for a site using a local template. 106 * 107 * @param templateFile 108 * @param attributes 109 * @param decoration 110 * @param defaultWindowTitle 111 * @param locale 112 * @return a SiteRenderingContext. 113 * @throws MalformedURLException if it bombs. 114 * @since 1.7, had an additional skinFile parameter before 115 * @deprecated Deprecated without replacement, use skins only. 116 * @see #createContextForSkin(File, Map, DecorationModel, String, Locale) 117 */ 118 @Deprecated 119 SiteRenderingContext createContextForTemplate( File templateFile, Map<String, ?> attributes, 120 DecorationModel decoration, String defaultWindowTitle, 121 Locale locale ) 122 throws MalformedURLException; 123 124 /** 125 * Copy resource files. 126 * 127 * @param siteRenderingContext 128 * @param resourcesDirectory 129 * @param outputDirectory 130 * @throws IOException if it bombs. 131 * @deprecated since 1.7, use copyResources without resourcesDirectory parameter 132 */ 133 void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory, File outputDirectory ) 134 throws IOException; 135 136 /** 137 * Copy resource files from skin, template, and site resources. 138 * 139 * @param siteRenderingContext 140 * @param outputDirectory 141 * @throws IOException if it bombs. 142 * @since 1.7 143 */ 144 void copyResources( SiteRenderingContext siteRenderingContext, File outputDirectory ) 145 throws IOException; 146 147 /** 148 * Locate Doxia document source files in the site source context. 149 * 150 * @param siteRenderingContext 151 * @return the Doxia document renderers in a Map keyed by output file name. 152 * @throws IOException if it bombs. 153 * @throws RendererException if it bombs. 154 * @deprecated since 1.8, use locateDocumentFiles with editable parameter 155 */ 156 Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext ) 157 throws IOException, RendererException; 158 159 /** 160 * Locate Doxia document source files in the site source context. 161 * 162 * @param siteRenderingContext 163 * @param mark Doxia document renderer as editable? (should not mark editable if generated Doxia source) 164 * @return the Doxia document renderers in a Map keyed by output file name. 165 * @throws IOException if it bombs. 166 * @throws RendererException if it bombs. 167 * @since 1.8 168 */ 169 Map<String, DocumentRenderer> locateDocumentFiles( SiteRenderingContext siteRenderingContext, boolean editable ) 170 throws IOException, RendererException; 171 172 /** 173 * Render a document written in a Doxia markup language. This method is an internal method, used by 174 * {@link DoxiaDocumentRenderer}. 175 * 176 * @param writer the writer to render the document to. 177 * @param docRenderingContext the document's rendering context, which is expected to have a non-null parser id. 178 * @param siteContext the site's rendering context 179 * @throws RendererException if it bombs. 180 * @throws FileNotFoundException if it bombs. 181 * @throws UnsupportedEncodingException if it bombs. 182 */ 183 void renderDocument( Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext ) 184 throws RendererException, FileNotFoundException, UnsupportedEncodingException; 185 }