public Representation represent(Variant variant) throws ResourceException { Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer,"script", makeDataModel()); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { ScriptResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
public Representation represent(Variant variant) throws ResourceException { Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer, "engine", makeDataModel()); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { EngineResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
public Representation represent(Variant variant) throws ResourceException { if (appCtx == null) { throw new ResourceException(404); } Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer, "beans", makeDataModel()); } }; } else { representation = new WriterRepresentation( MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { BeanBrowseResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
public Representation represent(Variant variant) throws ResourceException { if (cj == null) { throw new ResourceException(404); } Representation representation = null; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { CrawlJobModel model = makeDataModel(); model.put("heapReport", getEngine().heapReportData()); XmlMarshaller.marshalDocument(writer, "job", model); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { JobResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? // honor requested charset? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
protected Object renderHeadResponseItem( Context context, Request req, Response res, Variant variant, ResourceStore store, ResourceStoreRequest request, StorageCollectionItem coll ) throws IOException, AccessDeniedException, NoSuchResourceStoreException, IllegalOperationException, ItemNotFoundException, StorageException, ResourceException { // we are just returning anything, the connector will strip off content anyway. return new StorageItemRepresentation( variant.getMediaType(), coll ); }
protected Object renderHeadResponseItem(Context context, Request req, Response res, Variant variant, ResourceStore store, ResourceStoreRequest request, StorageCollectionItem coll) throws IOException, AccessDeniedException, NoSuchResourceStoreException, IllegalOperationException, ItemNotFoundException, StorageException, ResourceException { // we are just returning anything, the connector will strip off content anyway. return new StorageItemRepresentation(variant.getMediaType(), coll); }
public Representation represent(Variant variant) throws ResourceException { Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer, "engine", makeDataModel()); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { EngineResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
public Representation represent(Variant variant) throws ResourceException { Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer,"script", makeDataModel()); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { ScriptResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); 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", applicationStatusSource.getSystemStatus().getVersion()); dataModel.put("nexusRoot", BaseUrlHolder.get()); final VelocityRepresentation representation = new VelocityRepresentation(context, "/templates/repositoryContentHtml.vm", getClass().getClassLoader(), dataModel, variant.getMediaType()); return representation; } return null; }
/** * Returns an actual index representation for a given variant. * * @param variant * The selected variant. * @param indexContent * The directory index to represent. * @return The actual index representation. */ public Representation getIndexRepresentation(Variant variant, ReferenceList indexContent) { Representation result = null; if (variant.getMediaType().equals(MediaType.TEXT_HTML)) { result = indexContent.getWebRepresentation(); } else if (variant.getMediaType().equals(MediaType.TEXT_URI_LIST)) { result = indexContent.getTextRepresentation(); } return result; }
public Representation represent(Variant variant) throws ResourceException { if (appCtx == null) { throw new ResourceException(404); } Representation representation; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { XmlMarshaller.marshalDocument(writer, "beans", makeDataModel()); } }; } else { representation = new WriterRepresentation( MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { BeanBrowseResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? representation.setCharacterSet(CharacterSet.UTF_8); return representation; }
public Representation represent(Variant variant) throws ResourceException { if (cj == null) { throw new ResourceException(404); } Representation representation = null; if (variant.getMediaType() == MediaType.APPLICATION_XML) { representation = new WriterRepresentation(MediaType.APPLICATION_XML) { public void write(Writer writer) throws IOException { CrawlJobModel model = makeDataModel(); model.put("heapReport", getEngine().heapReportData()); XmlMarshaller.marshalDocument(writer, "job", model); } }; } else { representation = new WriterRepresentation(MediaType.TEXT_HTML) { public void write(Writer writer) throws IOException { JobResource.this.writeHtml(writer); } }; } // TODO: remove if not necessary in future? // honor requested charset? representation.setCharacterSet(CharacterSet.UTF_8); 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; }
if ( MediaType.TEXT_HTML.equals( variant.getMediaType() ) )
if (MediaType.TEXT_HTML.equals(variant.getMediaType())) { Representation result = serialize(context, req, variant, response);
public Object get(Context context, Request request, Response response, Variant variant) throws ResourceException MediaType mediaType = variant.getMediaType();