* @param is entity input stream
* @param app the app object
* @return a status code 201 or 400
*/
public static Response getCreateResponse(App app, String type, InputStream is) {
ParaObject content;
try {
if (is != null && is.available() > 0) {
if (is.available() > (1024 * 1024)) {
return getStatusResponse(Response.Status.BAD_REQUEST,
"Request is too large - the maximum is 1MB.");
}
Map<String, Object> newContent = Utils.getJsonReader(Map.class).readValue(is);
// type is not fount in datatypes (try to get it from req. body)
if (!StringUtils.isBlank(type)) {
newContent.put(Config._TYPE, type);
}
content = Utils.setAnnotatedFields(newContent);
content.setAppid(app.getAppIdentifier());
content.setShardKey(app.isShared() ? app.getAppIdentifier() : null);
registerNewTypes(app, content);
} else {
return getStatusResponse(Response.Status.BAD_REQUEST, "Missing request body.");
}
} catch (JsonParseException e) {