@Override public void sendContent( OutputStream out, Range range, Map<String, String> params, String contentType ) throws IOException { ITemplate template = editee.getTemplate(); if( template == null ) { log.debug( "-- no template. using default" ); String sTemplate = FileUtils.readResource( this.getClass(), "defaultEdit.vel" ); VelocityContext vc = new VelocityContext(); vc.put( "editee", editee ); vc.put( "targetPage", this ); vc.put( "params", params ); RenderContext rc = new RenderContext( template, editee, null, true ); vc.put( "renderContext", rc ); VelocityInterpreter.evalToStream( sTemplate, vc, out ); out.flush(); } else { log.trace("generate edit page with template: " + template.getName()); RenderContext rc = new RenderContext( template, editee, null, true ); if( params != null && params.size() > 0 ) { editee.preProcess(rc, params, null); } String s = editee.render( rc, params, template, true); //String s = template.render( rc, params, template); if( s == null ) { log.warn( "Got null content for editee: " + editee.getHref() ); return; } else { out.write( s.getBytes() ); } } }
@Override public String checkRedirect( Request request ) { //return null; if( editee instanceof ISubPage) { String s = editee.getParent().getHref(); if( !s.endsWith("/")) s += "/"; s = s + ".edit"; return s; } else { return null; } }
/** TODO: move editing logic to here from Page */ @Override public String processForm( Map<String, String> parameters, Map<String, FileItem> files ) throws NotAuthorizedException { return editee.processForm( parameters, files ); }
@Override public String getRealm() { return editee.getRealm(); }
@Override public Object authenticate( DigestResponse digestRequest ) { return editee.authenticate( digestRequest ); }
@Override public Object authenticate( String user, String password ) { return editee.authenticate( user, password ); }
@Override public String getName() { return editee.getName() + ".edit"; }