From f0dd38c7b08cb2f79f32fa79eb5ecf9b358f51ce Mon Sep 17 00:00:00 2001 From: felmer <franz-josef.elmer@id.ethz.ch> Date: Tue, 19 Nov 2019 13:05:55 +0100 Subject: [PATCH] SSDM-8929: Refactoring: methods errorTableModel() and logInvocationError() pulled up --- .../plugins/standard/AggregationService.java | 30 +++++++++++++++++++ .../plugins/standard/IngestionService.java | 29 ------------------ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AggregationService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AggregationService.java index 6a4a115ccfe..44f2b59cc6a 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AggregationService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/AggregationService.java @@ -18,14 +18,19 @@ package ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard; import java.io.File; import java.util.List; +import java.util.Map; import java.util.Properties; +import org.apache.commons.lang3.StringUtils; + import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IReportingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LinkModel; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ReportingPluginType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; +import ch.systemsx.cisd.openbis.generic.shared.util.IRowBuilder; +import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder; /** * The abstract superclass for plug-ins of type DSS_LINK. @@ -72,4 +77,29 @@ public abstract class AggregationService extends AbstractDatastorePlugin impleme + getReportingPluginType() + " tasks"); } + protected void logInvocationError(Map<String, Object> parameters, Throwable e) + { + StringBuilder sb = new StringBuilder(); + sb.append("Error producing aggregation report\n"); + sb.append("Class: "); + sb.append(getClass().getName()); + sb.append("\n"); + sb.append("Parameters: "); + sb.append(parameters.keySet()); + + operationLog.error(sb.toString(), e); + } + + protected TableModel errorTableModel(Map<String, Object> parameters, Throwable e) + { + SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); + builder.addHeader("Parameters"); + builder.addHeader("Error"); + IRowBuilder row = builder.addRow(); + row.setCell("Parameters", parameters.toString()); + String message = e.getMessage(); + row.setCell("Error", StringUtils.isBlank(message) ? e.toString() : message); + return builder.getTableModel(); + } + } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/IngestionService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/IngestionService.java index 302a4dbb491..86e33d2ceed 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/IngestionService.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/IngestionService.java @@ -24,8 +24,6 @@ import java.util.Map; import java.util.Properties; import java.util.concurrent.locks.ReentrantLock; -import org.apache.commons.lang3.StringUtils; - import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.common.action.AbstractDelegatedActionWithResult; import ch.systemsx.cisd.common.action.IDelegatedActionWithResult; @@ -66,8 +64,6 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation; import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel; -import ch.systemsx.cisd.openbis.generic.shared.util.IRowBuilder; -import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder; /** * @author Chandrasekhar Ramakrishnan @@ -413,31 +409,6 @@ public abstract class IngestionService<T extends DataSetInformation> extends Agg return false; } - protected TableModel errorTableModel(Map<String, Object> parameters, Throwable e) - { - SimpleTableModelBuilder builder = new SimpleTableModelBuilder(true); - builder.addHeader("Parameters"); - builder.addHeader("Error"); - IRowBuilder row = builder.addRow(); - row.setCell("Parameters", parameters.toString()); - String message = e.getMessage(); - row.setCell("Error", StringUtils.isBlank(message) ? e.toString() : message); - return builder.getTableModel(); - } - - protected void logInvocationError(Map<String, Object> parameters, Throwable e) - { - StringBuilder sb = new StringBuilder(); - sb.append("Error producing aggregation report\n"); - sb.append("Class: "); - sb.append(getClass().getName()); - sb.append("\n"); - sb.append("Parameters: "); - sb.append(parameters.keySet()); - - operationLog.error(sb.toString(), e); - } - /** * Callback when a transaction is rolledback. Subclasses may override. */ -- GitLab