Moving rest utility classes to components

This commit is contained in:
Martin Stockhammer 2021-01-01 19:00:03 +01:00
parent ca8bf90050
commit d4b3b087fd
20 changed files with 31 additions and 44 deletions

View File

@ -2,12 +2,6 @@
<configuration default="false" name="All Rest Services" type="JUnit" factoryName="JUnit" folderName="Redback">
<module name="redback-rest-services" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.apache.archiva.redback.rest.api.services.v2.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="org.apache.archiva.redback.rest.services" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />

View File

@ -2,12 +2,6 @@
<configuration default="false" name="V2 AuthenticationServiceTest" type="JUnit" factoryName="JUnit">
<module name="redback-rest-services" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.apache.archiva.redback.rest.api.services.v2.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="org.apache.archiva.redback.rest.services.v2" />
<option name="MAIN_CLASS_NAME" value="org.apache.archiva.redback.rest.services.v2.AuthenticationServiceTest" />
<option name="METHOD_NAME" value="" />

View File

@ -2,12 +2,6 @@
<configuration default="false" name="All V2 Rest Services" type="JUnit" factoryName="JUnit">
<module name="redback-rest-services" />
<useClassPathOnly />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="org.apache.archiva.redback.rest.api.services.v2.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<option name="PACKAGE_NAME" value="org.apache.archiva.redback.rest.services.v2" />
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />

View File

@ -341,6 +341,11 @@
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
</dependency>
<dependency>
<groupId>org.apache.archiva.components</groupId>
<artifactId>archiva-components-rest-util</artifactId>
<version>${archiva.comp.version}</version>
</dependency>
<dependency>
<groupId>org.apache.archiva.components.cache</groupId>
<artifactId>archiva-components-spring-cache-api</artifactId>

View File

@ -32,7 +32,8 @@
<properties>
<site.staging.base>${project.parent.parent.parent.basedir}</site.staging.base>
<enunciate.docsDir>${project.build.outputDirectory}/rest-docs-redback-rest-api</enunciate.docsDir>
<openapi.config.file>${project.basedir}/src/main/resources/redback/openapi-configuration.yaml</openapi.config.file>
<openapi.prefix>redback</openapi.prefix>
</properties>
<dependencies>
@ -52,7 +53,10 @@
<groupId>org.apache.archiva.redback</groupId>
<artifactId>redback-rbac-model</artifactId>
</dependency>
<dependency>
<groupId>org.apache.archiva.components</groupId>
<artifactId>archiva-components-rest-util</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>

View File

@ -19,6 +19,7 @@ package org.apache.archiva.redback.rest.api.model;
*/
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.archiva.redback.rest.api.model.v2.GrantType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

View File

@ -1,4 +1,4 @@
package org.apache.archiva.redback.rest.api.model;
package org.apache.archiva.redback.rest.api.model.v2;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@ -10,7 +10,6 @@ package org.apache.archiva.redback.rest.api.model;
* 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

View File

@ -17,7 +17,6 @@ package org.apache.archiva.redback.rest.api.model.v2;/*
*/
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.archiva.redback.rest.api.model.GrantType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

View File

@ -19,7 +19,6 @@ package org.apache.archiva.redback.rest.api.model.v2;
*/
import io.swagger.v3.oas.annotations.media.Schema;
import org.apache.archiva.redback.rest.api.model.GrantType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

View File

@ -25,12 +25,11 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
import org.apache.archiva.redback.rest.api.Constants;
import org.apache.archiva.redback.rest.api.model.ActionStatus;
import org.apache.archiva.redback.rest.api.model.v2.Group;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.GroupMapping;
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;

View File

@ -26,10 +26,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
import org.apache.archiva.redback.rest.api.model.RedbackRestError;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.Role;
import org.apache.archiva.redback.rest.api.model.v2.RoleInfo;
import org.apache.archiva.redback.rest.api.model.v2.RoleTemplate;

View File

@ -28,6 +28,7 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.archiva.components.rest.model.PagedResult;
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;
@ -36,7 +37,6 @@ import org.apache.archiva.redback.rest.api.model.RedbackRestError;
import org.apache.archiva.redback.rest.api.model.v2.PasswordChange;
import org.apache.archiva.redback.rest.api.model.v2.RoleTree;
import org.apache.archiva.redback.rest.api.model.v2.AvailabilityStatus;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.Permission;
import org.apache.archiva.redback.rest.api.model.v2.PingResult;
import org.apache.archiva.redback.rest.api.model.v2.RegistrationKey;

View File

@ -18,13 +18,14 @@ package org.apache.archiva.redback.rest.services.v2;
* under the License.
*/
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.components.rest.util.QueryHelper;
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.rbac.Role;
import org.apache.archiva.redback.rest.api.MessageKeys;
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
import org.apache.archiva.redback.rest.api.model.v2.BaseUserInfo;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.RoleInfo;
import org.apache.archiva.redback.rest.api.model.v2.UserInfo;
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;

View File

@ -31,7 +31,7 @@ import org.apache.archiva.redback.policy.AccountLockedException;
import org.apache.archiva.redback.policy.MustChangePasswordException;
import org.apache.archiva.redback.rest.api.MessageKeys;
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
import org.apache.archiva.redback.rest.api.model.GrantType;
import org.apache.archiva.redback.rest.api.model.v2.GrantType;
import org.apache.archiva.redback.rest.api.model.v2.PingResult;
import org.apache.archiva.redback.rest.api.model.v2.TokenRefreshRequest;
import org.apache.archiva.redback.rest.api.model.v2.TokenRequest;

View File

