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 8101df8aa1ccb9d6582c74f41764d1173f3dc224..e647b8b4f2608ddcb135ecd206aa7a19f33967e5 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 0000000000000000000000000000000000000000..44685c07c920e6c0d485224249c4507c96b6c153 --- /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"; + } +}