You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ma...@apache.org on 2021/01/01 18:07:41 UTC

[archiva-redback-core] branch master updated (f756869 -> d4b3b08)

This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/archiva-redback-core.git.


    from f756869  Changing password validation error results
     new 52aeae3  Moving GrantType to v2 package
     new ca8bf90  Using different OpenAPI features for redback and archiva
     new d4b3b08  Moving rest utility classes to components

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 idea.run.configuration/All Rest Services.run.xml   |   6 -
 .../V2 AuthenticationServiceTest.run.xml           |   6 -
 ...st.services.v2 in redback-rest-services.run.xml |   6 -
 pom.xml                                            |   5 +
 .../redback-rest/redback-rest-api/pom.xml          |   8 +-
 .../org/apache/archiva/redback/rest/api/Util.java  |  59 --------
 .../redback/rest/api/model/PaginationInfo.java     |  83 ----------
 .../redback/rest/api/model/TokenRequest.java       |   1 +
 .../redback/rest/api/model/{ => v2}/GrantType.java |   8 +-
 .../redback/rest/api/model/v2/PagedResult.java     |  72 ---------
 .../rest/api/model/v2/TokenRefreshRequest.java     |   1 -
 .../redback/rest/api/model/v2/TokenRequest.java    |   1 -
 .../redback/rest/api/services/v2/GroupService.java |   3 +-
 .../redback/rest/api/services/v2/RoleService.java  |   2 +-
 .../redback/rest/api/services/v2/UserService.java  |   2 +-
 .../{ => redback}/openapi-configuration.yaml       |   0
 .../rest/services/v2/BaseRedbackService.java       |   3 +-
 .../services/v2/DefaultAuthenticationService.java  |   2 +-
 .../rest/services/v2/DefaultGroupService.java      |   2 +-
 .../rest/services/v2/DefaultRoleService.java       |   9 +-
 .../rest/services/v2/DefaultUserService.java       |   2 +-
 .../redback/rest/services/v2/PagingHelper.java     |  46 ------
 .../redback/rest/services/v2/QueryHelper.java      | 168 ---------------------
 .../src/main/resources/META-INF/spring-context.xml |  13 +-
 .../services/v2/AuthenticationServiceTest.java     |   2 +-
 .../rest/services/v2/NativeRoleServiceTest.java    |   5 +-
 .../redback/rest/services/v2/UserServiceTest.java  |   6 +-
 .../src/test/resources/spring-context.xml          |   4 -
 28 files changed, 40 insertions(+), 485 deletions(-)
 delete mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/Util.java
 delete mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PaginationInfo.java
 rename redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/{ => v2}/GrantType.java (87%)
 delete mode 100644 redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/PagedResult.java
 rename redback-integrations/redback-rest/redback-rest-api/src/main/resources/{ => redback}/openapi-configuration.yaml (100%)
 delete mode 100644 redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/PagingHelper.java
 delete mode 100644 redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/QueryHelper.java


[archiva-redback-core] 02/03: Using different OpenAPI features for redback and archiva

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva-redback-core.git

commit ca8bf90050e875fc7b1a1392d3aea0b9cbcae634
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Fri Jan 1 18:59:41 2021 +0100

    Using different OpenAPI features for redback and archiva
---
 .../org/apache/archiva/redback/rest/api/Util.java  |  59 --------
 .../redback/rest/api/model/PaginationInfo.java     |  83 ----------
 .../redback/rest/api/model/v2/PagedResult.java     |  72 ---------
 .../redback/rest/services/v2/PagingHelper.java     |  46 ------
 .../redback/rest/services/v2/QueryHelper.java      | 168 ---------------------
 .../src/main/resources/META-INF/spring-context.xml |  13 +-
 .../src/test/resources/spring-context.xml          |   4 -
 7 files changed, 8 insertions(+), 437 deletions(-)

diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/Util.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/Util.java
deleted file mode 100644
index db4d4f9..0000000
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/Util.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.apache.archiva.redback.rest.api;/*
- * 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.commons.lang3.StringUtils;
-
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.UriInfo;
-
-/**
- * Central utility class that may be used by service implementations.
- *
- * @author Martin Stockhammer <ma...@apache.org>
- */
-public class Util
-{
-    /**
-     * Returns <code>false</code>, if the given parameter is not present in the given uriInfo, or is present and set to 'false' or '0'.
-     * In all other cases it returns <code>true</code>.
-     *
-     * This means you can activate a flag by setting '?param', '?param=true', '?param=1', ...
-     * It is deactivated, if the parameter is absent, or '?param=false', or '?param=0'
-     *
-     * @param uriInfo the uriInfo context instance, that is used to check for the parameter
-     * @param queryParameterName the query parameter name
-     * @return
-     */
-    public static boolean isFlagSet( final UriInfo uriInfo, final String queryParameterName) {
-        MultivaluedMap<String, String> params = uriInfo.getQueryParameters( );
-        if (!params.containsKey( queryParameterName )) {
-            return false;
-        }
-        // parameter is available
-        String value = params.getFirst( queryParameterName );
-        // if its available but without a value it is flagged as present
-        if (StringUtils.isEmpty( value )) {
-            return true;
-        }
-        // if it has a value, we check for false values:
-        if ("false".equalsIgnoreCase( value ) || "0".equalsIgnoreCase( value )) {
-            return false;
-        }
-        return true;
-    }
-}
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PaginationInfo.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PaginationInfo.java
deleted file mode 100644
index 4cd0fd8..0000000
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/PaginationInfo.java
+++ /dev/null
@@ -1,83 +0,0 @@
-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 io.swagger.v3.oas.annotations.media.Schema;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlRootElement;
-
-/**
- *
- * Informational attributes for pagination.
- *
- * @author Martin Stockhammer <ma...@apache.org>
- */
-@XmlRootElement(name="pagination")
-@Schema(name="PaginationInfo", description = "Contains paging information (limit, offset, totalCount)")
-public class PaginationInfo
-{
-    long totalCount;
-    long offset;
-    long limit;
-
-    public PaginationInfo() {
-
-    }
-
-    public PaginationInfo( long totalCount, long offset, long limit )
-    {
-        this.totalCount = totalCount;
-        this.offset = offset;
-        this.limit = limit;
-    }
-
-    @Schema(description = "The total number of data available.")
-    public long getTotalCount( )
-    {
-        return totalCount;
-    }
-
-    public void setTotalCount( long totalCount )
-    {
-        this.totalCount = totalCount;
-    }
-
-    @Schema(description = "The offset of the first element of the returned dataset.")
-    public long getOffset( )
-    {
-        return offset;
-    }
-
-    public void setOffset( long offset )
-    {
-        this.offset = offset;
-    }
-
-    @Schema(description = "The maximum number of elements returned per page.")
-    public long getLimit( )
-    {
-        return limit;
-    }
-
-    public void setLimit( long limit )
-    {
-        this.limit = limit;
-    }
-}
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/PagedResult.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/PagedResult.java
deleted file mode 100644
index 1aa998f..0000000
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/PagedResult.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package org.apache.archiva.redback.rest.api.model.v2;
-
-/*
- * 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 io.swagger.v3.oas.annotations.media.Schema;
-import org.apache.archiva.redback.rest.api.model.PaginationInfo;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import java.util.List;
-
-/**
- * A Paged result puts the data into an envelope
- * @author Martin Stockhammer <ma...@apache.org>
- */
-@XmlRootElement(name="pagedResult")
-@Schema(name = "PagedResult", description = "Contains paged data. Pages are defined by limit and offset.")
-public class PagedResult<T>
-{
-    PaginationInfo pagination;
-    List<T> data;
-
-    public PagedResult() {
-
-    }
-
-    public PagedResult( int totalCount, int offset, int limit, List<T> data ) {
-        this.data = data;
-        this.pagination = new PaginationInfo( totalCount, offset, limit );
-    }
-
-    public static final <T> PagedResult<T> of(int totalSize, int offset, int limit, List<T> element) {
-        return new PagedResult( totalSize, offset, limit, element);
-    }
-
-    @Schema(description = "This is the payload of the paged data. The type of data depends on the REST method. ")
-    public List<T> getData( )
-    {
-        return data;
-    }
-
-    public void setData( List<T> data )
-    {
-        this.data = data;
-    }
-
-    @Schema(description = "The pagination information")
-    public PaginationInfo getPagination( )
-    {
-        return pagination;
-    }
-
-    public void setPagination( PaginationInfo pagination )
-    {
-        this.pagination = pagination;
-    }
-}
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/PagingHelper.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/PagingHelper.java
deleted file mode 100644
index 1fa2756..0000000
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/PagingHelper.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package org.apache.archiva.redback.rest.services.v2;
-
-/*
- * 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.rest.api.model.v2.PagedResult;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * Helper class for creating paged results.
- *
- * @author Martin Stockhammer <ma...@apache.org>
- */
-public class PagingHelper
-{
-    public static <T> PagedResult<T> getResultFromList( int offset, int limit, List<T> data) {
-        if (offset>=data.size()) {
-            return new PagedResult<>( data.size( ), offset, limit, Collections.emptyList( ) );
-        }
-        int lastIndex = getLastIndex( offset, limit, data.size( ) );
-        return new PagedResult<>( data.size(), offset, limit, data.subList( offset, lastIndex ) );
-    }
-
-    public static int getLastIndex(int offset, int limit, int listSize) {
-        return Math.min( Math.max( 0, offset + limit ), listSize );
-    }
-
-
-}
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/QueryHelper.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/QueryHelper.java
deleted file mode 100644
index ba417aa..0000000
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/QueryHelper.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.apache.archiva.redback.rest.services.v2;/*
- * 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.commons.lang3.StringUtils;
-
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.function.BiPredicate;
-import java.util.function.Function;
-import java.util.function.Predicate;
-
-/**
- *
- * Helper class that returns combined filter and comparison objects for ordering.
- *
- * The query term may be consist of simple query terms separated by whitespace or attribute queries
- * in the form <code>attribute:query</code>, which means only the attribute is searched for the query string.
- * <br />
- * Example:
- * <dl>
- *     <dt>`user1 test`</dt>
- *     <dd>
- * searches for the tokens user1 and test in the default attributes.
- * </dd>
- * <dt>`user1 name:test`</dt>
- * <dd>searches for the token user1 in the default attributes and for the token test in the attribute name.</dd>
- * </dl>
- *
- *
- * @since 3.0
- * @author Martin Stockhammer <ma...@apache.org>
- */
-public class QueryHelper<T>
-{
-
-    private final Map<String, BiPredicate<String, T>> FILTER_MAP;
-    private final Map<String, Comparator<T>> ORDER_MAP;
-    private final String[] DEFAULT_SEARCH_FIELDS;
-    private final Predicate<T> DEFAULT_FILTER = ( T att ) -> false;
-
-
-    /**
-     * Creates a new query helper with the given filters and comparators.
-     *
-     * @param filterMap a map of filters, where the key is the attribute name and the value is a predicate that matches
-     *                  the filter value and the object instance.
-     * @param orderMap a map of comparators, where key is the attribute name and the value is a comparator for the given
-     *                 object instance
-     * @param defaultSearchFields A array of attribute names, that are used as default search fields.
-     */
-    public QueryHelper(Map<String, BiPredicate<String, T>> filterMap, Map<String, Comparator<T>> orderMap,
-                       String[] defaultSearchFields)
-    {
-        this.FILTER_MAP = filterMap;
-        this.DEFAULT_SEARCH_FIELDS = defaultSearchFields;
-        this.ORDER_MAP = new HashMap<>( orderMap );
-    }
-
-    public <U extends Comparable<? super U>> void addNullsafeFieldComparator( String fieldName, Function<? super T, U> keyExtractor) {
-        ORDER_MAP.put( fieldName, Comparator.comparing( keyExtractor, Comparator.nullsLast( Comparator.naturalOrder( ) ) ) );
-    }
-
-    public void addStringFilter(String attribute, Function<? super T, String> keyExtractor) {
-        this.FILTER_MAP.put( attribute, ( String q, T r ) -> StringUtils.containsIgnoreCase( keyExtractor.apply( r ), q ) );
-    }
-
-    public void addBooleanFilter(String attribute, Function<? super T, Boolean> keyExtractor) {
-        this.FILTER_MAP.put( attribute, ( String q, T r ) -> Boolean.valueOf( q ) == keyExtractor.apply( r ) );
-    }
-
-    /**
-     * Get the comparator for a specific attribute.
-     * @param attributeName the name of the attribute.
-     * @return
-     */
-    Comparator<T> getAttributeComparator( String attributeName )
-    {
-        return ORDER_MAP.get( attributeName );
-    }
-
-    /**
-     * Get the combined order for the given attributes in the given order.
-     *
-     * @param orderBy the attributes to compare. The first attribute in the list will be used first for comparing.
-     * @param ascending
-     * @return
-     */
-    Comparator<T> getComparator( List<String> orderBy, boolean ascending )
-    {
-        if ( ascending )
-        {
-            return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ) ).filter( Objects::nonNull )
-                .reduce( Comparator::thenComparing )
-                .orElseThrow( () -> new IllegalArgumentException( "No attribute ordering found" ) );
-        }
-
-        else
-        {
-            return orderBy.stream( ).map( ( String name ) -> getAttributeComparator( name ) == null ? null : getAttributeComparator( name )
-                .reversed( ) ).filter( Objects::nonNull ).reduce( Comparator::thenComparing )
-                .orElseThrow( () -> new IllegalArgumentException( "No attribute ordering found" ) );
-        }
-    }
-
-    /**
-     * Returns a query filter for a specific attribute and query token.
-     * @param attribute the attribute name to filter for.
-     * @param queryToken the search token.
-     * @return The predicate used to filter the token
-     */
-    Predicate<T> getAttributeQueryFilter( final String attribute, final String queryToken )
-    {
-        if ( FILTER_MAP.containsKey( attribute ) )
-        {
-            return ( T u ) -> FILTER_MAP.get( attribute ).test( queryToken, u );
-        }
-        else
-        {
-            return DEFAULT_FILTER;
-        }
-    }
-
-    /**
-     * Returns the combined query filter for the given query terms.
-     * The query terms may be either simple strings separated by whitespace or use the
-     * <code>attribute:query</code> syntax, that searches only the attribute for the query term.
-     * @param queryTerms the query string
-     * @return the combined query filter
-     */
-    Predicate<T> getQueryFilter( String queryTerms )
-    {
-        return Arrays.stream( queryTerms.split( "\\s+" ) )
-            .map( s -> {
-                    if ( s.contains( ":" ) )
-                    {
-                        String attr = StringUtils.substringBefore( s, ":" );
-                        String term = StringUtils.substringAfter( s, ":" );
-                        return getAttributeQueryFilter( attr, term );
-                    }
-                    else
-                    {
-                        return Arrays.stream( DEFAULT_SEARCH_FIELDS )
-                            .map( att -> getAttributeQueryFilter( att, s ) ).reduce( Predicate::or ).get( );
-                    }
-                }
-            ).reduce( Predicate::or ).get( );
-    }
-
-}
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 ff90b95..104d858 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
@@ -61,9 +61,12 @@
 
 
   <!-- CXF OpenApiFeature -->
