Adapting to changes in parent pom and redback

This commit is contained in:
Martin Stockhammer 2020-06-30 21:20:29 +02:00
parent bef02ef5b8
commit 509aad470c
8 changed files with 77 additions and 148 deletions

View File

@ -31,8 +31,6 @@
<properties> <properties>
<enunciate.docsDir>${project.build.outputDirectory}/rest-docs-archiva-rest-api</enunciate.docsDir> <enunciate.docsDir>${project.build.outputDirectory}/rest-docs-archiva-rest-api</enunciate.docsDir>
<site.staging.base>${project.parent.parent.parent.basedir}</site.staging.base> <site.staging.base>${project.parent.parent.parent.basedir}</site.staging.base>
<swagger-maven-plugin-version>2.1.2</swagger-maven-plugin-version>
<io.swagger.version>2.1.2</io.swagger.version>
</properties> </properties>
<dependencies> <dependencies>
@ -79,46 +77,6 @@
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId> <artifactId>javax.ws.rs-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<scope>compile</scope>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
</dependency>
</dependencies> </dependencies>
@ -135,95 +93,6 @@
</excludes> </excludes>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>bind-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>${swagger-maven-plugin-version}</version>
<configuration>
<outputFileName>openapi</outputFileName>
<outputPath>${project.build.directory}/generated</outputPath>
<outputFormat>JSONANDYAML</outputFormat>
<resourcePackages>
<package>org.apache.archiva.rest.api</package>
</resourcePackages>
<prettyPrint>TRUE</prettyPrint>
<configurationFilePath>${project.basedir}/src/main/resources/openapi-configuration.yaml</configurationFilePath>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>resolve</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.swagger.codegen.v3</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>3.0.20</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.directory}/generated/openapi.yaml</inputSpec>
<language>html</language>
<output>${project.build.directory}/generated-sources</output>
<ignoreFileOverride>${project.basedir}/src/main/resources/openapi-codegen-ignore</ignoreFileOverride>
<templateDirectory>${project.basedir}/src/main/resources/templates</templateDirectory>
<supportingFilesToGenerate>index.html,index2.html</supportingFilesToGenerate>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>site</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/site/openapi/</outputDirectory>
<resources>
<resource>
<directory>${project.build.directory}/generated</directory> <!-- source directory -->
<filtering>false</filtering>
<include>openapi.json</include>
<include>openapi.yaml</include>
</resource>
<resource>
<directory>${project.build.directory}/generated-sources/</directory>
<filtering>false</filtering>
<include>**/*</include>
<exclude>.swagger-codegen/**</exclude>
<exclude>.swagger-codegen-ignore</exclude>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins> </plugins>
</build> </build>

View File

@ -18,7 +18,6 @@ package org.apache.archiva.rest.api.model;
* under the License. * under the License.
*/ */
import javax.swing.*;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
/** /**
@ -32,6 +31,9 @@ public class ActionStatus
public static final ActionStatus SUCCESS = new ActionStatus( true ); public static final ActionStatus SUCCESS = new ActionStatus( true );
public static final ActionStatus FAIL = new ActionStatus( false ); public static final ActionStatus FAIL = new ActionStatus( false );
public static ActionStatus FROM(boolean status) {
return status ? SUCCESS : FAIL;
}
public ActionStatus() { public ActionStatus() {
@ -51,5 +53,9 @@ public class ActionStatus
this.success = success; this.success = success;
} }
@Override
public String toString( )
{
return Boolean.toString( success );
}
} }

View File

@ -439,6 +439,12 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Needed for JDK >= 9 --> <!-- Needed for JDK >= 9 -->
<dependency> <dependency>

View File

@ -21,11 +21,13 @@ package org.apache.archiva.rest.services.interceptors;
import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
/** /**
* class to setup Jackson Json configuration * class to setup Jackson Json configuration
@ -39,9 +41,12 @@ public class JacksonJsonConfigurator
private Logger log = LoggerFactory.getLogger( getClass() ); private Logger log = LoggerFactory.getLogger( getClass() );
@Inject @Inject
public JacksonJsonConfigurator( ObjectMapper objectMapper ) public JacksonJsonConfigurator( @Named( "redbackJacksonJsonMapper" ) ObjectMapper objectMapper,
@Named( "redbackJacksonXMLMapper" ) XmlMapper xmlMapper )
{ {
log.info( "configure jackson ObjectMapper" ); log.info( "configure jackson ObjectMapper" );
objectMapper.configure( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false ); objectMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
xmlMapper.disable( DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES );
} }
} }

View File

@ -39,17 +39,23 @@
<context:component-scan <context:component-scan
base-package="org.apache.archiva.rest.services,org.apache.archiva.redback.rest.services"/> base-package="org.apache.archiva.rest.services,org.apache.archiva.redback.rest.services"/>
<bean id="jsonProvider" class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider">
<bean id="eventSender" class="org.apache.cxf.ext.logging.slf4j.Slf4jVerboseEventSender"> <property name="mapper" ref="redbackJacksonJsonMapper"/>
<property name="loggingLevel" value="DEBUG" />
</bean> </bean>
<bean id="xmlProvider" class="com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider">
<property name="mapper" ref="redbackJacksonXMLMapper"/>
</bean>
<bean id="redbackJacksonJsonMapper" class="com.fasterxml.jackson.databind.ObjectMapper" />
<bean id="redbackJacksonXMLMapper" class="com.fasterxml.jackson.dataformat.xml.XmlMapper" />
<jaxrs:server id="archivaServices" address="/archivaServices" > <jaxrs:server id="archivaServices" address="/archivaServices" >
<jaxrs:providers> <jaxrs:providers>
<bean class="com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider"/> <ref bean="jsonProvider" />
<bean class="com.fasterxml.jackson.jaxrs.xml.JacksonJaxbXMLProvider"/> <ref bean="xmlProvider" />
<ref bean="authenticationInterceptor#rest"/> <ref bean="authenticationInterceptor#rest"/>
<ref bean="permissionInterceptor#rest"/> <ref bean="permissionInterceptor#rest"/>
<ref bean="requestValidationInterceptor#rest" /> <ref bean="requestValidationInterceptor#rest" />
@ -78,12 +84,6 @@
<ref bean="redbackRuntimeConfigurationService#rest"/> <ref bean="redbackRuntimeConfigurationService#rest"/>
</jaxrs:serviceBeans> </jaxrs:serviceBeans>
<jaxrs:features>
<bean class="org.apache.cxf.ext.logging.LoggingFeature">
<property name="sender" ref="eventSender"/>
</bean>
</jaxrs:features>
</jaxrs:server> </jaxrs:server>

View File

@ -168,7 +168,7 @@ public class DownloadArtifactsTest
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
"internal" ) ) "internal" ).isExists() )
{ {
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" ); roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, "internal" );
} }

View File

@ -131,7 +131,7 @@ public class DownloadSnapshotTest
RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader ); RoleManagementService roleManagementService = getRoleManagementService( authorizationHeader );
if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, if ( !roleManagementService.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER,
id ) ) id ).isExists() )
{ {
roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id ); roleManagementService.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, id );
} }

43
pom.xml
View File

@ -165,6 +165,12 @@
<artifactId>javax.ws.rs-api</artifactId> <artifactId>javax.ws.rs-api</artifactId>
<version>${javax.jaxrs.version}</version> <version>${javax.jaxrs.version}</version>
</dependency> </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${javax.validation.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
@ -1632,6 +1638,43 @@
<version>${cxf.version}</version> <version>${cxf.version}</version>
</dependency> </dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
<scope>compile</scope>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-jaxrs2</artifactId>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${io.swagger.version}</version>
<exclusions>
<exclusion>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>