-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
48 changed files
with
3,214 additions
and
403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
com.enterprisedt | ||
com.enterprisedt.net.ftp | ||
com.enterprisedt.net.ftp.internal | ||
com.enterprisedt.net.ftp.test | ||
com.enterprisedt.util | ||
com.enterprisedt.util.debug.util | ||
com.enterprisedt.util.proxy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
build.xml.data.CRC32=de15d164 | ||
build.xml.script.CRC32=01d62e7e | ||
build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45 | ||
build.xml.data.CRC32=323c66b9 | ||
build.xml.script.CRC32=c9ee64b8 | ||
build.xml.stylesheet.CRC32=28e38971@1.43.1.45 | ||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. | ||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. | ||
nbproject/build-impl.xml.data.CRC32=de15d164 | ||
nbproject/build-impl.xml.script.CRC32=ff99b49a | ||
nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45 | ||
nbproject/build-impl.xml.data.CRC32=323c66b9 | ||
nbproject/build-impl.xml.script.CRC32=8ea475b6 | ||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45 |
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,156 +1,58 @@ | ||
package com.chrissyx.jfix; | ||
|
||
import com.chrissyx.jfix.common.error.JFixError; | ||
import com.chrissyx.jfix.modules.GuiController; | ||
|
||
import com.enterprisedt.net.ftp.FTPException; | ||
import com.enterprisedt.net.ftp.FileTransferClient; | ||
import javax.swing.SwingUtilities; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
import java.util.LinkedList; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* <b>J</b>ava <b>F</b>TP F<b>i</b>letime Fi<b>x</b> manages FTP access and | ||
* fixes filetimes not possible to set with MDTM or MFMT with SITE UTIME. | ||
* Uses edtFTPj/Free as FTP client. | ||
* Main class and application entry point of JFix. | ||
* | ||
* <b>J</b>ava <b>F</b>TP F<b>i</b>letime Fi<b>x</b> manages FTP access and fixes timestamps of remote files. | ||
* Filetimes are set with FTP commands defined by the bundled plug-ins, e.g. SITE UTIME instead of unsupported MDTM or MFMT server commands. | ||
* | ||
* @author Chrissyx | ||
* @see <a href="http://www.enterprisedt.com/products/edtftpj/overview.html" target="_blank">edtFTPj/Free Homepage</a> | ||
* @version 1.0 | ||
*/ | ||
public class JFix | ||
{ | ||
/** | ||
* The FTP client being worked with. | ||
*/ | ||
private FileTransferClient ftpClient; | ||
|
||
/** | ||
* Date formatter to prepare the filetimes. | ||
*/ | ||
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); | ||
|
||
/** | ||
* Initializes the FTP client module. | ||
* | ||
* @param host Host address to conenct to | ||
* @param user User name for authentication | ||
* @param pass Password of user | ||
* @throws JFixError If setting up FTP client failed | ||
*/ | ||
public JFix(final String host, final String user, final String pass) throws | ||
JFixError | ||
{ | ||
this.ftpClient = new FileTransferClient(); | ||
try | ||
{ | ||
this.ftpClient.setRemoteHost(host); | ||
this.ftpClient.setUserName(user); | ||
this.ftpClient.setPassword(pass); | ||
} | ||
catch(final FTPException e) | ||
{ | ||
throw new JFixError("Can't setup FTP client!", e); | ||
} | ||
JFixMain.getLogger().info("JFix initialized!"); | ||
} | ||
|
||
/** | ||
* Connects to FTP host. | ||
* | ||
* @throws JFixError If connecting failed | ||
* Current version number of JFix. | ||
*/ | ||
public void connect() throws JFixError | ||
{ | ||
try | ||
{ | ||
this.ftpClient.connect(); | ||
} | ||
catch(final FTPException e) | ||
{ | ||
throw new JFixError("Can't connect to FTP host!", e); | ||
} | ||
catch(final IOException e) | ||
{ | ||
throw new JFixError(e); | ||
} | ||
JFixMain.getLogger().info( | ||
"Connected to " + this.ftpClient.getRemoteHost() + "!"); | ||
} | ||
public static final String VERSION = "1.0"; | ||
|
||
/** | ||
* Disconnects from FTP host. | ||
* | ||
* @throws JFixError If disconnecting failed | ||
* Hidden constructor to prevent instances of this class. | ||
*/ | ||
public void disconnect() throws JFixError | ||
private JFix() | ||
{ | ||
try | ||
{ | ||
this.ftpClient.disconnect(); | ||
} | ||
catch(final FTPException e) | ||
{ | ||
throw new JFixError("Can't disconnect from FTP host!", e); | ||
} | ||
catch(final IOException e) | ||
{ | ||
throw new JFixError(e); | ||
} | ||
JFixMain.getLogger().info("Disconnected from " + this.ftpClient. | ||
getRemoteHost() + "!"); | ||
} | ||
|
||
/** | ||
* Fixes the filestimes of current local files with the ones from the host. | ||
* Starts application with GUI by calling {@link GuiController}. | ||
* | ||
* @param localDir Locale directory to gather the files' timestamp | ||
* @param remoteDir Optional remote directory to change to first | ||
* @throws JFixError If executing FTP command failed | ||
* @param args Unused arguments | ||
*/ | ||
public void fixFiletimes(final String localDir, final String remoteDir) | ||
throws JFixError | ||
public static void main(final String[] args) | ||
{ | ||
if(remoteDir != null) | ||
try | ||
{ | ||
this.ftpClient.changeDirectory(remoteDir); | ||
} | ||
catch(final FTPException e) | ||
{ | ||
throw new JFixError( | ||
"Can't change remote directory to '" + remoteDir + "'!", e); | ||
} | ||
catch(final IOException e) | ||
{ | ||
throw new JFixError(e); | ||
} | ||
final LinkedList<String> commands = new LinkedList<String>(); | ||
//Create command list | ||
for(final File curFile : new File(localDir).listFiles()) | ||
{ | ||
final String curTime = this.sdf.format(new Date( | ||
curFile.lastModified())); | ||
commands.add("SITE UTIME " + curFile.getName() + " " + curTime + " " | ||
+ curTime + " " + curTime + " UTC"); | ||
} | ||
//Execute commands | ||
for(final String curCommand : commands) | ||
try | ||
{ | ||
JFixMain.getLogger().info("Executing '" + curCommand + "'...\n" | ||
+ this.ftpClient.executeCommand(curCommand)); | ||
} | ||
catch(final FTPException e) | ||
{ | ||
throw new JFixError( | ||
"Can't execute '" + curCommand + "' command!", e); | ||
} | ||
catch(final IOException e) | ||
LoggerFactory.getLogger(JFix.class).info("Starting JFix {}...", JFix.VERSION); | ||
LoggerFactory.getLogger(JFix.class).info("Running on {} {} with Java {}", new Object[] | ||
{ | ||
System.getProperty("os.name"), | ||
System.getProperty("os.version"), | ||
System.getProperty("java.version") | ||
}); | ||
SwingUtilities.invokeLater(new Runnable() | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public void run() | ||
{ | ||
throw new JFixError(e); | ||
GuiController.getInstance(); | ||
} | ||
JFixMain.getLogger().info("Executed " + commands.size() + " commands!"); | ||
}); | ||
} | ||
} |
Oops, something went wrong.