Codota Logo
TypeEditor.constraintViolation
Code IndexAdd Codota to your IDE (free)

How to use
constraintViolation
method
in
org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor

Best Java code snippets using org.apache.jackrabbit.oak.plugins.nodetype.TypeEditor.constraintViolation (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: apache/jackrabbit-oak

@Override
public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException {
  if (checkThisNode && effective.isMandatoryChildNode(name)) {
    constraintViolation(26, "Mandatory child node " + name + " can not be removed");
  }
  return null; // no further checking needed for the removed subtree
}
origin: org.apache.jackrabbit/oak-core

@Override
public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException {
  if (checkThisNode && effective.isMandatoryChildNode(name)) {
    constraintViolation(26, "Mandatory child node " + name + " can not be removed");
  }
  return null; // no further checking needed for the removed subtree
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException {
  if (checkThisNode && effective.isMandatoryChildNode(name)) {
    constraintViolation(26, "Mandatory child node " + name + " can not be removed");
  }
  return null; // no further checking needed for the removed subtree
}
origin: org.apache.jackrabbit/oak-core

@Override
public void propertyDeleted(PropertyState before)
    throws CommitFailedException {
  String name = before.getName();
  if (checkThisNode && effective.isMandatoryProperty(name)) {
    constraintViolation(
        22, "Mandatory property " + name + " can not be removed");
  }
}
origin: apache/jackrabbit-oak

@Override
public void propertyDeleted(PropertyState before)
    throws CommitFailedException {
  String name = before.getName();
  if (checkThisNode && effective.isMandatoryProperty(name)) {
    constraintViolation(
        22, "Mandatory property " + name + " can not be removed");
  }
}
origin: apache/jackrabbit-oak

private void checkRequiredType(PropertyState property, int requiredType) throws CommitFailedException {
  if (requiredType != property.getType().tag()) {
    constraintViolation(55, "Required property type violation in " + property);
  }
}
origin: org.apache.jackrabbit/oak-core

private void checkRequiredType(PropertyState property, int requiredType) throws CommitFailedException {
  if (requiredType != property.getType().tag()) {
    constraintViolation(55, "Required property type violation in " + property);
  }
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

@Override
public void propertyDeleted(PropertyState before)
    throws CommitFailedException {
  String name = before.getName();
  if (checkThisNode && effective.isMandatoryProperty(name)) {
    constraintViolation(
        22, "Mandatory property " + name + " can not be removed");
  }
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private void checkRequiredType(PropertyState property, int requiredType) throws CommitFailedException {
  if (requiredType != property.getType().tag()) {
    constraintViolation(55, "Required property type violation in " + property);
  }
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

  constraintViolation(1, "The primary type " + primary + " does not exist");
} else if (type.getBoolean(JCR_ISMIXIN)) {
  constraintViolation(2, "Mixin type " + primary + " used as the primary type");
} else {
  if (type.getBoolean(JCR_IS_ABSTRACT)) {
          + getPath());
    } else {
      constraintViolation(2, "Abstract type " + primary + " used as the primary type");
  type = types.getChildNode(mixin);
  if (!type.exists()) {
    constraintViolation(5, "The mixin type " + mixin + " does not exist");
  } else if (!type.getBoolean(JCR_ISMIXIN)) {
    constraintViolation(6, "Primary type " + mixin + " used as a mixin type");
  } else if (type.getBoolean(JCR_IS_ABSTRACT)) {
    constraintViolation(7, "Abstract type " + mixin + " used as a mixin type");
  } else {
    list.add(type);
origin: org.apache.jackrabbit/oak-core

private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException {
  EffectiveType effective = getEffective();
  Set<String> properties = effective.getMandatoryProperties();
  for (PropertyState ps : after.getProperties()) {
    properties.remove(ps.getName());
    checkPropertyTypeConstraints(ps);
  }
  // verify the presence of all mandatory items
  if (!properties.isEmpty()) {
    constraintViolation(21, "Mandatory property " + properties.iterator().next() + " not found in a new node");
  }
  List<String> names = Lists.newArrayList(after.getChildNodeNames());
  for (String child : effective.getMandatoryChildNodes()) {
    if (!names.remove(child)) {
      constraintViolation(25, "Mandatory child node " + child + " not found in a new node");
    }
  }
  if (!names.isEmpty()) {
    for (String name : names) {
      NodeState child = after.getChildNode(name);
      String primary = child.getName(JCR_PRIMARYTYPE);
      Iterable<String> mixins = child.getNames(JCR_MIXINTYPES);
      NodeBuilder childBuilder = builder.getChildNode(name);
      TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, false);
      if (!effective.isValidChildNode(name, editor.getEffective())) {
        constraintViolation(25, "Unexpected child node " + name + " found in a new node");
      }
    }
  }
}
origin: apache/jackrabbit-oak

private void checkNodeTypeConstraints(NodeState after) throws CommitFailedException {
  EffectiveType effective = getEffective();
  Set<String> properties = effective.getMandatoryProperties();
  for (PropertyState ps : after.getProperties()) {
    properties.remove(ps.getName());
    checkPropertyTypeConstraints(ps);
  }
  // verify the presence of all mandatory items
  if (!properties.isEmpty()) {
    constraintViolation(21, "Mandatory property " + properties.iterator().next() + " not found in a new node");
  }
  List<String> names = Lists.newArrayList(after.getChildNodeNames());
  for (String child : effective.getMandatoryChildNodes()) {
    if (!names.remove(child)) {
      constraintViolation(25, "Mandatory child node " + child + " not found in a new node");
    }
  }
  if (!names.isEmpty()) {
    for (String name : names) {
      NodeState child = after.getChildNode(name);
      String primary = child.getName(JCR_PRIMARYTYPE);
      Iterable<String> mixins = child.getNames(JCR_MIXINTYPES);
      NodeBuilder childBuilder = builder.getChildNode(name);
      TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, false);
      if (!effective.isValidChildNode(name, editor.getEffective())) {
        constraintViolation(25, "Unexpected child node " + name + " found in a new node");
      }
    }
  }
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private void checkValueConstraints(NodeState definition, PropertyState property, int requiredType) throws CommitFailedException {
  if (property.count() == 0) {
    return;
  }
  PropertyState constraints = definition.getProperty(JCR_VALUECONSTRAINTS);
  if (constraints == null || constraints.count() == 0) {
    return;
  }
  for (String constraint : constraints.getValue(STRINGS)) {
    Predicate<Value> predicate = valueConstraint(requiredType, constraint);
    for (Value v : ValueFactoryImpl.createValues(property, NamePathMapper.DEFAULT)) {
      if (predicate.apply(v)) {
        return;
      }
    }
  }
  constraintViolation(5, "Value constraint violation in " + property);
}
origin: apache/jackrabbit-oak

private void checkValueConstraints(NodeState definition, PropertyState property, int requiredType) throws CommitFailedException {
  if (property.count() == 0) {
    return;
  }
  PropertyState constraints = definition.getProperty(JCR_VALUECONSTRAINTS);
  if (constraints == null || constraints.count() == 0) {
    return;
  }
  for (String constraint : constraints.getValue(STRINGS)) {
    Predicate<Value> predicate = valueConstraint(requiredType, constraint);
    for (Value v : valueFactory.createValues(property)) {
      if (predicate.apply(v)) {
        return;
      }
    }
  }
  constraintViolation(5, "Value constraint violation in " + property);
}
origin: org.apache.jackrabbit/oak-core

private void checkValueConstraints(NodeState definition, PropertyState property, int requiredType) throws CommitFailedException {
  if (property.count() == 0) {
    return;
  }
  PropertyState constraints = definition.getProperty(JCR_VALUECONSTRAINTS);
  if (constraints == null || constraints.count() == 0) {
    return;
  }
  for (String constraint : constraints.getValue(STRINGS)) {
    Predicate<Value> predicate = valueConstraint(requiredType, constraint);
    for (Value v : valueFactory.createValues(property)) {
      if (predicate.apply(v)) {
        return;
      }
    }
  }
  constraintViolation(5, "Value constraint violation in " + property);
}
origin: apache/jackrabbit-oak

private void checkPropertyTypeConstraints(PropertyState after)
    throws CommitFailedException {
  if (NodeStateUtils.isHidden(after.getName())) {
    return;
  }
  NodeState definition = effective.getDefinition(after);
  if (definition == null) {
    constraintViolation(4, "No matching property definition found for " + after);
  } else if (JCR_UUID.equals(after.getName()) && effective.isNodeType(MIX_REFERENCEABLE)) {
    // special handling for the jcr:uuid property of mix:referenceable
    // TODO: this should be done in a pluggable extension
    if (!isValidUUID(after.getValue(Type.STRING))) {
      constraintViolation(12, "Invalid UUID value in the jcr:uuid property");
    }
  } else {
    int requiredType = getRequiredType(definition);
    if (requiredType != PropertyType.UNDEFINED) {
      checkRequiredType(after, requiredType);
      checkValueConstraints(definition, after, requiredType);
    }
  }
}
origin: org.apache.jackrabbit/oak-core

private void checkPropertyTypeConstraints(PropertyState after)
    throws CommitFailedException {
  if (NodeStateUtils.isHidden(after.getName())) {
    return;
  }
  NodeState definition = effective.getDefinition(after);
  if (definition == null) {
    constraintViolation(4, "No matching property definition found for " + after);
  } else if (JCR_UUID.equals(after.getName()) && effective.isNodeType(MIX_REFERENCEABLE)) {
    // special handling for the jcr:uuid property of mix:referenceable
    // TODO: this should be done in a pluggable extension
    if (!isValidUUID(after.getValue(Type.STRING))) {
      constraintViolation(12, "Invalid UUID value in the jcr:uuid property");
    }
  } else {
    int requiredType = getRequiredType(definition);
    if (requiredType != PropertyType.UNDEFINED) {
      checkRequiredType(after, requiredType);
      checkValueConstraints(definition, after, requiredType);
    }
  }
}
origin: org.apache.sling/org.apache.sling.testing.sling-mock-oak

private void checkPropertyTypeConstraints(PropertyState after)
    throws CommitFailedException {
  if (NodeStateUtils.isHidden(after.getName())) {
    return;
  }
  NodeState definition = effective.getDefinition(after);
  if (definition == null) {
    constraintViolation(4, "No matching property definition found for " + after);
  } else if (JCR_UUID.equals(after.getName()) && effective.isNodeType(MIX_REFERENCEABLE)) {
    // special handling for the jcr:uuid property of mix:referenceable
    // TODO: this should be done in a pluggable extension
    if (!isValidUUID(after.getValue(Type.STRING))) {
      constraintViolation(12, "Invalid UUID value in the jcr:uuid property");
    }
  } else {
    int requiredType = getRequiredType(definition);
    if (requiredType != PropertyType.UNDEFINED) {
      checkRequiredType(after, requiredType);
      checkValueConstraints(definition, after, requiredType);
    }
  }
}
origin: org.apache.jackrabbit/oak-core

@Override
public TypeEditor childNodeChanged(
    String name, NodeState before, NodeState after)
    throws CommitFailedException {
  String primary = after.getName(JCR_PRIMARYTYPE);
  Iterable<String> mixins = after.getNames(JCR_MIXINTYPES);
  if (primary == null && effective != null) {
    // no primary type defined, find and apply a default type
    primary = effective.getDefaultType(name);
    if (primary != null) {
      builder.setProperty(JCR_PRIMARYTYPE, primary, NAME);
    } else {
      constraintViolation(
          4, "No default primary type available "
          + " for child node " + name);
    }
  }
  // if node type didn't change no need to validate child node
  boolean validate = primaryChanged(before, primary) || mixinsChanged(before, mixins);
  NodeBuilder childBuilder = builder.getChildNode(name);
  TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, validate);
  if (checkThisNode && validate && !effective.isValidChildNode(name, editor.getEffective())) {
    constraintViolation(
        1, "No matching definition found for child node " + name
        + " with effective type " + editor.getEffective());
  }
  return editor;
}
origin: apache/jackrabbit-oak

@Override
public TypeEditor childNodeChanged(
    String name, NodeState before, NodeState after)
    throws CommitFailedException {
  String primary = after.getName(JCR_PRIMARYTYPE);
  Iterable<String> mixins = after.getNames(JCR_MIXINTYPES);
  if (primary == null && effective != null) {
    // no primary type defined, find and apply a default type
    primary = effective.getDefaultType(name);
    if (primary != null) {
      builder.setProperty(JCR_PRIMARYTYPE, primary, NAME);
    } else {
      constraintViolation(
          4, "No default primary type available "
          + " for child node " + name);
    }
  }
  // if node type didn't change no need to validate child node
  boolean validate = primaryChanged(before, primary) || mixinsChanged(before, mixins);
  NodeBuilder childBuilder = builder.getChildNode(name);
  TypeEditor editor = new TypeEditor(this, name, primary, mixins, childBuilder, validate);
  if (checkThisNode && validate && !effective.isValidChildNode(name, editor.getEffective())) {
    constraintViolation(
        1, "No matching definition found for child node " + name
        + " with effective type " + editor.getEffective());
  }
  return editor;
}
org.apache.jackrabbit.oak.plugins.nodetypeTypeEditorconstraintViolation

Javadoc

Throws or logs the specified constraint violation.

Popular methods of TypeEditor

  • <init>
  • checkNodeTypeConstraints
  • checkPropertyTypeConstraints
  • checkRequiredType
  • checkValueConstraints
  • childNodeChanged
  • createEffectiveType
  • getEffective
  • getPath
  • getRequiredType
  • mixinsChanged
  • primaryChanged
  • mixinsChanged,
  • primaryChanged,
  • propertyChanged,
  • childNodeDeleted,
  • create,
  • propertyDeleted

Popular in Java

  • Parsing JSON documents to java classes using gson
  • runOnUiThread (Activity)
  • putExtra (Intent)
  • setContentView (Activity)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Stack (java.util)
    The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • ImageIO (javax.imageio)
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now