/** * Method addData * * @param contentListResource */ public void addData(ContentListResource contentListResource) { if ( !(contentListResource instanceof ContentListResource) ) { throw new ClassCastException( "ContentListResourceResponse.addData(contentListResource) parameter must be instanceof " + ContentListResource.class.getName() ); } getData().add( contentListResource ); } //-- void addData(ContentListResource)
@SuppressWarnings("unchecked") public List<ContentListResource> getContentListResource( String repoId, String path, boolean isGroup ) throws IOException { Response response = this.getResponse( repoId, path, isGroup ); String responeText = response.getEntity().getText(); Assert.assertTrue( "Expected sucess: Status was: " + response.getStatus() + "\nResponse:\n" + responeText, response.getStatus().isSuccess() ); XStreamRepresentation representation = new XStreamRepresentation( this.xstream, responeText, this.mediaType ); ContentListResourceResponse listRepsonse = (ContentListResourceResponse) representation .getPayload( new ContentListResourceResponse() ); return listRepsonse.getData(); } }
ContentListResourceResponse response = new ContentListResourceResponse(); : -1); response.addData(resource);
/** * @deprecated This is half baked stuff */ public ContentListResourceResponse downloadRepoIndexContent(String repoId) throws IOException { String serviceURI = "service/local/repositories/" + repoId + "/index_content/"; String responseText = nexusRestClient.doGetForText(serviceURI); XStreamRepresentation re = new XStreamRepresentation(XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML); return (ContentListResourceResponse) re.getPayload(new ContentListResourceResponse()); }
public List<ContentListResource> getContentListResource(String repoId, String path, boolean isGroup) throws IOException { Response response = this.getResponse(repoId, path, isGroup); String responeText = response.getEntity().getText(); Assert.assertTrue( "Expected sucess: Status was: " + response.getStatus() + "\nResponse:\n" + responeText, response.getStatus().isSuccess()); XStreamRepresentation representation = new XStreamRepresentation(this.xstream, responeText, this.mediaType); ContentListResourceResponse listRepsonse = (ContentListResourceResponse) representation .getPayload(new ContentListResourceResponse()); return listRepsonse.getData(); } }
ContentListResourceResponse response = new ContentListResourceResponse(); response.addData( resource );
/** * @param repoId * @return * @throws java.io.IOException * @deprecated This is half baked stuff */ public ContentListResourceResponse downloadRepoIndexContent( String repoId ) throws IOException { String serviceURI = "service/local/repositories/" + repoId + "/index_content/"; String responseText = nexusRestClient.doGetForText( serviceURI ); XStreamRepresentation re = new XStreamRepresentation( XStreamFactory.getXmlXStream(), responseText, MediaType.APPLICATION_XML ); ContentListResourceResponse resourceResponse = (ContentListResourceResponse) re.getPayload( new ContentListResourceResponse() ); return resourceResponse; }
/** * Method removeData * * @param contentListResource */ public void removeData(ContentListResource contentListResource) { if ( !(contentListResource instanceof ContentListResource) ) { throw new ClassCastException( "ContentListResourceResponse.removeData(contentListResource) parameter must be instanceof " + ContentListResource.class.getName() ); } getData().remove( contentListResource ); } //-- void removeData(ContentListResource)
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; }
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; }