Package javax.jcr

Examples of javax.jcr.Session


     *
     * @throws NullPointerException If this class loader has already been
     *      destroyed.
     */
    private byte[] findClassLoaderClass(final String path) throws IOException {
        Session session = null;
        byte[] res = null;
        try {
            session = this.writer.createSession();
            if ( session.itemExists(path) ) {
                final Node node = (Node)session.getItem(path);
                logger.debug("Found resource at {}", path);
                res = Util.getBytes(node);
            } else {
                logger.debug("No classpath entry contains {}", path);
            }
        } catch (final RepositoryException re) {
            logger.debug("Error while trying to get node at " + path, re);
        } finally {
            if ( session != null ) {
                session.logout();
            }
        }
        if ( !this.dirty ) {
            synchronized ( this.usedResources ) {
                this.usedResources.add(path);
View Full Code Here


    private String encoding = "UTF-8";

    public void loadTestContent() throws RepositoryException, IOException {

        Session session = repository.loginAdministrative(null);
        try {
            new org.apache.jackrabbit.core.TestContentLoader().loadTestContent(session);
        } finally {
            session.logout();
        }
    }
View Full Code Here

        //
        // NOTE:
        // This is synchronous - take care to not block the system !!
        //

        Session session = null;
        final Bundle bundle = event.getBundle();
        switch (event.getType()) {
            case BundleEvent.STARTING:
                // register content when the bundle content is available
                // as node types are registered when the bundle is installed
View Full Code Here

        this.slingId = this.settingsService.getSlingId();
        this.initialContentLoader = new Loader(this);

        componentContext.getBundleContext().addBundleListener(this);

        Session session = null;
        try {
            session = this.getSession();
            this.createRepositoryPath(session, ContentLoaderService.BUNDLE_CONTENT_NODE);
            log.debug(
                    "Activated - attempting to load content from all "
                    + "bundles which are neither INSTALLED nor UNINSTALLED");

            int ignored = 0;
            Bundle[] bundles = componentContext.getBundleContext().getBundles();
            for (Bundle bundle : bundles) {
                if ((bundle.getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {

                    // load content for bundles which are neither INSTALLED nor
                    // UNINSTALLED
                    try {
                        initialContentLoader.registerBundle(session, bundle, false);
                    } catch (Throwable t) {
                        log.error(
                            "Problem loading initial content of bundle "
                                + bundle.getSymbolicName() + " ("
                                + bundle.getBundleId() + ")", t);
                    } finally {
                        if ( session.hasPendingChanges() ) {
                            session.refresh(false);
                        }
                    }
                } else {
                    ignored++;
                }
View Full Code Here

            SlingRepository slingRepo = (SlingRepository) getRepository();
            String workspace = slingRepo.getDefaultWorkspace();

            // no configuration, try to login and acquire the default name
            if (workspace == null || workspace.length() == 0) {
                Session tmp = null;
                try {
                    tmp = slingRepo.login();
                    workspace = tmp.getWorkspace().getName();
                } catch (Throwable t) {
                    // TODO: log !!
                    workspace = "default"; // fall back name
                } finally {
                    if (tmp != null) {
                        tmp.logout();
                    }
                }
            }

            locatorFactory = new SlingLocatorFactory(workspace);
View Full Code Here

        ObservationManager observationManager = mock(ObservationManager.class);

        Workspace workspace = mock(Workspace.class);
        when(workspace.getObservationManager()).thenReturn(observationManager);

        Session session = mock(Session.class);
        when(session.getWorkspace()).thenReturn(workspace);

        SlingRepository repository = mock(SlingRepository.class);
        when(repository.loginAdministrative(null)).thenReturn(session);

        EventAdmin eventAdmin = mock(EventAdmin.class);
View Full Code Here

         * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
         */
        public Object invoke(Object proxy, Method method, Object[] args)
        throws Throwable {
            if ( method.getName().equals("impersonate") && args != null && args.length == 1) {
                final Session session = this.delegatee.impersonate((Credentials)args[0]);
                this.namespaceSupport.defineNamespacePrefixes(session);
                final Class<?> sessionClass = session.getClass();
                return Proxy.newProxyInstance(sessionClass.getClassLoader(),
                        interfaces,
                        new SessionProxyInvocationHandler(session, this.namespaceSupport, interfaces));
            }
            try {
View Full Code Here

            if (pid.indexOf('/') != -1) {
                return null; // something bogus on the end of the path so bail
                             // out now.
            }
            try {
                Session session = resourceResolver.adaptTo(Session.class);
                if (session != null) {
                    UserManager userManager = AccessControlUtil.getUserManager(session);
                    if (userManager != null) {
                        Authorizable authorizable = userManager.getAuthorizable(pid);
                        if (authorizable != null) {
View Full Code Here

            } else if (SYSTEM_USER_MANAGER_GROUP_PATH.equals(path)) {
                searchType = PrincipalManager.SEARCH_TYPE_GROUP;
            }
            if (searchType != -1) {
                PrincipalIterator principals = null;
                Session session = resourceResolver.adaptTo(Session.class);
                if (session != null) {
                    PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
                    principals = principalManager.getPrincipals(searchType);
                }
View Full Code Here

    @Override
    protected void handleOperation(SlingHttpServletRequest request,
        AbstractPostResponse response, List<Modification> changes)
            throws RepositoryException {

        Session session = request.getResourceResolver().adaptTo(Session.class);
        String principalName = request.getParameter(SlingPostConstants.RP_NODE_NAME);
        Group group = createGroup(session,
                principalName,
                request.getRequestParameterMap(),
                changes);
View Full Code Here

TOP

Related Classes of javax.jcr.Session

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.