- get rid of client_java layer
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 30 Apr 2008 16:17:46 +0000 (16:17 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 30 Apr 2008 16:17:46 +0000 (16:17 +0000)
- better class naming
- keep SSL connection when possible

15 files changed:
org.glite.lb.client-java/build.xml
org.glite.lb.client-java/project/genEventTypes.pl
org.glite.lb.client-java/src/org/glite/lb/Context.java [moved from org.glite.lb.client-java/src/org/glite/lb/client_java/Context.java with 86% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/ContextIL.java [moved from org.glite.lb.client-java/src/org/glite/lb/client_java/ContextIL.java with 70% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/ContextLL.java [new file with mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/Event.java [moved from org.glite.lb.client-java/src/org/glite/lb/client_java/Event.java with 93% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/ILFileWriter.java [new file with mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/ProducerTestIL.java [moved from org.glite.lb.client-java/src/org/glite/test/Test.java with 55% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/ProducerTestLL.java [new file with mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/SSLSend.java [new file with mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/SeqCode.java [moved from org.glite.lb.client-java/src/org/glite/lb/client_java/SeqCode.java with 93% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/Sources.java [moved from org.glite.lb.client-java/src/org/glite/lb/client_java/Sources.java with 96% similarity, mode: 0644]
org.glite.lb.client-java/src/org/glite/lb/client_java/ContextProxy.java [deleted file]
org.glite.lb.client-java/src/org/glite/lb/client_java/Running.java [deleted file]
org.glite.lb.client-java/src/org/glite/lb/client_java/Transfer.java [deleted file]

index 1fe4afa..cca66fc 100755 (executable)
@@ -8,7 +8,7 @@
 
                <target name="-pre-compile">
                        <exec executable="${stageDir}/sbin/glite-lb-at3">
-                               <arg line="project/genEventTypes.pl src/org/glite/lb/client_java"/>
+                               <arg line="project/genEventTypes.pl src/org/glite/lb"/>
                        </exec>
                </target>
     <!--
index 672e7b5..e772057 100644 (file)
@@ -11,9 +11,9 @@
 
                print E
 qq{
-package org.glite.lb.client_java;
-import org.glite.jobid.api_java.CheckedString;
-import org.glite.jobid.api_java.Jobid;
+package org.glite.lb;
+import org.glite.jobid.CheckedString;
+import org.glite.jobid.Jobid;
 
 public class Event$uc extends Event \{
        public Event$uc() \{
old mode 100755 (executable)
new mode 100644 (file)
similarity index 86%
rename from org.glite.lb.client-java/src/org/glite/lb/client_java/Context.java
rename to org.glite.lb.client-java/src/org/glite/lb/Context.java
index 9b1fe9c..1fc4358
@@ -1,10 +1,10 @@
-package org.glite.lb.client_java;
+package org.glite.lb;
 
 import java.net.UnknownHostException;
 import java.util.Calendar;
 import java.util.Random;
-import org.glite.jobid.api_java.Jobid;
-import org.glite.jobid.api_java.CheckedString;
+import org.glite.jobid.Jobid;
+import org.glite.jobid.CheckedString;
 
 /**
  * Class representing a context for some job
@@ -12,10 +12,10 @@ import org.glite.jobid.api_java.CheckedString;
  * @author Pavel Piskac (173297@mail.muni.cz)
  * @version 15. 3. 2008
  */
-public class Context {
+public abstract class Context {
 
     private int id;
-    private Sources source;
+    private int source;
     private int flag;
     private String host;
     private String user;
@@ -23,8 +23,7 @@ public class Context {
     private String srcInstance;
     private Jobid jobid;
     private SeqCode seqCode;
-    private String message;
-
+    
     /**
      * Creates new instance of Context class.
      */
@@ -47,7 +46,7 @@ public class Context {
      * 
      */
     public Context(int id,
-            Sources source,
+            int source,
             int flag,
             String host,
             String user,
@@ -58,7 +57,7 @@ public class Context {
             id = new Random().nextInt();
         }
 
-        if (source == null) {
+        if (source <= -1 || source > Sources.EDG_WLL_SOURCE_LB_SERVER) {
             throw new IllegalArgumentException("Context source");
         }
 
@@ -106,8 +105,8 @@ public class Context {
      * @return String representation of Sources enum constants
      * @throws IllegalArgumentException if wrong source type is set
      */
-    private String recognizeSource(Sources sourceEnum) {
-        switch (sourceEnum.source) {
+    private String recognizeSource(int sourceEnum) {
+        switch (sourceEnum) {
             case Sources.EDG_WLL_SOURCE_NONE: return "Undefined";
             case Sources.EDG_WLL_SOURCE_USER_INTERFACE: return "UserInterface";
             case Sources.EDG_WLL_SOURCE_NETWORK_SERVER: return "NetworkServer";
@@ -123,17 +122,44 @@ public class Context {
     }
 
     /**
+     * Abstract method which will serve as method for sending messages with events.
+     * @param event event for which will be created and send message
+     */
+    public abstract void log(Event event);
+    
+    /**
      * Creates message prepared to send
      * @param event event for which is message generated
      * @throws IllegalArgumentException if event, source, user or job is null
      * or flag < 0
+     * @return output String with message
      */
-    public void log(Event event) {
+    protected String createMessage(Event event) {
+        if (event == null) {
+            throw new IllegalArgumentException("Context event");
+        }
+        
+        if (jobid == null) {
+            throw new IllegalArgumentException("Context jobid");
+        }
+
+        if (jobid.getBkserver() == null) {
+            throw new IllegalArgumentException("Context Jobid bkserver");
+        }
+
+        if (jobid.getPort() <= 0 || jobid.getPort() >= 65536) {
+            throw new IllegalArgumentException("Context Jobid port");
+        }
+        
+        if (jobid.getUnique() == null) {
+            throw new IllegalArgumentException("Context Jobid unique");
+        }
+        
         if (event == null) {
             throw new IllegalArgumentException("Context event");
         }
 
-        if (source == null) {
+        if (source <= -1 || source > Sources.EDG_WLL_SOURCE_LB_SERVER) {
             throw new IllegalArgumentException("Context source");
         }
 
@@ -161,10 +187,6 @@ public class Context {
             srcInstance = new String("");
         }
 
-        if (jobid == null) {
-            throw new IllegalArgumentException("Context jobid");
-        }
-
         String output;
         String date = "";
         String tmp;
@@ -200,11 +222,11 @@ public class Context {
                 " DG.SEQCODE=\"" + seqCode + "\"" +
                 event.ulm());
 
-        this.message = output;
+        return output;
     }
 
     /**
-     * Return flag which represents which part of sequence code will be changes
+     * Return flag 
      * 
      * @return flag
      */
@@ -213,7 +235,7 @@ public class Context {
     }
 
     /**
-     * Set flag which represents which part of sequence code will be changes
+     * Set flag
      * 
      * @param flag
      * @throws java.lang.IllegalArgumentException if flag is lower than 0
@@ -294,14 +316,6 @@ public class Context {
     }
 
     /**
-     * Gets message which is prepared to send.
-     * @return message
-     */
-    public String getMessage() {
-        return message;
-    }
-
-    /**
      * Gets prog.
      * @return prog
      */
@@ -344,20 +358,20 @@ public class Context {
     }
 
     /**
-     * Gets source.
+     * Gets source which represents which part of sequence code will be changed
      * @return source
      */
-    public Sources getSource() {
+    public int getSource() {
         return source;
     }
 
     /**
-     * Sets source
+     * Sets source which represents which part of sequence code will be changed
      * @param source source
      * @throws java.lang.IllegalArgumentException if source is null
      */
-    public void setSource(Sources source) {
-        if (source == null) {
+    public void setSource(int source) {
+        if (source <= -1 || source > Sources.EDG_WLL_SOURCE_LB_SERVER) {
             throw new IllegalArgumentException("Context source");
         }
 
old mode 100755 (executable)
new mode 100644 (file)
similarity index 70%
rename from org.glite.lb.client-java/src/org/glite/lb/client_java/ContextIL.java
rename to org.glite.lb.client-java/src/org/glite/lb/ContextIL.java
index 16ca38d..2d798cb
@@ -1,15 +1,6 @@
-package org.glite.lb.client_java;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import org.glite.jobid.api_java.Jobid;
-import org.glite.jobid.api_java.CheckedString;
+package org.glite.lb;
+
+import org.glite.jobid.Jobid;
 
 /**
  * Class which is used to send messages to inter-logger using unix socket.
@@ -48,8 +39,8 @@ public class ContextIL extends Context {
      * @param prefix path where are stored messages
      */
     public ContextIL(String pathToSocket, String prefix) {
-        this.prefix = new CheckedString(prefix).toString();
-        this.pathToSocket = new CheckedString(pathToSocket).toString();
+        this.prefix = prefix;
+        this.pathToSocket = pathToSocket;
     }
 
     /**
@@ -69,14 +60,14 @@ public class ContextIL extends Context {
      * or path is null or flag < 0
      */
     public ContextIL(int id,
-            Sources source,
+            int source,
             int flag,
             String host,
             String user,
             String prog,
             String srcInstance,
             Jobid jobid,
-            String path,
+            String pathToSocket,
             String prefix) {
 
         super(id, source, flag, host, user, prog, srcInstance, jobid);
@@ -85,78 +76,12 @@ public class ContextIL extends Context {
             throw new IllegalArgumentException("ContextIL prefix");
         }
 
-        if (path == null) {
+        if (pathToSocket == null) {
             throw new IllegalArgumentException("ContextIL path");
         }
 
-        this.prefix = new CheckedString(prefix).toString();
-        this.pathToSocket = new CheckedString(pathToSocket).toString();
-    }
-
-    /**
-     * Writes message to a file and returns original size of this file
-     * 
-     * @param prefix file path
-     * @param message message which will be written
-     * @return size of the file before writing the data
-     */
-    private Long writeToFile(String prefix, String message) {
-        FileWriter fileWriter = null;
-        Long fileLength = null;
-        RandomAccessFile raf = null;
-        FileLock fileLock = null;
-        File file;
-
-        for (int i = 0; i < repeatWriteToFile; i++) {
-            try {
-                file = new File(prefix);
-                raf = new RandomAccessFile(file, "rw");
-                FileChannel fileChannel = raf.getChannel();
-
-                fileLock = fileChannel.tryLock();
-                if (fileLock != null) {
-                    if (!file.exists()) {
-                        continue;
-                    }
-                    fileLength = new Long(raf.length());
-                    fileWriter = new FileWriter(file, true);
-                    //true means append data at the end of file
-
-                    BufferedWriter bufferedFileWriter = new BufferedWriter(fileWriter);
-
-                    bufferedFileWriter.write(message + '\n');
-                    bufferedFileWriter.flush();
-
-                    if (file.exists()) {
-                        break;
-                    }
-                }
-            } catch (FileNotFoundException ex) {
-                System.err.println(ex);
-            } catch (IOException ex) {
-                System.err.println(ex);
-            } catch (Exception ex) {
-                System.err.println(ex);
-            } finally {
-                if (fileLock != null) {
-                    try {
-                        fileLock.release();
-                    } catch (IOException ex) {
-                        System.err.println(ex);
-                    }
-                }
-
-                try {
-                    raf.close();
-                } catch (IOException ex) {
-                    System.err.println(ex);
-                } catch (NullPointerException ex) {
-                    System.err.println(ex);
-                }
-            }
-        }
-
-        return fileLength;
+        this.prefix = prefix;
+        this.pathToSocket = pathToSocket;
     }
 
     /**
@@ -174,7 +99,7 @@ public class ContextIL extends Context {
 
         if (useUnixSocket.booleanValue()) {
             try {
-                System.loadLibrary("sendviasocket");
+                System.loadLibrary("glite_lb_sendviasocket");
                message += '\n';
                    sendToSocket(pathToSocket,
                         fileSize,
@@ -215,10 +140,9 @@ public class ContextIL extends Context {
             useUnixSocket = Boolean.FALSE;
         }
         
-        super.log(event);
-        String message = super.getMessage();
+        String message = super.createMessage(event);
 
-        Long fileLength = writeToFile(prefix, message);
+        Long fileLength = ILFileWriter.write(prefix, message, repeatWriteToFile);
 
         writeToSocket(pathToSocket, fileLength.longValue(), message);
     }
@@ -243,7 +167,7 @@ public class ContextIL extends Context {
             throw new IllegalArgumentException("ContextIL pathToSocket");
         }
 
-        this.pathToSocket = new CheckedString(pathToSocket).toString();
+        this.pathToSocket = pathToSocket;
     }
 
     /**
@@ -286,7 +210,7 @@ public class ContextIL extends Context {
             throw new IllegalArgumentException("ContextIL prefix");
         }
 
-        this.prefix = new CheckedString(prefix).toString();
+        this.prefix = prefix;
     }
 
     /**
diff --git a/org.glite.lb.client-java/src/org/glite/lb/ContextLL.java b/org.glite.lb.client-java/src/org/glite/lb/ContextLL.java
new file mode 100644 (file)
index 0000000..127e0e9
--- /dev/null
@@ -0,0 +1,173 @@
+package org.glite.lb;
+
+import org.glite.jobid.Jobid;
+import org.glite.jobid.CheckedString;
+
+/** 
+ * This class provides sending messages using network sockets.
+ * 
+ * @author Pavel Piskac (173297@mail.muni.cz)
+ */
+public class ContextLL extends Context {
+
+    private String address;
+    private int port = 9002;
+    private String prefix;
+    private int repeatWriteToFile = 5;
+    private int timeout = 30000; //in milliseconds
+    private String pathToCertificate;
+    private String password;
+    private SSLSend sslSend = null;
+
+    public ContextLL() {
+    }
+
+    public ContextLL(String address, int port, String prefix) {
+        this.prefix = prefix;
+        this.address = address;
+        this.port = port;
+    }
+
+    public ContextLL(int id,
+            int source,
+            int flag,
+            String host,
+            String user,
+            String prog,
+            String srcInstance,
+            Jobid jobid,
+            String address,
+            int port,
+            String prefix) {
+
+        super(id, source, flag, host, user, prog, srcInstance, jobid);
+
+        if (prefix == null) {
+            throw new IllegalArgumentException("ContextProxy prefix");
+        }
+        if (address == null) {
+            throw new IllegalArgumentException("ContextProxy socket");
+        }
+        if (port < 0) {
+            throw new IllegalArgumentException("ContextProxy port");
+        }
+
+        this.prefix = new CheckedString(prefix).toString();
+        this.address = new CheckedString(address).toString();
+    }
+
+    @Override
+    public void log(Event event) {
+        if (event == null) {
+            throw new IllegalArgumentException("ContextProxy event");
+        }
+
+        if (prefix == null) {
+            throw new IllegalArgumentException("ContextProxy prefix");
+        }
+
+        if (address == null) {
+            throw new IllegalArgumentException("ContextProxy socket");
+        }
+
+        if (port < 0) {
+            throw new IllegalArgumentException("ContextProxy port");
+        }
+
+        if (sslSend == null) {
+            sslSend = new SSLSend();
+        }
+        
+        String message = super.createMessage(event);
+
+        ILFileWriter.write(prefix, message, repeatWriteToFile);
+        
+        
+        sslSend.send(pathToCertificate, password, address, port, timeout, message);
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        if (address == null) {
+            throw new IllegalArgumentException("ContextProxy address");
+        }
+        
+        this.address = address;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        if (port < 0) {
+            throw new IllegalArgumentException("ContextProxy port");
+        }
+        this.port = port;
+    }
+    
+    
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public void setPrefix(String prefix) {
+        if (prefix == null) {
+            throw new IllegalArgumentException("ContextProxy prefix");
+        }
+        
+        this.prefix = prefix;
+    }
+
+    public int getRepeatWriteToFile() {
+        return repeatWriteToFile;
+    }
+
+    public void setRepeatWriteToFile(int repeatWriteToFile) {
+        if (repeatWriteToFile < 1) {
+            throw new IllegalArgumentException("ContextProxy repeatWriteToFile");
+        }
+        
+        this.repeatWriteToFile = repeatWriteToFile;
+    }
+
+    public int getTimeout() {
+        return timeout;
+    }
+
+    public void setTimeout(int timeout) {
+        if (timeout < 0) {
+            throw new IllegalArgumentException("ContextProxy timout");
+        }
+        this.timeout = timeout;
+    }
+
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        if (password == null) {
+            throw new IllegalArgumentException("ContextProxy password");
+        }
+        
+        this.password = password;
+    }
+
+    public String getPathToCertificate() {
+        return pathToCertificate;
+    }
+
+    public void setPathToCertificate(String pathToCertificate) {
+        if (pathToCertificate == null) {
+            throw new IllegalArgumentException("ContextProxy pathToCertificate");
+        }
+        
+        this.pathToCertificate = pathToCertificate;
+    }
+
+    
+}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 93%
rename from org.glite.lb.client-java/src/org/glite/lb/client_java/Event.java
rename to org.glite.lb.client-java/src/org/glite/lb/Event.java
index 5c8cfbc..3e61203
@@ -1,4 +1,4 @@
-package org.glite.lb.client_java;
+package org.glite.lb;
 
 /**
  * Abstract class which serves as base for all events.
diff --git a/org.glite.lb.client-java/src/org/glite/lb/ILFileWriter.java b/org.glite.lb.client-java/src/org/glite/lb/ILFileWriter.java
new file mode 100644 (file)
index 0000000..28cb84d
--- /dev/null
@@ -0,0 +1,87 @@
+package org.glite.lb;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+
+/**
+ * This class provides writing messages to some file.
+ * 
+ * @author Pavel Piskac (173297@mail.muni.cz)
+ */
+public class ILFileWriter {
+
+    public ILFileWriter() {
+    }
+    
+    /**
+     * Writes message to a file and returns size of this file before writing the
+     * data
+     * @param prefix file path
+     * @param message message which will be written
+     * @param repeatWriteToFile count of attempts to write to file in case of failure
+     */
+    public static Long write(String prefix, String message, int repeatWriteToFile) {
+        FileWriter fileWriter = null;
+        Long fileLength = null;
+        RandomAccessFile raf = null;
+        FileLock fileLock = null;
+        File file;
+
+        for (int i = 0; i < repeatWriteToFile; i++) {
+            try {
+                file = new File(prefix);
+                raf = new RandomAccessFile(file, "rw");
+                FileChannel fileChannel = raf.getChannel();
+
+                fileLock = fileChannel.tryLock();
+                if (fileLock != null) {
+                    if (!file.exists()) {
+                        continue;
+                    }
+                    fileLength = new Long(raf.length());
+                    fileWriter = new FileWriter(file, true);
+                    //true means append data at the end of file
+
+                    BufferedWriter bufferedFileWriter = new BufferedWriter(fileWriter);
+
+                    bufferedFileWriter.write(message + '\n');
+                    bufferedFileWriter.flush();
+
+                    if (file.exists()) {
+                        break;
+                    }
+                }
+            } catch (FileNotFoundException ex) {
+                System.err.println(ex);
+            } catch (IOException ex) {
+                System.err.println(ex);
+            } catch (Exception ex) {
+                System.err.println(ex);
+            } finally {
+                if (fileLock != null) {
+                    try {
+                        fileLock.release();
+                    } catch (IOException ex) {
+                        System.err.println(ex);
+                    }
+                }
+
+                try {
+                    raf.close();
+                } catch (IOException ex) {
+                    System.err.println(ex);
+                } catch (NullPointerException ex) {
+                    System.err.println(ex);
+                }
+            }
+        }
+
+        return fileLength;
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 55%
rename from org.glite.lb.client-java/src/org/glite/test/Test.java
rename to org.glite.lb.client-java/src/org/glite/lb/ProducerTestIL.java
index 4e4b7be..fda43f4
@@ -1,81 +1,37 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package org.glite.test;
+package org.glite.lb;
 
 import java.util.Random;
-import org.glite.jobid.api_java.Jobid;
-import org.glite.lb.client_java.ContextIL;
-import org.glite.lb.client_java.Running;
-import org.glite.lb.client_java.SeqCode;
-import org.glite.lb.client_java.Sources;
+import org.glite.jobid.Jobid;
 
 /**
- *
- * @author xpiskac
+ * This class shows how to work with ContextIL.
+ * 
+ * @author Pavel Piskac
  */
-public class Test {
+public class ProducerTestIL {
 
     public static void main(String[] args) {
         
-        //how Jobid class works
-        //unique part is automatically generated
-        Jobid jobid1 = new Jobid("https://somewhere.cz", 5000);
-        System.out.println("bkserver "+ jobid1.getBkserver());
-        System.out.println("port "+ jobid1.getPort());
-        System.out.println("unique "+ jobid1.getUnique());
-        System.out.println("-------------------");
-        
-        //unique part is set by user
-        Jobid jobid2 = new Jobid("https://somewhere.cz", 5000, "my_unique_part");
-        System.out.println("bkserver "+ jobid2.getBkserver());
-        System.out.println("port "+ jobid2.getPort());
-        System.out.println("unique "+ jobid2.getUnique());
-        System.out.println("-------------------");
-        
-        //whole jobid is set by user and then parsed
-        Jobid jobid3 = new Jobid("https://somewhere.cz:5000/my_unique_part");
-        System.out.println("bkserver "+ jobid3.getBkserver());
-        System.out.println("port "+ jobid3.getPort());
-        System.out.println("unique "+ jobid3.getUnique());
-        System.out.println("-------------------");
-        
-        //each part is set separately
-        Jobid jobid4 = new Jobid();
-        jobid4.setBkserver("https://somewhere.cz");
-        jobid4.setPort(5000);
-        jobid4.setUnique("my_unique_part");
-        System.out.println("bkserver "+ jobid4.getBkserver());
-        System.out.println("port "+ jobid4.getPort());
-        System.out.println("unique "+ jobid4.getUnique());
-        System.out.println("-------------------");
-        
-        if (args.length == 0) {
+        if (args.length != 10) {
             System.out.println("How to use test class:\n" +
                     "you have to set 10 arguments in this order, if the choice is optional \"\" or text has to be set:\n" +
                     "1. jobid in format \"https://somewhere:port/unique_part\" (required)\n" +
                     "2. path to shared library written in c to be able to send messages via unix socket (optional)\n" +
-                    "3. source, enum constant from class Sources (required)\n" +
-                    "4. flag determines which part of sequence code will be increased\n" +
+                    "3. source, enum constant from class Sources, determines which part of sequence code will be increased (required)\n" +
+                    "4. flag (required)\n" +
                     "5. host name, if it is \"\" then is set name of the computer where is test class running (optional)\n" +
                     "6. user name (required)\n" +
-                    "7. PID of running process (optional)\n" +
+                    "7. srcInstance (optional)\n" +
                     "8. path to directory where will be saved files with events for each job (required)\n" +
                     "9. path to unix socket (required if path to shared library is set)\n" +
-                    "10. description for event in this case event running (optional)\n");
+                    "10. description for event in this case event running (required)\n");
         } else {
             /* Create new instance of jobid, you can use other constructors too (see org.glite.jobid.api_java.Jobid.java) 
              * Examples:
-             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz:9000/paja6_test2");
-             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz", 9000, "paja6_test2");
-             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz", 9000); //unique part is automatically generated
-             * Jobid jobid = new Jobid();
-             * jobid.setBkserver("https://skurut68-2.cesnet.cz");
-             * jobid.setPort(9000);
-             * jobid.setUnique("paja6_test2");
+             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz:9000/paja6_test2"); 
              */
             Jobid jobid = new Jobid(args[0]);
+            System.out.println("jobid: " + args[0]);
 
             /* Create sequence code
              * Example:
@@ -103,38 +59,45 @@ public class Test {
              * Example: ctx.setPathToNativeLib("/home/paja6/locallogger/build/classes/org/glite/lb/");
              */
             ctx.setPathToNativeLib(args[1]);
+            System.out.println("pathToNativeLib: " + args[1]);
 
             /* Id of the message is some random unique number. 
              */
             ctx.setId(new Random().nextInt(99999999));
 
             /* Source indicates source of the message, it is constant from org.glite.lb.client_java.Sources class
+             * and determines which part of sequence number will be increased.
              * Example: ctx.setSource(Sources.EDG_WLL_SOURCE_LRMS);
              * In this case we have to use method which converts args[2] to Sources. In real environment it will
              * not be used.
              */
-            ctx.setSource(new Sources(stringToSources(args[2])));
+            ctx.setSource(new Integer(args[2]));
+            System.out.println("source: " + args[2]);
 
-            /* Flag tells which part of the sequence number will be increased. It is a number in range from 0 to 8
+            /* Flag
              * Example: ctx.setFlag(0);
              */
-            ctx.setFlag((new Integer(args[3])).intValue());
+            ctx.setFlag(new Integer(args[3]));
+            System.out.println("flag: " + args[3]);
 
             /* Name of the computer where is locallogger running
              * Example: ctx.setHost("pelargir.ics.muni.cz");
              */
             ctx.setHost(args[4]);
+            System.out.println("host: " + args[4]);
 
             /* Name of the user who owns the job.
              * Example: ctx.setUser("Pavel Piskac");
              */
             ctx.setUser(args[5]);
+            System.out.println("user: " + args[5]);
 
             /* TODO co to vlastne znamena?
              * Mostly "" is set
              * Example: ctx.setSrcInstance("");
              */
             ctx.setSrcInstance(args[6]);
+            System.out.println("srcInstance: " + args[6]);
 
             /* Set the jobid for the context.
              */
@@ -159,20 +122,23 @@ public class Test {
              * Example: ctx.setPrefix("/home/paja6/tmp/dglog." + jobid.getUnique());
              */
             ctx.setPrefix(args[7]);
+            System.out.println("prefix: " + args[7]);
 
             /* Path to unix socket.
              * Example: ctx.setPathToSocket("/home/paja6/tmp/il.sock");
              */
             ctx.setPathToSocket(args[8]);
+            System.out.println("pathToSocket: " + args[8]);
 
             /* Create new instance of the event which will be logged.
              */
-            Running running = new Running();
+            EventRunning running = new EventRunning();
 
             /* Set some description for the event.
              * Example: running.setNode("worker node");
              */
             running.setNode(args[9]);
+            System.out.println("node: " + args[9]);
 
             /* And now is the context and event prepared to work.
              * 
@@ -180,22 +146,4 @@ public class Test {
             ctx.log(running);
         }
     }
-    
-    /*
-     * This method helps with converting String from input to convert to Source.
-     * In real environment it will not be used.
-     */
-    private static int stringToSources(String source) {
-        if (source.equals("Sources.EDG_WLL_SOURCE_NONE")) return Sources.EDG_WLL_SOURCE_NONE;
-        if (source.equals("Sources.EDG_WLL_SOURCE_USER_INTERFACE")) return Sources.EDG_WLL_SOURCE_USER_INTERFACE;
-        if (source.equals("Sources.EDG_WLL_SOURCE_NETWORK_SERVER")) return Sources.EDG_WLL_SOURCE_NETWORK_SERVER;
-        if (source.equals("Sources.EDG_WLL_SOURCE_WORKLOAD_MANAGER")) return Sources.EDG_WLL_SOURCE_WORKLOAD_MANAGER;
-        if (source.equals("Sources.EDG_WLL_SOURCE_BIG_HELPER")) return Sources.EDG_WLL_SOURCE_BIG_HELPER;
-        if (source.equals("Sources.EDG_WLL_SOURCE_JOB_SUBMISSION")) return Sources.EDG_WLL_SOURCE_JOB_SUBMISSION;
-        if (source.equals("Sources.EDG_WLL_SOURCE_LOG_MONITOR")) return Sources.EDG_WLL_SOURCE_LOG_MONITOR;
-        if (source.equals("Sources.EDG_WLL_SOURCE_LRMS")) return Sources.EDG_WLL_SOURCE_LRMS;
-        if (source.equals("Sources.EDG_WLL_SOURCE_APPLICATION")) return Sources.EDG_WLL_SOURCE_APPLICATION;
-        if (source.equals("Sources.EDG_WLL_SOURCE_LB_SERVER")) return Sources.EDG_WLL_SOURCE_LB_SERVER;
-        throw new IllegalArgumentException("wrong source type");
-    }
 }
diff --git a/org.glite.lb.client-java/src/org/glite/lb/ProducerTestLL.java b/org.glite.lb.client-java/src/org/glite/lb/ProducerTestLL.java
new file mode 100644 (file)
index 0000000..4861109
--- /dev/null
@@ -0,0 +1,170 @@
+package org.glite.lb;
+
+import java.util.Random;
+import org.glite.jobid.Jobid;
+
+/**
+ * This class shows how to work with ContextLL.
+ * 
+ * @author Pavel Piskac
+ */
+public class ProducerTestLL {
+
+    public static void main(String[] args) {
+
+        if (args.length != 13) {
+            System.out.println("How to use test class:\n" +
+                    "you have to set 13 arguments in this order, if the choice is optional \"\" or text has to be set:\n" +
+                    "1. jobid in format \"https://somewhere:port/unique_part\" (required)\n" +
+                    "2. source, enum constant from class Sources, determines which part of sequence code will be increased (required)\n" +
+                    "3. flag (required)\n" +
+                    "4. host name, if it is \"\" then is set name of the computer where is test class running (optional)\n" +
+                    "5. user name (required)\n" +
+                    "6. srcInstace (optional)\n" +
+                    "7. connection timeout (optional)\n" +
+                    "8. proxy server address (required)\n" +
+                    "9. proxy server port, default value is 9002 (optional)\n" +
+                    "10. path to user's certificate (required)\n" + 
+                    "11. password to certificate (required)\n" +
+                    "12. path to directory where will be saved files with logs until inter-logger sends the content.");
+        } else {
+            /* Create new instance of jobid, you can use other constructors too (see org.glite.jobid.api_java.Jobid.java) 
+             * Examples:
+             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz:9000/paja6_test2");
+             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz", 9000, "paja6_test2");
+             * Jobid jobid = new Jobid("https://skurut68-2.cesnet.cz", 9000); //unique part is automatically generated
+             * Jobid jobid = new Jobid();
+             * jobid.setBkserver("https://skurut68-2.cesnet.cz");
+             * jobid.setPort(9000);
+             * jobid.setUnique("paja6_testProxy3");
+             */
+            Jobid jobid = new Jobid(args[0]);
+            System.out.println("jobid: " + args[0]);
+
+            /* Create sequence code
+             * Example:
+             * SeqCode seqCode = new SeqCode();
+             * Insert sequence number in format 
+             * UI=XXXXXX:NS=XXXXXXXXXX:WM=XXXXXX:BH=XXXXXXXXXX:JSS=XXXXXX:LM=XXXXXX:LRMS=XXXXXX:APP=XXXXXX:LBS=XXXXXX
+             * where X is 0-9, or you can just create new instance of SeqCode where all parts are set to 0
+             * Example:
+             * SeqCode seqCode = new SeqCode();
+             * seqCode.getSeqCodeFromString("UI=000001:NS=0000000002:WM=000003:BH=0000000004:" + 
+             * "JSS=000005:LM=000006:LRMS=000007:APP=000008:LBS=000009"); 
+             * seqCode.incrementSeqCode(Sources.EDG_WLL_SOURCE_USER_INTERFACE); 
+             * resulting sequence code will be 
+             * UI=000002:NS=0000000002:WM=000003:BH=0000000004:JSS=000005:LM=000006:LRMS=000007:APP=000008:LBS=000009
+             */
+            SeqCode seqCode = new SeqCode();
+
+            /* Choose type of sending a log messages (at this time is implemented only ContextIL class)
+             * You can choose from some constructors (see org.glite.lb.client_java.ContextIL class)
+             */
+            ContextLL ctx = new ContextLL();
+
+            /* Id of the message is some random unique number. 
+             * This value will be ceplaced by value from proxy.
+             */
+            ctx.setId(new Random().nextInt(99999999));
+
+            /* Source indicates source of the message, it is constant from org.glite.lb.client_java.Sources class
+             * and determines which part of sequence number will be increased.
+             * Example: ctx.setSource(Sources.EDG_WLL_SOURCE_LRMS);
+             * In this case we have to use method which converts args[2] to Sources. In real environment it will
+             * not be used.
+             */
+            ctx.setSource(new Integer(args[1]));
+            System.out.println("source: " + args[1]);
+
+            /* Flag.
+             * Example: ctx.setFlag(0);
+             */
+            ctx.setFlag(new Integer(args[2]));
+            System.out.println("flag: " + args[2]);
+
+            /* Name of the computer where is locallogger running
+             * Example: ctx.setHost("pelargir.ics.muni.cz");
+             */
+            ctx.setHost(args[3]);
+            System.out.println("host: " + args[3]);
+
+            /* Name of the user who owns the job, this attribute will be replaced
+             * by value get from certificate.
+             * Example: ctx.setUser("Pavel Piskac");
+             */
+            ctx.setUser(args[4]);
+            System.out.println("user: " + args[4]);
+
+            /* TODO co to vlastne znamena?
+             * Mostly "" is set
+             * Example: ctx.setSrcInstance("");
+             */
+            ctx.setSrcInstance(args[5]);
+            System.out.println("srcInstance: " + args[5]);
+
+            /* Set the jobid for the context.
+             */
+            ctx.setJobid(jobid);
+
+            /* Set the jobid for the context.
+             */
+            ctx.setSeqCode(seqCode);
+
+            /* Timeout in seconds for the connection while sending the message via unix socket.
+             * Default value is 3 but you can change it.
+             */
+            ctx.setTimeout(new Integer(args[6]));
+            System.out.println("timeout: " + args[6]);
+
+            /* Address to proxy.
+             * Example:
+             * ctx.setAddress("147.251.3.62");
+             */
+            ctx.setAddress(args[7]);
+            System.out.println("address: " + args[7]);
+
+            /* Proxy server port.
+             * Example:
+             * ctx.setPort(9002);
+             */
+            ctx.setPort(new Integer(args[8]));
+            System.out.println("port: " + args[8]);
+
+            /* Path to user's certificate. Only *.ks and *.p12 certificates are allowed.
+             * Example:
+             * ctx.setPathToCertificate("/home/paja6/myCertificate.p12");
+             */
+            ctx.setPathToCertificate(args[9]);
+            System.out.println("pathToCertificate: " + args[9]);
+
+            /* Password to certificate.
+             * Example: 
+             * ctx.setPassword("MySecretPassword");
+             */
+            ctx.setPassword(args[10]);
+            System.out.println("password: " + args[10]);
+
+            /* Path to directory where will be saved files with logs until inter-logger sends 
+             * the content.
+             * Example: ctx.setPrefix("/home/paja6/tmp/dglog." + jobid.getUnique());
+             */
+            ctx.setPrefix(args[11]);
+            System.out.println("prefix: " + args[11]);
+
+            /* Create new instance of the event which will be logged.
+             */
+            EventRunning running = new EventRunning();
+
+            /* Set some description for the event.
+             * Example: running.setNode("worker node");
+             */
+            running.setNode(args[12]);
+            System.out.println("node: " + args[12]);
+
+            /* And now is the context and event prepared to work.
+             * 
+             */
+            ctx.log(running);
+        }
+    }
+}
diff --git a/org.glite.lb.client-java/src/org/glite/lb/SSLSend.java b/org.glite.lb.client-java/src/org/glite/lb/SSLSend.java
new file mode 100644 (file)
index 0000000..f940cb5
--- /dev/null
@@ -0,0 +1,236 @@
+package org.glite.lb;
+
+import javax.net.ssl.*;
+import java.io.*;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.security.*;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+import java.util.Enumeration;
+
+// http://java.sun.com/j2se/1.5.0/docs/guide/security/jsse/JSSERefGuide.html#SupportClasses
+/**
+ * This class opens secure connection using SSLv3 and then sends message to set
+ * address.
+ * 
+ * @author Pavel Piskac
+ */
+public class SSLSend {
+    
+    private static final String EDG_WLL_LOG_SOCKET_HEADER = "DGLOG";
+    
+    /**
+     * Implementation of abstract class X509KeyManager. 
+     * It is used to manage X509 certificates which are used to authenticate
+     * the local side of a secure socket.
+     */
+    static class MyX509KeyManager implements X509KeyManager {
+
+        private X509Certificate[] certchain;
+        private PrivateKey key;
+    
+        public MyX509KeyManager(Certificate[] cchain, PrivateKey key) {
+            this.certchain = new X509Certificate[cchain.length];
+            System.arraycopy(cchain, 0, this.certchain, 0, cchain.length);
+            this.key = key;
+        }
+
+        public String chooseClientAlias(String[] keyType, Principal[] issuers, Socket socket) {
+            return "";
+        }
+
+        public String chooseServerAlias(String keyType, Principal[] issuers, Socket socket) {
+            return null;
+        }
+
+        public X509Certificate[] getCertificateChain(String alias) {
+            return certchain;
+        }
+
+        public String[] getClientAliases(String keyType, Principal[] issuers) {
+            return null;
+        }
+
+        public PrivateKey getPrivateKey(String alias) {
+            return key;
+        }
+
+        public String[] getServerAliases(String keyType, Principal[] issuers) {
+            return null;
+        }
+    }
+
+    /**
+     * Implementation of abstract class X509TrustManager.
+     * It is used to authenticate the remote side of a secure socket.
+     */
+    static class MyX509TrustManager implements X509TrustManager {
+
+        public X509Certificate[] getAcceptedIssuers() {
+            return null;
+        }
+
+        public void checkClientTrusted(X509Certificate[] certs, String authType) {
+        }
+
+        public void checkServerTrusted(X509Certificate[] certs, String authType) throws
+                CertificateException {
+        }
+    }
+
+    /**
+     * Non-parametric constructor.
+     */
+    public SSLSend() {
+    }
+    
+    /**
+     * This method is used to send messages using a secure socket.
+     * 
+     * @param keyStoreSender path to user's certificate
+     * @param password password to user's certificate
+     * @param host host name
+     * @param port port number
+     * @param timeout connection timeout
+     * @param message message which will be send
+     */
+    public void send(String keyStoreSender, String password, String host,
+            int port, int timeout, String message) {
+
+        try {
+            KeyStore ks1 = readKeyStore(keyStoreSender, password);
+            
+            String alias = null;
+            for (Enumeration e = ks1.aliases(); e.hasMoreElements();) {
+                String a = (String) e.nextElement();
+                if (ks1.isKeyEntry(a)) {
+                    alias = a;
+                }
+            }
+            
+            PrivateKey privateKey = (PrivateKey) ks1.getKey(alias, password.toCharArray());
+            Certificate[] chain = ks1.getCertificateChain(alias);
+            
+            TrustManager[] trustAllCerts = new TrustManager[]{new MyX509TrustManager()};
+            X509KeyManager[] myKeyManager = new X509KeyManager[]{new MyX509KeyManager(chain, privateKey)};
+
+            SSLContext sctx = SSLContext.getInstance("SSLv3");
+            sctx.init(myKeyManager, trustAllCerts, null);
+
+            SSLSocketFactory factory = sctx.getSocketFactory();
+            
+            connect(factory, host, port, timeout, message);
+        } catch (CertificateException ex) {
+            System.err.println(ex);
+        } catch (KeyManagementException ex) {
+            System.err.println(ex);
+        } catch (KeyStoreException ex) {
+            System.err.println(ex);
+        } catch (NoSuchAlgorithmException ex) {
+            System.err.println(ex);
+        } catch (UnrecoverableKeyException ex) {
+            System.err.println(ex);
+        } catch (Exception ex) {
+            System.err.println(ex);
+        }
+    }
+
+    /**
+     * This method is used to connect to the remote side using SSL sockets. 
+     * After successful connection is send the message.
+     * 
+     * @param factory instance of SSLSocketFactory
+     * @param host host name
+     * @param port port number
+     * @param timeout connection timeout
+     * @param message message which will be send
+     */
+    static void connect(SSLSocketFactory factory, String host, int port, int timeout,
+            String message) {
+        PrintStream osw = null;
+        SSLSocket socket = null;
+        try {
+            socket = (SSLSocket) factory.createSocket();
+
+            socket.setEnabledProtocols(new String[]{"SSLv3"});
+            socket.setUseClientMode(true);
+
+            socket.setSoTimeout(timeout * 10); //read timeout
+            socket.connect(new InetSocketAddress(host, port), timeout); //connect timeout
+
+            socket.startHandshake();
+
+            SSLSession sess = socket.getSession();
+            if (sess == null) {
+                throw new NullPointerException("null session");
+            }
+          
+           message = message.replaceFirst("DG.LLLID=[0-9]* ", ""); 
+           message = message.replaceFirst("DG.USER=\\x22[a-zA-Z ]*\\x22 ", "");
+            System.out.println(message);
+           osw = new PrintStream(socket.getOutputStream(), false);
+            osw.print(EDG_WLL_LOG_SOCKET_HEADER);
+           osw.flush();
+           
+            int messageSize = message.length() + 2;
+           byte revertedInt[] = new byte[4];
+           revertedInt[0] = (byte)(messageSize % 256);
+           messageSize >>= 8;  
+           revertedInt[1] = (byte)(messageSize % 256);
+           messageSize >>= 8;
+           revertedInt[2] = (byte)(messageSize % 256);
+           messageSize >>= 8;
+           revertedInt[3] = (byte)(messageSize); 
+           
+            osw.write(revertedInt, 0, 4);
+           osw.flush(); 
+           
+            osw.print(message + '\n' + '\0');
+           osw.flush();
+        } catch (IOException ex) {
+            System.err.println(ex);
+        } catch (NullPointerException ex) {
+            System.err.println(ex);
+        } finally {
+            osw.close();
+
+            try {
+                socket.close();
+            } catch (IOException ex) {
+                System.err.println(ex);
+            }
+        }
+    }
+
+    /**
+     * This methods reads user's certificate
+     * 
+     * @param ksfile path to certificate
+     * @param password password to certificate
+     * @return instance of KeyStore with certificate
+     * @throws java.security.KeyStoreException
+     * @throws java.security.cert.CertificateException
+     * @throws java.security.NoSuchAlgorithmException
+     * @throws java.io.IOException
+     */
+    static KeyStore readKeyStore(String ksfile, String password) throws
+            KeyStoreException, CertificateException, NoSuchAlgorithmException, IOException {
+        
+        String kstype = null;
+        if (ksfile.endsWith(".ks")) {
+            kstype = "JKS";
+        }
+        if (ksfile.endsWith(".p12")) {
+            kstype = "PKCS12";
+        }
+        if (kstype == null) {
+            throw new KeyStoreException("Unknown key store");
+        }
+
+        KeyStore store = KeyStore.getInstance(kstype);
+        store.load(new FileInputStream(ksfile), password.toCharArray());
+        return store;
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 93%
rename from org.glite.lb.client-java/src/org/glite/lb/client_java/SeqCode.java
rename to org.glite.lb.client-java/src/org/glite/lb/SeqCode.java
index e8450b3..06b1920
@@ -1,4 +1,4 @@
-package org.glite.lb.client_java;
+package org.glite.lb;
 
 /**
  * This class represents sequence code.
@@ -32,8 +32,12 @@ public class SeqCode {
      * 
      * @param part part of sequence number which will be increased
      */
-    public void incrementSeqCode(Sources part) {
-        seqCode[part.source-1]++;
+    public void incrementSeqCode(int part) {
+        if (part <= -1 || part >= Sources.EDG_WLL_SOURCE_LB_SERVER) {
+            throw new IllegalArgumentException("SeqCode part");
+        }
+        
+        seqCode[part-1]++;
     }
     
     /**
old mode 100755 (executable)
new mode 100644 (file)
similarity index 96%
rename from org.glite.lb.client-java/src/org/glite/lb/client_java/Sources.java
rename to org.glite.lb.client-java/src/org/glite/lb/Sources.java
index af48310..c4e7ba0
@@ -1,4 +1,4 @@
-package org.glite.lb.client_java;
+package org.glite.lb;
 
 /**
  * Enum which represents type if sources.
diff --git a/org.glite.lb.client-java/src/org/glite/lb/client_java/ContextProxy.java b/org.glite.lb.client-java/src/org/glite/lb/client_java/ContextProxy.java
deleted file mode 100755 (executable)
index 581d521..0000000
+++ /dev/null
@@ -1,279 +0,0 @@
-package org.glite.lb.client_java;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.RandomAccessFile;
-import java.net.InetSocketAddress;
-import java.net.UnknownHostException;
-import java.nio.channels.FileChannel;
-import java.nio.channels.FileLock;
-import java.util.ArrayList;
-import javax.net.ssl.SSLSocket;
-import javax.net.ssl.SSLSocketFactory;
-import org.glite.jobid.api_java.Jobid;
-import org.glite.jobid.api_java.CheckedString;
-
-/** NOT IMPLEMENTED YET! THIS IS ONLY SKELETON
- *
- * @author xpiskac
- */
-public class ContextProxy extends Context {
-
-    private String address;
-    private int port;
-    private String prefix;
-    private int repeatWriteToFile = 5;
-    private int timeout = 30000;
-    private String pathToCertificate;
-    private String password;
-
-    public ContextProxy() {
-    }
-
-    public ContextProxy(String address, int port, String prefix) {
-        this.prefix = new CheckedString(prefix).toString();
-        this.address = new CheckedString(address).toString();
-        this.port = port;
-    }
-
-    public ContextProxy(int id,
-            Sources source,
-            int flag,
-            String host,
-            String user,
-            String prog,
-            String srcInstance,
-            Jobid jobid,
-            String address,
-            int port,
-            String prefix) {
-
-        super(id, source, flag, host, user, prog, srcInstance, jobid);
-
-        if (prefix == null) {
-            throw new IllegalArgumentException("ContextProxy prefix");
-        }
-        if (address == null) {
-            throw new IllegalArgumentException("ContextProxy socket");
-        }
-        if (port < 0) {
-            throw new IllegalArgumentException("ContextProxy port");
-        }
-
-        this.prefix = new CheckedString(prefix).toString();
-        this.address = new CheckedString(address).toString();
-    }
-
-    /**
-     * Writes message to a file and returns size of this file before writing the
-     * data
-     * @param prefix file path
-     * @param message message which will be written
-     * @return size of the file before writing the data
-     */
-    private Long writeToFile(String prefix, String message) {
-        FileWriter fileWriter = null;
-        Long fileLength = null;
-        RandomAccessFile raf = null;
-        FileLock fileLock = null;
-        File file;
-                
-        for (int i = 0; i < repeatWriteToFile; i++) {
-            try {
-                file = new File(prefix);
-                raf = new RandomAccessFile(file, "rw");
-                FileChannel fileChannel = raf.getChannel();
-
-                fileLock = fileChannel.tryLock();
-                if (fileLock != null) {
-                    if (!file.exists()) {
-                        continue;
-                    }
-                    fileLength = new Long(raf.length());
-                    fileWriter = new FileWriter(file, true);
-                    //true means append data to the end of file
-                    
-                    BufferedWriter bufferedFileWriter = new BufferedWriter(fileWriter);
-
-                    bufferedFileWriter.write(message + '\n');
-                    bufferedFileWriter.flush();
-                    
-                    if (file.exists()) {
-                        break;
-                    }
-                }
-            } catch (FileNotFoundException ex) {
-                System.err.println(ex);
-            } catch (IOException ex) {
-                System.err.println(ex);
-            } catch (Exception ex) {
-                System.err.println(ex);
-            } finally {
-                if (fileLock != null) {
-                    try {
-                        fileLock.release();
-                    } catch (IOException ex) {
-                        System.err.println(ex);
-                    }
-                }
-                
-                try {
-                    raf.close();
-                } catch (IOException ex) {
-                    System.err.println(ex);
-                }
-            }
-        }
-        
-        return fileLength;
-    }
-    
-    private void writeToSocket(String address, int port, int timeout, long fileSize, String message) {
-        // From http://sci.civ.zcu.cz/java/lbexample.zip ExampleSSLSocketFactory.java
-        SSLSocketFactory sslFactory = null;
-        try {
-            SSLSocket socket = (SSLSocket) sslFactory.createSocket();
-            //enable only SSLv3
-            socket.setEnabledProtocols(new String[]{"SSLv3"});   //  SSLv2Hello, SSLv3,TLSv1
-            //enable only ciphers without RC4 (some bug in JSSE?)
-            String[] ciphers = socket.getEnabledCipherSuites();
-//            ArrayList<String> al = new ArrayList<String>(ciphers.length);
-            ArrayList al = new ArrayList(ciphers.length);
-            for (int i = 0; i < ciphers.length; i++) {
-                if (ciphers[i].indexOf("RC4") == -1) al.add(ciphers[i]);
-            }
-            socket.setEnabledCipherSuites((String [])al.toArray(new String[al.size()]));
-            //connect as client
-            socket.setUseClientMode(true);
-            socket.setSoTimeout(timeout); //read timeout
-            socket.connect(new InetSocketAddress(address, port), timeout); //connect timeout
-            PrintWriter osw =
-                    new PrintWriter(socket.getOutputStream(), true);
-            osw.println(fileSize);
-            osw.println(message);
-            osw.close();
-            socket.close();
-        } catch (UnknownHostException ex) {
-            System.err.println("unknown host " + ex);
-        } catch (IOException ex) {
-            System.err.println("io exception " + ex);
-        }
-    }
-
-    public void log(Event event) {
-        if (event == null) {
-            throw new IllegalArgumentException("ContextProxy event");
-        }
-
-        if (prefix == null) {
-            throw new IllegalArgumentException("ContextProxy prefix");
-        }
-
-        if (address == null) {
-            throw new IllegalArgumentException("ContextProxy socket");
-        }
-
-        if (port < 0) {
-            throw new IllegalArgumentException("ContextProxy port");
-        }
-
-        super.log(event);
-        String message = super.getMessage();
-
-        Long fileSize = writeToFile(prefix, message);
-        
-        //writeToSocket(address, port, timeout, fileSize, message);
-        
-        //SSLSend sslSend = new SSLSend(keyStoreSender, password, address,
-        //    port, timeout, fileSize, message);
-    }
-
-    public String getAddress() {
-        return address;
-    }
-
-    public void setAddress(String address) {
-        if (prefix == null) {
-            throw new IllegalArgumentException("ContextProxy address");
-        }
-        
-        this.address = new CheckedString(address).toString();
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public void setPort(int port) {
-        if (port < 0) {
-            throw new IllegalArgumentException("ContextProxy port");
-        }
-        this.port = port;
-    }
-    
-    
-    public String getPrefix() {
-        return prefix;
-    }
-
-    public void setPrefix(String prefix) {
-        if (prefix == null) {
-            throw new IllegalArgumentException("ContextProxy prefix");
-        }
-        
-        this.prefix = new CheckedString(prefix).toString();
-    }
-
-    public int getRepeatWriteToFile() {
-        return repeatWriteToFile;
-    }
-
-    public void setRepeatWriteToFile(int repeatWriteToFile) {
-        if (repeatWriteToFile < 1) {
-            throw new IllegalArgumentException("ContextProxy repeatWriteToFile");
-        }
-        
-        this.repeatWriteToFile = repeatWriteToFile;
-    }
-
-    public int getTimeout() {
-        return timeout;
-    }
-
-    public void setTimeout(int timeout) {
-        if (timeout < 0) {
-            throw new IllegalArgumentException("ContextProxy timout");
-        }
-        this.timeout = timeout;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        if (password == null) {
-            throw new IllegalArgumentException("ContextProxy password");
-        }
-        
-        this.password = password;
-    }
-
-    public String getPathToCertificate() {
-        return pathToCertificate;
-    }
-
-    public void setPathToCertificate(String pathToCertificate) {
-        if (pathToCertificate == null) {
-            throw new IllegalArgumentException("ContextProxy pathToCertificate");
-        }
-        
-        this.pathToCertificate = pathToCertificate;
-    }
-
-    
-}
diff --git a/org.glite.lb.client-java/src/org/glite/lb/client_java/Running.java b/org.glite.lb.client-java/src/org/glite/lb/client_java/Running.java
deleted file mode 100755 (executable)
index 1389b60..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.glite.lb.client_java;
-
-import org.glite.jobid.api_java.CheckedString;
-
-/**
- * Class which represents event "running".
- * 
- * @author Pavel Piskac (173297@mail.muni.cz)
- */
-public class Running extends Event {
-    
-    private String node;
-    
-    /**
-     * Creates new instance.
-     */
-    public Running() {
-    }
-    
-    /**
-     * Creates new instance, where is set variable node.
-     * @param node node
-     */
-    public Running(String node) {
-        if (node == null) {
-            node = new String("");
-        }
-        
-        this.node = node;
-    }
-
-    /**
-     * Returns part of message, which will be joined to the of the message. 
-     * Its format is " DG.RUNNING.NODE=\"" + node + "\""
-     * @return part of message which is specific for event running 
-     */
-    public String ulm() {  
-        return (" DG.RUNNING.NODE=\"" + node + "\"");
-    }
-    
-    /**
-     * Returns event type specific for event running ("Running").
-     * 
-     * @return event type
-     */
-    public String getEventType() {
-        return "Running";
-    }
-    
-    /**
-     * Gets node.
-     * 
-     * @return node
-     */
-    public String getNode() {
-        return node;
-    }
-
-    /**
-     * Sets node, if node is null then it is "" set.
-     * @param node
-     */
-    public void setNode(String node) {
-        if (node == null) {
-            node = new String("");
-        }
-        
-        this.node = new CheckedString(node).toString();
-    }
-}
diff --git a/org.glite.lb.client-java/src/org/glite/lb/client_java/Transfer.java b/org.glite.lb.client-java/src/org/glite/lb/client_java/Transfer.java
deleted file mode 100755 (executable)
index a9c6770..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-package org.glite.lb.client_java;
-
-/**
- *
- * @author xpiskac
- */
-public class Transfer extends Event {
-    
-    private String destination;
-    private String destHostname;
-    private String destInstance;
-    private String jobDescription;
-    private String result;
-    private String reason;
-    private String destJobid;
-    
-    public Transfer() {
-    }
-    
-    public Transfer (String destination,
-                     String destHostname,
-                     String destInstance,
-                     String jobDescription,
-                     String result,
-                     String reason,
-                     String destJobid) {
-        
-        this.destination = destination;
-        this.destHostname = destHostname;
-        this.destInstance = destInstance;
-        this.jobDescription = jobDescription;
-        this.result = result;
-        this.reason = reason;
-        this.destJobid = destJobid;
-    }
-
-    public String ulm() {
-        return null; //zatim neimplementovano
-    }
-    
-    public String getEventType() {
-        return "Transfer";
-    }
-    
-    public String getDestHostname() {
-        return destHostname;
-    }
-
-    public void setDestHostname(String destHostname) {
-        this.destHostname = destHostname;
-    }
-
-    public String getDestInstance() {
-        return destInstance;
-    }
-
-    public void setDestInstance(String destInstance) {
-        this.destInstance = destInstance;
-    }
-
-    public String getDestJobid() {
-        return destJobid;
-    }
-
-    public void setDestJobid(String destJobid) {
-        this.destJobid = destJobid;
-    }
-
-    public String getDestination() {
-        return destination;
-    }
-
-    public void setDestination(String destination) {
-        this.destination = destination;
-    }
-
-    public String getJobDescription() {
-        return jobDescription;
-    }
-
-    public void setJobDescription(String jobDescription) {
-        this.jobDescription = jobDescription;
-    }
-
-    public String getReason() {
-        return reason;
-    }
-
-    public void setReason(String reason) {
-        this.reason = reason;
-    }
-
-    public String getResult() {
-        return result;
-    }
-
-    public void setResult(String result) {
-        this.result = result;
-    }
-}