Package com.sudicode.fb2gh.migrate
Class GHAttachmentUploader
- java.lang.Object
-
- com.sudicode.fb2gh.migrate.GHAttachmentUploader
-
- All Implemented Interfaces:
FBAttachmentConverter,Closeable,AutoCloseable
public class GHAttachmentUploader extends Object implements FBAttachmentConverter, Closeable
Uploads FogBugz attachments to GitHub Issues. Since the GitHub API does not currently support this, Selenium WebDriver is used instead. This implementation is therefore unstable and should be handled as such. But if it works for you, the more power to you.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGHAttachmentUploader.BrowserWeb browser.
-
Constructor Summary
Constructors Constructor Description GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser)Constructor.GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, int timeoutInSeconds)Constructor.GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, int timeoutInSeconds, FBAttachmentConverter fallback)Constructor.GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, FBAttachmentConverter fallback)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Quit the WebDriver.Stringconvert(FogBugz fogBugz, FBAttachment fbAttachment)Download the FogBugz attachment, then reupload it to GitHub Issues.Stringupload(File file)Upload a file to GitHub Issues, zipping if necessary.
-
-
-
Constructor Detail
-
GHAttachmentUploader
public GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser)
Constructor.- Parameters:
ghUsername- GitHub usernameghPassword- GitHub passwordghRepo- GitHub repository to upload tobrowser- TheGHAttachmentUploader.Browserto use
-
GHAttachmentUploader
public GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, int timeoutInSeconds)
Constructor.- Parameters:
ghUsername- GitHub usernameghPassword- GitHub passwordghRepo- GitHub repository to upload tobrowser- TheGHAttachmentUploader.Browserto usetimeoutInSeconds- The timeout used for blocking operations (downloading, uploading, etc.)
-
GHAttachmentUploader
public GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, FBAttachmentConverter fallback)
Constructor.- Parameters:
ghUsername- GitHub usernameghPassword- GitHub passwordghRepo- GitHub repository to upload tobrowser- TheGHAttachmentUploader.Browserto usefallback- TheFBAttachmentConverterto use if uploading to GitHub fails.
-
GHAttachmentUploader
public GHAttachmentUploader(String ghUsername, String ghPassword, GHRepo ghRepo, GHAttachmentUploader.Browser browser, int timeoutInSeconds, FBAttachmentConverter fallback)
Constructor.- Parameters:
ghUsername- GitHub usernameghPassword- GitHub passwordghRepo- GitHub repository to upload tobrowser- TheGHAttachmentUploader.Browserto usetimeoutInSeconds- The timeout used for blocking operations (downloading, uploading, etc.)fallback- TheFBAttachmentConverterto use if uploading to GitHub fails.
-
-
Method Detail
-
convert
public String convert(FogBugz fogBugz, FBAttachment fbAttachment)
Download the FogBugz attachment, then reupload it to GitHub Issues. If the file type is incompatible with GitHub Issues, zip it beforehand. Since ZIP files are supported by GitHub Issues, this guarantees that any attachment (within size constraints) will be accepted.- Specified by:
convertin interfaceFBAttachmentConverter- Parameters:
fogBugz- TheFogBugzinstance that owns theFBAttachmentfbAttachment- TheFBAttachment- Returns:
- URL of the uploaded file
-
upload
public String upload(File file) throws IOException
Upload a file to GitHub Issues, zipping if necessary.- Parameters:
file- The file to upload- Returns:
- URL of the uploaded file
- Throws:
IOException- if an I/O error occurs
-
close
public void close()
Quit the WebDriver.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-