private void checkAllValuesHaveTheSameType( Value[] values, Name name ) throws ValueFormatException { int valueType = -1; for (Value value : values) { if (value == null) { continue; } if (valueType == -1) { valueType = value.getType(); } else if (value.getType() != valueType) { // Make sure the type of each value is the same, as per Javadoc in section 10.4.2.6 of the JCR 2.0 spec String msg = JcrI18n.allPropertyValuesMustHaveSameType.text(readable(name), values, org.modeshape.jcr.api.PropertyType.nameFromValue(valueType), location(), workspaceName()); throw new javax.jcr.ValueFormatException(msg); } } }
private void checkAllValuesHaveTheSameType( Value[] values, Name name ) throws ValueFormatException { int valueType = -1; for (Value value : values) { if (value == null) { continue; } if (valueType == -1) { valueType = value.getType(); } else if (value.getType() != valueType) { // Make sure the type of each value is the same, as per Javadoc in section 10.4.2.6 of the JCR 2.0 spec String msg = JcrI18n.allPropertyValuesMustHaveSameType.text(readable(name), values, org.modeshape.jcr.api.PropertyType.nameFromValue(valueType), location(), workspaceName()); throw new javax.jcr.ValueFormatException(msg); } } }
String pName = readable(property.getName()); String loc = location(); if (defn != null) { String ptype = readable(node.getPrimaryType(sessionCache())); String mixins = readable(node.getMixinTypes(sessionCache())); String pstr = property.getString(session.namespaces()); throw new ConstraintViolationException(JcrI18n.propertyNoLongerHasValidDefinition.text(pstr, loc, ptype, mixins));
String pName = readable(property.getName()); String loc = location(); if (defn != null) { String ptype = readable(node.getPrimaryType(sessionCache())); String mixins = readable(node.getMixinTypes(sessionCache())); String pstr = property.getString(session.namespaces()); throw new ConstraintViolationException(JcrI18n.propertyNoLongerHasValidDefinition.text(pstr, loc, ptype, mixins));
void addSharedNode( AbstractJcrNode shareableNode, Name newNodeName ) throws RepositoryException { assert session == shareableNode.session; session.checkPermission(this, ModeShapePermissions.ADD_NODE); if (isLockedByAnotherSession()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(location())); } // Determine the node type based upon this node's type information ... SessionCache cache = sessionCache(); MutableCachedNode node = mutable(); // validate there is an appropriate child node definition JcrNodeDefinition childDefn = validateChildNodeDefinition(newNodeName, shareableNode.getPrimaryTypeName(), true); // See if this node is checked in. If so, then we can only create children if the child // node definition has an OPV of 'ignore'. See Section 15.2.2 of the JSR-283 spec for details ... if (!isCheckedOut() && childDefn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // The OPV is not 'ignore', so we can't create the new node ... Path parentPath = path(); String parentPathStr = readable(parentPath); int numExistingSns = node.getChildReferences(cache).getChildCount(newNodeName); int sns = numExistingSns + 1; String segment = readable(session.pathFactory().createSegment(newNodeName, sns)); String opv = OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion()); I18n msg = JcrI18n.cannotCreateChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore; throw new VersionException(msg.text(segment, readable(parentPathStr), childDefn.getName(), opv)); } // We can create the shared node ... NodeKey childKey = shareableNode.key(); node.linkChild(cache, childKey, newNodeName); }
void addSharedNode( AbstractJcrNode shareableNode, Name newNodeName ) throws RepositoryException { assert session == shareableNode.session; session.checkPermission(this, ModeShapePermissions.ADD_NODE); if (isLockedByAnotherSession()) { throw new LockException(JcrI18n.lockTokenNotHeld.text(location())); } // Determine the node type based upon this node's type information ... SessionCache cache = sessionCache(); MutableCachedNode node = mutable(); // validate there is an appropriate child node definition JcrNodeDefinition childDefn = validateChildNodeDefinition(newNodeName, shareableNode.getPrimaryTypeName(), true); // See if this node is checked in. If so, then we can only create children if the child // node definition has an OPV of 'ignore'. See Section 15.2.2 of the JSR-283 spec for details ... if (!isCheckedOut() && childDefn.getOnParentVersion() != OnParentVersionAction.IGNORE) { // The OPV is not 'ignore', so we can't create the new node ... Path parentPath = path(); String parentPathStr = readable(parentPath); int numExistingSns = node.getChildReferences(cache).getChildCount(newNodeName); int sns = numExistingSns + 1; String segment = readable(session.pathFactory().createSegment(newNodeName, sns)); String opv = OnParentVersionAction.nameFromValue(childDefn.getOnParentVersion()); I18n msg = JcrI18n.cannotCreateChildOnCheckedInNodeSinceOpvOfChildDefinitionIsNotIgnore; throw new VersionException(msg.text(segment, readable(parentPathStr), childDefn.getName(), opv)); } // We can create the shared node ... NodeKey childKey = shareableNode.key(); node.linkChild(cache, childKey, newNodeName); }
AbstractJcrNode getNode( Name childName ) throws PathNotFoundException, RepositoryException { // It's just a name, so look for a child ... ChildReference ref = node().getChildReferences(sessionCache()).getChild(childName); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(childName), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), null, key()); }
AbstractJcrNode getNode( Name childName ) throws PathNotFoundException, RepositoryException { // It's just a name, so look for a child ... ChildReference ref = node().getChildReferences(sessionCache()).getChild(childName); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(childName), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), null, key()); }
/** * Get the JCR node for the named child. * * @param name the child name; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @throws PathNotFoundException if there is no child with the supplied name * @throws ItemNotFoundException if this node or the referenced child no longer exist or cannot be found * @throws InvalidItemStateException if this node has been removed in this session's transient state */ protected final AbstractJcrNode childNode( Name name, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(name); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(name), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
/** * Get the JCR node for the named child. * * @param segment the child name and SNS index; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @throws PathNotFoundException if there is no child with the supplied name * @throws ItemNotFoundException if this node or the referenced child cannot be found * @throws InvalidItemStateException if this node has been removed in this session's transient state */ protected final AbstractJcrNode childNode( Segment segment, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(segment); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(segment), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
/** * Get the JCR node for the named child. * * @param name the child name; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @throws PathNotFoundException if there is no child with the supplied name * @throws ItemNotFoundException if this node or the referenced child no longer exist or cannot be found * @throws InvalidItemStateException if this node has been removed in this session's transient state */ protected final AbstractJcrNode childNode( Name name, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(name); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(name), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
/** * Get the JCR node for the named child. * * @param segment the child name and SNS index; may not be null * @param expectedType the expected implementation type for the node, or null if it is not known * @return the JCR node; never null * @throws PathNotFoundException if there is no child with the supplied name * @throws ItemNotFoundException if this node or the referenced child cannot be found * @throws InvalidItemStateException if this node has been removed in this session's transient state */ protected final AbstractJcrNode childNode( Segment segment, Type expectedType ) throws PathNotFoundException, ItemNotFoundException, InvalidItemStateException { ChildReference ref = node().getChildReferences(sessionCache()).getChild(segment); if (ref == null) { String msg = JcrI18n.childNotFoundUnderNode.text(readable(segment), location(), session.workspaceName()); throw new PathNotFoundException(msg); } return session().node(ref.getKey(), expectedType, key()); }
} catch (ConstraintViolationException e) { String propName = readable(prop.getName()); I18n msg = JcrI18n.unableToChangePrimaryTypeDueToPropertyDefinition; throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, propName), e); siblingCounter); if (childDefn == null) { String ptype = readable(primaryType); String mtypes = readable(parent.getMixinTypes(cache)); I18n msg = JcrI18n.unableToChangePrimaryTypeDueToParentsChildDefinition; throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, ptype, mtypes));
} catch (ConstraintViolationException e) { String propName = readable(prop.getName()); I18n msg = JcrI18n.unableToChangePrimaryTypeDueToPropertyDefinition; throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, propName), e); siblingCounter); if (childDefn == null) { String ptype = readable(primaryType); String mtypes = readable(parent.getMixinTypes(cache)); I18n msg = JcrI18n.unableToChangePrimaryTypeDueToParentsChildDefinition; throw new ConstraintViolationException(msg.text(location(), oldPrimaryType, newPrimaryTypeName, ptype, mtypes));
String msg = JcrI18n.childNotFoundUnderNode.text(readable(segment), location(), session.workspaceName()); throw new PathNotFoundException(msg);
String msg = JcrI18n.childNotFoundUnderNode.text(readable(segment), location(), session.workspaceName()); throw new PathNotFoundException(msg);