mirror of https://github.com/apache/archiva.git
[MRM-1490] expose service tru rest
impl Repo management service git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1159531 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
014e2fa339
commit
53d4ecac05
|
@ -28,6 +28,11 @@
|
||||||
<name>Archiva Web :: REST support :: Api</name>
|
<name>Archiva Web :: REST support :: Api</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.redback</groupId>
|
<groupId>org.codehaus.redback</groupId>
|
||||||
<artifactId>redback-authorization-api</artifactId>
|
<artifactId>redback-authorization-api</artifactId>
|
||||||
|
|
|
@ -28,11 +28,11 @@ import java.io.Serializable;
|
||||||
@XmlRootElement( name = "managedRepository" )
|
@XmlRootElement( name = "managedRepository" )
|
||||||
public class ManagedRepository
|
public class ManagedRepository
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
private String layout;
|
private String layout;
|
||||||
|
@ -40,12 +40,12 @@ public class ManagedRepository
|
||||||
private boolean snapshots = false;
|
private boolean snapshots = false;
|
||||||
|
|
||||||
private boolean releases = false;
|
private boolean releases = false;
|
||||||
|
|
||||||
public ManagedRepository()
|
public ManagedRepository()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManagedRepository( String id, String name, String url, String layout, boolean snapshots, boolean releases )
|
public ManagedRepository( String id, String name, String url, String layout, boolean snapshots, boolean releases )
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -55,56 +55,33 @@ public class ManagedRepository
|
||||||
this.snapshots = snapshots;
|
this.snapshots = snapshots;
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object other)
|
|
||||||
{
|
|
||||||
if ( this == other)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !(other instanceof ManagedRepository) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ManagedRepository that = (ManagedRepository) other;
|
|
||||||
boolean result = true;
|
|
||||||
result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLayout()
|
public String getLayout()
|
||||||
{
|
{
|
||||||
return this.layout;
|
return this.layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl()
|
public String getUrl()
|
||||||
{
|
{
|
||||||
return this.url;
|
return this.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int result = 17;
|
|
||||||
result = 37 * result + ( id != null ? id.hashCode() : 0 );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReleases()
|
public boolean isReleases()
|
||||||
{
|
{
|
||||||
return this.releases;
|
return this.releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get null
|
* Get null
|
||||||
|
@ -112,35 +89,68 @@ public class ManagedRepository
|
||||||
public boolean isSnapshots()
|
public boolean isSnapshots()
|
||||||
{
|
{
|
||||||
return this.snapshots;
|
return this.snapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id)
|
public void setId( String id )
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayout(String layout)
|
public void setLayout( String layout )
|
||||||
{
|
{
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
public void setName( String name )
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReleases(boolean releases)
|
public void setReleases( boolean releases )
|
||||||
{
|
{
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSnapshots(boolean snapshots)
|
public void setSnapshots( boolean snapshots )
|
||||||
{
|
{
|
||||||
this.snapshots = snapshots;
|
this.snapshots = snapshots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrl(String url)
|
public void setUrl( String url )
|
||||||
{
|
{
|
||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int result = 17;
|
||||||
|
result = 37 * result + ( id != null ? id.hashCode() : 0 );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals( Object other )
|
||||||
|
{
|
||||||
|
if ( this == other )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( other instanceof ManagedRepository ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ManagedRepository that = (ManagedRepository) other;
|
||||||
|
boolean result = true;
|
||||||
|
result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "ManagedRepository{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", url='" + url + '\''
|
||||||
|
+ ", layout='" + layout + '\'' + ", snapshots=" + snapshots + ", releases=" + releases + '}';
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,20 +26,20 @@ import java.io.Serializable;
|
||||||
@XmlRootElement( name = "remoteRepository" )
|
@XmlRootElement( name = "remoteRepository" )
|
||||||
public class RemoteRepository
|
public class RemoteRepository
|
||||||
implements Serializable
|
implements Serializable
|
||||||
{
|
{
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
|
|
||||||
private String layout;
|
private String layout;
|
||||||
|
|
||||||
public RemoteRepository()
|
public RemoteRepository()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
}
|
}
|
||||||
|
|
||||||
public RemoteRepository( String id, String name, String url, String layout )
|
public RemoteRepository( String id, String name, String url, String layout )
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
@ -47,69 +47,79 @@ public class RemoteRepository
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object other)
|
|
||||||
{
|
|
||||||
if ( this == other)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !(other instanceof RemoteRepository) )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoteRepository that = (RemoteRepository) other;
|
|
||||||
boolean result = true;
|
|
||||||
result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getId()
|
public String getId()
|
||||||
{
|
{
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLayout()
|
public String getLayout()
|
||||||
{
|
{
|
||||||
return this.layout;
|
return this.layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUrl()
|
public String getUrl()
|
||||||
{
|
{
|
||||||
return this.url;
|
return this.url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setId( String id )
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLayout( String layout )
|
||||||
|
{
|
||||||
|
this.layout = layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName( String name )
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl( String url )
|
||||||
|
{
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
int result = 17;
|
int result = 17;
|
||||||
result = 37 * result + ( id != null ? id.hashCode() : 0 );
|
result = 37 * result + ( id != null ? id.hashCode() : 0 );
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id)
|
public boolean equals( Object other )
|
||||||
{
|
{
|
||||||
this.id = id;
|
if ( this == other )
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !( other instanceof RemoteRepository ) )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoteRepository that = (RemoteRepository) other;
|
||||||
|
boolean result = true;
|
||||||
|
result = result && ( getId() == null ? that.getId() == null : getId().equals( that.getId() ) );
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayout(String layout)
|
@Override
|
||||||
|
public String toString()
|
||||||
{
|
{
|
||||||
this.layout = layout;
|
return "RemoteRepository{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", url='" + url + '\''
|
||||||
|
+ ", layout='" + layout + '\'' + '}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name)
|
|
||||||
{
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUrl(String url)
|
|
||||||
{
|
|
||||||
this.url = url;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services;
|
||||||
|
|
||||||
import org.apache.archiva.rest.api.model.ManagedRepository;
|
import org.apache.archiva.rest.api.model.ManagedRepository;
|
||||||
import org.apache.archiva.rest.api.model.RemoteRepository;
|
import org.apache.archiva.rest.api.model.RemoteRepository;
|
||||||
|
import org.apache.maven.archiva.security.ArchivaRoleConstants;
|
||||||
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
|
||||||
|
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
|
@ -40,13 +41,13 @@ public interface RepositoriesService
|
||||||
@Path( "getManagedRepositories" )
|
@Path( "getManagedRepositories" )
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( noRestriction = true )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
|
||||||
List<ManagedRepository> getManagedRepositories();
|
List<ManagedRepository> getManagedRepositories();
|
||||||
|
|
||||||
@Path( "getRemoteRepositories" )
|
@Path( "getRemoteRepositories" )
|
||||||
@GET
|
@GET
|
||||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } )
|
||||||
@RedbackAuthorization( noRestriction = true )
|
@RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION)
|
||||||
List<RemoteRepository> getRemoteRepositories();
|
List<RemoteRepository> getRemoteRepositories();
|
||||||
|
|
||||||
@Path( "scanRepository" )
|
@Path( "scanRepository" )
|
||||||
|
|
|
@ -33,6 +33,10 @@
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.archiva</groupId>
|
||||||
|
<artifactId>archiva-security</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.redback</groupId>
|
<groupId>org.codehaus.redback</groupId>
|
||||||
<artifactId>redback-authorization-api</artifactId>
|
<artifactId>redback-authorization-api</artifactId>
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.archiva.rest.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.rest.api.services.PingService;
|
import org.apache.archiva.rest.api.services.PingService;
|
||||||
|
import org.codehaus.plexus.redback.users.User;
|
||||||
|
import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +39,7 @@ public class DefaultPingService
|
||||||
|
|
||||||
public String pingWithAuthz()
|
public String pingWithAuthz()
|
||||||
{
|
{
|
||||||
|
User user = RedbackAuthenticationThreadLocal.get();
|
||||||
return ping();
|
return ping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,62 @@ package org.apache.archiva.rest.services;
|
||||||
import org.apache.archiva.rest.api.model.ManagedRepository;
|
import org.apache.archiva.rest.api.model.ManagedRepository;
|
||||||
import org.apache.archiva.rest.api.model.RemoteRepository;
|
import org.apache.archiva.rest.api.model.RemoteRepository;
|
||||||
import org.apache.archiva.rest.api.services.RepositoriesService;
|
import org.apache.archiva.rest.api.services.RepositoriesService;
|
||||||
|
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||||
|
import org.apache.maven.archiva.configuration.Configuration;
|
||||||
|
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||||
|
import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
@Service("repositoriesService#rest")
|
@Service( "repositoriesService#rest" )
|
||||||
public class DefaultRepositoriesService
|
public class DefaultRepositoriesService
|
||||||
implements RepositoriesService
|
implements RepositoriesService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
protected ArchivaConfiguration archivaConfiguration;
|
||||||
|
|
||||||
public List<ManagedRepository> getManagedRepositories()
|
public List<ManagedRepository> getManagedRepositories()
|
||||||
{
|
{
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
List<ManagedRepositoryConfiguration> managedRepoConfigs =
|
||||||
|
archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||||
|
|
||||||
|
List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
|
||||||
|
|
||||||
|
for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
|
||||||
|
{
|
||||||
|
// TODO fix resolution of repo url!
|
||||||
|
ManagedRepository repo =
|
||||||
|
new ManagedRepository( repoConfig.getId(), repoConfig.getName(), "URL", repoConfig.getLayout(),
|
||||||
|
repoConfig.isSnapshots(), repoConfig.isReleases() );
|
||||||
|
managedRepos.add( repo );
|
||||||
|
}
|
||||||
|
|
||||||
|
return managedRepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RemoteRepository> getRemoteRepositories()
|
public List<RemoteRepository> getRemoteRepositories()
|
||||||
{
|
{
|
||||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
Configuration config = archivaConfiguration.getConfiguration();
|
||||||
|
List<RemoteRepositoryConfiguration> remoteRepoConfigs = config.getRemoteRepositories();
|
||||||
|
|
||||||
|
List<RemoteRepository> remoteRepos = new ArrayList<RemoteRepository>( remoteRepoConfigs.size() );
|
||||||
|
|
||||||
|
for ( RemoteRepositoryConfiguration repoConfig : remoteRepoConfigs )
|
||||||
|
{
|
||||||
|
RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(),
|
||||||
|
repoConfig.getLayout() );
|
||||||
|
remoteRepos.add( repo );
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteRepos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
public Boolean scanRepository( String repositoryId, boolean fullScan )
|
||||||
|
|
|
@ -41,15 +41,21 @@
|
||||||
|
|
||||||
<jaxrs:server id="archivaServices" address="/archivaServices">
|
<jaxrs:server id="archivaServices" address="/archivaServices">
|
||||||
|
|
||||||
<jaxrs:serviceBeans>
|
|
||||||
<ref bean="pingService#rest"/>
|
|
||||||
</jaxrs:serviceBeans>
|
|
||||||
<jaxrs:providers>
|
<jaxrs:providers>
|
||||||
<ref bean="authenticationInterceptor#rest"/>
|
<ref bean="authenticationInterceptor#rest"/>
|
||||||
<ref bean="permissionInterceptor#rest"/>
|
<ref bean="permissionInterceptor#rest"/>
|
||||||
<ref bean="repositoriesService#rest"/>
|
<ref bean="repositoriesService#rest"/>
|
||||||
</jaxrs:providers>
|
</jaxrs:providers>
|
||||||
|
|
||||||
|
<jaxrs:serviceBeans>
|
||||||
|
<ref bean="pingService#rest"/>
|
||||||
|
<ref bean="repositoriesService#rest"/>
|
||||||
|
</jaxrs:serviceBeans>
|
||||||
|
|
||||||
|
<jaxrs:outInterceptors>
|
||||||
|
<ref bean="threadLocalUserCleaner#rest"/>
|
||||||
|
</jaxrs:outInterceptors>
|
||||||
|
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
|
@ -0,0 +1,33 @@
|
||||||
|
package org.apache.archiva.rest.services;
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
import org.codehaus.redback.rest.services.AbstractRestServicesTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Olivier Lamy
|
||||||
|
* @since TODO
|
||||||
|
*/
|
||||||
|
public abstract class AbstractArchivaRestTest
|
||||||
|
extends AbstractRestServicesTest
|
||||||
|
{
|
||||||
|
public String guestAuthzHeader =
|
||||||
|
"Basic " + org.apache.cxf.common.util.Base64Utility.encode( ( "guest" + ":" ).getBytes() );
|
||||||
|
}
|
|
@ -24,6 +24,7 @@ import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||||
import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
|
import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
|
||||||
import org.apache.cxf.jaxrs.client.WebClient;
|
import org.apache.cxf.jaxrs.client.WebClient;
|
||||||
import org.codehaus.redback.rest.services.AbstractRestServicesTest;
|
import org.codehaus.redback.rest.services.AbstractRestServicesTest;
|
||||||
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +32,7 @@ import org.junit.Test;
|
||||||
* @since 1.4
|
* @since 1.4
|
||||||
*/
|
*/
|
||||||
public class PingServiceTest
|
public class PingServiceTest
|
||||||
extends AbstractRestServicesTest
|
extends AbstractArchivaRestTest
|
||||||
{
|
{
|
||||||
|
|
||||||
PingService getPingService()
|
PingService getPingService()
|
||||||
|
@ -76,8 +77,21 @@ public class PingServiceTest
|
||||||
{
|
{
|
||||||
|
|
||||||
PingService service = getPingService();
|
PingService service = getPingService();
|
||||||
|
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
|
||||||
WebClient.client( service ).header( "Authorization", authorizationHeader );
|
WebClient.client( service ).header( "Authorization", authorizationHeader );
|
||||||
String res = service.pingWithAuthz();
|
String res = service.pingWithAuthz();
|
||||||
assertEquals( "Yeah Baby It rocks!", res );
|
assertEquals( "Yeah Baby It rocks!", res );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Ignore("FIXME guest failed ???")
|
||||||
|
public void pingWithAuthzGuest()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
PingService service = getPingService();
|
||||||
|
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
|
||||||
|
WebClient.client( service ).header( "Authorization", guestAuthzHeader );
|
||||||
|
String res = service.pingWithAuthz();
|
||||||
|
assertEquals( "Yeah Baby It rocks!", res );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,27 +19,55 @@ package org.apache.archiva.rest.services;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.rest.api.model.RemoteRepository;
|
||||||
import org.apache.archiva.rest.api.services.RepositoriesService;
|
import org.apache.archiva.rest.api.services.RepositoriesService;
|
||||||
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
|
||||||
import org.codehaus.redback.rest.services.AbstractRestServicesTest;
|
import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
|
||||||
|
import org.apache.cxf.jaxrs.client.WebClient;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
public class RepositoriesServiceTest
|
public class RepositoriesServiceTest
|
||||||
extends AbstractRestServicesTest
|
extends AbstractArchivaRestTest
|
||||||
{
|
{
|
||||||
RepositoriesService getPingService()
|
RepositoriesService getRepositoriesService()
|
||||||
{
|
{
|
||||||
return JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
|
return JAXRSClientFactory.create( "http://localhost:" + port + "/services/archivaServices/",
|
||||||
RepositoriesService.class );
|
RepositoriesService.class );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test( expected = ServerWebApplicationException.class )
|
||||||
public void listRemoteRepositories() throws Exception
|
public void listRemoteRepositoriesKarmaFailed()
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
|
RepositoriesService service = getRepositoriesService();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
assertFalse( service.getRemoteRepositories().isEmpty() );
|
||||||
|
}
|
||||||
|
catch ( ServerWebApplicationException e )
|
||||||
|
{
|
||||||
|
assertEquals( 403, e.getStatus() );
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void listRemoteRepositoriesKarma()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
RepositoriesService service = getRepositoriesService();
|
||||||
|
|
||||||
|
WebClient.client( service ).header( "Authorization", authorizationHeader );
|
||||||
|
WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
|
||||||
|
List<RemoteRepository> repos = service.getRemoteRepositories();
|
||||||
|
assertFalse( repos.isEmpty() );
|
||||||
|
log.info( "repos {}", repos );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,13 @@
|
||||||
<logger name="org.codehaus.redback.rest.services" >
|
<logger name="org.codehaus.redback.rest.services" >
|
||||||
<level value="debug"/>
|
<level value="debug"/>
|
||||||
</logger>
|
</logger>
|
||||||
|
<logger name="JPOX">
|
||||||
|
<level value="ERROR"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
<logger name="org.springframework">
|
||||||
|
<level value="ERROR"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
<root>
|
<root>
|
||||||
<priority value ="info" />
|
<priority value ="info" />
|
||||||
|
|
|
@ -43,7 +43,7 @@ import javax.inject.Named;
|
||||||
*
|
*
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractManagedRepositoriesAction
|
public abstract class AbstractManagedReposigettoriesAction
|
||||||
extends AbstractRepositoriesAdminAction
|
extends AbstractRepositoriesAdminAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue