@Override public void onRepositoryItemEvent( final RepositoryItemEvent ievt ) { // is this event coming from our master? if ( getMasterRepository() == ievt.getRepository() ) { try { if ( ievt instanceof RepositoryItemEventStore || ievt instanceof RepositoryItemEventCache ) { createLink( ievt.getItem() ); } else if ( ievt instanceof RepositoryItemEventDelete ) { deleteLink( ievt.getItem() ); } } catch ( Exception e ) { getLogger().warn( "Could not sync shadow repository because of exception", e ); } } }
@Override public Repository getMasterRepository() { try { return getRepositoryRegistry().getRepository( getExternalConfiguration( false ).getMasterRepositoryId() ); } catch ( NoSuchRepositoryException e ) { getLogger().warn( "ShadowRepository ID='" + getId() + "' cannot fetch it's master repository with ID='" + getExternalConfiguration( false ).getMasterRepositoryId() + "'!", e ); return null; } }
public void synchronizeWithMaster() if ( !getLocalStatus().shouldServiceRequest() ) getLogger().info( "Syncing shadow " + getId() + " with master repository " + getMasterRepository().getId() ); expireNotFoundCaches( root ); final DefaultWalkerContext ctx = new DefaultWalkerContext( getMasterRepository(), root ); getWalker().walk( ctx );
@Override public void setMasterRepository( final Repository masterRepository ) throws IncompatibleMasterRepositoryException { if ( getMasterRepositoryContentClass().getId().equals( masterRepository.getRepositoryContentClass().getId() ) ) { getExternalConfiguration( true ).setMasterRepositoryId( masterRepository.getId() ); } else { throw new IncompatibleMasterRepositoryException( this, masterRepository.getId() ); } }
@Override public void setSynchronizeAtStartup( final boolean val ) { getExternalConfiguration( true ).setSynchronizeAtStartup( val ); }
@Override public MavenRepository getMasterRepository() { return super.getMasterRepository().adaptToFacet( MavenRepository.class ); }
protected void synchronizeLink( final StorageItem item ) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException { createLink( item ); }
result = super.doRetrieveItem( request );
@Override public boolean isSynchronizeAtStartup() { return getExternalConfiguration( false ).isSynchronizeAtStartup(); }
protected StorageItem doRetrieveItemFromMaster( final ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { try { return getMasterRepository().retrieveItem( request ); } catch ( AccessDeniedException e ) { // if client has no access to content over shadow, we just hide the fact throw new ItemNotFoundException( request, this, e ); } } }
@Deprecated @Override public String getMasterRepositoryId() { // NEXUS-4901: this change is to lessen the logging noise, that is otherwise harmless but ugly return getExternalConfiguration( false ).getMasterRepositoryId(); }
/** * The shadow is delegating it's availability to it's master, but we can still shot down the shadow only. */ @Override public LocalStatus getLocalStatus() { return super.getLocalStatus().shouldServiceRequest() && getMasterRepository().getLocalStatus().shouldServiceRequest() ? LocalStatus.IN_SERVICE : LocalStatus.OUT_OF_SERVICE; }