Package org.apache.lenya.cms.repository

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


                // Workaround:
                // We create a new session because the sitetree of the transaction doesn't yet
                // contain
                // references to any new documents that were uploaded during the transaction.
                // See https://issues.apache.org/bugzilla/show_bug.cgi?id=47621
                Session readOnlySession = RepositoryUtil.createSession(this.manager,
                        examinedDocument.getSession().getIdentity(), false);
                DocumentFactory newFactory = DocumentUtil.createDocumentFactory(this.manager,
                        readOnlySession);
                final LinkRewriter[] rewriters = { new UrlToUuidRewriter(pub.getFactory()),
                        new UrlToUuidRewriter(newFactory) };
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"));

            session.commit();
        }

        Session aliceSession = login("alice");
        Publication alicePub = getPublication(aliceSession, "test");
        final SiteStructure authSite = alicePub.getArea("authoring").getSite();
        assertTrue(authSite.contains("/tutorial"));
        final Document index = authSite.getNode("/index").getLink("en").getDocument();
        final org.w3c.dom.Document indexDoc = DocumentHelper.readDocument(index.getRepositoryNode()
View Full Code Here

    protected static final String PARENT_PATH = "/foo";

    public void testSimpleSiteManager() throws Exception {

        Session session = login("lenya");

        DocumentFactory factory = DocumentUtil.createDocumentFactory(getManager(), session);
        Publication[] pubs = factory.getPublications();

        for (int i = 0; i < pubs.length; i++) {
View Full Code Here

     * Do the migration.
     * @throws Exception
     */
    public void testMigrateUuids() throws Exception {

        Session session = login("lenya");
        DocumentFactory factory = DocumentUtil.createDocumentFactory(getManager(), session);
        Publication[] pubs = factory.getPublications();
        for (int i = 0; i < pubs.length; i++) {
            this.migratedDocs.clear();
            migratePublication(pubs[i]);
        }
        session.commit();
    }
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!");
        }

        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

     * The test.
     * @throws Exception
     */
    public void testUsecase() throws Exception {

        Session session = getSession();
        prepareUsecase();

        UsecaseInvoker invoker = null;
        try {
            invoker = (UsecaseInvoker) getManager().lookup(TestUsecaseInvoker.ROLE);
View Full Code Here

            log.debug("No workflow event.");
        } else {
            log.debug("Workflow event: [" + eventName + "]");
            // check for workflow instance first (task can initialize the workflow history)
            try {
                Session session = RepositoryUtil.createSession(this.manager, null);
                DocumentFactory map = DocumentUtil.createDocumentIdentityMap(this.manager, session);
                this.document = map.getFromURL(webappUrl);
            } catch (Exception e) {
                throw new ExecutionException(e);
            }
View Full Code Here

     * @throws ExecutionException when something went wrong.
     */
    public void invokeTransition() throws ExecutionException {

        try {
            Session session = RepositoryUtil.createSession(this.manager, null);
            WorkflowUtil.invoke(this.manager,
                    session,
                    new ConsoleLogger(),
                    this.document,
                    getEventName());
View Full Code Here

            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);
            this.rewriter = new UrlToUuidRewriter(factory);
        } catch (final Exception e1) {
            throw new ProcessingException(e1);
        }
View Full Code Here

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

        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            String webappUrl = getWebappUrl(params, objectModel);
            URLInformation info = new URLInformation(webappUrl);
            String pubId = info.getPublicationId();
            this.rewriter = new IncomingLinkRewriter(factory.getPublication(pubId));
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.