Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

NEXUS-23827 - PACKAGES.gz cannot be updated if R repo doesn't allow r… #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.inject.Named;

import org.sonatype.nexus.repository.FacetSupport;
import org.sonatype.nexus.repository.config.Configuration;
import org.sonatype.nexus.repository.r.RFacet;
import org.sonatype.nexus.repository.r.RHostedFacet;
import org.sonatype.nexus.repository.r.internal.util.RFacetUtils;
Expand Down Expand Up @@ -55,6 +56,12 @@ public class RHostedFacetImpl
extends FacetSupport
implements RHostedFacet
{
@Override
protected void doInit(final Configuration configuration) throws Exception {
super.doInit(configuration);
getRepository().facet(StorageFacet.class).registerWritePolicySelector(new RWritePolicySelector());
}

@Override
@TransactionalTouchBlob
public Content getStoredContent(final String contentPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ class RHostedRecipe
void apply(@Nonnull final Repository repository) throws Exception {
repository.attach(securityFacet.get())
repository.attach(configure(viewFacet.get()))
repository.attach(storageFacet.get())
repository.attach(httpClientFacet.get())
repository.attach(componentMaintenanceFacet.get())
repository.attach(hostedFacet.get())
repository.attach(packagesBuilderFacet.get())
repository.attach(rFacet.get())
repository.attach(rRestoreFacet.get())
repository.attach(storageFacet.get())
repository.attach(searchFacet.get())
repository.attach(attributesFacet.get())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Sonatype Nexus (TM) Open Source Version
* Copyright (c) 2017-present Sonatype, Inc.
* All rights reserved. Includes the third-party code listed at http://links.sonatype.com/products/nexus/oss/attributions.
*
* This program and the accompanying materials are made available under the terms of the Eclipse Public License Version 1.0,
* which accompanies this distribution and is available at http://www.eclipse.org/legal/epl-v10.html.
*
* Sonatype Nexus (TM) Professional Version is available from Sonatype, Inc. "Sonatype" and "Sonatype Nexus" are trademarks
* of Sonatype, Inc. Apache Maven is a trademark of the Apache Software Foundation. M2eclipse is a trademark of the
* Eclipse Foundation. All other trademarks are the property of their respective owners.
*/
package org.sonatype.nexus.repository.r.internal.hosted;

import java.util.Objects;

import org.sonatype.nexus.repository.storage.Asset;
import org.sonatype.nexus.repository.storage.WritePolicy;
import org.sonatype.nexus.repository.storage.WritePolicySelector;

import static org.sonatype.nexus.repository.r.internal.AssetKind.PACKAGES;
import static org.sonatype.nexus.repository.r.internal.AssetKind.RDS_METADATA;
import static org.sonatype.nexus.repository.storage.AssetEntityAdapter.P_ASSET_KIND;
import static org.sonatype.nexus.repository.storage.WritePolicy.ALLOW;
import static org.sonatype.nexus.repository.storage.WritePolicy.ALLOW_ONCE;

public class RWritePolicySelector implements WritePolicySelector
{
@Override
public WritePolicy select(final Asset asset, final WritePolicy configured) {
if (ALLOW_ONCE == configured) {
final String assetKind = asset.formatAttributes().get(P_ASSET_KIND, String.class);
if (Objects.equals(PACKAGES.name(), assetKind) ||
Objects.equals(RDS_METADATA.name(), assetKind)) {
return ALLOW;
}
}
return configured;
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-plugins</artifactId>
<version>3.27.0-SNAPSHOT</version>
<version>3.28.0-SNAPSHOT</version>
</parent>

<artifactId>nexus-repository-base</artifactId>
Expand Down Expand Up @@ -47,7 +47,7 @@
</distributionManagement>

<properties>
<nxrm-version>3.27.0-SNAPSHOT</nxrm-version>
<nxrm-version>3.28.0-SNAPSHOT</nxrm-version>
</properties>

<repositories>
Expand Down