Commit b440b739 authored by Matija Obreza's avatar Matija Obreza

Merge branch '373-accession-v1-api' into 'master'

Resolve "Accession v1 API"

Closes #373

See merge request genesys-pgr/genesys-server!288
parents 473f89b2 3cfdd633
......@@ -79,14 +79,14 @@ import io.swagger.annotations.Api;
*/
@RestController("accessionApi1")
@PreAuthorize("isAuthenticated()")
@RequestMapping(AccessionController.API_BASE)
@RequestMapping(AccessionController.CONTROLLER_URL)
@Api(tags = { "accession" })
public class AccessionController {
private static final Logger LOG = LoggerFactory.getLogger(AccessionController.class);
/** The Constant API_BASE. */
public static final String API_BASE = ApiBaseController.APIv1_BASE + "/acn";
/** The Constant CONTROLLER_URL. */
public static final String CONTROLLER_URL = ApiBaseController.APIv1_BASE + "/acn";
private static final int DOWNLOAD_LIMIT = 200000;
......@@ -121,9 +121,9 @@ public class AccessionController {
* @param uuid the uuid
* @return the subset
*/
@GetMapping(value = "/{UUID:\\w{8}\\-\\w{4}.+}", produces = { MediaType.APPLICATION_JSON_VALUE })
@GetMapping(value = "/{uuid:\\w{8}\\-\\w{4}.+}", produces = { MediaType.APPLICATION_JSON_VALUE })
@JsonView({ JsonViews.Protected.class })
public Accession getByUuid(@PathVariable("UUID") final UUID uuid) {
public Accession getByUuid(@PathVariable("uuid") final UUID uuid) {
return accessionService.getByUuid(uuid);
}
......@@ -215,9 +215,9 @@ public class AccessionController {
return accessionService.getAccessionDetails(accession);
}
@GetMapping(value = "/details/{UUID:\\w{8}\\-\\w{4}.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "/details/{uuid:\\w{8}\\-\\w{4}.+}", produces = MediaType.APPLICATION_JSON_VALUE)
@JsonView(JsonViews.Root.class)
public AccessionService.AccessionDetails getAccessionDetailsByUUID(@PathVariable("UUID") final UUID uuid) {
public AccessionService.AccessionDetails getAccessionDetailsByUUID(@PathVariable("uuid") final UUID uuid) {
Accession accession = accessionService.getByUuid(uuid);
return accessionService.getAccessionDetails(accession);
}
......
/*
* Copyright 2018 Global Crop Diversity Trust
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.genesys2.server.api.v1;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.genesys2.server.api.ApiBaseController;
import org.genesys2.server.api.PleaseRetryException;
import org.genesys2.server.api.model.AccessionHeaderJson;
import org.genesys2.server.exception.InvalidApiUsageException;
import org.genesys2.server.model.impl.FaoInstitute;
import org.genesys2.server.service.InstituteService;
import org.genesys2.server.service.impl.RESTApiException;
import org.genesys2.server.service.worker.AccessionOpResponse;
import org.genesys2.server.service.worker.AccessionOpResponse.UpsertResult;
import org.genesys2.server.service.worker.AccessionUploader;
import org.genesys2.spring.ResourceNotFoundException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.CannotAcquireLockException;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.TransactionException;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import io.swagger.annotations.Api;
/**
* Accession API v1: the uploader.
*/
@RestController("accessionUploadApi1")
@PreAuthorize("isAuthenticated()")
@RequestMapping(AccessionUploadController.CONTROLLER_URL)
@Api(tags = { "accession" })
public class AccessionUploadController {
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(AccessionUploadController.class);
/** The Constant CONTROLLER_URL. */
public static final String CONTROLLER_URL = ApiBaseController.APIv1_BASE + "/acn";
/** The Constant UPLOAD_RETRIES. */
private static final int UPLOAD_RETRIES = 10;
/** The uploader. */
@Autowired
private AccessionUploader uploader;
/** The institute service. */
@Autowired
InstituteService instituteService;
/**
* Update accessions in the system.
*
* @param instCode the WIEWS institute code
* @param updates the updates
* @return the list
* @throws Exception the exception
*/
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{instCode}/upsert", method = { RequestMethod.POST }, produces = { MediaType.APPLICATION_JSON_VALUE })
public List<AccessionOpResponse> upsertInstituteAccession(@PathVariable("instCode") String instCode, @RequestBody ArrayNode updates) throws Exception {
StopWatch stopWatch = StopWatch.createStarted();
LOG.trace("Received:\n {}", updates);
// User's permission to WRITE to this WIEWS institute are checked in
// BatchRESTService.
final FaoInstitute institute = instituteService.getInstitute(instCode);
if (institute == null) {
throw new ResourceNotFoundException();
}
for (int tryCount = 0; tryCount < UPLOAD_RETRIES; tryCount++) {
try {
List<AccessionOpResponse> res = uploader.upsertAccessions(institute, updates);
LOG.info("Processed {} accessions for {} in {} tries in {}ms", updates.size(), instCode, tryCount + 1, stopWatch.getTime());
return res;
} catch (DataAccessException | TransactionException | PersistenceException e) {
List<AccessionOpResponse> res = upsert1By1(institute, updates);
LOG.info("Processed {} accessions for {} 1by1 after {} tries in {}ms because of {}", updates.size(), instCode, tryCount + 1, stopWatch.getTime(), e.getMessage());
return res;
} catch (PleaseRetryException e) {
LOG.error("Retry {} of {} tries due to: {}", tryCount, UPLOAD_RETRIES, e.getMessage());
// Wait a bit
Thread.sleep((long) (RandomUtils.nextDouble(10, 100) * tryCount));
}
}
throw new InvalidApiUsageException("Just couldn't do it.");
}
/**
* Upsert 1 by 1.
*
* @param institute the institute
* @param updates the updates
* @return the list
* @throws Exception the exception
*/
private List<AccessionOpResponse> upsert1By1(FaoInstitute institute, ArrayNode updates) throws Exception {
List<AccessionOpResponse> response = new ArrayList<>();
ArrayNode single = new ObjectMapper().createArrayNode();
for (JsonNode update : updates) {
single.removeAll();
single.add(update);
Throwable lastException = null;
for (int tryCount = 0; tryCount < UPLOAD_RETRIES; tryCount++) {
try {
response.addAll(uploader.upsertAccessions(institute, single));
lastException = null;
break;
} catch (TransactionException | RollbackException | CannotAcquireLockException | DataIntegrityViolationException | PleaseRetryException e) {
lastException = e;
if (tryCount > 1) {
LOG.info("Retry {} of {} tries due to: {}", tryCount, UPLOAD_RETRIES, e.getMessage());
} else {
LOG.debug("Retrying {} of {} tries due to: {}", tryCount, UPLOAD_RETRIES, e.getMessage());
}
// Wait a bit
Thread.sleep((long) (RandomUtils.nextDouble(10, 100) * tryCount));
}
}
if (lastException != null) {
LOG.warn("Upsert failed due to: {} data={}", lastException.getMessage(), update, lastException);
// record error
response.add(new AccessionOpResponse(update.get("instituteCode").asText(), update.get("accessionNumber").asText(), update.get("taxonomy").get("genus").asText())
.setResult(new UpsertResult(UpsertResult.Type.ERROR)).setError(getDetailedErrorMessage(lastException)));
}
}
return response;
}
/**
* Delete accessions by instituteCode, acceNumb and genus.
*
* @param instCode the inst code
* @param batch the batch
* @return the list
* @throws RESTApiException the REST api exception
*/
@PreAuthorize("isAuthenticated()")
@RequestMapping(value = "/{instCode}/delete", method = { RequestMethod.POST }, consumes = { MediaType.APPLICATION_JSON_VALUE }, produces = {
MediaType.APPLICATION_JSON_VALUE })
public @ResponseBody List<AccessionOpResponse> deleteAccessions(@PathVariable("instCode") String instCode, @RequestBody List<AccessionHeaderJson> batch) throws RESTApiException {
// User's permission to WRITE to this WIEWS institute are checked in
// BatchRESTService.
final FaoInstitute institute = instituteService.getInstitute(instCode);
if (institute == null) {
throw new ResourceNotFoundException();
}
try {
List<AccessionOpResponse> response = null;
try {
response = uploader.deleteAccessions(institute, batch);
LOG.info("Deleted {} accessions from {}", response.size(), instCode);
} catch (DataAccessException | TransactionException | PersistenceException e) {
LOG.info("Retrying delete one by one due to {}", e.getMessage());
response = deleteAccessions1by1(institute, batch);
}
return response;
} catch (CannotAcquireLockException e) {
throw new PleaseRetryException("Operation failed, please retry.", e);
}
}
/**
* Delete accessions 1 by 1.
*
* @param institute the institute
* @param batch the batch
* @return the list
*/
private List<AccessionOpResponse> deleteAccessions1by1(FaoInstitute institute, List<AccessionHeaderJson> batch) {
LOG.info("Attempting delete 1 by 1");
final List<AccessionHeaderJson> batchOfOne = new ArrayList<AccessionHeaderJson>();
List<AccessionOpResponse> response = new ArrayList<AccessionOpResponse>();
for (AccessionHeaderJson acceJ : batch) {
try {
batchOfOne.clear();
batchOfOne.add(acceJ);
AccessionOpResponse accessionResponse = uploader.deleteAccessions(institute, batchOfOne).get(0);
response.add(accessionResponse);
} catch (Throwable e) {
if (LOG.isInfoEnabled()) {
LOG.info("Error deleting {}: {}", acceJ.instCode, e.getMessage());
}
AccessionOpResponse accessionResponse = new AccessionOpResponse(acceJ.instCode, acceJ.acceNumb, acceJ.genus);
accessionResponse.setError(getDetailedErrorMessage(e));
response.add(accessionResponse);
}
}
return response;
}
/**
* Gets the detailed error message.
*
* @param e the exception
* @return the detailed error message
*/
private String getDetailedErrorMessage(Throwable e) {
StringBuffer sb=new StringBuffer(e.getMessage());
Throwable r = e;
while ((r = r.getCause()) !=null) {
sb.append("\n" + r.getMessage());
}
return sb.toString();
}
}
......@@ -75,9 +75,9 @@ public class DatasetController extends ApiBaseController {
// Rest controller base URL
public static final String CONTROLLER_URL = ApiBaseController.APIv1_BASE + "/dataset";
public static final String CREATOR_URL = "/{UUID}/datasetcreator";
public static final String FILES_URL = "/{UUID}/files";
protected static final String LOCATION_URL = "/{UUID}/location";
public static final String CREATOR_URL = "/{uuid}/datasetcreator";
public static final String FILES_URL = "/{uuid}/files";
protected static final String LOCATION_URL = "/{uuid}/location";
/** The dataset service. */
@Autowired
......@@ -124,8 +124,8 @@ public class DatasetController extends ApiBaseController {
* @return the dataset
* @throws NotFoundElement the not found element
*/
@GetMapping(value = "/{UUID}")
public Dataset getDataset(@PathVariable("UUID") final UUID uuid) throws NotFoundElement {
@GetMapping(value = "/{uuid}")
public Dataset getDataset(@PathVariable("uuid") final UUID uuid) throws NotFoundElement {
LOG.debug("Load Dataset by uuid {}", uuid);
return datasetService.loadDataset(uuid);
}
......@@ -138,8 +138,8 @@ public class DatasetController extends ApiBaseController {
* @return the dataset
* @throws Exception the exception
*/
@DeleteMapping("/{UUID},{version}")
public Dataset deleteDataset(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version) throws Exception {
@DeleteMapping("/{uuid},{version}")
public Dataset deleteDataset(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version) throws Exception {
final Dataset dataset = datasetService.removeDataset(datasetService.loadDataset(uuid, version));
dataset.setId(null);
return dataset;
......@@ -153,8 +153,8 @@ public class DatasetController extends ApiBaseController {
* @param descriptorUuids the descriptor uuids
* @return the dataset
*/
@PostMapping(value = "/add-descriptors/{UUID},{version}")
public Dataset addDescriptors(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
@PostMapping(value = "/add-descriptors/{uuid},{version}")
public Dataset addDescriptors(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
final Dataset dataset = datasetService.loadDataset(uuid, version);
final Set<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toSet());
return datasetService.addDescriptors(dataset, descriptors.toArray(new Descriptor[] {}));
......@@ -169,8 +169,8 @@ public class DatasetController extends ApiBaseController {
* @return the dataset
* @throws NotFoundElement the not found element
*/
@PostMapping(value = "/upsertaccessions/{UUID},{version}")
public Dataset upsertAccessions(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version,
@PostMapping(value = "/upsertaccessions/{uuid},{version}")
public Dataset upsertAccessions(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version,
@RequestBody final Set<AccessionRef> accessionRefs) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(uuid, version);
return datasetService.upsertAccessions(dataset, accessionRefs);
......@@ -226,15 +226,15 @@ public class DatasetController extends ApiBaseController {
* @param descriptorUuids the descriptor uuids
* @return the dataset
*/
@PostMapping(value = "/remove-descriptors/{UUID},{version}")
public Dataset removeDescriptors(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
@PostMapping(value = "/remove-descriptors/{uuid},{version}")
public Dataset removeDescriptors(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
final Dataset dataset = datasetService.loadDataset(uuid, version);
final Set<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toSet());
return datasetService.removeDescriptors(dataset, descriptors.toArray(new Descriptor[] {}));
}
@PostMapping(value = "/set-descriptors/{UUID},{version}")
public Dataset updateDescriptors(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
@PostMapping(value = "/set-descriptors/{uuid},{version}")
public Dataset updateDescriptors(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
final Dataset dataset = datasetService.loadDataset(uuid, version);
final List<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toList());
return datasetService.updateDescriptors(dataset, descriptors);
......@@ -304,7 +304,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@PostMapping(value = CREATOR_URL + "/create")
public DatasetCreator createDatasetCreator(@PathVariable("UUID") final UUID uuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
public DatasetCreator createDatasetCreator(@PathVariable("uuid") final UUID uuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(uuid);
return datasetService.createDatasetCreator(dataset, datasetCreator);
}
......@@ -319,7 +319,7 @@ public class DatasetController extends ApiBaseController {
*/
// uses request body
@RequestMapping(value = CREATOR_URL + "/delete", method = { RequestMethod.POST, RequestMethod.DELETE })
public DatasetCreator deleteDatasetCreator(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
public DatasetCreator deleteDatasetCreator(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(datasetUuid);
return datasetService.removeDatasetCreator(dataset, datasetCreator);
}
......@@ -332,7 +332,7 @@ public class DatasetController extends ApiBaseController {
* @return the page
*/
@GetMapping(value = CREATOR_URL + "/list")
public Page<DatasetCreator> listDatasetCreators(@PathVariable("UUID") final UUID uuid, final Pagination page) {
public Page<DatasetCreator> listDatasetCreators(@PathVariable("uuid") final UUID uuid, final Pagination page) {
return datasetService.listDatasetCreators(uuid, page.toPageRequest(100, Sort.Direction.ASC, "id"));
}
......@@ -345,7 +345,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@PostMapping(value = CREATOR_URL + "/update")
public DatasetCreator updateDatasetCreator(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
public DatasetCreator updateDatasetCreator(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final DatasetCreator datasetCreator) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(datasetUuid);
return datasetService.updateDatasetCreator(dataset, datasetCreator);
}
......@@ -375,7 +375,7 @@ public class DatasetController extends ApiBaseController {
* @throws IOException Signals that an I/O exception has occurred.
*/
@PostMapping(value = FILES_URL +"/add")
public Dataset addFileToDataset(@RequestParam("file") final MultipartFile inputFile, @PathVariable("UUID") final UUID datasetUuid) throws NotFoundElement,
public Dataset addFileToDataset(@RequestParam("file") final MultipartFile inputFile, @PathVariable("uuid") final UUID datasetUuid) throws NotFoundElement,
InvalidRepositoryFileDataException, InvalidRepositoryPathException, IOException {
LOG.info("Upload file to dataset by uuid {}", datasetUuid);
return datasetService.addDatasetFile(datasetService.loadDataset(datasetUuid), inputFile);
......@@ -395,7 +395,7 @@ public class DatasetController extends ApiBaseController {
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
@DeleteMapping(value = FILES_URL + "/delete/{fileUuid}")
public Dataset removeFileOfDataset(@PathVariable("UUID") final UUID datasetUuid, @PathVariable("fileUuid") final UUID fileUuid) throws NotFoundElement,
public Dataset removeFileOfDataset(@PathVariable("uuid") final UUID datasetUuid, @PathVariable("fileUuid") final UUID fileUuid) throws NotFoundElement,
InvalidRepositoryFileDataException, InvalidRepositoryPathException, IOException, NoSuchRepositoryFileException {
return datasetService.removeDatasetFile(datasetService.loadDataset(datasetUuid), fileUuid);
}
......@@ -408,7 +408,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@GetMapping(value = FILES_URL + "/list")
public List<RepositoryFile> getList(@PathVariable("UUID") final UUID datasetUuid) throws NotFoundElement {
public List<RepositoryFile> getList(@PathVariable("uuid") final UUID datasetUuid) throws NotFoundElement {
return datasetService.listDatasetFiles(datasetService.loadDataset(datasetUuid));
}
......@@ -426,7 +426,7 @@ public class DatasetController extends ApiBaseController {
* @throws NoSuchRepositoryFileException the no such repository file exception
*/
@PostMapping(value = FILES_URL + "/update")
public Dataset updateDatasetFile(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final RepositoryFile metadata) throws NotFoundElement,
public Dataset updateDatasetFile(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final RepositoryFile metadata) throws NotFoundElement,
InvalidRepositoryFileDataException, InvalidRepositoryPathException, IOException, NoSuchRepositoryFileException {
return datasetService.updateDatasetFile(datasetService.loadDataset(datasetUuid), metadata);
}
......@@ -440,7 +440,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@PostMapping(value = LOCATION_URL + "/create")
public DatasetLocation createLocation(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
public DatasetLocation createLocation(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(datasetUuid);
return datasetService.createLocation(dataset, datasetLocation);
}
......@@ -454,7 +454,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@RequestMapping(value = LOCATION_URL + "/delete", method = { RequestMethod.POST, RequestMethod.DELETE })
public DatasetLocation deleteLocation(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
public DatasetLocation deleteLocation(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(datasetUuid);
return datasetService.removeLocation(dataset, datasetLocation);
}
......@@ -467,7 +467,7 @@ public class DatasetController extends ApiBaseController {
* @return the page
*/
@GetMapping(value = LOCATION_URL + "/list")
public Page<DatasetLocation> listLocation(@PathVariable("UUID") final UUID uuid, final Pagination page) {
public Page<DatasetLocation> listLocation(@PathVariable("uuid") final UUID uuid, final Pagination page) {
return datasetService.listLocation(uuid, page.toPageRequest(100, Sort.Direction.ASC, "id"));
}
......@@ -480,7 +480,7 @@ public class DatasetController extends ApiBaseController {
* @throws NotFoundElement the not found element
*/
@PostMapping(value = LOCATION_URL + "/update")
public DatasetLocation updateLocation(@PathVariable("UUID") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
public DatasetLocation updateLocation(@PathVariable("uuid") final UUID datasetUuid, @RequestBody final DatasetLocation datasetLocation) throws NotFoundElement {
final Dataset dataset = datasetService.loadDataset(datasetUuid);
return datasetService.updateLocation(dataset, datasetLocation);
}
......
......@@ -80,8 +80,8 @@ public class DescriptorController extends ApiBaseController {
* @param uuid the uuid
* @return the descriptor
*/
@RequestMapping(value = "/{UUID}", method = RequestMethod.GET)
public Descriptor getDescriptor(@PathVariable("UUID") final UUID uuid) {
@RequestMapping(value = "/{uuid}", method = RequestMethod.GET)
public Descriptor getDescriptor(@PathVariable("uuid") final UUID uuid) {
return descriptorService.getDescriptor(uuid);
}
......@@ -92,8 +92,8 @@ public class DescriptorController extends ApiBaseController {
* @param version the version
* @return the descriptor
*/
@DeleteMapping(value = "/{UUID},{version}")
public Descriptor deleteDescriptor(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version) {
@DeleteMapping(value = "/{uuid},{version}")
public Descriptor deleteDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version) {
try {
return descriptorService.removeDescriptor(descriptorService.getDescriptor(uuid, version));
} catch (DataIntegrityViolationException e) {
......@@ -322,10 +322,10 @@ public class DescriptorController extends ApiBaseController {
* @param uuid descriptor UUID
* @return the other descriptor info
*/
@RequestMapping(value = "/extra/{UUID}", method = RequestMethod.GET)
@RequestMapping(value = "/extra/{uuid}", method = RequestMethod.GET)
@SuppressWarnings("unused")
@JsonView(JsonViews.Minimal.class)
public Object getOtherDescriptorInfo(@PathVariable("UUID") final UUID uuid) {
public Object getOtherDescriptorInfo(@PathVariable("uuid") final UUID uuid) {
final Descriptor descriptor = descriptorService.getDescriptor(uuid);
return new Object() {
......
......@@ -85,8 +85,8 @@ public class DescriptorListController {
* @param uuid the uuid
* @return the descriptor list
*/
@GetMapping(value = "/{UUID}")
public DescriptorList getDescriptorList(@PathVariable("UUID") final UUID uuid) {
@GetMapping(value = "/{uuid}")
public DescriptorList getDescriptorList(@PathVariable("uuid") final UUID uuid) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid);
return descriptorList;
}
......@@ -98,8 +98,8 @@ public class DescriptorListController {
* @param version the version
* @return the descriptor list
*/
@DeleteMapping(value = "/{UUID},{version}")
public DescriptorList deleteDescriptorList(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version) {
@DeleteMapping(value = "/{uuid},{version}")
public DescriptorList deleteDescriptorList(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version) {
return descriptorListService.deleteDescriptorList(descriptorListService.getDescriptorList(uuid, version));
}
......@@ -111,8 +111,8 @@ public class DescriptorListController {
* @throws IOException Signals that an I/O exception has occurred.
*/
@Transactional(readOnly = true)
@GetMapping(value = "/{UUID}/html", produces = { "text/html" })
public void generateDocument(@PathVariable("UUID") final UUID uuid, final HttpServletResponse response) throws IOException {
@GetMapping(value = "/{uuid}/html", produces = { "text/html" })
public void generateDocument(@PathVariable("uuid") final UUID uuid, final HttpServletResponse response) throws IOException {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid);
final String descriptorListHtml = exporter.htmlDescriptorList(descriptorList);
......@@ -204,8 +204,8 @@ public class DescriptorListController {
* @param descriptorUuids the descriptor uuids
* @return the descriptor list
*/
@PostMapping(value = "/add-descriptors/{UUID},{version}")
public DescriptorList addDescriptor(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
@PostMapping(value = "/add-descriptors/{uuid},{version}")
public DescriptorList addDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final List<UUID> descriptorUuids) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final List<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toList());
return descriptorListService.addDescriptors(descriptorList, descriptors.toArray(new Descriptor[] {}));
......@@ -219,8 +219,8 @@ public class DescriptorListController {
* @param descriptorUuids the descriptor uuids
* @return the descriptor list
*/
@PostMapping(value = "/remove-descriptors/{UUID},{version}")
public DescriptorList removeDescriptor(@PathVariable("UUID") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
@PostMapping(value = "/remove-descriptors/{uuid},{version}")
public DescriptorList removeDescriptor(@PathVariable("uuid") final UUID uuid, @PathVariable("version") final int version, @RequestBody final Set<UUID> descriptorUuids) {
final DescriptorList descriptorList = descriptorListService.getDescriptorList(uuid, version);
final Set<Descriptor> descriptors = descriptorUuids.stream().map(descriptorUuid -> descriptorService.getDescriptor(descriptorUuid)).collect(Collectors.toSet());