Package org.apache.sling.api.resource

Examples of org.apache.sling.api.resource.PersistenceException


        final Modifiable mod = new Modifiable();
        mod.resource = parent;
        mod.node = parent.adaptTo(Node.class);
        mod.valueMap = parent.adaptTo(ModifiableValueMap.class);
        if ( mod.valueMap == null ) {
            throw new PersistenceException("Resource at '" + parent.getPath() + "' is not modifiable.");
        }

        final String name = prop.getName();
        if (prop.providesValue()) {
            // if user provided a value, don't mess with it
View Full Code Here


     */
    private boolean storeAsReference(final Modifiable parent, String name, String[] values, int type, boolean multiValued, ValueFactory valFac)
            throws RepositoryException, PersistenceException {
        if ( parent.node == null ) {
            // TODO
            throw new PersistenceException("Resource " + parent.resource.getPath() + " does not support reference properties.");
        }
        if (multiValued) {
            Value[] array = referenceParser.parse(values, valFac, isWeakReference(type));
            if (array != null) {
                changes.add(Modification.onModified(
View Full Code Here

            resources.remove(resource);
            Node node = resource.adaptTo(Node.class);
            try {
                node.remove();
            } catch (RepositoryException e) {
                throw new PersistenceException("RepositoryException: "+e, e);
            }
        } else {
            throw new UnsupportedOperationException("Not implemented");
        }
    }
View Full Code Here

    public void commit() throws PersistenceException {
        try {
            this.session.save();
        } catch (final RepositoryException re) {
            throw new PersistenceException("Unable to commit changes.", re);
        }
    }
View Full Code Here

    public static void moveResource(Resource res, String path) throws PersistenceException {
        try{
            Session session = res.adaptTo(Node.class).getSession();
            session.move(res.getPath(), path);
        } catch(RepositoryException re) {
            throw new PersistenceException(String.valueOf(re), re);
        }
    }
View Full Code Here

    @Override
    public Resource create(Resource parent, String name,
            Map<String, Object> properties) throws PersistenceException {
        final String path = (parent.getPath().equals("/") ? parent.getPath() + name : parent.getPath() + '/' + name);
        if ( this.temporaryResources.containsKey(path) ) {
            throw new PersistenceException("Path already exists: " + path);
        }
        synchronized ( this.resources ) {
            if ( this.resources.containsKey(path) && !this.deletedResources.contains(path) ) {
                throw new PersistenceException("Path already exists: " + path);
            }
        }
        this.deletedResources.remove(path);
        if ( properties == null ) {
            properties = new HashMap<String, Object>();
View Full Code Here

    }

    public static void getOrCreateBasePath(final ResourceResolver resolver,
            final String path)
    throws PersistenceException {
        PersistenceException mostRecentPE = null;
        for(int i=0;i<5;i++) {
            try {
                ResourceUtil.getOrCreateResource(resolver,
                        path,
                        ResourceHelper.RESOURCE_TYPE_FOLDER,
                        ResourceHelper.RESOURCE_TYPE_FOLDER,
                        true);
                return;
            } catch ( final PersistenceException pe ) {
                //in case of exception, revert to last clean state and retry SLING-4014
                resolver.revert();
                mostRecentPE = pe;
            }
        }
        throw new PersistenceException("Unable to create resource with path " + path, mostRecentPE);
    }
View Full Code Here

    }

    public static Resource getOrCreateResource(final ResourceResolver resolver,
            final String path, final Map<String, Object> props)
    throws PersistenceException {
        PersistenceException mostRecentPE = null;
        for(int i=0;i<5;i++) {
            try {
                return ResourceUtil.getOrCreateResource(resolver,
                        path,
                        props,
                        ResourceHelper.RESOURCE_TYPE_FOLDER,
                        true);
            } catch ( final PersistenceException pe ) {
                //in case of exception, revert to last clean state and retry SLING-4014
                resolver.revert();
                mostRecentPE = pe;
            }
        }
        throw new PersistenceException("Unable to create resource with path " + path, mostRecentPE);
    }
View Full Code Here

            properties.put(SlingshotConstants.PROPERTY_TITLE, title);
            properties.put(SlingshotConstants.PROPERTY_DESCRIPTION, description);
            properties.put(SlingshotConstants.PROPERTY_USER, userId);

            // we try it five times
            PersistenceException exception = null;
            Resource newResource = null;
            for(int i=0; i<5; i++) {
                try {
                    exception = null;
                    final String name = ResourceUtil.createUniqueChildName(reqResource, Util.filter(title));
View Full Code Here

                            try {
                                node.remove();
                            } catch ( final RepositoryException re) {
                                // we ignore this
                            }
                            throw new PersistenceException(iae.getMessage(), iae, path, entry.getKey());
                        }
                    }
                }
            }

            return new JcrNodeResource(resolver, path, node, this.dynamicClassLoader);
        } catch (final RepositoryException e) {
            throw new PersistenceException("Unable to create node at " + path, e, path, null);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.sling.api.resource.PersistenceException

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.