Package org.apache.wiki

Examples of org.apache.wiki.WikiEngine


     {@inheritDoc}
     */
    @Override
    public String getString()
    {
        WikiEngine engine = m_wikiContext.getEngine();
        Element root = new Element("rss");
        root.setAttribute("version","2.0");

        Element channel = new Element("channel");
        root.addContent( channel );

        //
        //  Mandatory parts
        //
        channel.addContent( new Element("title").setText( getChannelTitle() ) );
        channel.addContent( new Element("link").setText(engine.getBaseURL()));
        channel.addContent( new Element("description").setText( getChannelDescription() ));

        //
        //  Optional
        //
        channel.addContent( new Element("language").setText(getChannelLanguage()));
        channel.addContent( new Element("generator").setText("JSPWiki "+Release.VERSTR));

        String mail = engine.getVariable(m_wikiContext,RSSGenerator.PROP_RSS_AUTHOREMAIL);
        if( mail != null )
        {
            String editor = engine.getVariable( m_wikiContext,RSSGenerator.PROP_RSS_AUTHOR );

            if( editor != null )
                mail = mail + " ("+editor+")";

            channel.addContent( new Element("managingEditor").setText(mail) );
View Full Code Here


    }

    private void addItemList(XML root) {
        SimpleDateFormat iso8601fmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");

        WikiEngine engine = m_wikiContext.getEngine();

        for (Iterator i = m_entries.iterator(); i.hasNext(); ) {
            Entry e = (Entry) i.next();

            String url = e.getURL();

            XML item = new XML("item");
            item.addAttribute("rdf:about", url);

            item.addElement(new XML("title").addElement(format(e.getTitle())));

            item.addElement(new XML("link").addElement(url));

            XML content = new XML("description");

            // TODO: Add a size limiter here
            content.addElement(format(e.getContent()));

            item.addElement(content);

            WikiPage p = e.getPage();

            if (p.getVersion() != -1) {
                item.addElement(new XML("wiki:version").addElement(Integer.toString(p.getVersion())));
            }

            if (p.getVersion() > 1) {
                item.addElement(new XML("wiki:diff").addElement(engine.getURL(WikiContext.DIFF,
                        p.getName(),
                        "r1=-1",
                        true)));
            }


            //
            //  Modification date.
            //
            Calendar cal = Calendar.getInstance();
            cal.setTime(p.getLastModified());
            cal.add(Calendar.MILLISECOND,
                    -(cal.get(Calendar.ZONE_OFFSET) +
                            (cal.getTimeZone().inDaylightTime(p.getLastModified()) ? cal.get(Calendar.DST_OFFSET) : 0)));

            item.addElement(new XML("dc:date").addElement(iso8601fmt.format(cal.getTime())));

            //
            //  Author
            String author = e.getAuthor();
            if (author == null) {
                author = "unknown";
            }

            XML contributor = new XML("dc:creator");

            item.addElement(contributor);

            /*
            XML description = new XML("rdf:Description");
            if( m_wikiContext.getEngine().pageExists(author) )
            {
                description.addAttribute( "link", engine.getURL( WikiContext.VIEW,
                                                                 author,
                                                                 null,
                                                                 true ) );
            }
           
            description.addElement( new XML("value").addElement( format(author) ) );
            contributor.addElement( description );
           */

            // Not too many aggregators seem to like this.  Therefore we're
            // just adding the name here.

            contributor.addElement(format(author));

            //  PageHistory

            item.addElement(new XML("wiki:history").addElement(engine.getURL(WikiContext.INFO,
                    p.getName(),
                    null,
                    true)));

            //
View Full Code Here

    private Collection getItems()
    {
        ArrayList<Element> list = new ArrayList<Element>();

        WikiEngine engine = m_wikiContext.getEngine();
        ServletContext servletContext = null;

        if( m_wikiContext.getHttpRequest() != null )
            servletContext = m_wikiContext.getHttpRequest().getSession().getServletContext();

        for( Iterator i = m_entries.iterator(); i.hasNext(); )
        {
            Entry e = (Entry)i.next();

            WikiPage p = e.getPage();

            Element entryEl = getElement("entry");

            //
            //  Mandatory elements
            //

            entryEl.addContent( getElement("id").setText( getEntryID(e)) );
            entryEl.addContent( getElement("title").setAttribute("type","html").setText( e.getTitle() ));
            entryEl.addContent( getElement("updated").setText( DateFormatUtils.formatUTC(p.getLastModified(),
                                                                                         RFC3339FORMAT )));
            //
            //  Optional elements
            //

            entryEl.addContent( getElement("author").addContent( getElement("name").setText( e.getAuthor() )));
            entryEl.addContent( getElement("link").setAttribute("rel","alternate").setAttribute("href",e.getURL()));
            entryEl.addContent( getElement("content").setAttribute("type","html").setText( e.getContent() ));

            //
            //  Check for enclosures
            //

            if( engine.getAttachmentManager().hasAttachments(p) && servletContext != null )
            {
                try
                {
                    Collection c = engine.getAttachmentManager().listAttachments(p);

                    for( Iterator a = c.iterator(); a.hasNext(); )
                    {
                        Attachment att = (Attachment) a.next();

                        Element attEl = getElement("link");
                        attEl.setAttribute( "rel","enclosure" );
                        attEl.setAttribute( "href", engine.getURL(WikiContext.ATTACH, att.getName(), null, true ) );
                        attEl.setAttribute( "length", Long.toString(att.getSize()) );
                        attEl.setAttribute( "type", getMimeType( servletContext, att.getFileName() ) );

                        entryEl.addContent( attEl );
                    }
View Full Code Here

     */
    @Override
    public String getString()
    {
        Element root = getElement("feed");
        WikiEngine engine = m_wikiContext.getEngine();

        Date lastModified = new Date(0L);

        for( Iterator i = m_entries.iterator(); i.hasNext(); )
        {
            Entry e = (Entry)i.next();

            if( e.getPage().getLastModified().after(lastModified) )
                lastModified = e.getPage().getLastModified();
        }

        //
        //  Mandatory parts
        //
        root.addContent( getElement("title").setText( getChannelTitle() ) );
        root.addContent( getElement("id").setText(getFeedID()) );
        root.addContent( getElement("updated").setText(DateFormatUtils.formatUTC( lastModified,
                                                                                  RFC3339FORMAT ) ));

        //
        //  Optional
        //
        // root.addContent( getElement("author").addContent(getElement("name").setText(format())))
        root.addContent( getElement("link").setAttribute("href",engine.getBaseURL()));
        root.addContent( getElement("generator").setText("JSPWiki "+Release.VERSTR));

        String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
                                           "page="+engine.encodeName(m_wikiContext.getPage().getName())+
                                           "&mode="+m_mode+
                                           "&type=atom",
                                           true );
        Element self = getElement("link").setAttribute("rel","self");
        self.setAttribute("href",rssFeedURL);
View Full Code Here

        // Supply a custom LoginModule class
        props.put( "jspwiki.loginModule.class", "org.apache.wiki.auth.login.CookieAssertionLoginModule" );

        // Init the engine and verify that we initialized with a custom auth
        // login module
        WikiEngine engine = new TestEngine( props );
        AuthenticationManager authMgr = engine.getAuthenticationManager();
        assertEquals( CookieAssertionLoginModule.class, authMgr.m_loginModuleClass );
    }
View Full Code Here

        props.put( "jspwiki.loginModule.options.key2", "value2" );
        props.put( "jspwiki.loginModule.options.key3", "value3" );

        // Init the engine and verify that we initialized with the correct
        // options
        WikiEngine engine = new TestEngine( props );
        AuthenticationManager authMgr = engine.getAuthenticationManager();
        Map<String, String> options = authMgr.m_loginModuleOptions;
        assertEquals( 3, options.size() );
        assertTrue( options.containsKey( "key1" ) );
        assertTrue( options.containsKey( "key2" ) );
        assertTrue( options.containsKey( "key3" ) );
View Full Code Here

                           Hashtable content,
                           boolean publish )
        throws XmlRpcException
    {
        log.info("metaWeblog.newPost() called");
        WikiEngine engine = m_context.getEngine();
       
        WikiPage page = engine.getPage( blogid );
        checkPermissions( page, username, password, "createPages" );

        try
        {
            WeblogEntryPlugin plugin = new WeblogEntryPlugin();

            String pageName = plugin.getNewEntryPage( engine, blogid );

            WikiPage entryPage = new WikiPage( engine, pageName );
            entryPage.setAuthor( username );

            WikiContext context = new WikiContext( engine, entryPage );

            StringBuffer text = new StringBuffer();
            text.append( "!"+content.get("title") );
            text.append( "\n\n" );
            text.append( content.get("description") );

            log.debug("Writing entry: "+text);

            engine.saveText( context, text.toString() );
        }
        catch( Exception e )
        {
            log.error("Failed to create weblog entry",e);
            throw new XmlRpcException( 0, "Failed to create weblog entry: "+e.getMessage() );
View Full Code Here

    public void testMessage() throws Exception
    {
        Properties props = new Properties();
        props.load(TestEngine.findTestProperties());
        WikiEngine engine = new TestEngine(props);
        InternationalizationManager i18n = engine.getInternationalizationManager();
        String core = "templates.default";
        Locale english = Locale.ENGLISH;
        Outcome o;

        o = Outcome.DECISION_APPROVE;
View Full Code Here

        doc.setContext( context ); // Make sure it is set
       
        //
        //  Do some sane defaults
        //
        WikiEngine engine = m_context.getEngine();
        String runplugins = engine.getVariable( m_context, MarkupParser.PROP_RUNPLUGINS );
        if( runplugins != null ) enablePlugins( TextUtil.isPositive(runplugins));
    }
View Full Code Here

            if( context instanceof HttpServletRequest )
            {
                boolean canDo = false;
                HttpServletRequest req = (HttpServletRequest) context;
               
                WikiEngine e = WikiEngine.getInstance( req.getSession().getServletContext(), null );
              
                for( Iterator i = c_globalObjects.values().iterator(); i.hasNext(); )
                {
                    CallbackContainer cc = (CallbackContainer) i.next();
                   
                    if( cc.m_object == instance )
                    {
                        canDo = e.getAuthorizationManager().checkPermission( WikiSession.getWikiSession(e, req),
                                                                             cc.m_permission );

                        break;
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.wiki.WikiEngine

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.