From 98bf7f928fbb4fb5a0ae14030c604c5b04d7ab4a Mon Sep 17 00:00:00 2001 From: gpawel <gpawel> Date: Tue, 2 Oct 2012 09:25:53 +0000 Subject: [PATCH] BIS-178 Metaprojects: persistence layer and public API SVN: 26932 --- .../v1/GeneralInformationChangingService.java | 15 ++++--- .../predicate/MetaprojectIdPredicate.java | 42 +++++++++++++++++++ 2 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/MetaprojectIdPredicate.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java index 8101df8aa1c..e647b8b4f26 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationChangingService.java @@ -32,6 +32,7 @@ import ch.systemsx.cisd.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.server.AbstractServer; import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.AuthorizationGuard; import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed; +import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.MetaprojectIdPredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.MetaprojectPredicate; import ch.systemsx.cisd.openbis.generic.server.business.IPropertiesBatchManager; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; @@ -177,7 +178,9 @@ public class GeneralInformationChangingService extends @Override @Transactional(readOnly = false) @RolesAllowed(RoleWithHierarchy.SPACE_USER) - public void deleteMetaproject(String sessionToken, Long metaprojectId) + public void deleteMetaproject(String sessionToken, + @AuthorizationGuard(guardClass = MetaprojectIdPredicate.class) + Long metaprojectId) { server.deleteMetaproject(sessionToken, new TechId(metaprojectId)); } @@ -185,8 +188,9 @@ public class GeneralInformationChangingService extends @Override @Transactional(readOnly = false) @RolesAllowed(RoleWithHierarchy.SPACE_USER) - public void addToMetaproject(String sessionToken, Long metaprojectId, - Collection<Experiment> experiments, Collection<Sample> samples, + public void addToMetaproject(String sessionToken, + @AuthorizationGuard(guardClass = MetaprojectIdPredicate.class) + Long metaprojectId, Collection<Experiment> experiments, Collection<Sample> samples, Collection<DataSet> dataSets, Collection<Material> materials) { server.addToMetaproject(sessionToken, new TechId(metaprojectId), @@ -197,8 +201,9 @@ public class GeneralInformationChangingService extends @Override @Transactional(readOnly = false) @RolesAllowed(RoleWithHierarchy.SPACE_USER) - public void removeFromMetaproject(String sessionToken, Long metaprojectId, - Collection<Experiment> experiments, Collection<Sample> samples, + public void removeFromMetaproject(String sessionToken, + @AuthorizationGuard(guardClass = MetaprojectIdPredicate.class) + Long metaprojectId, Collection<Experiment> experiments, Collection<Sample> samples, Collection<DataSet> dataSets, Collection<Material> materials) { server.removeFromMetaproject(sessionToken, new TechId(metaprojectId), diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/MetaprojectIdPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/MetaprojectIdPredicate.java new file mode 100644 index 00000000000..44685c07c92 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/MetaprojectIdPredicate.java @@ -0,0 +1,42 @@ +/* + * Copyright 2012 ETH Zuerich, CISD + * + * 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 ch.systemsx.cisd.openbis.generic.server.authorization.predicate; + +import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; + +/** + * @author Pawel Glyzewski + */ +public class MetaprojectIdPredicate extends DelegatedPredicate<TechId, Long> +{ + public MetaprojectIdPredicate() + { + super(new MetaprojectTechIdPredicate()); + } + + @Override + public TechId tryConvert(Long value) + { + return new TechId(value); + } + + @Override + public String getCandidateDescription() + { + return "Metaproject Id"; + } +} -- GitLab