public Representation getRepresentation( final Status status, final Request request, final Response response ) { final HashMap<String, Object> dataModel = new HashMap<String, Object>(); dataModel.put( "request", request ); dataModel.put( "nexusVersion", nexus.getSystemStatus().getVersion() ); dataModel.put( "nexusRoot", referenceFactory.getContextRoot( request ).toString() ); dataModel.put( "statusCode", status.getCode() ); dataModel.put( "statusName", status.getName() ); dataModel.put( "errorDescription", StringEscapeUtils.escapeHtml( status.getDescription() ) ); if ( null != status.getThrowable() ) { dataModel.put( "errorStackTrace", StringEscapeUtils.escapeHtml( ExceptionUtils.getStackTrace( status.getThrowable() ) ) ); } // Load up the template, and pass in the data VelocityRepresentation representation = new VelocityRepresentation( Context.getCurrent(), "/templates/errorPageContentHtml.vm", dataModel, MediaType.TEXT_HTML ); return representation; } }
protected Representation serialize( Context context, Request req, Variant variant, Object payload ) throws IOException { // TEXT_HTML is requested by direct browsing (IE) // APPLICATION_XML is requested by direct browsing (FF) if ( MediaType.TEXT_HTML.equals( variant.getMediaType() ) ) { HashMap<String, Object> dataModel = new HashMap<String, Object>(); dataModel.put( "listItems", sortContentListResource( ( (ContentListResourceResponse) payload ).getData() ) ); dataModel.put( "request", req ); dataModel.put( "nexusVersion", getNexus().getSystemStatus().getVersion() ); dataModel.put( "nexusRoot", getContextRoot( req ).toString() ); // Load up the template, and pass in the data VelocityRepresentation representation = new VelocityRepresentation( context, "/templates/repositoryContentHtml.vm", dataModel, variant.getMediaType() ); return representation; } return null; }
templatingContext.put( "nexusVersion", nexus.getSystemStatus().getVersion() ); templatingContext.put( "appName", nexus.getSystemStatus().getAppName() ); templatingContext.put( "formattedAppName", nexus.getSystemStatus().getFormattedAppName() );
if ( SystemState.STARTED.equals( getNexus().getSystemStatus().getState() ) ) if ( SystemState.STARTED.equals( getNexus().getSystemStatus().getState() ) )
throws ResourceException SystemStatus status = this.nexus.getSystemStatus();