Package org.sonatype.nexus.proxy.item

Examples of org.sonatype.nexus.proxy.item.ByteArrayContentLocator


    props.put(LAST_DISCOVERY_MESSAGE_KEY, discoveryStatus.getLastDiscoveryMessage());
    props.put(LAST_DISCOVERY_TIMESTAMP_KEY, Long.toString(discoveryStatus.getLastDiscoveryTimestamp()));

    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    props.store(bos, "Nexus discovery status");
    putFileItem(new ByteArrayContentLocator(bos.toByteArray(), "text/plain"));
  }
View Full Code Here


      throw new RemoteStorageException("Mock " + baseUrl + " is expected to be down.");
    }

    if (this.validUrlContentMap.containsKey(requestUrl)) {
      return new DefaultStorageFileItem(repository, request, true, false,
          new ByteArrayContentLocator(
              this.validUrlContentMap.get(requestUrl).getBytes(),
              "plain/text"));
    }

    // else
View Full Code Here

        final Repository repository = uid.getRepository();

        final DefaultStorageFileItem attributeItem =
            new DefaultStorageFileItem(repository, new ResourceStoreRequest(getAttributePath(repository,
                uid.getPath())), true, true, new ByteArrayContentLocator(bos.toByteArray(), "text/xml"));

        repository.getLocalStorage().storeItem(repository, attributeItem);
      }
      catch (UnsupportedStorageOperationException ex) {
        // TODO: what here? Is local storage unsuitable for storing attributes?
View Full Code Here

          // should not happen, look at implementation
          // we will handle here two byte array backed streams!
          throw new LocalStorageException("Problem ", e);
        }

        cl = new ByteArrayContentLocator(bos.toByteArray(), "text/xml");
      }

      target = getFileFromBase(repository, item.getResourceStoreRequest());

      getFSPeer().storeItem(repository, getBaseDir(repository, item.getResourceStoreRequest()), item, target, cl);
View Full Code Here

      throws IOException
  {
    checkNotNull(prefixSource);
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    getPrefixSourceMarshaller().write(prefixSource.readEntries(), bos);
    putFileItem(new ByteArrayContentLocator(bos.toByteArray(), "text/plain"));
  }
View Full Code Here

  public void writeUnsupported()
      throws IOException
  {
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    getPrefixSourceMarshaller().writeUnsupported(bos);
    putFileItem(new ByteArrayContentLocator(bos.toByteArray(), "text/plain"));
  }
View Full Code Here

    String mimeType = getMimeSupport().guessMimeTypeFromPath(getMimeRulesSource(), digestFileName);

    byte[] bytes = (digest + '\n').getBytes("UTF-8");

    ContentLocator contentLocator = new ByteArrayContentLocator(bytes, mimeType);

    ResourceStoreRequest req = new ResourceStoreRequest(digestFileName);

    req.getRequestContext().setParentContext(request.getRequestContext());
View Full Code Here

  {
    // we are creating file maven-metadata.xml, and ask the MimeUtil for it's exact MIME type to honor potential
    // user configuration
    String mimeType = getMimeSupport().guessMimeTypeFromPath(getMimeRulesSource(), "maven-metadata.xml");

    ContentLocator contentLocator = new ByteArrayContentLocator(content, mimeType);

    DefaultStorageCompositeFileItem result =
        new DefaultStorageCompositeFileItem(this, request, true, false, contentLocator, sources);

    result.setCreated(getNewestCreatedDate(sources));
View Full Code Here

        // serialize and swap the new metadata
        MetadataXpp3Writer metadataWriter = new MetadataXpp3Writer();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        OutputStreamWriter osw = new OutputStreamWriter(bos);
        metadataWriter.write(osw, imd);
        mdFile.setContentLocator(new ByteArrayContentLocator(bos.toByteArray(), mdFile.getMimeType()));
      }
      catch (Exception e) {
        log.error("Exception during repository metadata cleansing.", e);

        if (backup != null) {
          // get backup and continue operation
          backup.reset();
          mdFile.setContentLocator(new ByteArrayContentLocator(backup1.toByteArray(), mdFile.getMimeType()));
        }
      }
    }

    return super.doCacheItem(item);
View Full Code Here

            content = mdOutput.toByteArray();
          }

          String mimeType =
              getMimeSupport().guessMimeTypeFromPath(getMimeRulesSource(), request.getRequestPath());
          ContentLocator contentLocator = new ByteArrayContentLocator(content, mimeType);

          DefaultStorageFileItem result =
              new DefaultStorageFileItem(this, request, true, false, contentLocator);
          result.setCreated(mdItem.getCreated());
          result.setModified(System.currentTimeMillis());
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.item.ByteArrayContentLocator

Copyright © 2018 www.massapicom. 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.