Package org.apache.wiki.providers

# Class BasicAttachmentProvider

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

All Implemented Interfaces:
  `AttachmentProvider`, `WikiProvider`

public class BasicAttachmentProvider extends 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
Modifier and Type
Class
Description
`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
Modifier and Type
Field
Description
`static final String`
`ATTDIR_EXTENSION`
The default extension for the attachment directory.
`static final String`
`DIR_EXTENSION`
The default extension for the page attachment directory name.
`static final String`
`PROP_DISABLECACHE`
The property name for specifying which attachments are not cached.
`static final 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
Constructor
Description
`BasicAttachmentProvider()`

## Method Summary

Modifier and Type
Method
Description
`void`
`deleteAttachment(Attachment att)`
`void`
`deleteVersion(Attachment att)`
`Collection<Attachment>`
`findAttachments(QueryItem[] query)`
`InputStream`
`getAttachmentData(Attachment att)`
`Attachment`
`getAttachmentInfo(Page page, String name, int version)`
`protected static String`
`getFileExtension(String filename)`
Returns the file extension.
`String`
`getProviderInfo()`
`List<Attachment>`
`getVersionHistory(Attachment att)`
`void`
`initialize(Engine engine, Properties properties)`
`List<Attachment>`
`listAllChanged(Date timestamp)`
`List<Attachment>`
`listAttachments(Page page)`
`void`
`moveAttachmentsForPage(String oldParent, String newParent)`
`void`
`putAttachmentData(Attachment att, InputStream data)`

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

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

## Field Details

### PROP_DISABLECACHE

public static final 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 String PROPERTY_FILE
The name of the property file.

See Also:
  - Constant Field Values

### DIR_EXTENSION

public static final String DIR_EXTENSION
The default extension for the page attachment directory name.

See Also:
  - Constant Field Values

### ATTDIR_EXTENSION

public static final String ATTDIR_EXTENSION
The default extension for the attachment directory.

See Also:
  - Constant Field Values

## Constructor Details

### BasicAttachmentProvider

public BasicAttachmentProvider()

## Method Details

### initialize

public void initialize(Engine engine, Properties properties) throws NoRequiredPropertyException, IOException

Specified by:
  `initialize` in interface `WikiProvider`
Throws:
  `NoRequiredPropertyException`
  `IOException`

### getFileExtension

protected static String getFileExtension(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, InputStream data) throws ProviderException, IOException

Specified by:
  `putAttachmentData` in interface `AttachmentProvider`
Throws:
  `ProviderException`
  `IOException`

### getProviderInfo

public String getProviderInfo()

Specified by:
  `getProviderInfo` in interface `WikiProvider`

### getAttachmentData

public InputStream getAttachmentData(Attachment att) throws IOException, ProviderException

Specified by:
  `getAttachmentData` in interface `AttachmentProvider`
Throws:
  `IOException`
  `ProviderException`

### listAttachments

public List<Attachment> listAttachments(Page page) throws ProviderException

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

### findAttachments

public Collection<Attachment> findAttachments(QueryItem[] query)

Specified by:
  `findAttachments` in interface `AttachmentProvider`

### listAllChanged

public List<Attachment> listAllChanged(Date timestamp) throws ProviderException

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

### getAttachmentInfo

public Attachment getAttachmentInfo(Page page, String name, int version) throws ProviderException

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

### getVersionHistory

public 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(String oldParent, String newParent) throws ProviderException

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