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

LMS-2328 fixed

SVN: 21878
parent ed2e929a
No related branches found
No related tags found
No related merge requests found
......@@ -201,6 +201,8 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
}
private final OmniscientTopLevelDataSetRegistratorState state;
private final IThrowableHandler finalThrowableHandler;
private boolean stopped;
......@@ -211,8 +213,25 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
*/
protected AbstractOmniscientTopLevelDataSetRegistrator(
TopLevelDataSetRegistratorGlobalState globalState)
{
this(globalState, new IThrowableHandler()
{
public void handle(Throwable throwable)
{
}
});
}
/**
* Constructor.
*
* @param globalState
*/
protected AbstractOmniscientTopLevelDataSetRegistrator(
TopLevelDataSetRegistratorGlobalState globalState, IThrowableHandler finalThrowableHandler)
{
super(globalState);
this.finalThrowableHandler = finalThrowableHandler;
IStorageProcessorTransactional storageProcessor =
PropertiesBasedETLServerPlugin.create(IStorageProcessorTransactional.class,
......@@ -352,7 +371,7 @@ public abstract class AbstractOmniscientTopLevelDataSetRegistrator<T extends Dat
incomingDataSetFile, null, ex, ErrorType.REGISTRATION_SCRIPT_ERROR);
operationLog.info(rollbacker.getErrorMessageForLog());
rollbacker.doRollback();
finalThrowableHandler.handle(ex);
}
return service;
......
/*
* Copyright 2011 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.etlserver.registrator;
/**
* Interface of classes able to handle {@link Throwable} instances.
*
* @author Franz-Josef Elmer
*/
public interface IThrowableHandler
{
public void handle(Throwable throwable);
}
......@@ -19,10 +19,12 @@ package ch.systemsx.cisd.etlserver.registrator;
import java.io.File;
import org.python.core.Py;
import org.python.core.PyException;
import org.python.core.PyFunction;
import org.python.util.PythonInterpreter;
import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException;
import ch.systemsx.cisd.common.exceptions.UserFailureException;
import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.utilities.IDelegatedActionWithResult;
import ch.systemsx.cisd.common.utilities.PropertyUtils;
......@@ -70,6 +72,27 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
// The key for the script in the properties file
public static final String SCRIPT_PATH_KEY = "script-path";
private static final IThrowableHandler FINAL_THROWABLE_HANDLER = new IThrowableHandler()
{
public void handle(Throwable throwable)
{
if (throwable instanceof PyException)
{
throw new RuntimeException(throwable.toString());
}
if (throwable instanceof UserFailureException)
{
throw new RuntimeException(throwable.getMessage());
}
Throwable cause = throwable;
while (cause.getCause() != null)
{
cause = cause.getCause();
}
throw new RuntimeException(cause.toString());
}
};
private final File scriptFile;
......@@ -80,7 +103,7 @@ public class JythonTopLevelDataSetHandler<T extends DataSetInformation> extends
*/
public JythonTopLevelDataSetHandler(TopLevelDataSetRegistratorGlobalState globalState)
{
super(globalState);
super(globalState, FINAL_THROWABLE_HANDLER);
String path =
PropertyUtils.getMandatoryProperty(globalState.getThreadParameters()
......
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