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

SSDM-8929: Refactoring: methods errorTableModel() and logInvocationError() pulled up

parent 28b26538
No related branches found
No related tags found
No related merge requests found
...@@ -18,14 +18,19 @@ package ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard; ...@@ -18,14 +18,19 @@ package ch.systemsx.cisd.openbis.dss.generic.server.plugins.standard;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Properties; 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.server.plugins.tasks.IReportingPluginTask;
import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext; 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.LinkModel;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ReportingPluginType; 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.basic.dto.TableModel;
import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription; 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. * The abstract superclass for plug-ins of type DSS_LINK.
...@@ -72,4 +77,29 @@ public abstract class AggregationService extends AbstractDatastorePlugin impleme ...@@ -72,4 +77,29 @@ public abstract class AggregationService extends AbstractDatastorePlugin impleme
+ getReportingPluginType() + " tasks"); + 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();
}
} }
...@@ -24,8 +24,6 @@ import java.util.Map; ...@@ -24,8 +24,6 @@ import java.util.Map;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.lang3.StringUtils;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel; import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.action.AbstractDelegatedActionWithResult; import ch.systemsx.cisd.common.action.AbstractDelegatedActionWithResult;
import ch.systemsx.cisd.common.action.IDelegatedActionWithResult; import ch.systemsx.cisd.common.action.IDelegatedActionWithResult;
...@@ -66,8 +64,6 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; ...@@ -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.dto.DataSetInformation;
import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DssPropertyParametersUtil; 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.basic.dto.TableModel;
import ch.systemsx.cisd.openbis.generic.shared.util.IRowBuilder;
import ch.systemsx.cisd.openbis.generic.shared.util.SimpleTableModelBuilder;
/** /**
* @author Chandrasekhar Ramakrishnan * @author Chandrasekhar Ramakrishnan
...@@ -413,31 +409,6 @@ public abstract class IngestionService<T extends DataSetInformation> extends Agg ...@@ -413,31 +409,6 @@ public abstract class IngestionService<T extends DataSetInformation> extends Agg
return false; 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. * Callback when a transaction is rolledback. Subclasses may override.
*/ */
......
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