org.apache.maven.wagon.providers.http.HttpWagon Java Examples
The following examples show how to use
org.apache.maven.wagon.providers.http.HttpWagon.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StaticWagonProvider.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
public Wagon lookup( String roleHint ) throws Exception { log.debug("Looking up wagon for roleHint {}", roleHint); if ("https".equals(roleHint)) { return new HttpWagon(); } else if ("http".equals(roleHint)) { return new HttpWagon(); } throw new IllegalArgumentException("No wagon available for " + roleHint); }
Example #2
Source File: StaticWagonConfigurator.java From spring-cloud-deployer with Apache License 2.0 | 5 votes |
@Override public void configure(Wagon wagon, Object configuration) throws Exception { log.debug("Configuring wagon {} with {}", wagon, configuration); if (wagon instanceof HttpWagon && configuration instanceof MavenProperties.Wagon) { HttpWagon httpWagon = (HttpWagon)wagon; Map<WagonHttpMethod, WagonHttpMethodProperties> httpMethodProperties = ((MavenProperties.Wagon) configuration) .getHttp(); HttpConfiguration httpConfiguration = new HttpConfiguration(); for (Entry<WagonHttpMethod, WagonHttpMethodProperties> entry : httpMethodProperties.entrySet()) { switch (entry.getKey()) { case all: httpConfiguration.setAll(buildConfig(entry.getValue())); break; case get: httpConfiguration.setGet(buildConfig(entry.getValue())); break; case head: httpConfiguration.setHead(buildConfig(entry.getValue())); break; case put: httpConfiguration.setPut(buildConfig(entry.getValue())); break; default: break; } } httpWagon.setHttpConfiguration(httpConfiguration); } }
Example #3
Source File: RepositorySystemFactory.java From zeppelin with Apache License 2.0 | 5 votes |
@Override public Wagon lookup(String roleHint) throws Exception { if ("http".equals(roleHint)) { return new LightweightHttpWagon(); } if ("https".equals(roleHint)) { return new HttpWagon(); } return null; }
Example #4
Source File: DownloadArtifactsTest.java From archiva with Apache License 2.0 | 5 votes |
@Test public void downloadWithRemoteRedirect() throws Exception { RemoteRepository remoteRepository = getRemoteRepositoriesService().getRemoteRepository( "central" ); remoteRepository.setUrl( "http://localhost:" + redirectPort ); getRemoteRepositoriesService().updateRemoteRepository( remoteRepository ); RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ).isExists() ) { roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ); } getUserService( authorizationHeader ).createGuestUser(); roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" ); roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal", "guest" ); getUserService( authorizationHeader ).removeFromCache( "guest" ); Path file = Paths.get( "target/junit-4.9.jar" ); Files.deleteIfExists( file ); HttpWagon httpWagon = new HttpWagon(); httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); httpWagon.get( "repository/internal/junit/junit/4.9/junit-4.9.jar", file.toFile() ); ZipFile zipFile = new ZipFile( file.toFile() ); List<String> entries = getZipEntriesNames( zipFile ); ZipEntry zipEntry = zipFile.getEntry( "org/junit/runners/JUnit4.class" ); assertNotNull( "cannot find zipEntry org/junit/runners/JUnit4.class, entries: " + entries + ", content is: " + FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8") ), zipEntry ); zipFile.close(); file.toFile().deleteOnExit(); }
Example #5
Source File: DownloadSnapshotTest.java From archiva with Apache License 2.0 | 4 votes |
@Test public void downloadSNAPSHOT() throws Exception { String id = Long.toString( System.currentTimeMillis() ); Path srcRep = getProjectDirectory( ).resolve( "src/test/repositories/snapshot-repo" ); Path testRep = getBasedir( ).resolve( "target" ).resolve( "snapshot-repo-" + id ).toAbsolutePath(); FileUtils.copyDirectory( srcRep.toFile( ), testRep.toFile( ) ); createdPaths.add( testRep ); ManagedRepository managedRepository = new ManagedRepository( Locale.getDefault()); managedRepository.setId( id ); managedRepository.setName( "name of " + id ); managedRepository.setLocation( testRep.toString() ); managedRepository.setIndexDirectory( indexDir.resolve( "index-" + id ).toString() ); managedRepository.setPackedIndexDirectory( indexDir.resolve( "indexpacked-" + id ).toString() ); ManagedRepositoriesService managedRepositoriesService = getManagedRepositoriesService(); if ( managedRepositoriesService.getManagedRepository( id ) != null ) { managedRepositoriesService.deleteManagedRepository( id, false ); } getManagedRepositoriesService().addManagedRepository( managedRepository ); RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id ).isExists() ) { roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id ); } getUserService( authorizationHeader ).createGuestUser(); roleManagementService.assignRole( ArchivaRoleConstants.TEMPLATE_GUEST, "guest" ); roleManagementService.assignTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id, "guest" ); getUserService( authorizationHeader ).removeFromCache( "guest" ); Path file = Paths.get( "target/archiva-model-1.4-M4-SNAPSHOT.jar" ); Files.deleteIfExists(file); HttpWagon httpWagon = new HttpWagon(); httpWagon.connect( new Repository( "foo", "http://localhost:" + port ) ); httpWagon.get( "/repository/"+ id +"/org/apache/archiva/archiva-model/1.4-M4-SNAPSHOT/archiva-model-1.4-M4-SNAPSHOT.jar", file.toFile() ); ZipFile zipFile = new ZipFile( file.toFile() ); List<String> entries = getZipEntriesNames( zipFile ); ZipEntry zipEntry = zipFile.getEntry( "org/apache/archiva/model/ArchivaArtifact.class" ); assertNotNull( "cannot find zipEntry org/apache/archiva/model/ArchivaArtifact.class, entries: " + entries + ", content is: " + FileUtils.readFileToString( file.toFile(), Charset.forName( "UTF-8") ), zipEntry ); zipFile.close(); file.toFile().deleteOnExit(); }