From fdb48a6024f986a2e4181c1c583f2f282e2dfd1b Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Tue, 30 Jun 2020 21:19:55 +0200 Subject: [PATCH] Replacing simple REST return types by model objects --- pom.xml | 42 ++++ .../redback-rest/redback-rest-api/pom.xml | 21 ++ .../src/enunciate/enunciate.xml | 48 ---- .../redback/rest/api/model/ActionStatus.java | 76 +++++++ .../api/model/AuthenticationKeyResult.java | 50 ++++ .../rest/api/model/AvailabilityStatus.java | 48 ++++ .../rest/api/model/PasswordStatus.java | 45 ++++ .../redback/rest/api/model/PingResult.java | 48 ++++ .../rest/api/model/VerificationStatus.java | 48 ++++ .../api/services/LdapGroupMappingService.java | 9 +- .../rest/api/services/LoginService.java | 16 +- .../api/services/RoleManagementService.java | 35 +-- .../rest/api/services/UserService.java | 43 ++-- .../src/main/resources/openapi-codegen-ignore | 0 .../main/resources/openapi-configuration.yaml | 16 ++ .../resources/templates/bodyParam.mustache | 4 + .../resources/templates/formParam.mustache | 3 + .../resources/templates/headerParam.mustache | 3 + .../main/resources/templates/index.mustache | 213 ++++++++++++++++++ .../resources/templates/pathParam.mustache | 3 + .../resources/templates/queryParam.mustache | 3 + .../resources/templates/style.css.mustache | 172 ++++++++++++++ .../redback-rest-services/pom.xml | 14 ++ .../DefaultLdapGroupMappingService.java | 13 +- .../rest/services/DefaultLoginService.java | 19 +- .../DefaultRoleManagementService.java | 59 ++--- .../rest/services/DefaultUserService.java | 105 +++++---- .../interceptors/JacksonJsonConfigurator.java | 7 +- .../META-INF/cxf/org.apache.cxf.Logger | 1 + .../resources/META-INF/spring-context.xml | 10 +- .../services/AbstractRestServicesTest.java | 2 +- .../services/RoleManagementServiceTest.java | 6 +- .../rest/services/UserServiceTest.java | 16 +- 33 files changed, 999 insertions(+), 199 deletions(-) delete mode 100644 redback-integrations/redback-rest/redback-rest-api/src/enunciate/enunciate.xml create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/ActionStatus.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AuthenticationKeyResult.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AvailabilityStatus.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PasswordStatus.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PingResult.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/VerificationStatus.java create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-codegen-ignore create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-configuration.yaml create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/bodyParam.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/formParam.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/headerParam.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/index.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/pathParam.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/queryParam.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/style.css.mustache create mode 100644 redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger diff --git a/pom.xml b/pom.xml index c861d3e6..1aac0b0f 100644 --- a/pom.xml +++ b/pom.xml @@ -582,6 +582,48 @@ ${cxf.version} + + io.swagger.core.v3 + swagger-core + compile + ${io.swagger.version} + + + javax.ws.rs + jsr311-api + + + + + io.swagger.core.v3 + swagger-jaxrs2 + ${io.swagger.version} + + + javax.ws.rs + jsr311-api + + + + + io.swagger.core.v3 + swagger-annotations + ${io.swagger.version} + + + javax.ws.rs + jsr311-api + + + + + + jakarta.xml.bind + jakarta.xml.bind-api + 2.3.3 + provided + + javax.mail mail diff --git a/redback-integrations/redback-rest/redback-rest-api/pom.xml b/redback-integrations/redback-rest/redback-rest-api/pom.xml index ffd52d39..9fc6b2a8 100644 --- a/redback-integrations/redback-rest/redback-rest-api/pom.xml +++ b/redback-integrations/redback-rest/redback-rest-api/pom.xml @@ -71,8 +71,29 @@ org.apache.commons commons-lang3 + + + + + + + + org.apache.rat + apache-rat-plugin + + + target/generated + src/main/resources/templates/* + src/main/resources/openapi-codegen-ignore + + + + + + + - - - Apache Archiva Redback REST API - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/ActionStatus.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/ActionStatus.java new file mode 100644 index 00000000..9ed23bce --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/ActionStatus.java @@ -0,0 +1,76 @@ +package org.apache.archiva.redback.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; + +/** + * @author Martin Stockhammer + */ +@XmlRootElement(name = "actionStatus") +public class ActionStatus +{ + private boolean success = false; + private int modifiedNumber = 0; + + public static final ActionStatus SUCCESS = new ActionStatus( true ); + public static final ActionStatus FAIL = new ActionStatus( false ); + public static ActionStatus FROM(boolean status) { + return status ? SUCCESS : FAIL; + } + + public ActionStatus() { + + } + + public ActionStatus( boolean success) { + this.success = success; + } + + public ActionStatus(boolean success, int modifiedNumber) { + this.success = success; + this.modifiedNumber = modifiedNumber; + } + + public boolean isSuccess( ) + { + return success; + } + + public void setSuccess( boolean success ) + { + this.success = success; + } + + public int getModifiedNumber( ) + { + return modifiedNumber; + } + + public void setModifiedNumber( int modifiedNumber ) + { + this.modifiedNumber = modifiedNumber; + } + + @Override + public String toString( ) + { + return Boolean.toString( success ); + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AuthenticationKeyResult.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AuthenticationKeyResult.java new file mode 100644 index 00000000..467c9fb7 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AuthenticationKeyResult.java @@ -0,0 +1,50 @@ +package org.apache.archiva.redback.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 org.apache.archiva.redback.keys.AuthenticationKey; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * @author Martin Stockhammer + */ +@XmlRootElement(name = "authenticationKeyResult") +public class AuthenticationKeyResult +{ + String key = ""; + + public AuthenticationKeyResult() { + + } + + public AuthenticationKeyResult(String key) { + this.key = key; + } + + public String getKey( ) + { + return key; + } + + public void setKey( String key ) + { + this.key = key; + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AvailabilityStatus.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AvailabilityStatus.java new file mode 100644 index 00000000..da54317b --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/AvailabilityStatus.java @@ -0,0 +1,48 @@ +package org.apache.archiva.redback.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; + +/** + * @author Martin Stockhammer + */ +@XmlRootElement(name="availabilityStatus") +public class AvailabilityStatus +{ + boolean exists = false; + + public AvailabilityStatus() { + + } + + public AvailabilityStatus(boolean exists) { + this.exists = exists; + } + + public boolean isExists( ) + { + return exists; + } + + public void setExists( boolean exists ) + { + this.exists = exists; + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PasswordStatus.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PasswordStatus.java new file mode 100644 index 00000000..7a20e36c --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PasswordStatus.java @@ -0,0 +1,45 @@ +package org.apache.archiva.redback.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. + */ + +/** + * @author Martin Stockhammer + */ +public class PasswordStatus +{ + boolean changeRequired = false; + + public PasswordStatus() { + + } + + public PasswordStatus(boolean changeRequired) { + this.changeRequired = changeRequired; + } + + public boolean isChangeRequired( ) + { + return changeRequired; + } + + public void setChangeRequired( boolean changeRequired ) + { + this.changeRequired = changeRequired; + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PingResult.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PingResult.java new file mode 100644 index 00000000..34bde926 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PingResult.java @@ -0,0 +1,48 @@ +package org.apache.archiva.redback.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; + +/** + * @author Martin Stockhammer + */ +@XmlRootElement(name="pingResult") +public class PingResult +{ + boolean success; + + public PingResult() { + + } + + public PingResult( boolean success ) { + this.success = success; + } + + public boolean isSuccess( ) + { + return success; + } + + public void setSuccess( boolean success ) + { + this.success = success; + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/VerificationStatus.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/VerificationStatus.java new file mode 100644 index 00000000..3e5afed6 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/VerificationStatus.java @@ -0,0 +1,48 @@ +package org.apache.archiva.redback.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; + +/** + * @author Martin Stockhammer + */ +@XmlRootElement(name="verificationStatus") +public class VerificationStatus +{ + boolean success = false; + + public VerificationStatus() { + + } + + public VerificationStatus(boolean success ) { + this.success = success; + } + + public boolean isSuccess( ) + { + return success; + } + + public void setSuccess( boolean success ) + { + this.success = success; + } +} diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java index 6074a35d..fb326160 100644 --- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LdapGroupMappingService.java @@ -18,8 +18,10 @@ package org.apache.archiva.redback.rest.api.services; * under the License. */ +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; +import org.apache.archiva.redback.rest.api.model.ActionStatus; import org.apache.archiva.redback.rest.api.model.LdapGroupMapping; import org.apache.archiva.redback.rest.api.model.LdapGroupMappingUpdateRequest; import org.apache.archiva.redback.rest.api.model.StringList; @@ -40,6 +42,7 @@ import java.util.List; * @since 2.1 */ @Path("/ldapGroupMappingService/") +@Tag( name = "LDAP", description = "LDAP Service" ) public interface LdapGroupMappingService { @Path("ldapGroups") @@ -61,7 +64,7 @@ public interface LdapGroupMappingService @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION) - Boolean addLdapGroupMapping( LdapGroupMapping ldapGroupMapping ) + ActionStatus addLdapGroupMapping( LdapGroupMapping ldapGroupMapping ) throws RedbackServiceException; @DELETE @@ -69,14 +72,14 @@ public interface LdapGroupMappingService @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION) - Boolean removeLdapGroupMapping( @PathParam("group") String group ) + ActionStatus removeLdapGroupMapping( @PathParam("group") String group ) throws RedbackServiceException; @POST @Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @RedbackAuthorization(permissions = RedbackRoleConstants.CONFIGURATION_EDIT_OPERATION) - Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest ) + ActionStatus updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest ) throws RedbackServiceException; } diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java index f0e4f075..1ff1dcd1 100644 --- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/LoginService.java @@ -20,7 +20,11 @@ package org.apache.archiva.redback.rest.api.services; */ import org.apache.archiva.redback.authorization.RedbackAuthorization; +import org.apache.archiva.redback.keys.AuthenticationKey; +import org.apache.archiva.redback.rest.api.model.ActionStatus; +import org.apache.archiva.redback.rest.api.model.AuthenticationKeyResult; import org.apache.archiva.redback.rest.api.model.LoginRequest; +import org.apache.archiva.redback.rest.api.model.PingResult; import org.apache.archiva.redback.rest.api.model.User; import javax.ws.rs.GET; @@ -38,9 +42,9 @@ public interface LoginService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true ) - String addAuthenticationKey( @QueryParam( "providerKey" ) String providedKey, - @QueryParam( "principal" ) String principal, @QueryParam( "purpose" ) String purpose, - @QueryParam( "expirationMinutes" ) int expirationMinutes ) + AuthenticationKeyResult addAuthenticationKey( @QueryParam( "providerKey" ) String providedKey, + @QueryParam( "principal" ) String principal, @QueryParam( "purpose" ) String purpose, + @QueryParam( "expirationMinutes" ) int expirationMinutes ) throws RedbackServiceException; @@ -48,7 +52,7 @@ public interface LoginService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true ) - Boolean ping() + PingResult ping() throws RedbackServiceException; @@ -56,7 +60,7 @@ public interface LoginService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = false, noPermission = true ) - Boolean pingWithAutz() + PingResult pingWithAutz() throws RedbackServiceException; /** @@ -89,6 +93,6 @@ public interface LoginService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true, noPermission = true ) - Boolean logout() + ActionStatus logout() throws RedbackServiceException; } diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/RoleManagementService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/RoleManagementService.java index 2b62849e..761e3344 100644 --- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/RoleManagementService.java +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/RoleManagementService.java @@ -20,10 +20,13 @@ package org.apache.archiva.redback.rest.api.services; import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; +import org.apache.archiva.redback.rest.api.model.ActionStatus; import org.apache.archiva.redback.rest.api.model.Application; import org.apache.archiva.redback.rest.api.model.ApplicationRoles; +import org.apache.archiva.redback.rest.api.model.AvailabilityStatus; import org.apache.archiva.redback.rest.api.model.Role; import org.apache.archiva.redback.rest.api.model.User; +import org.apache.archiva.redback.rest.api.model.VerificationStatus; import javax.ws.rs.Consumes; import javax.ws.rs.GET; @@ -46,8 +49,8 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean createTemplatedRole( @QueryParam( "templateId" ) String templateId, - @QueryParam( "resource" ) String resource ) + ActionStatus createTemplatedRole( @QueryParam( "templateId" ) String templateId, + @QueryParam( "resource" ) String resource ) throws RedbackServiceException; /** @@ -62,7 +65,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean removeTemplatedRole( @QueryParam( "templateId" ) String templateId, + ActionStatus removeTemplatedRole( @QueryParam( "templateId" ) String templateId, @QueryParam( "resource" ) String resource ) throws RedbackServiceException; @@ -81,7 +84,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean updateRole( @QueryParam( "templateId" ) String templateId, @QueryParam( "oldResource" ) String oldResource, + ActionStatus updateRole( @QueryParam( "templateId" ) String templateId, @QueryParam( "oldResource" ) String oldResource, @QueryParam( "newResource" ) String newResource ) throws RedbackServiceException; @@ -96,7 +99,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean assignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal ) + ActionStatus assignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal ) throws RedbackServiceException; /** @@ -110,7 +113,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean assignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal ) + ActionStatus assignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal ) throws RedbackServiceException; /** @@ -126,7 +129,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean assignTemplatedRole( @QueryParam( "templateId" ) String templateId, + ActionStatus assignTemplatedRole( @QueryParam( "templateId" ) String templateId, @QueryParam( "resource" ) String resource, @QueryParam( "principal" ) String principal ) throws RedbackServiceException; @@ -142,7 +145,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean unassignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal ) + ActionStatus unassignRole( @QueryParam( "roleId" ) String roleId, @QueryParam( "principal" ) String principal ) throws RedbackServiceException; /** @@ -156,7 +159,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean unassignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal ) + ActionStatus unassignRoleByName( @QueryParam( "roleName" ) String roleName, @QueryParam( "principal" ) String principal ) throws RedbackServiceException; /** @@ -170,7 +173,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean roleExists( @QueryParam( "roleId" ) String roleId ) + AvailabilityStatus roleExists( @QueryParam( "roleId" ) String roleId ) throws RedbackServiceException; /** @@ -185,7 +188,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean templatedRoleExists( @QueryParam( "templateId" ) String templateId, + AvailabilityStatus templatedRoleExists( @QueryParam( "templateId" ) String templateId, @QueryParam( "resource" ) String resource ) throws RedbackServiceException; @@ -201,8 +204,8 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean verifyTemplatedRole( @QueryParam( "templateId" ) String templateId, - @QueryParam( "resource" ) String resource ) + VerificationStatus verifyTemplatedRole( @QueryParam( "templateId" ) String templateId, + @QueryParam( "resource" ) String resource ) throws RedbackServiceException; /** @@ -265,7 +268,7 @@ public interface RoleManagementService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean updateRoleDescription( @QueryParam( "roleName" ) String roleName, + ActionStatus updateRoleDescription( @QueryParam( "roleName" ) String roleName, @QueryParam( "roleDescription" ) String description ) throws RedbackServiceException; @@ -278,7 +281,7 @@ public interface RoleManagementService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean updateRoleUsers( Role role ) + ActionStatus updateRoleUsers( Role role ) throws RedbackServiceException; /** @@ -300,7 +303,7 @@ public interface RoleManagementService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_RBAC_ADMIN_OPERATION ) - Boolean updateUserRoles( User user ) + ActionStatus updateUserRoles( User user ) throws RedbackServiceException; } diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/UserService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/UserService.java index 9d10ff76..0363c852 100644 --- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/UserService.java +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/UserService.java @@ -21,13 +21,19 @@ package org.apache.archiva.redback.rest.api.services; import org.apache.archiva.redback.authorization.RedbackAuthorization; import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants; +import org.apache.archiva.redback.rest.api.model.ActionStatus; +import org.apache.archiva.redback.rest.api.model.AvailabilityStatus; import org.apache.archiva.redback.rest.api.model.Operation; +import org.apache.archiva.redback.rest.api.model.PasswordStatus; import org.apache.archiva.redback.rest.api.model.Permission; +import org.apache.archiva.redback.rest.api.model.PingResult; import org.apache.archiva.redback.rest.api.model.RegistrationKey; import org.apache.archiva.redback.rest.api.model.ResetPasswordRequest; import org.apache.archiva.redback.rest.api.model.User; import org.apache.archiva.redback.rest.api.model.UserRegistrationRequest; +import org.apache.archiva.redback.rest.api.model.VerificationStatus; +import javax.swing.*; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -61,7 +67,7 @@ public interface UserService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_CREATE_OPERATION ) - Boolean createUser( User user ) + ActionStatus createUser( User user ) throws RedbackServiceException; @@ -73,14 +79,14 @@ public interface UserService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noRestriction = true ) - Boolean createAdminUser( User user ) + ActionStatus createAdminUser( User user ) throws RedbackServiceException; @Path( "isAdminUserExists" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true ) - Boolean isAdminUserExists() + AvailabilityStatus isAdminUserExists() throws RedbackServiceException; @@ -88,14 +94,14 @@ public interface UserService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_DELETE_OPERATION ) - Boolean deleteUser( @PathParam( "userName" ) String username ) + ActionStatus deleteUser( @PathParam( "userName" ) String username ) throws RedbackServiceException; @Path( "updateUser" ) @POST @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - Boolean updateUser( User user ) + ActionStatus updateUser( User user ) throws RedbackServiceException; /** @@ -105,7 +111,7 @@ public interface UserService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - Boolean lockUser( @PathParam( "username" ) String username ) + ActionStatus lockUser( @PathParam( "username" ) String username ) throws RedbackServiceException; /** @@ -115,7 +121,7 @@ public interface UserService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - Boolean unlockUser( @PathParam( "username" ) String username ) + ActionStatus unlockUser( @PathParam( "username" ) String username ) throws RedbackServiceException; @@ -126,20 +132,9 @@ public interface UserService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - Boolean passwordChangeRequired( @PathParam( "username" ) String username ) + PasswordStatus passwordChangeRequired( @PathParam( "username" ) String username ) throws RedbackServiceException; - /** - * @since 2.0 - */ - @Path( "passwordChangeNotRequired/{username}" ) - @GET - @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) - @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - Boolean passwordChangeNotRequired( @PathParam( "username" ) String username ) - throws RedbackServiceException; - - /** * update only the current user and this fields: fullname, email, password. * the service verify the curent logged user with the one passed in the method @@ -149,21 +144,21 @@ public interface UserService @POST @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = false, noPermission = true ) - Boolean updateMe( User user ) + ActionStatus updateMe( User user ) throws RedbackServiceException; @Path( "ping" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true ) - Boolean ping() + PingResult ping() throws RedbackServiceException; @Path( "removeFromCache/{userName}" ) @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( permissions = RedbackRoleConstants.USER_MANAGEMENT_USER_EDIT_OPERATION ) - int removeFromCache( @PathParam( "userName" ) String username ) + ActionStatus removeFromCache( @PathParam( "userName" ) String username ) throws RedbackServiceException; @Path( "getGuestUser" ) @@ -202,7 +197,7 @@ public interface UserService @GET @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @RedbackAuthorization( noRestriction = true, noPermission = true ) - Boolean validateUserFromKey( @PathParam( "key" ) String key ) + VerificationStatus validateUserFromKey( @PathParam( "key" ) String key ) throws RedbackServiceException; /** @@ -215,7 +210,7 @@ public interface UserService @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN } ) @Consumes( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } ) @RedbackAuthorization( noRestriction = true, noPermission = true ) - Boolean resetPassword( ResetPasswordRequest resetPasswordRequest ) + ActionStatus resetPassword( ResetPasswordRequest resetPasswordRequest ) throws RedbackServiceException; /** diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-codegen-ignore b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-codegen-ignore new file mode 100644 index 00000000..e69de29b diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-configuration.yaml b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-configuration.yaml new file mode 100644 index 00000000..97ee6b12 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-configuration.yaml @@ -0,0 +1,16 @@ +resourcePackages: + - org.apache.archiva.redback.rest.api +prettyPrint: true +cacheTTL: 0 +openAPI: + info: + version: '3.0' + title: Apache Archiva Redback REST API + description: 'This is the Apache Archiva Redback REST API documentation' + termsOfService: https://archiva.apache.org + contact: + email: dev@archiva.apache.org + url: https://archiva.apache.org/index.html + license: + name: Apache 2.0 + url: http://www.apache.org/licenses/LICENSE-2.0.html \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/bodyParam.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/bodyParam.mustache new file mode 100644 index 00000000..4873e06e --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/bodyParam.mustache @@ -0,0 +1,4 @@ +{{#is this 'body-param'}}
{{baseName}} {{#baseType}}{{baseType}}{{/baseType}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}
+ +
Body Parameter — {{unescapedDescription}} {{#defaultValue}}default: {{{defaultValue}}}{{/defaultValue}}
{{/is}} + {{#example}}
example: {{example}}
{{/example}} \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/formParam.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/formParam.mustache new file mode 100644 index 00000000..6d23f933 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/formParam.mustache @@ -0,0 +1,3 @@ +{{#is this 'form-param'}}
{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}
+ +
Form Parameter — {{unescapedDescription}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}
{{/is}} \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/headerParam.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/headerParam.mustache new file mode 100644 index 00000000..ad00e3cb --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/headerParam.mustache @@ -0,0 +1,3 @@ +{{#is this 'header-param'}}
{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}
+ +
Header Parameter — {{unescapedDescription}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}
{{/is}} \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/index.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/index.mustache new file mode 100644 index 00000000..59b27c89 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/index.mustache @@ -0,0 +1,213 @@ + + + + {{{appName}}} + + + +

{{{appName}}}

+
{{{appDescription}}}
+ {{#infoUrl}}
More information: {{{infoUrl}}}
{{/infoUrl}} + {{#infoEmail}}
Contact Info: {{{infoEmail}}}
{{/infoEmail}} + {{#version}}
Version: {{{version}}}
{{/version}} + {{#basePathWithoutHost}}
BasePath:{{basePathWithoutHost}}
{{/basePathWithoutHost}} +
{{{licenseInfo}}}
+
{{{licenseUrl}}}
+

Access

+ {{#hasAuthMethods}} +
    + {{#authMethods}} +
  1. {{#is this 'basic'}}HTTP Basic Authentication{{/is}}{{#is this 'oauth'}}OAuth AuthorizationUrl:{{authorizationUrl}}TokenUrl:{{tokenUrl}}{{/is}}{{#is this 'api-key'}}APIKey KeyParamName:{{keyParamName}} KeyInQuery:{{isKeyInQuery}} KeyInHeader:{{isKeyInHeader}}{{/is}}
  2. + {{/authMethods}} +
+ {{/hasAuthMethods}} + +

Methods

+ [ Jump to Models ] + + {{! for the tables of content, I cheat and don't use CSS styles.... }} +

Table of Contents

+
{{access}}
+ {{#apiInfo}} + {{#apis}} + {{#operations}} +

{{baseName}}

+ + {{/operations}} + {{/apis}} + {{/apiInfo}} + + {{#apiInfo}} + {{#apis}} + {{#operations}} +

{{baseName}}

+ {{#operation}} +
+
+ Up +
{{httpMethod}} {{path}}
+
{{summary}} ({{nickname}})
+ {{! notes is operation.description. So why rename it and make it super confusing???? }} +
{{notes}}
+ + {{#hasPathParams}} +

Path parameters

+
+ {{#pathParams}}{{>pathParam}}{{/pathParams}} +
+ {{/hasPathParams}} + + {{#has this 'consumes'}} +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    + {{#consumes}} +
  • {{{mediaType}}}
  • + {{/consumes}} +
+ {{/has}} + + {{#hasBodyParam}} +

Request body

+
+ {{#bodyParams}}{{>bodyParam}}{{/bodyParams}} +
+ {{/hasBodyParam}} + + {{#hasHeaderParams}} +

Request headers

+
+ {{#headerParam}}{{>headerParam}}{{/headerParam}} +
+ {{/hasHeaderParams}} + + {{#hasQueryParams}} +

Query parameters

+
+ {{#queryParams}}{{>queryParam}}{{/queryParams}} +
+ {{/hasQueryParams}} + + {{#hasFormParams}} +

Form parameters

+
+ {{#formParams}}{{>formParam}}{{/formParams}} +
+ {{/hasFormParams}} + + {{#returnType}} +

Return type

+
+ {{#hasReference}}{{^returnSimpleType}}{{returnContainer}}[{{/returnSimpleType}}{{returnBaseType}}{{^returnSimpleType}}]{{/returnSimpleType}}{{/hasReference}} + {{^hasReference}}{{returnType}}{{/hasReference}} +
+ {{/returnType}} + + + + {{#hasExamples}} + {{#examples}} +

Example data

+
Content-Type: {{{contentType}}}
+
{{{example}}}
+ {{/examples}} + {{/hasExamples}} + + {{#has this 'produces'}} +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    + {{#produces}} +
  • {{{mediaType}}}
  • + {{/produces}} +
+ {{/has}} + +

Responses

+ {{#responses}} +

{{code}}

+ {{message}} + {{#simpleType}}{{dataType}}{{/simpleType}} + {{#examples}} +

Example data

+
Content-Type: {{{contentType}}}
+
{{example}}
+ {{/examples}} + {{/responses}} +
+
+ {{/operation}} + {{/operations}} + {{/apis}} + {{/apiInfo}} + +

Models

+ [ Jump to Methods ] + +

Table of Contents

+
    + {{#models}} + {{#model}} +
  1. {{name}}{{#title}} - {{title}}{{/title}}
  2. + {{/model}} + {{/models}} +
+ + {{#models}} + {{#model}} +
+

{{name}}{{#title}} - {{title}}{{/title}} Up

+ {{#unescapedDescription}}
{{unescapedDescription}}
{{/unescapedDescription}} +
+ {{#vars}}
{{name}} {{^required}}(optional){{/required}}
{{#isNot this 'primitive-type'}}{{datatype}}{{/isNot}} {{unescapedDescription}} {{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}
+ {{#is this 'enum'}} +
Enum:
+ {{#_enum}}
{{this}}
{{/_enum}} + {{/is}} + {{#example}} +
example: {{example}}
+ {{/example}} + {{#vendorExtensions.oneOf-model}} +
oneOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.oneOf-model}} + {{#vendorExtensions.anyOf-model}} +
anyOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.anyOf-model}} + {{#items}} + {{#vendorExtensions.oneOf-model}} +
items oneOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.oneOf-model}} + {{#vendorExtensions.anyOf-model}} +
items anyOf: + {{#vendorExtensions.x-model-names}} + {{this}}    + {{/vendorExtensions.x-model-names}} +
+ {{/vendorExtensions.anyOf-model}} + {{/items}} + {{/vars}} +
+
+ {{/model}} + {{/models}} + + diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/pathParam.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/pathParam.mustache new file mode 100644 index 00000000..fa512bfd --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/pathParam.mustache @@ -0,0 +1,3 @@ +{{#is this 'path-param'}}
{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}
+ +
Path Parameter — {{unescapedDescription}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}
{{/is}} \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/queryParam.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/queryParam.mustache new file mode 100644 index 00000000..ee9f48a7 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/queryParam.mustache @@ -0,0 +1,3 @@ +{{#is this 'query-param'}}
{{baseName}} {{^required}}(optional){{/required}}{{#required}}(required){{/required}}
+ +
Query Parameter — {{unescapedDescription}} {{#defaultValue}}default: {{{defaultValue}}} {{/defaultValue}}{{#dataFormat}}format: {{{dataFormat}}}{{/dataFormat}}
{{/is}} \ No newline at end of file diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/style.css.mustache b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/style.css.mustache new file mode 100644 index 00000000..04eccf69 --- /dev/null +++ b/redback-integrations/redback-rest/redback-rest-api/src/main/resources/templates/style.css.mustache @@ -0,0 +1,172 @@ +body { + font-family: Trebuchet MS, sans-serif; + font-size: 15px; + color: #444; + margin-right: 24px; +} + +h1 { + font-size: 25px; +} +h2 { + font-size: 20px; +} +h3 { + font-size: 16px; + font-weight: bold; +} +hr { + height: 1px; + border: 0; + color: #ddd; + background-color: #ddd; +} + +.app-desc { + clear: both; + margin-left: 20px; +} +.param-name { + width: 100%; +} +.license-info { + margin-left: 20px; +} + +.license-url { + margin-left: 20px; +} + +.model { + margin: 0 0 0px 20px; +} + +.method { + margin-left: 20px; +} + +.method-notes { + margin: 10px 0 20px 0; + font-size: 90%; + color: #555; +} + +pre { + padding: 10px; + margin-bottom: 2px; +} + +.http-method { + text-transform: uppercase; +} + +pre.get { + background-color: #0f6ab4; +} + +pre.post { + background-color: #10a54a; +} + +pre.put { + background-color: #c5862b; +} + +pre.delete { + background-color: #a41e22; +} + +.huge { + color: #fff; +} + +pre.example { + background-color: #f3f3f3; + padding: 10px; + border: 1px solid #ddd; +} + +code { + white-space: pre; +} + +.nickname { + font-weight: bold; +} + +.method-path { + font-size: 1.5em; + background-color: #0f6ab4; +} + +.up { + float:right; +} + +.parameter { + width: 500px; +} + +.param { + width: 500px; + padding: 10px 0 0 20px; + font-weight: bold; +} + +.param-desc { + width: 700px; + padding: 0 0 0 20px; + color: #777; +} + +.param-type { + font-style: italic; +} + +.param-enum-header { +width: 700px; +padding: 0 0 0 60px; +color: #777; +font-weight: bold; +} + +.param-enum { +width: 700px; +padding: 0 0 0 80px; +color: #777; +font-style: italic; +} + +.field-label { + padding: 0; + margin: 0; + clear: both; +} + +.field-items { + padding: 0 0 15px 0; + margin-bottom: 15px; +} + +.return-type { + clear: both; + padding-bottom: 10px; +} + +.param-header { + font-weight: bold; +} + +.method-tags { + text-align: right; +} + +.method-tag { + background: none repeat scroll 0% 0% #24A600; + border-radius: 3px; + padding: 2px 10px; + margin: 2px; + color: #FFF; + display: inline-block; + text-decoration: none; +} diff --git a/redback-integrations/redback-rest/redback-rest-services/pom.xml b/redback-integrations/redback-rest/redback-rest-services/pom.xml index b7512c52..61b6e7b9 100644 --- a/redback-integrations/redback-rest/redback-rest-services/pom.xml +++ b/redback-integrations/redback-rest/redback-rest-services/pom.xml @@ -186,6 +186,11 @@ jackson-jaxrs-xml-provider runtime + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + ${jackson.version} + org.apache.cxf @@ -327,6 +332,15 @@ + + org.apache.rat + apache-rat-plugin + + + src/main/resources/META-INF/cxf/org.apache.cxf.Logger + + + org.apache.maven.plugins maven-surefire-plugin diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java index 0fd85775..e4a8a0c7 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLdapGroupMappingService.java @@ -24,6 +24,7 @@ import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory; import org.apache.archiva.redback.common.ldap.connection.LdapException; import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper; import org.apache.archiva.redback.common.ldap.role.LdapRoleMapperConfiguration; +import org.apache.archiva.redback.rest.api.model.ActionStatus; import org.apache.archiva.redback.rest.api.model.LdapGroupMapping; import org.apache.archiva.redback.rest.api.model.LdapGroupMappingUpdateRequest; import org.apache.archiva.redback.rest.api.model.StringList; @@ -111,7 +112,7 @@ public class DefaultLdapGroupMappingService } } - public Boolean addLdapGroupMapping( LdapGroupMapping ldapGroupMapping ) + public ActionStatus addLdapGroupMapping( LdapGroupMapping ldapGroupMapping ) throws RedbackServiceException { try @@ -124,10 +125,10 @@ public class DefaultLdapGroupMappingService log.error( e.getMessage(), e ); throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean removeLdapGroupMapping( String group ) + public ActionStatus removeLdapGroupMapping( String group ) throws RedbackServiceException { try @@ -139,10 +140,10 @@ public class DefaultLdapGroupMappingService log.error( e.getMessage(), e ); throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest ) + public ActionStatus updateLdapGroupMapping( LdapGroupMappingUpdateRequest ldapGroupMappingUpdateRequest ) throws RedbackServiceException { try @@ -158,7 +159,7 @@ public class DefaultLdapGroupMappingService log.error( e.getMessage(), e ); throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } //------------------ diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java index 7dfbe4b2..170635b5 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultLoginService.java @@ -32,8 +32,11 @@ import org.apache.archiva.redback.keys.memory.MemoryAuthenticationKey; import org.apache.archiva.redback.keys.memory.MemoryKeyManager; import org.apache.archiva.redback.policy.AccountLockedException; import org.apache.archiva.redback.policy.MustChangePasswordException; +import org.apache.archiva.redback.rest.api.model.ActionStatus; +import org.apache.archiva.redback.rest.api.model.AuthenticationKeyResult; import org.apache.archiva.redback.rest.api.model.ErrorMessage; import org.apache.archiva.redback.rest.api.model.LoginRequest; +import org.apache.archiva.redback.rest.api.model.PingResult; import org.apache.archiva.redback.rest.api.model.User; import org.apache.archiva.redback.rest.api.services.LoginService; import org.apache.archiva.redback.rest.api.services.RedbackServiceException; @@ -87,7 +90,7 @@ public class DefaultLoginService } - public String addAuthenticationKey( String providedKey, String principal, String purpose, int expirationMinutes ) + public AuthenticationKeyResult addAuthenticationKey( String providedKey, String principal, String purpose, int expirationMinutes ) throws RedbackServiceException { KeyManager keyManager = securitySystem.getKeyManager(); @@ -118,19 +121,19 @@ public class DefaultLoginService keyManager.addKey( key ); - return key.getKey(); + return new AuthenticationKeyResult( key.getKey( ) ); } - public Boolean ping() + public PingResult ping() throws RedbackServiceException { - return Boolean.TRUE; + return new PingResult( true); } - public Boolean pingWithAutz() + public PingResult pingWithAutz() throws RedbackServiceException { - return Boolean.TRUE; + return new PingResult( true ); } public User logIn( LoginRequest loginRequest ) @@ -220,7 +223,7 @@ public class DefaultLoginService return isLogged && securitySession.getUser() != null ? buildRestUser( securitySession.getUser() ) : null; } - public Boolean logout() + public ActionStatus logout() throws RedbackServiceException { HttpSession httpSession = httpServletRequest.getSession(); @@ -228,7 +231,7 @@ public class DefaultLoginService { httpSession.invalidate(); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } private Calendar getNowGMT() diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java index 7f666377..a3a451cf 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultRoleManagementService.java @@ -26,11 +26,14 @@ import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.rbac.RbacManagerException; import org.apache.archiva.redback.rbac.Resource; import org.apache.archiva.redback.rbac.UserAssignment; +import org.apache.archiva.redback.rest.api.model.ActionStatus; import org.apache.archiva.redback.rest.api.model.Application; import org.apache.archiva.redback.rest.api.model.ApplicationRoles; +import org.apache.archiva.redback.rest.api.model.AvailabilityStatus; import org.apache.archiva.redback.rest.api.model.ErrorMessage; import org.apache.archiva.redback.rest.api.model.Role; import org.apache.archiva.redback.rest.api.model.RoleTemplate; +import org.apache.archiva.redback.rest.api.model.VerificationStatus; import org.apache.archiva.redback.rest.api.services.RedbackServiceException; import org.apache.archiva.redback.rest.api.services.RoleManagementService; import org.apache.archiva.redback.role.RoleManager; @@ -90,7 +93,7 @@ public class DefaultRoleManagementService log.debug( "use userManager impl: {}", userManager.getClass().getName() ); } - public Boolean createTemplatedRole( String templateId, String resource ) + public ActionStatus createTemplatedRole( String templateId, String resource ) throws RedbackServiceException { try @@ -101,10 +104,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean removeTemplatedRole( String templateId, String resource ) + public ActionStatus removeTemplatedRole( String templateId, String resource ) throws RedbackServiceException { @@ -116,10 +119,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean updateRole( String templateId, String oldResource, String newResource ) + public ActionStatus updateRole( String templateId, String oldResource, String newResource ) throws RedbackServiceException { try @@ -130,10 +133,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean assignRole( String roleId, String principal ) + public ActionStatus assignRole( String roleId, String principal ) throws RedbackServiceException { try @@ -144,10 +147,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean assignRoleByName( String roleName, String principal ) + public ActionStatus assignRoleByName( String roleName, String principal ) throws RedbackServiceException { try @@ -158,10 +161,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean assignTemplatedRole( String templateId, String resource, String principal ) + public ActionStatus assignTemplatedRole( String templateId, String resource, String principal ) throws RedbackServiceException { try @@ -172,10 +175,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean unassignRole( String roleId, String principal ) + public ActionStatus unassignRole( String roleId, String principal ) throws RedbackServiceException { try @@ -186,10 +189,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean unassignRoleByName( String roleName, String principal ) + public ActionStatus unassignRoleByName( String roleName, String principal ) throws RedbackServiceException { try @@ -200,15 +203,15 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean roleExists( String roleId ) + public AvailabilityStatus roleExists( String roleId ) throws RedbackServiceException { try { - return roleManager.roleExists( roleId ); + return new AvailabilityStatus( roleManager.roleExists( roleId ) ); } catch ( RoleManagerException e ) { @@ -216,12 +219,12 @@ public class DefaultRoleManagementService } } - public Boolean templatedRoleExists( String templateId, String resource ) + public AvailabilityStatus templatedRoleExists( String templateId, String resource ) throws RedbackServiceException { try { - return roleManager.templatedRoleExists( templateId, resource ); + return new AvailabilityStatus( roleManager.templatedRoleExists( templateId, resource ) ); } catch ( RoleManagerException e ) { @@ -230,7 +233,7 @@ public class DefaultRoleManagementService } - public Boolean verifyTemplatedRole( String templateId, String resource ) + public VerificationStatus verifyTemplatedRole( String templateId, String resource ) throws RedbackServiceException { try @@ -241,7 +244,7 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( e.getMessage() ); } - return Boolean.TRUE; + return new VerificationStatus( true ); } public List getEffectivelyAssignedRoles( String username ) @@ -460,7 +463,7 @@ public class DefaultRoleManagementService } } - public Boolean updateRoleDescription( String roleName, String description ) + public ActionStatus updateRoleDescription( String roleName, String description ) throws RedbackServiceException { try @@ -473,10 +476,10 @@ public class DefaultRoleManagementService { throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean updateRoleUsers( Role role ) + public ActionStatus updateRoleUsers( Role role ) throws RedbackServiceException { @@ -562,7 +565,7 @@ public class DefaultRoleManagementService } } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } public List getApplicationRoles( String username ) @@ -671,7 +674,7 @@ public class DefaultRoleManagementService } } - public Boolean updateUserRoles( org.apache.archiva.redback.rest.api.model.User user ) + public ActionStatus updateUserRoles( org.apache.archiva.redback.rest.api.model.User user ) throws RedbackServiceException { @@ -736,7 +739,7 @@ public class DefaultRoleManagementService throw redbackServiceException; } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java index b119c71d..320dc8ff 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/DefaultUserService.java @@ -39,14 +39,19 @@ import org.apache.archiva.redback.policy.UserSecurityPolicy; import org.apache.archiva.redback.rbac.RBACManager; import org.apache.archiva.redback.rbac.RbacManagerException; import org.apache.archiva.redback.rbac.UserAssignment; +import org.apache.archiva.redback.rest.api.model.ActionStatus; +import org.apache.archiva.redback.rest.api.model.AvailabilityStatus; import org.apache.archiva.redback.rest.api.model.ErrorMessage; import org.apache.archiva.redback.rest.api.model.Operation; +import org.apache.archiva.redback.rest.api.model.PasswordStatus; import org.apache.archiva.redback.rest.api.model.Permission; +import org.apache.archiva.redback.rest.api.model.PingResult; import org.apache.archiva.redback.rest.api.model.RegistrationKey; import org.apache.archiva.redback.rest.api.model.ResetPasswordRequest; import org.apache.archiva.redback.rest.api.model.Resource; import org.apache.archiva.redback.rest.api.model.User; import org.apache.archiva.redback.rest.api.model.UserRegistrationRequest; +import org.apache.archiva.redback.rest.api.model.VerificationStatus; import org.apache.archiva.redback.rest.api.services.RedbackServiceException; import org.apache.archiva.redback.rest.api.services.UserService; import org.apache.archiva.redback.rest.services.utils.PasswordValidator; @@ -141,7 +146,8 @@ public class DefaultUserService } - public Boolean createUser( User user ) + @Override + public ActionStatus createUser( User user ) throws RedbackServiceException { @@ -216,10 +222,11 @@ public class DefaultUserService { throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean deleteUser( String username ) + @Override + public ActionStatus deleteUser( String username ) throws RedbackServiceException { @@ -241,7 +248,7 @@ public class DefaultUserService try { userManager.deleteUser( username ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( UserNotFoundException e ) { @@ -259,6 +266,7 @@ public class DefaultUserService } + @Override public User getUser( String username ) throws RedbackServiceException { @@ -277,6 +285,7 @@ public class DefaultUserService } } + @Override public List getUsers() throws RedbackServiceException { @@ -298,7 +307,8 @@ public class DefaultUserService } } - public Boolean updateMe( User user ) + @Override + public ActionStatus updateMe( User user ) throws RedbackServiceException { // check username == one in the session @@ -365,10 +375,11 @@ public class DefaultUserService updateUser( realUser ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean updateUser( User user ) + @Override + public ActionStatus updateUser( User user ) throws RedbackServiceException { try @@ -383,7 +394,7 @@ public class DefaultUserService rawUser.setPermanent( user.isPermanent() ); userManager.updateUser( rawUser ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } catch ( UserNotFoundException e ) { @@ -395,7 +406,8 @@ public class DefaultUserService } } - public int removeFromCache( String userName ) + @Override + public ActionStatus removeFromCache( String userName ) throws RedbackServiceException { if ( userAssignmentsCache != null ) @@ -421,9 +433,10 @@ public class DefaultUserService } } - return 0; + return ActionStatus.SUCCESS; } + @Override public User getGuestUser() throws RedbackServiceException { @@ -438,6 +451,7 @@ public class DefaultUserService } } + @Override public User createGuestUser() throws RedbackServiceException { @@ -475,10 +489,11 @@ public class DefaultUserService } } - public Boolean ping() + @Override + public PingResult ping() throws RedbackServiceException { - return Boolean.TRUE; + return new PingResult( true ); } private User getSimpleUser( org.apache.archiva.redback.users.User user ) @@ -490,12 +505,13 @@ public class DefaultUserService return new User( user ); } - public Boolean createAdminUser( User adminUser ) + @Override + public ActionStatus createAdminUser( User adminUser ) throws RedbackServiceException { - if ( isAdminUserExists() ) + if ( isAdminUserExists().isExists() ) { - return Boolean.FALSE; + return ActionStatus.FAIL; } log.debug("Creating admin admin user '{}'", adminUser.getUsername()); if (!RedbackRoleConstants.ADMINISTRATOR_ACCOUNT_NAME.equals(adminUser.getUsername())) { @@ -526,16 +542,17 @@ public class DefaultUserService { throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - public Boolean isAdminUserExists() + @Override + public AvailabilityStatus isAdminUserExists() throws RedbackServiceException { try { userManager.findUser( config.getString( UserConfigurationKeys.DEFAULT_ADMIN ) ); - return Boolean.TRUE; + return new AvailabilityStatus( true ); } catch ( UserNotFoundException e ) { @@ -547,14 +564,15 @@ public class DefaultUserService if ( cause != null && cause instanceof UserNotFoundException ) { - return Boolean.FALSE; + return new AvailabilityStatus( false ); } throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); } - return Boolean.FALSE; + return new AvailabilityStatus( false ); } - public Boolean resetPassword( ResetPasswordRequest resetPasswordRequest ) + @Override + public ActionStatus resetPassword( ResetPasswordRequest resetPasswordRequest ) throws RedbackServiceException { String username = resetPasswordRequest.getUsername(); @@ -598,9 +616,10 @@ public class DefaultUserService throw new RedbackServiceException( new ErrorMessage( e.getMessage() ) ); } - return Boolean.TRUE; + return ActionStatus.SUCCESS; } + @Override public RegistrationKey registerUser( UserRegistrationRequest userRegistrationRequest ) throws RedbackServiceException { @@ -715,7 +734,8 @@ public class DefaultUserService } - public Boolean validateUserFromKey( String key ) + @Override + public VerificationStatus validateUserFromKey( String key ) throws RedbackServiceException { String principal = null; @@ -744,7 +764,7 @@ public class DefaultUserService log.info( "account validated for user {}", user.getUsername() ); - return Boolean.TRUE; + return new VerificationStatus( true ); } catch ( MustChangePasswordException | AccountLockedException | AuthenticationException e ) { @@ -771,6 +791,7 @@ public class DefaultUserService } } + @Override public Collection getCurrentUserPermissions() throws RedbackServiceException { @@ -788,6 +809,7 @@ public class DefaultUserService return getUserPermissions( userName ); } + @Override public Collection getCurrentUserOperations() throws RedbackServiceException { @@ -805,6 +827,7 @@ public class DefaultUserService return getUserOperations( userName ); } + @Override public Collection getUserOperations( String userName ) throws RedbackServiceException { @@ -822,6 +845,7 @@ public class DefaultUserService return operations; } + @Override public Collection getUserPermissions( String userName ) throws RedbackServiceException { @@ -950,7 +974,8 @@ public class DefaultUserService return null; } - public Boolean unlockUser( String username ) + @Override + public ActionStatus unlockUser( String username ) throws RedbackServiceException { User user = getUser( username ); @@ -958,12 +983,13 @@ public class DefaultUserService { user.setLocked( false ); updateUser( user ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - return Boolean.FALSE; + return ActionStatus.FAIL; } - public Boolean lockUser( String username ) + @Override + public ActionStatus lockUser( String username ) throws RedbackServiceException { User user = getUser( username ); @@ -971,12 +997,13 @@ public class DefaultUserService { user.setLocked( true ); updateUser( user ); - return Boolean.TRUE; + return ActionStatus.SUCCESS; } - return Boolean.FALSE; + return ActionStatus.FAIL; } - public Boolean passwordChangeRequired( String username ) + @Override + public PasswordStatus passwordChangeRequired( String username ) throws RedbackServiceException { User user = getUser( username ); @@ -984,21 +1011,9 @@ public class DefaultUserService { user.setPasswordChangeRequired( true ); updateUser( user ); - return Boolean.TRUE; + return new PasswordStatus( true ); } - return Boolean.FALSE; + return new PasswordStatus( false ); } - public Boolean passwordChangeNotRequired( String username ) - throws RedbackServiceException - { - User user = getUser( username ); - if ( user == null ) - { - user.setPasswordChangeRequired( false ); - updateUser( user ); - return Boolean.TRUE; - } - return Boolean.FALSE; - } } diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java index aca273c1..da24a700 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/interceptors/JacksonJsonConfigurator.java @@ -20,11 +20,14 @@ package org.apache.archiva.redback.rest.services.interceptors; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import org.eclipse.jetty.util.annotation.Name; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import javax.inject.Inject; +import javax.inject.Named; /** * to setup some ObjectMapper configuration @@ -38,10 +41,12 @@ public class JacksonJsonConfigurator private Logger log = LoggerFactory.getLogger( getClass() ); @Inject - public JacksonJsonConfigurator( ObjectMapper objectMapper ) + public JacksonJsonConfigurator( @Named("redbackJacksonJsonMapper") ObjectMapper objectMapper, + @Name( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper) { log.info( "configure jackson ObjectMapper" ); objectMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); + xmlMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES ); } } diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger b/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/cxf/org.apache.cxf.Logger new file mode 100644 index 00000000..27dd788b --- /dev/null +++ b/redback-integrations/redback-rest/redback-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/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml b/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml index c0b2e742..8e0441c1 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml +++ b/redback-integrations/redback-rest/redback-rest-services/src/main/resources/META-INF/spring-context.xml @@ -40,12 +40,17 @@ base-package="org.apache.archiva.redback.rest.services"/> - + - + + + + + + @@ -59,6 +64,7 @@ + diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java index 5ed7324b..972de2ee 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/AbstractRestServicesTest.java @@ -161,7 +161,7 @@ public abstract class AbstractRestServicesTest adminUser.setPassword( FakeCreateAdminServiceImpl.ADMIN_TEST_PWD ); adminUser.setFullName( "the admin user" ); adminUser.setEmail( "toto@toto.fr" ); - Boolean res = userService.createAdminUser( adminUser ); + Boolean res = userService.createAdminUser( adminUser ).isSuccess(); FakeCreateAdminService fakeCreateAdminService = getFakeCreateAdminService(); //assertTrue( res.booleanValue() ); diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java index ff2698d4..69d4b108 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/RoleManagementServiceTest.java @@ -49,8 +49,8 @@ public class RoleManagementServiceTest public void roleExist() throws Exception { - assertTrue( getRoleManagementService( authorizationHeader ).roleExists( "guest" ) ); - assertFalse( getRoleManagementService( authorizationHeader ).roleExists( "foo" ) ); + assertTrue( getRoleManagementService( authorizationHeader ).roleExists( "guest" ).isExists() ); + assertFalse( getRoleManagementService( authorizationHeader ).roleExists( "foo" ).isExists() ); } @Test( expected = ForbiddenException.class ) @@ -59,7 +59,7 @@ public class RoleManagementServiceTest { try { - assertTrue( getRoleManagementService( null ).roleExists( "guest" ) ); + assertTrue( getRoleManagementService( null ).roleExists( "guest" ).isExists() ); } catch ( ForbiddenException e ) { diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java index 0f76fdb6..f0ca82ec 100644 --- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java +++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/UserServiceTest.java @@ -59,7 +59,7 @@ public class UserServiceTest public void ping() throws Exception { - Boolean res = getUserService().ping(); + Boolean res = getUserService().ping().isSuccess(); assertTrue( res.booleanValue() ); } @@ -167,7 +167,7 @@ public class UserServiceTest assertThat( messageContent ).contains( "Use the following URL to validate your account." ).contains( "http://wine.fr/bordeaux" ).containsIgnoringCase( "toto" ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); service = getUserService( authorizationHeader ); @@ -177,7 +177,7 @@ public class UserServiceTest assertTrue( u.isValidated() ); assertTrue( u.isPasswordChangeRequired() ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); } catch ( Exception e ) @@ -226,7 +226,7 @@ public class UserServiceTest assertThat( messageContent ).contains( "Use the following URL to validate your account." ).contains( "http://localhost:" + getServerPort() ).containsIgnoringCase( "toto" ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); service = getUserService( authorizationHeader ); @@ -236,7 +236,7 @@ public class UserServiceTest assertTrue( u.isValidated() ); assertTrue( u.isPasswordChangeRequired() ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); } catch ( Exception e ) @@ -284,7 +284,7 @@ public class UserServiceTest assertTrue( emailMessages.get( 0 ).getText().contains( "Use the following URL to validate your account." ) ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); service = getUserService( authorizationHeader ); @@ -294,9 +294,9 @@ public class UserServiceTest assertTrue( u.isValidated() ); assertTrue( u.isPasswordChangeRequired() ); - assertTrue( service.validateUserFromKey( key ) ); + assertTrue( service.validateUserFromKey( key ).isSuccess() ); - assertTrue( service.resetPassword( new ResetPasswordRequest( "toto", "http://foo.fr/bar" ) ) ); + assertTrue( service.resetPassword( new ResetPasswordRequest( "toto", "http://foo.fr/bar" ) ).isSuccess() ); emailMessages = assertService.getEmailMessageSended(); assertEquals( 2, emailMessages.size() );