001 /*
002 Licensed to the Apache Software Foundation (ASF) under one
003 or more contributor license agreements. See the NOTICE file
004 distributed with this work for additional information
005 regarding copyright ownership. The ASF licenses this file
006 to you under the Apache License, Version 2.0 (the
007 "License"); you may not use this file except in compliance
008 with the License. You may obtain a copy of the License at
009
010 http://www.apache.org/licenses/LICENSE-2.0
011
012 Unless required by applicable law or agreed to in writing,
013 software distributed under the License is distributed on an
014 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 KIND, either express or implied. See the License for the
016 specific language governing permissions and limitations
017 under the License.
018 */
019 package org.apache.wiki.htmltowiki;
020
021 import org.apache.wiki.WikiContext;
022
023 /**
024 * Defines a Wiki configuration to XHtmlToWikiTranslator, including things like
025 * URLs.
026 *
027 */
028 public class XHtmlToWikiConfig
029 {
030 private String m_outlink = "outlink";
031
032 private String m_pageInfoJsp = "PageInfo.jsp";
033
034 private String m_wikiJspPage = "Wiki.jsp?page=";
035
036 private String m_editJspPage = "Edit.jsp?page=";
037
038 private String m_attachPage = "attach?page=";
039
040 private String m_pageName;
041
042 /**
043 * Creates a new, empty config object.
044 */
045 public XHtmlToWikiConfig()
046 {}
047
048 /**
049 * The constructor initializes the different internal fields
050 * according to the current URLConstructor.
051 *
052 * @param wikiContext A WikiContext
053 */
054 public XHtmlToWikiConfig( WikiContext wikiContext )
055 {
056 setWikiContext( wikiContext );
057
058 //
059 // Figure out the actual URLs.
060 //
061 // NB: The logic here will fail if you add something else after
062 // the Wiki page name in VIEW or ATTACH
063 //
064
065 m_wikiJspPage = wikiContext.getURL( WikiContext.VIEW, "" );
066
067 m_editJspPage = wikiContext.getURL( WikiContext.EDIT, "" );
068
069 m_attachPage = wikiContext.getURL( WikiContext.ATTACH, "" );
070
071 m_pageInfoJsp = wikiContext.getURL( WikiContext.INFO, "" );
072 }
073
074 private void setWikiContext( WikiContext wikiContext )
075 {
076 if( wikiContext.getPage() != null )
077 {
078 setPageName( wikiContext.getPage().getName() + '/' );
079 }
080 }
081
082 /**
083 * Return the URL for the attachments.
084 *
085 * @return URL for attachments.
086 */
087 public String getAttachPage()
088 {
089 return m_attachPage;
090 }
091
092 /**
093 * Set the URL for attachments.
094 *
095 * @param attachPage The attachment URL.
096 */
097 public void setAttachPage( String attachPage )
098 {
099 m_attachPage = attachPage;
100 }
101
102 /**
103 * Gets the URL of the outlink image.
104 *
105 * @return The URL of the outlink image.
106 */
107 public String getOutlink()
108 {
109 return m_outlink;
110 }
111
112 /**
113 * Set the outlink URL.
114 *
115 * @param outlink The outlink URL.
116 */
117 public void setOutlink( String outlink )
118 {
119 m_outlink = outlink;
120 }
121
122 /**
123 * Get the PageInfo.jsp URI.
124 *
125 * @return The URI for the page info display.
126 */
127 public String getPageInfoJsp()
128 {
129 return m_pageInfoJsp;
130 }
131
132 /**
133 * Set the URI for the page info display.
134 *
135 * @param pageInfoJsp URI for the page info.
136 */
137 public void setPageInfoJsp( String pageInfoJsp )
138 {
139 m_pageInfoJsp = pageInfoJsp;
140 }
141
142 /**
143 * Get the page name.
144 *
145 * @return The Page Name.
146 */
147 public String getPageName()
148 {
149 return m_pageName;
150 }
151
152
153 /**
154 * Set the page name.
155 *
156 * @param pageName The name of the page.
157 */
158 public void setPageName( String pageName )
159 {
160 m_pageName = pageName;
161 }
162
163 /**
164 * Get the URI to the Wiki.jsp view.
165 *
166 * @return The URI to the Wiki.jsp.
167 */
168 public String getWikiJspPage()
169 {
170 return m_wikiJspPage;
171 }
172
173 /**
174 * Set the URI to the Wiki.jsp.
175 *
176 * @param wikiJspPage The URI to the Wiki.jsp.
177 */
178 public void setWikiJspPage( String wikiJspPage )
179 {
180 m_wikiJspPage = wikiJspPage;
181 }
182
183 /**
184 * Return the URI to the Edit.jsp page.
185 *
186 * @return The URI to the Edit.jsp page.
187 */
188 public String getEditJspPage()
189 {
190 return m_editJspPage;
191 }
192
193 /**
194 * Set the URI to the Edit.jsp page.
195 *
196 * @param editJspPage The Edit.jsp URI.
197 */
198 public void setEditJspPage( String editJspPage )
199 {
200 m_editJspPage = editJspPage;
201 }
202 }