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 class
GHAttachmentUploader.Browser
Web 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 void
close()
Quit the WebDriver.String
convert(FogBugz fogBugz, FBAttachment fbAttachment)
Download the FogBugz attachment, then reupload it to GitHub Issues.String
upload(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.Browser
to 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.Browser
to 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.Browser
to usefallback
- TheFBAttachmentConverter
to 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.Browser
to usetimeoutInSeconds
- The timeout used for blocking operations (downloading, uploading, etc.)fallback
- TheFBAttachmentConverter
to 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:
convert
in interfaceFBAttachmentConverter
- Parameters:
fogBugz
- TheFogBugz
instance that owns theFBAttachment
fbAttachment
- 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
-