|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.confluence.upgrade.AbstractUpgradeTask com.atlassian.confluence.upgrade.upgradetask.AttachmentFileNameUpgradeTask
public class AttachmentFileNameUpgradeTask
Upgrade confluence file system based attachment storage to use new ID naming strategy for attachments [CONF-2948]
Field Summary | |
---|---|
String[] |
mangledEncodings
|
static int |
UPDATE_BUILD_NUMBER
|
Constructor Summary | |
---|---|
AttachmentFileNameUpgradeTask()
|
Method Summary | |
---|---|
void |
doUpgrade()
Upgrade the attachment files to use the new naming strategy |
String |
getBuildNumber()
|
String[] |
getMangledEncodings()
|
String |
getShortDescription()
A short (<50 chars) description of the upgrade action |
boolean |
isSearchForMissingAttachmentFiles()
|
protected void |
logMissingAttachments(Collection missingAttachments)
Report any attachments that were not upgraded successfully |
protected void |
processAttachments(Iterator attachmentIterator,
Collection missingAttachments)
Update attachment names on disk |
protected void |
processMissingAttachments(Collection missingAttachments)
Try and fix any attachment files that were not found |
protected void |
processStagedUpdates()
Process all of the staged updates |
void |
setAttachmentDao(AttachmentDao attachmentDao)
|
void |
setBootstrap(BootstrapManager bootstrap)
|
void |
setMangledEncodings(String[] mangledEncodings)
Set the list of character encodings to use when looking for missing attachment files on disk |
void |
setSearchForMissingAttachmentFiles(boolean searchForMissingAttachmentFiles)
Sets whether to try and find missing attachment files during upgrade (true by default) |
void |
setSettingsManager(SettingsManager settingsManager)
|
protected void |
stageUpdatedAttachment(File originalAttachment,
File updatedFile)
Stage an update for later processing - used for name collision resolution |
protected boolean |
tryToFixFile(File attachmentDir,
Attachment attachment,
String nativeEncoding)
Try and locate and update a file which may have a badly encoded file name This method will run through all the configured mangled encodings |
protected boolean |
tryToFixFile(File attachmentDir,
Attachment attachment,
String nativeEncoding,
String fileSystemEncoding)
Try to fix an attachment file by looking for a file name encoded with the specified encoding |
protected boolean |
updateAttachmentFile(Attachment attachment,
File attachmentFile)
Map an attachment to the new ID based naming scheme |
void |
validate()
This is only implemented in this abstract base class for the convenience of the large number of older upgrade tasks. |
Methods inherited from class com.atlassian.confluence.upgrade.AbstractUpgradeTask |
---|
addAllErrors, addError, addError, getConstraint, getErrors, setBuildNumber |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int UPDATE_BUILD_NUMBER
public String[] mangledEncodings
Constructor Detail |
---|
public AttachmentFileNameUpgradeTask()
Method Detail |
---|
public boolean isSearchForMissingAttachmentFiles()
public void setSearchForMissingAttachmentFiles(boolean searchForMissingAttachmentFiles)
searchForMissingAttachmentFiles
- public void setBootstrap(BootstrapManager bootstrap)
public String[] getMangledEncodings()
public void setMangledEncodings(String[] mangledEncodings)
mangledEncodings
- An array of character encoding strings as used by String.getBytes()public String getBuildNumber()
getBuildNumber
in interface UpgradeTask
getBuildNumber
in class AbstractUpgradeTask
public String getShortDescription()
UpgradeTask
getShortDescription
in interface UpgradeTask
getShortDescription
in class AbstractUpgradeTask
public void validate()
AbstractUpgradeTask
This is only implemented in this abstract base class for the convenience of the large number of older upgrade tasks.
If you are implementing a new UpgradeTask you must give some consideration to implementing validation as well.
validate
in interface UpgradeTask
validate
in class AbstractUpgradeTask
public void doUpgrade() throws Exception
Exception
protected void processAttachments(Iterator attachmentIterator, Collection missingAttachments)
attachmentIterator
- An Iterator over attachments to processmissingAttachments
- A collection to hold any attachment objects which could not be matched to a file on diskprotected void processMissingAttachments(Collection missingAttachments)
missingAttachments
- protected void logMissingAttachments(Collection missingAttachments)
missingAttachments
- Collection of missed attachmentsprotected boolean updateAttachmentFile(Attachment attachment, File attachmentFile)
attachment
- The attachment to processattachmentFile
- The expected location of the attachment
protected void stageUpdatedAttachment(File originalAttachment, File updatedFile)
originalAttachment
- The original attachment fileupdatedFile
- The file we want to rename it toprotected void processStagedUpdates()
protected boolean tryToFixFile(File attachmentDir, Attachment attachment, String nativeEncoding)
attachmentDir
- Root attachment directoryattachment
- Attachment to fixnativeEncoding
- Encoding to use to decode the Attachment object's getFileName()
protected boolean tryToFixFile(File attachmentDir, Attachment attachment, String nativeEncoding, String fileSystemEncoding) throws UnsupportedEncodingException
attachmentDir
- attachment
- nativeEncoding
- fileSystemEncoding
- Encoding to use when looking on disk
UnsupportedEncodingException
- When fileSystemEncoding is not recognisedpublic void setAttachmentDao(AttachmentDao attachmentDao)
public void setSettingsManager(SettingsManager settingsManager)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |