[New] Added tx.getConfiguration() to get getResourceBy(TYPE_CONFIGURATION, RES_CONFIGURATION)
gracefully handles missing resource
This commit is contained in:
parent
1b3b3778e6
commit
e017c98048
|
@ -662,6 +662,17 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
return getResourceMap().getTemplate(this, type, assertExists);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resource getConfiguration() {
|
||||
Resource configuration = getResourceBy(TYPE_CONFIGURATION, RES_CONFIGURATION, false);
|
||||
if (configuration == null) {
|
||||
configuration = new Resource(RES_CONFIGURATION, TYPE_CONFIGURATION, TYPE_CONFIGURATION);
|
||||
if (!isReadOnly())
|
||||
add(configuration);
|
||||
}
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order getOrderTemplate(String type) {
|
||||
return getOrderTemplate(type, false);
|
||||
|
@ -1693,7 +1704,8 @@ public abstract class AbstractTransaction implements StrolchTransaction {
|
|||
OperationsLog operationsLog = container.getComponent(OperationsLog.class);
|
||||
operationsLog.addMessage(new LogMessage(this.realm.getRealm(), this.certificate.getUsername(),
|
||||
Locator.valueOf(AGENT, "tx", this.action, getUniqueId()), LogSeverity.Exception,
|
||||
LogMessageState.Information, ResourceBundle.getBundle("strolch-agent"), "agent.tx.failed").withException(e).value("reason", e));
|
||||
LogMessageState.Information, ResourceBundle.getBundle("strolch-agent"), "agent.tx.failed")
|
||||
.withException(e).value("reason", e));
|
||||
}
|
||||
|
||||
String msg = "Strolch Transaction for realm {0} failed due to {1}\n{2}"; //$NON-NLS-1$
|
||||
|
|
|
@ -705,6 +705,18 @@ public interface StrolchTransaction extends AutoCloseable {
|
|||
*/
|
||||
Resource getResourceTemplate(String type, boolean assertExists) throws StrolchException;
|
||||
|
||||
/**
|
||||
* <p>Returns the {@link Resource} with the type {@link StrolchConstants#TYPE_CONFIGURATION} and id {@link
|
||||
* StrolchConstants#RES_CONFIGURATION}.</p>
|
||||
*
|
||||
* <p>Should the configuration resource not exist, then it will be created without any parameters, as {@link
|
||||
* Resource#getBoolean(String)} methods et. al. will then just return empty values for their corresponding
|
||||
* types.</p>
|
||||
*
|
||||
* @return the configuration resource
|
||||
*/
|
||||
Resource getConfiguration();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns a copy of the {@link Order} of Type {@link StrolchConstants#TEMPLATE} with the given type as id, or null
|
||||
|
|
Loading…
Reference in New Issue