Commit 53534592 authored by Matija Obreza's avatar Matija Obreza
Browse files

BUG: Fixed parameter names for Spring Security annotations

parent d6f4293d
......@@ -70,8 +70,8 @@ public interface DatasetService {
* @param accessionIdentifiers new accessionIdentifiers
* @return updated Dataset in db.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'write')")
Dataset updateAccessionIdentifiers(Dataset input, Set<AccessionIdentifier> accessionIdentifiers);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
Dataset updateAccessionIdentifiers(Dataset dataset, Set<AccessionIdentifier> accessionIdentifiers);
/**
* Method adding new descriptor to Dataset.
......@@ -80,8 +80,8 @@ public interface DatasetService {
* @param descriptors the descriptors
* @return updated Dataset in db.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'write')")
Dataset addDescriptors(Dataset input, Descriptor... descriptors);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
Dataset addDescriptors(Dataset dataset, Descriptor... descriptors);
/**
* Method removing preserved descriptor from Dataset.
......@@ -90,8 +90,8 @@ public interface DatasetService {
* @param descriptors the descriptors
* @return updated Dataset in db.
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'write')")
Dataset removeDescriptors(Dataset input, Descriptor... descriptors);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
Dataset removeDescriptors(Dataset dataset, Descriptor... descriptors);
/**
* Update all descriptors.
......@@ -100,8 +100,8 @@ public interface DatasetService {
* @param descriptors ordered descriptor list
* @return updated dataset
*/
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#input, 'write')")
Dataset updateDescriptors(Dataset input, List<Descriptor> descriptors);
@PreAuthorize("hasRole('ADMINISTRATOR') or hasPermission(#dataset, 'write')")
Dataset updateDescriptors(Dataset dataset, List<Descriptor> descriptors);
/**
* Load dataset based on identifiers and version provided in the input.
......
......@@ -127,20 +127,20 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset updateDataset(final Dataset source) {
LOG.info("Update Dataset. Input data {}", source);
final Dataset dataset = loadDataset(source);
public Dataset updateDataset(final Dataset input) {
LOG.info("Update Dataset. Input data {}", input);
final Dataset dataset = loadDataset(input);
if (dataset.isPublished()) {
LOG.warn("Refusing to update a published Dataset");
throw new DataIntegrityViolationException("Published dataset can't be updated");
}
if (source.getOwner() != null && !dataset.getOwner().equals(source.getOwner())) {
if (input.getOwner() != null && !dataset.getOwner().equals(input.getOwner())) {
throw new InvalidApiUsageException("Dataset owner can't be changed");
}
copyValues(dataset, source);
copyValues(dataset, input);
return lazyLoad(datasetRepository.save(dataset));
}
......@@ -150,9 +150,9 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset updateAccessionIdentifiers(final Dataset source, final Set<AccessionIdentifier> accessionIdentifiers) {
LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionIdentifiers {}", source, accessionIdentifiers);
final Dataset dataset = loadDataset(source);
public Dataset updateAccessionIdentifiers(Dataset dataset, final Set<AccessionIdentifier> accessionIdentifiers) {
LOG.info("Update AccessionIdentifiers. Input dataset: {}, input accessionIdentifiers {}", dataset, accessionIdentifiers);
dataset = loadDataset(dataset);
dataset.getAccessionIdentifiers().clear();
dataset.setAccessionIdentifiers(new HashSet<>(accessionIdentifiers));
return lazyLoad(datasetRepository.save(dataset));
......@@ -163,9 +163,9 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset addDescriptors(final Dataset source, final Descriptor... descriptors) {
LOG.info("Add descriptor to Dataset {}. Input descriptors {}", source, descriptors);
final Dataset dataset = loadDataset(source);
public Dataset addDescriptors(Dataset dataset, final Descriptor... descriptors) {
LOG.info("Add descriptor to Dataset {}. Input descriptors {}", dataset, descriptors);
dataset = loadDataset(dataset);
final Set<UUID> descriptorUuids = dataset.getDescriptors().stream().map(descriptor -> descriptor.getUuid()).collect(Collectors.toSet());
......@@ -186,9 +186,9 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset removeDescriptors(final Dataset input, final Descriptor... descriptors) {
LOG.info("Remove descriptors {} of dataset {}.", descriptors, input);
final Dataset dataset = loadDataset(input);
public Dataset removeDescriptors(Dataset dataset, final Descriptor... descriptors) {
LOG.info("Remove descriptors {} of dataset {}.", descriptors, dataset);
dataset = loadDataset(dataset);
// Which UUIDs to remove?
final Set<UUID> descriptorUuids = Arrays.stream(descriptors).map(descriptor -> descriptor.getUuid()).collect(Collectors.toSet());
......@@ -204,9 +204,9 @@ public class DatasetServiceImpl implements DatasetService {
*/
@Override
@Transactional
public Dataset updateDescriptors(final Dataset source, final List<Descriptor> descriptors) {
LOG.info("Update descriptors for Dataset {}. Input descriptors {}", source, descriptors);
final Dataset dataset = loadDataset(source);
public Dataset updateDescriptors(Dataset dataset, final List<Descriptor> descriptors) {
LOG.info("Update descriptors for Dataset {}. Input descriptors {}", dataset, descriptors);
dataset = loadDataset(dataset);
dataset.getDescriptors().clear();
copyDescriptors(dataset, descriptors);
......
Supports Markdown
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