use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxSignRequestPrefillTag method parseJSONMember.
/**
* {@inheritDoc}
*/
@Override
void parseJSONMember(JsonObject.Member member) {
JsonValue value = member.getValue();
String memberName = member.getName();
try {
if ("document_tag_id".equals(memberName)) {
this.documentTagId = value.asString();
} else if ("text_value".equals(memberName)) {
this.textValue = value.asString();
} else if ("checkbox_value".equals(memberName)) {
this.checkboxValue = value.asBoolean();
} else if ("date_value".equals(memberName)) {
this.dateValue = BoxDateFormat.parseDateOnly(value.asString());
}
} catch (Exception e) {
throw new BoxDeserializationException(memberName, value.toString(), e);
}
}
use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxFileUploadSessionPart method parseJSONMember.
@Override
protected void parseJSONMember(JsonObject.Member member) {
String memberName = member.getName();
JsonValue value = member.getValue();
if (memberName.equals("part_id")) {
this.partId = value.asString();
} else if (memberName.equals("offset")) {
this.offset = Double.valueOf(value.toString()).longValue();
} else if (memberName.equals("size")) {
this.size = Double.valueOf(value.toString()).longValue();
} else if (memberName.equals("sha1")) {
this.sha1 = value.asString();
}
}
use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxFileVersion method parseJSON.
/**
* Method used to update fields with values received from API.
*
* @param jsonObject JSON-encoded info about File Version object.
*/
private void parseJSON(JsonObject jsonObject) {
for (JsonObject.Member member : jsonObject) {
JsonValue value = member.getValue();
if (value.isNull()) {
continue;
}
try {
String memberName = member.getName();
if (memberName.equals("id")) {
this.versionID = value.asString();
} else if (memberName.equals("sha1")) {
this.sha1 = value.asString();
} else if (memberName.equals("name")) {
this.name = value.asString();
} else if (memberName.equals("size")) {
this.size = Double.valueOf(value.toString()).longValue();
} else if (memberName.equals("uploader_display_name")) {
this.uploaderDisplayName = value.asString();
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("modified_at")) {
this.modifiedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("trashed_at")) {
this.trashedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("trashed_by")) {
JsonObject userJSON = value.asObject();
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.trashedBy = user.new Info(userJSON);
} else if (memberName.equals("modified_by")) {
JsonObject userJSON = value.asObject();
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.modifiedBy = user.new Info(userJSON);
} else if (memberName.equals("restored_at")) {
this.restoredAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("restored_by")) {
JsonObject userJSON = value.asObject();
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(getAPI(), userID);
this.restoredBy = user.new Info(userJSON);
} else if (memberName.equals("purged_at")) {
this.purgedAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("version_number")) {
this.versionNumber = Long.parseLong(value.asString());
}
} catch (ParseException e) {
assert false : "A ParseException indicates a bug in the SDK.";
}
}
}
use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxLock method parseJSONMember.
@Override
protected void parseJSONMember(JsonObject.Member member) {
super.parseJSONMember(member);
String memberName = member.getName();
JsonValue value = member.getValue();
try {
if (memberName.equals("type")) {
this.type = value.asString();
} else if (memberName.equals("expires_at")) {
this.expiresAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("is_download_prevented")) {
this.isDownloadPrevented = value.asBoolean();
} else if (memberName.equals("created_by")) {
JsonObject userJSON = value.asObject();
if (this.createdBy == null) {
String userID = userJSON.get("id").asString();
BoxUser user = new BoxUser(this.api, userID);
this.createdBy = user.new Info(userJSON);
} else {
this.createdBy.update(userJSON);
}
} else if (memberName.equals("created_at")) {
this.createdAt = BoxDateFormat.parse(value.asString());
} else if (memberName.equals("id")) {
this.id = value.toString();
}
} catch (Exception e) {
throw new BoxDeserializationException(memberName, value.toString(), e);
}
}
use of com.eclipsesource.json.JsonValue in project box-java-sdk by box.
the class BoxMetadataQueryItem method parseJSONMember.
@Override
protected void parseJSONMember(JsonObject.Member member) {
super.parseJSONMember(member);
String memberName = member.getName();
JsonValue value = member.getValue();
if (memberName.equals("item")) {
String id = value.asObject().get("id").asString();
String type = value.asObject().get("type").asString();
this.item = new BoxFile(this.api, id).new Info(value.asObject());
if (type.equals("folder")) {
BoxFolder folder = new BoxFolder(this.api, id);
this.item = folder.new Info(value.asObject());
} else if (type.equals("file")) {
BoxFile file = new BoxFile(this.api, id);
this.item = file.new Info(value.asObject());
} else if (type.equals("web_link")) {
BoxWebLink link = new BoxWebLink(this.api, id);
this.item = link.new Info(value.asObject());
} else {
assert false : "Unsupported item type: " + type;
throw new BoxAPIException("Unsupported item type: " + type);
}
} else if (memberName.equals("metadata")) {
this.metadata = new HashMap<String, ArrayList<Metadata>>();
JsonObject metadataObject = value.asObject();
for (JsonObject.Member enterprise : metadataObject) {
String enterpriseName = enterprise.getName();
JsonObject templates = enterprise.getValue().asObject();
ArrayList<Metadata> enterpriseMetadataArray = new ArrayList<Metadata>();
for (JsonObject.Member template : templates) {
String templateName = template.getName();
JsonObject templateValue = template.getValue().asObject();
Metadata metadataOfTemplate = new Metadata(templateValue);
metadataOfTemplate.add("/$scope", enterpriseName);
metadataOfTemplate.add("/$template", templateName);
enterpriseMetadataArray.add(metadataOfTemplate);
}
this.metadata.put(enterpriseName, enterpriseMetadataArray);
}
}
}
Aggregations