Package org.modeshape.jcr.value

Examples of org.modeshape.jcr.value.Property$ValueTypeTransformer


        Map<String, Set<String>> result = new HashMap<>();
        ChildReferences permissionsReference = aclNode.getChildReferences(cache);
        for (ChildReference permissionReference : permissionsReference) {
            CachedNode permission = cache.getNode(permissionReference);
            String name = permission.getProperty(ModeShapeLexicon.PERMISSION_PRINCIPAL_NAME, cache).getFirstValue().toString();
            Property privileges = permission.getProperty(ModeShapeLexicon.PERMISSION_PRIVILEGES_NAME, cache);
            Set<String> privilegeNames = new HashSet<>();
            for (Object privilege : privileges.getValuesAsArray()) {
                privilegeNames.add(privilege.toString());
            }
            result.put(name, privilegeNames);
        }
        return result;
View Full Code Here


            if (permissionRef == null) {
                //this is a new principal
                permissionChanges().principalAdded(principal);
                org.modeshape.jcr.value.Property primaryType = propertyFactory.create(
                        JcrLexicon.PRIMARY_TYPE, ModeShapeLexicon.PERMISSION);
                Property principalProp = propertyFactory.create(ModeShapeLexicon.PERMISSION_PRINCIPAL_NAME,
                                                                    principal);
                Property privileges = propertyFactory.create(ModeShapeLexicon.PERMISSION_PRIVILEGES_NAME,
                                                             privilegesByPrincipalName.get(principal));
                aclNode.createChild(cache, null, principalName, primaryType, principalProp, privileges);
            } else {
                //there already is a child node for this principal, so we just need to update its privileges
                MutableCachedNode permissionNode = cache.mutable(permissionRef.getKey());
                Property privileges = propertyFactory.create(ModeShapeLexicon.PERMISSION_PRIVILEGES_NAME,
                                                             privilegesByPrincipalName.get(principal));
                permissionNode.setProperty(cache, privileges);
            }
        }
        return permissionChanges();
View Full Code Here

                    if (first) {
                        first = false;
                    } else {
                        sb.append(',');
                    }
                    Property property = entry.getValue();
                    sb.append(" +").append(property.getString(registry));
                }
            }
            if (removedProps) {
                boolean first = true;
                for (Name name : removedProperties.keySet()) {
View Full Code Here

                    List<Reference> resolvedReferences = new ArrayList<Reference>();
                    for (Iterator<?> valuesIterator = property.getValues(); valuesIterator.hasNext();) {
                        Reference reference = (Reference)valuesIterator.next();
                        resolvedReferences.add(resolveReference(sourceKey, targetKey, property.getName(), reference));
                    }
                    Property updatedProperty = property.isMultiple() ? propertyFactory.create(property.getName(),
                                                                                              resolvedReferences) : propertyFactory.create(property.getName(),
                                                                                                                                           resolvedReferences.get(0));
                    targetNode.setProperty(targetCache, updatedProperty);
                }
            }
View Full Code Here

        protected void copyProperties( MutableCachedNode targetNode,
                                       CachedNode sourceNode ) {
            NodeKey sourceNodeKey = sourceNode.getKey();
            for (Iterator<Property> propertyIterator = sourceNode.getProperties(sourceCache); propertyIterator.hasNext();) {
                Property property = propertyIterator.next();
                if (property.isReference() || property.isSimpleReference()) {
                    // reference properties are not copied directly because that would cause incorrect back-pointers
                    // they are processed at the end of the clone/copy operation.
                    Set<Property> referenceProperties = sourceKeyToReferenceProperties.get(sourceNodeKey);
                    if (referenceProperties == null) {
                        referenceProperties = new HashSet<Property>();
                        sourceKeyToReferenceProperties.put(sourceNodeKey, referenceProperties);
                    }
                    referenceProperties.add(property);
                } else if (property.getName().equals(JcrLexicon.UUID)) {
                    // UUIDs need to be handled differently
                    copyUUIDProperty(property, targetNode, sourceNode);
                } else {
                    boolean sourceExternal = !sourceNodeKey.getSourceKey().equals(sourceCache.getRootKey().getSourceKey());
                    boolean targetInternal = targetNode.getKey().getSourceKey().equals(targetCache.getRootKey().getSourceKey());
                    // we're trying to copy an external binary into an internal node
                    if (sourceExternal && targetInternal && property.getFirstValue() instanceof ExternalBinaryValue) {
                        Property newProperty = null;
                        if (property.isMultiple()) {
                            List<Object> values = new ArrayList<Object>(property.size());
                            for (Object value : property) {
                                values.add(convertToInternalBinaryValue(value));
                            }
View Full Code Here

                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);
                    }
                }
            }
        }
