Package org.apache.sling.api.resource

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


        // close is always allowed to be called
        rr.close();
        assertFalse(rr.isLive());
        // now check all public method - they should all throw!
        try {
            rr.adaptTo(Session.class);
            fail();
        } catch (final IllegalStateException ise) {
            // expected
        }
        try {
View Full Code Here


    }

    @Test public void test_clone_based_on_anonymous() throws Exception {
        final ResourceResolver anon0 = resFac.getResourceResolver((Map<String, Object>) null);
        // no session
        final Session anon0Session = anon0.adaptTo(Session.class);
        assertNull("Session should not be available", anon0Session);
        // no user information, so user id is null
        assertEquals(null, anon0.getUserID());

        // same user and workspace
View Full Code Here

        // no user information, so user id is null
        assertEquals(null, anon0.getUserID());

        // same user and workspace
        final ResourceResolver anon1 = anon0.clone(null);
        final Session anon1Session = anon1.adaptTo(Session.class);
        assertEquals(anon0.getUserID(), anon1.getUserID());
        assertNull("Session should not be available", anon1Session);
        anon1.close();

        // same workspace but admin user
View Full Code Here

        Session session = mock(Session.class);
        Workspace workspace = mock(Workspace.class);
        ObservationManager observationManager = mock(ObservationManager.class);
        when(workspace.getObservationManager()).thenReturn(observationManager);
        when(session.getWorkspace()).thenReturn(workspace);
        when(resourceResolver.adaptTo(Session.class)).thenReturn(session);

        ReplicationEventFactory eventFactory = mock(ReplicationEventFactory.class);

        FileVaultReplicationPackageBuilder fileVaultReplicationPackageBuilder = new FileVaultReplicationPackageBuilder(
                packaging, eventFactory);
View Full Code Here

        Session session = mock(Session.class);
        Workspace workspace = mock(Workspace.class);
        ObservationManager observationManager = mock(ObservationManager.class);
        when(workspace.getObservationManager()).thenReturn(observationManager);
        when(session.getWorkspace()).thenReturn(workspace);
        when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getId()).thenReturn(tempFile.getAbsolutePath());
        when(replicationPackage.getAction()).thenReturn(ReplicationActionType.ADD.name());
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/something"});
View Full Code Here

        Session session = mock(Session.class);
        Workspace workspace = mock(Workspace.class);
        ObservationManager observationManager = mock(ObservationManager.class);
        when(workspace.getObservationManager()).thenReturn(observationManager);
        when(session.getWorkspace()).thenReturn(workspace);
        when(resourceResolver.adaptTo(Session.class)).thenReturn(session);
        ReplicationPackage replicationPackage = mock(ReplicationPackage.class);
        when(replicationPackage.getId()).thenReturn(tempFile.getAbsolutePath());
        when(replicationPackage.getAction()).thenReturn(ReplicationActionType.ADD.name());
        when(replicationPackage.getPaths()).thenReturn(new String[]{"/something"});
View Full Code Here

                        resolver = fac.getAdministrativeResourceResolver(null);
                    } else {
                        resolver = fac.getResourceResolver(repoCredentials);
                    }

                    final Session s = resolver.adaptTo(Session.class);
                    ObservationManager om = s.getWorkspace().getObservationManager();
                    om.addEventListener(messageChangeHandler, 255, "/", true, null,
                        new String[] { "sling:Message" }, true);
                    om.addEventListener(languageChangeHandler, 255, "/", true, null,
                        new String[] { "mix:language" }, true);
View Full Code Here

        this.resourceResolver = null;
        clearCache();

        if (resolver != null) {

            Session s = resolver.adaptTo(Session.class);
            if (s != null) {

                try {
                    ObservationManager om = s.getWorkspace().getObservationManager();
                    om.removeEventListener(messageChangeHandler);
View Full Code Here

                resolver = null;
            }

            if (resolver != null) {
                return createUser(resolver.getUserID(),
                    resolver.adaptTo(org.apache.jackrabbit.api.security.user.User.class), resolver);
            }
        } catch (LoginException e) {
            throw new AuthenticationFailedException("Cannot login user " + auth, e);
        }
View Full Code Here

    }

    public String[] getAllUserNames() throws FtpException {
        final ResourceResolver admin = this.getAdminResolver();
        try {
            org.apache.jackrabbit.api.security.user.UserManager um = admin.adaptTo(org.apache.jackrabbit.api.security.user.UserManager.class);
            if (um != null) {
                try {
                    Iterator<Authorizable> ai = um.findAuthorizables(null, null,
                        org.apache.jackrabbit.api.security.user.UserManager.SEARCH_TYPE_USER);
                    ArrayList<String> list = new ArrayList<String>();
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.