[Minor] Also log for which parameter the element was not found
This commit is contained in:
parent
e2aea114d3
commit
49d5e41fe5
|
@ -88,7 +88,7 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
public T getTemplate(StrolchTransaction tx, String type, boolean assertExists) {
|
public T getTemplate(StrolchTransaction tx, String type, boolean assertExists) {
|
||||||
T t = getCachedDao().queryBy(StrolchConstants.TEMPLATE, type);
|
T t = getCachedDao().queryBy(StrolchConstants.TEMPLATE, type);
|
||||||
if (assertExists && t == null) {
|
if (assertExists && t == null) {
|
||||||
String msg = "The template for type {0} does not exist!"; //$NON-NLS-1$
|
String msg = "The template with type {0} does not exist!"; //$NON-NLS-1$
|
||||||
throw new StrolchException(MessageFormat.format(msg, type));
|
throw new StrolchException(MessageFormat.format(msg, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
public T getBy(StrolchTransaction tx, String type, String id, boolean assertExists) throws StrolchException {
|
public T getBy(StrolchTransaction tx, String type, String id, boolean assertExists) throws StrolchException {
|
||||||
T t = getCachedDao().queryBy(type, id);
|
T t = getCachedDao().queryBy(type, id);
|
||||||
if (assertExists && t == null) {
|
if (assertExists && t == null) {
|
||||||
String msg = "The element for type {0} and id {1} does not exist!"; //$NON-NLS-1$
|
String msg = "The element with type {0} and id {1} does not exist!"; //$NON-NLS-1$
|
||||||
throw new StrolchException(MessageFormat.format(msg, type, id));
|
throw new StrolchException(MessageFormat.format(msg, type, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
throws StrolchException {
|
throws StrolchException {
|
||||||
T t = getDbDao(tx).queryBy(type, id, version);
|
T t = getDbDao(tx).queryBy(type, id, version);
|
||||||
if (assertExists && t == null) {
|
if (assertExists && t == null) {
|
||||||
String msg = "The element for type {0} and id {1} and version {2} does not exist!"; //$NON-NLS-1$
|
String msg = "The element with type {0} and id {1} and version {2} does not exist!"; //$NON-NLS-1$
|
||||||
msg = MessageFormat.format(msg, type, id, version);
|
msg = MessageFormat.format(msg, type, id, version);
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,12 @@ public abstract class CachedElementMap<T extends StrolchRootElement> implements
|
||||||
assertIsRefParam(refP);
|
assertIsRefParam(refP);
|
||||||
String type = refP.getUom();
|
String type = refP.getUom();
|
||||||
String id = refP.getValue();
|
String id = refP.getValue();
|
||||||
return getBy(tx, type, id, assertExists);
|
T t = getBy(tx, type, id, false);
|
||||||
|
if (assertExists && t == null) {
|
||||||
|
String msg = "The element with type {0} and id {1} does not exist for param {2}"; //$NON-NLS-1$
|
||||||
|
throw new StrolchException(MessageFormat.format(msg, type, id, refP.getLocator()));
|
||||||
|
}
|
||||||
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue