added apidescriptor

This commit is contained in:
enricoottonello 2019-04-03 16:03:44 +02:00
parent b316467608
commit 2f79eb930a
3 changed files with 27 additions and 0 deletions

View File

@ -65,6 +65,18 @@ public class MDStoreController {
return mdstoreWithInfoRepository.findById(mdId).orElseThrow(() -> new NoContentException("Missing mdstore: " + mdId)); return mdstoreWithInfoRepository.findById(mdId).orElseThrow(() -> new NoContentException("Missing mdstore: " + mdId));
} }
@Transactional
@ApiOperation(value = "Increase the read count of the current mdstore")
@RequestMapping(value = "/mdstore/{mdId}/startReading", method = RequestMethod.GET)
public MDStoreVersion startReading(@ApiParam("the mdstore identifier") @PathVariable final String mdId) throws NoContentException {
final MDStoreCurrentVersion cv = mdstoreCurrentVersionRepository.findById(mdId).orElseThrow(() -> new NoContentException("Missing mdstore: " + mdId));
final MDStoreVersion v = mdstoreVersionRepository.findById(cv.getCurrentVersion())
.orElseThrow(() -> new NoContentException("Missing version: " + cv.getCurrentVersion()));
v.setReadCount(v.getReadCount() + 1);
mdstoreVersionRepository.save(v);
return v;
}
@ApiOperation(value = "Return the number of mdstores") @ApiOperation(value = "Return the number of mdstores")
@RequestMapping(value = "/count", method = RequestMethod.GET) @RequestMapping(value = "/count", method = RequestMethod.GET)
public long count() { public long count() {
@ -165,6 +177,16 @@ public class MDStoreController {
_deleteVersion(versionId, force); _deleteVersion(versionId, force);
} }
@Transactional
@ApiOperation(value = "Decrease the read count of a mdstore version")
@RequestMapping(value = "/version/{versionId}/endReading", method = RequestMethod.GET)
public MDStoreVersion endReading(@ApiParam("the id of the version that has been completely read") @PathVariable final String versionId)
throws MDStoreManagerException {
final MDStoreVersion v = mdstoreVersionRepository.findById(versionId).orElseThrow(() -> new MDStoreManagerException("Version not found"));
v.setReadCount(v.getReadCount() - 1);
return v;
}
@Transactional @Transactional
@ApiOperation(value = "Delete multiple mdstore versions") @ApiOperation(value = "Delete multiple mdstore versions")
@RequestMapping(value = "/versions/deleteList", method = RequestMethod.POST) @RequestMapping(value = "/versions/deleteList", method = RequestMethod.POST)

View File

@ -29,6 +29,11 @@
</repositories> </repositories>
<dependencies> <dependencies>
<dependency>
<groupId>eu.dnetlib.dhp</groupId>
<artifactId>dhp-common</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId> <artifactId>spring-boot-starter</artifactId>