From 386ca6a54bddacfb110e84b609e00ba72fbc9917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Guimar=C3=A3es?= Date: Tue, 24 May 2022 18:08:21 +0100 Subject: [PATCH] Fix CVE-2022-22965 --- pom.xml | 101 +++---- .../java/com/databasepreservation/DBVTK.java | 40 ++- .../common/api/MyApiListingResource.java | 20 -- .../common/api/RestApplication.java | 48 ---- .../common/api/RestApplicationNoSwagger.java | 108 ++++---- .../common/api/utils/ApiResponseMessage.java | 3 + .../common/api/v1/CollectionResource.java | 257 +++++++++--------- .../common/api/v1/FileResource.java | 38 +-- .../common/api/v1/SiardResource.java | 8 +- .../common/api/v1/ThemeResource.java | 18 +- .../navigation/BrowseNavigationPanel.java | 2 +- .../navigation/ValidationNavigationPanel.java | 12 +- .../IndeterminateProgressBarPanel.java | 4 +- .../progressBar/ProgressBarPanel.java | 4 +- .../validation/ValidatorPage.java | 4 +- .../table/TableAndColumnsParameters.java | 3 - .../client/services/ActivityLogService.java | 44 +-- .../services/AuthenticationService.java | 11 +- .../client/services/ClientLoggerService.java | 17 +- .../client/services/CollectionService.java | 92 +++---- .../client/services/ContextService.java | 12 +- .../client/services/DatabaseService.java | 22 +- .../common/client/services/JobService.java | 14 +- .../client/services/MigrationService.java | 33 +-- .../common/client/services/SiardService.java | 35 +-- .../CombinedSwaggerResourcesProvider.java | 40 --- .../common/server/swagger/SwaggerConfig.java | 67 ----- .../swagger/SwaggerConfigProperties.java | 102 ------- src/main/resources/application.properties | 14 +- .../resources/config/dbvtk-viewer.properties | 13 +- src/main/webapp/WEB-INF/web.xml | 2 +- 31 files changed, 447 insertions(+), 741 deletions(-) delete mode 100644 src/main/java/com/databasepreservation/common/api/MyApiListingResource.java delete mode 100644 src/main/java/com/databasepreservation/common/api/RestApplication.java delete mode 100644 src/main/java/com/databasepreservation/common/server/swagger/CombinedSwaggerResourcesProvider.java delete mode 100644 src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfig.java delete mode 100644 src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfigProperties.java diff --git a/pom.xml b/pom.xml index 04600449f..c5282440b 100644 --- a/pom.xml +++ b/pom.xml @@ -27,27 +27,19 @@ 2.9.0-jetty94 provided 2.9.10 - 3.0.2 - 2.29.1 - 1.5.20 - 2.9.2 - 2.10.5 - 2.10.5.1 - 3.6.1 - 3.5.0 - 8.4.1 - 2.2.2.RELEASE + 3.7.0 + 2.35 + 2.2.0 + 2.13.3 + 3.6.4 + 8.11.1 + 2.6.8 com.databasepreservation.desktop.Desktop com.databasepreservation.server.Server - - KEEPS-Artifacts - KEEP Artifacts-releases - https://artifactory.keep.pt/keep - github GitHub Packages @@ -66,7 +58,7 @@ org.springframework.boot spring-boot-starter-parent - 2.1.9.RELEASE + 2.6.7 @@ -116,7 +108,7 @@ org.springframework.boot spring-boot-maven-plugin - ${springboot.version} + ${version.springboot} @@ -253,7 +245,7 @@ org.springframework.boot spring-boot-maven-plugin - ${springboot.version} + ${version.springboot} -Djava.net.preferIPv4Stack=true @@ -300,7 +292,7 @@ org.springframework.boot spring-boot-maven-plugin - ${springboot.version} + ${version.springboot} -Djava.net.preferIPv4Stack=true @@ -447,7 +439,7 @@ com.github.jknack handlebars - 4.1.2 + 4.3.0 @@ -470,7 +462,7 @@ com.github.nmorel.gwtjackson gwt-jackson - 0.15.2 + 0.15.4 com.tractionsoftware @@ -485,7 +477,7 @@ org.jasig.cas.client cas-client-core - ${cas.client.version} + ${version.cas-client} javax.servlet @@ -503,7 +495,7 @@ javax.xml.bind jaxb-api - 2.3.0 + 2.3.1 sources provided @@ -512,7 +504,7 @@ org.fusesource.restygwt restygwt - 2.2.6 + 2.2.7 org.glassfish.jersey.containers @@ -545,21 +537,6 @@ org.glassfish.jersey.media jersey-media-json-jackson - - io.swagger - swagger-jersey2-jaxrs - ${version.swagger} - - - io.springfox - springfox-swagger2 - ${version.springfox-swagger} - - - io.springfox - springfox-swagger-ui - ${version.springfox-swagger} - com.fasterxml.jackson.core jackson-core @@ -568,7 +545,7 @@ com.fasterxml.jackson.core jackson-databind - ${version.jackson-databind} + ${version.jackson} com.fasterxml.jackson.core @@ -583,7 +560,7 @@ org.apache.commons commons-csv - 1.7 + 1.9.0 @@ -653,12 +630,12 @@ org.springframework.boot spring-boot-starter-web - ${springboot.version} + ${version.springboot} org.springframework.boot spring-boot-starter-jersey - ${springboot.version} + ${version.springboot} org.springframework.boot @@ -695,6 +672,22 @@ micrometer-registry-prometheus + + io.swagger.core.v3 + swagger-core + ${version.swagger} + + + io.swagger.core.v3 + swagger-jaxrs2 + ${version.swagger} + + + io.swagger.core.v3 + swagger-jaxrs2-servlet-initializer-v2 + ${version.swagger} + + org.slf4j @@ -704,12 +697,12 @@ org.apache.solr solr-solrj - ${solr.version} + ${version.solr} org.apache.solr solr-core - ${solr.version} + ${version.solr} @@ -740,29 +733,23 @@ io.dropwizard.metrics metrics-core - 3.2.6 + 4.2.9 ch.qos.logback logback-classic - 1.2.3 + 1.2.11 org.apache.commons commons-lang3 - 3.7 + 3.12.0 commons-configuration commons-configuration 1.10 - - org.w3c - w3c-utils - 1.0.0 - - @@ -774,19 +761,19 @@ org.testng testng - 6.9.4 + 7.5 test org.mockito mockito-core - 2.0.28-beta + 4.5.1 test junit junit - 4.13.1 + 4.13.2 test diff --git a/src/main/java/com/databasepreservation/DBVTK.java b/src/main/java/com/databasepreservation/DBVTK.java index 071301bc2..188a60cb0 100644 --- a/src/main/java/com/databasepreservation/DBVTK.java +++ b/src/main/java/com/databasepreservation/DBVTK.java @@ -36,31 +36,13 @@ import com.databasepreservation.common.server.BrowserServiceImpl; import com.databasepreservation.common.server.ViewerConfiguration; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - @SpringBootApplication -@EnableSwagger2 public class DBVTK { public static void main(String[] args) { ViewerConfiguration.getInstance(); SpringApplication.run(DBVTK.class, args); } - @Configuration - public static class DefaultView implements WebMvcConfigurer { - - @Override - public void addViewControllers(ViewControllerRegistry registry) { - if (ViewerConstants.APPLICATION_ENV_DESKTOP - .equals(System.getProperty(ViewerConstants.APPLICATION_ENV_KEY, ViewerConstants.APPLICATION_ENV_SERVER))) { - registry.addViewController("/").setViewName("forward:/desktop.html"); - registry.setOrder(Ordered.HIGHEST_PRECEDENCE); - } - registry.addRedirectViewController("/api-docs", "/swagger-ui.html"); - registry.setOrder(Ordered.HIGHEST_PRECEDENCE); - } - } - @Bean public ServletRegistrationBean browserService() { ServletRegistrationBean bean; @@ -135,7 +117,7 @@ public FilterRegistrationBean internalApiAuthFilter() { // Comma separated list of relative paths to exclude in filter logic (using // regular expressions for extra power) - registrationBean.addInitParameter("exclusions", "^/swagger.json,^/v1/theme/?"); + registrationBean.addInitParameter("exclusions", "^/openapi.json,^/v1/theme/?"); registrationBean.addUrlPatterns("/api/*"); @@ -172,9 +154,9 @@ public FilterRegistrationBean casValidationFilter() { registrationBean.addInitParameter("serverName", "https://localhost:8888"); registrationBean.addInitParameter("exceptionOnValidationFailure", "false"); registrationBean.addInitParameter("redirectAfterValidation", "false"); - registrationBean.addInitParameter("proxyCallbackUrl", "https://localhost:8888/callback"); - registrationBean.addInitParameter("proxyReceptorUrl", "/callback"); - registrationBean.addInitParameter("acceptAnyProxy", "true"); + registrationBean.addInitParameter("proxyCallbackUrl", ""); + registrationBean.addInitParameter("proxyReceptorUrl", ""); + registrationBean.addInitParameter("acceptAnyProxy", "false"); registrationBean.addUrlPatterns("/*"); return registrationBean; @@ -248,6 +230,20 @@ public DataSource getDataSource() { return dataSourceBuilder.build(); } + @Configuration + public static class DefaultView implements WebMvcConfigurer { + + @Override + public void addViewControllers(ViewControllerRegistry registry) { + if (ViewerConstants.APPLICATION_ENV_DESKTOP + .equals(System.getProperty(ViewerConstants.APPLICATION_ENV_KEY, ViewerConstants.APPLICATION_ENV_SERVER))) { + registry.addViewController("/").setViewName("forward:/desktop.html"); + registry.setOrder(Ordered.HIGHEST_PRECEDENCE); + } + registry.setOrder(Ordered.HIGHEST_PRECEDENCE); + } + } + // @Bean // MultipartConfigElement multipartConfigElement() { // MultipartConfigFactory factory = new MultipartConfigFactory(); diff --git a/src/main/java/com/databasepreservation/common/api/MyApiListingResource.java b/src/main/java/com/databasepreservation/common/api/MyApiListingResource.java deleted file mode 100644 index 25293b337..000000000 --- a/src/main/java/com/databasepreservation/common/api/MyApiListingResource.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/dbptk-ui - */ -package com.databasepreservation.common.api; - -import io.swagger.jaxrs.listing.ApiListingResource; - -import javax.ws.rs.Path; - -/** - * @author Miguel Guimarães - */ -@Path("/api/swagger.{type:json|yaml}") -public class MyApiListingResource extends ApiListingResource { - -} diff --git a/src/main/java/com/databasepreservation/common/api/RestApplication.java b/src/main/java/com/databasepreservation/common/api/RestApplication.java deleted file mode 100644 index e57971925..000000000 --- a/src/main/java/com/databasepreservation/common/api/RestApplication.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/dbptk-ui - */ -package com.databasepreservation.common.api; - -import org.glassfish.jersey.jackson.JacksonFeature; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.moxy.xml.MoxyXmlFeature; -import org.glassfish.jersey.server.ResourceConfig; - -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.config.SwaggerConfigLocator; -import io.swagger.jaxrs.config.SwaggerContextService; -import io.swagger.jaxrs.listing.ApiListingResource; -import io.swagger.jaxrs.listing.SwaggerSerializers; - -/** - * @author Bruno Ferreira - */ -public class RestApplication extends ResourceConfig { - private static final String DBVTK_API_PACKAGE = "com.databasepreservation.common.api"; - private static final String SWAGGER_PACKAGE = "io.swagger.jaxrs.listing"; - - public RestApplication() { - super(); - packages("com.databasepreservation.common.api", "com.databasepreservation.common.client.services", - ApiListingResource.class.getPackage().getName()); - - register(JacksonFeature.class); - register(MoxyXmlFeature.class); - register(MultiPartFeature.class); - - // https://github.com/swagger-api/swagger-core/wiki/Swagger-Core-Jersey-2.X-Project-Setup-1.5 - register(ApiListingResource.class); - register(SwaggerSerializers.class); - BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1"); - beanConfig.setBasePath("/api"); - beanConfig - .setResourcePackage("com.databasepreservation.common.api,com.databasepreservation.common.client.services"); - beanConfig.setScan(true); - SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, beanConfig); - } -} diff --git a/src/main/java/com/databasepreservation/common/api/RestApplicationNoSwagger.java b/src/main/java/com/databasepreservation/common/api/RestApplicationNoSwagger.java index a55e37fd2..96d3dfce9 100644 --- a/src/main/java/com/databasepreservation/common/api/RestApplicationNoSwagger.java +++ b/src/main/java/com/databasepreservation/common/api/RestApplicationNoSwagger.java @@ -7,9 +7,9 @@ */ package com.databasepreservation.common.api; -import com.databasepreservation.common.api.utils.CacheFilterFactory; -import com.databasepreservation.common.api.v1.CollectionResource; -import com.databasepreservation.common.api.v1.SiardResource; +import java.util.stream.Collectors; +import java.util.stream.Stream; + import org.glassfish.jersey.jackson.JacksonFeature; import org.glassfish.jersey.media.multipart.MultiPartFeature; import org.glassfish.jersey.moxy.xml.MoxyXmlFeature; @@ -18,76 +18,72 @@ import org.springframework.context.annotation.Configuration; import com.databasepreservation.common.api.exceptions.RestExceptionMapper; +import com.databasepreservation.common.api.utils.CacheFilterFactory; import com.databasepreservation.common.api.v1.ActivityLogResource; import com.databasepreservation.common.api.v1.AuthenticationResource; import com.databasepreservation.common.api.v1.ClientLoggerResource; +import com.databasepreservation.common.api.v1.CollectionResource; import com.databasepreservation.common.api.v1.ContextResource; import com.databasepreservation.common.api.v1.DatabaseResource; import com.databasepreservation.common.api.v1.FileResource; import com.databasepreservation.common.api.v1.JobResource; import com.databasepreservation.common.api.v1.MigrationResource; +import com.databasepreservation.common.api.v1.SiardResource; import com.databasepreservation.common.api.v1.ThemeResource; -import io.swagger.jaxrs.config.BeanConfig; -import io.swagger.jaxrs.config.SwaggerConfigLocator; -import io.swagger.jaxrs.config.SwaggerContextService; -import io.swagger.jaxrs.listing.SwaggerSerializers; -import io.swagger.models.Contact; -import io.swagger.models.Info; -import io.swagger.models.License; +import io.swagger.v3.jaxrs2.SwaggerSerializers; +import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource; +import io.swagger.v3.oas.integration.SwaggerConfiguration; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; @Configuration -public class RestApplicationNoSwagger { +public class RestApplicationNoSwagger extends ResourceConfig { + public RestApplicationNoSwagger() { + super(); + property(ServletProperties.FILTER_FORWARD_ON_404, true); + property(ServletProperties.FILTER_CONTEXT_PATH, "/api/*"); - @Configuration - static class JerseyConfig extends ResourceConfig { - /** - * We just need the packages that have REST resources in them. - */ - public JerseyConfig() { - property(ServletProperties.FILTER_FORWARD_ON_404, true); - property(ServletProperties.FILTER_CONTEXT_PATH, "/api/*"); - // packages("com.databasepreservation.visualization.api"); + OpenAPI oas = new OpenAPI(); + Info info = new Info().title("DBPTK Enterprise API").description("REST API for the DBPTK Enterprise") + .contact(new Contact().email("info@keep.pt").name("KEEP SOLUTIONS") + .url("https://www.keep.pt/en/contacts-proposals-information-telephone-address")) + .license(new License().name("LGPLv3").url("http://www.gnu.org/licenses/lgpl-3.0.html")).version("1.0.0"); - register(ActivityLogResource.class); - register(AuthenticationResource.class); - register(ClientLoggerResource.class); - register(CollectionResource.class); - register(ContextResource.class); - register(DatabaseResource.class); - register(FileResource.class); - register(JobResource.class); - register(MigrationResource.class); - register(SiardResource.class); - register(ThemeResource.class); + oas.info(info); - register(JacksonFeature.class); - register(MoxyXmlFeature.class); - register(RestExceptionMapper.class); - register(MultiPartFeature.class); - register(CacheFilterFactory.class); + // if (StringUtils.isNotBlank(context.getContextPath())) { + // oas.addServersItem(new Server().url(context.getContextPath())); + // } - register(MyApiListingResource.class); - register(SwaggerSerializers.class); + OpenApiResource openApiResource = new OpenApiResource(); + SwaggerConfiguration oasConfig = new SwaggerConfiguration().openAPI(oas).prettyPrint(true) + .resourcePackages(Stream.of("com.databasepreservation.visualization.api").collect(Collectors.toSet())); + openApiResource.setOpenApiConfiguration(oasConfig); + register(openApiResource); + register(JacksonFeature.class); + register(MoxyXmlFeature.class); + register(MultiPartFeature.class); + register(RestExceptionMapper.class); + register(CacheFilterFactory.class); - BeanConfig beanConfig = new BeanConfig(); - beanConfig.setVersion("1"); - // beanConfig.setBasePath(""); - beanConfig.setResourcePackage("com.databasepreservation.common.api"); - beanConfig.setScan(true); - Info info = new Info(); - info.setTitle("DBPTK Enterprise API"); - info.setDescription("REST API for the DBPTK Enterprise"); - License license = new License(); - Contact contact = new Contact().email("info@keep.pt") - .url("https://www.keep.pt/en/contacts-proposals-information-telephone-address/").name("Keep Solutions"); - info.setContact(contact); - license.name("LGPLv3").setUrl("http://www.gnu.org/licenses/lgpl-3.0.html"); - info.setLicense(license); + register(ActivityLogResource.class); + register(AuthenticationResource.class); + register(ClientLoggerResource.class); + register(CollectionResource.class); + register(ContextResource.class); + register(DatabaseResource.class); + register(FileResource.class); + register(JobResource.class); + register(MigrationResource.class); + register(SiardResource.class); + register(ThemeResource.class); + register(SwaggerSerializers.class); - beanConfig.setInfo(info); - SwaggerConfigLocator.getInstance().putConfig(SwaggerContextService.CONFIG_ID_DEFAULT, beanConfig); - } + // packages("com.databasepreservation.visualization.api","com.databasepreservation.common.client.services"); + // packages("io.swagger.v3.jaxrs2.integration.resources"); + // register(CorsFilter.class); } - } diff --git a/src/main/java/com/databasepreservation/common/api/utils/ApiResponseMessage.java b/src/main/java/com/databasepreservation/common/api/utils/ApiResponseMessage.java index a20b50101..ebc4597a2 100644 --- a/src/main/java/com/databasepreservation/common/api/utils/ApiResponseMessage.java +++ b/src/main/java/com/databasepreservation/common/api/utils/ApiResponseMessage.java @@ -7,6 +7,8 @@ */ package com.databasepreservation.common.api.utils; +import com.fasterxml.jackson.annotation.JsonIgnore; + import javax.xml.bind.annotation.XmlTransient; /** @@ -55,6 +57,7 @@ public ApiResponseMessage(int code, String message) { } @XmlTransient + @JsonIgnore public int getCode() { return code; } diff --git a/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java b/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java index 5e9d8085c..a6b9d2214 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/CollectionResource.java @@ -108,8 +108,9 @@ import com.databasepreservation.common.utils.LobManagerUtils; import com.databasepreservation.common.utils.UserUtility; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; /** * @author Miguel Guimarães @@ -141,8 +142,8 @@ public class CollectionResource implements CollectionService { @GET @Path("/{databaseUUID}/collection/{collectionUUID}/report") @Produces({MediaType.APPLICATION_OCTET_STREAM}) - @ApiOperation(value = "Downloads the migration report for a specific database") - public Response getReport(@PathParam("databaseUUID") String databaseUUID) { + @Operation(summary = "Downloads the migration report for a specific database") + public Response getReport(@PathParam("databaseUUID") String databaseUUID, @PathParam("collectionUUID") String collectionUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -150,7 +151,7 @@ public Response getReport(@PathParam("databaseUUID") String databaseUUID) { try { java.nio.file.Path reportPath = ViewerConfiguration.getInstance().getReportPath(databaseUUID, - ReporterType.BROWSE); + ReporterType.BROWSE); String filename = reportPath.getFileName().toString(); if (!Files.exists(reportPath)) { throw new NotFoundException("Missing report file: " + filename); @@ -165,7 +166,7 @@ public Response getReport(@PathParam("databaseUUID") String databaseUUID) { } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID); + databaseUUID); } } @@ -180,7 +181,7 @@ public String createCollection(String databaseUUID) { // creates a collection for that SIARD. If the user is a guest it will throw an // AuthorizationException final boolean loadOnAccess = ViewerFactory.getViewerConfiguration().getViewerConfigurationAsBoolean(false, - ViewerConstants.PROPERTY_PLUGIN_LOAD_ON_ACCESS); + ViewerConstants.PROPERTY_PLUGIN_LOAD_ON_ACCESS); if (loadOnAccess) { user = UserUtility.getUser(request); if (user.isGuest()) { @@ -204,7 +205,7 @@ public String createCollection(String databaseUUID) { } @Override - public ProgressData getProgressData(String databaseUUID) { + public ProgressData getProgressData(String databaseUUID, String collectionUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -219,7 +220,7 @@ public ProgressData getProgressData(String databaseUUID) { } @Override - public Boolean deleteCollection(String databaseUUID) { + public Boolean deleteCollection(String databaseUUID, String collectionUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -230,7 +231,7 @@ public Boolean deleteCollection(String databaseUUID) { if (SolrClientFactory.get().deleteCollection(collectionName)) { Filter savedSearchFilter = new Filter(new SimpleFilterParameter(SOLR_SEARCHES_DATABASE_UUID, databaseUUID)); SolrUtils.delete(ViewerFactory.getSolrClient(), SolrDefaultCollectionRegistry.get(SavedSearch.class), - savedSearchFilter); + savedSearchFilter); ViewerFactory.getSolrManager().markDatabaseCollection(databaseUUID, ViewerDatabaseStatus.METADATA_ONLY); return true; @@ -241,7 +242,7 @@ public Boolean deleteCollection(String databaseUUID) { } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID); + databaseUUID); } return false; } @@ -258,7 +259,7 @@ public List getCollectionConfiguration(String databaseUUID, St try { final CollectionStatus configurationCollection = ViewerFactory.getConfigurationManager() - .getConfigurationCollection(databaseUUID, collectionUUID); + .getConfigurationCollection(databaseUUID, collectionUUID); return Collections.singletonList(configurationCollection); } catch (GenericException e) { state = LogEntryState.FAILURE; @@ -294,7 +295,7 @@ public Boolean updateCollectionConfiguration(String databaseUUID, String collect ******************************************************************************/ @Override public DenormalizeConfiguration getDenormalizeConfigurationFile(String databaseUUID, String collectionUUID, - String tableUUID) { + String tableUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -302,7 +303,7 @@ public DenormalizeConfiguration getDenormalizeConfigurationFile(String databaseU try { java.nio.file.Path path = ViewerConfiguration.getInstance().getDatabasesPath().resolve(databaseUUID) - .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION); + .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION); if (Files.exists(path)) { return JsonTransformer.readObjectFromFile(path, DenormalizeConfiguration.class); } else { @@ -316,13 +317,13 @@ public DenormalizeConfiguration getDenormalizeConfigurationFile(String databaseU } finally { // register action controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); } } @Override public synchronized Boolean createDenormalizeConfigurationFile(String databaseUUID, String collectionUUID, - String tableUUID, DenormalizeConfiguration configuration) { + String tableUUID, DenormalizeConfiguration configuration) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -331,25 +332,25 @@ public synchronized Boolean createDenormalizeConfigurationFile(String databaseUU // check if there is no job running on table for (JobExecution runningJobExecution : jobExplorer.findRunningJobExecutions("denormalizeJob")) { if (runningJobExecution.getJobParameters().getString(ViewerConstants.CONTROLLER_TABLE_ID_PARAM) - .equals(tableUUID)) { + .equals(tableUUID)) { throw new RESTException("A job is already running on this table", - com.google.gwt.http.client.Response.SC_CONFLICT); + com.google.gwt.http.client.Response.SC_CONFLICT); } } try { JsonTransformer.writeObjectToFile(configuration, - ViewerConfiguration.getInstance().getDatabasesPath().resolve(databaseUUID) - .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION)); + ViewerConfiguration.getInstance().getDatabasesPath().resolve(databaseUUID) + .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION)); ViewerFactory.getConfigurationManager().addDenormalization(databaseUUID, - ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID); + ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID); } catch (GenericException | ViewerException e) { state = LogEntryState.FAILURE; throw new RESTException(e.getMessage()); } finally { // register action controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); } return true; } @@ -363,9 +364,9 @@ public Boolean deleteDenormalizeConfigurationFile(String databaseUUID, String co try { ViewerFactory.getConfigurationManager().removeDenormalization(databaseUUID, - ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID); + ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID); java.nio.file.Path path = ViewerConfiguration.getInstance().getDatabasesPath().resolve(databaseUUID) - .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION); + .resolve(ViewerConstants.DENORMALIZATION_STATUS_PREFIX + tableUUID + ViewerConstants.JSON_EXTENSION); if (Files.exists(path)) { Files.delete(path); } @@ -375,7 +376,7 @@ public Boolean deleteDenormalizeConfigurationFile(String databaseUUID, String co } finally { // register action controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); } return true; } @@ -390,9 +391,9 @@ public synchronized void run(String databaseUUID, String collectionUUID, String // check if there is no job running on table for (JobExecution runningJobExecution : jobExplorer.findRunningJobExecutions("denormalizeJob")) { if (runningJobExecution.getJobParameters().getString(ViewerConstants.CONTROLLER_TABLE_ID_PARAM) - .equals(tableUUID)) { + .equals(tableUUID)) { throw new RESTException("A job is already running on this table", - com.google.gwt.http.client.Response.SC_CONFLICT); + com.google.gwt.http.client.Response.SC_CONFLICT); } } @@ -413,13 +414,13 @@ public synchronized void run(String databaseUUID, String collectionUUID, String JobController.setMessageToSolrBatchJob(jobExecution, "Queue is full, please try later"); } } catch (JobExecutionAlreadyRunningException | JobRestartException | JobInstanceAlreadyCompleteException - | JobParametersInvalidException | NotFoundException | GenericException e) { + | JobParametersInvalidException | NotFoundException | GenericException e) { state = LogEntryState.FAILURE; throw new RESTException(e.getMessage()); } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); + databaseUUID, ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID); } } @@ -428,7 +429,7 @@ public synchronized void run(String databaseUUID, String collectionUUID, String ******************************************************************************/ @Override public IndexResult findRows(String databaseUUID, String collectionUUID, String schema, String table, - FindRequest findRequest, String localeString) { + FindRequest findRequest, String localeString) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -438,8 +439,8 @@ public IndexResult findRows(String databaseUUID, String collectionUUI try { final IndexResult viewerRowIndexResult = ViewerFactory.getSolrManager().findRows(databaseUUID, - findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets, findRequest.fieldsToReturn, - findRequest.extraParameters); + findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets, findRequest.fieldsToReturn, + findRequest.extraParameters); count = viewerRowIndexResult.getTotalCount(); return viewerRowIndexResult; } catch (GenericException | RequestNotValidException e) { @@ -448,15 +449,15 @@ public IndexResult findRows(String databaseUUID, String collectionUUI } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_FILTER_PARAM, JsonUtils.getJsonFromObject(findRequest.filter), - ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist), - ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count); + databaseUUID, ViewerConstants.CONTROLLER_FILTER_PARAM, JsonUtils.getJsonFromObject(findRequest.filter), + ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist), + ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count); } } @Override public ViewerRow retrieveRow(String databaseUUID, String collectionUUID, String schema, String table, - String rowIndex) { + String rowIndex) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -475,17 +476,17 @@ public ViewerRow retrieveRow(String databaseUUID, String collectionUUID, String } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_ROW_ID_PARAM, rowIndex); + databaseUUID, ViewerConstants.CONTROLLER_ROW_ID_PARAM, rowIndex); } } @GET @Path("/{databaseUUID}/collection/{collectionUUID}/data/{schema}/{table}/{rowIndex}/{columnIndex}") - @ApiOperation(value = "Downloads a LOB for a specific row within a database", notes = "download the specified LOB.", response = Response.class) + @Operation(summary = "Downloads a LOB for a specific row within a database") public Response exportLOB(@PathParam(ViewerConstants.API_PATH_PARAM_DATABASE_UUID) String databaseUUID, - @PathParam(ViewerConstants.API_PATH_PARAM_COLLECTION_UUID) String collectionUUID, - @PathParam("schema") String schema, @PathParam("table") String table, @PathParam("rowIndex") String rowIndex, - @PathParam("columnIndex") Integer columnIndex) { + @PathParam(ViewerConstants.API_PATH_PARAM_COLLECTION_UUID) String collectionUUID, + @PathParam("schema") String schema, @PathParam("table") String table, @PathParam("rowIndex") String rowIndex, + @PathParam("columnIndex") Integer columnIndex) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; @@ -498,7 +499,7 @@ public Response exportLOB(@PathParam(ViewerConstants.API_PATH_PARAM_DATABASE_UUI ViewerRow row = solrManager.retrieveRows(databaseUUID, rowIndex); final ViewerDatabase database = solrManager.retrieve(ViewerDatabase.class, databaseUUID); final CollectionStatus configurationCollection = ViewerFactory.getConfigurationManager() - .getConfigurationCollection(databaseUUID, databaseUUID); + .getConfigurationCollection(databaseUUID, databaseUUID); final TableStatus configTable = configurationCollection.getTableStatusByTableId(row.getTableId()); if (ViewerType.dbTypes.CLOB.equals(configTable.getColumnByIndex(columnIndex).getType())) { @@ -520,25 +521,25 @@ public Response exportLOB(@PathParam(ViewerConstants.API_PATH_PARAM_DATABASE_UUI } finally { // register action controllerAssistant.registerAction(user, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_ROW_ID_PARAM, - rowIndex, ViewerConstants.CONTROLLER_COLUMN_ID_PARAM, columnIndex); + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_ROW_ID_PARAM, + rowIndex, ViewerConstants.CONTROLLER_COLUMN_ID_PARAM, columnIndex); } } private Response handleConsolidatedLobDownload(String databaseUUID, TableStatus tableConfiguration, int columnIndex, - ViewerRow row, String rowIndex) throws IOException { + ViewerRow row, String rowIndex) throws IOException { final java.nio.file.Path consolidatedPath = LobManagerUtils.getConsolidatedPath( - ViewerFactory.getViewerConfiguration(), databaseUUID, tableConfiguration.getUuid(), columnIndex, rowIndex); + ViewerFactory.getViewerConfiguration(), databaseUUID, tableConfiguration.getUuid(), columnIndex, rowIndex); String handlebarsFilename = HandlebarsUtils.applyExportTemplate(row, tableConfiguration, columnIndex); if (ViewerStringUtils.isBlank(handlebarsFilename)) { handlebarsFilename = consolidatedPath.getFileName().toString(); } return ApiUtils.okResponse( - new StreamResponse(handlebarsFilename, tableConfiguration.getColumnByIndex(columnIndex).getApplicationType(), - DownloadUtils - .stream(Files.newInputStream(LobManagerUtils.getConsolidatedPath(ViewerFactory.getViewerConfiguration(), - databaseUUID, row.getTableId(), columnIndex, rowIndex))))); + new StreamResponse(handlebarsFilename, tableConfiguration.getColumnByIndex(columnIndex).getApplicationType(), + DownloadUtils + .stream(Files.newInputStream(LobManagerUtils.getConsolidatedPath(ViewerFactory.getViewerConfiguration(), + databaseUUID, row.getTableId(), columnIndex, rowIndex))))); } private Response handleClobDownload(TableStatus tableConfiguration, ViewerRow row, int columnIndex) { @@ -549,18 +550,18 @@ private Response handleClobDownload(TableStatus tableConfiguration, ViewerRow ro } ByteArrayInputStream inputStream = new ByteArrayInputStream( - row.getCells().get(tableConfiguration.getColumnByIndex(columnIndex).getId()).getValue().getBytes()); + row.getCells().get(tableConfiguration.getColumnByIndex(columnIndex).getId()).getValue().getBytes()); return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, - tableConfiguration.getColumnByIndex(columnIndex).getApplicationType(), DownloadUtils.stream(inputStream))); + tableConfiguration.getColumnByIndex(columnIndex).getApplicationType(), DownloadUtils.stream(inputStream))); } private Response handleExternalLobDownload(TableStatus tableConfiguration, ViewerRow row, int columnIndex) - throws FileNotFoundException { + throws FileNotFoundException { final String lobLocation = row.getCells().get(tableConfiguration.getColumnByIndex(columnIndex).getId()).getValue(); final java.nio.file.Path lobPath = Paths.get(lobLocation); final java.nio.file.Path completeLobPath = ViewerFactory.getViewerConfiguration().getSIARDFilesPath() - .resolve(lobPath); + .resolve(lobPath); String handlebarsFilename = HandlebarsUtils.applyExportTemplate(row, tableConfiguration, columnIndex); @@ -575,16 +576,16 @@ private Response handleExternalLobDownload(TableStatus tableConfiguration, Viewe } return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType, - DownloadUtils.stream(new FileInputStream(completeLobPath.toFile())))); + DownloadUtils.stream(new FileInputStream(completeLobPath.toFile())))); } private Response handleInternalLobDownload(String databasePath, TableStatus tableConfiguration, ViewerRow row, - int columnIndex) throws IOException, GenericException { + int columnIndex) throws IOException, GenericException { String handlebarsFilename = HandlebarsUtils.applyExportTemplate(row, tableConfiguration, columnIndex); if (ViewerStringUtils.isBlank(handlebarsFilename)) { handlebarsFilename = ViewerConstants.SIARD_RECORD_PREFIX + row.getUuid() - + ViewerConstants.SIARD_LOB_FILE_EXTENSION; + + ViewerConstants.SIARD_LOB_FILE_EXTENSION; } String handlebarsMimeType = HandlebarsUtils.applyMimeTypeTemplate(row, tableConfiguration, columnIndex); @@ -599,7 +600,7 @@ private Response handleInternalLobDownload(String databasePath, TableStatus tabl String decodedString = new String(Base64.decodeBase64(lobCellValue.getBytes())); return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType, - DownloadUtils.stream(new BufferedInputStream(new ByteArrayInputStream(decodedString.getBytes()))))); + DownloadUtils.stream(new BufferedInputStream(new ByteArrayInputStream(decodedString.getBytes()))))); } else { // handle lob as internal on separated folder ZipFile zipFile = new ZipFile(databasePath); @@ -609,25 +610,25 @@ private Response handleInternalLobDownload(String databasePath, TableStatus tabl } return ApiUtils.okResponse(new StreamResponse(handlebarsFilename, handlebarsMimeType, - DownloadUtils.stream(new BufferedInputStream(zipFile.getInputStream(entry))))); + DownloadUtils.stream(new BufferedInputStream(zipFile.getInputStream(entry))))); } } @GET @Path("{databaseUUID}/collection/{collectionUUID}/data/{schema}/{table}/find/export") @Produces({MediaType.APPLICATION_OCTET_STREAM}) - @ApiOperation(value = "Export the rows as CSV", notes = "", response = Response.class) + @Operation(summary = "Export the rows as CSV") public Response exportFindToCSV( - @ApiParam(value = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, - @ApiParam(value = "The collection unique identifier", required = true) @PathParam("collectionUUID") String collectionUUID, - @ApiParam(value = "The schema name", required = true) @PathParam("schema") String schema, - @ApiParam(value = "The table name", required = true) @PathParam("table") String table, - @ApiParam(value = "Find request to filter/limit the search") @QueryParam("f") String findRequestJson, - @ApiParam(value = "The CSV filename") @QueryParam("filename") String filename, - @ApiParam(value = "The Zip filename") @QueryParam("zipFilename") String zipFilename, - @ApiParam(value = "Export description", allowableValues = "true, false") @QueryParam("descriptions") boolean exportDescription, - @ApiParam(value = "Export LOBs", allowableValues = "true, false") @QueryParam("lobs") boolean exportLobs, - @ApiParam(value = "Fields to export", required = true) @QueryParam("fl") String fieldsToHeader) { + @Parameter(name = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, + @Parameter(name = "The collection unique identifier", required = true) @PathParam("collectionUUID") String collectionUUID, + @Parameter(name = "The schema name", required = true) @PathParam("schema") String schema, + @Parameter(name = "The table name", required = true) @PathParam("table") String table, + @Parameter(name = "Find request to filter/limit the search") @QueryParam("f") String findRequestJson, + @Parameter(name = "The CSV filename") @QueryParam("filename") String filename, + @Parameter(name = "The Zip filename") @QueryParam("zipFilename") String zipFilename, + @Parameter(name = "Export description", schema = @Schema(allowableValues = "true, false")) @QueryParam("descriptions") boolean exportDescription, + @Parameter(name = "Export LOBs", schema = @Schema(allowableValues = "true, false")) @QueryParam("lobs") boolean exportLobs, + @Parameter(name = "Fields to export", required = true) @QueryParam("fl") String fieldsToHeader) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -641,15 +642,15 @@ public Response exportFindToCSV( final ViewerDatabase database = solrManager.retrieve(ViewerDatabase.class, databaseUUID); findRequest = JsonUtils.getObjectFromJson(findRequestJson, FindRequest.class); final CollectionStatus configurationCollection = ViewerFactory.getConfigurationManager() - .getConfigurationCollection(databaseUUID, databaseUUID); + .getConfigurationCollection(databaseUUID, databaseUUID); final TableStatus configTable = configurationCollection.getTableStatusByTableId(schema + "." + table); if (Boolean.FALSE.equals(exportLobs) && StringUtils.isBlank(zipFilename)) { return handleCSVExport(solrManager, databaseUUID, configTable, findRequest, filename, exportDescription, - fieldsToHeader); + fieldsToHeader); } else { return handleCSVExportWithLobs(solrManager, configurationCollection, database, databaseUUID, configTable, - findRequest, zipFilename, filename, exportDescription, fieldsToHeader); + findRequest, zipFilename, filename, exportDescription, fieldsToHeader); } } catch (GenericException | RequestNotValidException | NotFoundException e) { state = LogEntryState.FAILURE; @@ -657,12 +658,12 @@ public Response exportFindToCSV( } finally { if (findRequest != null) { Object[] list = new Object[] {ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_FILTER_PARAM, - JsonUtils.getJsonFromObject(findRequest.filter), ViewerConstants.CONTROLLER_EXPORT_DESCRIPTIONS_PARAM, - exportDescription, ViewerConstants.CONTROLLER_EXPORT_LOBS_PARAM, exportLobs, - ViewerConstants.CONTROLLER_FILENAME_PARAM, filename, ViewerConstants.CONTROLLER_SUBLIST_PARAM, - findRequest.sublist == null ? JsonUtils.getJsonFromObject(Sublist.NONE) - : JsonUtils.getJsonFromObject(findRequest.sublist)}; + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_FILTER_PARAM, + JsonUtils.getJsonFromObject(findRequest.filter), ViewerConstants.CONTROLLER_EXPORT_DESCRIPTIONS_PARAM, + exportDescription, ViewerConstants.CONTROLLER_EXPORT_LOBS_PARAM, exportLobs, + ViewerConstants.CONTROLLER_FILENAME_PARAM, filename, ViewerConstants.CONTROLLER_SUBLIST_PARAM, + findRequest.sublist == null ? JsonUtils.getJsonFromObject(Sublist.NONE) + : JsonUtils.getJsonFromObject(findRequest.sublist)}; if (StringUtils.isNotBlank(zipFilename)) { list = appendValue(list, ViewerConstants.CONTROLLER_ZIP_FILENAME_PARAM); @@ -677,17 +678,17 @@ public Response exportFindToCSV( @GET @Path("{databaseUUID}/collection/{collectionUUID}/data/{schema}/{table}/{rowIndex}/export") @Produces({MediaType.APPLICATION_OCTET_STREAM}) - @ApiOperation(value = "Export the a single row as CSV", notes = "", response = Response.class) + @Operation(summary = "Export the a single row as CSV") public Response exportSingleRowToCSV( - @ApiParam(value = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, - @ApiParam(value = "The collection unique identifier", required = true) @PathParam("collectionUUID") String collectionUUID, - @ApiParam(value = "The schema name", required = true) @PathParam("schema") String schema, - @ApiParam(value = "The table name", required = true) @PathParam("table") String table, - @ApiParam(value = "The index of the row", required = true) @PathParam("rowIndex") String rowIndex, - @ApiParam(value = "The CSV filename", required = true) @QueryParam("filename") String filename, - @ApiParam(value = "The Zip filename") @QueryParam("zipFilename") String zipFilename, - @ApiParam(value = "Export description", allowableValues = "true, false", required = true) @QueryParam("descriptions") boolean exportDescription, - @ApiParam(value = "Export LOBs", allowableValues = "true, false", required = true) @QueryParam("lobs") boolean exportLobs) { + @Parameter(name = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, + @Parameter(name = "The collection unique identifier", required = true) @PathParam("collectionUUID") String collectionUUID, + @Parameter(name = "The schema name", required = true) @PathParam("schema") String schema, + @Parameter(name = "The table name", required = true) @PathParam("table") String table, + @Parameter(name = "The index of the row", required = true) @PathParam("rowIndex") String rowIndex, + @Parameter(name = "The CSV filename", required = true) @QueryParam("filename") String filename, + @Parameter(name = "The Zip filename") @QueryParam("zipFilename") String zipFilename, + @Parameter(name = "Export description", schema = @Schema(allowableValues = "true, false"), required = true) @QueryParam("descriptions") boolean exportDescription, + @Parameter(name = "Export LOBs", schema = @Schema(allowableValues = "true, false"), required = true) @QueryParam("lobs") boolean exportLobs) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; DatabaseRowsSolrManager solrManager = ViewerFactory.getSolrManager(); @@ -698,7 +699,7 @@ public Response exportSingleRowToCSV( final ViewerDatabase database = solrManager.retrieve(ViewerDatabase.class, databaseUUID); final ViewerRow viewerRow = solrManager.retrieveRows(databaseUUID, rowIndex); final CollectionStatus configurationCollection = ViewerFactory.getConfigurationManager() - .getConfigurationCollection(databaseUUID, databaseUUID); + .getConfigurationCollection(databaseUUID, databaseUUID); final TableStatus configTable = configurationCollection.getTableStatusByTableId(schema + "." + table); if (viewerRow != null && viewerRow.getTableId().equals(schema + "." + table)) { @@ -706,7 +707,7 @@ public Response exportSingleRowToCSV( return handleSingleCSVExportWithoutLOBs(databaseUUID, configTable, viewerRow, filename, exportDescription); } else { return handleSingleCSVExportWithLOBs(configurationCollection, database, configTable, viewerRow, filename, - zipFilename, exportDescription); + zipFilename, exportDescription); } } else { throw new NotFoundException("Table not found."); @@ -716,9 +717,9 @@ public Response exportSingleRowToCSV( throw new RESTException(e); } finally { Object[] list = new Object[] {ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, databaseUUID, - ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_ROW_ID_PARAM, - rowIndex, ViewerConstants.CONTROLLER_EXPORT_DESCRIPTIONS_PARAM, exportDescription, - ViewerConstants.CONTROLLER_EXPORT_LOBS_PARAM, exportLobs, ViewerConstants.CONTROLLER_FILENAME_PARAM, filename}; + ViewerConstants.CONTROLLER_TABLE_ID_PARAM, schema + "." + table, ViewerConstants.CONTROLLER_ROW_ID_PARAM, + rowIndex, ViewerConstants.CONTROLLER_EXPORT_DESCRIPTIONS_PARAM, exportDescription, + ViewerConstants.CONTROLLER_EXPORT_LOBS_PARAM, exportLobs, ViewerConstants.CONTROLLER_FILENAME_PARAM, filename}; if (StringUtils.isNotBlank(zipFilename)) { list = appendValue(list, ViewerConstants.CONTROLLER_ZIP_FILENAME_PARAM); @@ -730,54 +731,54 @@ public Response exportSingleRowToCSV( } private Response handleSingleCSVExportWithoutLOBs(String databaseUUID, TableStatus configTable, ViewerRow row, - String filename, boolean exportDescriptions) throws GenericException { + String filename, boolean exportDescriptions) throws GenericException { final CollectionStatus configurationCollection = ViewerFactory.getConfigurationManager() - .getConfigurationCollection(databaseUUID, databaseUUID); + .getConfigurationCollection(databaseUUID, databaseUUID); final List fieldsToReturn = configurationCollection.getFieldsToReturn(configTable.getId()); return ApiUtils.okResponse(new ViewerStreamingOutput( - new ResultsCSVOutputStream(row, configTable, filename, exportDescriptions, ',', String.join(",", fieldsToReturn))) + new ResultsCSVOutputStream(row, configTable, filename, exportDescriptions, ',', String.join(",", fieldsToReturn))) .toStreamResponse()); } private Response handleSingleCSVExportWithLOBs(CollectionStatus configurationCollection, ViewerDatabase database, - TableStatus configTable, ViewerRow row, String filename, String zipFilename, boolean exportDescriptions) - throws GenericException { + TableStatus configTable, ViewerRow row, String filename, String zipFilename, boolean exportDescriptions) + throws GenericException { final List fieldsToReturn = configurationCollection.getFieldsToReturn(configTable.getId()); return ApiUtils.okResponse(new StreamResponse(new ZipOutputStreamSingleRow(configurationCollection, database, - configTable, row, zipFilename, filename, fieldsToReturn, exportDescriptions))); + configTable, row, zipFilename, filename, fieldsToReturn, exportDescriptions))); } private Response handleCSVExport(DatabaseRowsSolrManager solrManager, final String databaseUUID, - final TableStatus configTable, final FindRequest findRequest, final String filename, - final boolean exportDescriptions, String fieldsToHeader) throws GenericException, RequestNotValidException { + final TableStatus configTable, final FindRequest findRequest, final String filename, + final boolean exportDescriptions, String fieldsToHeader) throws GenericException, RequestNotValidException { if (findRequest.sublist == null) { final IterableIndexResult allRows = solrManager.findAllRows(databaseUUID, findRequest.filter, findRequest.sorter, - findRequest.fieldsToReturn, findRequest.extraParameters); + findRequest.fieldsToReturn, findRequest.extraParameters); return ApiUtils.okResponse(new ViewerStreamingOutput(new IterableIndexResultsCSVOutputStream(allRows, configTable, - filename, exportDescriptions, ',', fieldsToHeader)).toStreamResponse()); + filename, exportDescriptions, ',', fieldsToHeader)).toStreamResponse()); } else { final IndexResult rows = solrManager.findRows(databaseUUID, findRequest.filter, findRequest.sorter, - findRequest.sublist, null, findRequest.fieldsToReturn, findRequest.extraParameters); + findRequest.sublist, null, findRequest.fieldsToReturn, findRequest.extraParameters); return ApiUtils.okResponse(new ViewerStreamingOutput( - new ResultsCSVOutputStream(rows, configTable, filename, exportDescriptions, ',', fieldsToHeader)) + new ResultsCSVOutputStream(rows, configTable, filename, exportDescriptions, ',', fieldsToHeader)) .toStreamResponse()); } } private Response handleCSVExportWithLobs(DatabaseRowsSolrManager solrManager, - CollectionStatus configurationCollection, ViewerDatabase database, final String databaseUUID, - final TableStatus configTable, final FindRequest findRequest, final String zipFilename, final String filename, - final boolean exportDescription, String fieldsToHeader) { + CollectionStatus configurationCollection, ViewerDatabase database, final String databaseUUID, + final TableStatus configTable, final FindRequest findRequest, final String zipFilename, final String filename, + final boolean exportDescription, String fieldsToHeader) { List fields = findRequest.fieldsToReturn; fields.add(ViewerConstants.INDEX_ID); final IterableIndexResult allRows = solrManager.findAllRows(databaseUUID, findRequest.filter, findRequest.sorter, - fields, findRequest.extraParameters); + fields, findRequest.extraParameters); final IterableIndexResult clone = solrManager.findAllRows(databaseUUID, findRequest.filter, findRequest.sorter, - fields, findRequest.extraParameters); + fields, findRequest.extraParameters); return ApiUtils.okResponse(new StreamResponse(new ZipOutputStreamMultiRow(configurationCollection, database, - configTable, allRows, clone, zipFilename, filename, findRequest.sublist, exportDescription, fieldsToHeader))); + configTable, allRows, clone, zipFilename, filename, findRequest.sublist, exportDescription, fieldsToHeader))); } private Object[] appendValue(Object[] obj, Object newObj) { @@ -791,7 +792,7 @@ private Object[] appendValue(Object[] obj, Object newObj) { ******************************************************************************/ @Override public String saveSavedSearch(String databaseUUID, String collectionUUID, String tableUUID, String name, - String description, SearchInfo searchInfo) { + String description, SearchInfo searchInfo) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -817,16 +818,16 @@ public String saveSavedSearch(String databaseUUID, String collectionUUID, String } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID, - ViewerConstants.CONTROLLER_SAVED_SEARCH_NAME_PARAM, name, - ViewerConstants.CONTROLLER_SAVED_SEARCH_DESCRIPTION_PARAM, description, - ViewerConstants.CONTROLLER_SAVED_SEARCH_PARAM, JsonUtils.getJsonFromObject(savedSearch)); + databaseUUID, ViewerConstants.CONTROLLER_TABLE_ID_PARAM, tableUUID, + ViewerConstants.CONTROLLER_SAVED_SEARCH_NAME_PARAM, name, + ViewerConstants.CONTROLLER_SAVED_SEARCH_DESCRIPTION_PARAM, description, + ViewerConstants.CONTROLLER_SAVED_SEARCH_PARAM, JsonUtils.getJsonFromObject(savedSearch)); } } @Override public IndexResult findSavedSearches(String databaseUUID, String collectionUUID, FindRequest findRequest, - String localeString) { + String localeString) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -836,7 +837,7 @@ public IndexResult findSavedSearches(String databaseUUID, String co try { final IndexResult savedSearchIndexResult = ViewerFactory.getSolrManager().find(SavedSearch.class, - findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets); + findRequest.filter, findRequest.sorter, findRequest.sublist, findRequest.facets); count = savedSearchIndexResult.getTotalCount(); return savedSearchIndexResult; } catch (GenericException | RequestNotValidException e) { @@ -845,9 +846,9 @@ public IndexResult findSavedSearches(String databaseUUID, String co } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_FILTER_PARAM, JsonUtils.getJsonFromObject(findRequest.filter), - ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist), - ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count); + databaseUUID, ViewerConstants.CONTROLLER_FILTER_PARAM, JsonUtils.getJsonFromObject(findRequest.filter), + ViewerConstants.CONTROLLER_SUBLIST_PARAM, JsonUtils.getJsonFromObject(findRequest.sublist), + ViewerConstants.CONTROLLER_RETRIEVE_COUNT, count); } } @@ -866,13 +867,13 @@ public SavedSearch retrieveSavedSearch(String databaseUUID, String collectionUUI } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID); + databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID); } } @Override public void updateSavedSearch(String databaseUUID, String collectionUUID, String savedSearchUUID, String name, - String description) { + String description) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -886,9 +887,9 @@ public void updateSavedSearch(String databaseUUID, String collectionUUID, String } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID, - ViewerConstants.CONTROLLER_SAVED_SEARCH_NAME_PARAM, name, - ViewerConstants.CONTROLLER_SAVED_SEARCH_DESCRIPTION_PARAM, description); + databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID, + ViewerConstants.CONTROLLER_SAVED_SEARCH_NAME_PARAM, name, + ViewerConstants.CONTROLLER_SAVED_SEARCH_DESCRIPTION_PARAM, description); } } @@ -907,7 +908,7 @@ public void deleteSavedSearch(String databaseUUID, String collectionUUID, String } finally { // register action controllerAssistant.registerAction(user, databaseUUID, state, ViewerConstants.CONTROLLER_DATABASE_ID_PARAM, - databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID); + databaseUUID, ViewerConstants.CONTROLLER_SAVED_SEARCH_UUID_PARAM, savedSearchUUID); } } } diff --git a/src/main/java/com/databasepreservation/common/api/v1/FileResource.java b/src/main/java/com/databasepreservation/common/api/v1/FileResource.java index 7c368ee3c..baba8db25 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/FileResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/FileResource.java @@ -49,28 +49,28 @@ import com.databasepreservation.common.utils.ControllerAssistant; import com.google.common.io.Files; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Gabriel Barros */ @Service @Path(FileResource.ENDPOINT) -@Api(value = FileResource.SWAGGER_ENDPOINT) +@Tag(name = FileResource.SWAGGER_ENDPOINT) public class FileResource { - private static final Logger LOGGER = LoggerFactory.getLogger(FileResource.class); public static final String ENDPOINT = "/" + ViewerConstants.API_SERVLET + ViewerConstants.API_V1_FILE_RESOURCE; public static final String SWAGGER_ENDPOINT = "v1 files"; - + private static final Logger LOGGER = LoggerFactory.getLogger(FileResource.class); @Context private HttpServletRequest request; @GET - @ApiOperation(value = "Lists all the SIARD files in the server", notes = "") + @Operation(summary = "Lists all the SIARD files in the server") public List list() { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; @@ -93,9 +93,9 @@ public List list() { @GET @Path("/download/siard") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation(value = "Downloads a specific SIARD file from the storage location", notes = "") + @Operation(summary = "Downloads a specific SIARD file from the storage location") public Response getSIARDFile( - @ApiParam(required = true, value = "The name of the SIARD file to download") @QueryParam(ViewerConstants.API_PATH_PARAM_FILENAME) String filename) { + @Parameter(required = true, name = "The name of the SIARD file to download") @QueryParam(ViewerConstants.API_PATH_PARAM_FILENAME) String filename) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -125,9 +125,9 @@ public Response getSIARDFile( } @DELETE - @ApiOperation(value = "Deletes a SIARD file", notes = "") + @Operation(summary = "Deletes a SIARD file") public void deleteSiardFile( - @ApiParam(value = "Filename to be deleted", required = true) @QueryParam(value = "filename") String filename) { + @Parameter(name = "Filename to be deleted", required = true) @QueryParam(value = "filename") String filename) { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -150,14 +150,14 @@ public void deleteSiardFile( @Produces({MediaType.APPLICATION_JSON}) @Consumes(MediaType.MULTIPART_FORM_DATA) @JSONP(callback = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK, queryParam = RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) - @ApiOperation(value = "Creates a new SIARD file", notes = "") - @ApiResponses(value = {@ApiResponse(code = 204, message = "OK"), - @ApiResponse(code = 409, message = "Already exists", response = ApiResponseMessage.class)}) + @Operation(summary = "Creates a new SIARD file") + @ApiResponses(value = {@ApiResponse(responseCode = "204", description = "OK"), + @ApiResponse(responseCode = "409", description = "Already exists")}) public Response createSIARDFile(@FormDataParam("upl") InputStream inputStream, @FormDataParam("upl") FormDataContentDisposition fileDetail, - @ApiParam(value = "Choose format in which to get the response", allowableValues = RodaConstants.API_POST_PUT_MEDIA_TYPES) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat, - @ApiParam(value = "JSONP callback name", required = false, allowMultiple = false, defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName) { + @Parameter(name = "Choose format in which to get the response", schema = @Schema(allowableValues = RodaConstants.API_POST_PUT_MEDIA_TYPES)) @QueryParam(RodaConstants.API_QUERY_KEY_ACCEPT_FORMAT) String acceptFormat, + @Parameter(name = "JSONP callback name", required = false, schema = @Schema(defaultValue = RodaConstants.API_QUERY_DEFAULT_JSONP_CALLBACK)) @QueryParam(RodaConstants.API_QUERY_KEY_JSONP_CALLBACK) String jsonpCallbackName) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -191,4 +191,4 @@ public Response createSIARDFile(@FormDataParam("upl") InputStream inputStream, fileDetail.getFileName()); } } -} \ No newline at end of file +} diff --git a/src/main/java/com/databasepreservation/common/api/v1/SiardResource.java b/src/main/java/com/databasepreservation/common/api/v1/SiardResource.java index edc4668c9..6f8fbae1f 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/SiardResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/SiardResource.java @@ -40,7 +40,7 @@ import com.databasepreservation.common.server.index.DatabaseRowsSolrManager; import com.databasepreservation.common.utils.ControllerAssistant; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; /** * @author Miguel Guimarães @@ -109,7 +109,7 @@ public Boolean validateSiard(String databaseUUID, String siardUUID, String valid } @Override - public ValidationProgressData getValidationProgressData(String databaseUUID) { + public ValidationProgressData getValidationProgressData(String databaseUUID, String siardUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; @@ -126,7 +126,7 @@ public ValidationProgressData getValidationProgressData(String databaseUUID) { @GET @Path("/{databaseUUID}/siard/{siardUUID}/download/validation") @Produces(MediaType.APPLICATION_OCTET_STREAM) - @ApiOperation(value = "Downloads a specific SIARD validation report file from the storage location", notes = "") + @Operation(summary = "Downloads a specific SIARD validation report file from the storage location", description = "") public Response getValidationReportFile(@PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID) { ControllerAssistant controllerAssistant = new ControllerAssistant() {}; @@ -157,7 +157,7 @@ public Response getValidationReportFile(@PathParam("databaseUUID") String databa } @Override - public void deleteValidationReport(String databaseUUID, String path) { + public void deleteValidationReport(String databaseUUID, String siardUUID, String path) { final ControllerAssistant controllerAssistant = new ControllerAssistant() {}; LogEntryState state = LogEntryState.SUCCESS; diff --git a/src/main/java/com/databasepreservation/common/api/v1/ThemeResource.java b/src/main/java/com/databasepreservation/common/api/v1/ThemeResource.java index c5c0213ee..1ee0c3c58 100644 --- a/src/main/java/com/databasepreservation/common/api/v1/ThemeResource.java +++ b/src/main/java/com/databasepreservation/common/api/v1/ThemeResource.java @@ -29,25 +29,25 @@ import com.databasepreservation.common.api.utils.Theme; import com.databasepreservation.common.client.ViewerConstants; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; @Service @Path(ThemeResource.ENDPOINT) -@Api(value = ThemeResource.SWAGGER_ENDPOINT) +@Tag(name = ThemeResource.SWAGGER_ENDPOINT) public class ThemeResource { public static final String ENDPOINT = "/" + ViewerConstants.API_SERVLET + ViewerConstants.API_V1_THEME_RESOURCE; public static final String SWAGGER_ENDPOINT = "v1 theme"; public static final int CACHE_CONTROL_MAX_AGE = 60; @GET - @ApiOperation(value = "Gets the custom theme") + @Operation(summary = "Gets the custom theme") public Response getResource( - @ApiParam(value = "The resource id", required = true) @QueryParam(ViewerConstants.API_QUERY_PARAM_RESOURCE_ID) String resourceId, - @ApiParam(value = "The default resource id", required = false) @QueryParam(ViewerConstants.API_QUERY_PARAM_DEFAULT_RESOURCE_ID) String fallbackResourceId, - @ApiParam(value = "If the resource is served inline", required = false) @QueryParam(ViewerConstants.API_QUERY_PARAM_INLINE) boolean inline, - @Context Request req) throws IOException, NotFoundException { + @Parameter(name = "The resource id", required = true) @QueryParam(ViewerConstants.API_QUERY_PARAM_RESOURCE_ID) String resourceId, + @Parameter(name = "The default resource id", required = false) @QueryParam(ViewerConstants.API_QUERY_PARAM_DEFAULT_RESOURCE_ID) String fallbackResourceId, + @Parameter(name = "If the resource is served inline", required = false) @QueryParam(ViewerConstants.API_QUERY_PARAM_INLINE) boolean inline, + @Context Request req) throws IOException, NotFoundException { Pair themeResource = Theme.getThemeResource(resourceId, fallbackResourceId); diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java index 58846ae83..af470f251 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/BrowseNavigationPanel.java @@ -213,7 +213,7 @@ private void delete() { CollectionService.Util.call((List collectionStatus) -> { ObserverManager.getCollectionObserver().setCollectionStatus(collectionStatus.get(0)); }).getCollectionConfiguration(database.getUuid(), database.getUuid()); - }).deleteCollection(database.getUuid()); + }).deleteCollection(database.getUuid(), database.getUuid()); } } } diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/ValidationNavigationPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/ValidationNavigationPanel.java index cfe933e7d..a7384d61a 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/ValidationNavigationPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/manager/SIARDPanel/navigation/ValidationNavigationPanel.java @@ -257,11 +257,11 @@ private void updateValidationButtons() { } break; case VALIDATION_RUNNING: - //if (ValidatorPage.checkInstance(database.getUuid())) { - navigationPanel.addButton(CommonClientUtils.wrapOnDiv(BTN_ITEM, btnOpenValidator)); - //} else { - //GWT.log("ELSE!!!!!"); - //} + // if (ValidatorPage.checkInstance(database.getUuid())) { + navigationPanel.addButton(CommonClientUtils.wrapOnDiv(BTN_ITEM, btnOpenValidator)); + // } else { + // GWT.log("ELSE!!!!!"); + // } break; case NOT_VALIDATED: btnValidate.setText(messages.SIARDHomePageButtonTextValidateNow()); @@ -346,7 +346,7 @@ private void delete() { if (!database.getValidationStatus().equals(ViewerDatabaseValidationStatus.VALIDATION_RUNNING)) { SiardService.Util .call((Void result) -> SIARDManagerPage.getInstance(database).refreshInstance(database.getUuid())) - .deleteValidationReport(database.getUuid(), database.getValidatorReportPath()); + .deleteValidationReport(database.getUuid(), database.getUuid(), database.getValidatorReportPath()); } } } diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/IndeterminateProgressBarPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/IndeterminateProgressBarPanel.java index 795df3738..6a3e2d6b9 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/IndeterminateProgressBarPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/IndeterminateProgressBarPanel.java @@ -80,7 +80,7 @@ private void init() { content.clear(); stopUpdating(); autoUpdateTimer.scheduleRepeating(1000); - }).getProgressData(databaseUUID); + }).getProgressData(databaseUUID, databaseUUID); } public void setTitleText(String text) { @@ -112,7 +112,7 @@ public void clear(String uuid) { } private void update() { - CollectionService.Util.call((Consumer) this::update).getProgressData(databaseUUID); + CollectionService.Util.call((Consumer) this::update).getProgressData(databaseUUID, databaseUUID); } private void update(ProgressData progressData) { diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/ProgressBarPanel.java b/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/ProgressBarPanel.java index d0e9b933a..cba6538d0 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/ProgressBarPanel.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/progressBar/ProgressBarPanel.java @@ -87,7 +87,7 @@ private void init() { content.clear(); stopUpdating(); autoUpdateTimer.scheduleRepeating(1000); - }).getProgressData(databaseUUID); + }).getProgressData(databaseUUID, databaseUUID); } public void setTitleText(String text) { @@ -120,7 +120,7 @@ public void clear(String uuid) { } private void update() { - CollectionService.Util.call((Consumer) this::update).getProgressData(databaseUUID); + CollectionService.Util.call((Consumer) this::update).getProgressData(databaseUUID, databaseUUID); } private void update(ProgressData progressData) { diff --git a/src/main/java/com/databasepreservation/common/client/common/visualization/validation/ValidatorPage.java b/src/main/java/com/databasepreservation/common/client/common/visualization/validation/ValidatorPage.java index af5e0d1ad..03994d4ee 100644 --- a/src/main/java/com/databasepreservation/common/client/common/visualization/validation/ValidatorPage.java +++ b/src/main/java/com/databasepreservation/common/client/common/visualization/validation/ValidatorPage.java @@ -152,7 +152,7 @@ private void initProgress() { autoUpdateTimer.run(); result.setFinished(false); // runValidator(); - }).getValidationProgressData(database.getUuid()); + }).getValidationProgressData(database.getUuid(), database.getUuid()); } private void runValidator() { @@ -181,7 +181,7 @@ private void update() { messages.basicActionClose(), "btn btn-link"); } } - }).getValidationProgressData(database.getUuid()); + }).getValidationProgressData(database.getUuid(), database.getUuid()); } private void update(ValidationProgressData validationProgressData) { diff --git a/src/main/java/com/databasepreservation/common/client/models/wizard/table/TableAndColumnsParameters.java b/src/main/java/com/databasepreservation/common/client/models/wizard/table/TableAndColumnsParameters.java index e4b827a51..fc2895f81 100644 --- a/src/main/java/com/databasepreservation/common/client/models/wizard/table/TableAndColumnsParameters.java +++ b/src/main/java/com/databasepreservation/common/client/models/wizard/table/TableAndColumnsParameters.java @@ -7,9 +7,6 @@ */ package com.databasepreservation.common.client.models.wizard.table; -import com.google.gwt.core.client.GWT; -import io.swagger.models.auth.In; - import java.io.Serializable; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/src/main/java/com/databasepreservation/common/client/services/ActivityLogService.java b/src/main/java/com/databasepreservation/common/client/services/ActivityLogService.java index 38ee26e95..ca08c81ff 100644 --- a/src/main/java/com/databasepreservation/common/client/services/ActivityLogService.java +++ b/src/main/java/com/databasepreservation/common/client/services/ActivityLogService.java @@ -13,12 +13,15 @@ import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; import org.fusesource.restygwt.client.DirectRestService; import org.fusesource.restygwt.client.MethodCallback; import org.fusesource.restygwt.client.REST; +import com.databasepreservation.common.api.utils.ApiResponseMessage; import com.databasepreservation.common.client.ViewerConstants; import com.databasepreservation.common.client.common.DefaultMethodCallback; import com.databasepreservation.common.client.index.FindRequest; @@ -27,18 +30,39 @@ import com.databasepreservation.common.client.models.activity.logs.ActivityLogWrapper; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães */ @Path(".." + ViewerConstants.ENDPOINT_ACTIVITY_LOG) -@Api(value = ActivityLogService.SWAGGER_ENDPOINT) +@Tag(name = ActivityLogService.SWAGGER_ENDPOINT) public interface ActivityLogService extends DirectRestService { public static final String SWAGGER_ENDPOINT = "v1 activity log"; + + @POST + @Path("/find") + @Operation(summary = "Finds logs", requestBody = @RequestBody(required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON)), responses = { + @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = IndexResult.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(implementation = ApiResponseMessage.class)))}) + @Produces(MediaType.APPLICATION_JSON) + IndexResult find( + @Parameter(name = "f", description = "Find request to filter/limit the search", required = true, content = @Content(mediaType = MediaType.APPLICATION_JSON)) FindRequest findRequest, + @Parameter(name = "Locale") @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String locale); + + @GET + @Path("/{logUUID}") + @Operation(summary = "Retrieve a specific log detail") + @Produces(MediaType.APPLICATION_JSON) + ActivityLogWrapper retrieve(@Parameter(name = "The unique log identifier") @PathParam("logUUID") String logUUID); + class Util { /** * @return the singleton instance @@ -59,16 +83,4 @@ public static ActivityLogService call(Consumer callback, Consumer return REST.withCallback(DefaultMethodCallback.get(callback, errorHandler)).call(get()); } } - - @POST - @Path("/find") - @ApiOperation(value = "Finds logs", response = IndexResult.class) - IndexResult find( - @ApiParam(value = "Find request to filter/limit the search", required = true, name = ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, - @ApiParam(value = "Locale") @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String locale); - - @GET - @Path("/{logUUID}") - @ApiOperation(value = "Retrieve a specific log detail", response = ActivityLogWrapper.class) - ActivityLogWrapper retrieve(@ApiParam(value = "The unique log identifier") @PathParam("logUUID") String logUUID); } diff --git a/src/main/java/com/databasepreservation/common/client/services/AuthenticationService.java b/src/main/java/com/databasepreservation/common/client/services/AuthenticationService.java index 1e88c2d2d..7e3bc939a 100644 --- a/src/main/java/com/databasepreservation/common/client/services/AuthenticationService.java +++ b/src/main/java/com/databasepreservation/common/client/services/AuthenticationService.java @@ -23,16 +23,17 @@ import com.databasepreservation.common.client.models.user.User; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Gabriel Barros */ @Path(".." + ViewerConstants.ENDPOINT_AUTHENTICATION) -@Api(value = AuthenticationService.SWAGGER_ENDPOINT) +@Tag(name = AuthenticationService.SWAGGER_ENDPOINT) public interface AuthenticationService extends DirectRestService { public static final String SWAGGER_ENDPOINT = "v1 authentication"; + class Util { /** * @return the singleton instance @@ -56,12 +57,12 @@ public static AuthenticationService call(Consumer callback, Consumer */ @Path(".." + ViewerConstants.ENDPOINT_CLIENT_LOGGER) -@Api(value = ClientLoggerService.SWAGGER_ENDPOINT) +@Tag(name = ClientLoggerService.SWAGGER_ENDPOINT) public interface ClientLoggerService extends DirectRestService { public static final String SWAGGER_ENDPOINT = "v1 client logger"; @@ -56,13 +57,13 @@ public static ClientLoggerService call(Consumer callback, Consumer */ @Path(".." + ViewerConstants.ENDPOINT_DATABASE) -@Api(value = CollectionService.SWAGGER_ENDPOINT) +@Tag(name = CollectionService.SWAGGER_ENDPOINT) public interface CollectionService extends DirectRestService { String SWAGGER_ENDPOINT = "v1 collection"; @@ -75,80 +75,80 @@ public static CollectionService call(Consumer callback, Consumer @POST @Path("{databaseUUID}/collection") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "Creates a collection for a database", notes = "", response = String.class) + @Operation(summary = "Creates a collection for a database") String createCollection(@PathParam("databaseUUID") String databaseUUID); @GET @Path("{databaseUUID}/collection/{collectionUUID}/status") - @ApiOperation(value = "Retrieves the progress data associated with an action done in the database", notes = "", response = ProgressData.class) - ProgressData getProgressData(@PathParam("databaseUUID") String databaseUUID); + @Operation(summary = "Retrieves the progress data associated with an action done in the database") + ProgressData getProgressData(@PathParam("databaseUUID") String databaseUUID, @PathParam("collectionUUID") String collectionUUID); @DELETE @Path("{databaseUUID}/collection/{collectionUUID}") - @ApiOperation(value = "Deletes the collection for a specific database", notes = "", response = Boolean.class) - Boolean deleteCollection(@PathParam("databaseUUID") String databaseUUID); + @Operation(summary = "Deletes the collection for a specific database") + Boolean deleteCollection(@PathParam("databaseUUID") String databaseUUID, @PathParam("collectionUUID") String collectionUUID); /******************************************************************************* * Collection Resource - Config Sub-resource *******************************************************************************/ @GET @Path("{databaseUUID}/collection/{collectionUUID}/config") - @ApiOperation(value = "Gets the internal collection configuration", response = CollectionStatus.class) + @Operation(summary = "Gets the internal collection configuration") List getCollectionConfiguration(@PathParam("databaseUUID") String databaseUUID, - @PathParam("databaseUUID") String collectionUUID); + @PathParam("collectionUUID") String collectionUUID); @PUT @Path("{databaseUUID}/collection/{collectionUUID}/config") - @ApiOperation(value = "Updates the internal collection configuration", response = Boolean.class) + @Operation(summary = "Updates the internal collection configuration") Boolean updateCollectionConfiguration(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, - @ApiParam(value = "collectionStatus", required = true) CollectionStatus status); + @PathParam("collectionUUID") String collectionUUID, + @Parameter(name = "collectionStatus", required = true) CollectionStatus status); /******************************************************************************* * Collection Resource - Config Sub-resource - Denormalization Sub-resource *******************************************************************************/ @GET @Path("{databaseUUID}/collection/{collectionUUID}/config/{tableUUID}") - @ApiOperation(value = "Gets the denormalization configuration file for a certain table within a database", response = DenormalizeConfiguration.class) + @Operation(summary = "Gets the denormalization configuration file for a certain table within a database") DenormalizeConfiguration getDenormalizeConfigurationFile(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID); + @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID); @POST @Path("{databaseUUID}/collection/{collectionUUID}/config/{tableUUID}") - @ApiOperation(value = "Creates the denormalization configuration file for a certain table within a database", response = Boolean.class) + @Operation(summary = "Creates the denormalization configuration file for a certain table within a database") Boolean createDenormalizeConfigurationFile(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID, - DenormalizeConfiguration configuration); + @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID, + DenormalizeConfiguration configuration); @DELETE @Path("{databaseUUID}/collection/{collectionUUID}/config/{tableUUID}") - @ApiOperation(value = "Deletes the denormalization configuration file for a certain table within a database", response = Boolean.class) + @Operation(summary = "Deletes the denormalization configuration file for a certain table within a database") Boolean deleteDenormalizeConfigurationFile(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID); + @PathParam("collectionUUID") String collectionUUID, @PathParam("tableUUID") String tableUUID); @GET @Path("{databaseUUID}/collection/{collectionUUID}/config/{tableUUID}/run") - @ApiOperation(value = "Runs a specific denormalization configuration for a certain table within a database") + @Operation(summary = "Runs a specific denormalization configuration for a certain table within a database") void run(@PathParam("databaseUUID") String databaseUUID, @PathParam("collectionUUID") String collectionUUID, - @PathParam("tableUUID") String tableUUID); + @PathParam("tableUUID") String tableUUID); /******************************************************************************* * Collection Resource - Data Sub-resource *******************************************************************************/ @POST @Path("{databaseUUID}/collection/{collectionUUID}/data/{schema}/{table}/find") - @ApiOperation(value = "Find all rows for a specific database", notes = "", response = ViewerRow.class, responseContainer = "IndexResult") + @Operation(summary = "Find all rows for a specific database") IndexResult findRows(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("schema") String schema, - @PathParam("table") String table, @ApiParam(ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, - @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); + @PathParam("collectionUUID") String collectionUUID, @PathParam("schema") String schema, + @PathParam("table") String table, @Parameter(name = ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, + @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); @GET @Path("/{databaseUUID}/collection/{collectionUUID}/data/{schema}/{table}/{rowIndex}") - @ApiOperation(value = "Retrieves a specific row within a specific database", notes = "", response = ViewerRow.class) + @Operation(summary = "Retrieves a specific row within a specific database") ViewerRow retrieveRow(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("schema") String schema, - @PathParam("table") String table, @PathParam("rowIndex") String rowIndex); + @PathParam("collectionUUID") String collectionUUID, @PathParam("schema") String schema, + @PathParam("table") String table, @PathParam("rowIndex") String rowIndex); /******************************************************************************* * Collection Resource - SavedSearch Sub-resource @@ -156,38 +156,38 @@ ViewerRow retrieveRow(@PathParam("databaseUUID") String databaseUUID, @POST @Path("/{databaseUUID}/collection/{collectionUUID}/savedSearch/") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "Saves a search for a specific table within a database", notes = "", response = String.class) + @Operation(summary = "Saves a search for a specific table within a database") String saveSavedSearch(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @QueryParam("tableUUID") String tableUUID, - @QueryParam("name") String name, @QueryParam("description") String description, - @ApiParam(ViewerConstants.API_QUERY_PARAM_SEARCH) SearchInfo searchInfo); + @PathParam("collectionUUID") String collectionUUID, @QueryParam("tableUUID") String tableUUID, + @QueryParam("name") String name, @QueryParam("description") String description, + @Parameter(name = ViewerConstants.API_QUERY_PARAM_SEARCH) SearchInfo searchInfo); @POST @Path("/{databaseUUID}/collection/{collectionUUID}/savedSearch/find") - @ApiOperation(value = "Finds all the saved search for a specific database", notes = "", response = SavedSearch.class, responseContainer = "IndexResult") + @Operation(summary = "Finds all the saved search for a specific database") IndexResult findSavedSearches(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, - @ApiParam(ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, - @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); + @PathParam("collectionUUID") String collectionUUID, + @Parameter(name = ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, + @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); @GET @Path("/{databaseUUID}/collection/{collectionUUID}/savedSearch/{savedSearchUUID}") - @ApiOperation(value = "Retrieves a specific saved search for a specific database", notes = "", response = SavedSearch.class) + @Operation(summary = "Retrieves a specific saved search for a specific database") SavedSearch retrieveSavedSearch(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID); + @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID); @PUT @Path("/{databaseUUID}/collection/{collectionUUID}/savedSearch/{savedSearchUUID}") - @ApiOperation(value = "Edits the content of a search", notes = "") + @Operation(summary = "Edits the content of a search") void updateSavedSearch(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID, - @ApiParam(value = "The saved search name", required = true) @QueryParam("name") String name, - @ApiParam(value = "The saved search description", required = true) @QueryParam("description") String description); + @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID, + @Parameter(name = "The saved search name", required = true) @QueryParam("name") String name, + @Parameter(name = "The saved search description", required = true) @QueryParam("description") String description); @DELETE - @ApiOperation(value = "Deletes a specific saved search for a specific database", notes = "") + @Operation(summary = "Deletes a specific saved search for a specific database") @Path("/{databaseUUID}/collection/{collectionUUID}/savedSearch/{savedSearchUUID}") void deleteSavedSearch(@PathParam("databaseUUID") String databaseUUID, - @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID); + @PathParam("collectionUUID") String collectionUUID, @PathParam("savedSearchUUID") String savedSearchUUID); } diff --git a/src/main/java/com/databasepreservation/common/client/services/ContextService.java b/src/main/java/com/databasepreservation/common/client/services/ContextService.java index ecd78ddd2..022bd3ea6 100644 --- a/src/main/java/com/databasepreservation/common/client/services/ContextService.java +++ b/src/main/java/com/databasepreservation/common/client/services/ContextService.java @@ -17,7 +17,6 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; -import io.swagger.annotations.Api; import org.fusesource.restygwt.client.DirectRestService; import org.fusesource.restygwt.client.MethodCallback; import org.fusesource.restygwt.client.REST; @@ -26,13 +25,14 @@ import com.databasepreservation.common.client.common.DefaultMethodCallback; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães */ @Path(".." + ViewerConstants.ENDPOINT_CONTEXT) -@Api(value = ContextService.SWAGGER_ENDPOINT, hidden = true) +@Tag(name = ContextService.SWAGGER_ENDPOINT) public interface ContextService extends DirectRestService { public static final String SWAGGER_ENDPOINT = "v1 context"; @@ -56,18 +56,18 @@ public static ContextService call(Consumer callback) { @GET @Path("/environment") @Produces({MediaType.TEXT_PLAIN}) - @ApiOperation(value = "Retrieves the environment", notes = "", response = String.class) + @Operation(summary = "Retrieves the environment", hidden = true) String getEnvironment(); @GET @Path("/clientMachineHost") @Produces({MediaType.TEXT_PLAIN}) - @ApiOperation(value = "Retrieves the client machine host", notes = "", response = String.class) + @Operation(summary = "Retrieves the client machine host", hidden = true) String getClientMachine(); @GET @Path("/shared/properties") - @ApiOperation(value = "Retrieves the shared properties", notes = "", response = Map.class) + @Operation(summary = "Retrieves the shared properties", hidden = true) Map> getSharedProperties( @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); } diff --git a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java index c66bad12e..718d5a526 100644 --- a/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java +++ b/src/main/java/com/databasepreservation/common/client/services/DatabaseService.java @@ -29,15 +29,15 @@ import com.databasepreservation.common.client.models.structure.ViewerDatabase; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães */ @Path(".." + ViewerConstants.ENDPOINT_DATABASE) -@Api(value = DatabaseService.SWAGGER_ENDPOINT) +@Tag(name = DatabaseService.SWAGGER_ENDPOINT) public interface DatabaseService extends DirectRestService { String SWAGGER_ENDPOINT = "v1 database"; @@ -67,23 +67,23 @@ public static DatabaseService call(Consumer callback, Consumer er *******************************************************************************/ @POST @Path("/find") - @ApiOperation(value = "Finds databases", notes = "", response = ViewerDatabase.class, responseContainer = "IndexResult") - IndexResult find(@ApiParam(ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest filter, - @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); + @Operation(summary = "Finds databases") + IndexResult find(@Parameter(name = ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest filter, + @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String localeString); @POST @Path("/") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "Creates a database", notes = "", response = String.class) - String create(@ApiParam("path") String path); + @Operation(summary = "Creates a database") + String create(@Parameter(name = "path") String path); @GET @Path("/{databaseUUID}") - @ApiOperation(value = "Retrieves a specific database", notes = "", response = ViewerDatabase.class) + @Operation(summary = "Retrieves a specific database") ViewerDatabase retrieve(@PathParam("databaseUUID") String databaseUUID); @DELETE @Path("/{databaseUUID}") - @ApiOperation(value = "Deletes a specific database", notes = "", response = Boolean.class) + @Operation(summary = "Deletes a specific database") Boolean delete(@PathParam("databaseUUID") String databaseUUID); } diff --git a/src/main/java/com/databasepreservation/common/client/services/JobService.java b/src/main/java/com/databasepreservation/common/client/services/JobService.java index 3453869ce..e4ddedf23 100644 --- a/src/main/java/com/databasepreservation/common/client/services/JobService.java +++ b/src/main/java/com/databasepreservation/common/client/services/JobService.java @@ -24,15 +24,15 @@ import com.databasepreservation.common.client.models.structure.ViewerJob; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Gabriel Barros */ @Path(".." + ViewerConstants.ENDPOINT_JOB) -@Api(value = JobService.SWAGGER_ENDPOINT) +@Tag(name = JobService.SWAGGER_ENDPOINT) public interface JobService extends DirectRestService { String SWAGGER_ENDPOINT = "v1 job"; @@ -59,7 +59,7 @@ public static JobService call(Consumer callback, Consumer errorHa @POST @Path("/find") - @ApiOperation(value = "Find all jobs", response = IndexResult.class) - IndexResult find(@ApiParam(ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, - @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String locale); + @Operation(summary = "Find all jobs") + IndexResult find(@Parameter(name = ViewerConstants.API_QUERY_PARAM_FILTER) FindRequest findRequest, + @QueryParam(ViewerConstants.API_QUERY_PARAM_LOCALE) String locale); } diff --git a/src/main/java/com/databasepreservation/common/client/services/MigrationService.java b/src/main/java/com/databasepreservation/common/client/services/MigrationService.java index 4cf1e0fe2..678493c9f 100644 --- a/src/main/java/com/databasepreservation/common/client/services/MigrationService.java +++ b/src/main/java/com/databasepreservation/common/client/services/MigrationService.java @@ -30,15 +30,15 @@ import com.databasepreservation.common.client.models.wizard.connection.ConnectionResponse; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães */ @Path(".." + ViewerConstants.ENDPOINT_MIGRATION) -@Api(value = MigrationService.SWAGGER_ENDPOINT) +@Tag(name = MigrationService.SWAGGER_ENDPOINT) public interface MigrationService extends DirectRestService { public static final String SWAGGER_ENDPOINT = "v1 migration"; @@ -65,40 +65,41 @@ public static MigrationService call(Consumer callback, Consumer e @GET @Path("/siard/modules") - @ApiOperation(value = "Retrieves the DBPTK developer SIARD migration modules", notes = "", response = Module.class, responseContainer = "List") + @Operation(summary = "Retrieves the DBPTK developer SIARD migration modules") List getSiardModules(@QueryParam("type") String type, @QueryParam("moduleName") String moduleName); @GET @Path("/dbms/modules") - @ApiOperation(value = "Retrieves the DBPTK developer DBMS migration modules", notes = "", response = Module.class, responseContainer = "List") + @Operation(summary = "Retrieves the DBPTK developer DBMS migration modules") List getDBMSModules(@QueryParam("type") String type, @QueryParam("moduleName") String moduleName); @GET @Path("/filter/modules") - @ApiOperation(value = "Retrieves the DBPTK developer filter modules", notes = "", response = Module.class, responseContainer = "List") + @Operation(summary = "Retrieves the DBPTK developer filter modules") List getFilterModules(@QueryParam("moduleName") String moduleName); @POST @Path("/dbms/test/connection") - @ApiOperation(value = "Tests the connection to the database", notes = "", response = ConnectionResponse.class) + @Operation(summary = "Tests the connection to the database") ConnectionResponse testConnection( - @ApiParam(value = "DBMS connection parameters") final ConnectionParameters connectionParameters); + @Parameter(name = "DBMS connection parameters") final ConnectionParameters connectionParameters); @POST @Path("/dbms/test/query") - @ApiOperation(value = "Retrieves the first 5 rows of the query execution", notes = "", response = String.class, responseContainer = "List") - List> testQuery(@ApiParam(value = "connection parameters") ConnectionParameters parameters, - @QueryParam("query") String query); + @Operation(summary = "Retrieves the first 5 rows of the query execution") + List> testQuery(@Parameter(name = "connection parameters") ConnectionParameters parameters, + @QueryParam("query") String query); @POST @Path("/dbms/metadata") - @ApiOperation(value = "Retrieves the metadata information associated with the database schema", notes = "", response = ViewerMetadata.class) + @Operation(summary = "Retrieves the metadata information associated with the database schema") ViewerMetadata getMetadata( - @ApiParam(value = "connection parameters") final ConnectionParameters connectionParameters); + @Parameter(name = "connection parameters") final ConnectionParameters connectionParameters); @POST @Path("/run") @Produces(MediaType.TEXT_PLAIN) - @ApiOperation(value = "Performs the migration operation", notes = "", response = String.class) - String run(@QueryParam("databaseUUID") String databaseUUID, @ApiParam("parameters") CreateSIARDParameters parameters); + @Operation(summary = "Performs the migration operation") + String run(@QueryParam("databaseUUID") String databaseUUID, + @Parameter(name = "parameters") CreateSIARDParameters parameters); } diff --git a/src/main/java/com/databasepreservation/common/client/services/SiardService.java b/src/main/java/com/databasepreservation/common/client/services/SiardService.java index 7cbb99e59..407263a8c 100644 --- a/src/main/java/com/databasepreservation/common/client/services/SiardService.java +++ b/src/main/java/com/databasepreservation/common/client/services/SiardService.java @@ -29,15 +29,15 @@ import com.databasepreservation.common.client.models.structure.ViewerMetadata; import com.google.gwt.core.client.GWT; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; /** * @author Miguel Guimarães */ @Path(".." + ViewerConstants.ENDPOINT_DATABASE) -@Api(value = SiardService.SWAGGER_ENDPOINT) +@Tag(name = SiardService.SWAGGER_ENDPOINT) public interface SiardService extends DirectRestService { String SWAGGER_ENDPOINT = "v1 SIARD"; @@ -64,16 +64,16 @@ public static SiardService call(Consumer callback, Consumer error @DELETE @Path("/{databaseUUID}/siard/{siardUUID}") - @ApiOperation(value = "Deletes a specific SIARD file in the storage location", notes = "") + @Operation(summary = "Deletes a specific SIARD file in the storage location") void deleteSIARDFile( - @ApiParam(value = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, + @Parameter(name = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID); @GET @Path("/{databaseUUID}/siard/{siardUUID}") - @ApiOperation(value = "Retrieves the SIARD within a specific database", notes = "", response = ViewerDatabase.class) + @Operation(summary = "Retrieves the SIARD within a specific database") ViewerDatabase getSiard( - @ApiParam(value = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, + @Parameter(name = "The database unique identifier", required = true) @PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID); /******************************************************************************* @@ -81,7 +81,7 @@ ViewerDatabase getSiard( *******************************************************************************/ @POST @Path("/{databaseUUID}/siard/{siardUUID}/validation") - @ApiOperation(value = "Validates the SIARD file against the specification", notes = "", response = Boolean.class) + @Operation(summary = "Validates the SIARD file against the specification") Boolean validateSiard(@PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID, @QueryParam("validationReportPath") String validationReportPath, @QueryParam("allowedTypePath") String allowedTypePath, @@ -89,26 +89,29 @@ Boolean validateSiard(@PathParam("databaseUUID") String databaseUUID, @PathParam @GET @Path("/{databaseUUID}/siard/{siardUUID}/validation/status") - @ApiOperation(value = "Retrieves the validation progress", notes = "", response = ValidationProgressData.class) - ValidationProgressData getValidationProgressData(@PathParam("databaseUUID") String databaseUUID); + @Operation(summary = "Retrieves the validation progress") + ValidationProgressData getValidationProgressData(@PathParam("databaseUUID") String databaseUUID, + @PathParam("siardUUID") String siardUUID); @DELETE @Path("/{databaseUUID}/siard/{siardUUID}/validation") - @ApiOperation(value = "Deletes the report generated for the validation of a SIARD file in the storage location", notes = "") - void deleteValidationReport(@PathParam("databaseUUID") String databaseUUID, @QueryParam("path") String path); + @Operation(summary = "Deletes the report generated for the validation of a SIARD file in the storage location") + void deleteValidationReport(@PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID, + @QueryParam("path") String path); /******************************************************************************* * Metadata Sub-resource *******************************************************************************/ @PUT @Path("/{databaseUUID}/siard/{siardUUID}/metadata") - @ApiOperation(value = "Updates the SIARD metadata information", notes = "", response = ViewerMetadata.class) + @Operation(summary = "Updates the SIARD metadata information") ViewerMetadata updateMetadataInformation(@PathParam("databaseUUID") String databaseUUID, - @PathParam("siardUUID") String siardUUID, @QueryParam("path") String path, SIARDUpdateParameters parameters, @QueryParam("updateOnModel") boolean updateOnModel); + @PathParam("siardUUID") String siardUUID, @QueryParam("path") String path, SIARDUpdateParameters parameters, + @QueryParam("updateOnModel") boolean updateOnModel); @GET @Path("/{databaseUUID}/siard/{siardUUID}/metadata") - @ApiOperation(value = "Gets the SIARD metadata information", notes = "", response = ViewerMetadata.class) + @Operation(summary = "Gets the SIARD metadata information") ViewerMetadata getMetadataInformation(@PathParam("databaseUUID") String databaseUUID, @PathParam("siardUUID") String siardUUID); } diff --git a/src/main/java/com/databasepreservation/common/server/swagger/CombinedSwaggerResourcesProvider.java b/src/main/java/com/databasepreservation/common/server/swagger/CombinedSwaggerResourcesProvider.java deleted file mode 100644 index 1757535e9..000000000 --- a/src/main/java/com/databasepreservation/common/server/swagger/CombinedSwaggerResourcesProvider.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/dbptk-ui - */ -package com.databasepreservation.common.server.swagger; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -import springfox.documentation.swagger.web.InMemorySwaggerResourcesProvider; -import springfox.documentation.swagger.web.SwaggerResource; -import springfox.documentation.swagger.web.SwaggerResourcesProvider; - -/** - * @author Miguel Guimarães - */ -@Component -public class CombinedSwaggerResourcesProvider { - @Primary - @Bean - public SwaggerResourcesProvider swaggerResourcesProvider(InMemorySwaggerResourcesProvider defaultResourcesProvider) { - return () -> { - SwaggerResource wsResource = new SwaggerResource(); - wsResource.setName("DBPTK Enterprise API"); - wsResource.setSwaggerVersion("1.0"); - wsResource.setLocation("/api/swagger.json"); - - List resources = new ArrayList<>(); - resources.add(wsResource); - return resources; - }; - } -} diff --git a/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfig.java b/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfig.java deleted file mode 100644 index 26b6934b6..000000000 --- a/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfig.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/dbptk-ui - */ -package com.databasepreservation.common.server.swagger; - -import java.time.LocalDate; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.ResponseEntity; - -import io.swagger.annotations.Api; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger.web.DocExpansion; -import springfox.documentation.swagger.web.ModelRendering; -import springfox.documentation.swagger.web.OperationsSorter; -import springfox.documentation.swagger.web.TagsSorter; -import springfox.documentation.swagger.web.UiConfiguration; -import springfox.documentation.swagger.web.UiConfigurationBuilder; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * @author Miguel Guimarães - */ - -@Configuration -@EnableSwagger2 -public class SwaggerConfig { - @Bean - public Docket api(SwaggerConfigProperties swaggerConfigProperties) { - return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo(swaggerConfigProperties)) - .enable(Boolean.parseBoolean(swaggerConfigProperties.getEnabled())).select() - .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)).paths(PathSelectors.any()).build().pathMapping("/") - .directModelSubstitute(LocalDate.class, String.class).genericModelSubstitutes(ResponseEntity.class) - .useDefaultResponseMessages(Boolean.parseBoolean(swaggerConfigProperties.getUseDefaultResponseMessages())) - .enableUrlTemplating(Boolean.parseBoolean(swaggerConfigProperties.getEnableUrlTemplating())); - } - - @Bean - UiConfiguration uiConfig(SwaggerConfigProperties swaggerConfigProperties) { - return UiConfigurationBuilder.builder().deepLinking(Boolean.valueOf(swaggerConfigProperties.getDeepLinking())) - .displayOperationId(Boolean.valueOf(swaggerConfigProperties.getDisplayOperationId())) - .defaultModelsExpandDepth(Integer.valueOf(swaggerConfigProperties.getDefaultModelsExpandDepth())) - .defaultModelExpandDepth(Integer.valueOf(swaggerConfigProperties.getDefaultModelExpandDepth())) - .defaultModelRendering(ModelRendering.EXAMPLE) - .displayRequestDuration(Boolean.valueOf(swaggerConfigProperties.getDisplayRequestDuration())) - .docExpansion(DocExpansion.NONE).filter(Boolean.valueOf(swaggerConfigProperties.getFilter())) - .maxDisplayedTags(Integer.valueOf(swaggerConfigProperties.getMaxDisplayedTags())) - .operationsSorter(OperationsSorter.ALPHA) - .showExtensions(Boolean.valueOf(swaggerConfigProperties.getShowExtensions())).tagsSorter(TagsSorter.ALPHA) - .supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS).validatorUrl(null).build(); - } - - private ApiInfo apiInfo(SwaggerConfigProperties swaggerConfigProperties) { - return new ApiInfoBuilder().title(swaggerConfigProperties.getTitle()) - .description(swaggerConfigProperties.getDescription()).version(swaggerConfigProperties.getApiVersion()).build(); - } -} diff --git a/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfigProperties.java b/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfigProperties.java deleted file mode 100644 index 3332a9799..000000000 --- a/src/main/java/com/databasepreservation/common/server/swagger/SwaggerConfigProperties.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE file at the root of the source - * tree and available online at - * - * https://github.com/keeps/dbptk-ui - */ -package com.databasepreservation.common.server.swagger; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Configuration; - -/** - * @author Miguel Guimarães - */ -@Configuration("swaggerConfigProperties") -public class SwaggerConfigProperties { - @Value("${api.version}") - private String apiVersion; - @Value("${swagger.enabled}") - private String enabled = "false"; - @Value("${swagger.title}") - private String title; - @Value("${swagger.description}") - private String description; - @Value("${swagger.useDefaultResponseMessages}") - private String useDefaultResponseMessages; - @Value("${swagger.enableUrlTemplating}") - private String enableUrlTemplating; - @Value("${swagger.deepLinking}") - private String deepLinking; - @Value("${swagger.defaultModelsExpandDepth}") - private String defaultModelsExpandDepth; - @Value("${swagger.defaultModelExpandDepth}") - private String defaultModelExpandDepth; - @Value("${swagger.displayOperationId}") - private String displayOperationId; - @Value("${swagger.displayRequestDuration}") - private String displayRequestDuration; - @Value("${swagger.filter}") - private String filter; - @Value("${swagger.maxDisplayedTags}") - private String maxDisplayedTags; - @Value("${swagger.showExtensions}") - private String showExtensions; - - public String getApiVersion() { - return apiVersion; - } - - public String getEnabled() { - return enabled; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public String getUseDefaultResponseMessages() { - return useDefaultResponseMessages; - } - - public String getEnableUrlTemplating() { - return enableUrlTemplating; - } - - public String getDeepLinking() { - return deepLinking; - } - - public String getDefaultModelsExpandDepth() { - return defaultModelsExpandDepth; - } - - public String getDefaultModelExpandDepth() { - return defaultModelExpandDepth; - } - - public String getDisplayOperationId() { - return displayOperationId; - } - - public String getDisplayRequestDuration() { - return displayRequestDuration; - } - - public String getFilter() { - return filter; - } - - public String getMaxDisplayedTags() { - return maxDisplayedTags; - } - - public String getShowExtensions() { - return showExtensions; - } -} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 10c063106..d97d7d8c6 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ +logging.level.org.springframework.boot.autoconfigure=INFO spring.jersey.type=filter spring.devtools.restart.exclude=static/**,public/**,config/i18n/client/**,com/databasepreservation/server/client/**,com/databasepreservation/desktop/client/* spring.jersey.filter.order=-100000 @@ -9,19 +10,6 @@ spring.datasource.hikari.maximumPoolSize={$BATCH_JOBS_MAX_POOL_SIZE:5} spring.main.banner-mode=off server.use-forward-headers=true api.version=1.0 -swagger.enabled=true -swagger.title=DBPTK Enterprise API -swagger.description= -swagger.useDefaultResponseMessages=false -swagger.enableUrlTemplating=true -swagger.deepLinking=true -swagger.defaultModelsExpandDepth=1 -swagger.defaultModelExpandDepth=1 -swagger.displayOperationId=false -swagger.displayRequestDuration=false -swagger.filter=false -swagger.maxDisplayedTags=0 -swagger.showExtensions=false org.quartz.scheduler.instanceName = MyScheduler org.quartz.threadPool.threadCount = 1 org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore diff --git a/src/main/resources/config/dbvtk-viewer.properties b/src/main/resources/config/dbvtk-viewer.properties index 53e085a1e..b8ca51625 100644 --- a/src/main/resources/config/dbvtk-viewer.properties +++ b/src/main/resources/config/dbvtk-viewer.properties @@ -16,7 +16,7 @@ ui.sharedProperties.whitelist.messages.prefix=ui.facets ############################################## # Management ############################################## -manage.upload.basePath=/siard-path +#manage.upload.basePath=/siard-path ############################################## # Solr ############################################## @@ -44,9 +44,7 @@ ui.filter.cas.enabled=false ui.filter.cas.casServerUrlPrefix=${env:CAS_INTERNAL_URL}/cas ui.filter.cas.casServerLoginUrl=${env:CAS_EXTERNAL_URL}/cas/login ui.filter.cas.casServerLogoutUrl=${env:CAS_EXTERNAL_URL}/cas/logout -ui.filter.cas.exclusions=^/swagger.json,^/v1/theme/?,^/v1/auth/ticket? -ui.filter.cas.proxyCallbackUrl=${env:DBPTKE_INTERNAL_URL}/callback -ui.filter.cas.proxyReceptorUrl=/callback +ui.filter.cas.exclusions=^/openapi.json,^/v1/theme/?,^/v1/auth/ticket? ############################################## # DBPTK Enterprise base address ############################################## @@ -73,9 +71,9 @@ user.attribute.roles.users=users ############################################## # Protected Resources ############################################## -ui.filter.onOff.protectedResourcesAllowAllIPs=true -ui.filter.onOff.protectedResourcesWhitelistedIP[].ip=127.0.0.1 -ui.filter.onOff.protectedResourcesWhitelistedIP[].username=localhost-whitelist-access +#ui.filter.onOff.protectedResourcesAllowAllIPs=false +#ui.filter.onOff.protectedResourcesWhitelistedIP[].ip=127.0.0.1 +#ui.filter.onOff.protectedResourcesWhitelistedIP[].username=localhost-whitelist-access ############################################## # Facets ############################################## @@ -118,4 +116,3 @@ ui.blob.autoDetect.mimeType.onColumn=false # BLOB ############################################## ui.blob.prefix.name=record - diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index ae167e317..265a5ceff 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -248,7 +248,7 @@ org.glassfish.jersey.servlet.ServletContainer javax.ws.rs.Application - com.databasepreservation.common.api.RestApplication + com.databasepreservation.common.api.RestApplicationNoSwagger 2