if( wup != null )
{
submitter = wup.getName();
}
if( title == null ) throw new PluginException(rb.getString("bugreporthandler.titlerequired"));
if( title.length() == 0 ) return "";
if( description == null ) description = "";
if( version == null ) version = "unknown";
Properties mappings = parseMappings( params.get( PARAM_MAPPINGS ) );
//
// Start things
//
try
{
StringWriter str = new StringWriter();
PrintWriter out = new PrintWriter( str );
Date d = new Date();
//
// Outputting of basic data
//
out.println("|"+mappings.getProperty(PARAM_TITLE,"Title")+"|"+title);
out.println("|"+mappings.getProperty("date","Date")+"|"+format.format(d));
out.println("|"+mappings.getProperty(PARAM_VERSION,"Version")+"|"+version);
if( submitter != null )
{
out.println("|"+mappings.getProperty("submitter","Submitter")+
"|"+submitter);
}
//
// Outputting the other parameters added to this.
//
for( Iterator<Map.Entry<String, String>> i = params.entrySet().iterator(); i.hasNext(); )
{
Map.Entry<String, String> entry = i.next();
if( entry.getKey().equals( PARAM_TITLE ) ||
entry.getKey().equals( PARAM_DESCRIPTION ) ||
entry.getKey().equals( PARAM_VERSION ) ||
entry.getKey().equals( PARAM_MAPPINGS ) ||
entry.getKey().equals( PARAM_PAGE ) ||
entry.getKey().startsWith("_") )
{
// Ignore this
}
else
{
//
// If no mapping has been defined, just ignore
// it.
//
String head = mappings.getProperty( entry.getKey(), entry.getKey() );
if( head.length() > 0 )
{
out.println("|"+head+
"|"+entry.getValue());
}
}
}
out.println();
out.println( description );
out.close();
//
// Now create a new page for this bug report
//
String pageName = findNextPage( context, title, params.get( PARAM_PAGE ) );
WikiPage newPage = new WikiPage( context.getEngine(), pageName );
WikiContext newContext = (WikiContext)context.clone();
newContext.setPage( newPage );
context.getEngine().saveText( newContext,
str.toString() );
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern( rb.getString("bugreporthandler.new") );
String[] args = { "<a href=\""+context.getViewURL(pageName)+"\">"+pageName+"</a>" };
return formatter.format( args );
}
catch( RedirectException e )
{
log.info("Saving not allowed, reason: '"+e.getMessage()+"', can't redirect to "+e.getRedirect());
throw new PluginException("Saving not allowed, reason: "+e.getMessage());
}
catch( WikiException e )
{
log.error("Unable to save page!",e);