Commit 31638a0e authored by Matija Obreza's avatar Matija Obreza
Browse files

REST /datasets/{id}/methods

parent 2bcfc928
......@@ -31,7 +31,9 @@ import org.genesys2.server.exception.AuthorizationException;
import org.genesys2.server.model.genesys.Metadata;
import org.genesys2.server.service.CropService;
import org.genesys2.server.service.DatasetService;
import org.genesys2.server.service.GenesysService;
import org.genesys2.server.service.TraitService;
import org.genesys2.spring.ResourceNotFoundException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
......@@ -50,6 +52,9 @@ public class DatasetController extends RestController {
@Autowired
DatasetService datasetService;
@Autowired
GenesysService genesysService;
@Autowired
TraitService traitService;
......@@ -91,7 +96,7 @@ public class DatasetController extends RestController {
}
/**
* Get crop details /crops/{shortName}
* Get metadata details /datasets/{shortName}
*
* @return
* @throws AuthorizationException
......@@ -103,6 +108,23 @@ public class DatasetController extends RestController {
return OAuth2Cleanup.clean(datasetService.getDataset(metadataId));
}
/**
* Get metadata Methods /datasets/{shortName}/methods
*
* @return
* @throws AuthorizationException
*/
@RequestMapping(value = "/{metadataId:.+}/methods", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody
Object getMetadataMethods(@PathVariable("metadataId") Long metadataId) throws AuthorizationException {
LOG.info("Getting metadata methods for " + metadataId);
Metadata metadata = datasetService.getDataset(metadataId);
if (metadata == null) {
throw new ResourceNotFoundException();
}
return OAuth2Cleanup.clean(genesysService.listMethods(metadata));
}
public static class MetadataJson {
@NotBlank
@NotNull
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment