public Modification storeAsReference()

in src/main/java/org/apache/sling/servlets/post/impl/helper/JCRSupportImpl.java [258:284]


    public Modification storeAsReference(
            final Object n, final String name, final String[] values, final int type, final boolean multiValued)
            throws PersistenceException {
        try {
            final Node node = (Node) n;
            if (multiValued) {
                Value[] array = ReferenceParser.parse(node.getSession(), values, isWeakReference(type));
                if (array != null) {
                    return Modification.onModified(node.setProperty(name, array).getPath());
                }
            } else {
                if (values.length >= 1) {
                    Value v = ReferenceParser.parse(node.getSession(), values[0], isWeakReference(type));
                    if (v != null) {
                        return Modification.onModified(node.setProperty(name, v).getPath());
                    }
                }
            }
            return null;
        } catch (final NoSuchNodeTypeException | ConstraintViolationException e) {
            throw new PreconditionViolatedPersistenceException(e.getMessage(), e);
        } catch (final VersionException | LockException e) {
            throw new TemporaryPersistenceException(e.getMessage(), e);
        } catch (final RepositoryException re) {
            throw new PersistenceException(re.getMessage(), re);
        }
    }