Package org.apache.sling.api.resource

Examples of org.apache.sling.api.resource.ResourceResolver.commit()


        Resource testResource2 = resolver2.getResource("/test");
        assertNotNull(testResource2);
       
        // delete resource and make sure it is removed in resolver 1 as well
        resolver2.delete(testResource2);
        resolver2.commit();
       
        assertNull(resolver1.getResource("/test"));
    }

}
View Full Code Here


     */
    public void remove(boolean logErrorOnFailure) {
        final ResourceResolver resourceResolver = getResource().getResourceResolver();
        try{
            resourceResolver.delete(getResource());
            resourceResolver.commit();
        } catch(PersistenceException pe) {
            if (logErrorOnFailure) {
                logger.error("remove: Could not remove node: " + pe, pe);
            } else {
                logger.info("remove: Could not remove node: "+pe);
View Full Code Here

              anyChanges = true;
                myInstanceMap.put(entry.getKey(), entry.getValue());
            }

            if (anyChanges) {
                resourceResolver.commit();
            }
        } catch (LoginException e) {
            logger.error(
                    "handleEvent: could not log in administratively: " + e, e);
            throw new RuntimeException("Could not log in to repository (" + e
View Full Code Here

                }
                resourceMap.put("leaderElectionId", prefix + "_"
                        + currentTimeMillisStr + "_" + slingId);
                resetLeaderElectionId = false;
            }
            resourceResolver.commit();

            // SLING-2892: only in success case: remember the last heartbeat value written
            lastHeartbeatWritten = currentTime;
            // and set the first heartbeat written value - if it is not already set
            if (firstHeartbeatWritten==-1) {
View Full Code Here

                    + settingsService.getSlingId()
                    + "/announcements/" + ownerId;
            final Resource announcementsResource = resourceResolver.getResource(path);
            if (announcementsResource!=null) {
                resourceResolver.delete(announcementsResource);
                resourceResolver.commit();
            }

        } catch (LoginException e) {
            logger.error(
                    "unregisterAnnouncement: could not log in administratively: "
View Full Code Here

                                    + "/"
                                    + settingsService.getSlingId()
                                    + "/announcements");

            topologyAnnouncement.persistTo(announcementsResource);
            resourceResolver.commit();
            ownAnnouncementsCache.put(topologyAnnouncement.getOwnerId(),
                    new CachedAnnouncement(topologyAnnouncement, config));
        } catch (LoginException e) {
            logger.error(
                    "registerAnnouncement: could not log in administratively: "
View Full Code Here

                    config.getClusterInstancesPath()
                                + "/"
                                + settingsService.getSlingId()
                                + "/announcements/"
                                + instanceId);
            resourceResolver.commit();
            resourceResolver.close();
            resourceResolver = null;
        } catch (LoginException e) {
            logger.error(
                    "deleteAnnouncementsOf: could not log in administratively when deleting "
View Full Code Here

            delete(child);
        }
        resolver.delete(rsrc);
        deleteCount++;
        if ( deleteCount >= 20 ) {
            resolver.commit();
            deleteCount = 0;
        }
    }

    public void cleanup() {
View Full Code Here

        try {
            resolver = factory.getAdministrativeResourceResolver(null);
            final Resource rsrc = resolver.getResource(JobManagerConfiguration.DEFAULT_REPOSITORY_PATH);
            if ( rsrc != null ) {
                delete(rsrc);
                resolver.commit();
            }
        } catch ( final LoginException le ) {
            // ignore
        } catch (final PersistenceException e) {
            // ignore
View Full Code Here

            delete(child);
        }
        resolver.delete(rsrc);
        count++;
        if ( count >= max ) {
            resolver.commit();
            count = 0;
        }
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.