final ValueFactory valueFactory = node.getSession().getValueFactory();
for (final String uniqueKeyRef : uniqueKeys.split("\\s")) {
final String uniqueKeyUuid = resolver.resolveInternalReference(uniqueKeyRef);
final Node uniqueKeyNode = resolver.getNode(uniqueKeyUuid);
UnresolvedReference unresolved = null;
// - relational:uniqueKeys (weakreference) multiple
if (uniqueKeyNode == null) {
unresolved = resolver.addUnresolvedReference(uniqueKeyUuid);
unresolved.addReferencerReference(element.getUuid(), JcrId.UNIQUE_KEYS);
} else {
if (!uniqueKeyNode.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
uniqueKeyNode.addMixin(JcrConstants.MIX_REFERENCEABLE);
}
final Value weakReference = valueFactory.createValue(uniqueKeyNode, true);
addPropertyValue(node, JcrId.UNIQUE_KEYS, weakReference);
}
// - relational:uniqueKeyXmiUuids (string) multiple
addPropertyValue(node, JcrId.UNIQUE_KEY_XMI_UUIDS, uniqueKeyUuid);
// - relational:uniqueKeyHrefs (string) multiple
addPropertyValue(node, JcrId.UNIQUE_KEY_HREFS, uniqueKeyRef);
// - relational:uniqueKeyNames (string) multiple
if (uniqueKeyNode != null) {
addPropertyValue(node, JcrId.UNIQUE_KEY_NAMES, uniqueKeyNode.getName());
} else if (unresolved != null) {
unresolved.addResolvedName(element.getUuid(), JcrId.UNIQUE_KEY_NAMES);
} else {
assert false;
}
}
}