1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir package convwatch;
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir // imports
31*cdf0e10cSrcweir import java.util.ArrayList;
32*cdf0e10cSrcweir import java.io.File;
33*cdf0e10cSrcweir import java.io.FileFilter;
34*cdf0e10cSrcweir 
35*cdf0e10cSrcweir import convwatch.EnhancedComplexTestCase;
36*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir import convwatch.ConvWatchException;
39*cdf0e10cSrcweir import convwatch.DirectoryHelper;
40*cdf0e10cSrcweir import convwatch.GraphicalTestArguments;
41*cdf0e10cSrcweir import convwatch.HTMLOutputter;
42*cdf0e10cSrcweir import helper.OfficeProvider;
43*cdf0e10cSrcweir import helper.OfficeWatcher;
44*cdf0e10cSrcweir import helper.OSHelper;
45*cdf0e10cSrcweir import convwatch.PerformanceContainer;
46*cdf0e10cSrcweir 
47*cdf0e10cSrcweir /**
48*cdf0e10cSrcweir  * The following Complex Test will test
49*cdf0e10cSrcweir  * an already created document and it's postscript output (by an older office version)
50*cdf0e10cSrcweir  * with a new office version.
51*cdf0e10cSrcweir  * This test use Ghostscript for the jpeg export and graphically compare tools from ImageMagick.
52*cdf0e10cSrcweir  * Read the manual for more information.
53*cdf0e10cSrcweir  *
54*cdf0e10cSrcweir  * this is only the starter program
55*cdf0e10cSrcweir  * more is found in qadevOOo/runner/convwatch/*
56*cdf0e10cSrcweir  */
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir public class ConvWatchStarter extends EnhancedComplexTestCase
59*cdf0e10cSrcweir {
60*cdf0e10cSrcweir     // The first of the mandatory functions:
61*cdf0e10cSrcweir     /**
62*cdf0e10cSrcweir      * Return the name of the test.
63*cdf0e10cSrcweir      * In this case it is the actual name of the service.
64*cdf0e10cSrcweir      * @return The tested service.
65*cdf0e10cSrcweir      */
66*cdf0e10cSrcweir     // public String getTestObjectName() {
67*cdf0e10cSrcweir     //     return "ConvWatch runner";
68*cdf0e10cSrcweir     // }
69*cdf0e10cSrcweir 
70*cdf0e10cSrcweir     // The second of the mandatory functions: return all test methods as an
71*cdf0e10cSrcweir     // array. There is only one test function in this example.
72*cdf0e10cSrcweir     /**
73*cdf0e10cSrcweir      * Return all test methods.
74*cdf0e10cSrcweir      * @return The test methods.
75*cdf0e10cSrcweir      */
76*cdf0e10cSrcweir     public String[] getTestMethodNames() {
77*cdf0e10cSrcweir         return new String[]{"compareGraphicalDiffs"};
78*cdf0e10cSrcweir     }
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir     String m_sInputPath = "";
81*cdf0e10cSrcweir     String m_sReferencePath = "";
82*cdf0e10cSrcweir     String m_sOutputPath = "";
83*cdf0e10cSrcweir     String m_sDiffPath = null;
84*cdf0e10cSrcweir 
85*cdf0e10cSrcweir     private void initMember()
86*cdf0e10cSrcweir         {
87*cdf0e10cSrcweir             // MUST PARAMETER
88*cdf0e10cSrcweir             // INPUTFILE ----------
89*cdf0e10cSrcweir             String sINPATH = (String)param.get( PropertyName.DOC_COMPARATOR_INPUT_PATH );
90*cdf0e10cSrcweir             boolean bQuit = false;
91*cdf0e10cSrcweir             if (sINPATH == null || sINPATH.length() == 0)
92*cdf0e10cSrcweir             {
93*cdf0e10cSrcweir                 log.println("Please set input path (path to documents) " + PropertyName.DOC_COMPARATOR_INPUT_PATH + "=path.");
94*cdf0e10cSrcweir                 bQuit = true;
95*cdf0e10cSrcweir             }
96*cdf0e10cSrcweir             else
97*cdf0e10cSrcweir             {
98*cdf0e10cSrcweir                 log.println("found " + PropertyName.DOC_COMPARATOR_INPUT_PATH + " " + sINPATH);
99*cdf0e10cSrcweir                 m_sInputPath = sINPATH;
100*cdf0e10cSrcweir             }
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir             // REFERENCE_PATH ----------
103*cdf0e10cSrcweir             String sREF = (String)param.get( PropertyName.DOC_COMPARATOR_REFERENCE_PATH );
104*cdf0e10cSrcweir             if (sREF == null || sREF.length() == 0)
105*cdf0e10cSrcweir             {
106*cdf0e10cSrcweir                 // log.println("Please set reference file (path to good documents) REFERENCEFILE=path.");
107*cdf0e10cSrcweir                 log.println("Assumtion, reference directory and input directory are the same.");
108*cdf0e10cSrcweir                 m_sReferencePath = m_sInputPath;
109*cdf0e10cSrcweir             }
110*cdf0e10cSrcweir             else
111*cdf0e10cSrcweir             {
112*cdf0e10cSrcweir                 log.println("found " + PropertyName.DOC_COMPARATOR_REFERENCE_PATH + " " + sREF);
113*cdf0e10cSrcweir                 m_sReferencePath = sREF;
114*cdf0e10cSrcweir             }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir             // OUTPUT_PATH ----------
117*cdf0e10cSrcweir             String sOUT = (String)param.get( PropertyName.DOC_COMPARATOR_OUTPUT_PATH );
118*cdf0e10cSrcweir             if (sOUT == null || sOUT.length() == 0)
119*cdf0e10cSrcweir             {
120*cdf0e10cSrcweir                 log.println("Please set output path (path to a temp directory) " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + "=path.");
121*cdf0e10cSrcweir                 bQuit = true;
122*cdf0e10cSrcweir             }
123*cdf0e10cSrcweir             else
124*cdf0e10cSrcweir             {
125*cdf0e10cSrcweir                 log.println("found " + PropertyName.DOC_COMPARATOR_OUTPUT_PATH + " " + sOUT);
126*cdf0e10cSrcweir                 m_sOutputPath = sOUT;
127*cdf0e10cSrcweir             }
128*cdf0e10cSrcweir 
129*cdf0e10cSrcweir             if (bQuit == true)
130*cdf0e10cSrcweir             {
131*cdf0e10cSrcweir                 // log.println("must quit.");
132*cdf0e10cSrcweir                 assure("Must quit", false);
133*cdf0e10cSrcweir             }
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir             // DIFF_PATH ----------
137*cdf0e10cSrcweir             String sDIFF = (String)param.get( PropertyName.DOC_COMPARATOR_DIFF_PATH );
138*cdf0e10cSrcweir             if (sDIFF == null || sDIFF.length() == 0)
139*cdf0e10cSrcweir             {
140*cdf0e10cSrcweir             }
141*cdf0e10cSrcweir             else
142*cdf0e10cSrcweir             {
143*cdf0e10cSrcweir                 log.println("found " + PropertyName.DOC_COMPARATOR_DIFF_PATH + " " + sDIFF);
144*cdf0e10cSrcweir                 m_sDiffPath = sDIFF;
145*cdf0e10cSrcweir             }
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir             if (m_sInputPath.startsWith("file:") ||
148*cdf0e10cSrcweir                 m_sReferencePath.startsWith("file:") ||
149*cdf0e10cSrcweir                 m_sOutputPath.startsWith("file:"))
150*cdf0e10cSrcweir             {
151*cdf0e10cSrcweir                 assure("We can't handle file: URL right, use system path instead.", false);
152*cdf0e10cSrcweir             }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         }
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir     /**
158*cdf0e10cSrcweir      *
159*cdf0e10cSrcweir      * @return a List of software which must accessable as an external executable
160*cdf0e10cSrcweir      */
161*cdf0e10cSrcweir     protected Object[] mustInstalledSoftware()
162*cdf0e10cSrcweir         {
163*cdf0e10cSrcweir             ArrayList aList = new ArrayList();
164*cdf0e10cSrcweir             // Tools from ImageMagick
165*cdf0e10cSrcweir             if (! OSHelper.isWindows())
166*cdf0e10cSrcweir             {
167*cdf0e10cSrcweir             aList.add( "composite -version" );
168*cdf0e10cSrcweir             aList.add( "identify -version" );
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir             // Ghostscript
171*cdf0e10cSrcweir             aList.add( "gs -version" );
172*cdf0e10cSrcweir             }
173*cdf0e10cSrcweir             else
174*cdf0e10cSrcweir             {
175*cdf0e10cSrcweir                 aList.add( "composite.exe -version" );
176*cdf0e10cSrcweir                 aList.add( "identify.exe -version" );
177*cdf0e10cSrcweir 
178*cdf0e10cSrcweir                 // Ghostscript
179*cdf0e10cSrcweir                 aList.add( "gswin32c.exe -version" );
180*cdf0e10cSrcweir             }
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir             return aList.toArray();
183*cdf0e10cSrcweir         }
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir     /**
187*cdf0e10cSrcweir      * The test method itself.
188*cdf0e10cSrcweir      * Don't try to call it from outside, it is started only from qadevOOo runner
189*cdf0e10cSrcweir      */
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir     /* protected */
192*cdf0e10cSrcweir     public void compareGraphicalDiffs()
193*cdf0e10cSrcweir         {
194*cdf0e10cSrcweir             GlobalLogWriter.set(log);
195*cdf0e10cSrcweir             String sDBConnection = (String)param.get( PropertyName.DB_CONNECTION_STRING );
196*cdf0e10cSrcweir             // check if all need software is installed and accessable
197*cdf0e10cSrcweir             checkEnvironment(mustInstalledSoftware());
198*cdf0e10cSrcweir 
199*cdf0e10cSrcweir             GraphicalTestArguments aGTA = getGraphicalTestArguments();
200*cdf0e10cSrcweir             if (aGTA == null)
201*cdf0e10cSrcweir             {
202*cdf0e10cSrcweir                 assure("Must quit", false);
203*cdf0e10cSrcweir             }
204*cdf0e10cSrcweir             if (aGTA.cancelRequest())
205*cdf0e10cSrcweir             {
206*cdf0e10cSrcweir                 return;
207*cdf0e10cSrcweir             }
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir             initMember();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir             aGTA.allowStore();
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir             String sBuildID = aGTA.getBuildID();
214*cdf0e10cSrcweir             log.println("Current Office has buildid: " + sBuildID);
215*cdf0e10cSrcweir 
216*cdf0e10cSrcweir             // LLA: sample code, how to access all parameters
217*cdf0e10cSrcweir             // for (Enumeration e = param.keys() ; e.hasMoreElements() ;)
218*cdf0e10cSrcweir             // {
219*cdf0e10cSrcweir             //     System.out.println(e.nextElement());
220*cdf0e10cSrcweir             // }
221*cdf0e10cSrcweir 
222*cdf0e10cSrcweir             String fs = System.getProperty("file.separator");
223*cdf0e10cSrcweir 
224*cdf0e10cSrcweir             String sHTMLName = "index.html";
225*cdf0e10cSrcweir             File aInputPathTest = new File(m_sInputPath);
226*cdf0e10cSrcweir             if (!aInputPathTest.isDirectory())
227*cdf0e10cSrcweir             {
228*cdf0e10cSrcweir                 int n = m_sInputPath.lastIndexOf(fs);
229*cdf0e10cSrcweir                 sHTMLName = m_sInputPath.substring(n + 1);
230*cdf0e10cSrcweir                 sHTMLName += ".html";
231*cdf0e10cSrcweir             }
232*cdf0e10cSrcweir             HTMLOutputter HTMLoutput = HTMLOutputter.create(m_sOutputPath, sHTMLName, "", "");
233*cdf0e10cSrcweir             HTMLoutput.header( m_sOutputPath );
234*cdf0e10cSrcweir             HTMLoutput.indexSection( m_sOutputPath );
235*cdf0e10cSrcweir             LISTOutputter LISToutput = LISTOutputter.create(m_sOutputPath, "allfiles.txt");
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir             DB.init(aGTA.getDBInfoString() + "," + sDBConnection);
238*cdf0e10cSrcweir 
239*cdf0e10cSrcweir             File aInputPath = new File(m_sInputPath);
240*cdf0e10cSrcweir             if (aInputPath.isDirectory())
241*cdf0e10cSrcweir             {
242*cdf0e10cSrcweir                 // check a whole directory
243*cdf0e10cSrcweir                 // a whole directory
244*cdf0e10cSrcweir                 FileFilter aFileFilter = FileHelper.getFileFilter();
245*cdf0e10cSrcweir 
246*cdf0e10cSrcweir                 Object[] aList = DirectoryHelper.traverse(m_sInputPath, aFileFilter, aGTA.includeSubDirectories());
247*cdf0e10cSrcweir                 if (aList.length == 0)
248*cdf0e10cSrcweir                 {
249*cdf0e10cSrcweir                     log.println("Nothing to do, there are no document files found.");
250*cdf0e10cSrcweir                 }
251*cdf0e10cSrcweir                 else
252*cdf0e10cSrcweir                 {
253*cdf0e10cSrcweir                     for (int i=0;i<aList.length;i++)
254*cdf0e10cSrcweir                     {
255*cdf0e10cSrcweir                         String sEntry = (String)aList[i];
256*cdf0e10cSrcweir                         log.println("- next file is: ------------------------------");
257*cdf0e10cSrcweir                         log.println(sEntry);
258*cdf0e10cSrcweir 
259*cdf0e10cSrcweir                         String sNewSubDir = FileHelper.removeFirstDirectorysAndBasenameFrom(sEntry, m_sInputPath);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir                         String sNewReferencePath = m_sReferencePath;
262*cdf0e10cSrcweir                         String sNewOutputPath = m_sOutputPath;
263*cdf0e10cSrcweir                         String sNewDiffPath = m_sDiffPath;
264*cdf0e10cSrcweir                         if (sNewSubDir.length() > 0)
265*cdf0e10cSrcweir                         {
266*cdf0e10cSrcweir                             if (sNewReferencePath != null)
267*cdf0e10cSrcweir                                 sNewReferencePath = sNewReferencePath + fs + sNewSubDir;
268*cdf0e10cSrcweir                             // String sNameNoSuffix = FileHelper.getNameNoSuffix(FileHelper.getBasename(sEntry));
269*cdf0e10cSrcweir                             // sNewReferenceFile = sNewReferencePath + fs + sNameNoSuffix + ".prn";
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir                             sNewOutputPath = sNewOutputPath + fs + sNewSubDir;
272*cdf0e10cSrcweir                             if (sNewDiffPath != null)
273*cdf0e10cSrcweir                                 sNewDiffPath = sNewDiffPath + fs + sNewSubDir;
274*cdf0e10cSrcweir                         }
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir                         // NameHelper aNameContainer = new NameHelper(m_sOutputPath, sNewSubDir, FileHelper.getBasename(sEntry));
277*cdf0e10cSrcweir                         // aNameContainer.print();
278*cdf0e10cSrcweir 
279*cdf0e10cSrcweir                         if (aGTA.checkIfUsableDocumentType(sEntry))
280*cdf0e10cSrcweir                         {
281*cdf0e10cSrcweir                             runGDCWithStatus(HTMLoutput, LISToutput, sEntry, sNewOutputPath, sNewReferencePath, sNewDiffPath, sNewSubDir);
282*cdf0e10cSrcweir                         }
283*cdf0e10cSrcweir                         if (aGTA.cancelRequest())
284*cdf0e10cSrcweir                         {
285*cdf0e10cSrcweir                             break;
286*cdf0e10cSrcweir                         }
287*cdf0e10cSrcweir                     }
288*cdf0e10cSrcweir                 }
289*cdf0e10cSrcweir             }
290*cdf0e10cSrcweir             else
291*cdf0e10cSrcweir             {
292*cdf0e10cSrcweir                 // check exact name
293*cdf0e10cSrcweir                 if (aGTA.checkIfUsableDocumentType(m_sInputPath))
294*cdf0e10cSrcweir                 {
295*cdf0e10cSrcweir                     runGDCWithStatus(HTMLoutput, LISToutput, m_sInputPath, m_sOutputPath, m_sReferencePath, m_sDiffPath, "");
296*cdf0e10cSrcweir                 }
297*cdf0e10cSrcweir             }
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir             LISToutput.close();
300*cdf0e10cSrcweir             HTMLoutput.close();
301*cdf0e10cSrcweir             log.println("The file '" + HTMLoutput.getFilename() + "' shows a html based status.");
302*cdf0e10cSrcweir             DB.writeHTMLFile(HTMLoutput.getFilename());
303*cdf0e10cSrcweir         }
304*cdf0e10cSrcweir 
305*cdf0e10cSrcweir 
306*cdf0e10cSrcweir     // -----------------------------------------------------------------------------
307*cdf0e10cSrcweir     void runGDCWithStatus(HTMLOutputter _aHTMLoutput, LISTOutputter _aLISToutput, String _sInputFile, String _sOutputPath, String _sReferencePath, String _sDiffPath, String _sNewSubDir )
308*cdf0e10cSrcweir         {
309*cdf0e10cSrcweir             // start a fresh Office
310*cdf0e10cSrcweir             GraphicalTestArguments aGTA = getGraphicalTestArguments();
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir             OfficeProvider aProvider = null;
313*cdf0e10cSrcweir             // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
314*cdf0e10cSrcweir             if (aGTA.shouldOfficeStart())
315*cdf0e10cSrcweir             {
316*cdf0e10cSrcweir                 // if (OSHelper.isWindows())
317*cdf0e10cSrcweir                 // {
318*cdf0e10cSrcweir                 //     aSemaphore.P(aSemaphore.getSemaphoreFile());
319*cdf0e10cSrcweir                 // }
320*cdf0e10cSrcweir 
321*cdf0e10cSrcweir                 aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
322*cdf0e10cSrcweir                 aProvider = new OfficeProvider();
323*cdf0e10cSrcweir                 XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
324*cdf0e10cSrcweir                 param.put("ServiceFactory", xMSF);
325*cdf0e10cSrcweir                 aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);
326*cdf0e10cSrcweir 
327*cdf0e10cSrcweir                 long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
328*cdf0e10cSrcweir                 aGTA = getGraphicalTestArguments(); // get new TestArguments
329*cdf0e10cSrcweir                 aGTA.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
330*cdf0e10cSrcweir             }
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir             // Watcher Object is need in log object to give a simple way to say if a running office is alive.
333*cdf0e10cSrcweir             // As long as a log comes, it pings the Watcher and says the office is alive, if not an
334*cdf0e10cSrcweir             // internal counter increase and at a given point (300 seconds) the office is killed.
335*cdf0e10cSrcweir             GlobalLogWriter.get().println("Set office watcher");
336*cdf0e10cSrcweir             OfficeWatcher aWatcher = (OfficeWatcher)param.get("Watcher");
337*cdf0e10cSrcweir             GlobalLogWriter.get().setWatcher(aWatcher);
338*cdf0e10cSrcweir             // initializeWatcher(param);
339*cdf0e10cSrcweir 
340*cdf0e10cSrcweir             String sStatusRunThrough = "";
341*cdf0e10cSrcweir             String sStatusMessage = "";
342*cdf0e10cSrcweir             try
343*cdf0e10cSrcweir             {
344*cdf0e10cSrcweir                 DB.destination_start();
345*cdf0e10cSrcweir                 // better was:
346*cdf0e10cSrcweir                 // load document
347*cdf0e10cSrcweir                 // create postscript from document
348*cdf0e10cSrcweir                 // check file
349*cdf0e10cSrcweir                 GraphicalDifferenceCheck.checkOneFile(_sInputFile, _sOutputPath, _sReferencePath, _sDiffPath, aGTA);
350*cdf0e10cSrcweir                 sStatusRunThrough = "PASSED, OK";
351*cdf0e10cSrcweir                 DB.destination_finished();
352*cdf0e10cSrcweir             }
353*cdf0e10cSrcweir             catch(ConvWatchCancelException e)
354*cdf0e10cSrcweir             {
355*cdf0e10cSrcweir                 assure(e.getMessage(), false, true);
356*cdf0e10cSrcweir                 sStatusRunThrough = "CANCELLED, FAILED";
357*cdf0e10cSrcweir                 sStatusMessage = e.getMessage();
358*cdf0e10cSrcweir                 DB.destination_failed(sStatusRunThrough, sStatusMessage);
359*cdf0e10cSrcweir             }
360*cdf0e10cSrcweir             catch(ConvWatchException e)
361*cdf0e10cSrcweir             {
362*cdf0e10cSrcweir                 assure(e.getMessage(), false, true);
363*cdf0e10cSrcweir                 sStatusMessage = e.getMessage();
364*cdf0e10cSrcweir                 sStatusRunThrough = "PASSED, FAILED";
365*cdf0e10cSrcweir                 DB.destination_failed(sStatusRunThrough, sStatusMessage);
366*cdf0e10cSrcweir             }
367*cdf0e10cSrcweir             catch(com.sun.star.lang.DisposedException e)
368*cdf0e10cSrcweir             {
369*cdf0e10cSrcweir                 assure(e.getMessage(), false, true);
370*cdf0e10cSrcweir                 sStatusMessage = e.getMessage();
371*cdf0e10cSrcweir                 sStatusRunThrough = "FAILED, FAILED";
372*cdf0e10cSrcweir                 DB.destination_failed(sStatusRunThrough, sStatusMessage);
373*cdf0e10cSrcweir             }
374*cdf0e10cSrcweir 
375*cdf0e10cSrcweir             GlobalLogWriter.get().println("Watcher count is: " + aWatcher.getPing());
376*cdf0e10cSrcweir 
377*cdf0e10cSrcweir             // Office shutdown
378*cdf0e10cSrcweir             if (aProvider != null)
379*cdf0e10cSrcweir             {
380*cdf0e10cSrcweir                 aProvider.closeExistingOffice(param, true);
381*cdf0e10cSrcweir                 // if (OSHelper.isWindows())
382*cdf0e10cSrcweir                 // {
383*cdf0e10cSrcweir                 //     aSemaphore.V(aSemaphore.getSemaphoreFile());
384*cdf0e10cSrcweir                 //     aSemaphore.sleep(2);
385*cdf0e10cSrcweir                 //     // wait some time maybe an other process will take the semaphore
386*cdf0e10cSrcweir                 //     // I know, this is absolutly dirty, but the whole convwatch is dirty and need a big cleanup.
387*cdf0e10cSrcweir                 // }
388*cdf0e10cSrcweir             }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir             // -------------------- Status --------------------
391*cdf0e10cSrcweir             String fs = System.getProperty("file.separator");
392*cdf0e10cSrcweir             String sBasename = FileHelper.getBasename(_sInputFile);
393*cdf0e10cSrcweir             String sFilenameNoSuffix = FileHelper.getNameNoSuffix(sBasename);
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir             // -------------------- List of all files -----------------
396*cdf0e10cSrcweir             String sListFile;
397*cdf0e10cSrcweir             if (_sNewSubDir.length() > 0)
398*cdf0e10cSrcweir             {
399*cdf0e10cSrcweir                 sListFile = _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
400*cdf0e10cSrcweir             }
401*cdf0e10cSrcweir             else
402*cdf0e10cSrcweir             {
403*cdf0e10cSrcweir                 sListFile = sFilenameNoSuffix + ".ini";
404*cdf0e10cSrcweir             }
405*cdf0e10cSrcweir             _aLISToutput.writeValue(sListFile);
406*cdf0e10cSrcweir 
407*cdf0e10cSrcweir             // -------------------- HTML --------------------
408*cdf0e10cSrcweir             String sLink;
409*cdf0e10cSrcweir             String sLinkDD;
410*cdf0e10cSrcweir             String sLinkName;
411*cdf0e10cSrcweir             String sLinkDDName;
412*cdf0e10cSrcweir             String sHTMLPrefix = aGTA.getHTMLOutputPrefix();
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir             GlobalLogWriter.get().println("----------------------------------------------------------------------");
415*cdf0e10cSrcweir             GlobalLogWriter.get().println(" OutputPath: " + _sOutputPath);
416*cdf0e10cSrcweir             GlobalLogWriter.get().println("    NewPath: " + _sNewSubDir);
417*cdf0e10cSrcweir             GlobalLogWriter.get().println("----------------------------------------------------------------------");
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir //             if (_sNewSubDir.length() > 0)
420*cdf0e10cSrcweir //             {
421*cdf0e10cSrcweir //                 sLink   = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + sFilenameNoSuffix + ".ini";
422*cdf0e10cSrcweir //                 sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
423*cdf0e10cSrcweir //             }
424*cdf0e10cSrcweir //             else
425*cdf0e10cSrcweir //             {
426*cdf0e10cSrcweir             sLink = sHTMLPrefix   /* + "/cw.php?inifile=" */ + _sOutputPath + fs + sFilenameNoSuffix + ".ini";
427*cdf0e10cSrcweir                 // sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + _sNewSubDir + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
428*cdf0e10cSrcweir             sLinkDD = sHTMLPrefix /* + "/cw.php?inifile=" */ + _sOutputPath + fs + "DiffDiff_" + sFilenameNoSuffix + ".ini";
429*cdf0e10cSrcweir //             }
430*cdf0e10cSrcweir             sLinkName = sFilenameNoSuffix;
431*cdf0e10cSrcweir             sLinkDDName = sFilenameNoSuffix + " (DiffDiff)";
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir             if (_sDiffPath != null && _sDiffPath.length() > 0)
434*cdf0e10cSrcweir             {
435*cdf0e10cSrcweir                 _aHTMLoutput.indexLine( sLinkDD, sLinkDDName, sLink, sLinkName, sStatusRunThrough, sStatusMessage );
436*cdf0e10cSrcweir             }
437*cdf0e10cSrcweir             else
438*cdf0e10cSrcweir             {
439*cdf0e10cSrcweir                 _aHTMLoutput.indexLine( sLink, sLinkName, "", "", sStatusRunThrough, sStatusMessage );
440*cdf0e10cSrcweir             }
441*cdf0e10cSrcweir 
442*cdf0e10cSrcweir         }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir }
446