Package org.jboss.seam.wiki.core.dao

Examples of org.jboss.seam.wiki.core.dao.WikiNodeDAO


    @Test
    public void isUniqueWikinameFalse() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                WikiNodeDAO dao = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                Boolean result = dao.isUniqueWikiname(3l, "One");
                assert !result;
            }
        }.run();
    }
View Full Code Here


    @Test
    public void isUniqueWikinameTrueWithNode() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                WikiNodeDAO dao = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newDoc = new WikiDocument();
                newDoc.setWikiname("Foobar");
                Boolean result = dao.isUniqueWikiname(3l, newDoc);
                assert result;
            }
        }.run();
    }
View Full Code Here

    @Test
    public void isUniqueWikinameFalseWithNode() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                WikiNodeDAO dao = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newDoc = new WikiDocument();
                newDoc.setWikiname("One");
                Boolean result = dao.isUniqueWikiname(3l, newDoc);
                assert !result;
            }
        }.run();
    }
View Full Code Here

    @Test
    public void findComments() throws Exception {
        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                WikiNodeDAO dao = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument d = dao.findWikiDocument(6l);
                assert d.getName().equals("One");

                List<WikiComment> comments = dao.findWikiComments(d, true);
                assert comments.size() == 6;

                assert comments.get(0).getId().equals(10l);
                assert comments.get(1).getId().equals(11l);
                assert comments.get(2).getId().equals(12l);
View Full Code Here

    public String nuke() {
     
       // First delete their comments
      
       DocumentHome documentHome = (DocumentHome) Component.getInstance("documentHome");             
       WikiNodeDAO wikiNodeDAO = (WikiNodeDAO) Component.getInstance("wikiNodeDAO");
             
       // Find all the content that this user has created
       List<WikiNode> userNodes = wikiNodeDAO.findWikiNodes(getInstance());
      
       Set<WikiNode> nodesToDelete = new HashSet<WikiNode>();
      
       // Build a list of all the child nodes of the user's nodes
       for (WikiNode node : userNodes)
View Full Code Here

    public Feed resolveFeedWithAreaNameAndNodeName(String areaName, String nodeName) {
        Feed feed = null;
        if (!areaName.matches("^[A-Z0-9]+.*")) return feed;
        log.debug("trying to retrieve area: " + areaName);
        WikiNodeDAO nodeDAO = (WikiNodeDAO)Component.getInstance(WikiNodeDAO.class);
        WikiDirectory area = nodeDAO.findAreaUnrestricted(areaName);
        if (area != null && (nodeName == null || !nodeName.matches("^[A-Z0-9]+.*")) && area.getFeed() != null) {
            log.debug("using feed of area, no node requested: " + area);
            feed = area.getFeed();
        } else if (area != null && nodeName != null && nodeName.matches("^[A-Z0-9]+.*")) {
            log.debug("trying to retrieve node: " + nodeName);
            WikiDirectory nodeDir = nodeDAO.findWikiDirectoryInAreaUnrestricted(area.getAreaNumber(), nodeName);
            if (nodeDir != null && nodeDir.getFeed() != null) {
                log.debug("using feed of node: " + nodeDir);
                feed = nodeDir.getFeed();
            } else {
                log.debug("node not found or node has no feed");
View Full Code Here

    public void newTopic() throws Exception {

        final String conversationId = new FacesRequest() {

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);
                home.newTopic();
            }
        }.run();

        new FacesRequest() {

            protected void beforeRequest() {
                setParameter("cid", conversationId);
            }

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);

                home.getInstance().setName("New Topic");
                home.getTextEditor().setValue("This is a new topic.");

                assert invokeMethod("#{topicHome.persist}") == null;

                Long newId = (Long)getValue("#{topicHome.instance.id}");

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newTopic = nodeDAO.findWikiDocument(newId);

                assert newTopic.getAreaNumber().equals(100l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);
                FeedEntry fe = feedDAO.findFeedEntry(newTopic);
View Full Code Here

        loginAdmin();

        final String conversationId = new FacesRequest() {

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);
                home.newTopic();
            }
        }.run();

        new FacesRequest() {

            protected void beforeRequest() {
                setParameter("cid", conversationId);
            }

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);

                home.getInstance().setName("New Topic");
                home.getTextEditor().setValue("This is a new topic.");
                home.setSticky(true);

                assert invokeMethod("#{topicHome.persist}") == null;
               
                Long newId = (Long)getValue("#{topicHome.instance.id}");

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newTopic = nodeDAO.findWikiDocument(newId);

                assert newTopic.getAreaNumber().equals(100l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);
                FeedEntry fe = feedDAO.findFeedEntry(newTopic);
View Full Code Here

        loginAdmin();

        final String conversationId = new FacesRequest() {

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);
                home.newTopic();
            }
        }.run();

        new FacesRequest() {

            protected void beforeRequest() {
                setParameter("cid", conversationId);
            }

            protected void updateModelValues() throws Exception {
                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDirectory forumDir = nodeDAO.findWikiDirectory(102l);
                Contexts.getPageContext().set("currentDirectory", forumDir);
                Contexts.getPageContext().set("currentDocument", forumDir.getDefaultFile());
            }

            protected void invokeApplication() throws Exception {
                TopicHome home = (TopicHome)getInstance(TopicHome.class);

                home.getInstance().setName("New Topic");
                home.getTextEditor().setValue("This is a new topic.");
                home.getInstance().setEnableComments(false);

                assert invokeMethod("#{topicHome.persist}") == null;

                Long newId = (Long)getValue("#{topicHome.instance.id}");

                WikiNodeDAO nodeDAO = (WikiNodeDAO)getInstance(WikiNodeDAO.class);
                WikiDocument newTopic = nodeDAO.findWikiDocument(newId);

                assert newTopic.getAreaNumber().equals(100l);

                FeedDAO feedDAO = (FeedDAO)getInstance(FeedDAO.class);
                FeedEntry fe = feedDAO.findFeedEntry(newTopic);
View Full Code Here

        }
    }

    public void createHomeDirectory(User user) {

        WikiNodeDAO nodeDAO = (WikiNodeDAO)Component.getInstance(WikiNodeDAO.class);
        WikiURLRenderer urlRenderer = (WikiURLRenderer)Component.getInstance(WikiURLRenderer.class);

        // Create home directory
        WikiDirectory memberArea = (WikiDirectory)Component.getInstance("memberArea");

        WikiDirectory homeDirectory = new WikiDirectory();
        homeDirectory.setName(user.getUsername());
        homeDirectory.setWikiname(WikiUtil.convertToWikiName(homeDirectory.getName()));
        homeDirectory.setAreaNumber(memberArea.getAreaNumber());
        homeDirectory.setCreatedBy(user);
        homeDirectory.setWriteAccessLevel(Role.ADMINROLE_ACCESSLEVEL);
        homeDirectory.setReadAccessLevel(Role.GUESTROLE_ACCESSLEVEL);
        homeDirectory.setParent(memberArea);
        user.setMemberHome(homeDirectory);

        // Create feed for home directory
        WikiFeed feed = new WikiFeed();
        feed.setLink(urlRenderer.renderURL(homeDirectory));
        feed.setDirectory(homeDirectory);
        feed.setAuthor(homeDirectory.getCreatedBy().getFullname());
        feed.setTitle(homeDirectory.getName());
        homeDirectory.setFeed(feed);

        nodeDAO.makePersistent(homeDirectory);

        // Create home page
        WikiDocument homePage = new WikiDocument();
        homePage.setName("Home of " + user.getUsername());
        homePage.setWikiname(WikiUtil.convertToWikiName(homePage.getName()));
        homePage.setCreatedBy(user);
        homePage.setAreaNumber(homeDirectory.getAreaNumber());
        homePage.setContent(Preferences.instance().get(UserManagementPreferences.class).getHomepageDefaultContent());
        homePage.setWriteAccessLevel(Role.ADMINROLE_ACCESSLEVEL);
        homePage.setReadAccessLevel(Role.GUESTROLE_ACCESSLEVEL);

        MacroWikiTextRenderer renderer = MacroWikiTextRenderer.renderMacros(homePage.getContent());
        homePage.setContentMacros(renderer.getMacros());

        homePage.setParent(homeDirectory);
        homeDirectory.setDefaultFile(homePage);

        nodeDAO.makePersistent(homePage);
    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.wiki.core.dao.WikiNodeDAO

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.