mirror of https://github.com/apache/archiva.git
start working on browsing only one repository to avoid merging incomplete metadata
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1301522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fffe588b9
commit
6c2bf258aa
|
@ -165,20 +165,17 @@
|
|||
<groupId>org.codehaus.redback</groupId>
|
||||
<artifactId>redback-users-memory</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>${redback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.redback</groupId>
|
||||
<artifactId>redback-keys-memory</artifactId>
|
||||
<scope>test</scope>
|
||||
<version>${redback.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.codehaus.redback</groupId>
|
||||
<artifactId>redback-rbac-cached</artifactId>
|
||||
<version>${redback.version}</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
|
|
|
@ -28,6 +28,7 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
|
@ -64,4 +65,11 @@ public interface BrowseService
|
|||
ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId,
|
||||
@PathParam( "a" ) String artifactId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
@Path( "userRepositories" )
|
||||
@GET
|
||||
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
|
||||
@RedbackAuthorization( noPermission = true, noRestriction = true )
|
||||
List<String> getUserRepositories()
|
||||
throws ArchivaRestServiceException;
|
||||
}
|
||||
|
|
|
@ -350,6 +350,12 @@ public class DefaultBrowseService
|
|||
}
|
||||
}
|
||||
|
||||
public List<String> getUserRepositories()
|
||||
throws ArchivaRestServiceException
|
||||
{
|
||||
return getObservableRepos();
|
||||
}
|
||||
|
||||
//---------------------------
|
||||
// internals
|
||||
//---------------------------
|
||||
|
|
|
@ -33,10 +33,18 @@
|
|||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-admin-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-security-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.inject</groupId>
|
||||
<artifactId>javax.inject</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
|
@ -153,6 +161,31 @@
|
|||
<artifactId>redback-common-test-resources</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-repository-admin-default</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-http-lightweight</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>metadata-repository-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>metadata-store-file</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
@ -190,6 +223,9 @@
|
|||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<basedir>${basedir}</basedir>
|
||||
<appserver.base>${project.build.directory}/appserver-base</appserver.base>
|
||||
<plexus.home>${project.build.directory}/appserver-base</plexus.home>
|
||||
<derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
|
||||
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
|
||||
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
|
||||
|
|
|
@ -20,8 +20,9 @@ package org.apache.archiva.security;
|
|||
*/
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
|
||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||
import org.codehaus.plexus.redback.authentication.AuthenticationResult;
|
||||
import org.codehaus.plexus.redback.authorization.AuthorizationException;
|
||||
|
@ -57,9 +58,9 @@ public class DefaultUserRepositories
|
|||
private RoleManager roleManager;
|
||||
|
||||
@Inject
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
private ManagedRepositoryAdmin managedRepositoryAdmin;
|
||||
|
||||
private Logger log = LoggerFactory.getLogger( DefaultUserRepositories.class );
|
||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
public List<String> getObservableRepositoryIds( String principal )
|
||||
throws PrincipalNotFoundException, AccessDeniedException, ArchivaSecurityException
|
||||
|
@ -80,36 +81,57 @@ public class DefaultUserRepositories
|
|||
private List<String> getAccessibleRepositoryIds( String principal, String operation )
|
||||
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException
|
||||
{
|
||||
SecuritySession securitySession = createSession( principal );
|
||||
|
||||
List<String> repoIds = new ArrayList<String>();
|
||||
|
||||
List<ManagedRepositoryConfiguration> repos = archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||
|
||||
for ( ManagedRepositoryConfiguration repo : repos )
|
||||
List<ManagedRepository> managedRepositories = getAccessibleRepositories( principal, operation );
|
||||
List<String> repoIds = new ArrayList<String>( managedRepositories.size() );
|
||||
for ( ManagedRepository managedRepository : managedRepositories )
|
||||
{
|
||||
try
|
||||
{
|
||||
String repoId = repo.getId();
|
||||
if ( securitySystem.isAuthorized( securitySession, operation, repoId ) )
|
||||
{
|
||||
repoIds.add( repoId );
|
||||
}
|
||||
}
|
||||
catch ( AuthorizationException e )
|
||||
{
|
||||
// swallow.
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( "Not authorizing '{}' for repository '{}': {}",
|
||||
Lists.<Object>newArrayList( principal, repo.getId(), e.getMessage() ) );
|
||||
}
|
||||
}
|
||||
repoIds.add( managedRepository.getId() );
|
||||
}
|
||||
|
||||
return repoIds;
|
||||
}
|
||||
|
||||
public List<ManagedRepository> getAccessibleRepositories( String principal, String operation )
|
||||
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException
|
||||
{
|
||||
SecuritySession securitySession = createSession( principal );
|
||||
|
||||
List<ManagedRepository> managedRepositories = new ArrayList<ManagedRepository>();
|
||||
|
||||
try
|
||||
{
|
||||
List<ManagedRepository> repos = managedRepositoryAdmin.getManagedRepositories();
|
||||
|
||||
for ( ManagedRepository repo : repos )
|
||||
{
|
||||
try
|
||||
{
|
||||
String repoId = repo.getId();
|
||||
if ( securitySystem.isAuthorized( securitySession, operation, repoId ) )
|
||||
{
|
||||
managedRepositories.add( repo );
|
||||
}
|
||||
}
|
||||
catch ( AuthorizationException e )
|
||||
{
|
||||
// swallow.
|
||||
if ( log.isDebugEnabled() )
|
||||
{
|
||||
log.debug( "Not authorizing '{}' for repository '{}': {}",
|
||||
Lists.<Object>newArrayList( principal, repo.getId(), e.getMessage() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return managedRepositories;
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
throw new ArchivaSecurityException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private SecuritySession createSession( String principal )
|
||||
throws ArchivaSecurityException, AccessDeniedException
|
||||
{
|
||||
|
@ -212,14 +234,4 @@ public class DefaultUserRepositories
|
|||
{
|
||||
this.roleManager = roleManager;
|
||||
}
|
||||
|
||||
public ArchivaConfiguration getArchivaConfiguration()
|
||||
{
|
||||
return archivaConfiguration;
|
||||
}
|
||||
|
||||
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
|
||||
{
|
||||
this.archivaConfiguration = archivaConfiguration;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ package org.apache.archiva.security;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.admin.model.beans.ManagedRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -84,5 +86,18 @@ public interface UserRepositories
|
|||
*/
|
||||
boolean isAuthorizedToDeleteArtifacts( String principal, String repoId )
|
||||
throws AccessDeniedException, ArchivaSecurityException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param principal
|
||||
* @param operation
|
||||
* @since 1.4-M3
|
||||
* @return
|
||||
* @throws ArchivaSecurityException
|
||||
* @throws AccessDeniedException
|
||||
* @throws PrincipalNotFoundException
|
||||
*/
|
||||
List<ManagedRepository> getAccessibleRepositories( String principal, String operation )
|
||||
throws ArchivaSecurityException, AccessDeniedException, PrincipalNotFoundException;
|
||||
|
||||
}
|
||||
|
|
|
@ -37,9 +37,10 @@
|
|||
<bean name="userRepositories" class="org.apache.archiva.security.DefaultUserRepositories">
|
||||
<property name="securitySystem" ref="securitySystem#testable"/>
|
||||
<property name="roleManager" ref="roleManager"/>
|
||||
<property name="archivaConfiguration" ref="archivaConfiguration"/>
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean name="authorizer#rbac" class="org.codehaus.plexus.redback.authorization.rbac.RbacAuthorizer">
|
||||
<property name="manager" ref="rBACManager#memory"/>
|
||||
<property name="userManager" ref="userManager#memory"/>
|
||||
|
@ -83,7 +84,9 @@
|
|||
</bean>
|
||||
<alias name="archivaConfiguration#default" alias="archivaConfiguration"/>
|
||||
|
||||
<bean name="registry#test" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
|
||||
<alias name="commons-configuration" alias="registry#test"/>
|
||||
|
||||
<bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
|
||||
<property name="properties">
|
||||
<value>
|
||||
<![CDATA[
|
||||
|
@ -98,38 +101,16 @@
|
|||
</property>
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
partially configured
|
||||
<bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler">
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="org.quartz.scheduler.instanceName">scheduler1</prop>
|
||||
<prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop>
|
||||
<prop key="org.quartz.threadPool.threadCount">2</prop>
|
||||
<prop key="org.quartz.threadPool.threadPriority">4</prop>
|
||||
<prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.redback.role.RoleManager</role>
|
||||
<role-hint>default</role-hint>
|
||||
<implementation>org.codehaus.plexus.redback.role.DefaultRoleManager</implementation>
|
||||
<description>RoleProfileManager:</description>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.redback.role.validator.RoleModelValidator</role>
|
||||
<role-hint>default</role-hint>
|
||||
<field-name>modelValidator</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.redback.role.processor.RoleModelProcessor</role>
|
||||
<role-hint>default</role-hint>
|
||||
<field-name>modelProcessor</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.redback.role.template.RoleTemplateProcessor</role>
|
||||
<role-hint>default</role-hint>
|
||||
<field-name>templateProcessor</field-name>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.redback.rbac.RBACManager</role>
|
||||
<role-hint>memory</role-hint>
|
||||
<field-name>rbacManager</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
|
||||
-->
|
||||
</beans>
|
|
@ -170,19 +170,29 @@ $(function() {
|
|||
var mainContent = $("#main-content");
|
||||
mainContent.html($("#browse-tmpl" ).tmpl());
|
||||
mainContent.find("#browse_result").html(mediumSpinnerImg());
|
||||
$.ajax("restServices/archivaServices/browseService/rootGroups", {
|
||||
|
||||
$.ajax("restServices/archivaServices/browseService/userRepositories", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var browseResultEntries = mapbrowseResultEntries(data);
|
||||
$.log("size:"+browseResultEntries.length);
|
||||
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
|
||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
|
||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
|
||||
enableAutocompleBrowse();
|
||||
mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data}));// selected_repository_tmpl
|
||||
$.ajax("restServices/archivaServices/browseService/rootGroups", {
|
||||
type: "GET",
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
var browseResultEntries = mapbrowseResultEntries(data);
|
||||
$.log("size:"+browseResultEntries.length);
|
||||
var browseViewModel = new BrowseViewModel(browseResultEntries,null,null);
|
||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_breadcrumb").get(0));
|
||||
ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0));
|
||||
enableAutocompleBrowse();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
enableAutocompleBrowse=function(groupId){
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
</div>
|
||||
<div id="main_browse_result">
|
||||
<div id="main_browse_result_content" class="well">
|
||||
<div id="selected_repository"></div>
|
||||
<div id="browse_breadcrumb" data-bind='template:{name:"browse-breadcrumb-tmpl"}'></div>
|
||||
<div id="browse_result" class="well" data-bind='template:{name:"browse-groups-tmpl"}'></div>
|
||||
<div id="browse_artifact" class="well" data-bind='template:{name:"browse-artifact-tmpl"}'></div>
|
||||
|
@ -377,3 +378,12 @@
|
|||
{{/each}}
|
||||
</tbody>
|
||||
</script>
|
||||
|
||||
|
||||
<script id="selected_repository_tmpl" type="text/html">
|
||||
<select id="repository">
|
||||
{{each(i,repository) repositories}}
|
||||
<option value="${repository}">${repository}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
</script>
|
Loading…
Reference in New Issue