Search in sources :

Example 1 with P_INDEX_SECTION

use of org.sonatype.nexus.repository.apt.internal.AptProperties.P_INDEX_SECTION in project nexus-public by sonatype.

the class AptHostedFacet method createMetadataFileWithData.

private void createMetadataFileWithData(final List<AssetChange> changes, final CompressingTempFileStore result, final Map<String, Writer> streams, final List<FluentAsset> assets) throws IOException {
    // NOTE:  We exclude added assets as well to account for the case where we are replacing an asset
    Set<String> excludeNames = changes.stream().map(c -> c.getAsset().path()).collect(Collectors.toSet());
    for (FluentAsset asset : assets) {
        final String name = asset.path();
        final String arch = (String) FormatAttributesUtils.getFormatAttributes(asset).get(P_ARCHITECTURE);
        Writer outWriter = streams.computeIfAbsent(arch, result::openOutput);
        if (!excludeNames.contains(name)) {
            final String indexSection = (String) FormatAttributesUtils.getFormatAttributes(asset).get(P_INDEX_SECTION);
            outWriter.write(indexSection);
            outWriter.write("\n\n");
        }
    }
    List<FluentAsset> addAssets = changes.stream().filter(c -> c.getAction() == AssetAction.ADDED).map(AssetChange::getAsset).collect(Collectors.toList());
    // HACK: tx.browse won't see changes in the current transaction, so we have to manually add these in here
    for (FluentAsset asset : addAssets) {
        String arch = (String) FormatAttributesUtils.getFormatAttributes(asset).get(P_ARCHITECTURE);
        String indexSection = (String) FormatAttributesUtils.getFormatAttributes(asset).get(P_INDEX_SECTION);
        Writer outWriter = streams.computeIfAbsent(arch, result::openOutput);
        outWriter.write(indexSection);
        outWriter.write("\n\n");
    }
}
Also used : GZ(org.sonatype.nexus.repository.apt.internal.AptProperties.GZ) Arrays(java.util.Arrays) ControlFile(org.sonatype.nexus.repository.apt.internal.debian.ControlFile) Date(java.util.Date) FluentAsset(org.sonatype.nexus.repository.content.fluent.FluentAsset) BytesPayload(org.sonatype.nexus.repository.view.payloads.BytesPayload) StringUtils(org.apache.commons.lang3.StringUtils) AptContentFacet(org.sonatype.nexus.repository.apt.datastore.AptContentFacet) RELEASE(org.sonatype.nexus.repository.apt.internal.ReleaseName.RELEASE) StreamPayload(org.sonatype.nexus.repository.view.payloads.StreamPayload) Map(java.util.Map) FormatAttributesUtils(org.sonatype.nexus.repository.content.utils.FormatAttributesUtils) AssetAction(org.sonatype.nexus.repository.apt.internal.hosted.AssetAction) TimeZone(java.util.TimeZone) Collection(java.util.Collection) FacetSupport(org.sonatype.nexus.repository.FacetSupport) Set(java.util.Set) Collectors(java.util.stream.Collectors) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) Writer(java.io.Writer) Optional(java.util.Optional) P_INDEX_SECTION(org.sonatype.nexus.repository.apt.internal.AptProperties.P_INDEX_SECTION) INRELEASE(org.sonatype.nexus.repository.apt.internal.ReleaseName.INRELEASE) Continuation(org.sonatype.nexus.common.entity.Continuation) Paragraph(org.sonatype.nexus.repository.apt.internal.debian.ControlFile.Paragraph) MD5(org.sonatype.nexus.common.hash.HashAlgorithm.MD5) RELEASE_GPG(org.sonatype.nexus.repository.apt.internal.ReleaseName.RELEASE_GPG) HashMap(java.util.HashMap) CompressingTempFileStore(org.sonatype.nexus.repository.apt.internal.hosted.CompressingTempFileStore) BZ2(org.sonatype.nexus.repository.apt.internal.AptProperties.BZ2) Payload(org.sonatype.nexus.repository.view.Payload) DEB(org.sonatype.nexus.repository.apt.internal.AptProperties.DEB) Named(javax.inject.Named) PackageInfo(org.sonatype.nexus.repository.apt.internal.debian.PackageInfo) PATTERN_RFC1123(org.apache.http.protocol.HttpDateGenerator.PATTERN_RFC1123) Charsets(com.google.common.base.Charsets) ContentFacet(org.sonatype.nexus.repository.content.facet.ContentFacet) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) IOException(java.io.IOException) Facet(org.sonatype.nexus.repository.Facet) AptSigningFacet(org.sonatype.nexus.repository.apt.internal.gpg.AptSigningFacet) SHA256(org.sonatype.nexus.common.hash.HashAlgorithm.SHA256) P_ARCHITECTURE(org.sonatype.nexus.repository.apt.internal.AptProperties.P_ARCHITECTURE) AptMimeTypes(org.sonatype.nexus.repository.apt.internal.AptMimeTypes) AssetBlob(org.sonatype.nexus.repository.content.AssetBlob) HashAlgorithm(org.sonatype.nexus.common.hash.HashAlgorithm) Collections(java.util.Collections) DateFormatUtils(org.apache.commons.lang3.time.DateFormatUtils) Writer(java.io.Writer) FluentAsset(org.sonatype.nexus.repository.content.fluent.FluentAsset)

Aggregations

Charsets (com.google.common.base.Charsets)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 TimeZone (java.util.TimeZone)1 Collectors (java.util.stream.Collectors)1 Named (javax.inject.Named)1 IOUtils (org.apache.commons.io.IOUtils)1 StringUtils (org.apache.commons.lang3.StringUtils)1 DateFormatUtils (org.apache.commons.lang3.time.DateFormatUtils)1 PATTERN_RFC1123 (org.apache.http.protocol.HttpDateGenerator.PATTERN_RFC1123)1