Package org.apache.wiki.attachment

Examples of org.apache.wiki.attachment.Attachment


        ReferenceManager refMgr = m_engine.getReferenceManager();
        AttachmentManager attMgr = m_engine.getAttachmentManager();
       
        m_engine.saveText( NAME1, "fooBar");

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

        try
        {   
            // and check post-conditions       
View Full Code Here


     {@inheritDoc}
     */
    public Attachment getAttachmentInfo( WikiPage page, String name, int version )
        throws ProviderException
    {
        Attachment att = new Attachment( m_engine, page.getName(), name );
        File dir = findAttachmentDir( att );

        if( !dir.exists() )
        {
            // log.debug("Attachment dir not found - thus no attachment can exist.");
            return null;
        }
       
        if( version == WikiProvider.LATEST_VERSION )
        {
            version = findLatestVersion(att);
        }

        att.setVersion( version );
       
        // Should attachment be cachable by the client (browser)?
        if (m_disableCache != null)
        {
            Matcher matcher = m_disableCache.matcher(name);
            if (matcher.matches())
            {
                att.setCacheable(false);
            }
        }
       

        // System.out.println("Fetching info on version "+version);
        try
        {
            Properties props = getPageProperties(att);

            att.setAuthor( props.getProperty( version+".author" ) );

            String changeNote = props.getProperty( version+".changenote" );
            if( changeNote != null )
            {
                att.setAttribute(WikiPage.CHANGENOTE, changeNote);
            }
           
            File f = findFile( dir, att );

            att.setSize( f.length() );
            att.setLastModified( new Date(f.lastModified()) );
        }
        catch( FileNotFoundException e )
        {
            log.error( "Can't get attachment properties for " + att, e );
            return null;
View Full Code Here

                    c.size()==1 &&
                    ((String)c.iterator().next()).equals( "TestAtt.txt" ) );
       
        // now we create the attachment
           
        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
        att.setAuthor( "FirstPost" );
        attMgr.storeAttachment( att, m_engine.makeAttachmentFile() );
        try
        {   
            // and check post-conditions       
            c = refMgr.findUncreated();
View Full Code Here

        ReferenceManager refMgr = m_engine.getReferenceManager();
        AttachmentManager attMgr = m_engine.getAttachmentManager();
       
        m_engine.saveText( NAME1, "fooBar");

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

        m_engine.saveText( NAME1, " ["+NAME1+"/TestAtt.txt] ");

        try
View Full Code Here

        ReferenceManager refMgr = m_engine.getReferenceManager();
        AttachmentManager attMgr = m_engine.getAttachmentManager();
       
        m_engine.saveText( NAME1, "[TestPage2]");

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

        m_engine.saveText( "TestPage2", "["+NAME1+"/TestAtt.txt]");

        try
View Full Code Here

        {
            int latest = findLatestVersion( att );

            for( int i = latest; i >= 1; i-- )
            {
                Attachment a = getAttachmentInfo( new WikiPage( m_engine, att.getParentName() ),
                                                  att.getFileName(), i );

                if( a != null )
                {
                    list.add( a );
View Full Code Here

    public void testDeletePageAndAttachments()
        throws Exception
    {
        m_engine.saveText( NAME1, "Test" );

        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
       
        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
        File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
View Full Code Here

    public void testDeletePageAndAttachments2()
        throws Exception
    {
        m_engine.saveText( NAME1, "Test" );

        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
        att.setAuthor( "FirstPost" );
        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
       
        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
        File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );

        String atts = props.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
        File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
       
        assertTrue( "Didn't create it!", saved.exists() );

        assertTrue( "Attachment dir does not exist", attfile.exists() );
       
        WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );

        assertNotNull( "page", page );

        att = m_engine.getAttachmentManager().getAttachmentInfo(NAME1+"/TestAtt.txt");
       
        m_engine.deletePage(att.getName());
       
        m_engine.deletePage( NAME1 );
       
        assertNull( "Page not removed", m_engine.getPage(NAME1) );
        assertNull( "Att not removed", m_engine.getPage(NAME1+"/TestAtt.txt") );
View Full Code Here

     * @param data
     */
    public void addAttachment( String pageName, String attachmentName, byte[] data )
        throws ProviderException, IOException
    {
        Attachment att = new Attachment(this,pageName,attachmentName);

        getAttachmentManager().storeAttachment(att, new ByteArrayInputStream(data));
    }
View Full Code Here

    public void testPutAttachmentUTF8()
        throws Exception
    {
        File in = makeAttachmentFile();

        Attachment att = new Attachment( m_engine, NAME1, "\u3072\u3048\u308b\u00e5\u00e4\u00f6test.f\u00fc\u00fc" );

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

        List res = m_provider.listAllChanged( new Date(0L) );

        Attachment a0 = (Attachment) res.get(0);
       
        assertEquals( "name", att.getName(), a0.getName() );
    }
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.