partial migration to new openAPI
This commit is contained in:
parent
834c21ffc8
commit
e037cd0b41
|
@ -1,53 +1,46 @@
|
|||
package eu.dnetlib.data.mdstore.manager;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springdoc.core.GroupedOpenApi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.domain.EntityScan;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@EntityScan("eu.dnetlib.dhp.schema.mdstore")
|
||||
public class MainApplication extends AbstractDnetApp {
|
||||
|
||||
@Value("${dhp.swagger.api.host}")
|
||||
private String swaggetHost;
|
||||
|
||||
@Value("${dhp.swagger.api.basePath}")
|
||||
private String swaggerPath;
|
||||
|
||||
public static void main(final String[] args) {
|
||||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi publicApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("MDStore APIs")
|
||||
.pathsToMatch("**/mdstores/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket
|
||||
.host(swaggetHost)
|
||||
.pathMapping(swaggerPath)
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.contains("/mdstores"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("MDStore Manager APIs")
|
||||
protected void configSwagger(final OpenAPI openApi) {
|
||||
openApi.info(new Info().title("MDStore Manager APIs")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,15 +23,13 @@ import eu.dnetlib.data.mdstore.manager.utils.DatabaseUtils;
|
|||
import eu.dnetlib.data.mdstore.manager.utils.HdfsClient;
|
||||
import eu.dnetlib.dhp.schema.mdstore.MDStoreVersion;
|
||||
import eu.dnetlib.dhp.schema.mdstore.MDStoreWithInfo;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/mdstores")
|
||||
@Tag(tags = {
|
||||
"Metadata Stores"
|
||||
})
|
||||
@Tag(name = "Metadata Stores")
|
||||
public class MDStoreController extends AbstractDnetController {
|
||||
|
||||
@Autowired
|
||||
|
@ -56,32 +54,32 @@ public class MDStoreController extends AbstractDnetController {
|
|||
|
||||
@Operation(summary = "Return a mdstores by id")
|
||||
@GetMapping("/mdstore/{mdId}")
|
||||
public MDStoreWithInfo getMdStore(@Parameter("the mdstore identifier") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
public MDStoreWithInfo getMdStore(@Parameter(name = "the mdstore identifier") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
return databaseUtils.findMdStore(mdId);
|
||||
}
|
||||
|
||||
@Operation(summary = "Increase the read count of the current mdstore")
|
||||
@GetMapping("/mdstore/{mdId}/startReading")
|
||||
public MDStoreVersion startReading(@Parameter("the mdstore identifier") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
public MDStoreVersion startReading(@Parameter(name = "the mdstore identifier") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
return databaseUtils.startReading(mdId);
|
||||
}
|
||||
|
||||
@Operation(summary = "Create a new mdstore")
|
||||
@GetMapping("/new/{format}/{layout}/{interpretation}")
|
||||
public MDStoreWithInfo createMDStore(
|
||||
@Parameter("mdstore format") @PathVariable final String format,
|
||||
@Parameter("mdstore layout") @PathVariable final String layout,
|
||||
@Parameter("mdstore interpretation") @PathVariable final String interpretation,
|
||||
@Parameter("datasource name") @RequestParam(required = true) final String dsName,
|
||||
@Parameter("datasource id") @RequestParam(required = true) final String dsId,
|
||||
@Parameter("api id") @RequestParam(required = true) final String apiId) throws MDStoreManagerException {
|
||||
@Parameter(name = "mdstore format") @PathVariable final String format,
|
||||
@Parameter(name = "mdstore layout") @PathVariable final String layout,
|
||||
@Parameter(name = "mdstore interpretation") @PathVariable final String interpretation,
|
||||
@Parameter(name = "datasource name") @RequestParam(required = true) final String dsName,
|
||||
@Parameter(name = "datasource id") @RequestParam(required = true) final String dsId,
|
||||
@Parameter(name = "api id") @RequestParam(required = true) final String apiId) throws MDStoreManagerException {
|
||||
final String id = databaseUtils.createMDStore(format, layout, interpretation, dsName, dsId, apiId);
|
||||
return databaseUtils.findMdStore(id);
|
||||
}
|
||||
|
||||
@Operation(summary = "Delete a mdstore by id")
|
||||
@DeleteMapping("/mdstore/{mdId}")
|
||||
public StatusResponse delete(@Parameter("the id of the mdstore that will be deleted") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
public StatusResponse delete(@Parameter(name = "the id of the mdstore that will be deleted") @PathVariable final String mdId) throws MDStoreManagerException {
|
||||
final String hdfsPath = databaseUtils.deleteMdStore(mdId);
|
||||
hdfsClient.deletePath(hdfsPath);
|
||||
return StatusResponse.DELETED;
|
||||
|
@ -95,14 +93,14 @@ public class MDStoreController extends AbstractDnetController {
|
|||
|
||||
@Operation(summary = "Create a new preliminary version of a mdstore")
|
||||
@GetMapping("/mdstore/{mdId}/newVersion")
|
||||
public MDStoreVersion prepareNewVersion(@Parameter("the id of the mdstore for which will be created a new version") @PathVariable final String mdId) {
|
||||
public MDStoreVersion prepareNewVersion(@Parameter(name = "the id of the mdstore for which will be created a new version") @PathVariable final String mdId) {
|
||||
return databaseUtils.prepareMdStoreVersion(mdId);
|
||||
}
|
||||
|
||||
@Operation(summary = "Promote a preliminary version to current")
|
||||
@GetMapping("/version/{versionId}/commit/{size}")
|
||||
public MDStoreVersion commitVersion(@Parameter("the id of the version that will be promoted to the current version") @PathVariable final String versionId,
|
||||
@Parameter("the size of the new current mdstore") @PathVariable final long size) throws MDStoreManagerException {
|
||||
public MDStoreVersion commitVersion(@Parameter(name = "the id of the version that will be promoted to the current version") @PathVariable final String versionId,
|
||||
@Parameter(name = "the size of the new current mdstore") @PathVariable final long size) throws MDStoreManagerException {
|
||||
try {
|
||||
return databaseUtils.commitMdStoreVersion(versionId, size);
|
||||
} finally {
|
||||
|
@ -112,7 +110,7 @@ public class MDStoreController extends AbstractDnetController {
|
|||
|
||||
@Operation(summary = "Abort a preliminary version")
|
||||
@GetMapping("/version/{versionId}/abort")
|
||||
public StatusResponse commitVersion(@Parameter("the id of the version to abort") @PathVariable final String versionId) throws MDStoreManagerException {
|
||||
public StatusResponse commitVersion(@Parameter(name = "the id of the version to abort") @PathVariable final String versionId) throws MDStoreManagerException {
|
||||
final String hdfsPath = databaseUtils.deleteMdStoreVersion(versionId, true);
|
||||
hdfsClient.deletePath(hdfsPath);
|
||||
return StatusResponse.ABORTED;
|
||||
|
@ -120,15 +118,15 @@ public class MDStoreController extends AbstractDnetController {
|
|||
|
||||
@Operation(summary = "Return an existing mdstore version")
|
||||
@GetMapping("/version/{versionId}")
|
||||
public MDStoreVersion getVersion(@Parameter("the id of the version that has to be deleted") @PathVariable final String versionId)
|
||||
public MDStoreVersion getVersion(@Parameter(name = "the id of the version that has to be deleted") @PathVariable final String versionId)
|
||||
throws MDStoreManagerException {
|
||||
return databaseUtils.findVersion(versionId);
|
||||
}
|
||||
|
||||
@Operation(summary = "Delete a mdstore version")
|
||||
@DeleteMapping("/version/{versionId}")
|
||||
public StatusResponse deleteVersion(@Parameter("the id of the version that has to be deleted") @PathVariable final String versionId,
|
||||
@Parameter("if true, the controls on writing and readcount values will be skipped") @RequestParam(required = false, defaultValue = "false") final boolean force)
|
||||
public StatusResponse deleteVersion(@Parameter(name = "the id of the version that has to be deleted") @PathVariable final String versionId,
|
||||
@Parameter(name = "if true, the controls on writing and readcount values will be skipped") @RequestParam(required = false, defaultValue = "false") final boolean force)
|
||||
throws MDStoreManagerException {
|
||||
final String hdfsPath = databaseUtils.deleteMdStoreVersion(versionId, force);
|
||||
hdfsClient.deletePath(hdfsPath);
|
||||
|
@ -137,14 +135,14 @@ public class MDStoreController extends AbstractDnetController {
|
|||
|
||||
@Operation(summary = "Decrease the read count of a mdstore version")
|
||||
@GetMapping("/version/{versionId}/endReading")
|
||||
public MDStoreVersion endReading(@Parameter("the id of the version that has been completely read") @PathVariable final String versionId)
|
||||
public MDStoreVersion endReading(@Parameter(name = "the id of the version that has been completely read") @PathVariable final String versionId)
|
||||
throws MDStoreManagerException {
|
||||
return databaseUtils.endReading(versionId);
|
||||
}
|
||||
|
||||
@Operation(summary = "Reset the read count of a mdstore version")
|
||||
@GetMapping("/version/{versionId}/resetReading")
|
||||
public MDStoreVersion resetReading(@Parameter("the id of the version") @PathVariable final String versionId)
|
||||
public MDStoreVersion resetReading(@Parameter(name = "the id of the version") @PathVariable final String versionId)
|
||||
throws MDStoreManagerException {
|
||||
return databaseUtils.resetReading(versionId);
|
||||
}
|
||||
|
@ -172,7 +170,7 @@ public class MDStoreController extends AbstractDnetController {
|
|||
@Operation(summary = "Fix the inconsistencies on HDFS")
|
||||
@GetMapping("/hdfs/inconsistencies")
|
||||
public Set<String> fixHdfsInconsistencies(
|
||||
@Parameter("force the deletion of hdfs paths") @RequestParam(required = false, defaultValue = "false") final boolean delete)
|
||||
@Parameter(name = "force the deletion of hdfs paths") @RequestParam(required = false, defaultValue = "false") final boolean delete)
|
||||
throws MDStoreManagerException {
|
||||
|
||||
final Set<String> hdfsDirs = hdfsClient.listHadoopDirs();
|
||||
|
|
|
@ -42,5 +42,5 @@ dhp.mdstore-manager.hadoop.zeppelin.name-prefix = mdstoreManager
|
|||
|
||||
dhp.mdstore-manager.inspector.records.max = 1000
|
||||
|
||||
dhp.swagger.api.host = localhost
|
||||
dhp.swagger.api.basePath = /
|
||||
# dhp.swagger.api.host = localhost
|
||||
dhp.swagger.api.basePath = /**
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package eu.dnetlib.organizations;
|
||||
|
||||
import org.springdoc.core.GroupedOpenApi;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import eu.dnetlib.common.app.AbstractDnetApp;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.info.License;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableSwagger2
|
||||
@EnableCaching
|
||||
@EnableScheduling
|
||||
@ComponentScan(basePackages = "eu.dnetlib")
|
||||
|
@ -24,20 +24,23 @@ public class MainApplication extends AbstractDnetApp {
|
|||
SpringApplication.run(MainApplication.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi publicApi() {
|
||||
return GroupedOpenApi.builder()
|
||||
.group("D-Net Organizations Service APIs")
|
||||
.pathsToMatch("/api/**", "/oa_api/**")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configSwagger(final Docket docket) {
|
||||
docket.select()
|
||||
.apis(RequestHandlerSelectors.any())
|
||||
.paths(p -> p.startsWith("/api/") || p.startsWith("/oa_api"))
|
||||
.build()
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("D-Net Organizations Service APIs")
|
||||
protected void configSwagger(final OpenAPI openApi) {
|
||||
openApi.info(new Info().title("D-Net Organizations Service APIs\"")
|
||||
.description("APIs documentation")
|
||||
.version("1.1")
|
||||
.contact(ApiInfo.DEFAULT_CONTACT)
|
||||
.license("Apache 2.0")
|
||||
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0")
|
||||
.build());
|
||||
.license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0")))
|
||||
.externalDocs(new ExternalDocumentation()
|
||||
.description("SpringShop Wiki Documentation")
|
||||
.url("https://springshop.wiki.github.org/docs"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue