1   package ch.ige.edossier.web.test;
2   
3   import java.io.File;
4   import java.io.FileInputStream;
5   import java.io.IOException;
6   import java.sql.SQLException;
7   import ch.ige.edossier.web.server.dao.InterceptionDAO;
8   import ch.ige.edossier.web.vo.InterceptionVO;
9   
10  /**
11   * B32.03 - eDossier-Interceptions - Diplomarbeit an der Software-Schule Schweiz<br>
12   * Die Klasse InterceptionTest wird verwendet um Nachträglich Bilder in die Datenbank zu publizieren.
13   * <p>
14   * Copyright (c) 2004, Eidgenössisches Institut für Geistiges Eigentum
15   * @author    Anita Rueegsegger, Marc Bouquet
16   * @version   $Id: InterceptionTest.java,v 1.4 2004/11/02 02:01:53 bouquet Exp $
17   */
18  public class InterceptionTest
19  {
20    public InterceptionTest()
21    {
22      selectInterceptions();
23    }
24  
25  //  private static byte[] getFile()
26  //  {
27  //    String filename = "c://temp/test.pdf";
28  //    FileInputStream in = null;
29  //    try
30  //    {
31  //      File f = new File( filename );
32  //      byte buffer[] = new byte[ ( int )f.length() ];
33  //      in = new FileInputStream( f );
34  //
35  //      in = new FileInputStream( filename );
36  //      int len = in.read( buffer, 0, ( int )f.length() );
37  //      String str = new String( buffer, 0, len );
38  //      System.out.println( str );
39  //      return buffer;
40  //    }
41  //    catch( IOException e )
42  //    {
43  //      System.out.println( e );
44  //    }
45  //    finally
46  //    {
47  //      if( in != null )
48  //      {
49  //        try
50  //        {
51  //          in.close();
52  //        }
53  //        catch( IOException ioex )
54  //        {
55  //          System.out.println( "IOException: " + ioex.getMessage() );
56  //        }
57  //      }
58  //    }
59  //    return null;
60  //  }
61  
62    private void selectInterceptions()
63    {
64      try
65      {
66        InterceptionVO interceptionVO = new InterceptionDAO().select( 5293340 );
67  
68  //      String text = interceptionVO.getText();
69  //      text = text.replaceAll("<br>", "\n");
70  //      interceptionVO.setText(text);
71  //
72  //      String titel = interceptionVO.getTitel();
73  //      titel = titel.replaceAll("<br>", "\n");
74  //      titel = titel.replaceAll("http://wdl.ige.ch", "<a href=\"http://wdl.ige.ch\">http://wdl.ige.ch</a>");
75  //      interceptionVO.setTitel(titel);
76        System.out.println( interceptionVO.toString() );
77      }
78      catch( Exception ex )
79      {
80        ex.printStackTrace();
81      }
82    }
83  
84    public static void main( String[] args )
85    {
86      new InterceptionTest();
87  //    InterceptionVO interceptionVO = new InterceptionVO();
88  //
89  //    interceptionVO.setInterceptionId( 2222 );
90  //    interceptionVO.setPdf( getFile() );
91  //
92  //    System.out.println( interceptionVO.toString() );
93  //
94  //    try
95  //    {
96  //      new InterceptionDAO().insertPdf( interceptionVO );
97  //    }
98  //    catch( SQLException ex )
99  //    {
100 //      System.out.println( "SQL-Fehler: " + ex.getMessage() );
101 //    }
102   }
103 }
104