Package org.apache.jackrabbit.ocm.exception

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


    public static Class forName(String clazz) {
        try {
            return Class.forName(clazz, true, getClassLoader());
        }
        catch(Exception ex) {
            throw new JcrMappingException("Cannot load class " + clazz, ex);
        }
    }
View Full Code Here


   * @return The class matching to the interface default interface
   */
  public static Class getDefaultImplementation(Class clazz)
  {
    if (! clazz.isInterface())
      throw new JcrMappingException(clazz + " is not an interface");

    return defaultImplementation.get(clazz);
  }
View Full Code Here

      }
     
      FieldDescriptor fieldDescriptor = beanClassDescriptor.getUuidFieldDescriptor();
      if (fieldDescriptor == null)
      {
        throw new JcrMappingException("The bean doesn't have an uuid - classdescriptor : " + beanClassDescriptor.getClassName());
      }
     
      String uuid = (String) ReflectionUtils.getNestedProperty(object, fieldDescriptor.getFieldName());
      parentNode.setProperty(beanDescriptor.getJcrName(), uuid, PropertyType.REFERENCE);
    } catch (Exception e) {
View Full Code Here

    Node objectNode = null;
    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

        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

            log.debug("Logout. Persisting current session changes.");
            this.session.save();
            this.session.logout();
            log.debug("Session closed");
        } catch (NoSuchNodeTypeException nsnte) {
            throw new JcrMappingException("Cannot persist current session changes. An unknown node type was used.", nsnte);
        } catch (javax.jcr.version.VersionException ve) {
            throw new VersionException("Cannot persist current session changes. Attempt to overwrite checked-in node", ve);
        } catch (LockException le) {
            throw new ObjectContentManagerException("Cannot persist current session changes. Violation of a lock detected", le);
        } catch (javax.jcr.RepositoryException e) {
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.