bug4371 Adjustments in AbstractDataImportResponse hierarchy

This commit is contained in:
Benjamin Barth committed 2017-12-19 17:55:57 +01:00
1 parent ef08782408
commit df2edb9b6a
3 files changed
+30 -8

No files matched your search

@@ -17,6 +17,31 @@ class AbstractDataImportResponse extends JavaScriptObject {
private static final Logger logger = Logger.getLogger(AbstractDataImportResponse.class.getName());
/**
* Extracts {@link ErrorMessage}s contained in this {@link JavaScriptObject JavaScript object}'s <i>errors</i>
* field.
*
* @return the {@link List} of contained {@link ErrorMessage}s or an empty list if the <i>errors</i> field is
* <code>undefined</code> or empty
*
* @see #getJsObjectList(String)
*/
public final List<ErrorMessage> getErrors() {
return getJsObjectList("errors");
}
/**
* Checks if this {@link JavaScriptObject JavaScript object} contained errors.
*
* @return <code>true</code> if the {@link #getErrors() error list} is neither <code>null</code> nor empty,
* <code>false</code> otherwise
* @see #getErrors()
*/
public final boolean hasErrors() {
final List<ErrorMessage> errors = getErrors();
return errors != null && !errors.isEmpty();
}
/**
* {@link JSONParser#parseStrict(String) Strictly parses} the provided {@link String} representation into JSON and
* {@link JavaScriptObject#cast() casts} it to the desired type.
@@ -52,4 +52,9 @@ public class ExpeditionDataImportResponse extends AbstractDataImportResponse {
return this.sensorFixImporterType;
}-*/;
public final boolean hasEventId() {
final String stringValue = getString("eventId");
return stringValue != null && !stringValue.isEmpty();
}
}
@@ -15,17 +15,9 @@ public class SensorDataImportResponse extends AbstractDataImportResponse {
return getStringList("uploads");
}
public final List<ErrorMessage> getErrors() {
return getJsObjectList("errors");
}
public final boolean didSucceedImportingAnyFile() {
return getUploads() != null && !getUploads().isEmpty();
}
public final boolean hasErrors() {
final List<ErrorMessage> errors = getErrors();
return errors != null && !errors.isEmpty();
}
}