Codota Logo
Content.<init>
Code IndexAdd Codota to your IDE (free)

How to use
org.sonatype.nexus.repository.view.Content
constructor

Best Java code snippets using org.sonatype.nexus.repository.view.Content.<init> (Showing top 20 results out of 315)

  • Common ways to obtain Content
private void myMethod () {
Content c =
  • Codota IconBlob blob;Asset asset;new Content(new BlobPayload(blob, asset.requireContentType()))
  • Smart code suggestions by Codota
}
origin: sonatype-nexus-community/nexus-repository-composer

/**
 * Builds a packages.json file as a {@code Content} instance containing the actual JSON for the given providers.
 */
private Content buildPackagesJson(final Repository repository, final Set<String> names) throws IOException {
 Map<String, Object> packagesJson = new LinkedHashMap<>();
 packagesJson.put(PROVIDERS_URL_KEY, repository.getUrl() + PACKAGE_JSON_PATH);
 packagesJson.put(PROVIDERS_KEY, names.stream()
   .collect(Collectors.toMap((each) -> each, (each) -> singletonMap(SHA256_KEY, null))));
 return new Content(new StringPayload(mapper.writeValueAsString(packagesJson), ContentTypes.APPLICATION_JSON));
}
origin: org.sonatype.nexus/nexus-repository

/**
 * Create {@link Content} out of HTTP response.
 */
