Package org.apache.wiki

Examples of org.apache.wiki.WikiEngine


    }

    public void testMessage() throws Exception
    {
        Properties props = TestEngine.getTestProperties();
        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


    public void setUp()
        throws Exception
    {
            Properties props = TestEngine.getTestProperties();
            PropertyConfigurator.configure(props);
            WikiEngine engine  = new TestEngine(props);
            m_db = engine.getUserManager().getUserDatabase();
    }
View Full Code Here

   */
  protected void setUp() throws Exception
  {
      super.setUp();
      Properties props = TestEngine.getTestProperties();
      WikiEngine engine  = new TestEngine( props );
      m_db = new XMLGroupDatabase();
      m_db.initialize( engine, props );
      m_wiki = engine.getApplicationName();
  }
View Full Code Here

    }

    public void setUp() throws Exception
    {
        Properties props = TestEngine.getTestProperties();
        WikiEngine engine  = new TestEngine( props );
        m_wiki = engine.getApplicationName();
       
        m_group = new Group( "TestGroup", m_wiki );
    }
View Full Code Here

  protected void setUp() throws Exception
  {
      super.setUp();
      Properties props = TestEngine.getTestProperties();
      props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml" );
      WikiEngine engine  = new TestEngine(props);
      m_db = new XMLUserDatabase();
      m_db.initialize(engine, props);
  }
