Object thisValue = thisField.getValue(); Object thatValue = that.get(thisField.getName()); if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) { return false; Object thisValue = thisField.getValue(); Object thatValue = that.get(thisField.getName()); if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) { return false;
public void getProperties( Document document, Map<Name, Property> result ) { // Get the properties container ... Document properties = document.getDocument(PROPERTIES); if (properties != null) { // For all namespaces ... for (Field nsField : properties.fields()) { String namespaceUri = nsField.getName(); Document nsDoc = nsField.getValueAsDocument(); // Get all the properties in the namespace ... for (Field propField : nsDoc.fields()) { String localName = propField.getName(); Name propertyName = names.create(namespaceUri, localName); if (!result.containsKey(propertyName)) { Object fieldValue = propField.getValue(); Property property = propertyFor(propertyName, fieldValue); result.put(propertyName, property); } } } } }
switch (pdef.getPropertyType()) { case STRING: return field.getValueAsString(); case BOOLEAN: return field.getValueAsBoolean(); case DECIMAL: return BigDecimal.valueOf(field.getValueAsInt()); case INTEGER: return field.getValueAsInt(); case DATETIME: case URI: try { return new URI(field.getValueAsString()); } catch (Exception e) { return field.getValueAsUuid(); case HTML: return field.getValueAsString();
String namespaceUri = field.getName(); Document props = field.getValueAsDocument(); String jcrPropertyName = prefix + property.getName(); String cmisPropertyName = properties.findCmisName(jcrPropertyName);
final Iterator<String> indexIter = IndexSequence.infiniteSequence(); for (Document.Field field : doc.fields()) { String name = field.getName(); String index = indexIter.next(); if (!index.equals(name)) {
Object thisValue = thisField.getValue(); Object thatValue = that.get(thisField.getName()); if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) { return false; Object thisValue = thisField.getValue(); Object thatValue = that.get(thisField.getName()); if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) { return false;
final Iterator<String> indexIter = IndexSequence.infiniteSequence(); for (Document.Field field : doc.fields()) { String name = field.getName(); String index = indexIter.next(); if (!index.equals(name)) {
boolean isArray = components instanceof List; for (Field field : components.fields()) { Object value = field.getValue(); if (value instanceof Document) { Document component = (Document)value; String classname = component.getString(FieldName.CLASSNAME); String name = isArray ? component.getString(FieldName.NAME) : field.getName(); if (classname != null) { String resolvedClassname = classnamesByAlias.get(classname.toLowerCase());
boolean isArray = components instanceof List; for (Field field : components.fields()) { Object value = field.getValue(); if (value instanceof Document) { Document component = (Document)value; String classname = component.getString(FieldName.CLASSNAME); String name = isArray ? component.getString(FieldName.NAME) : field.getName(); if (classname != null) { String resolvedClassname = classnamesByAlias.get(classname.toLowerCase());
protected void addValidatorsForPatternProperties( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Document properties = parent.getDocument("patternProperties"); if (properties != null && properties.size() != 0) { for (Field field : properties.fields()) { String name = field.getName(); Object value = field.getValue(); Path path = Paths.path(parentPath, "patternProperties", name); if (!(value instanceof Document)) { problems.recordError(path, "Expected a nested object"); } Document propertySchema = (Document)value; try { Pattern namePattern = Pattern.compile(name); Validator propertyValidator = create(propertySchema, path); if (propertyValidator != null) { validators.add(new PatternPropertyValidator(namePattern, propertyValidator)); } } catch (PatternSyntaxException e) { problems.recordError(path, "Expected the field name to be a regular expression"); } } } }
protected void addValidatorsForPatternProperties( Document parent, Path parentPath, Problems problems, CompositeValidator validators ) { Document properties = parent.getDocument("patternProperties"); if (properties != null && properties.size() != 0) { for (Field field : properties.fields()) { String name = field.getName(); Object value = field.getValue(); Path path = Paths.path(parentPath, "patternProperties", name); if (!(value instanceof Document)) { problems.recordError(path, "Expected a nested object"); } Document propertySchema = (Document)value; try { Pattern namePattern = Pattern.compile(name); Validator propertyValidator = create(propertySchema, path); if (propertyValidator != null) { validators.add(new PatternPropertyValidator(namePattern, propertyValidator)); } } catch (PatternSyntaxException e) { problems.recordError(path, "Expected the field name to be a regular expression"); } } } }
@Override public void validate( Object fieldValue, String fieldName, Document parent, Path pathToParent, Problems problems, SchemaDocumentResolver resolver ) { if (fieldValue == null) { if (fieldName == null) { // Go through all of the fields in the document ... for (Field field : parent.fields()) { validate(field.getValue(), field.getName(), parent, pathToParent, problems, resolver); } } } else { if (!allowedPropertyNames.contains(fieldName)) { // Then the field is not handled by an explicit schema, so it's not allowed ... problems.recordError(pathToParent.with(fieldName), "The '" + fieldName + "' field on '" + pathToParent + "' is not defined in the schema and the schema does not allow additional properties."); } else { problems.recordSuccess(); } } }
@Override public void validate( Object fieldValue, String fieldName, Document parent, Path pathToParent, Problems problems, SchemaDocumentResolver resolver ) { if (fieldName != null && !allowedPropertyNames.contains(fieldName)) { // Then the field is not handled by an explicit schema, so we need to check it here validator.validate(fieldValue, fieldName, parent, pathToParent, problems, resolver); } else if (fieldName == null) { // we need to validate each defined additional property which has a schema for (Field field : parent.fields()) { if (field.getValue() instanceof Document) { validator.validate(null, null, (Document)field.getValue(), pathToParent.with(field.getName()), problems, resolver); } else { validator.validate(field.getValue(), field.getName(), parent, pathToParent, problems, resolver); } } } }
@Override public void validate( Object fieldValue, String fieldName, Document parent, Path pathToParent, Problems problems, SchemaDocumentResolver resolver ) { if (fieldValue == null) { if (fieldName == null) { // Go through all of the fields in the document ... for (Field field : parent.fields()) { validate(field.getValue(), field.getName(), parent, pathToParent, problems, resolver); } } } else { if (!allowedPropertyNames.contains(fieldName)) { // Then the field is not handled by an explicit schema, so it's not allowed ... problems.recordError(pathToParent.with(fieldName), "The '" + fieldName + "' field on '" + pathToParent + "' is not defined in the schema and the schema does not allow additional properties."); } else { problems.recordSuccess(); } } }