Tabnine Logo
Content
Code IndexAdd Tabnine to your IDE (free)

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

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

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-npm

/**
 * Save repository root asset & create blob from a temporary blob.
 *
 * @return blob content
 */
@Nonnull
static Content saveRepositoryRoot(final StorageTx tx,
                 final Asset asset,
                 final TempBlob tempBlob,
                 final Content content) throws IOException
{
 Content.applyToAsset(asset, Content.maintainLastModified(asset, content.getAttributes()));
 AssetBlob assetBlob = storeContent(tx, asset, tempBlob, AssetKind.REPOSITORY_ROOT);
 tx.saveAsset(asset);
 return toContent(asset, assetBlob.getBlob());
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

@Override
public InputStream read() throws IOException {
 Content content = mavenFacet.get(mavenPath);
 if (content != null) {
  return content.openInputStream();
 }
 return null;
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

private void putAssetPayload(final StorageTx tx,
  final Asset asset,
  final AssetBlob assetBlob,
  @Nullable final AttributesMap contentAttributes)
  throws IOException
{
 tx.attachBlob(asset, assetBlob);
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
}
origin: org.sonatype.nexus/nexus-repository

 private static Payload cachePayload(final Content remote) throws IOException {
  try (InputStream in = remote.openInputStream()) {
   return new BytesPayload(toByteArray(in), remote.getContentType());
  }
 }
}
origin: sonatype-nexus-community/nexus-repository-apt

private void addSignatureItem(StringBuilder builder, HashAlgorithm algo, Content content, String filename) {
 Map<HashAlgorithm, HashCode> hashMap = content.getAttributes().get(Content.CONTENT_HASH_CODES_MAP,
   Content.T_CONTENT_HASH_CODES_MAP);
 builder.append("\n ");
 builder.append(hashMap.get(algo).toString());
 builder.append(" ");
 builder.append(content.getSize());
 builder.append(" ");
 builder.append(filename);
}
origin: org.sonatype.nexus/nexus-repository

 private Asset getAssetFromPayload(final Payload payload) {
  if (payload instanceof Content) {
   return ((Content) payload).getAttributes().get(Asset.class);
  }
  return null;
 }
}
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: 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.plugins/nexus-repository-npm

@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
 if (asset == null) {
  log.debug(
    "Attempting to set cache info for non-existent npm asset {}", content.getAttributes().require(Asset.class)
  );
  return;
 }
 log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
 CacheInfo.applyToAsset(asset, cacheInfo);
 tx.saveAsset(asset);
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

