[Minor] Logging of exception in StrolchSystemActionWithResult

This commit is contained in:
Robert von Burg 2018-08-03 22:14:12 +02:00
parent 2eaca7d7d8
commit f6349dde10
3 changed files with 21 additions and 11 deletions

View File

@ -1,12 +1,12 @@
/*
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
*
*
* 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.
@ -72,11 +72,11 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
* @param privilegeXmlFile
* a {@link File} reference to the XML file containing the configuration for Privilege
*
* @return the initialized {@link PrivilegeHandler} where the {@link EncryptionHandler} and
* {@link PersistenceHandler} are set and initialized as well
* @return the initialized {@link PrivilegeHandler} where the {@link EncryptionHandler} and {@link
* PersistenceHandler} are set and initialized as well
*/
private li.strolch.privilege.handler.PrivilegeHandler initializeFromXml(ComponentConfiguration configuration,
File privilegeXmlFile) {
File privilegeXmlFile) {
// make sure file exists
if (!privilegeXmlFile.exists()) {
@ -132,7 +132,7 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
}
return certificate;
}
@Override
public Certificate authenticateSingleSignOn(Object data) {
assertContainerStarted();

View File

@ -14,7 +14,7 @@ public class StrolchSystemAction extends SystemAction {
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
private PrivilegedRunnable runnable;
private final PrivilegedRunnable runnable;
public StrolchSystemAction(PrivilegedRunnable runnable) {
this.runnable = runnable;

View File

@ -3,16 +3,20 @@ package li.strolch.runtime.privilege;
import li.strolch.privilege.handler.SystemAction;
import li.strolch.privilege.handler.SystemActionWithResult;
import li.strolch.privilege.model.PrivilegeContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* {@link SystemAction} to run {@link PrivilegedRunnableWithResult} as a system user
*
* @author Robert von Burg <eitch@eitchnet.ch>
*
* @param <T>
*
* @author Robert von Burg <eitch@eitchnet.ch>
*/
public class StrolchSystemActionWithResult<T> extends SystemActionWithResult<T> {
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
private PrivilegedRunnableWithResult<T> runnable;
public StrolchSystemActionWithResult(PrivilegedRunnableWithResult<T> runnable) {
@ -21,6 +25,12 @@ public class StrolchSystemActionWithResult<T> extends SystemActionWithResult<T>
@Override
public T execute(PrivilegeContext privilegeContext) {
return this.runnable.run(privilegeContext);
try {
return this.runnable.run(privilegeContext);
} catch (Exception e) {
logger.error("Failed to execute SystemAction for " + privilegeContext.getUsername() + " due to " + e
.getMessage(), e);
throw e;
}
}
}