congrats Icon
New! Announcing our next generation AI code completions
Read here
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

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • setScale (BigDecimal)
  • getSystemService (Context)
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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