@ -18,6 +18,7 @@ package org.apache.archiva.redback.rest.services.v2;
* under the License.
*/
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.common.ldap.MappingException;
import org.apache.archiva.redback.common.ldap.ObjectNotFoundException;
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
@ -30,7 +31,6 @@ import org.apache.archiva.redback.rest.api.MessageKeys;
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
import org.apache.archiva.redback.rest.api.model.v2.Group;
import org.apache.archiva.redback.rest.api.model.v2.GroupMapping;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;
import org.apache.archiva.redback.rest.api.services.v2.GroupService;
import org.slf4j.Logger;

View File

@ -18,13 +18,14 @@ package org.apache.archiva.redback.rest.services.v2;
* under the License.
*/
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.components.rest.util.QueryHelper;
import org.apache.archiva.components.rest.util.RestUtil;
import org.apache.archiva.redback.rbac.RBACManager;
import org.apache.archiva.redback.rbac.RbacManagerException;
import org.apache.archiva.redback.rbac.RbacObjectNotFoundException;
import org.apache.archiva.redback.rest.api.MessageKeys;
import org.apache.archiva.redback.rest.api.Util;
import org.apache.archiva.redback.rest.api.model.ErrorMessage;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.Role;
import org.apache.archiva.redback.rest.api.model.v2.RoleInfo;
import org.apache.archiva.redback.rest.api.model.v2.RoleTemplate;
@ -432,7 +433,7 @@ public class DefaultRoleService extends BaseRedbackService
String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order ) throws RedbackServiceException
{
boolean ascending = isAscending( order );
boolean recursePresent = Util.isFlagSet( uriInfo, "recurse" );
boolean recursePresent = RestUtil.isFlagSet( uriInfo, "recurse" );
boolean parentsOnly = "parentsOnly".equals( recurse );
try
{
@ -454,7 +455,7 @@ public class DefaultRoleService extends BaseRedbackService
public PagedResult<UserInfo> getUnassignedUsers( String roleId, String recurse, String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order ) throws RedbackServiceException
{
boolean ascending = isAscending( order );
boolean recursePresent = Util.isFlagSet( uriInfo, "recurse" );
boolean recursePresent = RestUtil.isFlagSet( uriInfo, "recurse" );
boolean parentsOnly = "parentsOnly".equals( recurse );
try
{

View File

@ -21,6 +21,7 @@ package org.apache.archiva.redback.rest.services.v2;
import net.sf.ehcache.CacheManager;
import org.apache.archiva.components.cache.Cache;
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.authentication.AuthenticationException;
import org.apache.archiva.redback.authentication.Token;
import org.apache.archiva.redback.authentication.TokenBasedAuthenticationDataSource;
@ -50,7 +51,6 @@ import org.apache.archiva.redback.rest.api.model.v2.Application;
import org.apache.archiva.redback.rest.api.model.v2.AvailabilityStatus;
import org.apache.archiva.redback.rest.api.model.v2.BaseRoleInfo;
import org.apache.archiva.redback.rest.api.model.v2.Operation;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.PasswordChange;
import org.apache.archiva.redback.rest.api.model.v2.Permission;
import org.apache.archiva.redback.rest.api.model.v2.PingResult;

View File

@ -19,7 +19,7 @@ package org.apache.archiva.redback.rest.services.v2;
*/
import org.apache.archiva.redback.integration.security.role.RedbackRoleConstants;
import org.apache.archiva.redback.rest.api.model.GrantType;
import org.apache.archiva.redback.rest.api.model.v2.GrantType;
import org.apache.archiva.redback.rest.api.model.v2.TokenRequest;
import org.apache.archiva.redback.rest.api.model.v2.TokenResponse;
import org.apache.archiva.redback.rest.api.services.RedbackServiceException;

View File

@ -19,10 +19,8 @@ package org.apache.archiva.redback.rest.services.v2;
*/
import io.restassured.response.Response;
import io.restassured.response.ResponseBodyExtractionOptions;
import org.apache.archiva.redback.rest.api.model.User;
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.BaseUserInfo;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.Permission;
import org.apache.archiva.redback.rest.api.model.v2.RoleInfo;
import org.apache.archiva.redback.rest.api.model.v2.RoleTemplate;
@ -44,7 +42,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static io.restassured.RestAssured.given;
import static io.restassured.http.ContentType.JSON;

View File

@ -19,10 +19,10 @@ package org.apache.archiva.redback.rest.services.v2;
* under the License.
*/
import org.apache.archiva.redback.rest.api.model.GrantType;
import org.apache.archiva.components.rest.model.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.GrantType;
import org.apache.archiva.redback.rest.api.model.v2.Operation;
import org.apache.archiva.redback.rest.api.model.v2.SelfUserData;
import org.apache.archiva.redback.rest.api.model.v2.PagedResult;
import org.apache.archiva.redback.rest.api.model.v2.Permission;
import org.apache.archiva.redback.rest.api.model.v2.PingResult;
import org.apache.archiva.redback.rest.api.model.v2.TokenRequest;
@ -124,7 +124,7 @@ public class UserServiceTest
{
String adminHeader = getAdminAuthzHeader( );
UserService userService = getUserService( adminHeader );
PagedResult<org.apache.archiva.redback.rest.api.model.v2.UserInfo> users = userService.getUsers( "", 0, Integer.MAX_VALUE, Collections.emptyList(), "asc" );
PagedResult<UserInfo> users = userService.getUsers( "", 0, Integer.MAX_VALUE, Collections.emptyList(), "asc" );
assertNotNull( users );
assertFalse( users.getData().isEmpty( ) );
}