From 1a046ba879d49a5166bd14b0dbfe37dc3ee00a49 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 27 Feb 2013 10:30:19 +0000 Subject: [PATCH] SP-417, BIS-278: new listAttachment methods removed from IGeneralInformationService. Methods in implementation and test methods out-commented. Also new Identifiers removed. SVN: 28464 --- .../api/v1/GeneralInformationService.java | 259 ++++++------ .../v1/GeneralInformationServiceLogger.java | 59 ++- .../ExperimentIdentifierPredicate.java | 85 ---- .../predicate/ProjectIdentifierPredicate.java | 83 ---- .../predicate/SampleIdentifierPredicate.java | 86 ---- .../GeneralInformationServiceJsonApiTest.java | 339 ++++++++------- .../api/v1/GeneralInformationServiceTest.java | 389 +++++++++--------- .../api/v1/IGeneralInformationService.java | 30 -- .../api/v1/dto/ExperimentIdentifier.java | 229 ----------- .../api/v1/dto/IDatabaseIdentifier.java | 33 -- .../api/v1/dto/IPermanentIdentifier.java | 32 -- .../shared/api/v1/dto/ProjectIdentifier.java | 189 --------- .../shared/api/v1/dto/SampleIdentifier.java | 202 --------- 13 files changed, 515 insertions(+), 1500 deletions(-) delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ExperimentIdentifierPredicate.java delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectIdentifierPredicate.java delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleIdentifierPredicate.java delete mode 100644 openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ExperimentIdentifier.java delete mode 100644 openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IDatabaseIdentifier.java delete mode 100644 openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IPermanentIdentifier.java delete mode 100644 openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ProjectIdentifier.java delete mode 100644 openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SampleIdentifier.java diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java index 914ceed8a69..96673c5cb73 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java @@ -44,11 +44,8 @@ import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.Capabili import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.ReturnValueFilter; import ch.systemsx.cisd.openbis.generic.server.authorization.annotation.RolesAllowed; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.ExperimentAugmentedCodePredicate; -import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.ExperimentIdentifierPredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.ExperimentListPredicate; -import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.ProjectIdentifierPredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.ProjectPredicate; -import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SampleIdentifierPredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SampleListPredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.predicate.SamplePredicate; import ch.systemsx.cisd.openbis.generic.server.authorization.validator.DataSetByExperimentIdentifierValidator; @@ -69,7 +66,6 @@ import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDatabaseInstanceDAO; import ch.systemsx.cisd.openbis.generic.shared.ICommonServer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.Translator; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; @@ -85,18 +81,17 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchableEntityKind; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SpaceWithProjectsAndRoleAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Vocabulary; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.metaproject.IMetaprojectId; import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetRelatedEntities; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExperimentType; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.AbstractExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListMaterialCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Metaproject; @@ -706,7 +701,8 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio SampleToDataSetRelatedEntitiesTranslator translator = new SampleToDataSetRelatedEntitiesTranslator(sampleTypes, samples); DataSetRelatedEntities dsre = translator.convertToDataSetRelatedEntities(); - List<AbstractExternalData> dataSets = commonServer.listRelatedDataSets(sessionToken, dsre, true); + List<AbstractExternalData> dataSets = + commonServer.listRelatedDataSets(sessionToken, dsre, true); return Translator.translate(dataSets, connectionsToGet); } @@ -764,7 +760,8 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio ExperimentToDataSetRelatedEntitiesTranslator translator = new ExperimentToDataSetRelatedEntitiesTranslator(experimentTypes, experiments); DataSetRelatedEntities dsre = translator.convertToDataSetRelatedEntities(); - List<AbstractExternalData> dataSets = commonServer.listRelatedDataSets(sessionToken, dsre, true); + List<AbstractExternalData> dataSets = + commonServer.listRelatedDataSets(sessionToken, dsre, true); return Translator.translate(dataSets, connectionsToGet); } @@ -1089,127 +1086,127 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio return result; } - @Override - @Transactional(readOnly = true) - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) - public List<Attachment> listAttachmentsForProject(String sessionToken, - @AuthorizationGuard(guardClass = ProjectIdentifierPredicate.class) - ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier project, - boolean allVersions) - { - final TechId techId; - if (project.getDatabaseId() != null) - { - techId = new TechId(project.getDatabaseId()); - } else if (project.getPermId() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveProjectIdByPermId( - project.getPermId()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else if (project.getCode() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveProjectIdByCode( - project.getSpaceCode(), project.getCode()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else - { - throw new IllegalArgumentException("No identifier given."); - } - final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = - commonServer.listProjectAttachments(sessionToken, techId); - return Translator.translateAttachments(attachments, allVersions); - } - - @Override - @Transactional(readOnly = true) - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) - public List<Attachment> listAttachmentsForExperiment(String sessionToken, - @AuthorizationGuard(guardClass = ExperimentIdentifierPredicate.class) - ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier experiment, - boolean allVersions) - { - final TechId techId; - if (experiment.getDatabaseId() != null) - { - techId = new TechId(experiment.getDatabaseId()); - } else if (experiment.getPermId() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveExperimentIdByPermId( - experiment.getPermId()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else if (experiment.getCode() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveExperimentIdByCode( - experiment.getSpaceCode(), experiment.getProjectCode(), - experiment.getCode()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else - { - throw new IllegalArgumentException("No identifier given."); - } - final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = - commonServer.listExperimentAttachments(sessionToken, techId); - return Translator.translateAttachments(attachments, allVersions); - } - - @Override - @Transactional(readOnly = true) - @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) - public List<Attachment> listAttachmentsForSample(String sessionToken, - @AuthorizationGuard(guardClass = SampleIdentifierPredicate.class) - SampleIdentifier sample, - boolean allVersions) - { - final TechId techId; - if (sample.getDatabaseId() != null) - { - techId = new TechId(sample.getDatabaseId()); - } else if (sample.getPermId() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveSampleIdByPermId( - sample.getPermId()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else if (sample.getCode() != null) - { - final Long id = - boFactory.getEntityResolver().tryResolveSampleIdByCode( - sample.getSpaceCode(), sample.getCode()); - if (id == null) - { - return Collections.emptyList(); - } - techId = new TechId(id); - } else - { - throw new IllegalArgumentException("No identifier given."); - } - final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = - commonServer.listSampleAttachments(sessionToken, techId); - return Translator.translateAttachments(attachments, allVersions); - } + // @Override + // @Transactional(readOnly = true) + // @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + // public List<Attachment> listAttachmentsForProject(String sessionToken, + // @AuthorizationGuard(guardClass = ProjectIdentifierPredicate.class) + // ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier project, + // boolean allVersions) + // { + // final TechId techId; + // if (project.getDatabaseId() != null) + // { + // techId = new TechId(project.getDatabaseId()); + // } else if (project.getPermId() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveProjectIdByPermId( + // project.getPermId()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else if (project.getCode() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveProjectIdByCode( + // project.getSpaceCode(), project.getCode()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else + // { + // throw new IllegalArgumentException("No identifier given."); + // } + // final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = + // commonServer.listProjectAttachments(sessionToken, techId); + // return Translator.translateAttachments(attachments, allVersions); + // } + // + // @Override + // @Transactional(readOnly = true) + // @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + // public List<Attachment> listAttachmentsForExperiment(String sessionToken, + // @AuthorizationGuard(guardClass = ExperimentIdentifierPredicate.class) + // ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier experiment, + // boolean allVersions) + // { + // final TechId techId; + // if (experiment.getDatabaseId() != null) + // { + // techId = new TechId(experiment.getDatabaseId()); + // } else if (experiment.getPermId() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveExperimentIdByPermId( + // experiment.getPermId()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else if (experiment.getCode() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveExperimentIdByCode( + // experiment.getSpaceCode(), experiment.getProjectCode(), + // experiment.getCode()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else + // { + // throw new IllegalArgumentException("No identifier given."); + // } + // final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = + // commonServer.listExperimentAttachments(sessionToken, techId); + // return Translator.translateAttachments(attachments, allVersions); + // } + // + // @Override + // @Transactional(readOnly = true) + // @RolesAllowed(RoleWithHierarchy.SPACE_OBSERVER) + // public List<Attachment> listAttachmentsForSample(String sessionToken, + // @AuthorizationGuard(guardClass = SampleIdentifierPredicate.class) + // SampleIdentifier sample, + // boolean allVersions) + // { + // final TechId techId; + // if (sample.getDatabaseId() != null) + // { + // techId = new TechId(sample.getDatabaseId()); + // } else if (sample.getPermId() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveSampleIdByPermId( + // sample.getPermId()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else if (sample.getCode() != null) + // { + // final Long id = + // boFactory.getEntityResolver().tryResolveSampleIdByCode( + // sample.getSpaceCode(), sample.getCode()); + // if (id == null) + // { + // return Collections.emptyList(); + // } + // techId = new TechId(id); + // } else + // { + // throw new IllegalArgumentException("No identifier given."); + // } + // final List<ch.systemsx.cisd.openbis.generic.shared.basic.dto.Attachment> attachments = + // commonServer.listSampleAttachments(sessionToken, techId); + // return Translator.translateAttachments(attachments, allVersions); + // } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java index c12767c85a5..33789f567a6 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java @@ -26,7 +26,6 @@ import ch.systemsx.cisd.authentication.ISessionManager; import ch.systemsx.cisd.openbis.common.spring.IInvocationLoggerContext; import ch.systemsx.cisd.openbis.generic.shared.AbstractServerLogger; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType.VocabularyTerm; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; @@ -34,16 +33,13 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStoreURLForDataSets; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MetaprojectAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SpaceWithProjectsAndRoleAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.metaproject.IMetaprojectId; @@ -390,31 +386,32 @@ class GeneralInformationServiceLogger extends AbstractServerLogger implements return null; } - @Override - public List<Attachment> listAttachmentsForProject(String sessionToken, - ProjectIdentifier project, boolean allVersions) - { - logAccess(sessionToken, "listAttachmentsForProject", "PROJECT(%s)", "ALL_VERSIONS(%s)", - project, allVersions); - return null; - } - - @Override - public List<Attachment> listAttachmentsForExperiment(String sessionToken, - ExperimentIdentifier experiment, boolean allVersions) - { - logAccess(sessionToken, "listAttachmentsForExperiment", "EXPERIMENT(%s)", - "ALL_VERSIONS(%s)", experiment, allVersions); - return null; - } - - @Override - public List<Attachment> listAttachmentsForSample(String sessionToken, SampleIdentifier sample, - boolean allVersions) - { - logAccess(sessionToken, "listAttachmentsForSample", "SAMPLE(%s)", "ALL_VERSIONS(%s)", - sample, allVersions); - return null; - } - + // @Override + // public List<Attachment> listAttachmentsForProject(String sessionToken, + // ProjectIdentifier project, boolean allVersions) + // { + // logAccess(sessionToken, "listAttachmentsForProject", "PROJECT(%s)", "ALL_VERSIONS(%s)", + // project, allVersions); + // return null; + // } + // + // @Override + // public List<Attachment> listAttachmentsForExperiment(String sessionToken, + // ExperimentIdentifier experiment, boolean allVersions) + // { + // logAccess(sessionToken, "listAttachmentsForExperiment", "EXPERIMENT(%s)", + // "ALL_VERSIONS(%s)", experiment, allVersions); + // return null; + // } + // + // @Override + // public List<Attachment> listAttachmentsForSample(String sessionToken, SampleIdentifier + // sample, + // boolean allVersions) + // { + // logAccess(sessionToken, "listAttachmentsForSample", "SAMPLE(%s)", "ALL_VERSIONS(%s)", + // sample, allVersions); + // return null; + // } + // } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ExperimentIdentifierPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ExperimentIdentifierPredicate.java deleted file mode 100644 index 66147f597c2..00000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ExperimentIdentifierPredicate.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright 2013 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 java.util.List; - -import ch.systemsx.cisd.common.exceptions.Status; -import ch.systemsx.cisd.openbis.generic.server.authorization.RoleWithIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.dto.PermId; -import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; - -/** - * An <code>IPredicate</code> implementation based on {@link ExperimentIdentifier}. - * - * @author Bernd Rinn - */ -public class ExperimentIdentifierPredicate extends - AbstractExperimentPredicate<ExperimentIdentifier> -{ - @Override - public final String getCandidateDescription() - { - return "experiment identifier"; - } - - @Override - protected Status doEvaluation(final PersonPE person, - final List<RoleWithIdentifier> allowedRoles, - final ExperimentIdentifier identifier) - { - assert spacePredicate.initialized : "Predicate has not been initialized"; - assert experimentTechIdPredicate.initialized : "Predicate has not been initialized"; - assert experimentPermIdPredicate.initialized : "Predicate has not been initialized"; - assert experimentAugmentedCodePredicate.initialized : "Predicate has not been initialized"; - Status status = null; - if (identifier.getDatabaseId() != null) - { - status = experimentTechIdPredicate.doEvaluation(person, - allowedRoles, new TechId(identifier.getDatabaseId())); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getPermId() != null) - { - status = experimentPermIdPredicate.doEvaluation(person, - allowedRoles, new PermId(identifier.getPermId())); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getAugmentedCode() != null) - { - status = experimentAugmentedCodePredicate.doEvaluation(person, - allowedRoles, identifier.getAugmentedCode()); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (status == null) - { - return Status.createError("No identifier given"); - } - return Status.OK; - } -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectIdentifierPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectIdentifierPredicate.java deleted file mode 100644 index d151b387594..00000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/ProjectIdentifierPredicate.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2013 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 java.util.List; - -import ch.systemsx.cisd.common.exceptions.Status; -import ch.systemsx.cisd.openbis.generic.server.authorization.RoleWithIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; - -/** - * An <code>IPredicate</code> implementation based on {@link ProjectIdentifier}. - * - * @author Bernd Rinn - */ -public class ProjectIdentifierPredicate extends AbstractProjectPredicate<ProjectIdentifier> -{ - @Override - public final String getCandidateDescription() - { - return "project identifier"; - } - - @Override - protected Status doEvaluation(final PersonPE person, - final List<RoleWithIdentifier> allowedRoles, - final ProjectIdentifier identifier) - { - assert spacePredicate.initialized : "Predicate has not been initialized"; - assert projectTechIdPredicate.initialized : "Predicate has not been initialized"; - assert projectPermIdPredicate.initialized : "Predicate has not been initialized"; - assert projectAugmentedCodePredicate.initialized : "Predicate has not been initialized"; - Status status = null; - if (identifier.getDatabaseId() != null) - { - status = projectTechIdPredicate.doEvaluation(person, - allowedRoles, new TechId(identifier.getDatabaseId())); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getPermId() != null) - { - status = projectPermIdPredicate.doEvaluation(person, - allowedRoles, identifier.getPermId()); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getAugmentedCode() != null) - { - status = projectAugmentedCodePredicate.doEvaluation(person, - allowedRoles, identifier.getAugmentedCode()); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (status == null) - { - return Status.createError("No identifier given"); - } - return Status.OK; - } -} diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleIdentifierPredicate.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleIdentifierPredicate.java deleted file mode 100644 index ba4e7c4ceea..00000000000 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/authorization/predicate/SampleIdentifierPredicate.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2013 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 java.util.List; - -import ch.systemsx.cisd.common.exceptions.Status; -import ch.systemsx.cisd.openbis.generic.server.authorization.RoleWithIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; -import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; -import ch.systemsx.cisd.openbis.generic.shared.dto.PermId; -import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE; - -/** - * An <code>IPredicate</code> implementation based on {@link ExperimentIdentifier}. - * - * @author Bernd Rinn - */ -public class SampleIdentifierPredicate extends - AbstractSamplePredicate<SampleIdentifier> -{ - @Override - public final String getCandidateDescription() - { - return "sample identifier"; - } - - @Override - protected Status doEvaluation(final PersonPE person, - final List<RoleWithIdentifier> allowedRoles, - final SampleIdentifier identifier) - { - assert spacePredicate.initialized : "Predicate has not been initialized"; - assert sampleTechIdPredicate.initialized : "Predicate has not been initialized"; - assert samplePermIdPredicate.initialized : "Predicate has not been initialized"; - assert sampleAugmentedCodePredicate.initialized : "Predicate has not been initialized"; - Status status = null; - if (identifier.getDatabaseId() != null) - { - status = sampleTechIdPredicate.doEvaluation(person, - allowedRoles, new TechId(identifier.getDatabaseId())); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getPermId() != null) - { - status = samplePermIdPredicate.doEvaluation(person, - allowedRoles, new PermId(identifier.getPermId())); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (identifier.getAugmentedCode() != null) - { - status = sampleAugmentedCodePredicate.doEvaluation(person, - allowedRoles, identifier.getAugmentedCode()); - if (Status.OK.equals(status) == false) - { - return status; - } - } - if (status == null) - { - return Status.createError("No identifier given"); - } - return Status.OK; - } -} diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/remoteapitest/api/v1/GeneralInformationServiceJsonApiTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/remoteapitest/api/v1/GeneralInformationServiceJsonApiTest.java index 40a9fa15054..c46048cf353 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/remoteapitest/api/v1/GeneralInformationServiceJsonApiTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/remoteapitest/api/v1/GeneralInformationServiceJsonApiTest.java @@ -22,13 +22,10 @@ import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.fail; import java.net.MalformedURLException; -import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; -import java.util.Date; import java.util.EnumSet; import java.util.List; import java.util.Map; @@ -42,19 +39,15 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.common.string.ToStringComparator; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationChangingService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyTypeGroup; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClauseAttribute; @@ -790,171 +783,171 @@ public class GeneralInformationServiceJsonApiTest extends RemoteApiTestCase return null; } - @Test - public void testListAttachmentsForExperimentAllVersions() - { - final List<Experiment> experiments = - generalInformationService.listExperiments(sessionToken, - Collections.singletonList("/CISD/NEMO/EXP1")); - assertEquals(1, experiments.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromEntity(experiments.get(0)), - true); - assertEquals(4, attachments.size()); - int version = 4; - for (Attachment a : attachments) - { - assertEquals("exampleExperiments.txt", a.getFileName()); - assertEquals(version, a.getVersion()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - assertTrue(a.getRegistrationDate().getTime() > 0); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - String.format( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=%d&entity=EXPERIMENT&permId=200811050951882-1028", - version), - a.getPermLink()); - --version; - } - } - - @Test - public void testListAttachmentsForExperimentLatestVersion() - { - final List<Experiment> experiments = - generalInformationService.listExperiments(sessionToken, - Collections.singletonList("/CISD/NEMO/EXP1")); - assertEquals(1, experiments.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromEntity(experiments.get(0)), false); - assertEquals(1, attachments.size()); - final Attachment a = attachments.get(0); - assertEquals("exampleExperiments.txt", a.getFileName()); - assertEquals(4, a.getVersion()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - assertTrue(a.getRegistrationDate().getTime() > 0); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=4&entity=EXPERIMENT&permId=200811050951882-1028", - a.getPermLink()); - - final List<Attachment> attachments2 = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromAugmentedCode("/CISD/NEMO/EXP1"), false); - - assertEquals(1, attachments2.size()); - - final Attachment a2 = attachments2.get(0); - assertEquals(a, a2); - } - - @Test - public void testListAttachmentsForSample() - { - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, - "3VCP6")); - - final List<Sample> samples = - generalInformationService.searchForSamples(sessionToken, searchCriteria); - assertEquals(1, samples.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromEntity(samples.get(0)), - true); - assertEquals(1, attachments.size()); - - final Attachment a = attachments.get(0); - assertEquals("sampleHistory.txt", a.getFileName()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - assertEquals(1, a.getVersion()); - assertTrue(a.getRegistrationDate().getTime() > 0); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=sampleHistory.txt&version=1&entity=SAMPLE&permId=200811050946559-980", - a.getPermLink()); - - final List<Attachment> attachments2 = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromPermId("200811050946559-980"), true); - - assertEquals(1, attachments2.size()); - - final Attachment a2 = attachments2.get(0); - assertEquals(a, a2); - - final List<Attachment> attachments3 = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromAugmentedCode("/CISD/3VCP6"), true); - - assertEquals(1, attachments3.size()); - - final Attachment a3 = attachments3.get(0); - assertEquals(a, a3); - } - - @Test - public void testListAttachmentsForProjectNoAttachment() - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromAugmentedCode("/CISD/DEFAULT"), true); - - assertEquals(0, attachments.size()); - } - - @Test - public void testListAttachmentsForProjectNonExisting() - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromAugmentedCode("/NONE/EXISTENT"), true); - - assertEquals(0, attachments.size()); - } - - @Test - public void testListAttachmentsForProjects() throws ParseException - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromPermId("20120814110011738-103"), true); - - assertEquals(1, attachments.size()); - - final Attachment a = attachments.get(0); - assertEquals("projectDescription.txt", a.getFileName()); - assertEquals("The Project", a.getTitle()); - assertEquals("All about it.", a.getDescription()); - assertEquals(1, a.getVersion()); - final Date date = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") - .parse("2012-01-03 08:27:57.123 +0100"); - assertEquals(date, a.getRegistrationDate()); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=projectDescription.txt&version=1&entity=PROJECT&code=NEMO&space=CISD", - a.getPermLink()); - } + // @Test + // public void testListAttachmentsForExperimentAllVersions() + // { + // final List<Experiment> experiments = + // generalInformationService.listExperiments(sessionToken, + // Collections.singletonList("/CISD/NEMO/EXP1")); + // assertEquals(1, experiments.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromEntity(experiments.get(0)), + // true); + // assertEquals(4, attachments.size()); + // int version = 4; + // for (Attachment a : attachments) + // { + // assertEquals("exampleExperiments.txt", a.getFileName()); + // assertEquals(version, a.getVersion()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // assertTrue(a.getRegistrationDate().getTime() > 0); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // String.format( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=%d&entity=EXPERIMENT&permId=200811050951882-1028", + // version), + // a.getPermLink()); + // --version; + // } + // } + // + // @Test + // public void testListAttachmentsForExperimentLatestVersion() + // { + // final List<Experiment> experiments = + // generalInformationService.listExperiments(sessionToken, + // Collections.singletonList("/CISD/NEMO/EXP1")); + // assertEquals(1, experiments.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromEntity(experiments.get(0)), false); + // assertEquals(1, attachments.size()); + // final Attachment a = attachments.get(0); + // assertEquals("exampleExperiments.txt", a.getFileName()); + // assertEquals(4, a.getVersion()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // assertTrue(a.getRegistrationDate().getTime() > 0); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=4&entity=EXPERIMENT&permId=200811050951882-1028", + // a.getPermLink()); + // + // final List<Attachment> attachments2 = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromAugmentedCode("/CISD/NEMO/EXP1"), false); + // + // assertEquals(1, attachments2.size()); + // + // final Attachment a2 = attachments2.get(0); + // assertEquals(a, a2); + // } + // + // @Test + // public void testListAttachmentsForSample() + // { + // SearchCriteria searchCriteria = new SearchCriteria(); + // searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, + // "3VCP6")); + // + // final List<Sample> samples = + // generalInformationService.searchForSamples(sessionToken, searchCriteria); + // assertEquals(1, samples.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromEntity(samples.get(0)), + // true); + // assertEquals(1, attachments.size()); + // + // final Attachment a = attachments.get(0); + // assertEquals("sampleHistory.txt", a.getFileName()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // assertEquals(1, a.getVersion()); + // assertTrue(a.getRegistrationDate().getTime() > 0); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=sampleHistory.txt&version=1&entity=SAMPLE&permId=200811050946559-980", + // a.getPermLink()); + // + // final List<Attachment> attachments2 = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromPermId("200811050946559-980"), true); + // + // assertEquals(1, attachments2.size()); + // + // final Attachment a2 = attachments2.get(0); + // assertEquals(a, a2); + // + // final List<Attachment> attachments3 = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromAugmentedCode("/CISD/3VCP6"), true); + // + // assertEquals(1, attachments3.size()); + // + // final Attachment a3 = attachments3.get(0); + // assertEquals(a, a3); + // } + // + // @Test + // public void testListAttachmentsForProjectNoAttachment() + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromAugmentedCode("/CISD/DEFAULT"), true); + // + // assertEquals(0, attachments.size()); + // } + // + // @Test + // public void testListAttachmentsForProjectNonExisting() + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromAugmentedCode("/NONE/EXISTENT"), true); + // + // assertEquals(0, attachments.size()); + // } + // + // @Test + // public void testListAttachmentsForProjects() throws ParseException + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromPermId("20120814110011738-103"), true); + // + // assertEquals(1, attachments.size()); + // + // final Attachment a = attachments.get(0); + // assertEquals("projectDescription.txt", a.getFileName()); + // assertEquals("The Project", a.getTitle()); + // assertEquals("All about it.", a.getDescription()); + // assertEquals(1, a.getVersion()); + // final Date date = + // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") + // .parse("2012-01-03 08:27:57.123 +0100"); + // assertEquals(date, a.getRegistrationDate()); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=projectDescription.txt&version=1&entity=PROJECT&code=NEMO&space=CISD", + // a.getPermLink()); + // } } diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/api/v1/GeneralInformationServiceTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/api/v1/GeneralInformationServiceTest.java index 5fa3222b443..93a7e3d0ed7 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/api/v1/GeneralInformationServiceTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/systemtest/api/v1/GeneralInformationServiceTest.java @@ -40,7 +40,6 @@ import org.testng.annotations.Test; import ch.systemsx.cisd.common.exceptions.AuthorizationFailureException; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; @@ -48,19 +47,16 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDeta import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.EntityRegistrationDetails.EntityRegistrationDetailsInitializer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment.ExperimentInitializer; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialTypeIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MetaprojectAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.PropertyTypeGroup; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample.SampleInitializer; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.CompareMode; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria.MatchClause; @@ -786,7 +782,8 @@ public class GeneralInformationServiceTest extends SystemTestCase s1.setRegistrationDetails(new EntityRegistrationDetails( new EntityRegistrationDetailsInitializer())); Sample sample = new Sample(s1); - AbstractExternalData dataSetInfo = genericServer.getDataSetInfo(sessionToken, new TechId(13)); + AbstractExternalData dataSetInfo = + genericServer.getDataSetInfo(sessionToken, new TechId(13)); DataSetUpdatesDTO updates = new DataSetUpdatesDTO(); updates.setVersion(dataSetInfo.getVersion()); updates.setDatasetId(new TechId(dataSetInfo.getId())); @@ -1665,197 +1662,197 @@ public class GeneralInformationServiceTest extends SystemTestCase assertEquals("TEST_METAPROJECTS", metaprojectAssignments.getMetaproject().getName()); } - @Test - public void testListAttachmentsForExperimentAllVersions() throws ParseException - { - final List<Experiment> experiments = - generalInformationService.listExperiments(sessionToken, - Collections.singletonList("/CISD/NEMO/EXP1")); - assertEquals(1, experiments.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromEntity(experiments.get(0)), - true); - assertEquals(4, attachments.size()); - int version = 4; - final String[] regDates = - new String[] - { "2008-12-10 13:49:27.901 +0100", "2008-12-10 13:49:20.236 +0100", - "2008-12-10 13:49:14.564 +0100", "2008-12-10 13:48:17.996 +0100" }; - for (Attachment a : attachments) - { - assertEquals("exampleExperiments.txt", a.getFileName()); - assertEquals(version, a.getVersion()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - final Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") - .parse(regDates[4 - version]); - assertEquals( - date, - a.getRegistrationDate()); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - String.format( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=%d&entity=EXPERIMENT&permId=200811050951882-1028", - version), - a.getPermLink()); - --version; - } - } - - @Test - public void testListAttachmentsForExperimentLatestVersion() throws ParseException - { - final List<Experiment> experiments = - generalInformationService.listExperiments(sessionToken, - Collections.singletonList("/CISD/NEMO/EXP1")); - assertEquals(1, experiments.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromEntity(experiments.get(0)), false); - assertEquals(1, attachments.size()); - final Attachment a = attachments.get(0); - assertEquals("exampleExperiments.txt", a.getFileName()); - assertEquals(4, a.getVersion()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - final Date date = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") - .parse("2008-12-10 13:49:27.901 +0100"); - assertEquals(date, a.getRegistrationDate()); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=4&entity=EXPERIMENT&permId=200811050951882-1028", - a.getPermLink()); - - final List<Attachment> attachments2 = - generalInformationService.listAttachmentsForExperiment(sessionToken, - ExperimentIdentifier.createFromAugmentedCode("/CISD/NEMO/EXP1"), false); - - assertEquals(1, attachments2.size()); - - final Attachment a2 = attachments2.get(0); - assertEquals(a, a2); - } - - @Test - public void testListAttachmentsForSample() throws ParseException - { - SearchCriteria searchCriteria = new SearchCriteria(); - searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, - "3VCP6")); - - final List<Sample> samples = - generalInformationService.searchForSamples(sessionToken, searchCriteria); - assertEquals(1, samples.size()); - - final List<Attachment> attachments = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromEntity(samples.get(0)), - true); - assertEquals(1, attachments.size()); - - final Attachment a = attachments.get(0); - assertEquals("sampleHistory.txt", a.getFileName()); - assertEquals("", a.getTitle()); - assertEquals("", a.getDescription()); - assertEquals(1, a.getVersion()); - final Date date = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") - .parse("2009-06-09 17:00:00.000 +0200"); - assertEquals(date, a.getRegistrationDate()); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=sampleHistory.txt&version=1&entity=SAMPLE&permId=200811050946559-980", - a.getPermLink()); - - final List<Attachment> attachments2 = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromPermId("200811050946559-980"), true); - - assertEquals(1, attachments2.size()); - - final Attachment a2 = attachments2.get(0); - assertEquals(a, a2); - - final List<Attachment> attachments3 = - generalInformationService.listAttachmentsForSample(sessionToken, - SampleIdentifier.createFromAugmentedCode("/CISD/3VCP6"), true); - - assertEquals(1, attachments3.size()); - - final Attachment a3 = attachments3.get(0); - assertEquals(a, a3); - } - - @Test - public void testListAttachmentsForProjectNoAttachment() - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromAugmentedCode("/CISD/DEFAULT"), true); - - assertEquals(0, attachments.size()); - } - - @Test - public void testListAttachmentsForProjectNonExisting() - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromAugmentedCode("/NONE/EXISTENT"), true); - - assertEquals(0, attachments.size()); - } - - @Test - public void testListAttachmentsForProject() throws ParseException - { - final List<Attachment> attachments = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromPermId("20120814110011738-103"), true); - - assertEquals(1, attachments.size()); - - final Attachment a = attachments.get(0); - assertEquals("projectDescription.txt", a.getFileName()); - assertEquals("The Project", a.getTitle()); - assertEquals("All about it.", a.getDescription()); - assertEquals(1, a.getVersion()); - final Date date = - new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") - .parse("2012-01-03 08:27:57.123 +0100"); - assertEquals(date, a.getRegistrationDate()); - assertEquals("test", a.getUserId()); - assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); - assertNotNull(a.getUserFirstName()); - assertNotNull(a.getUserLastName()); - assertEquals( - "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=projectDescription.txt&version=1&entity=PROJECT&code=NEMO&space=CISD", - a.getPermLink()); - - final List<Attachment> attachments2 = - generalInformationService.listAttachmentsForProject(sessionToken, - ProjectIdentifier.createFromAugmentedCode("/CISD/NEMO"), true); - - assertEquals(1, attachments2.size()); - - final Attachment a2 = attachments2.get(0); - assertEquals(a, a2); - - } - + // @Test + // public void testListAttachmentsForExperimentAllVersions() throws ParseException + // { + // final List<Experiment> experiments = + // generalInformationService.listExperiments(sessionToken, + // Collections.singletonList("/CISD/NEMO/EXP1")); + // assertEquals(1, experiments.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromEntity(experiments.get(0)), + // true); + // assertEquals(4, attachments.size()); + // int version = 4; + // final String[] regDates = + // new String[] + // { "2008-12-10 13:49:27.901 +0100", "2008-12-10 13:49:20.236 +0100", + // "2008-12-10 13:49:14.564 +0100", "2008-12-10 13:48:17.996 +0100" }; + // for (Attachment a : attachments) + // { + // assertEquals("exampleExperiments.txt", a.getFileName()); + // assertEquals(version, a.getVersion()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // final Date date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") + // .parse(regDates[4 - version]); + // assertEquals( + // date, + // a.getRegistrationDate()); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // String.format( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=%d&entity=EXPERIMENT&permId=200811050951882-1028", + // version), + // a.getPermLink()); + // --version; + // } + // } + // + // @Test + // public void testListAttachmentsForExperimentLatestVersion() throws ParseException + // { + // final List<Experiment> experiments = + // generalInformationService.listExperiments(sessionToken, + // Collections.singletonList("/CISD/NEMO/EXP1")); + // assertEquals(1, experiments.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromEntity(experiments.get(0)), false); + // assertEquals(1, attachments.size()); + // final Attachment a = attachments.get(0); + // assertEquals("exampleExperiments.txt", a.getFileName()); + // assertEquals(4, a.getVersion()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // final Date date = + // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") + // .parse("2008-12-10 13:49:27.901 +0100"); + // assertEquals(date, a.getRegistrationDate()); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=exampleExperiments.txt&version=4&entity=EXPERIMENT&permId=200811050951882-1028", + // a.getPermLink()); + // + // final List<Attachment> attachments2 = + // generalInformationService.listAttachmentsForExperiment(sessionToken, + // ExperimentIdentifier.createFromAugmentedCode("/CISD/NEMO/EXP1"), false); + // + // assertEquals(1, attachments2.size()); + // + // final Attachment a2 = attachments2.get(0); + // assertEquals(a, a2); + // } + // + // @Test + // public void testListAttachmentsForSample() throws ParseException + // { + // SearchCriteria searchCriteria = new SearchCriteria(); + // searchCriteria.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.CODE, + // "3VCP6")); + // + // final List<Sample> samples = + // generalInformationService.searchForSamples(sessionToken, searchCriteria); + // assertEquals(1, samples.size()); + // + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromEntity(samples.get(0)), + // true); + // assertEquals(1, attachments.size()); + // + // final Attachment a = attachments.get(0); + // assertEquals("sampleHistory.txt", a.getFileName()); + // assertEquals("", a.getTitle()); + // assertEquals("", a.getDescription()); + // assertEquals(1, a.getVersion()); + // final Date date = + // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") + // .parse("2009-06-09 17:00:00.000 +0200"); + // assertEquals(date, a.getRegistrationDate()); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=sampleHistory.txt&version=1&entity=SAMPLE&permId=200811050946559-980", + // a.getPermLink()); + // + // final List<Attachment> attachments2 = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromPermId("200811050946559-980"), true); + // + // assertEquals(1, attachments2.size()); + // + // final Attachment a2 = attachments2.get(0); + // assertEquals(a, a2); + // + // final List<Attachment> attachments3 = + // generalInformationService.listAttachmentsForSample(sessionToken, + // SampleIdentifier.createFromAugmentedCode("/CISD/3VCP6"), true); + // + // assertEquals(1, attachments3.size()); + // + // final Attachment a3 = attachments3.get(0); + // assertEquals(a, a3); + // } + // + // @Test + // public void testListAttachmentsForProjectNoAttachment() + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromAugmentedCode("/CISD/DEFAULT"), true); + // + // assertEquals(0, attachments.size()); + // } + // + // @Test + // public void testListAttachmentsForProjectNonExisting() + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromAugmentedCode("/NONE/EXISTENT"), true); + // + // assertEquals(0, attachments.size()); + // } + // + // @Test + // public void testListAttachmentsForProject() throws ParseException + // { + // final List<Attachment> attachments = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromPermId("20120814110011738-103"), true); + // + // assertEquals(1, attachments.size()); + // + // final Attachment a = attachments.get(0); + // assertEquals("projectDescription.txt", a.getFileName()); + // assertEquals("The Project", a.getTitle()); + // assertEquals("All about it.", a.getDescription()); + // assertEquals(1, a.getVersion()); + // final Date date = + // new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z") + // .parse("2012-01-03 08:27:57.123 +0100"); + // assertEquals(date, a.getRegistrationDate()); + // assertEquals("test", a.getUserId()); + // assertEquals("franz-josef.elmer@systemsx.ch", a.getUserEmail()); + // assertNotNull(a.getUserFirstName()); + // assertNotNull(a.getUserLastName()); + // assertEquals( + // "http://localhost/openbis/index.html?viewMode=SIMPLE#action=DOWNLOAD_ATTACHMENT&file=projectDescription.txt&version=1&entity=PROJECT&code=NEMO&space=CISD", + // a.getPermLink()); + // + // final List<Attachment> attachments2 = + // generalInformationService.listAttachmentsForProject(sessionToken, + // ProjectIdentifier.createFromAugmentedCode("/CISD/NEMO"), true); + // + // assertEquals(1, attachments2.size()); + // + // final Attachment a2 = attachments2.get(0); + // assertEquals(a, a2); + // + // } + // private void sortDataSets(List<DataSet> dataSets) { Collections.sort(dataSets, new Comparator<DataSet>() diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java index 61e8e1c8c5d..646b68534ad 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java @@ -24,7 +24,6 @@ import java.util.Set; import ch.systemsx.cisd.common.api.IRpcService; import ch.systemsx.cisd.common.exceptions.UserFailureException; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Attachment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ControlledVocabularyPropertyType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; @@ -32,16 +31,13 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStoreURLForDataSets; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ExperimentIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MetaprojectAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Project; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.ProjectIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Role; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleFetchOption; -import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SampleIdentifier; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.SpaceWithProjectsAndRoleAssignments; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.id.metaproject.IMetaprojectId; @@ -490,30 +486,4 @@ public interface IGeneralInformationService extends IRpcService */ public MetaprojectAssignments getMetaproject(String sessionToken, IMetaprojectId metaprojectId); - /** - * @param project The project to list the attachments for. - * @param allVersions If <code>true</code>, return all versions of the attachments, otherwise - * return only the latest version. - * @since 1.22 - */ - public List<Attachment> listAttachmentsForProject(String sessionToken, - ProjectIdentifier project, boolean allVersions); - - /** - * @param experiment The experiment to list the attachments for. - * @param allVersions If <code>true</code>, return all versions of the attachments, otherwise - * return only the latest version. - * @since 1.22 - */ - public List<Attachment> listAttachmentsForExperiment(String sessionToken, - ExperimentIdentifier experiment, boolean allVersions); - - /** - * @param sample The sample to list the attachments for. - * @param allVersions If <code>true</code>, return all versions of the attachments, otherwise - * return only the latest version. - * @since 1.22 - */ - public List<Attachment> listAttachmentsForSample(String sessionToken, - SampleIdentifier sample, boolean allVersions); } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ExperimentIdentifier.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ExperimentIdentifier.java deleted file mode 100644 index cd52530da7f..00000000000 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ExperimentIdentifier.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2010 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.shared.api.v1.dto; - -import java.io.Serializable; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import ch.systemsx.cisd.common.reflection.ModifiedShortPrefixToStringStyle; - -/** - * Unique identifier for an experiment in openBIS. - * - * @author Bernd Rinn - */ -@SuppressWarnings("unused") -@JsonObject("ExperimentIdentifier") -public class ExperimentIdentifier implements Serializable, IPermanentIdentifier, IDatabaseIdentifier -{ - private static final long serialVersionUID = 1L; - - private Long databaseId; - - private String permId; - - private String spaceCode; - - private String projectCode; - - private String code; - - /** - * Creates an {@link ExperimentIdentifier} from the given <var>augmentedCode</code>. - * - * @param augmentedCode The <var>augmentedCode</code> in the form - * <code>/SPACE/PROJECT/EXPERIMENT</code> - * @return An experiment identifer corresponding to <var>augmentedCode</code>. Note that this - * experiment identifier has no perm id or database id set. - * @throws IllegalArgumentException If the <var>augmentedCode</code> is not in the form - * <code>/SPACE/PROJECT/EXPERIMENT</code>. - */ - public static ExperimentIdentifier createFromAugmentedCode(String augmentedCode) - throws IllegalArgumentException - { - final String[] splitted = augmentedCode.split("/"); - if (splitted.length != 4 || splitted[0].length() != 0) - { - throw new IllegalArgumentException("Augmented code '" + augmentedCode - + "' needs to be either of the form '/SPACE/PROJECT/EXPERIMENT' " - + "or 'PROJECT/EXPERIMENT'."); - } - if (StringUtils.isBlank(splitted[3])) - { - throw new IllegalArgumentException("No code given."); - } - if (StringUtils.isBlank(splitted[2])) - { - throw new IllegalArgumentException("No project code given."); - } - if (StringUtils.isBlank(splitted[1])) - { - throw new IllegalArgumentException("No space code given."); - } - return new ExperimentIdentifier(null, null, splitted[3], splitted[2], splitted[1]); - } - - /** - * Creates an {@link ExperimentIdentifier} from the given <var>permId</code>. - * - * @param permId The <var>permId</code> - * @return An experiment identifier corresponding to <var>permId</code>. Note that this - * experiment identifier has no code, project or space information. - */ - public static ExperimentIdentifier createFromPermId(String permId) - throws IllegalArgumentException - { - if (StringUtils.isBlank(permId)) - { - throw new IllegalArgumentException("No perm id given."); - } - return new ExperimentIdentifier(null, permId, null, null, null); - } - - /** - * Creates an {@link ExperimentIdentifier} from the given <var>entity</code>. - * - * @param entity The entity as received from one of the other methods. - * @return An experiment identifier corresponding to <var>entity</code>. Note that this - * experiment identifier has no permid, code, project or space information. - */ - public static ExperimentIdentifier createFromEntity(Experiment entity) - { - return new ExperimentIdentifier(entity.getId(), null, null, null, null); - } - - /** - * A <code>spaceCode == null</code> is interpreted as the home space. - */ - private ExperimentIdentifier(Long databaseId, String permId, String code, - String projectCode, String spaceCode) - { - this.databaseId = databaseId; - this.permId = permId; - this.spaceCode = spaceCode; - this.projectCode = projectCode; - this.code = code; - } - - @Override - public Long getDatabaseId() - { - return databaseId; - } - - @Override - public String getPermId() - { - return permId; - } - - /** - * The code of the space of this experiment. - */ - public String getSpaceCode() - { - return spaceCode; - } - - /** - * The code of the project of this experiment. - */ - public String getProjectCode() - { - return projectCode; - } - - /** - * The experiment code. - */ - public String getCode() - { - return code; - } - - /** - * Returns the augmented (full) code of this experiment. - */ - @JsonIgnore - public String getAugmentedCode() - { - if (code == null) - { - return null; - } - return "/" + spaceCode + "/" + projectCode + "/" + code; - } - - // - // JSON-RPC - // - - private ExperimentIdentifier() - { - } - - private void setSpaceCode(String spaceCode) - { - this.spaceCode = spaceCode; - } - - private void setProjectCode(String projectCode) - { - this.projectCode = projectCode; - } - - private void setcode(String code) - { - this.code = code; - } - - private void setPermId(String permId) - { - this.permId = permId; - } - - private void setDatabaseId(Long databaseId) - { - this.databaseId = databaseId; - } - - @Override - public final boolean equals(final Object obj) - { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public final int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() - { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } -} diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IDatabaseIdentifier.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IDatabaseIdentifier.java deleted file mode 100644 index d60c1561d40..00000000000 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IDatabaseIdentifier.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2013 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.shared.api.v1.dto; - -/** - * A database id of an entity. - * <i> - * Note that this is id not meant to be persisted anywhere outside of the database. Use - * {@link IPermanentIdentifier} for that. - * - * @author Bernd Rinn - */ -public interface IDatabaseIdentifier -{ - /** - * Returns the database id of the entity. - */ - public Long getDatabaseId(); -} diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IPermanentIdentifier.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IPermanentIdentifier.java deleted file mode 100644 index 4a55874d282..00000000000 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/IPermanentIdentifier.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2010 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.shared.api.v1.dto; - -/** - * A role that represents a permanent identifier in openBIS. - * - * @author Bernd Rinn - */ -public interface IPermanentIdentifier -{ - - /** - * Returns the permanent identifier. - */ - public String getPermId(); - -} \ No newline at end of file diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ProjectIdentifier.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ProjectIdentifier.java deleted file mode 100644 index 8ac113ce45c..00000000000 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/ProjectIdentifier.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * Copyright 2010 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.shared.api.v1.dto; - -import java.io.Serializable; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import ch.systemsx.cisd.common.reflection.ModifiedShortPrefixToStringStyle; - -/** - * Unique identifier for a project in openBIS. - * - * @author Bernd Rinn - */ -@SuppressWarnings("unused") -@JsonObject("ProjectIdentifier") -public class ProjectIdentifier implements Serializable, IPermanentIdentifier, IDatabaseIdentifier -{ - private static final long serialVersionUID = 1L; - - private Long databaseId; - - private String permId; - - private String spaceCode; - - private String code; - - /** - * Creates an {@link ProjectIdentifier} from the given <var>augmentedCode</code>. - * - * @param augmentedCode The <var>augmentedCode</code> in the form - * <code>/SPACE/PROJECT</code>. - * @return A sample identifier corresponding to <var>augmentedCode</code>. Note that this - * sample identifier has no perm id set. - * @throws IllegalArgumentException If the <var>augmentedCode</code> is not in the form - * <code>/SPACE/SAMPLE</code> or <code>/SAMPLE</code>. - */ - public static ProjectIdentifier createFromAugmentedCode(String augmentedCode) - throws IllegalArgumentException - { - final String[] splitted = augmentedCode.split("/"); - if (splitted.length == 3 && splitted[0].length() == 0) - { - return new ProjectIdentifier(null, null, splitted[2], splitted[1]); - } - throw new IllegalArgumentException("Augmented code '" + augmentedCode - + "' needs to be of the form '/SPACE/PROJECT'."); - } - - /** - * Creates an {@link ProjectIdentifier} from the given <var>permId</code>. - * - * @param permId The <var>permId</code> - * @return An identifier corresponding to <var>permId</code>. Note that this - * identifier has no code, project or space information. - */ - public static ProjectIdentifier createFromPermId(String permId) - throws IllegalArgumentException - { - return new ProjectIdentifier(null, permId, null, null); - } - - /** - * Creates an {@link ProjectIdentifier} from the given <var>entity</code>. - * - * @param entity The entity as received from one of the other methods. - * @return An identifier corresponding to <var>entity</code>. Note that this - * identifier has no perm id, code, project or space information. - */ - public static ProjectIdentifier createFromEntity(Project entity) - { - return new ProjectIdentifier(entity.getId(), null, null, null); - } - - private ProjectIdentifier(Long databaseId, String permId, String sampleCode, - String spaceCode) - { - this.databaseId = databaseId; - this.permId = permId; - this.spaceCode = spaceCode; - this.code = sampleCode; - } - - @Override - public Long getDatabaseId() - { - return databaseId; - } - - @Override - public String getPermId() - { - return permId; - } - - /** - * The code of the space of this project. - */ - public String getSpaceCode() - { - return spaceCode; - } - - public String getCode() - { - return code; - } - - /** - * Returns the augmented (full) code of this project. - */ - @JsonIgnore - public String getAugmentedCode() - { - if (code == null) - { - return null; - } - return "/" + spaceCode + "/" + code; - } - - // - // JSON-RPC - // - - private ProjectIdentifier() - { - } - - private void setSpaceCode(String spaceCode) - { - this.spaceCode = spaceCode; - } - - private void setCode(String code) - { - this.code = code; - } - - private void setPermId(String permId) - { - this.permId = permId; - } - - private void setDatabaseId(Long databaseId) - { - this.databaseId = databaseId; - } - - @Override - public final boolean equals(final Object obj) - { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public final int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() - { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } -} diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SampleIdentifier.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SampleIdentifier.java deleted file mode 100644 index 4b2216f15f2..00000000000 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/SampleIdentifier.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * Copyright 2010 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.shared.api.v1.dto; - -import java.io.Serializable; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.commons.lang.builder.ToStringBuilder; -import org.apache.commons.lang.builder.ToStringStyle; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -import ch.systemsx.cisd.base.annotation.JsonObject; -import ch.systemsx.cisd.common.reflection.ModifiedShortPrefixToStringStyle; - -/** - * Unique identifier for a sample in openBIS. - * - * @author Bernd Rinn - */ -@SuppressWarnings("unused") -@JsonObject("SampleIdentifier") -public class SampleIdentifier implements Serializable, IPermanentIdentifier, IDatabaseIdentifier -{ - private static final long serialVersionUID = 1L; - - private Long databaseId; - - private String permId; - - private String spaceCode; - - private String code; - - /** - * Creates an {@link SampleIdentifier} from the given <var>augmentedCode</code>. - * - * @param augmentedCode The <var>augmentedCode</code> in the form - * <code>/SPACE/SAMPLE</code> or <code>/SAMPLE</code>. - * @return A sample identifier corresponding to <var>augmentedCode</code>. Note that this - * sample identifier has no perm id set. - * @throws IllegalArgumentException If the <var>augmentedCode</code> is not in the form - * <code>/SPACE/SAMPLE</code> or <code>/SAMPLE</code>. - */ - public static SampleIdentifier createFromAugmentedCode(String augmentedCode) - throws IllegalArgumentException - { - final String[] splitted = augmentedCode.split("/"); - if (splitted.length == 3 && splitted[0].length() == 0) - { - return new SampleIdentifier(null, null, splitted[2], splitted[1]); - } - if (splitted.length == 2 && splitted[0].length() == 0) // Instance sample - { - return new SampleIdentifier(null, null, splitted[1], null); - } - throw new IllegalArgumentException("Augmented code '" + augmentedCode - + "' needs to be either of the form '/SPACE/SAMPLE' " + "or '/SAMPLE'."); - } - - /** - * Creates an {@link SampleIdentifier} from the given <var>permId</code>. - * - * @param permId The <var>permId</code> - * @return An identifier corresponding to <var>permId</code>. Note that this - * identifier has no code, project or space information. - */ - public static SampleIdentifier createFromPermId(String permId) - throws IllegalArgumentException - { - return new SampleIdentifier(null, permId, null, null); - } - - /** - * Creates an {@link SampleIdentifier} from the given <var>entity</code>. - * - * @param entity The entity as received from one of the other methods. - * @return An identifier corresponding to <var>entity</code>. Note that this - * identifier has no permid, code, project or space information. - */ - public static SampleIdentifier createFromEntity(Sample entity) - { - return new SampleIdentifier(entity.getId(), null, null, null); - } - - /** - * A <code>spaceCode == null</code> means: instance sample. - */ - private SampleIdentifier(Long databaseId, String permId, String sampleCode, - String spaceCode) - { - this.databaseId = databaseId; - this.permId = permId; - this.spaceCode = spaceCode; - this.code = sampleCode; - } - - @Override - public Long getDatabaseId() - { - return databaseId; - } - - @Override - public String getPermId() - { - return permId; - } - - /** - * The code of the space of this sample. - */ - public String getSpaceCode() - { - return spaceCode; - } - - public String getCode() - { - return code; - } - - /** - * Returns the augmented (full) code of this sample. - */ - @JsonIgnore - public String getAugmentedCode() - { - if (code == null) - { - return null; - } - if (spaceCode != null) - { - return "/" + spaceCode + "/" + code; - } else - { - return "/" + code; - } - } - - // - // JSON-RPC - // - - private SampleIdentifier() - { - } - - private void setSpaceCode(String spaceCode) - { - this.spaceCode = spaceCode; - } - - private void setCode(String code) - { - this.code = code; - } - - private void setPermId(String permId) - { - this.permId = permId; - } - - private void setDatabaseId(Long databaseId) - { - this.databaseId = databaseId; - } - - @Override - public final boolean equals(final Object obj) - { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public final int hashCode() - { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() - { - return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); - } -} -- GitLab