[Minor] Logging of exception in StrolchSystemActionWithResult
This commit is contained in:
parent
2eaca7d7d8
commit
f6349dde10
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
* Copyright 2013 Robert von Burg <eitch@eitchnet.ch>
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@ -72,11 +72,11 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
|
||||||
* @param privilegeXmlFile
|
* @param privilegeXmlFile
|
||||||
* a {@link File} reference to the XML file containing the configuration for Privilege
|
* a {@link File} reference to the XML file containing the configuration for Privilege
|
||||||
*
|
*
|
||||||
* @return the initialized {@link PrivilegeHandler} where the {@link EncryptionHandler} and
|
* @return the initialized {@link PrivilegeHandler} where the {@link EncryptionHandler} and {@link
|
||||||
* {@link PersistenceHandler} are set and initialized as well
|
* PersistenceHandler} are set and initialized as well
|
||||||
*/
|
*/
|
||||||
private li.strolch.privilege.handler.PrivilegeHandler initializeFromXml(ComponentConfiguration configuration,
|
private li.strolch.privilege.handler.PrivilegeHandler initializeFromXml(ComponentConfiguration configuration,
|
||||||
File privilegeXmlFile) {
|
File privilegeXmlFile) {
|
||||||
|
|
||||||
// make sure file exists
|
// make sure file exists
|
||||||
if (!privilegeXmlFile.exists()) {
|
if (!privilegeXmlFile.exists()) {
|
||||||
|
@ -132,7 +132,7 @@ public class DefaultStrolchPrivilegeHandler extends StrolchComponent implements
|
||||||
}
|
}
|
||||||
return certificate;
|
return certificate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Certificate authenticateSingleSignOn(Object data) {
|
public Certificate authenticateSingleSignOn(Object data) {
|
||||||
assertContainerStarted();
|
assertContainerStarted();
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class StrolchSystemAction extends SystemAction {
|
||||||
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
|
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
|
||||||
|
|
||||||
private PrivilegedRunnable runnable;
|
private final PrivilegedRunnable runnable;
|
||||||
|
|
||||||
public StrolchSystemAction(PrivilegedRunnable runnable) {
|
public StrolchSystemAction(PrivilegedRunnable runnable) {
|
||||||
this.runnable = runnable;
|
this.runnable = runnable;
|
||||||
|
|
|
@ -3,16 +3,20 @@ package li.strolch.runtime.privilege;
|
||||||
import li.strolch.privilege.handler.SystemAction;
|
import li.strolch.privilege.handler.SystemAction;
|
||||||
import li.strolch.privilege.handler.SystemActionWithResult;
|
import li.strolch.privilege.handler.SystemActionWithResult;
|
||||||
import li.strolch.privilege.model.PrivilegeContext;
|
import li.strolch.privilege.model.PrivilegeContext;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link SystemAction} to run {@link PrivilegedRunnableWithResult} as a system user
|
* {@link SystemAction} to run {@link PrivilegedRunnableWithResult} as a system user
|
||||||
*
|
|
||||||
* @author Robert von Burg <eitch@eitchnet.ch>
|
|
||||||
*
|
*
|
||||||
* @param <T>
|
* @param <T>
|
||||||
|
*
|
||||||
|
* @author Robert von Burg <eitch@eitchnet.ch>
|
||||||
*/
|
*/
|
||||||
public class StrolchSystemActionWithResult<T> extends SystemActionWithResult<T> {
|
public class StrolchSystemActionWithResult<T> extends SystemActionWithResult<T> {
|
||||||
|
|
||||||
|
public static final Logger logger = LoggerFactory.getLogger(StrolchSystemAction.class);
|
||||||
|
|
||||||
private PrivilegedRunnableWithResult<T> runnable;
|
private PrivilegedRunnableWithResult<T> runnable;
|
||||||
|
|
||||||
public StrolchSystemActionWithResult(PrivilegedRunnableWithResult<T> runnable) {
|
public StrolchSystemActionWithResult(PrivilegedRunnableWithResult<T> runnable) {
|
||||||
|
@ -21,6 +25,12 @@ public class StrolchSystemActionWithResult<T> extends SystemActionWithResult<T>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public T execute(PrivilegeContext privilegeContext) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue