Commit a085ff49 authored by Matija Obreza's avatar Matija Obreza

Fix: prevent updates to published subsets and datasets

- API reset state to draft when adding accessions
parent 1778b014
......@@ -526,8 +526,8 @@ public class DatasetServiceImpl implements DatasetService {
if (loadedDataset == null) {
throw new NotFoundElement("Dataset doesn't exist");
}
if (loadedDataset.getState() != PublishState.DRAFT) {
throw new InvalidApiUsageException("Dataset should in draft state");
if (loadedDataset.isPublished()) {
throw new InvalidApiUsageException("Dataset is published, no edits allowed.");
}
loadedDataset.setAccessionRefs(lookupMatchingAccessions(accessionRefs));
......
......@@ -313,6 +313,9 @@ public class SubsetServiceImpl implements SubsetService {
public Subset addAccessions(final Subset input, final Set<UUID> accessionsUuids) {
LOG.info("Add accessions to Subset. Input accessions {}", input);
final Subset subset = loadSubset(input);
if (subset.isPublished()) {
throw new InvalidApiUsageException("Subset is published, no edits allowed.");
}
final List<Accession> accessions = accessionRepository.find(accessionsUuids);
......@@ -320,13 +323,12 @@ public class SubsetServiceImpl implements SubsetService {
for (Accession accession : accessions) {
if (currentAccessions.contains(accession.getUuid())) {
LOG.warn("Current Subset already contains accession, ignoring");
LOG.debug("Current Subset already contains accession, ignoring");
} else {
subset.getAccessionRefs().add(new AccessionRef(accession));
currentAccessions.add(accession.getUuid());
}
}
subset.setState(PublishState.DRAFT);
return deepLoad(subsetRepository.save(subset));
}
......
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