@Override public NetworkProxy getNetworkProxy( String networkProxyId ) throws RepositoryAdminException { for ( NetworkProxy networkProxy : getNetworkProxies() ) { if ( StringUtils.equals( networkProxyId, networkProxy.getId() ) ) { return networkProxy; } } return null; }
@Override public void addNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation ) throws RepositoryAdminException { if ( networkProxy == null ) { return; } if ( getNetworkProxy( networkProxy.getId() ) != null ) { throw new RepositoryAdminException( "cannot add NetworkProxy with id " + networkProxy.getId() + " already exist" ); } Configuration configuration = getArchivaConfiguration().getConfiguration(); configuration.addNetworkProxy( getNetworkProxyConfiguration( networkProxy ) ); triggerAuditEvent( networkProxy.getId(), null, AuditEvent.ADD_NETWORK_PROXY, auditInformation ); saveConfiguration( configuration ); }
@Override public void updateNetworkProxy( NetworkProxy networkProxy, AuditInformation auditInformation ) throws RepositoryAdminException { if ( networkProxy == null ) { return; } if ( getNetworkProxy( networkProxy.getId() ) == null ) { throw new RepositoryAdminException( "cannot update NetworkProxy with id " + networkProxy.getId() + " as not exist" ); } Configuration configuration = getArchivaConfiguration().getConfiguration(); NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy ); configuration.removeNetworkProxy( networkProxyConfiguration ); configuration.addNetworkProxy( networkProxyConfiguration ); triggerAuditEvent( networkProxy.getId(), null, AuditEvent.MODIFY_NETWORK_PROXY, auditInformation ); saveConfiguration( configuration ); }
@Override public void deleteNetworkProxy( String networkProxyId, AuditInformation auditInformation ) throws RepositoryAdminException { NetworkProxy networkProxy = getNetworkProxy( networkProxyId ); if ( networkProxy == null ) { throw new RepositoryAdminException( "cannot delete NetworkProxy with id " + networkProxyId + " as not exist" ); } Configuration configuration = getArchivaConfiguration().getConfiguration(); NetworkProxyConfiguration networkProxyConfiguration = getNetworkProxyConfiguration( networkProxy ); configuration.removeNetworkProxy( networkProxyConfiguration ); for ( RemoteRepositoryConfiguration rrc : configuration.getRemoteRepositories() ) { if ( StringUtils.equals( rrc.getRemoteDownloadNetworkProxyId(), networkProxyId ) ) { rrc.setRemoteDownloadNetworkProxyId( null ); } } triggerAuditEvent( networkProxy.getId(), null, AuditEvent.DELETE_NETWORK_PROXY, auditInformation ); saveConfiguration( configuration ); }