protected static boolean isUnchangedAutocreatedProperty()

in src/main/java/org/apache/sling/jcr/repoinit/impl/NodePropertiesVisitor.java [124:157]


    protected static boolean isUnchangedAutocreatedProperty(Node n, final String pRelPath)
            throws RepositoryException {
        boolean sameAsDefault = false;

        // deal with the pRelPath nesting
        Path path = Paths.get(pRelPath);
        Path parentPath = path.getParent();
        String name = path.getFileName().toString();
        if (parentPath != null) {
            String relPath = parentPath.toString();
            if (n.hasNode(relPath)) {
                n = n.getNode(relPath);
            } else {
                n = null;
            }
        }

        //  if the property has been set by being autocreated and the value is still
        //  the same as the default values then also allow changing the value
        if (n != null && n.hasProperty(name)) {
            @Nullable
            PropertyDefinition pd = resolvePropertyDefinition(name, n);
            if (pd != null && pd.isAutoCreated()) {
                // if the current value is the same as the autocreated default values
                //  then allow the value to be changed.
                if (pd.isMultiple()) {
                    sameAsDefault = Arrays.equals(pd.getDefaultValues(), n.getProperty(name).getValues());
                } else {
                    sameAsDefault = Arrays.equals(pd.getDefaultValues(), new Value[] {n.getProperty(name).getValue()});
                }
            }
        }
        return sameAsDefault;
    }