-  <bean id="openApiFeature" class="org.apache.cxf.jaxrs.openapi.OpenApiFeature">
-    <property name="scanKnownConfigLocations" value="true"/>
-    <!-- customize some of the properties -->
+  <bean id="redbackOpenApiFeature" class="org.apache.cxf.jaxrs.openapi.OpenApiFeature">
+    <property name="scanKnownConfigLocations" value="false"/>
+    <property name="configLocation" value="redback/openapi-configuration.yaml"/>
+    <property name="scan" value="false"/>
+    <property name="useContextBasedConfig" value="true"/>
+    <!-- <property name="scannerClass" value="io.swagger.v3.jaxrs2.integration.JaxrsApplicationScanner"/> -->
   </bean>
 
   <jaxrs:server name="redbackServices" address="/redbackServices">
@@ -89,7 +92,7 @@
     </jaxrs:providers>
    </jaxrs:server>
 
-  <jaxrs:server address="/v2/redback">
+  <jaxrs:server name="v2.redback" address="/v2/redback">
     <jaxrs:serviceBeans>
       <ref bean="v2.userService#rest"/>
       <ref bean="v2.authenticationService#rest"/>
@@ -109,7 +112,7 @@
       <ref bean="threadLocalUserCleaner#rest"/>
     </jaxrs:providers>
     <jaxrs:features>
