Package org.apache.lenya.cms.repository

Examples of org.apache.lenya.cms.repository.Session


        DocumentFactory map = getFactory();
        Document document = map.getFromURL(url);

        document.getRepositoryNode().lock();

        Session session = getSession(submitSituation);
        Workflowable workflowable = WorkflowUtil.getWorkflowable(getManager(),
                session,
                getLogger(),
                document);
        if (workflowable.getVersions().length > 0) {
View Full Code Here


        getLogger().info("Test completed.");
    }

    protected void invoke(Document document, TestSituation situation)
            throws AccessControlException, RepositoryException, WorkflowException {
        Session session = getSession(situation);
        Workflowable instance = new DocumentWorkflowable(getManager(),
                session,
                document,
                getLogger());
        assertNotNull(instance);
View Full Code Here

        assertEquals(value, situation.getValue());
    }

    protected Session getSession(TestSituation situation) throws AccessControlException,
            RepositoryException {
        Session session = login(situation.getUser());
        getLogger().info("User: [" + session.getIdentity().getUser() + "]");
        return session;
    }
View Full Code Here

            throws AccessControlException {
        return login(userId, TEST_PUB_ID);
    }

    protected Session login(String userId, String pubId) throws AccessControlException {
        Session session = new SessionImpl(null, true, getManager(), getLogger());
        getRequest().setAttribute(Session.class.getName(), session);

        DefaultAccessController ac = getAccessController(session, pubId);
        AccreditableManager acMgr = ac.getAccreditableManager();
        User user = acMgr.getUserManager().getUser(userId);

        if (user == null) {
            throw new AccessControlException("The user [" + userId
                    + "] does not exist in the accreditable manager [" + acMgr.getId() + "]!");
        }

        ac.setupIdentity(getRequest());

        org.apache.cocoon.environment.Session cocoonSession = getRequest().getSession();
        Identity identity = (Identity) cocoonSession.getAttribute(Identity.class.getName());

        if (!identity.contains(user)) {
            User oldUser = identity.getUser();
            if (oldUser != null) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Removing user [" + oldUser + "] from identity.");
                }
                identity.removeIdentifiable(oldUser);
            }
            identity.addIdentifiable(user);
        }

        ac.authorize(getRequest());

        Accreditable[] accrs = identity.getAccreditables();
        for (int i = 0; i < accrs.length; i++) {
            getLogger().info("Accreditable: " + accrs[i]);
        }

        session.setIdentity(identity);
        return session;
    }
View Full Code Here

        WorkflowManager workflowManager = null;

        try {
            Request request = ObjectModelHelper.getRequest(_objectModel);
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory map = DocumentUtil.createDocumentFactory(this.manager, session);

            String webappUrl = ServletHelper.getWebappURI(request);
            Document document = null;
            if (map.isDocument(webappUrl)) {
View Full Code Here

    /**
     * @throws Exception if an error occurs.
     */
    public void testImport() throws Exception {
       
        Session session = login("lenya");
       
        Publication pub = getPublication(session, "test");
        Area area = pub.getArea("authoring");
       
        if (area.getDocuments().length == 0) {
            Publication defaultPub = getPublication(session, "default");
            Area defaultArea = defaultPub.getArea("authoring");
            String pubPath = defaultArea.getPublication().getDirectory().getAbsolutePath();
            String path = pubPath.replace(File.separatorChar, '/') + "/example-content";
            Importer importer = new Importer(getManager(), getLogger());
            importer.importContent(defaultPub, area, path);
           
            assertTrue(area.getSite().contains("/tutorial"));
            checkLinks(area);
           
            session.commit();
        }
       
        Session aliceSession = login("alice");
        Publication alicePub = getPublication(aliceSession, "test");
        assertTrue(alicePub.getArea("authoring").getSite().contains("/tutorial"));
       
    }
View Full Code Here

        }
    }

    protected static Node getRepositoryNode(ServiceManager manager, DocumentFactory docFactory,
            String sourceUri) {
        Session session = docFactory.getSession();
        NodeFactory factory = null;
        try {
            factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
            return (Node) session.getRepositoryItem(factory, sourceUri);
        } catch (Exception e) {
            throw new RuntimeException("Creating repository node failed: ", e);
        } finally {
            if (factory != null) {
                manager.release(factory);
View Full Code Here

        Document document = null;

        Request request = ObjectModelHelper.getRequest(objectModel);

        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory docFactory = DocumentUtil.createDocumentFactory(this.manager, session);
            Publication pub = docFactory.getPublication(publicationId);
            document = docFactory.get(pub, area, uuid, language, revision);
        } catch (Exception e) {
            throw new ConfigurationException("Error getting document [" + publicationId + ":"
View Full Code Here

            throws ConfigurationException {
        Object value = null;

        try {
            Request request = ObjectModelHelper.getRequest(objectModel);
            Session session = RepositoryUtil.getSession(this.manager, request);

            ResourceType resourceType;
            Publication pub = null;
            String attribute;
View Full Code Here

    private Request request;

    protected DocumentFactory getDocumentFactory() {
        if (this.documentIdentityMap == null) {
            try {
                Session session = RepositoryUtil.getSession(this.manager, this.request);
                this.documentIdentityMap = DocumentUtil.createDocumentFactory(this.manager, session);
            } catch (RepositoryException e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.repository.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.