From b9316745df508c88c3c691bb4a509265a523dfde Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Tue, 30 Jun 2020 08:05:07 +0200 Subject: [PATCH] Adapting to new cxf version. Using result objects instead of simple types in REST services. --- .../archiva/rest/api/model/ActionStatus.java | 55 ++++++++++++++++ .../rest/api/model/AvailabilityStatus.java | 51 +++++++++++++++ .../archiva/rest/api/model/FileStatus.java | 50 +++++++++++++++ .../rest/api/model/PermissionStatus.java | 51 +++++++++++++++ .../archiva/rest/api/model/ScanStatus.java | 52 +++++++++++++++ .../rest/api/model/ValidationStatus.java | 51 +++++++++++++++ .../ArchivaAdministrationService.java | 26 +++----- .../ArchivaRuntimeConfigurationService.java | 3 +- .../rest/api/services/BrowseService.java | 26 ++++---- .../rest/api/services/CommonServices.java | 4 +- .../services/ManagedRepositoriesService.java | 12 ++-- .../api/services/NetworkProxyService.java | 3 +- .../services/ProxyConnectorRuleService.java | 7 ++- .../api/services/ProxyConnectorService.java | 9 +-- .../RedbackRuntimeConfigurationService.java | 7 ++- .../services/RemoteRepositoriesService.java | 9 +-- .../api/services/RepositoriesService.java | 41 ++++++++---- .../api/services/RepositoryGroupService.java | 11 ++-- .../api/services/SystemStatusService.java | 5 +- .../archiva-rest-services/pom.xml | 13 +++- .../DefaultArchivaAdministrationService.java | 39 +++++------- ...ultArchivaRuntimeConfigurationService.java | 5 +- .../rest/services/DefaultBrowseService.java | 36 +++++------ .../rest/services/DefaultCommonServices.java | 7 ++- .../DefaultManagedRepositoriesService.java | 20 +++--- .../services/DefaultNetworkProxyService.java | 5 +- .../DefaultProxyConnectorRuleService.java | 13 ++-- .../DefaultProxyConnectorService.java | 21 ++++--- ...ultRedbackRuntimeConfigurationService.java | 15 +++-- .../DefaultRemoteRepositoriesService.java | 25 ++++---- .../services/DefaultRepositoriesService.java | 63 ++++++++++--------- .../DefaultRepositoryGroupService.java | 39 ++++++------ .../services/DefaultSystemStatusService.java | 9 +-- .../META-INF/cxf/org.apache.cxf.Logger | 1 + .../resources/META-INF/spring-context.xml | 13 ++++ .../services/AbstractArchivaRestTest.java | 25 ++++---- .../ArchivaAdministrationServiceTest.java | 1 - .../rest/services/CommonServicesTest.java | 4 +- .../rest/services/CopyArtifactTest.java | 2 +- .../ManagedRepositoriesServiceTest.java | 13 ++-- .../RemoteRepositoriesServiceTest.java | 6 +- .../services/RepositoriesServiceTest.java | 10 ++- .../src/test/resources/log4j2-test.xml | 3 +- .../DownloadArtifactFromQueryTest.java | 3 +- ...DownloadMergedIndexNonDefaultPathTest.java | 6 +- .../DownloadMergedIndexTest.java | 3 +- ...RemoteRepositoryConnectivityCheckTest.java | 7 +-- pom.xml | 8 ++- 48 files changed, 625 insertions(+), 263 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ActionStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AvailabilityStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/FileStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PermissionStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ScanStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ValidationStatus.java create mode 100644 archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ActionStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ActionStatus.java new file mode 100644 index 000000000..5620f4f35 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ActionStatus.java @@ -0,0 +1,55 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.swing.*; +import javax.xml.bind.annotation.XmlRootElement; + +/** + * Simple result for actions that are triggered by the web service. + * @author Martin Stockhammer + */ +@XmlRootElement(name = "actionStatus") +public class ActionStatus +{ + private boolean success = false; + + public static final ActionStatus SUCCESS = new ActionStatus( true ); + public static final ActionStatus FAIL = new ActionStatus( false ); + + public ActionStatus() { + + } + + public ActionStatus( boolean success) { + this.success = success; + } + + public boolean isSuccess( ) + { + return success; + } + + public void setSuccess( boolean success ) + { + this.success = success; + } + + +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AvailabilityStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AvailabilityStatus.java new file mode 100644 index 000000000..001c69fdd --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AvailabilityStatus.java @@ -0,0 +1,51 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.xml.bind.annotation.XmlRootElement; + +/** + * The availability status of some service. + * + * @author Martin Stockhammer + */ +@XmlRootElement(name = "availabilityStatus") +public class AvailabilityStatus +{ + + boolean available = false; + + public AvailabilityStatus() { + + } + + public AvailabilityStatus( boolean available) { + this.available = available; + } + + public boolean isAvailable( ) + { + return available; + } + + public void setAvailable( boolean available ) + { + this.available = available; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/FileStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/FileStatus.java new file mode 100644 index 000000000..e53a96f4e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/FileStatus.java @@ -0,0 +1,50 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.xml.bind.annotation.XmlRootElement; + +/** + * Status result of a given file + * + * @author Martin Stockhammer + */ +@XmlRootElement(name = "fileStatus") +public class FileStatus +{ + boolean exists = false; + + public FileStatus() { + + } + + public FileStatus(boolean exists) { + this.exists = exists; + } + + public boolean isExists( ) + { + return exists; + } + + public void setExists( boolean exists ) + { + this.exists = exists; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PermissionStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PermissionStatus.java new file mode 100644 index 000000000..78412dece --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/PermissionStatus.java @@ -0,0 +1,51 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.xml.bind.annotation.XmlRootElement; + +/** + * Current permission status for some object + * + * @author Martin Stockhammer + */ +@XmlRootElement(name = "permissionStatus") +public class PermissionStatus +{ + boolean authorizedToDeleteArtifacts = false; + + PermissionStatus() { + + } + + public PermissionStatus( boolean authorizedToDeleteArtifacts ) + { + this.authorizedToDeleteArtifacts = authorizedToDeleteArtifacts; + } + + public boolean isAuthorizedToDeleteArtifacts( ) + { + return authorizedToDeleteArtifacts; + } + + public void setAuthorizedToDeleteArtifacts( boolean authorizedToDeleteArtifacts ) + { + this.authorizedToDeleteArtifacts = authorizedToDeleteArtifacts; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ScanStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ScanStatus.java new file mode 100644 index 000000000..e7c09c808 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ScanStatus.java @@ -0,0 +1,52 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.xml.bind.annotation.XmlRootElement; + +/** + * The current status of repository scanning + * + * @author Martin Stockhammer + */ +@XmlRootElement(name = "scanStatus") +public class ScanStatus +{ + boolean isAlreadyScanning = false; + + + public ScanStatus() { + + } + + public ScanStatus( boolean isAlreadyScanning ) + { + this.isAlreadyScanning = isAlreadyScanning; + } + + public boolean isAlreadyScanning( ) + { + return isAlreadyScanning; + } + + public void setAlreadyScanning( boolean alreadyScanning ) + { + isAlreadyScanning = alreadyScanning; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ValidationStatus.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ValidationStatus.java new file mode 100644 index 000000000..197d3f5ac --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ValidationStatus.java @@ -0,0 +1,51 @@ +package org.apache.archiva.rest.api.model; + +/* + * 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 javax.xml.bind.annotation.XmlRootElement; + +/** + * Returns true, if a test is valid. + * + * @author Martin Stockhammer + */ +@XmlRootElement(name="validationStatus") +public class ValidationStatus +{ + boolean valid; + + public ValidationStatus() { + + } + + public ValidationStatus( boolean valid ) + { + this.valid = valid; + } + + public boolean isValid( ) + { + return valid; + } + + public void setValid( boolean valid ) + { + this.valid = valid; + } +} diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java index 77544cc8e..60d40087e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaAdministrationService.java @@ -27,6 +27,7 @@ import org.apache.archiva.admin.model.beans.NetworkConfiguration; import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.AdminRepositoryConsumer; import org.apache.archiva.security.common.ArchivaRoleConstants; @@ -59,22 +60,22 @@ public interface ArchivaAdministrationService @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteLegacyArtifactPath( @QueryParam( "path" ) String path ) + ActionStatus deleteLegacyArtifactPath( @QueryParam( "path" ) String path ) throws ArchivaRestServiceException; @Path( "addFileTypePattern" ) @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean addFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, @QueryParam( "pattern" ) String pattern ) + ActionStatus addFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, @QueryParam( "pattern" ) String pattern ) throws ArchivaRestServiceException; @Path( "removeFileTypePattern" ) @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean removeFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, - @QueryParam( "pattern" ) String pattern ) + ActionStatus removeFileTypePattern( @QueryParam( "fileTypeId" ) String fileTypeId, + @QueryParam( "pattern" ) String pattern ) throws ArchivaRestServiceException; @Path( "getFileType" ) @@ -103,14 +104,14 @@ public interface ArchivaAdministrationService @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean removeFileType( @QueryParam( "fileTypeId" ) String fileTypeId ) + ActionStatus removeFileType( @QueryParam( "fileTypeId" ) String fileTypeId ) throws ArchivaRestServiceException; @Path( "enabledKnownContentConsumer/{knownContentConsumer}" ) @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean enabledKnownContentConsumer( @PathParam( "knownContentConsumer" ) String knownContentConsumer ) + ActionStatus enabledKnownContentConsumer( @PathParam( "knownContentConsumer" ) String knownContentConsumer ) throws ArchivaRestServiceException; @Path( "enabledKnownContentConsumers" ) @@ -125,14 +126,14 @@ public interface ArchivaAdministrationService @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean disabledKnownContentConsumer( @PathParam( "knownContentConsumer" ) String knownContentConsumer ) + ActionStatus disabledKnownContentConsumer( @PathParam( "knownContentConsumer" ) String knownContentConsumer ) throws ArchivaRestServiceException; @Path( "enabledInvalidContentConsumer/{invalidContentConsumer}" ) @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean enabledInvalidContentConsumer( @PathParam( "invalidContentConsumer" ) String invalidContentConsumer ) + ActionStatus enabledInvalidContentConsumer( @PathParam( "invalidContentConsumer" ) String invalidContentConsumer ) throws ArchivaRestServiceException; @Path( "enabledInvalidContentConsumers" ) @@ -146,7 +147,7 @@ public interface ArchivaAdministrationService @GET @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN} ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean disabledInvalidContentConsumer( @PathParam( "invalidContentConsumer" ) String invalidContentConsumer ) + ActionStatus disabledInvalidContentConsumer( @PathParam( "invalidContentConsumer" ) String invalidContentConsumer ) throws ArchivaRestServiceException; @Path( "getFileTypes" ) @@ -211,13 +212,6 @@ public interface ArchivaAdministrationService UiConfiguration getUiConfiguration( ) throws ArchivaRestServiceException; - @Path( "registrationDisabled" ) - @GET - @Produces( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML} ) - @RedbackAuthorization( noRestriction = true, noPermission = true ) - Boolean registrationDisabled( ) - throws ArchivaRestServiceException; - @Path( "setUiConfiguration" ) @POST @Consumes( {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML} ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java index ba1f9466b..a53c06d99 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -50,6 +51,6 @@ public interface ArchivaRuntimeConfigurationService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) + ActionStatus updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java index 43d2d52de..c957c14fc 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java @@ -24,8 +24,10 @@ import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.maven2.model.TreeEntry; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.ArtifactContent; import org.apache.archiva.rest.api.model.ArtifactContentEntry; +import org.apache.archiva.rest.api.model.AvailabilityStatus; import org.apache.archiva.rest.api.model.BrowseResult; import org.apache.archiva.rest.api.model.Entry; import org.apache.archiva.rest.api.model.MetadataAddRequest; @@ -148,24 +150,24 @@ public interface BrowseService @PUT @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") - Boolean addMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, - @PathParam("v") String version, @PathParam("key") String key, @PathParam("value") String value, - @QueryParam("repositoryId") String repositoryId ) + ActionStatus addMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, + @PathParam("v") String version, @PathParam("key") String key, @PathParam("value") String value, + @QueryParam("repositoryId") String repositoryId ) throws ArchivaRestServiceException; @Path("metadata/{g}/{a}/{v}/{key}") @DELETE @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") - Boolean deleteMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, - @PathParam("v") String version, @PathParam("key") String key, - @QueryParam("repositoryId") String repositoryId ) + ActionStatus deleteMetadata( @PathParam("g") String groupId, @PathParam("a") String artifactId, + @PathParam("v") String version, @PathParam("key") String key, + @QueryParam("repositoryId") String repositoryId ) throws ArchivaRestServiceException; @Path("importMetadata") @POST @RedbackAuthorization(noPermission = false, noRestriction = false, permissions = "archiva-add-metadata") - Boolean importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam("repository") String repository ) + ActionStatus importMetadata( MetadataAddRequest metadataAddRequest, @QueryParam("repository") String repository ) throws ArchivaRestServiceException; @Path("artifactContentEntries/{g}/{a}/{v}") @@ -211,8 +213,8 @@ public interface BrowseService @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(noPermission = true, noRestriction = true) - Boolean artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId, - @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) + AvailabilityStatus artifactAvailable( @PathParam("g") String groupId, @PathParam("a") String artifactId, + @PathParam("v") String version, @QueryParam("repositoryId") String repositoryId ) throws ArchivaRestServiceException; /** @@ -224,9 +226,9 @@ public interface BrowseService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noPermission = true, noRestriction = true ) - Boolean artifactAvailable( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, - @PathParam( "v" ) String version, @PathParam( "c" ) String classifier, - @QueryParam( "repositoryId" ) String repositoryId ) + AvailabilityStatus artifactAvailable( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId, + @PathParam( "v" ) String version, @PathParam( "c" ) String classifier, + @QueryParam( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; /** diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java index 9589a103b..68d827fa1 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/CommonServices.java @@ -20,6 +20,8 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; +import org.apache.archiva.rest.api.model.ValidationStatus; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -68,7 +70,7 @@ public interface CommonServices @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noRestriction = true ) - Boolean validateCronExpression( @QueryParam( "cronExpression" ) String cronExpression ) + ValidationStatus validateCronExpression( @QueryParam( "cronExpression" ) String cronExpression ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java index c2df28337..208f24f09 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java @@ -23,7 +23,9 @@ import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.ArchivaRepositoryStatistics; +import org.apache.archiva.rest.api.model.FileStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -65,8 +67,8 @@ public interface ManagedRepositoriesService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteManagedRepository( @QueryParam( "repositoryId" ) String repositoryId, - @QueryParam( "deleteContent" ) boolean deleteContent ) + ActionStatus deleteManagedRepository( @QueryParam( "repositoryId" ) String repositoryId, + @QueryParam( "deleteContent" ) boolean deleteContent ) throws ArchivaRestServiceException; @@ -84,17 +86,17 @@ public interface ManagedRepositoriesService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean updateManagedRepository( ManagedRepository managedRepository ) + ActionStatus updateManagedRepository( ManagedRepository managedRepository ) throws ArchivaRestServiceException; /** - * @since 1.4-M3 + * @since 3.0 */ @Path( "fileLocationExists" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean fileLocationExists( @QueryParam( "fileLocation" ) String fileLocation ) + FileStatus getFileStatus( @QueryParam( "fileLocation" ) String fileLocation ) throws ArchivaRestServiceException; /** diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java index be5489e1d..24ef02d8d 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/NetworkProxyService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -74,6 +75,6 @@ public interface NetworkProxyService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteNetworkProxy( @PathParam( "networkProxyId" ) String networkProxyId ) + ActionStatus deleteNetworkProxy( @PathParam( "networkProxyId" ) String networkProxyId ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorRuleService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorRuleService.java index 1399effd9..da7c66268 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorRuleService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorRuleService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.ProxyConnectorRule; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -53,7 +54,7 @@ public interface ProxyConnectorRuleService @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + ActionStatus addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException; @Path ( "deleteProxyConnectorRule" ) @@ -61,7 +62,7 @@ public interface ProxyConnectorRuleService @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + ActionStatus deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException; /** @@ -72,6 +73,6 @@ public interface ProxyConnectorRuleService @Consumes ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + ActionStatus updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java index b370d237e..2dd6b2db5 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ProxyConnectorService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.PolicyInformation; import org.apache.archiva.security.common.ArchivaRoleConstants; @@ -63,7 +64,7 @@ public interface ProxyConnectorService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean addProxyConnector( ProxyConnector proxyConnector ) + ActionStatus addProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException; @Path( "deleteProxyConnector" ) @@ -71,7 +72,7 @@ public interface ProxyConnectorService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteProxyConnector( ProxyConnector proxyConnector ) + ActionStatus deleteProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException; /** @@ -81,7 +82,7 @@ public interface ProxyConnectorService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean removeProxyConnector( @QueryParam( "sourceRepoId" ) String sourceRepoId, + ActionStatus removeProxyConnector( @QueryParam( "sourceRepoId" ) String sourceRepoId, @QueryParam( "targetRepoId" ) String targetRepoId ) throws ArchivaRestServiceException; @@ -96,7 +97,7 @@ public interface ProxyConnectorService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean updateProxyConnector( ProxyConnector proxyConnector ) + ActionStatus updateProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException; @Path( "allPolicies" ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java index 67f44ee09..bbd656a93 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RedbackRuntimeConfigurationService.java @@ -22,6 +22,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.LdapConfiguration; import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation; import org.apache.archiva.rest.api.model.RedbackImplementationsInformations; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; @@ -56,7 +57,7 @@ public interface RedbackRuntimeConfigurationService @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) + ActionStatus updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) throws ArchivaRestServiceException; @Path("userManagerImplementationInformations") @@ -85,7 +86,7 @@ public interface RedbackRuntimeConfigurationService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean checkLdapConnection() + ActionStatus checkLdapConnection() throws ArchivaRestServiceException; @Path("checkLdapConnection") @@ -93,6 +94,6 @@ public interface RedbackRuntimeConfigurationService @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean checkLdapConnection( LdapConfiguration ldapConfiguration ) + ActionStatus checkLdapConnection( LdapConfiguration ldapConfiguration ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java index 632c8ff51..69e5f85ad 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RemoteRepositoriesService.java @@ -23,6 +23,7 @@ import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tags; import org.apache.archiva.admin.model.beans.RemoteRepository; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -63,7 +64,7 @@ public interface RemoteRepositoriesService @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean deleteRemoteRepository( @PathParam("repositoryId") String repositoryId ) + ActionStatus deleteRemoteRepository( @PathParam("repositoryId") String repositoryId ) throws ArchivaRestServiceException; @@ -72,7 +73,7 @@ public interface RemoteRepositoriesService @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean addRemoteRepository( RemoteRepository remoteRepository ) + ActionStatus addRemoteRepository( RemoteRepository remoteRepository ) throws ArchivaRestServiceException; @@ -81,13 +82,13 @@ public interface RemoteRepositoriesService @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean updateRemoteRepository( RemoteRepository remoteRepository ) + ActionStatus updateRemoteRepository( RemoteRepository remoteRepository ) throws ArchivaRestServiceException; @Path("checkRemoteConnectivity/{repositoryId}") @GET @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization(permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION) - Boolean checkRemoteConnectivity( @PathParam( "repositoryId" ) String repositoryId ) + ActionStatus checkRemoteConnectivity( @PathParam( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java index 75e467010..156827547 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoriesService.java @@ -23,7 +23,10 @@ import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.maven2.model.Artifact; import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.repository.scanner.RepositoryScanStatistics; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.ArtifactTransferRequest; +import org.apache.archiva.rest.api.model.PermissionStatus; +import org.apache.archiva.rest.api.model.ScanStatus; import org.apache.archiva.rest.api.model.StringList; import org.apache.archiva.security.common.ArchivaRoleConstants; @@ -53,8 +56,8 @@ public interface RepositoriesService @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER) - Boolean scanRepository( @QueryParam ("repositoryId") String repositoryId, - @QueryParam ("fullScan") boolean fullScan ) + ActionStatus scanRepository( @QueryParam ("repositoryId") String repositoryId, + @QueryParam ("fullScan") boolean fullScan ) throws ArchivaRestServiceException; @@ -70,25 +73,32 @@ public interface RepositoriesService throws ArchivaRestServiceException; + /** + * Returns the scan status of the given repository + * @param repositoryId the repository identifier + * @return the status + * @throws ArchivaRestServiceException + * @since 3.0 + */ @Path ("alreadyScanning/{repositoryId}") @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER) - Boolean alreadyScanning( @PathParam ("repositoryId") String repositoryId ) + ScanStatus getScanStatus( @PathParam ("repositoryId") String repositoryId ) throws ArchivaRestServiceException; @Path ("removeScanningTaskFromQueue/{repositoryId}") @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER) - Boolean removeScanningTaskFromQueue( @PathParam ("repositoryId") String repositoryId ) + ActionStatus removeScanningTaskFromQueue( @PathParam ("repositoryId") String repositoryId ) throws ArchivaRestServiceException; @Path ("scanRepositoryNow") @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER) - Boolean scanRepositoryNow( @QueryParam ("repositoryId") String repositoryId, + ActionStatus scanRepositoryNow( @QueryParam ("repositoryId") String repositoryId, @QueryParam ("fullScan") boolean fullScan ) throws ArchivaRestServiceException; @@ -101,14 +111,14 @@ public interface RepositoriesService @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true) - Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest ) + ActionStatus copyArtifact( ArtifactTransferRequest artifactTransferRequest ) throws ArchivaRestServiceException; @Path ("scheduleDownloadRemoteIndex") @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (permissions = ArchivaRoleConstants.OPERATION_RUN_INDEXER) - Boolean scheduleDownloadRemoteIndex( @QueryParam ("repositoryId") String repositoryId, + ActionStatus scheduleDownloadRemoteIndex( @QueryParam ("repositoryId") String repositoryId, @QueryParam ("now") boolean now, @QueryParam ("fullDownload") boolean fullDownload ) throws ArchivaRestServiceException; @@ -123,7 +133,7 @@ public interface RepositoriesService @Consumes ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true) - Boolean deleteArtifact( Artifact artifact ) + ActionStatus deleteArtifact( Artifact artifact ) throws ArchivaRestServiceException; /** @@ -134,16 +144,23 @@ public interface RepositoriesService @DELETE @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true) - Boolean removeProjectVersion( @PathParam ( "repositoryId" ) String repositoryId, + ActionStatus removeProjectVersion( @PathParam ( "repositoryId" ) String repositoryId, @PathParam ( "namespace" ) String namespace, @PathParam ( "projectId" ) String projectId, @PathParam ( "version" ) String version ) throws ArchivaRestServiceException; + /** + * Returns the permission status for the current user and the given repository. + * @param repoId the repository identifier + * @return the status + * @throws ArchivaRestServiceException + * @since 3.0 + */ @Path ("isAuthorizedToDeleteArtifacts/{repositoryId}") @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true, noRestriction = true) - Boolean isAuthorizedToDeleteArtifacts( @PathParam ("repositoryId") String repoId ) + PermissionStatus getPermissionStatus( @PathParam ("repositoryId") String repoId ) throws ArchivaRestServiceException; /** @@ -154,7 +171,7 @@ public interface RepositoriesService @GET @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true) - Boolean deleteGroupId( @QueryParam ("groupId") String groupId, @QueryParam ("repositoryId") String repositoryId ) + ActionStatus deleteGroupId( @QueryParam ("groupId") String groupId, @QueryParam ("repositoryId") String repositoryId ) throws ArchivaRestServiceException; /** @@ -165,7 +182,7 @@ public interface RepositoriesService @DELETE @Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN }) @RedbackAuthorization (noPermission = true) - Boolean deleteProject( @PathParam ("groupId") String groupId, @PathParam ("projectId") String projectId, + ActionStatus deleteProject( @PathParam ("groupId") String groupId, @PathParam ("projectId") String projectId, @PathParam ("repositoryId") String repositoryId ) throws ArchivaRestServiceException; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java index 2daedc195..0208f8eb1 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/RepositoryGroupService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.security.common.ArchivaRoleConstants; import javax.ws.rs.Consumes; @@ -60,7 +61,7 @@ public interface RepositoryGroupService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean addRepositoryGroup( RepositoryGroup repositoryGroup ) + ActionStatus addRepositoryGroup( RepositoryGroup repositoryGroup ) throws ArchivaRestServiceException; @Path( "updateRepositoryGroup" ) @@ -68,21 +69,21 @@ public interface RepositoryGroupService @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean updateRepositoryGroup( RepositoryGroup repositoryGroup ) + ActionStatus updateRepositoryGroup( RepositoryGroup repositoryGroup ) throws ArchivaRestServiceException; @Path( "deleteRepositoryGroup/{repositoryGroupId}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteRepositoryGroup( @PathParam( "repositoryGroupId" ) String repositoryGroupId ) + ActionStatus deleteRepositoryGroup( @PathParam( "repositoryGroupId" ) String repositoryGroupId ) throws ArchivaRestServiceException; @Path( "addRepositoryToGroup" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean addRepositoryToGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, + ActionStatus addRepositoryToGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, @QueryParam( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; @@ -90,7 +91,7 @@ public interface RepositoryGroupService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean deleteRepositoryFromGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, + ActionStatus deleteRepositoryFromGroup( @QueryParam( "repositoryGroupId" ) String repositoryGroupId, @QueryParam( "repositoryId" ) String repositoryId ) throws ArchivaRestServiceException; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java index 96fe1d866..c6b43328c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SystemStatusService.java @@ -20,6 +20,7 @@ package org.apache.archiva.rest.api.services; import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.CacheEntry; import org.apache.archiva.rest.api.model.QueueEntry; import org.apache.archiva.rest.api.model.RepositoryScannerStatistics; @@ -72,14 +73,14 @@ public interface SystemStatusService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean clearCache( @PathParam( "key" ) String cacheKey ) + ActionStatus clearCache( @PathParam( "key" ) String cacheKey ) throws ArchivaRestServiceException; @Path( "clearAllCaches" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION ) - Boolean clearAllCaches() + ActionStatus clearAllCaches() throws ArchivaRestServiceException; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml index a5c914b83..d8fed9482 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml @@ -312,11 +312,12 @@ com.fasterxml.jackson.jaxrs jackson-jaxrs-json-provider + 2.10.4 com.fasterxml.jackson.jaxrs jackson-jaxrs-xml-provider - runtime + 2.10.4 org.apache.cxf @@ -326,11 +327,20 @@ org.apache.cxf cxf-rt-transports-http + + org.apache.cxf + cxf-rt-frontend-jaxrs + test + org.apache.cxf cxf-rt-rs-client test + + org.apache.cxf + cxf-rt-features-logging + @@ -456,6 +466,7 @@ src/test/repo-with-osgi-stage/** src/test/repo-with-classifier-only/** src/test/repo-with-snapshots/** + src/main/resources/META-INF/cxf/org.apache.cxf.Logger diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java index 18d14807f..dabab53ea 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java @@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.*; import org.apache.archiva.repository.scanner.RepositoryContentConsumers; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.AdminRepositoryConsumer; import org.apache.archiva.rest.api.services.ArchivaAdministrationService; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; @@ -68,13 +69,13 @@ public class DefaultArchivaAdministrationService @Override - public Boolean deleteLegacyArtifactPath( String path ) + public ActionStatus deleteLegacyArtifactPath( String path ) throws ArchivaRestServiceException { try { archivaAdministration.deleteLegacyArtifactPath( path, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus( true ); } catch ( RepositoryAdminException e ) { @@ -84,13 +85,13 @@ public class DefaultArchivaAdministrationService @Override - public Boolean addFileTypePattern( String fileTypeId, String pattern ) + public ActionStatus addFileTypePattern( String fileTypeId, String pattern ) throws ArchivaRestServiceException { try { archivaAdministration.addFileTypePattern( fileTypeId, pattern, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -99,13 +100,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean removeFileTypePattern( String fileTypeId, String pattern ) + public ActionStatus removeFileTypePattern( String fileTypeId, String pattern ) throws ArchivaRestServiceException { try { archivaAdministration.removeFileTypePattern( fileTypeId, pattern, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -142,13 +143,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean removeFileType( String fileTypeId ) + public ActionStatus removeFileType( String fileTypeId ) throws ArchivaRestServiceException { try { archivaAdministration.removeFileType( fileTypeId, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -157,13 +158,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean enabledKnownContentConsumer( String knownContentConsumer ) + public ActionStatus enabledKnownContentConsumer( String knownContentConsumer ) throws ArchivaRestServiceException { try { archivaAdministration.addKnownContentConsumer( knownContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -186,13 +187,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean disabledKnownContentConsumer( String knownContentConsumer ) + public ActionStatus disabledKnownContentConsumer( String knownContentConsumer ) throws ArchivaRestServiceException { try { archivaAdministration.removeKnownContentConsumer( knownContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -201,13 +202,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean enabledInvalidContentConsumer( String invalidContentConsumer ) + public ActionStatus enabledInvalidContentConsumer( String invalidContentConsumer ) throws ArchivaRestServiceException { try { archivaAdministration.addInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -230,13 +231,13 @@ public class DefaultArchivaAdministrationService } @Override - public Boolean disabledInvalidContentConsumer( String invalidContentConsumer ) + public ActionStatus disabledInvalidContentConsumer( String invalidContentConsumer ) throws ArchivaRestServiceException { try { archivaAdministration.removeInvalidContentConsumer( invalidContentConsumer, getAuditInformation() ); - return Boolean.TRUE; + return new ActionStatus(true); } catch ( RepositoryAdminException e ) { @@ -319,12 +320,6 @@ public class DefaultArchivaAdministrationService } } - @Override - public Boolean registrationDisabled() - throws ArchivaRestServiceException - { - return getUiConfiguration().isDisableRegistration(); - } @Override public UiConfiguration getUiConfiguration() diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java index a799462ed..6d012ad72 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java @@ -25,6 +25,7 @@ import org.apache.archiva.admin.model.beans.FileLockConfiguration; import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.components.cache.Cache; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService; import org.springframework.stereotype.Service; @@ -67,7 +68,7 @@ public class DefaultArchivaRuntimeConfigurationService } @Override - public Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) + public ActionStatus updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration ) throws ArchivaRestServiceException { try @@ -95,6 +96,6 @@ public class DefaultArchivaRuntimeConfigurationService { throw new ArchivaRestServiceException( e.getMessage(), e ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java index 76fd075c0..912b24ba4 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java @@ -613,8 +613,8 @@ public class DefaultBrowseService } @Override - public Boolean addMetadata( String groupId, String artifactId, String version, String key, String value, - String repositoryId ) + public ActionStatus addMetadata( String groupId, String artifactId, String version, String key, String value, + String repositoryId ) throws ArchivaRestServiceException { ProjectVersionMetadata projectVersionMetadata = @@ -622,7 +622,7 @@ public class DefaultBrowseService if ( projectVersionMetadata == null ) { - return Boolean.FALSE; + return new ActionStatus( false ); } Map properties = new HashMap<>(); @@ -672,11 +672,11 @@ public class DefaultBrowseService { repositorySession.close(); } - return Boolean.TRUE; + return new ActionStatus( true ); } @Override - public Boolean deleteMetadata( String groupId, String artifactId, String version, String key, String repositoryId ) + public ActionStatus deleteMetadata( String groupId, String artifactId, String version, String key, String repositoryId ) throws ArchivaRestServiceException { ProjectVersionMetadata projectVersionMetadata = @@ -684,7 +684,7 @@ public class DefaultBrowseService if ( projectVersionMetadata == null ) { - return Boolean.FALSE; + return new ActionStatus( false ); } GenericMetadataFacet metadataFacet = @@ -698,7 +698,7 @@ public class DefaultBrowseService } else { - return Boolean.TRUE; + return new ActionStatus( true ); } RepositorySession repositorySession = null; @@ -729,7 +729,7 @@ public class DefaultBrowseService { repositorySession.close(); } - return Boolean.TRUE; + return new ActionStatus( true ); } @Override @@ -883,8 +883,8 @@ public class DefaultBrowseService } @Override - public Boolean artifactAvailable( String groupId, String artifactId, String version, String classifier, - String repositoryId ) + public AvailabilityStatus artifactAvailable( String groupId, String artifactId, String version, String classifier, + String repositoryId ) throws ArchivaRestServiceException { List selectedRepos = getSelectedRepos( repositoryId ); @@ -920,7 +920,7 @@ public class DefaultBrowseService if ( file != null && file.exists() ) { - return true; + return new AvailabilityStatus( true ); } // in case of SNAPSHOT we can have timestamped version locally ! @@ -946,7 +946,7 @@ public class DefaultBrowseService log.debug( "try to find timestamped snapshot version file: {}", timeStampFile.getPath() ); if ( timeStampFile.exists() ) { - return true; + return new AvailabilityStatus( true ); } } } @@ -960,7 +960,7 @@ public class DefaultBrowseService // download pom now String pomPath = StringUtils.substringBeforeLast( path, ".jar" ) + ".pom"; proxyHandler.fetchFromProxies( managedRepositoryContent.getRepository(), pomPath ); - return true; + return new AvailabilityStatus( true ); } } } catch ( RepositoryException e ) @@ -970,11 +970,11 @@ public class DefaultBrowseService Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e ); } - return false; + return new AvailabilityStatus( false ); } @Override - public Boolean artifactAvailable( String groupId, String artifactId, String version, String repositoryId ) + public AvailabilityStatus artifactAvailable( String groupId, String artifactId, String version, String repositoryId ) throws ArchivaRestServiceException { return artifactAvailable( groupId, artifactId, version, null, repositoryId ); @@ -1093,16 +1093,16 @@ public class DefaultBrowseService } @Override - public Boolean importMetadata( MetadataAddRequest metadataAddRequest, String repositoryId ) + public ActionStatus importMetadata( MetadataAddRequest metadataAddRequest, String repositoryId ) throws ArchivaRestServiceException { - boolean result = true; + ActionStatus result = new ActionStatus( true ); for ( Map.Entry metadata : metadataAddRequest.getMetadatas().entrySet() ) { result = addMetadata( metadataAddRequest.getGroupId(), metadataAddRequest.getArtifactId(), metadataAddRequest.getVersion(), metadata.getKey(), metadata.getValue(), repositoryId ); - if ( !result ) + if ( !result.isSuccess() ) { break; } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java index 2005a4450..25ee182f7 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultCommonServices.java @@ -21,6 +21,8 @@ package org.apache.archiva.rest.services; import org.apache.archiva.components.scheduler.CronExpressionValidator; import org.apache.archiva.redback.rest.api.services.RedbackServiceException; import org.apache.archiva.redback.rest.api.services.UtilServices; +import org.apache.archiva.rest.api.model.ActionStatus; +import org.apache.archiva.rest.api.model.ValidationStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.CommonServices; import org.apache.commons.lang3.StringUtils; @@ -30,6 +32,7 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import javax.inject.Inject; +import javax.validation.Valid; import javax.ws.rs.core.Response; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -187,9 +190,9 @@ public class DefaultCommonServices @Override - public Boolean validateCronExpression( String cronExpression ) + public ValidationStatus validateCronExpression( String cronExpression ) throws ArchivaRestServiceException { - return cronExpressionValidator.validate( cronExpression ); + return new ValidationStatus(cronExpressionValidator.validate( cronExpression )); } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java index ca5513545..6aec318da 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java @@ -27,7 +27,9 @@ import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.stats.model.RepositoryStatistics; import org.apache.archiva.metadata.repository.stats.model.RepositoryStatisticsManager; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.ArchivaRepositoryStatistics; +import org.apache.archiva.rest.api.model.FileStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ManagedRepositoriesService; import org.apache.commons.lang3.StringEscapeUtils; @@ -95,13 +97,13 @@ public class DefaultManagedRepositoriesService @Override - public Boolean deleteManagedRepository( String repoId, boolean deleteContent ) + public ActionStatus deleteManagedRepository( String repoId, boolean deleteContent ) throws ArchivaRestServiceException { try { - return managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation(), deleteContent ); + return new ActionStatus( managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation( ), deleteContent ) ); } catch ( RepositoryAdminException e ) { @@ -134,16 +136,16 @@ public class DefaultManagedRepositoriesService @Override - public Boolean updateManagedRepository( ManagedRepository managedRepository ) + public ActionStatus updateManagedRepository( ManagedRepository managedRepository ) throws ArchivaRestServiceException { try { - return managedRepositoryAdmin.updateManagedRepository( managedRepository, - managedRepository.isStageRepoNeeded(), - getAuditInformation(), - managedRepository.isResetStats() ); + return new ActionStatus( managedRepositoryAdmin.updateManagedRepository( managedRepository, + managedRepository.isStageRepoNeeded( ), + getAuditInformation( ), + managedRepository.isResetStats( ) ) ); } catch ( RepositoryAdminException e ) { @@ -152,11 +154,11 @@ public class DefaultManagedRepositoriesService } @Override - public Boolean fileLocationExists( String fileLocation ) + public FileStatus getFileStatus( String fileLocation ) throws ArchivaRestServiceException { String location = repositoryCommonValidator.removeExpressions( fileLocation ); - return Files.exists( Paths.get( location )); + return new FileStatus( Files.exists( Paths.get( location ) ) ); } @Override diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java index 6e3c0fec8..4d06e39bd 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultNetworkProxyService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.NetworkProxy; import org.apache.archiva.admin.model.networkproxy.NetworkProxyAdmin; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.NetworkProxyService; import org.springframework.stereotype.Service; @@ -106,13 +107,13 @@ public class DefaultNetworkProxyService } @Override - public Boolean deleteNetworkProxy( String networkProxyId ) + public ActionStatus deleteNetworkProxy( String networkProxyId ) throws ArchivaRestServiceException { try { getNetworkProxyAdmin().deleteNetworkProxy( networkProxyId, getAuditInformation() ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( RepositoryAdminException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorRuleService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorRuleService.java index b21b8235f..1972a2009 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorRuleService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorRuleService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ProxyConnectorRule; import org.apache.archiva.admin.model.proxyconnectorrule.ProxyConnectorRuleAdmin; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ProxyConnectorRuleService; import org.apache.commons.lang3.StringUtils; @@ -87,7 +88,7 @@ public class DefaultProxyConnectorRuleService } @Override - public Boolean addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + public ActionStatus addProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException { @@ -96,7 +97,7 @@ public class DefaultProxyConnectorRuleService try { proxyConnectorRuleAdmin.addProxyConnectorRule( proxyConnectorRule, getAuditInformation() ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( RepositoryAdminException e ) { @@ -105,13 +106,13 @@ public class DefaultProxyConnectorRuleService } @Override - public Boolean deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + public ActionStatus deleteProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException { try { proxyConnectorRuleAdmin.deleteProxyConnectorRule( proxyConnectorRule, getAuditInformation() ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( RepositoryAdminException e ) { @@ -120,13 +121,13 @@ public class DefaultProxyConnectorRuleService } @Override - public Boolean updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) + public ActionStatus updateProxyConnectorRule( ProxyConnectorRule proxyConnectorRule ) throws ArchivaRestServiceException { try { proxyConnectorRuleAdmin.updateProxyConnectorRule( proxyConnectorRule, getAuditInformation() ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( RepositoryAdminException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java index 88ebe9616..e8bc8e9d8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultProxyConnectorService.java @@ -22,6 +22,7 @@ import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.ProxyConnector; import org.apache.archiva.admin.model.proxyconnector.ProxyConnectorAdmin; import org.apache.archiva.policies.Policy; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.PolicyInformation; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.ProxyConnectorService; @@ -80,16 +81,16 @@ public class DefaultProxyConnectorService } @Override - public Boolean addProxyConnector( ProxyConnector proxyConnector ) + public ActionStatus addProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException { if ( proxyConnector == null ) { - return Boolean.FALSE; + return ActionStatus.FAIL; } try { - return proxyConnectorAdmin.addProxyConnector( proxyConnector, getAuditInformation() ); + return new ActionStatus( proxyConnectorAdmin.addProxyConnector( proxyConnector, getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -98,16 +99,16 @@ public class DefaultProxyConnectorService } @Override - public Boolean deleteProxyConnector( ProxyConnector proxyConnector ) + public ActionStatus deleteProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException { if ( proxyConnector == null ) { - return Boolean.FALSE; + return ActionStatus.FAIL; } try { - return proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation() ); + return new ActionStatus( proxyConnectorAdmin.deleteProxyConnector( proxyConnector, getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -116,7 +117,7 @@ public class DefaultProxyConnectorService } @Override - public Boolean removeProxyConnector( String sourceRepoId, String targetRepoId ) + public ActionStatus removeProxyConnector( String sourceRepoId, String targetRepoId ) throws ArchivaRestServiceException { ProxyConnector proxyConnector = getProxyConnector( sourceRepoId, targetRepoId ); @@ -130,16 +131,16 @@ public class DefaultProxyConnectorService } @Override - public Boolean updateProxyConnector( ProxyConnector proxyConnector ) + public ActionStatus updateProxyConnector( ProxyConnector proxyConnector ) throws ArchivaRestServiceException { if ( proxyConnector == null ) { - return Boolean.FALSE; + return ActionStatus.FAIL; } try { - return proxyConnectorAdmin.updateProxyConnector( proxyConnector, getAuditInformation() ); + return new ActionStatus( proxyConnectorAdmin.updateProxyConnector( proxyConnector, getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index 96b544f8e..c45b1da2f 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -34,6 +34,7 @@ import org.apache.archiva.redback.policy.PasswordRule; import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.role.RoleManager; import org.apache.archiva.redback.users.UserManager; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.RBACManagerImplementationInformation; import org.apache.archiva.rest.api.model.RedbackImplementationsInformations; import org.apache.archiva.rest.api.model.UserManagerImplementationInformation; @@ -112,7 +113,7 @@ public class DefaultRedbackRuntimeConfigurationService } @Override - public Boolean updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) + public ActionStatus updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) throws ArchivaRestServiceException { try @@ -221,9 +222,7 @@ public class DefaultRedbackRuntimeConfigurationService } - - - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch (ArchivaRestServiceException e) { log.error(e.getMessage(), e); @@ -303,7 +302,7 @@ public class DefaultRedbackRuntimeConfigurationService } @Override - public Boolean checkLdapConnection() + public ActionStatus checkLdapConnection() throws ArchivaRestServiceException { LdapConnection ldapConnection = null; @@ -325,11 +324,11 @@ public class DefaultRedbackRuntimeConfigurationService } } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override - public Boolean checkLdapConnection( LdapConfiguration ldapConfiguration ) + public ActionStatus checkLdapConnection( LdapConfiguration ldapConfiguration ) throws ArchivaRestServiceException { LdapConnection ldapConnection = null; @@ -380,7 +379,7 @@ public class DefaultRedbackRuntimeConfigurationService } } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } private Properties toProperties( Map map ) diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java index f32ddde32..1e9a39c27 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRemoteRepositoriesService.java @@ -26,6 +26,7 @@ import org.apache.archiva.proxy.ProxyRegistry; import org.apache.archiva.proxy.maven.WagonFactory; import org.apache.archiva.proxy.maven.WagonFactoryRequest; import org.apache.archiva.proxy.model.NetworkProxy; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RemoteRepositoriesService; import org.apache.commons.lang3.StringUtils; @@ -91,10 +92,10 @@ public class DefaultRemoteRepositoriesService } @Override - public Boolean deleteRemoteRepository(String repositoryId) + public ActionStatus deleteRemoteRepository( String repositoryId) throws ArchivaRestServiceException { try { - return remoteRepositoryAdmin.deleteRemoteRepository(repositoryId, getAuditInformation()); + return new ActionStatus( remoteRepositoryAdmin.deleteRemoteRepository( repositoryId, getAuditInformation( ) ) ); } catch (RepositoryAdminException e) { log.error(e.getMessage(), e); throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); @@ -102,10 +103,10 @@ public class DefaultRemoteRepositoriesService } @Override - public Boolean addRemoteRepository(RemoteRepository remoteRepository) + public ActionStatus addRemoteRepository(RemoteRepository remoteRepository) throws ArchivaRestServiceException { try { - return remoteRepositoryAdmin.addRemoteRepository(remoteRepository, getAuditInformation()); + return new ActionStatus( remoteRepositoryAdmin.addRemoteRepository( remoteRepository, getAuditInformation( ) ) ); } catch (RepositoryAdminException e) { log.error(e.getMessage(), e); throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); @@ -113,10 +114,10 @@ public class DefaultRemoteRepositoriesService } @Override - public Boolean updateRemoteRepository(RemoteRepository remoteRepository) + public ActionStatus updateRemoteRepository(RemoteRepository remoteRepository) throws ArchivaRestServiceException { try { - return remoteRepositoryAdmin.updateRemoteRepository(remoteRepository, getAuditInformation()); + return new ActionStatus( remoteRepositoryAdmin.updateRemoteRepository( remoteRepository, getAuditInformation( ) ) ); } catch (RepositoryAdminException e) { log.error(e.getMessage(), e); throw new ArchivaRestServiceException(e.getMessage(), e.getFieldName(), e); @@ -124,13 +125,13 @@ public class DefaultRemoteRepositoriesService } @Override - public Boolean checkRemoteConnectivity(String repositoryId) + public ActionStatus checkRemoteConnectivity( String repositoryId) throws ArchivaRestServiceException { try { RemoteRepository remoteRepository = remoteRepositoryAdmin.getRemoteRepository(repositoryId); if (remoteRepository == null) { log.warn("Remote repository {} does not exist. Connectivity check returns false.", repositoryId); - return Boolean.FALSE; + return ActionStatus.FAIL; } NetworkProxy networkProxy = null; if (StringUtils.isNotBlank(remoteRepository.getRemoteDownloadNetworkProxyId())) { @@ -175,22 +176,22 @@ public class DefaultRemoteRepositoriesService // MRM-1933, there are certain servers that do not allow browsing if (!(StringUtils.isEmpty(remoteRepository.getCheckPath()) || "/".equals(remoteRepository.getCheckPath()))) { - return wagon.resourceExists(remoteRepository.getCheckPath()); + return new ActionStatus( wagon.resourceExists( remoteRepository.getCheckPath( ) ) ); } else { // we only check connectivity as remote repo can be empty // MRM-1909: Wagon implementation appends a slash already wagon.getFileList(""); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch (TransferFailedException e) { log.info("TransferFailedException :{}", e.getMessage()); - return Boolean.FALSE; + return ActionStatus.FAIL; } catch (Exception e) { // This service returns either true or false, Exception cannot be handled by the clients log.debug("Exception occured on connectivity test.", e); log.info("Connection exception: {}", e.getMessage()); - return Boolean.FALSE; + return ActionStatus.FAIL; } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java index 3967d12df..f99b06db7 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java @@ -71,7 +71,10 @@ import org.apache.archiva.repository.scanner.RepositoryScannerInstance; import org.apache.archiva.repository.storage.RepositoryStorage; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.archiva.repository.storage.fs.FsStorageUtil; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.ArtifactTransferRequest; +import org.apache.archiva.rest.api.model.PermissionStatus; +import org.apache.archiva.rest.api.model.ScanStatus; import org.apache.archiva.rest.api.model.StringList; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RepositoriesService; @@ -156,42 +159,42 @@ public class DefaultRepositoriesService private List algorithms = Arrays.asList(ChecksumAlgorithm.SHA256, ChecksumAlgorithm.SHA1, ChecksumAlgorithm.MD5 ); @Override - public Boolean scanRepository( String repositoryId, boolean fullScan ) + public ActionStatus scanRepository( String repositoryId, boolean fullScan ) { - return doScanRepository( repositoryId, fullScan ); + return new ActionStatus( doScanRepository( repositoryId, fullScan ) ); } @Override - public Boolean alreadyScanning( String repositoryId ) + public ScanStatus getScanStatus( String repositoryId ) { // check queue first to make sure it doesn't get dequeued between calls if ( repositoryTaskScheduler.isProcessingRepositoryTask( repositoryId ) ) { - return true; + return new ScanStatus( true ); } for ( RepositoryScannerInstance scan : repoScanner.getInProgressScans() ) { if ( scan.getRepository().getId().equals( repositoryId ) ) { - return true; + return new ScanStatus( true ); } } - return false; + return new ScanStatus( false ); } @Override - public Boolean removeScanningTaskFromQueue( String repositoryId ) + public ActionStatus removeScanningTaskFromQueue( String repositoryId ) { RepositoryTask task = new RepositoryTask(); task.setRepositoryId( repositoryId ); try { - return repositoryTaskScheduler.unQueueTask( task ); + return new ActionStatus( repositoryTaskScheduler.unQueueTask( task ) ); } catch ( TaskQueueException e ) { log.error( "failed to unschedule scanning of repo with id {}", repositoryId, e ); - return false; + return ActionStatus.FAIL; } } @@ -205,7 +208,7 @@ public class DefaultRepositoriesService } @Override - public Boolean scanRepositoryNow( String repositoryId, boolean fullScan ) + public ActionStatus scanRepositoryNow( String repositoryId, boolean fullScan ) throws ArchivaRestServiceException { @@ -225,7 +228,7 @@ public class DefaultRepositoriesService scheduler.queueTask( new RepositoryTask( repositoryId, fullScan ) ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( Exception e ) { @@ -235,7 +238,7 @@ public class DefaultRepositoriesService } @Override - public Boolean scheduleDownloadRemoteIndex( String repositoryId, boolean now, boolean fullDownload ) + public ActionStatus scheduleDownloadRemoteIndex( String repositoryId, boolean now, boolean fullDownload ) throws ArchivaRestServiceException { try @@ -247,11 +250,11 @@ public class DefaultRepositoriesService log.error( e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), e ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override - public Boolean copyArtifact( ArtifactTransferRequest artifactTransferRequest ) + public ActionStatus copyArtifact( ArtifactTransferRequest artifactTransferRequest ) throws ArchivaRestServiceException { // check parameters @@ -487,7 +490,7 @@ public class DefaultRepositoriesService log.error( "IOException: {}", e.getMessage(), e ); throw new ArchivaRestServiceException( e.getMessage(), e ); } - return true; + return ActionStatus.SUCCESS; } private void queueRepositoryTask( String repositoryId, StorageAsset localFile ) @@ -616,7 +619,7 @@ public class DefaultRepositoriesService } @Override - public Boolean removeProjectVersion( String repositoryId, String namespace, String projectId, String version ) + public ActionStatus removeProjectVersion( String repositoryId, String namespace, String projectId, String version ) throws ArchivaRestServiceException { // if not a generic we can use the standard way to delete artifact @@ -633,7 +636,7 @@ public class DefaultRepositoriesService throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null ); } - if ( !isAuthorizedToDeleteArtifacts( repositoryId ) ) + if ( !getPermissionStatus( repositoryId ).isAuthorizedToDeleteArtifacts() ) { throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null ); } @@ -707,11 +710,11 @@ public class DefaultRepositoriesService } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override - public Boolean deleteArtifact( Artifact artifact ) + public ActionStatus deleteArtifact( Artifact artifact ) throws ArchivaRestServiceException { @@ -727,7 +730,7 @@ public class DefaultRepositoriesService throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null ); } - if ( !isAuthorizedToDeleteArtifacts( repositoryId ) ) + if ( !getPermissionStatus( repositoryId ).isAuthorizedToDeleteArtifacts() ) { throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null ); } @@ -825,7 +828,7 @@ public class DefaultRepositoriesService //throw new ContentNotFoundException( // artifact.getNamespace() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion() ); log.warn( "targetPath {} not found skip file deletion", targetPath ); - return false; + return ActionStatus.FAIL; } // TODO: this should be in the storage mechanism so that it is all tied together @@ -981,11 +984,11 @@ public class DefaultRepositoriesService repositorySession.close(); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override - public Boolean deleteGroupId( String groupId, String repositoryId ) + public ActionStatus deleteGroupId( String groupId, String repositoryId ) throws ArchivaRestServiceException { if ( StringUtils.isEmpty( repositoryId ) ) @@ -993,7 +996,7 @@ public class DefaultRepositoriesService throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null ); } - if ( !isAuthorizedToDeleteArtifacts( repositoryId ) ) + if ( !getPermissionStatus( repositoryId ).isAuthorizedToDeleteArtifacts() ) { throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null ); } @@ -1051,11 +1054,11 @@ public class DefaultRepositoriesService repositorySession.close(); } - return true; + return ActionStatus.SUCCESS; } @Override - public Boolean deleteProject( String groupId, String projectId, String repositoryId ) + public ActionStatus deleteProject( String groupId, String projectId, String repositoryId ) throws ArchivaRestServiceException { if ( StringUtils.isEmpty( repositoryId ) ) @@ -1063,7 +1066,7 @@ public class DefaultRepositoriesService throw new ArchivaRestServiceException( "repositoryId cannot be null", 400, null ); } - if ( !isAuthorizedToDeleteArtifacts( repositoryId ) ) + if ( !getPermissionStatus( repositoryId ).isAuthorizedToDeleteArtifacts() ) { throw new ArchivaRestServiceException( "not authorized to delete artifacts", 403, null ); } @@ -1131,12 +1134,12 @@ public class DefaultRepositoriesService repositorySession.close(); } - return true; + return ActionStatus.SUCCESS; } @Override - public Boolean isAuthorizedToDeleteArtifacts( String repoId ) + public PermissionStatus getPermissionStatus( String repoId ) throws ArchivaRestServiceException { String userName = @@ -1144,7 +1147,7 @@ public class DefaultRepositoriesService try { - return userRepositories.isAuthorizedToDeleteArtifacts( userName, repoId ); + return new PermissionStatus( userRepositories.isAuthorizedToDeleteArtifacts( userName, repoId ) ); } catch ( ArchivaSecurityException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java index 1f33314b1..9053f00e5 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoryGroupService.java @@ -21,6 +21,7 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.model.RepositoryAdminException; import org.apache.archiva.admin.model.beans.RepositoryGroup; import org.apache.archiva.admin.model.group.RepositoryGroupAdmin; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.archiva.rest.api.services.RepositoryGroupService; import org.apache.commons.lang3.StringUtils; @@ -79,16 +80,16 @@ public class DefaultRepositoryGroupService } @Override - public Boolean addRepositoryGroup( RepositoryGroup repoGroup ) + public ActionStatus addRepositoryGroup( RepositoryGroup repoGroup ) throws ArchivaRestServiceException { try { - return repositoryGroupAdmin.addRepositoryGroup( - new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<>( - repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl( - repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ), - getAuditInformation() ); + return new ActionStatus( repositoryGroupAdmin.addRepositoryGroup( + new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId( ), new ArrayList<>( + repoGroup.getRepositories( ) ) ).mergedIndexPath( repoGroup.getMergedIndexPath( ) ).mergedIndexTtl( + repoGroup.getMergedIndexTtl( ) ).cronExpression( repoGroup.getCronExpression( ) ), + getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -97,16 +98,16 @@ public class DefaultRepositoryGroupService } @Override - public Boolean updateRepositoryGroup( RepositoryGroup repoGroup ) + public ActionStatus updateRepositoryGroup( RepositoryGroup repoGroup ) throws ArchivaRestServiceException { try { - return repositoryGroupAdmin.updateRepositoryGroup( - new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId(), new ArrayList<>( - repoGroup.getRepositories() ) ).mergedIndexPath( repoGroup.getMergedIndexPath() ).mergedIndexTtl( - repoGroup.getMergedIndexTtl() ).cronExpression( repoGroup.getCronExpression() ), - getAuditInformation() ); + return new ActionStatus( repositoryGroupAdmin.updateRepositoryGroup( + new org.apache.archiva.admin.model.beans.RepositoryGroup( repoGroup.getId( ), new ArrayList<>( + repoGroup.getRepositories( ) ) ).mergedIndexPath( repoGroup.getMergedIndexPath( ) ).mergedIndexTtl( + repoGroup.getMergedIndexTtl( ) ).cronExpression( repoGroup.getCronExpression( ) ), + getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -115,12 +116,12 @@ public class DefaultRepositoryGroupService } @Override - public Boolean deleteRepositoryGroup( String repositoryGroupId ) + public ActionStatus deleteRepositoryGroup( String repositoryGroupId ) throws ArchivaRestServiceException { try { - return repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation() ); + return new ActionStatus( repositoryGroupAdmin.deleteRepositoryGroup( repositoryGroupId, getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -129,12 +130,12 @@ public class DefaultRepositoryGroupService } @Override - public Boolean addRepositoryToGroup( String repositoryGroupId, String repositoryId ) + public ActionStatus addRepositoryToGroup( String repositoryGroupId, String repositoryId ) throws ArchivaRestServiceException { try { - return repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation() ); + return new ActionStatus( repositoryGroupAdmin.addRepositoryToGroup( repositoryGroupId, repositoryId, getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { @@ -143,13 +144,13 @@ public class DefaultRepositoryGroupService } @Override - public Boolean deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId ) + public ActionStatus deleteRepositoryFromGroup( String repositoryGroupId, String repositoryId ) throws ArchivaRestServiceException { try { - return repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, - getAuditInformation() ); + return new ActionStatus( repositoryGroupAdmin.deleteRepositoryFromGroup( repositoryGroupId, repositoryId, + getAuditInformation( ) ) ); } catch ( RepositoryAdminException e ) { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java index e62cdc99e..775664662 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSystemStatusService.java @@ -26,6 +26,7 @@ import org.apache.archiva.components.taskqueue.TaskQueue; import org.apache.archiva.components.taskqueue.TaskQueueException; import org.apache.archiva.repository.scanner.RepositoryScanner; import org.apache.archiva.repository.scanner.RepositoryScannerInstance; +import org.apache.archiva.rest.api.model.ActionStatus; import org.apache.archiva.rest.api.model.CacheEntry; import org.apache.archiva.rest.api.model.ConsumerScanningStatistics; import org.apache.archiva.rest.api.model.QueueEntry; @@ -165,7 +166,7 @@ public class DefaultSystemStatusService } @Override - public Boolean clearCache( String cacheKey ) + public ActionStatus clearCache( String cacheKey ) throws ArchivaRestServiceException { Cache cache = caches.get( cacheKey ); @@ -176,18 +177,18 @@ public class DefaultSystemStatusService } cache.clear(); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override - public Boolean clearAllCaches() + public ActionStatus clearAllCaches() throws ArchivaRestServiceException { for ( Cache cache : caches.values() ) { cache.clear(); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } @Override diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger new file mode 100644 index 000000000..27dd788b3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger @@ -0,0 +1 @@ +org.apache.cxf.common.logging.Slf4jLogger \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml index 3373b12dc..ede2fe6c0 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml @@ -40,10 +40,16 @@ base-package="org.apache.archiva.rest.services,org.apache.archiva.redback.rest.services"/> + + + + + + @@ -72,6 +78,13 @@ + + + + + + + T getService( Class clazz, String authzHeader ) { T service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", clazz, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); if ( authzHeader != null ) { @@ -296,7 +295,7 @@ public abstract class AbstractArchivaRestTest { return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", RepositoryGroupService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); } protected ProxyConnectorService getProxyConnectorService() @@ -304,7 +303,7 @@ public abstract class AbstractArchivaRestTest ProxyConnectorService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", ProxyConnectorService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); WebClient.client(service).header("Referer","http://localhost:"+getServerPort()); @@ -319,7 +318,7 @@ public abstract class AbstractArchivaRestTest NetworkProxyService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", NetworkProxyService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); WebClient.client( service ).header( "Authorization", authorizationHeader ); WebClient.client(service).header("Referer","http://localhost:"+getServerPort()); @@ -334,7 +333,7 @@ public abstract class AbstractArchivaRestTest ArchivaAdministrationService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", ArchivaAdministrationService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -351,7 +350,7 @@ public abstract class AbstractArchivaRestTest RedbackRuntimeConfigurationService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", RedbackRuntimeConfigurationService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE ); WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE ); @@ -368,7 +367,7 @@ public abstract class AbstractArchivaRestTest BrowseService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", BrowseService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); // to add authentification if ( authzHeader != null ) { @@ -399,7 +398,7 @@ public abstract class AbstractArchivaRestTest SearchService service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", SearchService.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); // to add authentification if ( authzHeader != null ) { @@ -422,7 +421,7 @@ public abstract class AbstractArchivaRestTest CommonServices service = JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/", CommonServices.class, - Collections.singletonList( new JacksonJaxbJsonProvider() ) ); + Arrays.asList( new JacksonJaxbJsonProvider( ), new JacksonJaxbXMLProvider( ) ) ); if ( authzHeader != null ) { @@ -664,7 +663,7 @@ public abstract class AbstractArchivaRestTest protected void waitForScanToComplete( String repoId ) throws ArchivaRestServiceException, InterruptedException { - while ( getRepositoriesService( authorizationHeader ).alreadyScanning( repoId ) ) { + while ( getRepositoriesService( authorizationHeader ).getScanStatus( repoId ).isAlreadyScanning() ) { // Would be better to cancel, if we had that capacity Thread.sleep( 100 ); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java index 77eb008f8..0c34b1d2c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaAdministrationServiceTest.java @@ -22,7 +22,6 @@ import org.apache.archiva.admin.model.beans.FileType; import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.rest.api.model.AdminRepositoryConsumer; -import org.apache.archiva.rest.api.services.ArchivaRestServiceException; import org.apache.commons.lang3.StringUtils; import org.junit.Test; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CommonServicesTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CommonServicesTest.java index eac5aa983..ff5e86350 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CommonServicesTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CommonServicesTest.java @@ -32,7 +32,7 @@ public class CommonServicesTest throws Exception { CommonServices commonServices = getCommonServices( null ); - assertTrue( commonServices.validateCronExpression( "0 0,30 * * * ?" ) ); + assertTrue( commonServices.validateCronExpression( "0 0,30 * * * ?" ).isValid() ); } @Test @@ -40,6 +40,6 @@ public class CommonServicesTest throws Exception { CommonServices commonServices = getCommonServices( null ); - assertFalse( commonServices.validateCronExpression( "0,30 * * * ?" ) ); + assertFalse( commonServices.validateCronExpression( "0,30 * * * ?" ).isValid() ); } } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java index 51ee1cd86..62fc7c044 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/CopyArtifactTest.java @@ -56,7 +56,7 @@ public class CopyArtifactTest // retrieve the service RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); // copy the artifact - Boolean res = repositoriesService.copyArtifact( artifactTransferRequest ); + Boolean res = repositoriesService.copyArtifact( artifactTransferRequest ).isSuccess(); // END SNIPPET: copy-artifact assertTrue( res ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java index 41296cb2b..8838c461c 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ManagedRepositoriesServiceTest.java @@ -26,7 +26,6 @@ import org.apache.archiva.rest.api.services.RepositoriesService; import org.junit.Test; import java.nio.file.Path; -import java.nio.file.Paths; /** @@ -58,7 +57,7 @@ public class ManagedRepositoriesServiceTest RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( repo.getId() ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; @@ -85,7 +84,7 @@ public class ManagedRepositoriesServiceTest RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( repo.getId() ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; @@ -104,7 +103,7 @@ public class ManagedRepositoriesServiceTest assertEquals( "toto", repo.getName() ); timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( repo.getId() ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( repo.getId() ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; @@ -122,10 +121,10 @@ public class ManagedRepositoriesServiceTest ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader ); Path target = getProjectDirectory().resolve( "target" ); - assertTrue( service.fileLocationExists( target.toAbsolutePath().toString() ) ); + assertTrue( service.getFileStatus( target.toAbsolutePath().toString() ).isExists() ); // normally should not exists :-) - assertFalse( service.fileLocationExists( "/fooofofof/foddfdofd/dedede/kdeo" ) ); + assertFalse( service.getFileStatus( "/fooofofof/foddfdofd/dedede/kdeo" ).isExists() ); } @@ -151,7 +150,7 @@ public class ManagedRepositoriesServiceTest repositoriesService.scanRepositoryDirectoriesNow( testRepoId ); int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( testRepoId ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( testRepoId ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java index b2471edfe..ed5b731c8 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RemoteRepositoriesServiceTest.java @@ -176,7 +176,7 @@ public class RemoteRepositoriesServiceTest service.addRemoteRepository(getRemoteRepository()); - assertTrue(service.checkRemoteConnectivity("id-new")); + assertTrue(service.checkRemoteConnectivity("id-new").isSuccess()); } finally { removeRemoteRepositories("id-new"); } @@ -198,7 +198,7 @@ public class RemoteRepositoriesServiceTest service.addRemoteRepository(getRemoteMavenRepository()); - assertTrue(service.checkRemoteConnectivity("id-maven1")); + assertTrue(service.checkRemoteConnectivity("id-maven1").isSuccess()); } finally { removeRemoteRepositories("id-maven1"); } @@ -222,7 +222,7 @@ public class RemoteRepositoriesServiceTest service.addRemoteRepository(getRemoteOracleRepository()); - assertTrue(service.checkRemoteConnectivity("id-oracle")); + assertTrue(service.checkRemoteConnectivity("id-oracle").isSuccess()); } finally { removeRemoteRepositories("id-oracle"); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java index 7b765c2b1..fd14b026e 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java @@ -21,7 +21,6 @@ package org.apache.archiva.rest.services; import org.apache.archiva.admin.model.beans.ManagedRepository; import org.apache.archiva.maven2.model.Artifact; -import org.apache.archiva.redback.rest.api.services.RedbackServiceException; import org.apache.archiva.redback.rest.api.services.UserService; import org.apache.archiva.rest.api.model.BrowseResult; import org.apache.archiva.rest.api.model.BrowseResultEntry; @@ -37,7 +36,6 @@ import javax.ws.rs.ForbiddenException; import javax.ws.rs.core.Response; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.List; import java.util.Locale; @@ -77,13 +75,13 @@ public class RepositoriesServiceTest String repoId = managedRepositoriesService.getManagedRepositories().get( 0 ).getId(); int timeout = 20000; - while ( timeout > 0 && service.alreadyScanning( repoId ) ) + while ( timeout > 0 && service.getScanStatus( repoId ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; } - assertTrue( service.scanRepository( repoId, true ) ); + assertTrue( service.scanRepository( repoId, true ).isSuccess() ); } @Test( expected = ForbiddenException.class ) @@ -393,7 +391,7 @@ public class RepositoriesServiceTest { getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); - assertTrue( repositoriesService.isAuthorizedToDeleteArtifacts( managedRepository.getId() ) ); + assertTrue( repositoriesService.getPermissionStatus( managedRepository.getId() ).isAuthorizedToDeleteArtifacts() ); } finally { @@ -413,7 +411,7 @@ public class RepositoriesServiceTest { getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); RepositoriesService repositoriesService = getRepositoriesService( ); - assertFalse( repositoriesService.isAuthorizedToDeleteArtifacts( managedRepository.getId() ) ); + assertFalse( repositoriesService.getPermissionStatus( managedRepository.getId() ).isAuthorizedToDeleteArtifacts() ); } finally { diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml index 11a7b9022..8e0fce6e0 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j2-test.xml @@ -49,7 +49,8 @@ - + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactFromQueryTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactFromQueryTest.java index b13e24722..183839c1e 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactFromQueryTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadArtifactFromQueryTest.java @@ -38,7 +38,6 @@ import java.io.IOException; import java.net.URI; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Locale; /** @@ -129,7 +128,7 @@ public class DownloadArtifactFromQueryTest // wait a bit to ensure index is finished int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( id ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( id ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexNonDefaultPathTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexNonDefaultPathTest.java index ebe5f9f49..a0d5ff3d1 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexNonDefaultPathTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexNonDefaultPathTest.java @@ -43,10 +43,6 @@ import org.junit.runner.RunWith; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -145,7 +141,7 @@ public class DownloadMergedIndexNonDefaultPathTest // wait a bit to ensure index is finished int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( id ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( id ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexTest.java index 5e27eeb14..01b2cb6bf 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/DownloadMergedIndexTest.java @@ -43,7 +43,6 @@ import org.junit.runner.RunWith; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -136,7 +135,7 @@ public class DownloadMergedIndexTest // wait a bit to ensure index is finished int timeout = 20000; - while ( timeout > 0 && repositoriesService.alreadyScanning( id ) ) + while ( timeout > 0 && repositoriesService.getScanStatus( id ).isAlreadyScanning() ) { Thread.sleep( 500 ); timeout -= 500; diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java index 435f51de5..084a38cea 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/remotedownload/RemoteRepositoryConnectivityCheckTest.java @@ -37,7 +37,6 @@ import org.junit.Test; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Locale; import static org.assertj.core.api.Assertions.assertThat; @@ -110,7 +109,7 @@ public class RemoteRepositoryConnectivityCheckTest service.addRemoteRepository( repo ); - assertThat( service.checkRemoteConnectivity( repo.getId() ) ).isTrue(); + assertThat( service.checkRemoteConnectivity( repo.getId() ).isSuccess() ).isTrue(); } finally { @@ -145,7 +144,7 @@ public class RemoteRepositoryConnectivityCheckTest service.addRemoteRepository( repo ); - assertThat( service.checkRemoteConnectivity( repo.getId() ) ).isTrue(); + assertThat( service.checkRemoteConnectivity( repo.getId() ).isSuccess() ).isTrue(); } finally { @@ -173,7 +172,7 @@ public class RemoteRepositoryConnectivityCheckTest service.addRemoteRepository( repo ); - assertThat( service.checkRemoteConnectivity( repo.getId() ) ).isFalse(); + assertThat( service.checkRemoteConnectivity( repo.getId() ).isSuccess() ).isFalse(); } finally { diff --git a/pom.xml b/pom.xml index cd4f4cf75..ca0cbfdf4 100644 --- a/pom.xml +++ b/pom.xml @@ -707,18 +707,22 @@ cxf-rt-frontend-jaxrs ${cxf.version} - org.apache.cxf cxf-rt-rs-client ${cxf.version} - org.apache.cxf cxf-rt-rs-extension-providers ${cxf.version} + + org.apache.cxf + cxf-rt-features-logging + ${cxf.version} + + org.apache.archiva archiva-rest-api