diff --git a/engine/src/main/java/org/archive/crawler/restlet/JobRelatedResource.java b/engine/src/main/java/org/archive/crawler/restlet/JobRelatedResource.java index 20c1c409..856d014d 100644 --- a/engine/src/main/java/org/archive/crawler/restlet/JobRelatedResource.java +++ b/engine/src/main/java/org/archive/crawler/restlet/JobRelatedResource.java @@ -91,6 +91,7 @@ public abstract class JobRelatedResource extends BaseResource { if (obj == null || (obj instanceof Optional && !((Optional) obj).isPresent()) || obj instanceof Class + || obj instanceof Logger || alreadyWritten.contains(obj) || obj.getClass().getName().startsWith("org.springframework.")) { return; @@ -235,7 +236,8 @@ public abstract class JobRelatedResource extends BaseResource { info.put("propValue", null); return info; } - if (object instanceof String || BeanUtils.isSimpleValueType(object.getClass()) || object instanceof File) { + if (object instanceof String || BeanUtils.isSimpleValueType(object.getClass()) || object instanceof File || + object instanceof Logger) { info.put("class", object.getClass().getName()); info.put("propValue", object); return info; @@ -256,24 +258,6 @@ public abstract class JobRelatedResource extends BaseResource { info.put("class", object.getClass().getName()); Collection properties = new LinkedList(); - BeanWrapperImpl bwrap = new BeanWrapperImpl(object); - for (PropertyDescriptor pd : getPropertyDescriptors(bwrap)) { - - if (pd.getReadMethod() != null && !pd.isHidden()) { - String propName = pd.getName(); - if (beanPath != null) { - beanPathPrefix = beanPath + "."; - } - Object propValue = makePresentableMapFor(propName, - bwrap.getPropertyValue(propName), - alreadyWritten, beanPathPrefix); - properties.add(propValue); - } - } - if (properties.size() > 0) { - info.put("properties", properties); - } - Collection propValues = new LinkedList(); if(object.getClass().isArray()) { // TODO: may want a special handling for an array of @@ -287,8 +271,7 @@ public abstract class JobRelatedResource extends BaseResource { propValues.add(makePresentableMapFor(i + "", Array.get(object, i), alreadyWritten, beanPathPrefix)); } - } - if (object instanceof List) { + } else if (object instanceof List) { List list = (List) object; for (int i = 0; i < list.size(); i++) { if (beanPath != null) { @@ -302,13 +285,7 @@ public abstract class JobRelatedResource extends BaseResource { LOGGER.warning(list + ".get(" + i + ") -" + e); } } - } else if (object instanceof Iterable) { - for (Object next : (Iterable) object) { - propValues.add(makePresentableMapFor("#", next, alreadyWritten, - beanPathPrefix)); - } - } - if (object instanceof Map) { + } else if (object instanceof Map) { for (Object next : ((Map) object).entrySet()) { // TODO: protect against giant maps? Map.Entry entry = (Map.Entry) next; @@ -318,8 +295,32 @@ public abstract class JobRelatedResource extends BaseResource { propValues.add(makePresentableMapFor(entry.getKey().toString(), entry.getValue(), alreadyWritten, beanPathPrefix)); } + } else if (object instanceof Iterable) { + for (Object next : (Iterable) object) { + propValues.add(makePresentableMapFor("#", next, alreadyWritten, + beanPathPrefix)); + } + } else { + BeanWrapperImpl bwrap = new BeanWrapperImpl(object); + for (PropertyDescriptor pd : getPropertyDescriptors(bwrap)) { + if (pd.getReadMethod() != null && !pd.isHidden()) { + String propName = pd.getName(); + if (beanPath != null) { + beanPathPrefix = beanPath + "."; + } + Object propValue = makePresentableMapFor(propName, + bwrap.getPropertyValue(propName), + alreadyWritten, beanPathPrefix); + properties.add(propValue); + } + } } - if (propValues.size() > 0) { + + if (!properties.isEmpty()) { + info.put("properties", properties); + } + + if (!propValues.isEmpty()) { info.put("propValue", propValues); }