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.ui.admin;
020
021 import java.io.IOException;
022 import java.util.Map;
023
024 import javax.servlet.http.HttpServletRequest;
025 import javax.servlet.http.HttpServletResponse;
026
027 import org.apache.wiki.WikiContext;
028 import org.apache.wiki.parser.WikiDocument;
029 import org.apache.wiki.render.RenderingManager;
030
031 /**
032 * This class is still experimental.
033 *
034 */
035 public abstract class WikiFormAdminBean
036 implements AdminBean
037 {
038 public abstract String getForm( WikiContext context );
039
040 public abstract void handleResponse( WikiContext context, Map params );
041
042 public String doGet(WikiContext context)
043 {
044 String result = "";
045
046 String wikiMarkup = getForm(context);
047
048 RenderingManager mgr = context.getEngine().getRenderingManager();
049
050 WikiDocument doc;
051 try
052 {
053 doc = mgr.getParser( context, wikiMarkup ).parse();
054 result = mgr.getHTML(context, doc);
055 }
056 catch (IOException e)
057 {
058 // TODO Auto-generated catch block
059 e.printStackTrace();
060 }
061
062 return result;
063 }
064
065 public String handlePost(WikiContext context, HttpServletRequest req, HttpServletResponse resp)
066 {
067 return null;
068 // FIXME: Not yet implemented
069 }
070 }