Package org.apache.wiki.attachment

Examples of org.apache.wiki.attachment.AttachmentManager


        return m_currentElement;
    }

    private String findAttachment( String linktext )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();
        Attachment att = null;

        try
        {
            att = mgr.getAttachmentInfo( m_context, linktext );
        }
        catch( ProviderException e )
        {
            log.warn("Finding attachments failed: ",e);
            return null;
View Full Code Here


            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

            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

        return m_currentElement;
    }

    private String findAttachment( String linktext )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();
        Attachment att = null;

        try
        {
            att = mgr.getAttachmentInfo( m_context, linktext );
        }
        catch( ProviderException e )
        {
            log.warn("Finding attachments failed: ",e);
            return null;
View Full Code Here

    
     *  @return the content of the Attachment as a String.
     */
    protected String getAttachmentContent( String attachmentName, int version )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();

        try
        {
            Attachment att = mgr.getAttachmentInfo( attachmentName, version );
            //FIXME: Find out why sometimes att is null
            if(att != null)
            {
                return getAttachmentContent( att );
            }
View Full Code Here

     * FIXME This is a very simple implementation of some text-based attachment, mainly used for testing.
     * This should be replaced /moved to Attachment search providers or some other 'pluggable' wat to search attachments
     */
    protected String getAttachmentContent( Attachment att )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();
        //FIXME: Add attachment plugin structure

        String filename = att.getFileName();

        boolean searchSuffix = false;
        for( String suffix : SEARCHABLE_FILE_SUFFIXES )
        {
            if( filename.endsWith( suffix ) )
            {
                searchSuffix = true;
            }
        }

        if( searchSuffix )
        {
            InputStream attStream;

            try
            {
                attStream = mgr.getAttachmentStream( att );

                StringWriter sout = new StringWriter();
                FileUtil.copyContents( new InputStreamReader(attStream), sout );

                attStream.close();
View Full Code Here

    
     *  @return the content of the Attachment as a String.
     */
    protected String getAttachmentContent( String attachmentName, int version )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();

        try
        {
            Attachment att = mgr.getAttachmentInfo( attachmentName, version );
            //FIXME: Find out why sometimes att is null
            if(att != null)
            {
                return getAttachmentContent( att );
            }
View Full Code Here

     * FIXME This is a very simple implementation of some text-based attachment, mainly used for testing.
     * This should be replaced /moved to Attachment search providers or some other 'pluggable' wat to search attachments
     */
    protected String getAttachmentContent( Attachment att )
    {
        AttachmentManager mgr = m_engine.getAttachmentManager();
        //FIXME: Add attachment plugin structure

        String filename = att.getFileName();

        boolean searchSuffix = false;
        for( String suffix : SEARCHABLE_FILE_SUFFIXES )
        {
            if( filename.endsWith( suffix ) )
            {
                searchSuffix = true;
            }
        }

        String out = null;
        if( searchSuffix )
        {
            InputStream attStream = null;
            StringWriter sout = new StringWriter();
           
            try
            {
                attStream = mgr.getAttachmentStream( att );
                FileUtil.copyContents( new InputStreamReader(attStream), sout );
                out = sout.toString();
            }
            catch (ProviderException e)
            {
View Full Code Here

     */
    public void testAttachmentRefs()
        throws Exception
    {
        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       
            Collection c = refMgr.findUncreated();
View Full Code Here

    public void testAttachmentRefs2()
        throws Exception
    {
        ReferenceManager refMgr = m_engine.getReferenceManager();
        AttachmentManager attMgr = m_engine.getAttachmentManager();
       
        m_engine.saveText( NAME1, "[TestAtt.txt]");

        // check a few pre-conditions
       
        Collection c = refMgr.findReferrers( "TestAtt.txt" );
        assertTrue( "normal, unexisting page",
                    c!=null && ((String)c.iterator().next()).equals( NAME1 ) );
       
        c = refMgr.findReferrers( NAME1+"/TestAtt.txt" );
        assertTrue( "no attachment", c==null || c.size()==0 );
       
        c = refMgr.findUncreated();
        assertTrue( "unknown attachment",
                    c!=null &&
                    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();
            assertTrue( "attachment exists: ",           
View Full Code Here

TOP

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

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.