当前位置: 首页>>代码示例>>Java>>正文


Java BytesPayload类代码示例

本文整理汇总了Java中org.sonatype.nexus.repository.view.payloads.BytesPayload的典型用法代码示例。如果您正苦于以下问题:Java BytesPayload类的具体用法?Java BytesPayload怎么用?Java BytesPayload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BytesPayload类属于org.sonatype.nexus.repository.view.payloads包,在下文中一共展示了BytesPayload类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: write

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
/**
 * Writes passed in metadata as XML.
 */
public static void write(final Repository repository, final MavenPath mavenPath, final Metadata metadata)
    throws IOException
{
  MavenFacet mavenFacet = repository.facet(MavenFacet.class);
  final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  MavenModels.writeMetadata(buffer, metadata);
  mavenFacet.put(mavenPath, new BytesPayload(buffer.toByteArray(),
      MavenMimeRulesSource.METADATA_TYPE));
  final Map<HashAlgorithm, HashCode> hashCodes = mavenFacet.get(mavenPath).getAttributes()
      .require(Content.CONTENT_HASH_CODES_MAP, Content.T_CONTENT_HASH_CODES_MAP);
  checkState(hashCodes != null, "hashCodes");
  for (HashType hashType : HashType.values()) {
    MavenPath checksumPath = mavenPath.hash(hashType);
    HashCode hashCode = hashCodes.get(hashType.getHashAlgorithm());
    checkState(hashCode != null, "hashCode: type=%s", hashType);
    mavenFacet.put(checksumPath, new StringPayload(hashCode.toString(), Constants.CHECKSUM_CONTENT_TYPE));
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:22,代码来源:MetadataUtils.java

示例2: buildPackages

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
static Content buildPackages(final Collection<Map<String, String>> entries) throws IOException {
  CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory();
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  try (CompressorOutputStream cos = compressorStreamFactory.createCompressorOutputStream(GZIP, os)) {
    try (OutputStreamWriter writer = new OutputStreamWriter(cos, UTF_8)) {
      for (Map<String, String> entry : entries) {
        InternetHeaders headers = new InternetHeaders();
        headers.addHeader(P_PACKAGE, entry.get(P_PACKAGE));
        headers.addHeader(P_VERSION, entry.get(P_VERSION));
        headers.addHeader(P_DEPENDS, entry.get(P_DEPENDS));
        headers.addHeader(P_IMPORTS, entry.get(P_IMPORTS));
        headers.addHeader(P_SUGGESTS, entry.get(P_SUGGESTS));
        headers.addHeader(P_LICENSE, entry.get(P_LICENSE));
        headers.addHeader(P_NEEDS_COMPILATION, entry.get(P_NEEDS_COMPILATION));
        Enumeration<String> headerLines = headers.getAllHeaderLines();
        while (headerLines.hasMoreElements()) {
          String line = headerLines.nextElement();
          writer.write(line, 0, line.length());
          writer.write('\n');
        }
        writer.write('\n');
      }
    }
  }
  catch ( CompressorException e ) {
    throw new RException(null, e);
  }
  return new Content(new BytesPayload(os.toByteArray(), "application/x-gzip"));
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-r,代码行数:30,代码来源:RPackagesUtils.java

示例3: getPublicKey

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
public Content getPublicKey() throws IOException, PGPException {
  PGPSecretKey signKey = readSecretKey();
  PGPPublicKey publicKey = signKey.getPublicKey();
  ByteArrayOutputStream buffer = new ByteArrayOutputStream();
  try (BCPGOutputStream os = new BCPGOutputStream(new ArmoredOutputStream(buffer))) {
    publicKey.encode(os);
  }
  return new Content(new BytesPayload(buffer.toByteArray(), AptMimeTypes.PUBLICKEY));
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-apt,代码行数:10,代码来源:AptSigningFacet.java

示例4: rebuildIndexesInTransaction

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
@TransactionalStoreMetadata
private void rebuildIndexesInTransaction(StorageTx tx, AssetChange... changes) throws IOException, PGPException {
  AptFacet aptFacet = getRepository().facet(AptFacet.class);
  AptSigningFacet signingFacet = getRepository().facet(AptSigningFacet.class);
  Bucket bucket = tx.findBucket(getRepository());

  StringBuilder sha256Builder = new StringBuilder();
  StringBuilder md5Builder = new StringBuilder();
  String releaseFile;
  try (CompressingTempFileStore store = buildPackageIndexes(tx, bucket, changes)) {
    for (Map.Entry<String, CompressingTempFileStore.FileMetadata> entry : store.getFiles().entrySet()) {
      Content plainContent = aptFacet.put(
          packageIndexName(entry.getKey(), ""),
          new StreamPayload(entry.getValue().plainSupplier(), entry.getValue().plainSize(), AptMimeTypes.TEXT));
      addSignatureItem(md5Builder, MD5, plainContent, packageRelativeIndexName(entry.getKey(), ""));
      addSignatureItem(sha256Builder, SHA256, plainContent, packageRelativeIndexName(entry.getKey(), ""));

      Content gzContent = aptFacet.put(
          packageIndexName(entry.getKey(), ".gz"),
          new StreamPayload(entry.getValue().gzSupplier(), entry.getValue().bzSize(), AptMimeTypes.GZIP));
      addSignatureItem(md5Builder, MD5, gzContent, packageRelativeIndexName(entry.getKey(), ".gz"));
      addSignatureItem(sha256Builder, SHA256, gzContent, packageRelativeIndexName(entry.getKey(), ".gz"));

      Content bzContent = aptFacet.put(
          packageIndexName(entry.getKey(), ".bz2"),
          new StreamPayload(entry.getValue().bzSupplier(), entry.getValue().bzSize(), AptMimeTypes.BZIP));
      addSignatureItem(md5Builder, MD5, bzContent, packageRelativeIndexName(entry.getKey(), ".bz2"));
      addSignatureItem(sha256Builder, SHA256, bzContent, packageRelativeIndexName(entry.getKey(), ".bz2"));
    }

    releaseFile = buildReleaseFile(aptFacet.getDistribution(), store.getFiles().keySet(), md5Builder.toString(), sha256Builder.toString());
  }

  aptFacet.put(releaseIndexName("Release"), new BytesPayload(releaseFile.getBytes(Charsets.UTF_8), AptMimeTypes.TEXT));
  byte[] inRelease = signingFacet.signInline(releaseFile);
  aptFacet.put(releaseIndexName("InRelease"), new BytesPayload(inRelease, AptMimeTypes.TEXT));
  byte[] releaseGpg = signingFacet.signExternal(releaseFile);
  aptFacet.put(releaseIndexName("Release.gpg"), new BytesPayload(releaseGpg, AptMimeTypes.SIGNATURE));
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-apt,代码行数:40,代码来源:AptHostedFacet.java

示例5: getPackages

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
@Override
@TransactionalTouchMetadata
public Content getPackages(final String packagesPath) {
  checkNotNull(packagesPath);
  try {
    // TODO: Do NOT do this on each request as there is at least some overhead, and memory usage is proportional to
    // the number of packages contained in a particular path. We should be able to generate this when something has
    // changed or via a scheduled task using an approach similar to the Yum implementation rather than this method.
    StorageTx tx = UnitOfWork.currentTx();
    RPackagesBuilder packagesBuilder = new RPackagesBuilder(packagesPath);
    for (Asset asset : tx.browseAssets(tx.findBucket(getRepository()))) {
      packagesBuilder.append(asset);
    }
    CompressorStreamFactory compressorStreamFactory = new CompressorStreamFactory();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try (CompressorOutputStream cos = compressorStreamFactory.createCompressorOutputStream(GZIP, os)) {
      try (OutputStreamWriter writer = new OutputStreamWriter(cos, UTF_8)) {
        for (Entry<String, Map<String, String>> eachPackage : packagesBuilder.getPackageInformation().entrySet()) {
          Map<String, String> packageInfo = eachPackage.getValue();
          InternetHeaders headers = new InternetHeaders();
          headers.addHeader(P_PACKAGE, packageInfo.get(P_PACKAGE));
          headers.addHeader(P_VERSION, packageInfo.get(P_VERSION));
          headers.addHeader(P_DEPENDS, packageInfo.get(P_DEPENDS));
          headers.addHeader(P_IMPORTS, packageInfo.get(P_IMPORTS));
          headers.addHeader(P_SUGGESTS, packageInfo.get(P_SUGGESTS));
          headers.addHeader(P_LICENSE, packageInfo.get(P_LICENSE));
          headers.addHeader(P_NEEDS_COMPILATION, packageInfo.get(P_NEEDS_COMPILATION));
          Enumeration<String> headerLines = headers.getAllHeaderLines();
          while (headerLines.hasMoreElements()) {
            String line = headerLines.nextElement();
            writer.write(line, 0, line.length());
            writer.write('\n');
          }
          writer.write('\n');
        }
      }
    }
    return new Content(new BytesPayload(os.toByteArray(), "application/x-gzip"));
  }
  catch (CompressorException | IOException e) {
    throw new RException(packagesPath, e);
  }
}
 
开发者ID:sonatype-nexus-community,项目名称:nexus-repository-r,代码行数:44,代码来源:RHostedFacetImpl.java

示例6: cachePayload

import org.sonatype.nexus.repository.view.payloads.BytesPayload; //导入依赖的package包/类
private static Payload cachePayload(final Content remote) throws IOException {
  try (InputStream in = remote.openInputStream()) {
    return new BytesPayload(toByteArray(in), remote.getContentType());
  }
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:6,代码来源:TempContent.java


注:本文中的org.sonatype.nexus.repository.view.payloads.BytesPayload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。