/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public Set<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); Set<Path> ret = new HashSet<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public Set<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); Set<Path> ret = new HashSet<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during insertion. If the returned list is empty, the user can insert the * doc. */ public List<Path> getInaccessibleFields_Insert(JsonDoc doc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.insert); List<Path> ret = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> cursor = doc.getAllNodes(x); if (cursor.hasNext()) { ret.add(x); } } return ret; }
/** * Returns a projection that excludes the fields the caller does not have * access to based on the operation */ public Projection getExcludedFields(Operation op) { Set<Path> inaccessibleFields = getInaccessibleFields(op); Projection ret; if (inaccessibleFields.isEmpty()) { ret = null; } else if (inaccessibleFields.size() == 1) { ret = new FieldProjection(inaccessibleFields.iterator().next(), false, true); } else { List<Projection> list = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { list.add(new FieldProjection(x, false, true)); } ret = new ProjectionList(list); } return ret; }
/** * Returns a projection that excludes the fields the caller does not have * access to based on the operation */ public Projection getExcludedFields(Operation op) { Set<Path> inaccessibleFields = getInaccessibleFields(op); Projection ret; if (inaccessibleFields.isEmpty()) { ret = null; } else if (inaccessibleFields.size() == 1) { ret = new FieldProjection(inaccessibleFields.iterator().next(), false, true); } else { List<Projection> list = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { list.add(new FieldProjection(x, false, true)); } ret = new ProjectionList(list); } return ret; }
/** * Returns a projection that excludes the fields the caller does not have * access to based on the operation */ public Projection getExcludedFields(Operation op) { Set<Path> inaccessibleFields = getInaccessibleFields(op); Projection ret; if (inaccessibleFields.isEmpty()) { ret = null; } else { if (inaccessibleFields.size() == 1) { ret = new FieldProjection(inaccessibleFields.iterator().next(), false, true); } else { List<Projection> list = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { list.add(new FieldProjection(x, false, true)); } ret = new ProjectionList(list); } } return ret; }
/** * Returns a list of fields in the doc inaccessible to the current user * during update. * * @param newDoc The new version of the document * @param oldDoc The old version of the document */ public List<Path> getInaccessibleFields_Update(JsonDoc newDoc, JsonDoc oldDoc) { Set<Path> inaccessibleFields = getInaccessibleFields(Operation.update); List<Path> ret = new ArrayList<>(inaccessibleFields.size()); for (Path x : inaccessibleFields) { KeyValueCursor<Path, JsonNode> oldCursor = oldDoc.getAllNodes(x); KeyValueCursor<Path, JsonNode> newCursor = newDoc.getAllNodes(x); if (different(oldCursor, newCursor)) { ret.add(x); } } return ret; }
comparator = md.getEntitySchema().getDocComparator(); Set<Path> inaccessibleFields = getInaccessibleFields(Operation.update); Set<Path> ret = new HashSet<>(); if (!inaccessibleFields.isEmpty()) {
comparator = md.getEntitySchema().getDocComparator(); Set<Path> inaccessibleFields = getInaccessibleFields(Operation.update); Set<Path> ret = new HashSet<>(); if (!inaccessibleFields.isEmpty()) {