Examples of NexusStreamResponse


Examples of org.sonatype.nexus.configuration.NexusStreamResponse

      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);
    }
  }
View Full Code Here

Examples of org.sonatype.nexus.configuration.NexusStreamResponse

    if (fileName != null) {
      File configFile = new File(getConfigurationDirectory(), fileName);

      if (configFile.canRead() && configFile.isFile()) {
        NexusStreamResponse response = new NexusStreamResponse();

        response.setName(fileName);

        if (fileName.endsWith(".xml")) {
          response.setMimeType("text/xml");
        }
        else {
          response.setMimeType("text/plain");
        }

        response.setSize(configFile.length());
        response.setFromByte(0);
        response.setBytesCount(configFile.length());
        response.setInputStream(new FileInputStream(configFile));

        return response;
      }
      else {
        return null;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.