-      <ref bean="openApiFeature" />
+      <ref bean="redbackOpenApiFeature" />
     </jaxrs:features>
   </jaxrs:server>
 
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml
index a9f90c8..1da544b 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml
+++ b/redback-integrations/redback-rest/redback-rest-services/src/test/resources/spring-context.xml
@@ -48,11 +48,7 @@
   </bean>
 
   <alias name="authenticator#jwt" alias="jwtAuthenticator#default" />
-
-
-
   <alias name="authorizer#rbac" alias="authorizer#default"/>
-
   <alias name="userManager#configurable" alias="userManager#default"/>
 
   <!--


[archiva-redback-core] 03/03: Moving rest utility classes to components

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva-redback-core.git

commit d4b3b087fd1fb01d41b2d85b061cf5999fd2a1d8
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Fri Jan 1 19:00:03 2021 +0100

    Moving rest utility classes to components
---
 idea.run.configuration/All Rest Services.run.xml                 | 6 ------
 idea.run.configuration/V2 AuthenticationServiceTest.run.xml      | 6 ------
 ...iva.redback.rest.services.v2 in redback-rest-services.run.xml | 6 ------
 pom.xml                                                          | 5 +++++
 redback-integrations/redback-rest/redback-rest-api/pom.xml       | 8 ++++++--
 .../org/apache/archiva/redback/rest/api/model/TokenRequest.java  | 1 +
 .../org/apache/archiva/redback/rest/api/model/v2/GrantType.java  | 3 +--
 .../archiva/redback/rest/api/model/v2/TokenRefreshRequest.java   | 1 -
 .../apache/archiva/redback/rest/api/model/v2/TokenRequest.java   | 1 -
 .../archiva/redback/rest/api/services/v2/GroupService.java       | 3 +--
 .../apache/archiva/redback/rest/api/services/v2/RoleService.java | 2 +-
 .../apache/archiva/redback/rest/api/services/v2/UserService.java | 2 +-
 .../archiva/redback/rest/services/v2/BaseRedbackService.java     | 3 ++-
 .../redback/rest/services/v2/DefaultAuthenticationService.java   | 2 +-
 .../archiva/redback/rest/services/v2/DefaultGroupService.java    | 2 +-
 .../archiva/redback/rest/services/v2/DefaultRoleService.java     | 9 +++++----
 .../archiva/redback/rest/services/v2/DefaultUserService.java     | 2 +-
 .../redback/rest/services/v2/AuthenticationServiceTest.java      | 2 +-
 .../archiva/redback/rest/services/v2/NativeRoleServiceTest.java  | 5 +----
 .../apache/archiva/redback/rest/services/v2/UserServiceTest.java | 6 +++---
 20 files changed, 31 insertions(+), 44 deletions(-)

