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

Commit

Permalink
NEXUS-1819, more tests passing
Browse files Browse the repository at this point in the history
git-svn-id: file:///opt/svn/repositories/sonatype.org/nexus/trunk/nexus@3701 2aa8b3fc-8ebb-4439-a84f-95066eaea8ab
  • Loading branch information
tstevens committed Mar 20, 2009
1 parent 1c1760b commit 5852d1f
Show file tree
Hide file tree
Showing 13 changed files with 807 additions and 680 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.codehaus.plexus.component.annotations.Component;
Expand Down Expand Up @@ -51,6 +53,8 @@
import org.sonatype.nexus.configuration.upgrade.UpgradeMessage;
import org.sonatype.nexus.configuration.upgrade.Upgrader;
import org.sonatype.nexus.proxy.repository.GroupRepository;
import org.sonatype.nexus.proxy.repository.LocalStatus;
import org.sonatype.nexus.proxy.repository.ProxyMode;
import org.sonatype.nexus.proxy.repository.Repository;
import org.sonatype.nexus.proxy.repository.ShadowRepository;

Expand All @@ -70,6 +74,26 @@ public class Upgrade108to140
private static final String GROUP_MEMBERS_NODE = "memberRepositories";

private static final String GROUP_CHILD_NODE = "memberRepository";

private final Map<String, String> localStatus = new HashMap<String, String>();
private final Map<String, String> checksumPolicy = new HashMap<String, String>();
private final Map<String, String> proxyMode = new HashMap<String, String>();

public Upgrade108to140()
{
// migrate to ENUMS
this.localStatus.put( "inService", "IN_SERVICE" );
this.localStatus.put( "outOfService", "OUT_OF_SERVICE" );

this.checksumPolicy.put( "ignore", "IGNORE" );
this.checksumPolicy.put( "warn", "WARN" );
this.checksumPolicy.put( "strictIfExists", "STRICT_IF_EXISTS" );
this.checksumPolicy.put( "strict", "STRICT" );

this.proxyMode.put( "allow", "ALLOW" );
this.proxyMode.put( "blockedAuto", "BLOCKED_AUTO" );
this.proxyMode.put( "blockedManual", "BLOKED_MANUAL" );
}

public Object loadConfiguration( File file )
throws IOException,
Expand Down Expand Up @@ -262,7 +286,7 @@ protected CRepository copyCRepository1_0_8( org.sonatype.nexus.configuration.mod
CRepository newrepo = new CRepository();
newrepo.setId( oldrepos.getId() );
newrepo.setName( oldrepos.getName() );
newrepo.setLocalStatus( oldrepos.getLocalStatus() );
newrepo.setLocalStatus( this.localStatus.get( oldrepos.getLocalStatus()) );
newrepo.setAllowWrite( oldrepos.isAllowWrite() );
newrepo.setBrowseable( oldrepos.isBrowseable() );
newrepo.setIndexable( oldrepos.isIndexable() );
Expand All @@ -278,14 +302,14 @@ protected CRepository copyCRepository1_0_8( org.sonatype.nexus.configuration.mod
// Manipulate the dom
Xpp3Dom externalConfig = new Xpp3Dom( EXTERNAL_CONFIG );
newrepo.setExternalConfiguration( externalConfig );
this.setNodeValue( externalConfig, "proxyMode", oldrepos.getProxyMode() );
this.setNodeValue( externalConfig, "proxyMode", this.proxyMode.get( oldrepos.getProxyMode() ));
this.setNodeValue( externalConfig, "artifactMaxAge", Integer.toString( oldrepos.getArtifactMaxAge() ) );
this.setNodeValue( externalConfig, "itemMaxAge", Integer.toString( oldrepos.getMetadataMaxAge() ) );
this.setNodeValue( externalConfig, "cleanseRepositoryMetadata", Boolean.toString( oldrepos
.isMaintainProxiedRepositoryMetadata() ) ); // TODO
this
.setNodeValue( externalConfig, "downloadRemoteIndex", Boolean.toString( oldrepos.isDownloadRemoteIndexes() ) );
this.setNodeValue( externalConfig, "checksumPolicy", oldrepos.getChecksumPolicy() );
this.setNodeValue( externalConfig, "checksumPolicy", this.checksumPolicy.get( oldrepos.getChecksumPolicy() ));
this.setNodeValue( externalConfig, "repositoryPolicy", oldrepos.getRepositoryPolicy() );

if ( oldrepos.getLocalStorage() != null )
Expand Down Expand Up @@ -492,7 +516,7 @@ protected CRepository copyCRepositoryShadow1_0_8(
{
newShadow.setId( oldshadow.getId() );
newShadow.setName( oldshadow.getName() );
newShadow.setLocalStatus( oldshadow.getLocalStatus() );
newShadow.setLocalStatus( this.localStatus.get( oldshadow.getLocalStatus() ));
newShadow.setProviderHint( oldshadow.getType() );
newShadow.setProviderRole( ShadowRepository.class.getName() );
newShadow.setExposed( oldshadow.isExposed() );
Expand Down Expand Up @@ -558,7 +582,8 @@ protected CRepository copyCRepositoryGroup1_0_8(
groupRepo.setBrowseable( true );
groupRepo.setExposed( true );
groupRepo.setIndexable( false );

groupRepo.setLocalStatus( LocalStatus.IN_SERVICE.toString());

if ( oldgroup.getLocalStorage() != null )
{
CLocalStorage localStorage = new CLocalStorage();
Expand Down
Loading

0 comments on commit 5852d1f

Please sign in to comment.