Skip to content
Snippets Groups Projects
Commit 156fa724 authored by felmer's avatar felmer
Browse files

SSDM-3768: Introducing EntityUtils.render methods to add perm ID to...

SSDM-3768: Introducing EntityUtils.render methods to add perm ID to verification error messages because the original identifier might be changed.

SVN: 37552
parent 26a63383
No related branches found
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; ...@@ -28,6 +28,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress;
import ch.ethz.sis.openbis.generic.server.asapi.v3.utils.EntityUtils;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.spring.ExposablePropertyPlaceholderConfigurer; import ch.systemsx.cisd.common.spring.ExposablePropertyPlaceholderConfigurer;
import ch.systemsx.cisd.openbis.generic.server.business.bo.util.DataSetTypeWithoutExperimentChecker; import ch.systemsx.cisd.openbis.generic.server.business.bo.util.DataSetTypeWithoutExperimentChecker;
...@@ -102,7 +103,7 @@ public class VerifyDataSetSampleAndExperimentExecutor implements IVerifyDataSetS ...@@ -102,7 +103,7 @@ public class VerifyDataSetSampleAndExperimentExecutor implements IVerifyDataSetS
if (experiment != null && experiment.getDeletion() != null) if (experiment != null && experiment.getDeletion() != null)
{ {
throw new UserFailureException("Data set can not be registered because experiment '" throw new UserFailureException("Data set can not be registered because experiment '"
+ experiment.getIdentifier() + "' is in trash."); + EntityUtils.render(experiment) + "' is in trash.");
} }
} }
......
...@@ -23,6 +23,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; ...@@ -23,6 +23,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress;
import ch.ethz.sis.openbis.generic.server.asapi.v3.utils.EntityUtils;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleGenericBusinessRules; import ch.systemsx.cisd.openbis.generic.server.business.bo.SampleGenericBusinessRules;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
...@@ -48,8 +49,8 @@ public class VerifySampleContainerExecutor implements IVerifySampleContainerExec ...@@ -48,8 +49,8 @@ public class VerifySampleContainerExecutor implements IVerifySampleContainerExec
{ {
if (sample.equals(containerCandidate)) if (sample.equals(containerCandidate))
{ {
throw UserFailureException.fromTemplate("'%s' cannot be it's own container.", throw UserFailureException.fromTemplate("Sample %s cannot be it's own container.",
sample.getIdentifier()); EntityUtils.render(sample));
} }
containerCandidate = containerCandidate.getContainer(); containerCandidate = containerCandidate.getContainer();
} }
......
...@@ -26,6 +26,7 @@ import org.springframework.beans.factory.InitializingBean; ...@@ -26,6 +26,7 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.utils.EntityUtils;
import ch.systemsx.cisd.common.collection.CollectionUtils; import ch.systemsx.cisd.common.collection.CollectionUtils;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.spring.ExposablePropertyPlaceholderConfigurer; import ch.systemsx.cisd.common.spring.ExposablePropertyPlaceholderConfigurer;
...@@ -73,7 +74,7 @@ public class VerifySampleDataSetsExecutor implements IVerifySampleDataSetsExecut ...@@ -73,7 +74,7 @@ public class VerifySampleDataSetsExecutor implements IVerifySampleDataSetsExecut
if (dataSetsNeedingExperiment.isEmpty() == false) if (dataSetsNeedingExperiment.isEmpty() == false)
{ {
throw new UserFailureException("Operation cannot be performed, because the sample " throw new UserFailureException("Operation cannot be performed, because the sample "
+ sample.getIdentifier() + " has the following datasets which need an experiment: " + EntityUtils.render(sample) + " has the following datasets which need an experiment: "
+ CollectionUtils.abbreviate(dataSetsNeedingExperiment, 10)); + CollectionUtils.abbreviate(dataSetsNeedingExperiment, 10));
} }
......
...@@ -26,6 +26,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; ...@@ -26,6 +26,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress;
import ch.ethz.sis.openbis.generic.server.asapi.v3.utils.EntityUtils;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDAOFactory;
import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDataDAO; import ch.systemsx.cisd.openbis.generic.server.dataaccess.IDataDAO;
...@@ -79,26 +80,26 @@ public class VerifySampleExperimentExecutor implements IVerifySampleExperimentEx ...@@ -79,26 +80,26 @@ public class VerifySampleExperimentExecutor implements IVerifySampleExperimentEx
{ {
throw UserFailureException.fromTemplate("Cannot detach the sample '%s' from the space " throw UserFailureException.fromTemplate("Cannot detach the sample '%s' from the space "
+ "because there are already datasets attached to the sample.", + "because there are already datasets attached to the sample.",
sample.getIdentifier()); EntityUtils.render(sample));
} }
if (experiment != null && sample.getSpace() == null) if (experiment != null && sample.getSpace() == null)
{ {
throw new UserFailureException("Shared samples cannot be attached to experiments. Sample: " throw new UserFailureException("Shared samples cannot be attached to experiments. Sample: "
+ sample.getIdentifier() + ", Experiment: " + experiment.getIdentifier()); + EntityUtils.render(sample) + ", Experiment: " + EntityUtils.render(experiment));
} }
if (experiment != null && experiment.getProject().getSpace().equals(sample.getSpace()) == false) if (experiment != null && experiment.getProject().getSpace().equals(sample.getSpace()) == false)
{ {
throw new UserFailureException("Sample space must be the same as experiment space. " throw new UserFailureException("Sample space must be the same as experiment space. "
+ "Sample: " + sample.getIdentifier() + ", Experiment: " + experiment.getIdentifier()); + "Sample: " + EntityUtils.render(sample) + ", Experiment: " + EntityUtils.render(experiment));
} }
if (experiment != null && sample.getProject() != null if (experiment != null && sample.getProject() != null
&& experiment.getProject().equals(sample.getProject()) == false) && experiment.getProject().equals(sample.getProject()) == false)
{ {
throw new UserFailureException("Sample project must be the same as experiment project. " throw new UserFailureException("Sample project must be the same as experiment project. "
+ "Sample: " + sample.getIdentifier() + ", Project: " + sample.getProject().getIdentifier() + "Sample: " + EntityUtils.render(sample) + ", Project: " + EntityUtils.render(sample.getProject())
+ ", Experiment: " + experiment.getIdentifier()); + ", Experiment: " + EntityUtils.render(experiment));
} }
} }
......
...@@ -23,6 +23,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext; ...@@ -23,6 +23,7 @@ import ch.ethz.sis.openbis.generic.server.asapi.v3.executor.IOperationContext;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatch;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.common.batch.CollectionBatchProcessor;
import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress; import ch.ethz.sis.openbis.generic.server.asapi.v3.helper.entity.progress.VerifyProgress;
import ch.ethz.sis.openbis.generic.server.asapi.v3.utils.EntityUtils;
import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE; import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE; import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
...@@ -46,12 +47,12 @@ public class VerifySampleProjectExecutor implements IVerifySampleProjectExecutor ...@@ -46,12 +47,12 @@ public class VerifySampleProjectExecutor implements IVerifySampleProjectExecutor
if (project != null && sample.getSpace() == null) if (project != null && sample.getSpace() == null)
{ {
throw new UserFailureException("Shared samples cannot be attached to projects. Sample: " throw new UserFailureException("Shared samples cannot be attached to projects. Sample: "
+ sample.getIdentifier() + ", Project: " + project.getIdentifier()); + EntityUtils.render(sample) + ", Project: " + EntityUtils.render(project));
} }
if (project != null && project.getSpace().equals(sample.getSpace()) == false) if (project != null && project.getSpace().equals(sample.getSpace()) == false)
{ {
throw new UserFailureException("Sample space must be the same as project space. Sample: " throw new UserFailureException("Sample space must be the same as project space. Sample: "
+ sample.getIdentifier() + ", Project: " + project.getIdentifier()); + EntityUtils.render(sample) + ", Project: " + EntityUtils.render(project));
} }
} }
......
/*
* Copyright 2017 ETH Zuerich, SIS
*
* 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.ethz.sis.openbis.generic.server.asapi.v3.utils;
import ch.systemsx.cisd.openbis.generic.shared.dto.IEntityInformationHolderDTO;
import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
/**
* Entity utility functions.
*
* @author Franz-Josef Elmer
*/
public class EntityUtils
{
public static String render(IEntityInformationHolderDTO entity)
{
String identifier = entity.getIdentifier();
String permId = entity.getPermId();
return render(identifier, permId);
}
public static String render(ProjectPE project)
{
return render(project.getIdentifier(), project.getPermId());
}
private static String render(String identifier, String permId)
{
return identifier + " (perm id: " + permId + ")";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment