Package org.apache.lenya.cms.repository

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


            Parameters _parameters) throws ProcessingException, SAXException, IOException {
        super.setup(_resolver, _objectModel, _source, _parameters);
        Request request = ObjectModelHelper.getRequest(_objectModel);

        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            URLInformation info = new URLInformation(ServletHelper.getWebappURI(request));
            String pubId = info.getPublicationId();
            this.rewriter = new IncomingLinkRewriter(factory.getPublication(pubId));
        } catch (final Exception e) {
View Full Code Here


        try {
            if (_parameters.isParameter(PARAMETER_URLS)) {
                setUrlType(_parameters.getParameter(PARAMETER_URLS));
            }
            Session session = RepositoryUtil.getSession(this.manager, _request);
            this.rewriter = new OutgoingLinkRewriter(this.manager, session, _request
                    .getRequestURI(), request.isSecure(), false, this.relativeUrls);
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
View Full Code Here

     */
    void handleError(String msg) throws SAXException {
        closeIndexer();

        try {
            Session session = RepositoryUtil.getSession(this.manager, this.request);
            User sender = session.getIdentity().getUser();
            UserManager userManager = (UserManager) sender.getItemManager();
            User recipient = userManager.getUser(this.notificationRecipient);
            Identifiable[] recipients = { recipient };

            String subject = "indexing-failed-subject";
View Full Code Here

import org.apache.lenya.cms.repository.Session;

public class OutgoingLinkRewriterTest extends AbstractAccessControlTest {

    public void testRelativeUrls() throws Exception {
        Session session = login("lenya");
        String url = "/aaa/bbb/ccc";
        OutgoingLinkRewriter rewriter = new OutgoingLinkRewriter(getManager(), session, url, false, false, true);
       
        assertEquals(rewriter.rewrite("/aaa/bbb/foo"), "foo");
        assertEquals(rewriter.rewrite("/aaa/bbb"), "..");
View Full Code Here

                        this.delegate = getFormatSource(doc, format);
                    }
                }
                if (this.delegate == null) {
                    String lenyaURL = doc.getSourceURI();
                    Session session = RepositoryUtil.getSession(this.manager, request);
                    this.delegate = new RepositorySource(manager, lenyaURL, session, getLogger());
                }
            }

        } catch (Exception e) {
View Full Code Here

        // UUID
        start = end + 1;
        uuid = location.substring(start);

        Session session;
        try {
            session = RepositoryUtil.getSession(this.manager, request);
        } catch (RepositoryException e1) {
            throw new RuntimeException(e1);
        }
View Full Code Here

        String url = null;
        ContextUtility contextUtility = null;
        try {
            contextUtility = (ContextUtility) serviceManager.lookup(ContextUtility.ROLE);
            Session session = RepositoryUtil.getSession(this.serviceManager, contextUtility
                    .getRequest());
            DocumentFactory map = DocumentUtil.createDocumentFactory(this.serviceManager, session);

            // always check for authoring URL since the live document doesn't
            // have to exist
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

    private DefaultAccessController accessController;

    protected org.apache.lenya.cms.repository.Session login(String userId)
            throws AccessControlException {

        Session session = new SessionImpl(null, true, getManager(), getLogger());
       
        DefaultAccessController ac = getAccessController(session, TEST_PUB_ID);
        AccreditableManager acMgr = ac.getAccreditableManager();
        User user = acMgr.getUserManager().getUser(userId);

        if (user == null) {
            throw new AccessControlException("The user [" + userId + "] does not exist!");
        }

        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

     * @throws Exception
     */
    public void testResourceLinkRewriting() throws Exception {
        String documentId = "/testResourceLinkRewriting";
       
        Session session = login("lenya");
        DocumentFactory factory = DocumentUtil.createDocumentFactory(getManager(), session);

        Publication pub = getPublication("test");
       
        ResourceWrapperTest.createResource(factory, pub, documentId, getManager(), getLogger());
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.