Java Code Examples for org.sonatype.nexus.common.collect.AttributesMap#contains()

The following examples show how to use org.sonatype.nexus.common.collect.AttributesMap#contains() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConanHashVerifier.java    From nexus-repository-conan with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Retrieves the hash maps which are stored as key, value pairs within the conanmanifest file
 * @param tx
 * @param bucket
 * @param assetPath
 * @return hashcode of the file
 */
public HashCode lookupHashFromAsset(final StorageTx tx, final Bucket bucket, final String assetPath) {
  checkNotNull(tx);
  checkNotNull(bucket);
  checkNotNull(assetPath);

  AttributesMap attributes = getConanmanifestHashes(tx, bucket, assetPath);

  if(attributes != null) {
    String filename = getFilenameFromPath(assetPath);
    if (attributes.contains(filename)) {
      return HashCode.fromString((String) attributes.get(filename));
    }
  }
  return null;
}
 
Example 2
Source File: FluentAssetImpl.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Record external cache details provided by upstream content.
 *
 * @see ProxyFacetSupport#fetch
 */
private void cacheContentHeaders(final AttributesMap contentAttributes) {
  ImmutableMap.Builder<String, String> headerBuilder = ImmutableMap.builder();
  if (contentAttributes.contains(CONTENT_LAST_MODIFIED)) {
    headerBuilder.put(CONTENT_LAST_MODIFIED, contentAttributes.get(CONTENT_LAST_MODIFIED).toString());
  }
  if (contentAttributes.contains(CONTENT_ETAG)) {
    headerBuilder.put(CONTENT_ETAG, contentAttributes.get(CONTENT_ETAG, String.class));
  }
  Map<String, String> contentHeaders = headerBuilder.build();
  if (!contentHeaders.isEmpty()) {
    withAttribute(CONTENT, contentHeaders);
  }
  else {
    withoutAttribute(CONTENT);
  }
}
 
Example 3
Source File: OrientPyPiHostedFacetImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private void mayAddEtag(final AttributesMap attributesMap, final HashCode hashCode) {
  if (attributesMap.contains(CONTENT_ETAG)) {
    return;
  }

  if (hashCode != null) {
    attributesMap.set(CONTENT_ETAG, "{SHA1{" + hashCode + "}}");
  }
}
 
Example 4
Source File: MavenFacetUtils.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Adds {@link Content#CONTENT_ETAG} content attribute if not present. In case of hosted repositories, this is safe
 * and even good thing to do, as the content is hosted here only and NX is content authority.
 */
public static void mayAddETag(final AttributesMap attributesMap,
                              final Map<HashAlgorithm, HashCode> hashCodes) {
  if (attributesMap.contains(Content.CONTENT_ETAG)) {
    return;
  }
  HashCode sha1HashCode = hashCodes.get(HashAlgorithm.SHA1);
  if (sha1HashCode != null) {
    attributesMap.set(Content.CONTENT_ETAG, "{SHA1{" + sha1HashCode + "}}");
  }
}