Skip to content

Commit

Permalink
Provide a more meaningful warning if state transformation in item fails
Browse files Browse the repository at this point in the history
Because the TransformationHelper throws a TransformationException to the
caller since PR eclipse-archived#5679, it is now possible to provide a meaningful warning
where the transformation is started, i.e. provide the item name.

Fixes eclipse-archived#5120

Signed-off-by: Stefan Triller <[email protected]>
  • Loading branch information
triller-telekom committed Jul 12, 2018
1 parent 7f7bfe2 commit c112be0
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static EnrichedItemDTO map(Item item, boolean drillDown, Predicate<Item>
private static EnrichedItemDTO map(Item item, ItemDTO itemDTO, URI uri, boolean drillDown,
Predicate<Item> itemFilter, Locale locale) {
String state = item.getState().toFullString();
String transformedState = considerTransformation(state, item.getStateDescription(locale));
String transformedState = considerTransformation(state, item, locale);
if (transformedState != null && transformedState.equals(state)) {
transformedState = null;
}
Expand Down Expand Up @@ -106,7 +106,8 @@ private static StateDescription considerTransformation(StateDescription desc) {
}
}

private static String considerTransformation(String state, StateDescription stateDescription) {
private static String considerTransformation(String state, Item item, Locale locale) {
StateDescription stateDescription = item.getStateDescription(locale);
if (stateDescription != null && stateDescription.getPattern() != null && state != null) {
try {
return TransformationHelper.transform(RESTCoreActivator.getBundleContext(),
Expand All @@ -116,8 +117,8 @@ private static String considerTransformation(String state, StateDescription stat
// return state as it is without transformation
return state;
} catch (TransformationException e) {
LOGGER.debug("Failed transforming the state '{}' with pattern '{}': {}", state,
stateDescription.getPattern(), e.getMessage());
LOGGER.warn("Failed transforming the state '{}' on item '{}' with pattern '{}': {}", state,
item.getName(), stateDescription.getPattern(), e.getMessage());
return state;
}
} else {
Expand Down

0 comments on commit c112be0

Please sign in to comment.