use of org.bson.BSONObject in project v7files by thiloplanz.
the class MapUtils method get.
private static Object get(Map<?, ?> b, String fieldName) {
if (!fieldName.contains("."))
return notNull(b.get(fieldName));
String[] path = StringUtils.split(fieldName, ".", 2);
Object nested = b.get(path[0]);
if (nested == null)
return null;
if (nested instanceof BSONObject)
return BSONUtils.get((BSONObject) nested, path[1]);
if (nested instanceof Map<?, ?>)
return get((Map<?, ?>) nested, path[1]);
throw new IllegalArgumentException("cannot get field `" + fieldName + "` of " + b);
}
use of org.bson.BSONObject in project v7files by thiloplanz.
the class BSONUtils method get.
public static Object get(BSONObject b, String fieldName) {
if (!fieldName.contains("."))
return notNull(b.get(fieldName));
String[] path = StringUtils.split(fieldName, ".", 2);
Object nested = b.get(path[0]);
if (nested == null)
return null;
if (nested instanceof BSONObject)
return get((BSONObject) nested, path[1]);
throw new IllegalArgumentException("cannot get field `" + fieldName + "` of " + b);
}
use of org.bson.BSONObject in project v7files by thiloplanz.
the class V7File method getAcl.
public Object[] getAcl(String permission) {
BSONObject acls = (BSONObject) metaData.get("acl");
if (acls == null)
return null;
List<?> acl = (List<?>) acls.get(permission);
if (acl == null)
return ArrayUtils.EMPTY_OBJECT_ARRAY;
return acl.toArray();
}
use of org.bson.BSONObject in project v7files by thiloplanz.
the class V7File method getEffectiveAcl.
/**
* @param permission
* "read", "write", or "open"
* @return the ACL for this permission, if not set, inherited from parents
* null if not set (not even at parents), empty if set but empty
*/
public Object[] getEffectiveAcl(String permission) {
BSONObject acls = (BSONObject) metaData.get("acl");
if (acls == null)
if (parent != null)
return parent.getEffectiveAcl(permission);
else
return null;
List<?> acl = (List<?>) acls.get(permission);
if (acl == null)
return ArrayUtils.EMPTY_OBJECT_ARRAY;
return acl.toArray();
}
use of org.bson.BSONObject in project v7files by thiloplanz.
the class V7GridFS method updateContents.
void updateContents(DBObject metaData, ContentPointer newContents) throws IOException {
ContentPointer oldContents = getContentPointer(metaData);
if (newContents.contentEquals(oldContents))
return;
String filename = (String) metaData.get("filename");
String contentType = (String) metaData.get("contentType");
Object fileId = metaData.get("_id");
BSONObject newContent = storage.updateBackRefs(newContents, fileId, filename, contentType);
metaData.removeField("sha");
metaData.removeField("length");
metaData.removeField("in");
metaData.putAll(newContent);
updateMetaData(metaData);
}
Aggregations