Package org.apache.wiki.providers

## Class BasicAttachmentProvider

- java.lang.Object
- - org.apache.wiki.providers.BasicAttachmentProvider

All Implemented Interfaces:
  `AttachmentProvider`, `WikiProvider`

    public class BasicAttachmentProvider
    extends java.lang.Object
    implements AttachmentProvider

Provides basic, versioning attachments.

       Structure is as follows:
          attachment_dir/
             ThisPage/
                attachment.doc/
                   attachment.properties
                   1.doc
                   2.doc
                   3.doc
                picture.png/
                   attachment.properties
                   1.png
                   2.png
             ThatPage/
                picture.png/
                   attachment.properties
                   1.png

The names of the directories will be URLencoded.

"attachment.properties" consists of the following items:

- 1.author = author name for version 1 (etc)

### Nested Class Summary

Nested Classes
`static class` `BasicAttachmentProvider.AttachmentFilter` Returns only those directories that contain attachments.
`static class` `BasicAttachmentProvider.AttachmentVersionFilter` Accepts only files that are actual versions, no control files.

### Field Summary

Fields
`static java.lang.String` `ATTDIR_EXTENSION` The default extension for the attachment directory.
`static java.lang.String` `DIR_EXTENSION` The default extension for the page attachment directory name.
`static java.lang.String` `PROP_DISABLECACHE` The property name for specifying which attachments are not cached.
`static java.lang.String` `PROPERTY_FILE` The name of the property file.

### Fields inherited from interface org.apache.wiki.api.providers.AttachmentProvider

`PROP_STORAGEDIR`

### Fields inherited from interface org.apache.wiki.api.providers.WikiProvider

`LATEST_VERSION`

### Constructor Summary

Constructors
`BasicAttachmentProvider()`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `deleteAttachment​(Attachment att)`
`void` `deleteVersion​(Attachment att)`
`java.util.Collection<Attachment>` `findAttachments​(QueryItem[] query)`
`java.io.InputStream` `getAttachmentData​(Attachment att)`
`Attachment` `getAttachmentInfo​(Page page, java.lang.String name, int version)`
`protected static java.lang.String` `getFileExtension​(java.lang.String filename)` Returns the file extension.
`java.lang.String` `getProviderInfo()`
`java.util.List<Attachment>` `getVersionHistory​(Attachment att)`
`void` `initialize​(Engine engine, java.util.Properties properties)`
`java.util.List<Attachment>` `listAllChanged​(java.util.Date timestamp)`
`java.util.List<Attachment>` `listAttachments​(Page page)`
`void` `moveAttachmentsForPage​(java.lang.String oldParent, java.lang.String newParent)`
`void` `putAttachmentData​(Attachment att, java.io.InputStream data)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### PROP_DISABLECACHE

    public static final java.lang.String PROP_DISABLECACHE

The property name for specifying which attachments are not cached. Value is `"jspwiki.basicAttachmentProvider.disableCache"`.

See Also:
  Constant Field Values

#### PROPERTY_FILE

    public static final java.lang.String PROPERTY_FILE

The name of the property file.

See Also:
  Constant Field Values

#### DIR_EXTENSION

    public static final java.lang.String DIR_EXTENSION

The default extension for the page attachment directory name.

See Also:
  Constant Field Values

#### ATTDIR_EXTENSION

    public static final java.lang.String ATTDIR_EXTENSION

The default extension for the attachment directory.

See Also:
  Constant Field Values

### Constructor Detail

#### BasicAttachmentProvider

    public BasicAttachmentProvider()

### Method Detail

#### initialize

    public void initialize​(Engine engine,
                           java.util.Properties properties)
                    throws NoRequiredPropertyException,
                           java.io.IOException

Specified by:
  `initialize` in interface `WikiProvider`
Throws:
  `NoRequiredPropertyException`
  `java.io.IOException`

#### getFileExtension

    protected static java.lang.String getFileExtension​(java.lang.String filename)

Returns the file extension. For example "test.png" returns "png".

If file has no extension, will return "bin"

Parameters:
  `filename` - The file name to check
Returns:
  The extension. If no extension is found, returns "bin".

#### putAttachmentData

    public void putAttachmentData​(Attachment att,
                                  java.io.InputStream data)
                           throws ProviderException,
                                  java.io.IOException

Specified by:
  `putAttachmentData` in interface `AttachmentProvider`
Throws:
  `ProviderException`
  `java.io.IOException`

#### getProviderInfo

    public java.lang.String getProviderInfo()

Specified by:
  `getProviderInfo` in interface `WikiProvider`

#### getAttachmentData

    public java.io.InputStream getAttachmentData​(Attachment att)
                                          throws java.io.IOException,
                                                 ProviderException

Specified by:
  `getAttachmentData` in interface `AttachmentProvider`
Throws:
  `java.io.IOException`
  `ProviderException`

#### listAttachments

    public java.util.List<Attachment> listAttachments​(Page page)
                                               throws ProviderException

Specified by:
  `listAttachments` in interface `AttachmentProvider`
Throws:
  `ProviderException`

#### findAttachments

    public java.util.Collection<Attachment> findAttachments​(QueryItem[] query)

Specified by:
  `findAttachments` in interface `AttachmentProvider`

#### listAllChanged

    public java.util.List<Attachment> listAllChanged​(java.util.Date timestamp)
                                              throws ProviderException

Specified by:
  `listAllChanged` in interface `AttachmentProvider`
Throws:
  `ProviderException`

#### getAttachmentInfo

    public Attachment getAttachmentInfo​(Page page,
                                        java.lang.String name,
                                        int version)
                                 throws ProviderException

Specified by:
  `getAttachmentInfo` in interface `AttachmentProvider`
Throws:
  `ProviderException`

#### getVersionHistory

    public java.util.List<Attachment> getVersionHistory​(Attachment att)

Specified by:
  `getVersionHistory` in interface `AttachmentProvider`

#### deleteVersion

    public void deleteVersion​(Attachment att)
                       throws ProviderException

Specified by:
  `deleteVersion` in interface `AttachmentProvider`
Throws:
  `ProviderException`

#### deleteAttachment

    public void deleteAttachment​(Attachment att)
                          throws ProviderException

Specified by:
  `deleteAttachment` in interface `AttachmentProvider`
Throws:
  `ProviderException`

#### moveAttachmentsForPage

    public void moveAttachmentsForPage​(java.lang.String oldParent,
                                       java.lang.String newParent)
                                throws ProviderException

Specified by:
  `moveAttachmentsForPage` in interface `AttachmentProvider`
Throws:
  `ProviderException`