View Full Code Here

     {@inheritDoc}
     */
    public String execute( WikiContext context, Map<String, String> params )
        throws PluginException
    {
        WikiEngine engine = context.getEngine();
        String src     = getCleanParameter( params, PARAM_SRC );
        String align   = getCleanParameter( params, PARAM_ALIGN );
        String ht      = getCleanParameter( params, PARAM_HEIGHT );
        String wt      = getCleanParameter( params, PARAM_WIDTH );
        String alt     = getCleanParameter( params, PARAM_ALT );
        String caption = getCleanParameter( params, PARAM_CAPTION );
        String link    = getCleanParameter( params, PARAM_LINK );
        String target  = getCleanParameter( params, PARAM_TARGET );
        String style   = getCleanParameter( params, PARAM_STYLE );
        String cssclass= getCleanParameter( params, PARAM_CLASS );
        // String map     = getCleanParameter( params, PARAM_MAP );
        String border  = getCleanParameter( params, PARAM_BORDER );

        if( src == null )
        {
            throw new PluginException("Parameter 'src' is required for Image plugin");
        }

        if( cssclass == null ) cssclass = "imageplugin";

        if( target != null && !validTargetValue(target) )
        {
            target = null; // not a valid value so ignore
        }

        try
        {
            AttachmentManager mgr = engine.getAttachmentManager();
            Attachment        att = mgr.getAttachmentInfo( context, src );

            if( att != null )
            {
                src = context.getURL( WikiContext.ATTACH, att.getName() );
View Full Code Here

    private static final Logger log = Logger.getLogger( PageSizeTag.class );
   
    public final int doWikiStartTag()
        throws IOException
    {
        WikiEngine engine = m_wikiContext.getEngine();
        WikiPage   page   = m_wikiContext.getPage();

        try
        {
            if( page != null )
            {
                long size = page.getSize();

                if( size == -1 && engine.pageExists(page) ) // should never happen with attachments
                {
                    size = engine.getPureText( page.getName(), page.getVersion() ).length();
                    page.setSize( size );
                }

                pageContext.getOut().write( Long.toString(size) );
            }
View Full Code Here

        }
       
        //
        //  Preconditions: "from" page must exist, and "to" page must not yet exist.
        //
        WikiEngine engine = context.getEngine();
        WikiPage fromPage = engine.getPage( renameFrom );
       
        if( fromPage == null )
        {
            throw new WikiException("No such page "+renameFrom);
        }
       
        WikiPage toPage = engine.getPage( renameToClean );
       
        if( toPage != null )
        {
            throw new WikiException( "Page already exists " + renameToClean );
        }
       
        //
        //  Options
        //
       
        m_camelCase = TextUtil.getBooleanProperty( engine.getWikiProperties(),
                                                   JSPWikiMarkupParser.PROP_CAMELCASELINKS,
                                                   m_camelCase );

        Set<String> referrers = getReferencesToChange( fromPage, engine );

        //
        //  Do the actual rename by changing from the frompage to the topage, including
        //  all of the attachments
        //
       
        //  Remove references to attachments under old name
        @SuppressWarnings( "unchecked" )
        Collection<Attachment> attachmentsOldName = engine.getAttachmentManager().listAttachments( fromPage );
        for (Attachment att:attachmentsOldName)
        {
            WikiPage fromAttPage = engine.getPage( att.getName() );
            engine.getReferenceManager().pageRemoved( fromAttPage );
        }

        engine.getPageManager().getProvider().movePage( renameFrom, renameToClean );

        if( engine.getAttachmentManager().attachmentsEnabled() )
        {
            engine.getAttachmentManager().getCurrentProvider().moveAttachmentsForPage( renameFrom, renameToClean );
        }
       
        //
        //  Add a comment to the page notifying what changed.  This adds a new revision
        //  to the repo with no actual change.
        //
       
        toPage = engine.getPage( renameToClean );
       
        if( toPage == null ) throw new InternalWikiException("Rename seems to have failed for some strange reason - please check logs!");

        toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
        toPage.setAuthor( context.getCurrentUser().getName() );
       
        engine.getPageManager().putPageText( toPage, engine.getPureText( toPage ) );

        //
        //  Update the references
        //
       
        engine.getReferenceManager().pageRemoved( fromPage );
        engine.updateReferences( toPage );

        //
        //  Update referrers
        //
        if( changeReferrers )
        {
            updateReferrers( context, fromPage, toPage, referrers );
        }

        //
        //  re-index the page including its attachments
        //
        engine.getSearchManager().reindexPage(toPage);
       
        @SuppressWarnings( "unchecked" )
        Collection<Attachment> attachmentsNewName = engine.getAttachmentManager().listAttachments( toPage );
        for (Attachment att:attachmentsNewName)
        {
            WikiPage toAttPage = engine.getPage( att.getName() );
            // add reference to attachment under new page name
            engine.updateReferences( toAttPage );
            engine.getSearchManager().reindexPage(att);
        }

        // Currently not used internally by JSPWiki itself, but you can use it for something else.
        WikiEventManager.fireEvent( this, new WikiPageRenameEvent( this, renameFrom, renameToClean ) );
View Full Code Here

     @param fromPage The old page
     *  @param toPage The new page
     */
    private void updateReferrers( WikiContext context, WikiPage fromPage, WikiPage toPage, Set<String>referrers )
    {
        WikiEngine engine = context.getEngine();
       
        if( referrers.isEmpty() ) return; // No referrers
       
        for( String pageName : referrers )
        {
            //  In case the page was just changed from under us, let's do this
            //  small kludge.
            if( pageName.equals( fromPage.getName() ) )
            {
                pageName = toPage.getName();
            }
           
            WikiPage p = engine.getPage( pageName );
           
            String sourceText = engine.getPureText( p );
           
            String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
           
            if( m_camelCase )
                newText = replaceCCReferrerString( context, newText, fromPage.getName(), toPage.getName() );
           
            if( !sourceText.equals( newText ) )
            {
                p.setAttribute( WikiPage.CHANGENOTE, fromPage.getName()+" ==> "+toPage.getName() );
                p.setAuthor( context.getCurrentUser().getName() );
        
                try
                {
                    engine.getPageManager().putPageText( p, newText );
                    engine.updateReferences( p );
                }
                catch( ProviderException e )
                {
                    //
                    //  We fail with an error, but we will try to continue to rename
View Full Code Here

    public final int doStartTag()
    {
        m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
                                                                PageContext.REQUEST_SCOPE );

        WikiEngine engine = m_wikiContext.getEngine();
        WikiPage   page;

        page = m_wikiContext.getPage();

        try
        {
            if( page != null && engine.pageExists(page) )
            {
                Collection versions = engine.getVersionHistory( page.getName() );

                if( versions == null )
                {
                    // There is no history
                    return SKIP_BODY;
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.