NexusStreamResponse response = new NexusStreamResponse(); response.setName( fileName ); response.setMimeType( "text/xml" ); response.setMimeType( "text/plain" ); response.setSize( configFile.length() ); response.setFromByte( 0 ); response.setBytesCount( configFile.length() ); response.setInputStream( new FileInputStream( configFile ) );
public NexusStreamResponse getConfigurationAsStream() throws IOException { NexusStreamResponse response = new NexusStreamResponse(); response.setName( "current" ); response.setMimeType( "text/xml" ); // TODO: response.setSize( 0 ); response.setInputStream( nexusConfiguration.getConfigurationSource().getConfigurationAsStream() ); return response; }
/** * Returns the requested Nexus configuration. The keys for various configurations should be discovered by querying * * the "/configs" resource first. This resource emits the raw configuration file used by Nexus as response body. * * @param configKey The configuration key for which we want to get the configuration. */ @Override @GET @ResourceMethodSignature(pathParams = {@PathParam("configKey")}, output = String.class) public Object get(Context context, Request request, Response response, Variant variant) throws ResourceException { String key = request.getAttributes().get(GlobalConfigurationPlexusResource.CONFIG_NAME_KEY).toString(); try { NexusStreamResponse result; if (!getNexusConfiguration().getConfigurationFiles().containsKey(key)) { throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, "No configuration with key '" + key + "' found!"); } else { result = getNexusConfiguration().getConfigurationAsStreamByKey(key); } // TODO: make this real resource being able to be polled (ETag and last modified support) return new InputStreamRepresentation(MediaType.valueOf(result.getMimeType()), result.getInputStream()); } catch (IOException e) { throw new ResourceException(Status.SERVER_ERROR_INTERNAL, "IOException during configuration retrieval!", e); } }
resource.setResourceURI( createChildReference( request, this, logFile.getName() ).toString() ); resource.setName( logFile.getName() ); resource.setSize( logFile.getSize() ); resource.setMimeType( logFile.getMimeType() );
return new InputStreamRepresentation( MediaType.valueOf( result.getMimeType() ), result.getInputStream() );
return new InputStreamRepresentation( MediaType.valueOf( result.getMimeType() ), result.getInputStream() );