Commit 23d93f50 authored by Matija Obreza's avatar Matija Obreza
Browse files

Dataset, Descriptor and DescriptorList declare owner as ACL parent object

- Permissions are inherited from Partner
- listMyXxxxx methods return data from Partners
parent 9202e761
......@@ -32,7 +32,6 @@ import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.OrderColumn;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
......@@ -203,6 +202,14 @@ public class Dataset extends UuidModel implements Publishable, SelfCleaning, Pub
trimStringsToNull();
}
/**
* Owner is the ACL parent object for the dataset
*/
@Override
public AclAwareModel aclParentObject() {
return this.owner;
}
/**
* Gets the creators.
......
......@@ -244,6 +244,14 @@ public class Descriptor extends UuidModel implements SelfCleaning, Publishable,
trimStringsToNull();
}
/**
* Owner is the ACL parent object for the descriptor
*/
@Override
public AclAwareModel aclParentObject() {
return this.owner;
}
/**
* Instantiates a new descriptor.
*
......
......@@ -145,6 +145,14 @@ public class DescriptorList extends UuidModel implements Publishable, SelfCleani
trimStringsToNull();
}
/**
* Owner is the ACL parent object for the descriptor list
*/
@Override
public AclAwareModel aclParentObject() {
return this.owner;
}
/**
* Gets the publisher.
*
......
......@@ -41,6 +41,7 @@ import org.genesys.catalog.persistence.dataset.DatasetVersionsRepository;
import org.genesys.catalog.service.DatasetService;
import org.genesys.catalog.service.filters.DatasetFilter;
import org.genesys.catalog.util.Utils;
import org.genesys.common.model.Partner;
import org.genesys.filerepository.InvalidRepositoryFileDataException;
import org.genesys.filerepository.InvalidRepositoryPathException;
import org.genesys.filerepository.NoSuchRepositoryFileException;
......@@ -260,8 +261,8 @@ public class DatasetServiceImpl implements DatasetService {
if (utils.hasRole(UserRole.ADMINISTRATOR)) {
return datasetRepository.findAll(filter.buildQuery(), page);
} else {
final HashSet<Long> ids = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(Dataset.class, BasePermission.WRITE));
return datasetRepository.findAll(dataset.id.in(ids).and(filter.buildQuery()), page);
final HashSet<Long> partners = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(Partner.class, BasePermission.WRITE));
return datasetRepository.findAll(dataset.owner.id.in(partners).and(filter.buildQuery()), page);
}
}
......
......@@ -38,6 +38,7 @@ import org.genesys.catalog.service.DescriptorListService;
import org.genesys.catalog.service.DescriptorService;
import org.genesys.catalog.service.filters.DescriptorListFilter;
import org.genesys.catalog.util.Utils;
import org.genesys.common.model.Partner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -309,8 +310,8 @@ public class DescriptorListServiceImpl implements DescriptorListService {
if (utils.hasRole(UserRole.ADMINISTRATOR)) {
return descriptorListRepository.findAll(filter.buildQuery(), page);
} else {
final HashSet<Long> ids = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(DescriptorList.class, BasePermission.WRITE));
return descriptorListRepository.findAll(descriptorList.id.in(ids).and(filter.buildQuery()), page);
final HashSet<Long> partners = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(Partner.class, BasePermission.WRITE));
return descriptorListRepository.findAll(descriptorList.owner.id.in(partners).and(filter.buildQuery()), page);
}
}
......
......@@ -204,8 +204,8 @@ public class DescriptorServiceImpl implements DescriptorService {
if (utils.hasRole(UserRole.ADMINISTRATOR)) {
return descriptorRepository.findAll(filter.buildQuery(), page);
} else {
final HashSet<Long> ids = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(Descriptor.class, BasePermission.WRITE));
return descriptorRepository.findAll(descriptor.id.in(ids).and(filter.buildQuery()), page);
final HashSet<Long> partners = new HashSet<>(utils.listObjectIdentityIdsForCurrentUser(Partner.class, BasePermission.WRITE));
return descriptorRepository.findAll(descriptor.owner.id.in(partners).and(filter.buildQuery()), page);
}
}
......
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