View Full Code Here

    public String getPrimaryTypeName( Document document ) {
        return strings.create(getProperty(document, JcrLexicon.PRIMARY_TYPE).getFirstValue());
    }

    public Set<Name> getMixinTypes( Document document ) {
        Property prop = getProperty(document, JcrLexicon.MIXIN_TYPES);
        if (prop == null || prop.size() == 0) return Collections.emptySet();

        if (prop.size() == 1) {
            Name name = names.create(prop.getFirstValue());
            return Collections.singleton(name);
        }
        Set<Name> result = new HashSet<Name>();
        for (Object value : prop) {
            Name name = names.create(value);
View Full Code Here

        }
        return result;
    }

    public Set<String> getMixinTypeNames( Document document ) {
        Property prop = getProperty(document, JcrLexicon.MIXIN_TYPES);
        if (prop == null || prop.size() == 0) return Collections.emptySet();

        if (prop.size() == 1) {
            String name = strings.create(prop.getFirstValue());
            return Collections.singleton(name);
        }
        Set<String> result = new HashSet<String>();
        for (Object value : prop) {
            String name = strings.create(value);
View Full Code Here

                Name resolvedPrimaryTypeName = null;

                AbstractJcrNode sourceChildNode = null;
                AbstractJcrNode targetChildNode = null;

                Property frozenPrimaryType = sourceChild.getProperty(JcrLexicon.FROZEN_PRIMARY_TYPE, cache);
                Name sourceFrozenPrimaryType = frozenPrimaryType != null ? name(frozenPrimaryType.getFirstValue()) : null;
                boolean isShared = ModeShapeLexicon.SHARE.equals(sourceFrozenPrimaryType);
                boolean shouldRestore = !versionedChildrenThatShouldNotBeRestored.contains(targetChild);
                boolean shouldRestoreMixinsAndUuid = false;

                Path targetPath = target.getPath(cache);
                boolean restoreTargetUnderSamePath = targetChild != null
                                                     && targetChild.getPath(cache).getParent().isSameAs(targetPath);

                if (targetChild != null) {
                    resolvedChild = resolveSourceNode(sourceChild, checkinTime, cache);
                    resolvedPrimaryTypeName = name(resolvedChild.getPrimaryType(cache));
                    sourceChildNode = session.node(resolvedChild, (Type)null);
                    targetChildNode = session.node(targetChild, (Type)null);

                    if (isShared && !restoreTargetUnderSamePath) {
                        // This is a shared node that already exists in the workspace ...
                        restoredSharedChild(target, sourceChild, targetChildNode);
                        continue;
                    }
                }

                if (!restoreTargetUnderSamePath) {
                    if (targetChild != null) {
                        if (!cache.isDestroyed(targetChild.getKey())) {
                            // the target child exists but is under a different path in the source than the target
                            // so we need to remove it from its parent in the target to avoid the case when later on, it might be
                            // destroyed
                            MutableCachedNode targetChildParent = cache.mutable(targetChild.getParentKey(cache));
                            targetChildParent.removeChild(cache, targetChild.getKey());
                        }
                        resolvedChild = resolveSourceNode(sourceChild, checkinTime, cache);
                    } else {
                        // Pull the resolved node
                        resolvedChild = inSourceOnly.get(sourceChild);
                    }
                    resolvedPrimaryTypeName = name(resolvedChild.getPrimaryType(cache));

                    sourceChildNode = session.node(resolvedChild, (Type)null);
                    shouldRestoreMixinsAndUuid = true;

                    Name primaryTypeName = null;
                    NodeKey desiredKey = null;
                    Name desiredName = null;
                    if (isShared && sourceChildNode != null) {
                        // This is a shared node that already exists in the workspace ...
                        AbstractJcrNode resolvedChildNode = session.node(resolvedChild, (Type)null);
                        restoredSharedChild(target, sourceChild, resolvedChildNode);
                        continue;
                    }

                    if (JcrNtLexicon.FROZEN_NODE.equals(resolvedPrimaryTypeName)) {
                        primaryTypeName = name(resolvedChild.getProperty(JcrLexicon.FROZEN_PRIMARY_TYPE, cache).getFirstValue());
                        Property idProp = resolvedChild.getProperty(JcrLexicon.FROZEN_UUID, cache);
                        String frozenUuid = string(idProp.getFirstValue());
                        desiredKey = target.getKey().withId(frozenUuid);
                        // the name should be that of the versioned child
                        desiredName = session.node(sourceChild, (Type)null).name();
                    } else {
                        primaryTypeName = resolvedChild.getPrimaryType(cache);
                        Property idProp = resolvedChild.getProperty(JcrLexicon.UUID, cache);
                        if (idProp == null || idProp.isEmpty()) {
                            desiredKey = target.getKey().withRandomId();
                        } else {
                            String uuid = string(idProp.getFirstValue());
                            desiredKey = target.getKey().withId(uuid);
                        }
                        assert sourceChildNode != null;
                        desiredName = sourceChildNode.name();
                    }
                    Property primaryType = propFactory.create(JcrLexicon.PRIMARY_TYPE, primaryTypeName);
                    targetChild = target.createChild(cache, desiredKey, desiredName, primaryType);
                    targetChildNode = session.node(targetChild, (Type)null);
                    assert shouldRestore;
                }
View Full Code Here

         */
        private void restoredSharedChild( MutableCachedNode target,
                                          CachedNode sourceChild,
                                          AbstractJcrNode existingShareableForChild ) throws RepositoryException {
            // The node is shared and exists at another location ...
            Property idProp = sourceChild.getProperty(JcrLexicon.FROZEN_UUID, cache);
            String frozenUuid = string(idProp.getFirstValue());
            NodeKey desiredKey = target.getKey().withId(frozenUuid);
            // the name should be that of the versioned child
            Name desiredName = session.node(sourceChild, (Type)null).name();

            // Now link the existing node as a child of the target node ...
View Full Code Here

TOP

Related Classes of org.modeshape.jcr.value.Property$ValueTypeTransformer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.