aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2021-12-24 11:13:43 +0100
committerMartin Stockhammer <martin_s@apache.org>2021-12-24 11:13:43 +0100
commit78413e37c4ea50778a5448f5e50071e1039457c4 (patch)
tree244b3f90abfa3345e0135ef2db325b912145571a /archiva-modules
parentc818808b7c995d3ad7fe8f0a9ea372aea96835cf (diff)
downloadarchiva-78413e37c4ea50778a5448f5e50071e1039457c4.tar.gz
archiva-78413e37c4ea50778a5448f5e50071e1039457c4.zip
code cleanup
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/v2/svc/maven/DefaultMavenManagedRepositoryService.java37
1 files changed, 18 insertions, 19 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/v2/svc/maven/DefaultMavenManagedRepositoryService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/v2/svc/maven/DefaultMavenManagedRepositoryService.java
index 5e3c11ab4..498000f61 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/v2/svc/maven/DefaultMavenManagedRepositoryService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/v2/svc/maven/DefaultMavenManagedRepositoryService.java
@@ -92,9 +92,9 @@ public class DefaultMavenManagedRepositoryService implements MavenManagedReposit
QUERY_HELPER.addNullsafeFieldComparator( "name", ManagedRepository::getName );
}
- private ManagedRepositoryAdmin managedRepositoryAdmin;
- private RepositoryRegistry repositoryRegistry;
- private SecuritySystem securitySystem;
+ private final ManagedRepositoryAdmin managedRepositoryAdmin;
+ private final RepositoryRegistry repositoryRegistry;
+ private final SecuritySystem securitySystem;
public DefaultMavenManagedRepositoryService( SecuritySystem securitySystem,
RepositoryRegistry repositoryRegistry,
@@ -133,7 +133,7 @@ public class DefaultMavenManagedRepositoryService implements MavenManagedReposit
final Comparator<ManagedRepository> comparator = QUERY_HELPER.getComparator( orderBy, order );
int totalCount = Math.toIntExact( repos.stream( ).filter( queryFilter ).count( ) );
return PagedResult.of( totalCount, offset, limit, repos.stream( ).filter( queryFilter ).sorted( comparator )
- .map(mr -> MavenManagedRepository.of(mr)).skip( offset ).limit( limit ).collect( Collectors.toList( ) ) );
+ .map( MavenManagedRepository::of ).skip( offset ).limit( limit ).collect( Collectors.toList( ) ) );
}
catch (ArithmeticException e) {
log.error( "Invalid number of repositories detected." );
@@ -157,21 +157,20 @@ public class DefaultMavenManagedRepositoryService implements MavenManagedReposit
@Override
public Response deleteManagedRepository( String repositoryId, Boolean deleteContent ) throws ArchivaRestServiceException
{
- ManagedRepository repo = repositoryRegistry.getManagedRepository( repositoryId );
- if (repo==null) {
- throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.REPOSITORY_NOT_FOUND, repositoryId ), 404 );
- }
- if (repo.getType()!=RepositoryType.MAVEN) {
- throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.REPOSITORY_WRONG_TYPE, repositoryId, repo.getType().name() ), 404 );
- }
- try
+ MavenManagedRepository repo = getManagedRepository( repositoryId );
+ if (repo != null)
{
- managedRepositoryAdmin.deleteManagedRepository( repositoryId, getAuditInformation( ), deleteContent );
- return Response.ok( ).build( );
- }
- catch ( RepositoryAdminException e )
- {
- throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.REPOSITORY_DELETE_FAILED, e.getMessage( ) ) );
+ try
+ {
+ managedRepositoryAdmin.deleteManagedRepository( repositoryId, getAuditInformation( ), deleteContent );
+ return Response.ok( ).build( );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.REPOSITORY_DELETE_FAILED, e.getMessage( ) ) );
+ }
+ } else {
+ throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.REPOSITORY_NOT_FOUND, repositoryId ), 404 );
}
}
@@ -306,7 +305,7 @@ public class DefaultMavenManagedRepositoryService implements MavenManagedReposit
}
private void checkAuthority(final String userName, final String srcRepositoryId, final String dstRepositoryId ) throws ArchivaRestServiceException {
- User user = null;
+ User user;
try
{
user = securitySystem.getUserManager().findUser( userName );