protected Content createContent(final Context context, final HttpResponse response)
{
 return new Content(new HttpEntityPayload(response, response.getEntity()));
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

/**
 * Merges the metadata but doesn't cache it. Returns {@code null} if no usable response was in passed in map.
 *
 * @since 3.13
 */
@Nullable
public Content mergeWithoutCaching(final MavenPath mavenPath, final Map<Repository, Response> responses)
  throws IOException
{
 return merge(mavenPath, responses, Function.identity(), (in, contentType) -> {
  // load bytes in memory to make content re-usable; metadata shouldn't be too large
  // (don't include cache-related attributes since this content has not been cached)
  return new Content(new BytesPayload(toByteArray(in), contentType));
 });
}
origin: sonatype-nexus-community/nexus-repository-composer

return new Content(new StringPayload(mapper.writeValueAsString(singletonMap(PACKAGES_KEY, packages)),
  ContentTypes.APPLICATION_JSON));
origin: org.sonatype.nexus.plugins/nexus-repository-npm

/**
 * Convert an asset blob to {@link Content}.
 *
 * @return content of asset blob
 */
@Nonnull
public static Content toContent(final Asset asset, final Blob blob) {
 Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
 Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
 return content;
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

return new Content(new StreamPayload(
  new InputStreamSupplier()
origin: sonatype-nexus-community/nexus-repository-apt

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));
}
origin: sonatype-nexus-community/nexus-repository-composer

return new Content(new StringPayload(mapper.writeValueAsString(singletonMap(PACKAGES_KEY, packages)),
  ContentTypes.APPLICATION_JSON));
origin: sonatype-nexus-community/nexus-repository-helm

 /**
  * Convert an asset blob to {@link Content}.
  *
  * @return content of asset blob
  */
 public Content toContent(final Asset asset, final Blob blob) {
  Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
  return content;
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-raw

 private Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

private Content toContent(final Asset asset, final Blob blob) {
 final String contentType = asset.contentType();
 final Content content = new Content(new BlobPayload(blob, contentType));
 Content.extractFromAsset(asset, HashType.ALGORITHMS, content.getAttributes());
 return content;
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

/**
 * Creates a {@link Content} out of passed in package metadata.
 */
@Nonnull
static Content toContent(final Asset packageRootAsset, final NestedAttributesMap packageRoot) {
 Content content = new Content(new BytesPayload(NpmJsonUtils.bytes(packageRoot), ContentTypes.APPLICATION_JSON));
 Content.extractFromAsset(packageRootAsset, HASH_ALGORITHMS, content.getAttributes());
 content.getAttributes().set(NestedAttributesMap.class, packageRoot);
 return content;
}
origin: sonatype-nexus-community/nexus-repository-apt

public static Content toContent(final Asset asset, final Blob blob) {
 final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
 Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
 return content;
}
origin: sonatype-nexus-community/nexus-repository-composer

 private Content toContent(final Asset asset, final Blob blob) {
  final Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
  Content.extractFromAsset(asset, hashAlgorithms, content.getAttributes());
  return content;
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

public static void addHashes(final MavenFacet mavenFacet,
               final MavenPath mavenPath,
               final Map<HashAlgorithm, HashCode> hashCodes,
               final DateTime now)
  throws IOException
{
 for (HashType hashType : HashType.values()) {
  final HashCode hashCode = hashCodes.get(hashType.getHashAlgorithm());
  if (hashCode != null) {
   final Content hashContent = new Content(
     new StringPayload(hashCode.toString(), Constants.CHECKSUM_CONTENT_TYPE));
   hashContent.getAttributes().set(Content.CONTENT_LAST_MODIFIED, now);
   mavenFacet.put(mavenPath.hash(hashType), hashContent);
  }
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

 hashCodes.put(entry.getKey(), entry.getValue().hash());
Content content = new Content(new StreamPayload(
  new InputStreamSupplier()
origin: org.sonatype.nexus.plugins/nexus-repository-npm

/**
 * Returns the tarball content.
 */
@Nullable
static Content getTarballContent(final StorageTx tx,
                 final Bucket bucket,
                 final NpmPackageId packageId,
                 final String tarballName)
{
 Asset asset = findTarballAsset(tx, bucket, packageId, tarballName);
 if (asset == null) {
  return null;
 }
 Blob blob = tx.requireBlob(asset.requireBlobRef());
 Content content = new Content(new BlobPayload(blob, asset.requireContentType()));
 Content.extractFromAsset(asset, HASH_ALGORITHMS, content.getAttributes());
 return content;
}
origin: sonatype-nexus-community/nexus-repository-apt

Content fetchedContent = new Content(new HttpEntityPayload(response, entity));
AttributesMap contentAttrs = fetchedContent.getAttributes();
contentAttrs.set(Content.CONTENT_LAST_MODIFIED, getDateHeader(response, HttpHeaders.LAST_MODIFIED));
origin: org.sonatype.nexus.plugins/nexus-repository-maven

/**
 * Attempts to cache the merged content, falling back to temporary uncached result if necessary.
 */
private Content cache(final MavenPath mavenPath,
           final TempBlob tempBlob,
           final String contentType) throws IOException {
 AttributesMap attributesMap = new AttributesMap();
 maintainCacheInfo(attributesMap);
 mayAddETag(attributesMap, tempBlob.getHashes());
 try {
  return doCache(mavenPath, tempBlob, contentType, attributesMap);
 }
 catch (ONeedRetryException | ORecordDuplicatedException | MissingBlobException e) {
  log.debug("Conflict caching merged content {} : {}",
    getRepository().getName(), mavenPath.getPath(), e);
 }
 catch (Exception e) {
  log.warn("Problem caching merged content {} : {}",
    getRepository().getName(), mavenPath.getPath(), e);
 }
 invalidatePath(mavenPath); // sanity: force re-merge on next request
 try (InputStream in = tempBlob.get()) {
  // load bytes in memory before tempBlob vanishes; metadata shouldn't be too large
  // (don't include cache-related attributes since this content has not been cached)
  return new Content(new BytesPayload(toByteArray(in), contentType));
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

return new Content(new StringPayload(content, ContentTypes.APPLICATION_JSON));
org.sonatype.nexus.repository.viewContent<init>

Popular methods of Content

  • getAttributes
  • applyToAsset
    Applies non-format specific content attributes onto passed in Asset from passed in AttributesMap(usu
  • extractFromAsset
    Extracts non-format specific content attributes into the passed in AttributesMap (usually originatin
  • findAsset
    Finds fresh Asset instance from passed in TX by entity ID of the Asset used to create passed in Cont
  • maintainLastModified
    Maintains the "last modified" attribute of the content by setting it to "now". It accepts nulls, and
  • openInputStream
  • getContentType
  • close
  • getSize

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • BitSet (java.util)
    This class implements a vector of bits that grows as needed. Each component of the bit set has a boo
  • Dictionary (java.util)
    The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to valu
  • Iterator (java.util)
    An iterator over a collection. Iterator takes the place of Enumeration in the Java Collections Frame
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • JButton (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now