From c0546d8e9f9947ca304a74c6122240eac25f4b3e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 7 Aug 2008 17:30:54 +0000 Subject: Update: Completed SVN plugin Closes #12 --- update/plugin/svn/trunk/manifest.mf | 2 + update/plugin/svn/trunk/nbproject/project.dtd | 54 ++++++++++++++ .../plugin/svn/trunk/nbproject/project.properties | 13 +++- .../com/fourisland/instadisc/update/svn/MD5.java | 68 ++++++++++++++++++ .../com/fourisland/instadisc/update/svn/Main.java | 83 ++++++++++++++++++++++ 5 files changed, 219 insertions(+), 1 deletion(-) create mode 100644 update/plugin/svn/trunk/manifest.mf create mode 100644 update/plugin/svn/trunk/nbproject/project.dtd create mode 100644 update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java (limited to 'update/plugin') diff --git a/update/plugin/svn/trunk/manifest.mf b/update/plugin/svn/trunk/manifest.mf new file mode 100644 index 0000000..0f8d5d3 --- /dev/null +++ b/update/plugin/svn/trunk/manifest.mf @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build \ No newline at end of file diff --git a/update/plugin/svn/trunk/nbproject/project.dtd b/update/plugin/svn/trunk/nbproject/project.dtd new file mode 100644 index 0000000..7b77177 --- /dev/null +++ b/update/plugin/svn/trunk/nbproject/project.dtd @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/update/plugin/svn/trunk/nbproject/project.properties b/update/plugin/svn/trunk/nbproject/project.properties index 77bb3db..97cccc2 100644 --- a/update/plugin/svn/trunk/nbproject/project.properties +++ b/update/plugin/svn/trunk/nbproject/project.properties @@ -1,3 +1,5 @@ +application.title=InstaDiscUpdateSVN +application.vendor=hatkirby build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form # This directory is removed when the project is cleaned: @@ -18,7 +20,8 @@ dist.javadoc.dir=${dist.dir}/javadoc excludes= includes=** jar.compress=false -javac.classpath= +javac.classpath=\ + ${libs.XML-RPC2.classpath} # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -40,6 +43,14 @@ javadoc.splitindex=true javadoc.use=true javadoc.version=false javadoc.windowtitle= +jnlp.codebase.type=local +jnlp.codebase.url=file:/home/hatkirby/NetBeansProjects/InstaDiscUpdateSVN/dist/ +jnlp.enabled=false +jnlp.offline-allowed=false +jnlp.signed=false +# Property libs.XML-RPC2.classpath is set here just to make sharing of project simpler. +# The library definition has always preference over this property. +libs.XML-RPC2.classpath=lib/commons-logging-1.1.jar:lib/ws-commons-util-1.0.2.jar:lib/xmlrpc-client-3.1.jar:lib/xmlrpc-common-3.1.jar:lib/xmlrpc-server-3.1.jar main.class=com.fourisland.instadisc.update.svn.Main manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF diff --git a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java new file mode 100644 index 0000000..0929022 --- /dev/null +++ b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/MD5.java @@ -0,0 +1,68 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package com.fourisland.instadisc.update.svn; + +import java.security.MessageDigest; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author hatkirby + */ +public class MD5 { + + String ver; + + public MD5(String ver) { + this.ver = ver; + } + + public MD5(char[] password) { + int i=0; + ver=""; + for (i=0;i y ? x : y); + } + + private String pad(String in, String pad, int len) + { + while (in.length() < len) + { + in = pad + in; + } + return in; + } +} diff --git a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java index e69de29..1bc9a07 100644 --- a/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java +++ b/update/plugin/svn/trunk/src/com/fourisland/instadisc/update/svn/Main.java @@ -0,0 +1,83 @@ +package com.fourisland.instadisc.update.svn; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.xmlrpc.XmlRpcException; +import org.apache.xmlrpc.client.XmlRpcClient; +import org.apache.xmlrpc.client.XmlRpcClientConfigImpl; + +public class Main { + + public static void main(String[] args) { + try + { + String username = getArg(0, args); + String password = getArg(1, args); + String centralServer = getArg(2, args); + String pathScheme = getArg(3, args); + String author = getArg(4, args); + String subscription = getArg(5, args); + String revision = getArg(6, args); + + StringBuilder messBuilder = new StringBuilder(); + byte rs = 0; + + while (rs != -1) + { + try + { + rs = (byte) System.in.read(); + if (rs != -1) + { + messBuilder.append(new String(new byte[]{rs})); + } + } catch (IOException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + } + + String message = messBuilder.toString(); + message = message.substring(0, message.indexOf("\n")); + + Random r = new Random(); + int verID = r.nextInt(Integer.MAX_VALUE); + + String path = pathScheme.replace("__REV__", revision); + + XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl(); + config.setServerURL(new URL(centralServer)); + XmlRpcClient client = new XmlRpcClient(); + client.setConfig(config); + client.execute("InstaDisc.sendFromUpdate", new Object[]{username, + (new MD5(username + ":" + (new MD5(password)).hash() + ":" + verID)).hash(), + verID, + subscription, + message, + author, + path, + "a:0:{}" + }); + } catch (XmlRpcException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } catch (MalformedURLException ex) + { + Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public static String getArg(int arg, String[] args) { + if (args.length < (arg+1)) + { + System.out.println("Program requires 7 arguments and you only provided " + arg); + System.exit(1); + } + + return args[arg]; + } +} -- cgit 1.4.1