diff --git a/idea.run.configuration/All Rest Services.run.xml b/idea.run.configuration/All Rest Services.run.xml
index 010200a..300691f 100644
--- a/idea.run.configuration/All Rest Services.run.xml	
+++ b/idea.run.configuration/All Rest Services.run.xml	
@@ -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="" />
diff --git a/idea.run.configuration/V2 AuthenticationServiceTest.run.xml b/idea.run.configuration/V2 AuthenticationServiceTest.run.xml
index 116e14c..c177bd3 100644
--- a/idea.run.configuration/V2 AuthenticationServiceTest.run.xml	
+++ b/idea.run.configuration/V2 AuthenticationServiceTest.run.xml	
@@ -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="" />
diff --git a/idea.run.configuration/org.apache.archiva.redback.rest.services.v2 in redback-rest-services.run.xml b/idea.run.configuration/org.apache.archiva.redback.rest.services.v2 in redback-rest-services.run.xml
index f4b1844..b336afe 100644
--- a/idea.run.configuration/org.apache.archiva.redback.rest.services.v2 in redback-rest-services.run.xml	
+++ b/idea.run.configuration/org.apache.archiva.redback.rest.services.v2 in redback-rest-services.run.xml	
@@ -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="" />
diff --git a/pom.xml b/pom.xml
index 7798486..8bc9601 100644
--- a/pom.xml
+++ b/pom.xml
@@ -342,6 +342,11 @@
         <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>
         <version>${archiva.comp.version}</version>
