Package org.apache.wiki.attachment

Examples of org.apache.wiki.attachment.Attachment


        File sDir = new File(m_engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR ));
        File attDir = new File( sDir, NAME1+"-att" );


        Attachment att = new Attachment( m_engine, NAME1, "test1.txt" );

        m_provider.putAttachmentData( att, new FileInputStream(in) );
       
        File extrafile = makeExtraFile( attDir, "ping.pong" );
       
        try
        {
            Thread.sleep( 2000L ); // So that we get a bit of granularity.

            Attachment att2 = new Attachment( m_engine, NAME2, "test2.txt" );

            m_provider.putAttachmentData( att2, new FileInputStream(in) );
       
            List res = m_provider.listAllChanged( new Date(0L) );

            assertEquals( "list size", 2, res.size() );

            Attachment a2 = (Attachment) res.get(0)// Most recently changed
            Attachment a1 = (Attachment) res.get(1)// Least recently changed

            assertEquals( "a1 name", att.getName(), a1.getName() );
            assertEquals( "a2 name", att2.getName(), a2.getName() );
        }
        finally
        {
            extrafile.delete();
View Full Code Here


        File in = makeAttachmentFile();

        File sDir = new File(m_engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR ));
        File attDir = new File( sDir, NAME1+"-att" );

        Attachment att = new Attachment( m_engine, NAME1, "test1.txt" );

        m_provider.putAttachmentData( att, new FileInputStream(in) );
       
        // This is our extraneous directory.
        File extrafile = new File( attDir, "ping.pong" );
        extrafile.mkdir();
       
        try
        {
            Thread.sleep( 2000L ); // So that we get a bit of granularity.

            Attachment att2 = new Attachment( m_engine, NAME2, "test2.txt" );

            m_provider.putAttachmentData( att2, new FileInputStream(in) );
       
            List res = m_provider.listAllChanged( new Date(0L) );

            assertEquals( "list size", 2, res.size() );

            Attachment a2 = (Attachment) res.get(0)// Most recently changed
            Attachment a1 = (Attachment) res.get(1)// Least recently changed

            assertEquals( "a1 name", att.getName(), a1.getName() );
            assertEquals( "a2 name", att2.getName(), a2.getName() );
        }
        finally
        {
            extrafile.delete();
View Full Code Here

    public void testListAllNoExtension()
        throws Exception
    {
        File in = makeAttachmentFile();
       
        Attachment att = new Attachment( m_engine, NAME1, "test1." );

        m_provider.putAttachmentData( att, new FileInputStream(in) );

        Thread.sleep( 2000L ); // So that we get a bit of granularity.

        Attachment att2 = new Attachment( m_engine, NAME2, "test2." );

        m_provider.putAttachmentData( att2, new FileInputStream(in) );
       
        List res = m_provider.listAllChanged( new Date(0L) );

        assertEquals( "list size", 2, res.size() );

        Attachment a2 = (Attachment) res.get(0)// Most recently changed
        Attachment a1 = (Attachment) res.get(1)// Least recently changed

        assertEquals( "a1 name", att.getName(), a1.getName() );
        assertEquals( "a2 name", att2.getName(), a2.getName() );       
    }
View Full Code Here

        // Create test page & attachment
        String src = "[{ALLOW edit Alice}] ";
        m_engine.saveText( "Test", src );

        File f = m_engine.makeAttachmentFile();
        Attachment att = new Attachment( m_engine, "Test", "test1.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, f );

        Attachment p = (Attachment) m_engine.getPage( "Test/test1.txt" );
        Permission view = PermissionFactory.getPagePermission( p, "view" );
        Permission edit = PermissionFactory.getPagePermission( p, "edit" );

        // Create authenticated session with user 'Alice', who can read & edit (in ACL)
        WikiSession session;
View Full Code Here

        // Create test page & attachment
        String src = "[{ALLOW view Alice}] ";
        m_engine.saveText( "Test", src );

        File f = m_engine.makeAttachmentFile();
        Attachment att = new Attachment( m_engine, "Test", "test1.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, f );

        Attachment p = (Attachment) m_engine.getPage( "Test/test1.txt" );
        Permission view = PermissionFactory.getPagePermission( p, "view" );
        Permission edit = PermissionFactory.getPagePermission( p, "edit" );

        // Create session with user 'Alice', who can read (in ACL)
        WikiSession session;
View Full Code Here

    {
        Date time = getCalendarTime( Calendar.getInstance().getTime() );
        Vector previousChanges = m_handler.getRecentChanges( time );

        m_engine.saveText( NAME1, "Foo" );
        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
        WikiPage directInfo = m_engine.getPage( NAME1 );
        time = getCalendarTime( directInfo.getLastModified() );
        Vector recentChanges = m_handler.getRecentChanges( time );
View Full Code Here

        String text = "[Foobar] [Test/TestAtt.txt]";
        String pageName = NAME1;

        m_engine.saveText( pageName, text );

        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );

        // Test.

        Vector links = m_handler.listLinks( pageName );
View Full Code Here

        assertEquals( "no rename",
                      "[FooTest/foo.txt] [linktext|FooTest/bar.jpg]",
                      data.trim() );

        Attachment att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/foo.txt");
        assertNotNull("footext",att);
       
        att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/bar.jpg");
        assertNotNull("barjpg",att);
       
View Full Code Here

        }

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

            if( att != null )
            {
                src = context.getURL( WikiContext.ATTACH, att.getName() );
            }
        }
        catch( ProviderException e )
        {
            throw new PluginException( "Attachment info failed: "+e.getMessage() );
View Full Code Here

    private void refreshBlacklists( WikiContext context )
    {
        try
        {
            WikiPage source = context.getEngine().getPage( m_forbiddenWordsPage );
            Attachment att = context.getEngine().getAttachmentManager().getAttachmentInfo( context, m_blacklist );

            boolean rebuild = false;

            //
            //  Rebuild, if the page or the attachment has changed since.
            //
            if( source != null )
            {
                if( m_spamPatterns == null || m_spamPatterns.isEmpty() || source.getLastModified().after(m_lastRebuild) )
                {
                    rebuild = true;
                }
            }

            if( att != null )
            {
                if( m_spamPatterns == null || m_spamPatterns.isEmpty() || att.getLastModified().after(m_lastRebuild) )
                {
                    rebuild = true;
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.wiki.attachment.Attachment

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.