final Closer closer = Closer.create();
try {
 final JsonParser jsonParser = mapper.getFactory().createParser(closer.register(fullIndex.openInputStream()));
 if (jsonParser.nextToken() == JsonToken.START_OBJECT &&
   NpmMetadataUtils.META_UPDATED.equals(jsonParser.nextFieldName())) {
return new Content(new StreamPayload(
  new InputStreamSupplier()
origin: sonatype-nexus-community/nexus-repository-composer

@Override
@TransactionalTouchMetadata
public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 Bucket bucket = tx.findBucket(getRepository());
 Asset asset = Content.findAsset(tx, bucket, content);
 if (asset == null) {
  log.debug("Attempting to set cache info for non-existent Composer asset {}", path);
  return;
 }
 CacheInfo.applyToAsset(asset, cacheInfo);
 tx.saveAsset(asset);
}
origin: sonatype-nexus-community/nexus-repository-apt

@Transactional(retryOn = { ONeedRetryException.class })
@Override
public void createSnapshot(String id, SnapshotComponentSelector selector) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 StorageFacet storageFacet = facet(StorageFacet.class);
 Bucket bucket = tx.findBucket(getRepository());
 Component component = tx.createComponent(bucket, getRepository().getFormat()).name(id);
 tx.saveComponent(component);
 for (SnapshotItem item : collectSnapshotItems(selector)) {
  String assetName = createAssetPath(id, item.specifier.path);
  Asset asset = tx.createAsset(bucket, component).name(assetName);
  try (final TempBlob streamSupplier = storageFacet.createTempBlob(item.content.openInputStream(), FacetHelper.hashAlgorithms)) {
   AssetBlob blob = tx.createBlob(item.specifier.path, streamSupplier, FacetHelper.hashAlgorithms, null,
     FacetHelper.determineContentType(item), true);
   tx.attachBlob(asset, blob);
  }
  finally {
   item.content.close();
  }
  tx.saveAsset(asset);
 }
}
origin: sonatype-nexus-community/nexus-repository-apt

public static String determineContentType(SnapshotItem item) {
 String ct = item.content.getContentType();
 if (ct == null) {
  switch (item.specifier.role) {
   case RELEASE_INDEX:
   case RELEASE_INLINE_INDEX:
   case PACKAGE_INDEX_RAW:
    return AptMimeTypes.TEXT;
   case RELEASE_SIG:
    return AptMimeTypes.SIGNATURE;
   case PACKAGE_INDEX_BZ2:
    return AptMimeTypes.BZIP;
   case PACKAGE_INDEX_GZ:
    return AptMimeTypes.GZIP;
  }
 }
 return ct;
}
origin: org.sonatype.nexus/nexus-repository

 @Nullable
 private static EntityId extractComponentId(final Content content) {
  Optional<Asset> asset = Optional.ofNullable(content.getAttributes().get(Asset.class));
  return asset.map(Asset::componentId).orElse(null);
 }
}
origin: org.sonatype.nexus.plugins/nexus-repository-npm

private void saveAsset(final StorageTx tx,
            final Asset asset,
            final AssetBlob assetBlob,
            final AssetKind kind,
            @Nullable final AttributesMap contentAttributes)
{
 asset.formatAttributes().set(P_ASSET_KIND, kind.name());
 tx.attachBlob(asset, assetBlob);
 Content.applyToAsset(asset, Content.maintainLastModified(asset, contentAttributes));
 tx.saveAsset(asset);
}
origin: org.sonatype.nexus.plugins/nexus-repository-maven

 hashCodes.put(entry.getKey(), entry.getValue().hash());
Content content = new Content(new StreamPayload(
  new InputStreamSupplier()
  contentType)
);
content.getAttributes().set(Content.CONTENT_LAST_MODIFIED, DateTime.now());
content.getAttributes().set(Content.CONTENT_HASH_CODES_MAP, hashCodes);
AttributesMap attributesMap = content.getAttributes();
mayAddETag(attributesMap, getHashAlgorithmFromContent(attributesMap));
return content;
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: sonatype-nexus-community/nexus-repository-helm

@TransactionalTouchMetadata
public void setCacheInfo(final Content content, final CacheInfo cacheInfo) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 Asset asset = Content.findAsset(tx, tx.findBucket(getRepository()), content);
 if (asset == null) {
  log.debug(
    "Attempting to set cache info for non-existent Helm asset {}", content.getAttributes().require(Asset.class)
  );
  return;
 }
 log.debug("Updating cacheInfo of {} to {}", asset, cacheInfo);
 CacheInfo.applyToAsset(asset, cacheInfo);
 tx.saveAsset(asset);
}
origin: org.sonatype.nexus.plugins/nexus-repository-raw

@Override
@TransactionalTouchMetadata
public void setCacheInfo(final String path, final Content content, final CacheInfo cacheInfo) throws IOException {
 StorageTx tx = UnitOfWork.currentTx();
 Bucket bucket = tx.findBucket(getRepository());
 // by EntityId
 Asset asset = Content.findAsset(tx, bucket, content);
 if (asset == null) {
  // by format coordinates
  Component component = tx.findComponentWithProperty(P_NAME, path, bucket);
  if (component != null) {
   asset = tx.firstAsset(component);
  }
 }
 if (asset == null) {
  log.debug("Attempting to set cache info for non-existent raw component {}", path);
  return;
 }
 log.debug("Updating cacheInfo of {} to {}", path, cacheInfo);
 CacheInfo.applyToAsset(asset, cacheInfo);
 tx.saveAsset(asset);
}
org.sonatype.nexus.repository.viewContent

Javadoc

Content, that is wrapped Payload with AttributesMap.

Most used methods

  • <init>
  • 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

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • compareTo (BigDecimal)
  • getApplicationContext (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now