@Override public AbstractProxyRepositoryConfiguration createExternalConfigurationHolder(final CRepository config) { return new AbstractProxyRepositoryConfiguration((Xpp3Dom) config.getExternalConfiguration()) { }; } };
@Override protected void copyTransients( Object source, Object destination ) { ( (CRepository) destination ).setExternalConfiguration( ( (CRepository) source ).getExternalConfiguration() ); ( (CRepository) destination ).externalConfigurationImple = ( (CRepository) source ).externalConfigurationImple; ( (CRepository) destination ).defaultLocalStorageUrl = ( (CRepository) source ).defaultLocalStorageUrl; // trick with RemoteStorage, which is an object, and XStream will not "overlap" it properly (ie. destionation != // null but source == null) if ( ( (CRepository) source ).getRemoteStorage() == null ) { ( (CRepository) destination ).setRemoteStorage( null ); } }
@Override protected CRepositoryCoreConfiguration initCoreConfiguration() { CRepository repo = new DefaultCRepository(); repo.setId(""); repo.setProviderRole(WebSiteRepository.class.getName()); repo.setProviderHint(SiteRepository.ID); Xpp3Dom ex = new Xpp3Dom(DefaultCRepository.EXTERNAL_CONFIGURATION_NODE_NAME); repo.setExternalConfiguration(ex); repo.setIndexable(false); repo.setWritePolicy(RepositoryWritePolicy.ALLOW_WRITE.name()); repo.setNotFoundCacheTTL(1440); CRepositoryCoreConfiguration result = new CRepositoryCoreConfiguration( getTemplateProvider().getApplicationConfiguration(), repo, new CRepositoryExternalConfigurationHolderFactory<DefaultSiteRepositoryConfiguration>() { public DefaultSiteRepositoryConfiguration createExternalConfigurationHolder(CRepository config) { return new DefaultSiteRepositoryConfiguration((Xpp3Dom) config.getExternalConfiguration()); } }); return result; }
protected void doForceNfcSetting( final Configuration configuration ) { getLogger().info( "Enforcing proper NFC use: every non-proxy repository present in system will have NFC deactivated (system property override present)." ); // conservatively shut down NFC on any non-proxy repository for ( CRepository repository : configuration.getRepositories() ) { final boolean isProxyRepository = repository.getRemoteStorage() != null && repository.getRemoteStorage().getUrl() != null; repository.setNotFoundCacheActive( isProxyRepository ); } }
CRepository repo = new DefaultCRepository(); repo.setId(""); repo.setName(""); repo.setProviderRole(Repository.class.getName()); repo.setProviderHint(DefaultProxyRubyRepository.ID); repo.setRemoteStorage(new CRemoteStorage()); repo.getRemoteStorage().setProvider( getTemplateProvider().getRemoteProviderHintFactory().getDefaultHttpRoleHint()); repo.getRemoteStorage().setUrl("http://some-remote-repository/repo-root"); repo.setExternalConfiguration(ex); repo.externalConfigurationImple = exConf; repo.setWritePolicy(RepositoryWritePolicy.READ_ONLY.name()); repo.setNotFoundCacheActive(true); repo.setNotFoundCacheTTL(1440); repo.setIndexable(true); repo.setSearchable(true);
appModel.setLocalStatus( LocalStatus.IN_SERVICE.name() ); if ( target != null ) appModel.setLocalStatus( target.getLocalStatus() ); ex = (Xpp3Dom) target.getExternalConfiguration(); appModel.setId( resource.getId() ); appModel.setName( resource.getName() ); appModel.setExposed( resource.isExposed() ); appModel.setProviderRole( resource.getProviderRole() ); appModel.setExternalConfiguration( ex ); appModel.setIndexable( false ); appModel.setWritePolicy( repoResource.getWritePolicy() ); appModel.setBrowseable( repoResource.isBrowseable() ); appModel.setIndexable( repoResource.isIndexable() ); appModel.setSearchable( repoResource.isIndexable() ); appModel.setNotFoundCacheTTL( repoResource.getNotFoundCacheTTL() ); appModel.setExternalConfiguration( ex );
value.setId( cRepository.getId() ); value.setName( cRepository.getName() ); value.setProviderRole( cRepository.getProviderRole() ); value.setProviderHint( cRepository.getProviderHint() ); value.setPathPrefix( cRepository.getPathPrefix() ); value.setLocalStatus( cRepository.getLocalStatus() ); value.setNotFoundCacheActive( cRepository.isNotFoundCacheActive() ); value.setNotFoundCacheTTL( cRepository.getNotFoundCacheTTL() ); value.setUserManaged( cRepository.isUserManaged() ); value.setExposed( cRepository.isExposed() ); value.setBrowseable( cRepository.isBrowseable() ); value.setWritePolicy( cRepository.getWritePolicy() ); value.setIndexable( cRepository.isIndexable() ); value.setSearchable( cRepository.isSearchable() ); value.setLocalStorage( upgradeCLocalStorage( cRepository.getLocalStorage() ) ); value.setRemoteStorage( upgradeCRemoteStorage( cRepository.getRemoteStorage() ) );
CRepository repo = new DefaultCRepository(); repo.setId(""); repo.setName(""); repo.setProviderRole(GroupRepository.class.getName()); repo.setProviderHint(DefaultRubyGroupRepository.ID); repo.setSearchable(false); repo.setExternalConfiguration(ex); repo.setWritePolicy(RepositoryWritePolicy.READ_ONLY.name());
CRepository repo = new DefaultCRepository(); repo.setId(""); repo.setName(""); repo.setProviderRole(Repository.class.getName()); repo.setProviderHint(DefaultHostedRubyRepository.ID); repo.setExternalConfiguration(ex); repo.setWritePolicy(RepositoryWritePolicy.ALLOW_WRITE_ONCE.name()); repo.setNotFoundCacheTTL(1440); repo.setIndexable(true); repo.setSearchable(true);
if ( cRepository.getId() != null ) serializer.startTag( NAMESPACE, "id" ).text( cRepository.getId() ).endTag( NAMESPACE, "id" ); if ( cRepository.getName() != null ) serializer.startTag( NAMESPACE, "name" ).text( cRepository.getName() ).endTag( NAMESPACE, "name" ); if ( cRepository.getProviderRole() != null ) serializer.startTag( NAMESPACE, "providerRole" ).text( cRepository.getProviderRole() ).endTag( NAMESPACE, "providerRole" ); if ( cRepository.getProviderHint() != null ) serializer.startTag( NAMESPACE, "providerHint" ).text( cRepository.getProviderHint() ).endTag( NAMESPACE, "providerHint" ); if ( cRepository.getPathPrefix() != null ) serializer.startTag( NAMESPACE, "pathPrefix" ).text( cRepository.getPathPrefix() ).endTag( NAMESPACE, "pathPrefix" ); if ( cRepository.getLocalStatus() != null ) serializer.startTag( NAMESPACE, "localStatus" ).text( cRepository.getLocalStatus() ).endTag( NAMESPACE, "localStatus" ); if ( cRepository.isNotFoundCacheActive() != false ) serializer.startTag( NAMESPACE, "notFoundCacheActive" ).text( String.valueOf( cRepository.isNotFoundCacheActive() ) ).endTag( NAMESPACE, "notFoundCacheActive" ); if ( cRepository.getNotFoundCacheTTL() != 0 )
if ( StringUtils.isBlank( cfg.getId() ) ) else if ( !cfg.getId().matches( REPOSITORY_ID_PATTERN ) ) if ( "all".equals( cfg.getId() ) ) if ( StringUtils.isBlank( cfg.getName() ) ) response.addValidationWarning( new ValidationMessage( "id", "Repository with ID='" + cfg.getId() + "' has no name, defaulted it's name to it's ID." ) ); cfg.setName( cfg.getId() ); LocalStatus.valueOf( cfg.getLocalStatus() ); + cfg.getId() + "\" has unacceptable value \"" + cfg.getLocalStatus() + "\"! (Allowed values are: \"" + LocalStatus.IN_SERVICE + "\" and \"" + LocalStatus.OUT_OF_SERVICE + "\")", e ) ); if ( cfg.isIndexable() && ( !"maven2".equals( cfg.getProviderHint() ) ) ) + cfg.getProviderHint() + "\" repositories, only Maven2 repositories are indexable!" ) ); cfg.setIndexable( false ); if ( "maven2".equals( cfg.getProviderHint() ) || "maven1".equals( cfg.getProviderHint() ) ) if ( cfg.getRemoteStorage() != null && cfg.getRemoteStorage().getUrl() != null && !cfg.getRemoteStorage().getUrl().endsWith( RepositoryItemUid.PATH_SEPARATOR ) )
throws PlexusResourceException M2RepositoryConfiguration exConf = new M2RepositoryConfiguration( (Xpp3Dom) target.getExternalConfiguration() ); if ( target.getRemoteStorage() == null ) target.setRemoteStorage( new CRemoteStorage() ); target.getRemoteStorage().setUrl( model.getRemoteStorage().getRemoteStorageUrl() ); target.getRemoteStorage().setAuthentication( this.convertAuthentication( model.getRemoteStorage().getAuthentication(), null ) ); target.getRemoteStorage().setConnectionSettings( this.convertRemoteConnectionSettings( model.getRemoteStorage().getConnectionSettings() ) ); target.getRemoteStorage().setHttpProxySettings( this.convertHttpProxySettings( model.getRemoteStorage().getHttpProxySettings(), null ) );
CRepository cRepo = NexusConfigUtil.getRepo( repo.getId() ); Assert.assertEquals( expected.getId(), cRepo.getId() ); Assert.assertEquals( expected.getChecksumPolicy(), cRepo.getChecksumPolicy() ); Assert.assertEquals( expected.getName(), cRepo.getName() ); cRepo.getType() ); Assert.assertNotNull( "Unknown repo type='" + cRepo.getType() + "'!", expectedCc ); Assert.assertEquals( expected.getFormat(), expectedCc.getId() ); Assert.assertEquals( expected.getNotFoundCacheTTL(), cRepo.getNotFoundCacheTTL() ); Assert.assertEquals( expected.getOverrideLocalStorageUrl(), cRepo.getLocalStorage() ); Assert.assertNull( cRepo.getRemoteStorage() ); .getRemoteStorage().getUrl() ); Assert.assertEquals( expected.getRepoPolicy(), cRepo.getRepositoryPolicy() );
Assert.assertEquals(cRepo.getId(), expected.getId()); Assert.assertEquals(cRepo.getName(), expected.getName()); CRepository cRepo = getTest().getNexusConfigUtil().getRepo(repo.getId()); Assert.assertEquals(expected.getId(), cRepo.getId()); Assert.assertEquals(expected.getName(), cRepo.getName()); Assert.assertEquals(expected.getNotFoundCacheTTL(), cRepo.getNotFoundCacheTTL()); cRepo.getLocalStorage().getUrl()); cRepo.getLocalStorage().getUrl().endsWith("/") ? cRepo.getLocalStorage().getUrl() : cRepo.getLocalStorage().getUrl() + "/"; String overridLocalStorage = expected.getOverrideLocalStorageUrl().endsWith("/") ? expected.getOverrideLocalStorageUrl() Assert.assertNull(cRepo.getRemoteStorage()); Assert.assertEquals(cRepo.getRemoteStorage().getUrl(), expected.getRemoteStorage().getRemoteStorageUrl());
public M2LayoutedM1ShadowRepositoryConfiguration getRepoShadow(String repoId) throws IOException { List<CRepository> repos = getNexusConfig().getRepositories(); for (Iterator<CRepository> iter = repos.iterator(); iter.hasNext(); ) { CRepository cRepo = iter.next(); // check id if (cRepo.getId().equals(repoId)) { M2LayoutedM1ShadowRepositoryConfiguration exRepoConf = new M2LayoutedM1ShadowRepositoryConfiguration((Xpp3Dom) cRepo.getExternalConfiguration()); return exRepoConf; } } return null; }
public String getRemoteUrl() { if ( getCurrentConfiguration( false ).getRemoteStorage() != null ) { return getCurrentConfiguration( false ).getRemoteStorage().getUrl(); } else { return null; } }
if ( StringUtils.isEmpty( repo.getId() ) ) else if ( !repo.getId().matches( REPOSITORY_ID_PATTERN ) ) if ( StringUtils.isEmpty( repo.getName() ) ) repo.setName( repo.getId() ); response.addValidationWarning( new ValidationMessage( "id", "Repository with ID='" + repo.getId() + "' has no name, defaulted to it's ID." ) ); if ( !validateLocalStatus( repo.getLocalStatus() ) ) new ValidationMessage( "id", "LocalStatus of repository with ID='" + repo.getId() ) + "' is wrong " + repo.getLocalStatus() + "! (Allowed values are: '" + LocalStatus.IN_SERVICE + "' and '" + LocalStatus.OUT_OF_SERVICE + "')" ); if ( context.getExistingRepositoryIds().contains( repo.getId() ) ) response.addValidationError( new ValidationMessage( "id", "Repository with ID=" + repo.getId() + " already exists!" ) ); context.getExistingRepositoryIds().add( repo.getId() ); if ( context.getExistingRepositoryShadowIds().contains( repo.getId() ) ) response.addValidationError( new ValidationMessage( "id", "Repository " + repo.getId() + " conflicts with existing Shadow with same ID='" + repo.getId() + "'!" ) ); if ( context.getExistingRepositoryGroupIds().contains( repo.getId() ) )
@Override protected ExternalConfiguration<?> prepareExternalConfiguration( Object configuration ) { if ( externalConfigurationFactory == null ) { return null; } // prepare the Xpp3Dom root node if ( repositoryModel.getExternalConfiguration() == null ) { // just put an elephant in South Africa to find it for sure ;) repositoryModel .setExternalConfiguration( new Xpp3Dom( DefaultCRepository.EXTERNAL_CONFIGURATION_NODE_NAME ) ); } // set the holder if ( repositoryModel.externalConfigurationImple == null ) { // in 1st round, i intentionally choosed to make our lives bitter, and handle config manually // later we will see about it repositoryModel.externalConfigurationImple = externalConfigurationFactory.createExternalConfigurationHolder( repositoryModel ); } return new DefaultExternalConfiguration<AbstractXpp3DomExternalConfigurationHolder>( getApplicationConfiguration(), this, (AbstractXpp3DomExternalConfigurationHolder) repositoryModel.externalConfigurationImple ); }
public void setRemoteStorage( RemoteRepositoryStorage remoteStorage ) { this.remoteStorage = remoteStorage; if ( remoteStorage == null ) { getCurrentConfiguration( true ).setRemoteStorage( null ); } else { if ( getCurrentConfiguration( true ).getRemoteStorage() == null ) { getCurrentConfiguration( true ).setRemoteStorage( new CRemoteStorage() ); } getCurrentConfiguration( true ).getRemoteStorage().setProvider( remoteStorage.getProviderId() ); setWritePolicy( RepositoryWritePolicy.READ_ONLY ); } }
if ( repo.getRemoteStorage() != null ) if ( repo.getRemoteStorage() != null ) getRemoteRepositoryStorage( repo.getId(), repo.getRemoteStorage().getUrl(), repo.getRemoteStorage().getProvider() ); configRemoteStorage.validateStorageUrl( repo.getRemoteStorage().getUrl() ); oldRemoteStorage.validateStorageUrl( repo.getRemoteStorage().getUrl() ); if ( repo.getRemoteStorage().getAuthentication() != null ) prepository.setRemoteAuthenticationSettings( authenticationInfoConverter.convertAndValidateFromModel( repo.getRemoteStorage().getAuthentication() ) ); if ( repo.getRemoteStorage().getConnectionSettings() != null ) prepository.setRemoteConnectionSettings( globalRemoteConnectionSettings.convertAndValidateFromModel( repo.getRemoteStorage().getConnectionSettings() ) ); if ( repo.getRemoteStorage().getHttpProxySettings() != null ) if ( repo.getRemoteStorage().getHttpProxySettings().isBlockInheritance() ) prepository.setRemoteProxySettings( globalHttpProxySettings.convertAndValidateFromModel( repo.getRemoteStorage().getHttpProxySettings() ) );