Skip to content

Commit

Permalink
JFix 1.0 from 2011-09-30
Browse files Browse the repository at this point in the history
  • Loading branch information
Chrissyx committed Jan 8, 2021
1 parent 3f6533e commit 86e601f
Show file tree
Hide file tree
Showing 48 changed files with 3,214 additions and 403 deletions.
6 changes: 3 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="CHPJFix" default="default" basedir=".">
<description>Builds, tests, and runs the project CHPJFix.</description>
<project name="JFix" default="default" basedir=".">
<description>Builds, tests, and runs the project JFix.</description>
<import file="nbproject/build-impl.xml"/>
<!--
Expand Down Expand Up @@ -59,7 +59,7 @@
An example of overriding the target for project execution could look like this:
<target name="run" depends="CHPJFix-impl.jar">
<target name="run" depends="JFix-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
Expand Down
Binary file added lib/commons-codec.jar
Binary file not shown.
Binary file modified lib/edtftpj.jar
Binary file not shown.
Binary file added lib/logback-classic.jar
Binary file not shown.
Binary file added lib/logback-core.jar
Binary file not shown.
Binary file added lib/slf4j-api.jar
Binary file not shown.
419 changes: 328 additions & 91 deletions nbproject/build-impl.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions nbproject/edtFTPjDocList/package-list
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
12 changes: 6 additions & 6 deletions nbproject/genfiles.properties
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.
4 changes: 0 additions & 4 deletions nbproject/private/private.properties

This file was deleted.

95 changes: 33 additions & 62 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,57 +1,10 @@
application.desc=CHS - Java FTP Filetime Fix
application.homepage=http://www.chrissyx.de.vu
application.title=CHPJFix
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.homepage=http://www.chrissyx.com/
application.title=JFix
application.vendor=Chrissyx
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=4
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterFields=1
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.continuationIndentSize=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.redundantDoWhileBraces=LEAVE_ALONE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.redundantForBraces=LEAVE_ALONE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.redundantIfBraces=LEAVE_ALONE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.redundantWhileBraces=LEAVE_ALONE
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeCatchParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeForParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeIfParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeSwitchParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeSynchronizedParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceBeforeWhileParen=false
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-limit-width=80
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapAnnotationArgs=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapArrayInit=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapChainedMethodCalls=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapDoWhileStatement=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapEnumConstants=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsKeyword=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapExtendsImplementsList=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapForStatement=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapIfStatement=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapMethodCallArgs=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapMethodParams=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsList=WRAP_IF_LONG
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapWhileStatement=WRAP_IF_LONG
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
Expand All @@ -70,25 +23,38 @@ debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/CHPJFix.jar
dist.jar=${dist.dir}/JFix.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.edtftpj.jar=lib/edtftpj.jar
file.reference.commons-codec.jar=lib\\commons-codec.jar
file.reference.edtftpj.jar=lib\\edtftpj.jar
file.reference.logback-classic.jar=lib/logback-classic.jar
file.reference.logback-core.jar=lib/logback-core.jar
file.reference.slf4j-api.jar=lib/slf4j-api.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=false
jar.index=${jnlp.enabled}
javac.classpath=\
${file.reference.edtftpj.jar}
${file.reference.edtftpj.jar}:\
${file.reference.slf4j-api.jar}:\
${file.reference.logback-core.jar}:\
${file.reference.logback-classic.jar}:\
${file.reference.commons-codec.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=true
javac.processorpath=\
${javac.classpath}
javac.source=1.6
javac.target=1.6
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}:\
${libs.junit_4.classpath}
javadoc.additionalparam=-link http://java.sun.com/javase/6/docs/api -link http://www.enterprisedt.com/products/edtftpj/doc/api
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=-link http://download.oracle.com/javase/6/docs/api/ -link http://www.enterprisedt.com/products/edtftpj/doc/api/ -link http://slf4j.org/apidocs/ -link http://logback.qos.ch/apidocs/ -link http://commons.apache.org/codec/api-release/ -linkoffline http://www.enterprisedt.com/products/edtftpj/doc/api/ C:\\Programme\\NetBeans\\projects\\JFix\\nbproject\\edtFTPjDocList\\
javadoc.author=true
javadoc.encoding=${source.encoding}
javadoc.noindex=false
Expand All @@ -98,15 +64,20 @@ javadoc.private=true
javadoc.splitindex=true
javadoc.use=true
javadoc.version=true
javadoc.windowtitle=CHS - Java FTP Filetime Fix
jnlp.codebase.type=local
javadoc.windowtitle=JFix
jnlp.codebase.type=no.codebase
jnlp.descriptor=application
jnlp.enabled=false
jnlp.mixed.code=default
jnlp.offline-allowed=false
jnlp.signed=false
main.class=com.chrissyx.jfix.JFixMain
jnlp.signing=
jnlp.signing.alias=
jnlp.signing.keystore=
main.class=com.chrissyx.jfix.JFix
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
Expand Down
2 changes: 1 addition & 1 deletion nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>CHPJFix</name>
<name>JFix</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
Expand Down
160 changes: 31 additions & 129 deletions src/com/chrissyx/jfix/JFix.java
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!");
});
}
}
Loading

0 comments on commit 86e601f

Please sign in to comment.