Package org.apache.jackrabbit.ocm.exception

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


     */
    public void save() {
        try {
            this.session.save();
        } 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 (RepositoryException e) {
View Full Code Here


    public static ManageableCollection getManageableCollection(String manageableCollectionClassName) {
        try {
            return (ManageableCollection) ReflectionUtils.newInstance(manageableCollectionClassName);
        }
        catch (Exception e) {
            throw new JcrMappingException("Cannot create manageable collection : "
                                           + manageableCollectionClassName,
                                           e);
        }
    }
View Full Code Here

                return new ManageableSet();
            }
           
            Object collection = collectionClass.newInstance();
            if (!(collection instanceof ManageableCollection)) {
                throw new JcrMappingException("Unsupported collection type :"
                                               + collectionClass.getName());
            }
            else {
                return (ManageableCollection) collection;
            }
        }
        catch (Exception e) {
            throw new JcrMappingException("Cannot create manageable collection", e);
        }
    }
View Full Code Here

            if (object.getClass().equals(Set.class)) {
                return new ManageableSet((Set) object);
            }
        }
        catch (Exception e) {
            throw new JcrMappingException("Impossible to create the manageable collection", e);
        }
       
        throw new JcrMappingException("Unsupported collection type :" + object.getClass().getName());
    }
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

      }
     
      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

  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

            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

        }

        String jcrName = collectionDescriptor.getJcrName();

        if (jcrName == null) {
            throw new JcrMappingException(
                    "The JcrName attribute is not defined for the CollectionDescriptor : "
                    + collectionDescriptor.getFieldName() + " for the classdescriptor : " + collectionDescriptor.getClassDescriptor().getClassName());
        }

        Node collectionNode = parentNode.addNode(jcrName);
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()) {
        mixinTypeName = ManagerConstant.DISCRIMINATOR_NODE_TYPE;
        objectNode.addMixin(mixinTypeName);
        objectNode.setProperty(ManagerConstant.DISCRIMINATOR_PROPERTY_NAME, ReflectionUtils.getBeanClass(object)
            .getName());
      }


    } 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

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.