@Override public void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg) throws RepositoryException { setBaseConfig(repo, cfg); repo.setCheckPath(cfg.getCheckPath()); repo.setSchedulingDefinition(cfg.getRefreshCronExpression()); try { repo.setLocation(new URI(cfg.getUrl())); } catch (UnsupportedURIException | URISyntaxException e) { log.error("Could not set remote url " + cfg.getUrl()); throw new RepositoryException("The url config is not a valid uri: " + cfg.getUrl()); repo.setTimeout(Duration.ofSeconds(cfg.getTimeout())); RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class).get(); remoteIndexFeature.setDownloadRemoteIndex(cfg.isDownloadRemoteIndex()); remoteIndexFeature.setDownloadRemoteIndexOnStartup(cfg.isDownloadRemoteIndexOnStartup()); repo.addExtraHeader( key.toString(), cfg.getExtraHeaders().get(key).toString() ); repo.addExtraParameter( key.toString(), cfg.getExtraParameters().get(key).toString() ); credentials.setPassword(cfg.getPassword().toCharArray()); credentials.setUsername(cfg.getUsername()); repo.setCredentials(credentials); } else { credentials.setPassword(new char[0]); IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); if (cfg.getIndexDir() != null) { indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir()));
@SuppressWarnings("unchecked") @Override public void updateRemoteInstance( EditableRemoteRepository remoteRepository, RemoteRepositoryConfiguration configuration ) throws RepositoryException { try { remoteRepository.setName( remoteRepository.getPrimaryLocale(), configuration.getName( ) ); remoteRepository.setBaseUri( new URI( "" ) ); remoteRepository.setDescription( remoteRepository.getPrimaryLocale(), configuration.getDescription( ) ); remoteRepository.setLayout( configuration.getLayout( ) ); remoteRepository.setSchedulingDefinition( configuration.getRefreshCronExpression( ) ); remoteRepository.setCheckPath( configuration.getCheckPath( ) ); remoteRepository.setExtraHeaders( configuration.getExtraHeaders( ) ); remoteRepository.setExtraParameters( configuration.getExtraParameters( ) ); remoteRepository.setTimeout( Duration.ofSeconds( configuration.getTimeout( ) ) ); char[] pwd = configuration.getPassword()==null ? "".toCharArray() : configuration.getPassword().toCharArray(); remoteRepository.setCredentials( new PasswordCredentials( configuration.getUsername( ), pwd ) ); remoteRepository.setLocation( new URI( configuration.getUrl( )==null ? "" : configuration.getUrl() ) ); RemoteIndexFeature rif = remoteRepository.getFeature( RemoteIndexFeature.class ).get( ); rif.setDownloadRemoteIndexOnStartup( configuration.isDownloadRemoteIndexOnStartup( ) ); rif.setDownloadRemoteIndex( configuration.isDownloadRemoteIndex( ) ); rif.setIndexUri( new URI( configuration.getIndexDir( ) ) ); rif.setDownloadTimeout( Duration.ofSeconds( configuration.getRemoteDownloadTimeout( ) ) ); rif.setProxyId( configuration.getRemoteDownloadNetworkProxyId( ) ); } catch ( Exception e ) { throw new RepositoryException( "Error", e ); } }