if ( repository.getRepositoryKind().isFacetAvailable( ProxyRepository.class ) ) ProxyRepository proxy = repository.adaptToFacet( ProxyRepository.class ); (StorageFileItem) proxy.getRemoteStorage().retrieveItem( proxy, req, proxy.getRemoteUrl() );
while ( isRunning() && getRepository().getProxyMode() != null ) LocalStatus repositoryLocalStatus = getRepository().getLocalStatus(); getRepository().getRepositoryStatusCheckMode(); getRepository().getRemoteStatus( new ResourceStoreRequest( RepositoryItemUid.PATH_ROOT ), true ); ProxyMode repositoryProxyMode = getRepository().getProxyMode(); getRepository().getRemoteStatus( new ResourceStoreRequest( RepositoryItemUid.PATH_ROOT ), true ); long sleepTime = getRepository().getNextRemoteStatusRetainTime(); if ( getRepository().getProxyMode().shouldAutoUnblock() ) "Next attempt to auto-unblock the \"" + getRepository().getName() + "\" (id=" + getRepository().getId() + ") repository by checking its remote peer health will occur in " + DurationFormatUtils.formatDurationWords( sleepTime, true, true ) + "." );
protected synchronized RemoteStorageContext getRemoteStorageContext( ProxyRepository repository ) throws RemoteStorageException final RemoteStorageContext ctx = repository.getRemoteStorageContext(); if ( ctx != null ) if ( !repositoryContexts.containsKey( repository.getId() ) || !ctx.hasContextObject( CONTEXT_UPDATED_KEY ) || ctx.getGeneration() > repositoryContexts.get( repository.getId() ) ) if ( !repositoryContexts.containsKey( repository.getId() ) ) new Object[] { ctx, repositoryContexts.get( repository.getId() ) } ); if ( !repositoryContexts.containsKey( repository.getId() ) ) repositoryContexts.put( repository.getId(), ctx.getGeneration() );
@Inject public YumProxyImpl(final ProxyMetadataRequestStrategy proxyMetadataRequestStrategy, final BlockSqliteDatabasesRequestStrategy blockSqliteDatabasesRequestStrategy, final @Assisted ProxyRepository repository) throws MalformedURLException, URISyntaxException { this.repository = checkNotNull(repository); this.baseDir = RepositoryUtils.getBaseDir(repository); this.yumRepository = new YumRepositoryImpl(baseDir, repository.getId(), null); repository.registerRequestStrategy( BlockSqliteDatabasesRequestStrategy.class.getName(), checkNotNull(blockSqliteDatabasesRequestStrategy) ); repository.registerRequestStrategy( ProxyMetadataRequestStrategy.class.getName(), checkNotNull(proxyMetadataRequestStrategy) ); }
log.debug("Checking if {}:primary.xml locations should be rewritten after being proxied", repository.getId()); final String repositoryUrl = repository.getRemoteUrl(); return processMetadata( repository,
@Override protected void processFileItem(final WalkerContext context, final StorageFileItem item) throws Exception { if (!item.getPath().equals("/" + Yum.PATH_OF_REPOMD_XML) && !locations.contains(item.getPath().substring(1))) { log.trace("Removing obsolete {}:{}", repository.getId(), item.getPath()); repository.deleteItem(true, item.getResourceStoreRequest()); } } });
resource.getRemoteStorage().setRemoteStorageUrl(repository.getRemoteUrl()); resource.setAutoBlockActive(repository.isAutoBlockActive()); resource.setFileTypeValidation(repository.isFileTypeValidation()); if (repository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) { resource.setArtifactMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getArtifactMaxAge()); resource.setMetadataMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getMetadataMaxAge()); resource.setItemMaxAge(repository.adaptToFacet(MavenProxyRepository.class).getItemMaxAge());
sb.append( revt.getRepository().getName() ); sb.append( "\" (repoId=" ).append( revt.getRepository().getId() ).append( ") was " ); sb.append( revt.getRepository().getProxyMode().toString() ).append( "." ); sb.append( revt.getRepository().getName() ); sb.append( "\" (repoId=" ).append( revt.getRepository().getId() ); sb.append( revt.getRepository().getRemoteUrl() ); sb.append( DurationFormatUtils.formatDurationWords( revt.getRepository().getCurrentRemoteStatusRetainTime(), true, true ) + "." );
private boolean isProxy() { return repository.getRemoteUrl() != null; }
proxyRepo.setRemoteUrl( model.getRemoteStorage().getRemoteStorageUrl() ); String oldPasswordForRemoteStorage = null; if ( proxyRepo.getRemoteAuthenticationSettings() != null && UsernamePasswordRemoteAuthenticationSettings.class.isInstance( proxyRepo .getRemoteAuthenticationSettings() ) ) .getRemoteAuthenticationSettings() ).getPassword(); if ( proxyRepo.getRemoteProxySettings() != null && proxyRepo.getRemoteProxySettings().isEnabled() && proxyRepo.getRemoteProxySettings().getProxyAuthentication() != null && UsernamePasswordRemoteAuthenticationSettings.class.isInstance( proxyRepo .getRemoteAuthenticationSettings() ) ) ( (UsernamePasswordRemoteAuthenticationSettings) proxyRepo.getRemoteProxySettings() .getProxyAuthentication() ).getPassword(); proxyRepo.setRemoteAuthenticationSettings( remoteAuth ); proxyRepo.getRemoteStorageContext().removeRemoteAuthenticationSettings(); proxyRepo.setRemoteConnectionSettings( remoteConnSettings ); proxyRepo.getRemoteStorageContext().removeRemoteConnectionSettings(); proxyRepo.setRemoteProxySettings( httpProxySettings ); proxyRepo.getRemoteStorageContext().removeRemoteProxySettings();
public RepositoryStatusCheckerThread( final Logger logger, final ProxyRepository repository ) { super( "RepositoryStatusChecker-" + repository.getId() ); this.logger = logger; this.repository = repository; this.running = true; }
if ( !repository.getRepositoryKind().isFacetAvailable( MavenProxyRepository.class ) ) if ( isAlreadyBeingIndexed( repository.getId() ) ) MavenProxyRepository mpr = repository.adaptToFacet( MavenProxyRepository.class ); Lock lock = getLock( repository.getId() ).writeLock(); lock.lock(); getLogger().info( "Trying to get remote index for repository " + repository.getId() ); getLogger().info( "Remote indexes updated successfully for repository " + repository.getId() ); "Remote indexes unchanged (no update needed) for repository " + repository.getId() ); getLogger().warn( "Cannot fetch remote index for repository " + repository.getId(), e );
proxyRepo.setRemoteUrl(model.getRemoteStorage().getRemoteStorageUrl()); } catch (RemoteStorageException e) { ValidationResponse vr = new ApplicationValidationResponse(); if (proxyRepo.getRemoteAuthenticationSettings() != null && UsernamePasswordRemoteAuthenticationSettings.class.isInstance(proxyRepo .getRemoteAuthenticationSettings())) { oldPasswordForRemoteStorage = ((UsernamePasswordRemoteAuthenticationSettings) proxyRepo .getRemoteAuthenticationSettings()).getPassword(); proxyRepo.setRemoteAuthenticationSettings(remoteAuth); proxyRepo.getRemoteStorageContext().removeRemoteAuthenticationSettings(); proxyRepo.setRemoteConnectionSettings(remoteConnSettings); proxyRepo.getRemoteStorageContext().removeRemoteConnectionSettings(); proxyRepo.setAutoBlockActive(((RepositoryProxyResource) model).isAutoBlockActive()); proxyRepo.setFileTypeValidation(((RepositoryProxyResource) model).isFileTypeValidation());
sb.append(revt.getRepository().getName()); sb.append("' (ID='").append(revt.getRepository().getId()).append("') was set to "); sb.append(revt.getRepository().getProxyMode().toString()).append(".");
private DefaultStorageFileItem doRetriveRemoteChecksumItem( ProxyRepository proxy, ResourceStoreRequest request ) throws ItemNotFoundException { try { return (DefaultStorageFileItem) proxy.getRemoteStorage().retrieveItem( proxy, request, proxy.getRemoteUrl() ); } catch ( RemoteAccessException e ) { throw new ItemNotFoundException( request, proxy, e ); } catch ( RemoteStorageException e ) { throw new ItemNotFoundException( request, proxy, e ); } } }
@Override protected ChecksumPolicy getChecksumPolicy( ProxyRepository proxy, AbstractStorageItem item ) { if ( isChecksum( item.getRepositoryItemUid().getPath() ) ) { // do not validate checksum files return null; } if ( !proxy.getRepositoryKind().isFacetAvailable( MavenProxyRepository.class ) ) { // we work only with maven proxy reposes, all others are neglected return null; } MavenProxyRepository mpr = proxy.adaptToFacet( MavenProxyRepository.class ); ChecksumPolicy checksumPolicy = mpr.getChecksumPolicy(); if ( checksumPolicy == null || !checksumPolicy.shouldCheckChecksum() || !( item instanceof DefaultStorageFileItem ) ) { // there is either no need to validate or we can't validate the item content return null; } return checksumPolicy; }
if (!repository.adaptToFacet(MavenProxyRepository.class).isDownloadRemoteIndexes()) { return; repository.expireCaches(new ResourceStoreRequest(PUBLISHING_PATH_PREFIX)); log.info("Cannot incrementally update index for repository {}", repository.getId()); throw e;
/** * The repository is capable of remote access for indexing purposes. * * @since 2.7.0 */ private boolean REMOTEACCESSALLOWED(Repository repository) { final ProxyRepository proxyRepository = repository.adaptToFacet(ProxyRepository.class); if (proxyRepository != null) { return proxyRepository.getProxyMode().shouldProxy(); } else { return false; } }
RemoteRepositoryStorage oldRemoteStorage = prepository.getRemoteStorage(); prepository.setRemoteStorage( configRemoteStorage ); prepository.setRemoteAuthenticationSettings( authenticationInfoConverter.convertAndValidateFromModel( repo.getRemoteStorage().getAuthentication() ) ); prepository.setRemoteConnectionSettings( globalRemoteConnectionSettings.convertAndValidateFromModel( repo.getRemoteStorage().getConnectionSettings() ) ); prepository.setRemoteProxySettings( null ); prepository.setRemoteProxySettings( globalHttpProxySettings.convertAndValidateFromModel( repo.getRemoteStorage().getHttpProxySettings() ) ); prepository.setRemoteStorage( null );