@Override protected AbstractMavenRepositoryConfiguration getExternalConfiguration( boolean forModification ) { return (AbstractMavenRepositoryConfiguration) super.getExternalConfiguration( forModification ); }
@Override public DefaultFSLocalRepositoryStorage getLocalStorage() { return (DefaultFSLocalRepositoryStorage) super.getLocalStorage(); }
protected DownloadMirrorSelector openDownloadMirrorSelector( ResourceStoreRequest request ) { return this.getDownloadMirrors().openSelector( this.getRemoteUrl() ); }
/** * Checks if item is old with "default" maxAge. * * @param item the item * @return true, if it is old */ protected boolean isOld( StorageItem item ) { return isOld( getItemMaxAge(), item ); }
/** * Checks if item is old with given maxAge. * * @param maxAge * @param item * @return */ protected boolean isOld( int maxAge, StorageItem item ) { return isOld( maxAge, item, isItemAgingActive() ); }
final RepositoryItemUid itemUid = createUid( request.getRequestPath() ); DownloadMirrorSelector selector = this.openDownloadMirrorSelector( request ); if ( getLogger().isDebugEnabled() ) getLogger().debug( "Mirror count:" + mirrors.size() ); mirrors.add( new Mirror( "default", getRemoteUrl(), getRemoteUrl() ) ); if ( getRemoteStorageContext() != null ) RemoteConnectionSettings settings = getRemoteStorageContext().getRemoteConnectionSettings(); if (settings != null) { retryCount = settings.getRetrievalRetryCount(); if ( getLogger().isDebugEnabled() ) getLogger().debug( "Using mirror URL:" + mirror.getUrl() + ", retryCount=" + retryCount ); getRemoteStorage().validateStorageUrl( mirror.getUrl() ); logFailedMirror( mirror, e ); getRemoteStorage().retrieveItem( this, request, mirror.getUrl() ); remoteItem = doCacheItem( remoteItem ); if ( doValidateRemoteItemContent( request, mirror.getUrl(), remoteItem, events ) )
if ( getRepositoryKind().isFacetAvailable( ProxyRepository.class ) ) ProxyMode oldProxyMode = getProxyMode(); getExternalConfiguration( false ).setProxyMode( proxyMode ); if ( isDirty() ) getExternalConfiguration( true ).setProxyMode( proxyMode ); getExternalConfiguration( true ).setProxyMode( proxyMode ); long initialStep = getRemoteConnectionSettings().getConnectionTimeout() * 2L; if ( getLogger().isDebugEnabled() ) getLogger().debug( "We have a BLOCKED_MANUAL -> ALLOW transition, purging NFC" ); getNotFoundCache().purge(); resetRemoteStatus(); eventBus().post( new RepositoryEventProxyModeSet( this, oldProxyMode, proxyMode, cause ) ); eventBus().post( new RepositoryEventProxyModeChanged( this, oldProxyMode, proxyMode, cause ) );
boolean shouldProxy = !request.isRequestLocalOnly() && getProxyMode() != null && getProxyMode().shouldProxy(); for ( RequestProcessor processor : getRequestProcessors().values() ) if ( localItem == null || isOld( localItem ) ) if ( getLogger().isDebugEnabled() ) getLogger().debug( "Item " + request.toString() + " is old, checking for newer file on remote then local: " shouldGetRemote = doCheckRemoteItemExistence( localItem, request ); markItemRemotelyChecked( localItem ); if ( getLogger().isDebugEnabled() ) getLogger().debug( "No newer version of item " + request.toString() + " found on remote storage." ); if ( getLogger().isDebugEnabled() ) getLogger().debug( "Newer version of item " + request.toString() + " is found on remote storage." ); autoBlockProxying( ex ); remoteItem = doRetrieveRemoteItem( request );
throws IllegalOperationException, ItemNotFoundException, StorageException if ( getLogger().isDebugEnabled() ) db.append( ", remoteOnly=" ).append( request.isRequestRemoteOnly() ); if ( getProxyMode() != null ) db.append( ", ProxyMode=" + getProxyMode().toString() ); getLogger().debug( db.toString() ); final RepositoryItemUid itemUid = createUid( request.getRequestPath() ); if ( !getRepositoryKind().isFacetAvailable( ProxyRepository.class ) ) if ( localItem != null && !isOld( localItem ) ) if ( localItem != null && !isOld( localItem ) ) return doRetrieveItem0( request, localItem );
for ( RequestProcessor processor : getRequestProcessors().values() ) if ( getLogger().isDebugEnabled() ) getLogger().debug( "Caching item " + item.getRepositoryItemUid().toString() + " in local storage of repository." ); final Action action = getResultingActionOnWrite( item.getResourceStoreRequest() ); getLocalStorage().storeItem( this, item ); removeFromNotFoundCache( item.getResourceStoreRequest() ); result = getLocalStorage().retrieveItem( this, new ResourceStoreRequest( item ) ); eventBus().post( new RepositoryItemEventCacheCreate( this, result ) ); eventBus().post( new RepositoryItemEventCacheUpdate( this, result ) ); getLogger().warn( "Nexus BUG in " + RepositoryStringUtils.getHumanizedNameString( this ) getLogger().warn( "LocalStorage or repository " + RepositoryStringUtils.getHumanizedNameString( this ) + " does not handle STORE operation, not caching remote fetched item.", ex );
public void setAutoBlockActive( boolean val ) { // NEXUS-3516: if user disables autoblock, and repo is auto-blocked, unblock it if ( !val && ProxyMode.BLOCKED_AUTO.equals( getProxyMode() ) ) { getLogger().warn( String.format( "Proxy Repository %s was auto-blocked, but user disabled this feature. Unblocking repository, but this MAY cause Nexus to leak connections (if remote repository is still down)!", RepositoryStringUtils.getHumanizedNameString( this ) ) ); setProxyMode( ProxyMode.ALLOW ); } getExternalConfiguration( true ).setAutoBlockActive( val ); }
public void setRemoteUrl( String remoteUrl ) throws RemoteStorageException { if ( getRemoteStorage() != null ) { String newRemoteUrl = remoteUrl.trim(); String oldRemoteUrl = getRemoteUrl(); if ( !newRemoteUrl.endsWith( RepositoryItemUid.PATH_SEPARATOR ) ) { newRemoteUrl = newRemoteUrl + RepositoryItemUid.PATH_SEPARATOR; } getRemoteStorage().validateStorageUrl( newRemoteUrl ); getCurrentConfiguration( true ).getRemoteStorage().setUrl( newRemoteUrl ); if ( ( StringUtils.isEmpty( oldRemoteUrl ) && StringUtils.isNotEmpty( newRemoteUrl ) ) || ( StringUtils.isNotEmpty( oldRemoteUrl ) && !oldRemoteUrl.equals( newRemoteUrl ) ) ) { this.remoteUrlChanged = true; } } else { throw new RemoteStorageException( "No remote storage set on repository \"" + getName() + "\" (ID=\"" + getId() + "\"), cannot set remoteUrl!" ); } }
public ProxyMode getProxyMode() { if ( getRepositoryKind().isFacetAvailable( ProxyRepository.class ) ) { return getExternalConfiguration( false ).getProxyMode(); } else { return null; } }
if ( !getProxyMode().shouldCheckRemoteStatus() ) if ( isRemoteStorageReachable( request ) ) autoUnBlockProxying(); autoBlockProxying( new ItemNotFoundException( request, AbstractProxyRepository.this ) ); autoBlockProxying( e );
@SuppressWarnings("deprecation") @Override public StorageItem retrieveDirectItem(ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException, IOException { // bypass access control return super.retrieveItem(false, request); }
@Override protected StorageItem doRetrieveItem( ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { if ( !shouldServeByPolicies( request ) ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "The serving of item " + request.toString() + " is forbidden by Maven repository policy." ); } throw new ItemNotFoundException( request, this ); } return super.doRetrieveItem( request ); }
@Override public String getRemoteUrl() { if (!StringUtils.isEmpty(overwriteRemoteUrl)) { return overwriteRemoteUrl; } return super.getRemoteUrl(); }
@SuppressWarnings("deprecation") @Override public StorageItem retrieveItem(ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { // TODO do not use this since it bypasses access control if (request.getRequestPath().startsWith("/.nexus")) { return super.retrieveItem(request); } return facade.handleRetrieve(this, request, facade.get(request)); }