diff --git a/redback-integrations/redback-rest/redback-rest-api/pom.xml b/redback-integrations/redback-rest/redback-rest-api/pom.xml
index 6779dea..2b30768 100644
--- a/redback-integrations/redback-rest/redback-rest-api/pom.xml
+++ b/redback-integrations/redback-rest/redback-rest-api/pom.xml
@@ -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>
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/TokenRequest.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/TokenRequest.java
index 3df19b2..cd21d6d 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/TokenRequest.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/TokenRequest.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
index 63c362a..8b0cb79 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
@@ -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
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRefreshRequest.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRefreshRequest.java
index a474303..98137b3 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRefreshRequest.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRefreshRequest.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRequest.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRequest.java
index 73f6ad9..7fc208d 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRequest.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/TokenRequest.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/GroupService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/GroupService.java
index 86b87af..1797150 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/GroupService.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/GroupService.java
@@ -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;
 
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/RoleService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/RoleService.java
index a8be9ff..51d8a21 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/RoleService.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/RoleService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/UserService.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/UserService.java
index 5bb4811..edd8994 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/UserService.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/services/v2/UserService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/BaseRedbackService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/BaseRedbackService.java
index 01fd95e..b22ad74 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/BaseRedbackService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/BaseRedbackService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultAuthenticationService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultAuthenticationService.java
index d68f4a2..5fbd64c 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultAuthenticationService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultAuthenticationService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultGroupService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultGroupService.java
index fb4072c..a2f3ec1 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultGroupService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultGroupService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultRoleService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultRoleService.java
index d70f556..6109bfc 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultRoleService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultRoleService.java
@@ -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
         {
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java
index c15daad..30983bb 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/main/java/org/apache/archiva/redback/rest/services/v2/DefaultUserService.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AuthenticationServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AuthenticationServiceTest.java
index 1e3d492..0baa3a3 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AuthenticationServiceTest.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/AuthenticationServiceTest.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeRoleServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeRoleServiceTest.java
index 0b6c33c..8cd8384 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeRoleServiceTest.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/NativeRoleServiceTest.java
@@ -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;
diff --git a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/UserServiceTest.java b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/UserServiceTest.java
index 0cc32b3..1f8f722 100644
--- a/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/UserServiceTest.java
+++ b/redback-integrations/redback-rest/redback-rest-services/src/test/java/org/apache/archiva/redback/rest/services/v2/UserServiceTest.java
@@ -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( ) );
     }


[archiva-redback-core] 01/03: Moving GrantType to v2 package

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

martin_s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/archiva-redback-core.git

commit 52aeae39837868bbde9415b14378a4522a7b89be
Author: Martin Stockhammer <ma...@apache.org>
AuthorDate: Thu Dec 31 15:43:49 2020 +0100

    Moving GrantType to v2 package
---
 .../apache/archiva/redback/rest/api/model/{ => v2}/GrantType.java    | 5 +----
 .../src/main/resources/{ => redback}/openapi-configuration.yaml      | 0
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/GrantType.java b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
similarity index 90%
rename from redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/GrantType.java
rename to redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
index 200dc75..63c362a 100644
--- a/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/GrantType.java
+++ b/redback-integrations/redback-rest/redback-rest-api/src/main/java/org/apache/archiva/redback/rest/api/model/v2/GrantType.java
@@ -57,9 +57,6 @@ public enum GrantType
     @Override
     public String toString( )
     {
-        final StringBuilder sb = new StringBuilder( "GrantType{" );
-        sb.append( "label='" ).append( label ).append( '\'' );
-        sb.append( '}' );
-        return sb.toString( );
+        return this.label;
     }
 }
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/redback/openapi-configuration.yaml
similarity index 100%
rename from redback-integrations/redback-rest/redback-rest-api/src/main/resources/openapi-configuration.yaml
rename to redback-integrations/redback-rest/redback-rest-api/src/main/resources/redback/openapi-configuration.yaml