Package org.apache.jackrabbit.ocm.exception

Examples of org.apache.jackrabbit.ocm.exception.JcrMappingException


        String[] pathElements = path.split(PATH_SEPARATOR);

        if (! isValidPath(path))
        {
            throw new JcrMappingException("Invalid path : " + path);
        }
        return pathElements[pathElements.length-1];
    }
View Full Code Here


    Node objectNode;
    try {
      objectNode = parentNode.addNode(nodeName, jcrType);
    } catch (NoSuchNodeTypeException nsnte) {
      throw new JcrMappingException("Unknown node type " + jcrType + " for mapped class " + object.getClass(), nsnte);
    } catch (RepositoryException re) {
      throw new ObjectContentManagerException("Cannot create new node of type " + jcrType + " from mapped class "
          + object.getClass(), re);
    }

    String[] mixinTypes = classDescriptor.getJcrMixinTypes();
    String mixinTypeName = null;
    try {

      // Add mixin types
      if (null != classDescriptor.getJcrMixinTypes()) {
        for (int i = 0; i < mixinTypes.length; i++) {
          mixinTypeName = mixinTypes[i].trim();
          objectNode.addMixin(mixinTypeName);
        }
      }

      // Add mixin types defined in the associated interfaces
      if (!classDescriptor.hasDiscriminator() && classDescriptor.hasInterfaces()) {
        Iterator interfacesIterator = classDescriptor.getImplements().iterator();
        while (interfacesIterator.hasNext()) {
          String interfaceName = (String) interfacesIterator.next();
          ClassDescriptor interfaceDescriptor = mapper
              .getClassDescriptorByClass(ReflectionUtils.forName(interfaceName));
          objectNode.addMixin(interfaceDescriptor.getJcrType().trim());
        }
      }

      // If required, add the discriminator node type
      if (classDescriptor.hasDiscriminator()) {
        addDiscriminatorProperty(object, objectNode);
      }


    } catch (NoSuchNodeTypeException nsnte) {
      throw new JcrMappingException("Unknown mixin type " + mixinTypeName + " for mapped class " + object.getClass(), nsnte);
    } catch (RepositoryException re) {
      throw new ObjectContentManagerException("Cannot create new node of type " + jcrType + " from mapped class "
          + object.getClass(), re);
    }
View Full Code Here

        }
        classDescriptor = mapper.getClassDescriptorByNodeType(nodeType);
      }

      if (null == classDescriptor) {
        throw new JcrMappingException("Impossible to find the classdescriptor for " + path
            + ". There is no discriminator and associated  JCR node type");
      }

      Object object = ReflectionUtils.newInstance(classDescriptor.getClassName());
View Full Code Here

          }
      }

      // ensure class is concrete (neither interface nor abstract)
      if (clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
          throw new JcrMappingException( "Cannot instantiate non-concrete class " + clazz.getName()
                        + " for node " + path + " of type " + node.getPrimaryNodeType().getName());
      }

            Object object = ReflectionUtils.newInstance(classDescriptor.getClassName());
View Full Code Here

  private void validateClassName() {
    try {
            ReflectionUtils.forName(this.className);
    } catch (JcrMappingException e) {
       throw new JcrMappingException("Class used in descriptor not found : " + className);
    }
  }
View Full Code Here

        if (jcrTypeName != null && !jcrTypeName.equals("")) {
          session.getWorkspace().getNodeTypeManager().getNodeType(jcrTypeName);
        }
      }
    } catch (NoSuchNodeTypeException nsnte) {
      throw new JcrMappingException("Mapping for class '" + classDescriptor.getClassName()
          + "' use unknown primary or mixin node type '" + jcrTypeName + "'");
    } catch (RepositoryException re) {
      throw new org.apache.jackrabbit.ocm.exception.RepositoryException(re);
    }
  }
View Full Code Here

  public String getPath(Session session, Object object) {
    ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(object.getClass());

    final FieldDescriptor pathFieldDescriptor = classDescriptor.getPathFieldDescriptor();
    if (pathFieldDescriptor == null) {
      throw new JcrMappingException(
          "Class of type: "
              + object.getClass().getName()
              + " has no path mapping. Maybe attribute path=\"true\" for a field element of this class in mapping descriptor is missing " +
                " or maybe it is defined in an ancestor class which has no mapping descriptor.");
    }
View Full Code Here

  }

  private ClassDescriptor getClassDescriptor(Class beanClass) {
    ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(beanClass);
    if (null == classDescriptor) {
      throw new JcrMappingException("Class of type: " + beanClass.getName()
          + " is not JCR persistable. Maybe element 'class-descriptor' for this type in mapping file is missing");
    }

    return classDescriptor;
  }
View Full Code Here

            // For collection of bean references, only Collections are supported
            if (! (objects instanceof ManageableCollection))
            {

              throw new JcrMappingException("Impossible to retrieve the attribute "
                  + collectionDescriptor.getFieldName() + " in the class "
                  + collectionDescriptor.getClassDescriptor().getClassName()
                  " because it is not a collection");
            }
View Full Code Here

          ClassDescriptor classDescriptor = mapper.getClassDescriptorByClass(object.getClass());

          FieldDescriptor fieldDescriptor = classDescriptor.getUuidFieldDescriptor();
          if (fieldDescriptor == null)
          {
            throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : "
                                  + classDescriptor.getClassName());
          }

          String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
          values[i] = valueFactory.createValue(uuid, PropertyType.REFERENCE);
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.ocm.exception.JcrMappingException

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.