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 package helper; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir import java.io.BufferedReader; 30*cdf0e10cSrcweir import java.io.File; 31*cdf0e10cSrcweir import java.io.FileReader; 32*cdf0e10cSrcweir import java.io.InputStream; 33*cdf0e10cSrcweir import java.io.InputStreamReader; 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir import java.util.ArrayList; 36*cdf0e10cSrcweir import java.util.Collections; 37*cdf0e10cSrcweir import java.util.StringTokenizer; 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir import share.DescEntry; 40*cdf0e10cSrcweir import share.DescGetter; 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir /** 43*cdf0e10cSrcweir * This is the Office-API specific DescGetter<br> 44*cdf0e10cSrcweir * <br> 45*cdf0e10cSrcweir * Examples:<br><br> 46*cdf0e10cSrcweir * -o sw.SwXBodyText<br> 47*cdf0e10cSrcweir * runs the module test of <B>Sw.SwXBodyText</B><br> 48*cdf0e10cSrcweir * <br> 49*cdf0e10cSrcweir * -o sw.SwXBodyText::com::sun::star::text::Text<br> 50*cdf0e10cSrcweir * runs only the interface test <B>com.sun.star.textText</B> of the module <B>Sw.SwXBodyText</B><br> 51*cdf0e10cSrcweir * <br> 52*cdf0e10cSrcweir * -o sw.SwXBodyText::com::sun::star::text::Text,com::sun::star::text::XSimpleText<br> 53*cdf0e10cSrcweir * runs only the interfaces test <B>com.sun.star.textText</B> and <B>com.sun.star.text.XSimpleText</B> of the module <B>Sw.SwXBodyText</B><br> 54*cdf0e10cSrcweir * <br> 55*cdf0e10cSrcweir * -p sw<br> 56*cdf0e10cSrcweir * runs all modules of the project <B>sw</B><br> 57*cdf0e10cSrcweir * <br> 58*cdf0e10cSrcweir * -p listall<br> 59*cdf0e10cSrcweir * lists all known module tests<br> 60*cdf0e10cSrcweir * <br> 61*cdf0e10cSrcweir * -sce SCENARIO_FILE<br> 62*cdf0e10cSrcweir * A scenario file is a property file which could cotain <B>-o</B> and <B>-p</B> properties<br> 63*cdf0e10cSrcweir * <br> 64*cdf0e10cSrcweir * -sce sw.SwXBodyText,sw.SwXBookmark<br> 65*cdf0e10cSrcweir * runs the module test of <B>Sw.SwXBodyText</B> and <B>sw.SwXBookmark</B><br> 66*cdf0e10cSrcweir */ 67*cdf0e10cSrcweir public class APIDescGetter extends DescGetter 68*cdf0e10cSrcweir { 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir private static String fullJob = null; 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir /* 73*cdf0e10cSrcweir * gets the needed information about a StarOffice component 74*cdf0e10cSrcweir * @param descPath Path to the ComponentDescription 75*cdf0e10cSrcweir * @param entry contains the entry name, e.g. sw.SwXBodyText 76*cdf0e10cSrcweir * @param debug if true some debug information is displayed on standard out 77*cdf0e10cSrcweir */ 78*cdf0e10cSrcweir public DescEntry[] getDescriptionFor(String job, String descPath, 79*cdf0e10cSrcweir boolean debug) 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir if (job.startsWith("-o")) 83*cdf0e10cSrcweir { 84*cdf0e10cSrcweir job = job.substring(3, job.length()).trim(); 85*cdf0e10cSrcweir 86*cdf0e10cSrcweir if (job.indexOf(".") < 0) 87*cdf0e10cSrcweir { 88*cdf0e10cSrcweir return null; 89*cdf0e10cSrcweir } 90*cdf0e10cSrcweir 91*cdf0e10cSrcweir // special in case several Interfaces are given comma separated 92*cdf0e10cSrcweir if (job.indexOf(",") < 0) 93*cdf0e10cSrcweir { 94*cdf0e10cSrcweir DescEntry entry = getDescriptionForSingleJob(job, descPath, 95*cdf0e10cSrcweir debug); 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir if (entry != null) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir return new DescEntry[] 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir entry 102*cdf0e10cSrcweir }; 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir else 105*cdf0e10cSrcweir { 106*cdf0e10cSrcweir return null; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir else 110*cdf0e10cSrcweir { 111*cdf0e10cSrcweir ArrayList subs = getSubInterfaces(job); 112*cdf0e10cSrcweir String partjob = job.substring(0, job.indexOf(",")).trim(); 113*cdf0e10cSrcweir DescEntry entry = getDescriptionForSingleJob(partjob, descPath, 114*cdf0e10cSrcweir debug); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if (entry != null) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir for (int i = 0; i < entry.SubEntryCount; i++) 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir String subEntry = entry.SubEntries[i].longName; 121*cdf0e10cSrcweir int cpLength = entry.longName.length(); 122*cdf0e10cSrcweir subEntry = subEntry.substring(cpLength + 2, 123*cdf0e10cSrcweir subEntry.length()); 124*cdf0e10cSrcweir 125*cdf0e10cSrcweir if (subs.contains(subEntry)) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir entry.SubEntries[i].isToTest = true; 128*cdf0e10cSrcweir } 129*cdf0e10cSrcweir } 130*cdf0e10cSrcweir 131*cdf0e10cSrcweir return new DescEntry[] 132*cdf0e10cSrcweir { 133*cdf0e10cSrcweir entry 134*cdf0e10cSrcweir }; 135*cdf0e10cSrcweir } 136*cdf0e10cSrcweir else 137*cdf0e10cSrcweir { 138*cdf0e10cSrcweir return null; 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir } 141*cdf0e10cSrcweir } 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir if (job.startsWith("-p")) 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir job = job.substring(3, job.length()).trim(); 146*cdf0e10cSrcweir 147*cdf0e10cSrcweir String[] scenario = createScenario(descPath, job, debug); 148*cdf0e10cSrcweir if (scenario == null) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir return null; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir DescEntry[] entries = new DescEntry[scenario.length]; 153*cdf0e10cSrcweir for (int i = 0; i < scenario.length; i++) 154*cdf0e10cSrcweir { 155*cdf0e10cSrcweir entries[i] = getDescriptionForSingleJob( 156*cdf0e10cSrcweir scenario[i].substring(3).trim(), descPath, debug); 157*cdf0e10cSrcweir } 158*cdf0e10cSrcweir if (job.equals("listall")) 159*cdf0e10cSrcweir { 160*cdf0e10cSrcweir util.dbg.printArray(scenario); 161*cdf0e10cSrcweir System.exit(0); 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir return entries; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir if (job.startsWith("-sce")) 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir job = job.substring(5, job.length()).trim(); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir File sceFile = new File(job); 171*cdf0e10cSrcweir if (sceFile.exists()) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir return getScenario(job, descPath, debug); 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir else 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir //look the scenarion like this? : 178*cdf0e10cSrcweir // sw.SwXBodyText,sw.SwXTextCursor 179*cdf0e10cSrcweir ArrayList subs = getSubObjects(job); 180*cdf0e10cSrcweir DescEntry[] entries = new DescEntry[subs.size()]; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir for (int i = 0; i < subs.size(); i++) 183*cdf0e10cSrcweir { 184*cdf0e10cSrcweir entries[i] = getDescriptionForSingleJob( 185*cdf0e10cSrcweir (String) subs.get(i), descPath, debug); 186*cdf0e10cSrcweir } 187*cdf0e10cSrcweir return entries; 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir else 191*cdf0e10cSrcweir { 192*cdf0e10cSrcweir return null; 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir } 195*cdf0e10cSrcweir 196*cdf0e10cSrcweir protected DescEntry getDescriptionForSingleJob(String job, String descPath, 197*cdf0e10cSrcweir boolean debug) 198*cdf0e10cSrcweir { 199*cdf0e10cSrcweir boolean isSingleInterface = job.indexOf("::") > 0; 200*cdf0e10cSrcweir fullJob = job; 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir if (isSingleInterface) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir job = job.substring(0, job.indexOf("::")); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir if (job.startsWith("bugs")) 208*cdf0e10cSrcweir { 209*cdf0e10cSrcweir DescEntry Entry = new DescEntry(); 210*cdf0e10cSrcweir Entry.entryName = job; 211*cdf0e10cSrcweir Entry.longName = job; 212*cdf0e10cSrcweir Entry.EntryType = "bugdoc"; 213*cdf0e10cSrcweir Entry.isOptional = false; 214*cdf0e10cSrcweir Entry.isToTest = true; 215*cdf0e10cSrcweir Entry.SubEntryCount = 0; 216*cdf0e10cSrcweir Entry.hasErrorMsg = false; 217*cdf0e10cSrcweir Entry.State = "non possible"; 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir return Entry; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir 222*cdf0e10cSrcweir DescEntry entry = null; 223*cdf0e10cSrcweir 224*cdf0e10cSrcweir if (descPath != null) 225*cdf0e10cSrcweir { 226*cdf0e10cSrcweir if (debug) 227*cdf0e10cSrcweir { 228*cdf0e10cSrcweir System.out.println("## reading from File " + descPath); 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir entry = getFromDirectory(descPath, job, debug); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir else 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir if (debug) 236*cdf0e10cSrcweir { 237*cdf0e10cSrcweir System.out.println("## reading from jar"); 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir 240*cdf0e10cSrcweir entry = getFromClassPath(job, debug); 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir boolean foundInterface = false; 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir if (isSingleInterface && (entry != null)) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir for (int i = 0; i < entry.SubEntryCount; i++) 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir if (!(entry.SubEntries[i].longName).equals(fullJob)) 250*cdf0e10cSrcweir { 251*cdf0e10cSrcweir entry.SubEntries[i].isToTest = false; 252*cdf0e10cSrcweir } 253*cdf0e10cSrcweir else 254*cdf0e10cSrcweir { 255*cdf0e10cSrcweir foundInterface = true; 256*cdf0e10cSrcweir entry.SubEntries[i].isToTest = true; 257*cdf0e10cSrcweir } 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir } 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir if (isSingleInterface && !foundInterface || entry == null) 262*cdf0e10cSrcweir { 263*cdf0e10cSrcweir return setErrorDescription(entry, 264*cdf0e10cSrcweir "couldn't find a description for test '" + fullJob + "'"); 265*cdf0e10cSrcweir } 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir return entry; 268*cdf0e10cSrcweir } 269*cdf0e10cSrcweir 270*cdf0e10cSrcweir protected static DescEntry[] getSubEntries(BufferedReader cvsFile, 271*cdf0e10cSrcweir DescEntry parent, boolean debug) 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir String line = ""; 274*cdf0e10cSrcweir String old_ifc_name = ""; 275*cdf0e10cSrcweir ArrayList ifc_names = new ArrayList(); 276*cdf0e10cSrcweir ArrayList meth_names = new ArrayList(); 277*cdf0e10cSrcweir DescEntry ifcDesc = null; 278*cdf0e10cSrcweir 279*cdf0e10cSrcweir while (line != null) 280*cdf0e10cSrcweir { 281*cdf0e10cSrcweir try 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir line = cvsFile.readLine(); 284*cdf0e10cSrcweir if (line == null) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir continue; 287*cdf0e10cSrcweir } 288*cdf0e10cSrcweir if (line.startsWith("#")) 289*cdf0e10cSrcweir { 290*cdf0e10cSrcweir continue; 291*cdf0e10cSrcweir } 292*cdf0e10cSrcweir if (line.length() <= 0) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir continue; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir // TODO Probleme here 297*cdf0e10cSrcweir // int nFirstSemicolon = line.indexOf(";"); 298*cdf0e10cSrcweir // int nLastSemicolon = line.lastIndexOf(";"); 299*cdf0e10cSrcweir 300*cdf0e10cSrcweir String unknown; 301*cdf0e10cSrcweir String ifc_name = ""; // = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1); 302*cdf0e10cSrcweir String meth_name = ""; // = line.substring(line.lastIndexOf(";") + 2, line.length() - 1); 303*cdf0e10cSrcweir StringTokenizer aToken = new StringTokenizer(line, ";"); 304*cdf0e10cSrcweir if (aToken.countTokens() < 3) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir System.out.println("Wrong format: Line '" + line + "' is not supported."); 307*cdf0e10cSrcweir continue; 308*cdf0e10cSrcweir } 309*cdf0e10cSrcweir if (aToken.hasMoreTokens()) 310*cdf0e10cSrcweir { 311*cdf0e10cSrcweir unknown = StringHelper.removeQuoteIfExists(aToken.nextToken()); 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir if (aToken.hasMoreTokens()) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir ifc_name = StringHelper.removeQuoteIfExists(aToken.nextToken()); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir if (aToken.hasMoreTokens()) 318*cdf0e10cSrcweir { 319*cdf0e10cSrcweir meth_name = StringHelper.removeQuoteIfExists(aToken.nextToken()); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir 322*cdf0e10cSrcweir // String ifc_name = line.substring(line.indexOf(";") + 2, line.lastIndexOf(";") - 1); 323*cdf0e10cSrcweir // String meth_name = line.substring(line.lastIndexOf(";") + 2, line.length() - 1); 324*cdf0e10cSrcweir 325*cdf0e10cSrcweir DescEntry methDesc = createDescEntry(meth_name, ifc_name, parent); 326*cdf0e10cSrcweir 327*cdf0e10cSrcweir if (!ifc_name.equals(old_ifc_name)) 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if (ifcDesc != null) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir ifcDesc.SubEntries = getDescArray(meth_names.toArray()); 332*cdf0e10cSrcweir ifcDesc.SubEntryCount = meth_names.size(); 333*cdf0e10cSrcweir 334*cdf0e10cSrcweir //mark service/interface as optional if all methods/properties are optional 335*cdf0e10cSrcweir boolean allOptional = true; 336*cdf0e10cSrcweir 337*cdf0e10cSrcweir for (int k = 0; k < ifcDesc.SubEntryCount; k++) 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir if (!ifcDesc.SubEntries[k].isOptional) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir allOptional = false; 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir } 344*cdf0e10cSrcweir 345*cdf0e10cSrcweir if (!ifcDesc.isOptional && allOptional) 346*cdf0e10cSrcweir { 347*cdf0e10cSrcweir ifcDesc.isOptional = allOptional; 348*cdf0e10cSrcweir } 349*cdf0e10cSrcweir 350*cdf0e10cSrcweir meth_names.clear(); 351*cdf0e10cSrcweir ifc_names.add(ifcDesc); 352*cdf0e10cSrcweir } 353*cdf0e10cSrcweir 354*cdf0e10cSrcweir ifcDesc = new DescEntry(); 355*cdf0e10cSrcweir ifcDesc.isToTest = true; 356*cdf0e10cSrcweir old_ifc_name = ifc_name; 357*cdf0e10cSrcweir 358*cdf0e10cSrcweir if (ifc_name.indexOf("#optional") > 0) 359*cdf0e10cSrcweir { 360*cdf0e10cSrcweir ifcDesc.isOptional = true; 361*cdf0e10cSrcweir ifc_name = ifc_name.substring(0, ifc_name.indexOf("#")); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir 364*cdf0e10cSrcweir String className = createClassName(ifc_name); 365*cdf0e10cSrcweir 366*cdf0e10cSrcweir ifcDesc.EntryType = entryType; 367*cdf0e10cSrcweir ifcDesc.entryName = "ifc" + className; 368*cdf0e10cSrcweir ifcDesc.longName = parent.entryName + "::" + ifc_name; 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir meth_names.add(methDesc); 371*cdf0e10cSrcweir 372*cdf0e10cSrcweir } 373*cdf0e10cSrcweir catch (java.io.IOException ioe) 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir parent.hasErrorMsg = true; 376*cdf0e10cSrcweir parent.ErrorMsg = "IOException while reading the description"; 377*cdf0e10cSrcweir 378*cdf0e10cSrcweir return null; 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir } 381*cdf0e10cSrcweir 382*cdf0e10cSrcweir ifcDesc.SubEntries = getDescArray(meth_names.toArray()); 383*cdf0e10cSrcweir ifcDesc.SubEntryCount = meth_names.size(); 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir //mark service/interface as optional if all methods/properties are optional 386*cdf0e10cSrcweir boolean allOptional = true; 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir for (int k = 0; k < ifcDesc.SubEntryCount; k++) 389*cdf0e10cSrcweir { 390*cdf0e10cSrcweir if (!ifcDesc.SubEntries[k].isOptional) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir allOptional = false; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir } 395*cdf0e10cSrcweir 396*cdf0e10cSrcweir if (!ifcDesc.isOptional && allOptional) 397*cdf0e10cSrcweir { 398*cdf0e10cSrcweir ifcDesc.isOptional = allOptional; 399*cdf0e10cSrcweir } 400*cdf0e10cSrcweir 401*cdf0e10cSrcweir ifc_names.add(ifcDesc); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir return getDescArray(makeArray(ifc_names)); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir private static String createClassName(String _ifc_name) 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir StringTokenizer st = new StringTokenizer(_ifc_name, ":"); 408*cdf0e10cSrcweir String className = ""; 409*cdf0e10cSrcweir 410*cdf0e10cSrcweir int count = 3; 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir if (_ifc_name.startsWith("drafts")) 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir count = 4; 415*cdf0e10cSrcweir } 416*cdf0e10cSrcweir 417*cdf0e10cSrcweir for (int i = 0; st.hasMoreTokens(); i++) 418*cdf0e10cSrcweir { 419*cdf0e10cSrcweir String token = st.nextToken(); 420*cdf0e10cSrcweir 421*cdf0e10cSrcweir // skipping (drafts.)com.sun.star 422*cdf0e10cSrcweir if (i >= count) 423*cdf0e10cSrcweir { 424*cdf0e10cSrcweir if (!st.hasMoreTokens()) 425*cdf0e10cSrcweir { 426*cdf0e10cSrcweir // inserting '_' before the last token 427*cdf0e10cSrcweir token = "_" + token; 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir className += ("." + token); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir } 433*cdf0e10cSrcweir return className; 434*cdf0e10cSrcweir } 435*cdf0e10cSrcweir 436*cdf0e10cSrcweir private static String entryType; 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir private static DescEntry createDescEntry(String meth_name, String ifc_name, DescEntry parent) 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir entryType = "service"; 441*cdf0e10cSrcweir DescEntry methDesc = new DescEntry(); 442*cdf0e10cSrcweir 443*cdf0e10cSrcweir if (meth_name.indexOf("#optional") > 0) 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir methDesc.isOptional = true; 446*cdf0e10cSrcweir meth_name = meth_name.substring(0, meth_name.indexOf("#")); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir 449*cdf0e10cSrcweir if (meth_name.endsWith("()")) 450*cdf0e10cSrcweir { 451*cdf0e10cSrcweir methDesc.EntryType = "method"; 452*cdf0e10cSrcweir entryType = "interface"; 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir else 455*cdf0e10cSrcweir { 456*cdf0e10cSrcweir methDesc.EntryType = "property"; 457*cdf0e10cSrcweir entryType = "service"; 458*cdf0e10cSrcweir } 459*cdf0e10cSrcweir 460*cdf0e10cSrcweir methDesc.entryName = meth_name; 461*cdf0e10cSrcweir methDesc.isToTest = true; 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir 464*cdf0e10cSrcweir String withoutHash = ifc_name; 465*cdf0e10cSrcweir 466*cdf0e10cSrcweir if (ifc_name.indexOf("#optional") > 0) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir withoutHash = ifc_name.substring(0, ifc_name.indexOf("#")); 469*cdf0e10cSrcweir } 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir methDesc.longName = parent.entryName + "::" + withoutHash + "::" + meth_name; 472*cdf0e10cSrcweir 473*cdf0e10cSrcweir return methDesc; 474*cdf0e10cSrcweir } 475*cdf0e10cSrcweir 476*cdf0e10cSrcweir private static void createIfcName(String ifc_name, ArrayList meth_names, DescEntry ifcDesc) 477*cdf0e10cSrcweir { 478*cdf0e10cSrcweir } 479*cdf0e10cSrcweir 480*cdf0e10cSrcweir /** 481*cdf0e10cSrcweir * This method ensures that XComponent will be the last in the list of interfaces 482*cdf0e10cSrcweir */ 483*cdf0e10cSrcweir protected static Object[] makeArray(ArrayList entries) 484*cdf0e10cSrcweir { 485*cdf0e10cSrcweir Object[] entriesArray = entries.toArray(); 486*cdf0e10cSrcweir ArrayList returnArray = new ArrayList(); 487*cdf0e10cSrcweir Object addAtEnd = null; 488*cdf0e10cSrcweir 489*cdf0e10cSrcweir for (int k = 0; k < entriesArray.length; k++) 490*cdf0e10cSrcweir { 491*cdf0e10cSrcweir DescEntry entry = (DescEntry) entriesArray[k]; 492*cdf0e10cSrcweir 493*cdf0e10cSrcweir if (entry.entryName.equals("ifc.lang._XComponent")) 494*cdf0e10cSrcweir { 495*cdf0e10cSrcweir addAtEnd = entry; 496*cdf0e10cSrcweir } 497*cdf0e10cSrcweir else 498*cdf0e10cSrcweir { 499*cdf0e10cSrcweir returnArray.add(entry); 500*cdf0e10cSrcweir } 501*cdf0e10cSrcweir } 502*cdf0e10cSrcweir 503*cdf0e10cSrcweir if (addAtEnd != null) 504*cdf0e10cSrcweir { 505*cdf0e10cSrcweir returnArray.add(addAtEnd); 506*cdf0e10cSrcweir } 507*cdf0e10cSrcweir 508*cdf0e10cSrcweir return returnArray.toArray(); 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir protected static DescEntry setErrorDescription(DescEntry entry, 512*cdf0e10cSrcweir String ErrorMsg) 513*cdf0e10cSrcweir { 514*cdf0e10cSrcweir if (entry == null) 515*cdf0e10cSrcweir { 516*cdf0e10cSrcweir entry = new DescEntry(); 517*cdf0e10cSrcweir } 518*cdf0e10cSrcweir entry.hasErrorMsg = true; 519*cdf0e10cSrcweir entry.ErrorMsg = "Error while getting description for test '" + 520*cdf0e10cSrcweir fullJob + "' as an API test: " + ErrorMsg; 521*cdf0e10cSrcweir 522*cdf0e10cSrcweir return entry; 523*cdf0e10cSrcweir } 524*cdf0e10cSrcweir 525*cdf0e10cSrcweir protected static DescEntry[] getDescArray(Object[] list) 526*cdf0e10cSrcweir { 527*cdf0e10cSrcweir DescEntry[] entries = new DescEntry[list.length]; 528*cdf0e10cSrcweir 529*cdf0e10cSrcweir for (int i = 0; i < list.length; i++) 530*cdf0e10cSrcweir { 531*cdf0e10cSrcweir entries[i] = (DescEntry) list[i]; 532*cdf0e10cSrcweir } 533*cdf0e10cSrcweir 534*cdf0e10cSrcweir return entries; 535*cdf0e10cSrcweir } 536*cdf0e10cSrcweir 537*cdf0e10cSrcweir protected DescEntry getFromClassPath(String aEntry, boolean debug) 538*cdf0e10cSrcweir { 539*cdf0e10cSrcweir int dotindex = aEntry.indexOf('.'); 540*cdf0e10cSrcweir 541*cdf0e10cSrcweir if (dotindex == -1) 542*cdf0e10cSrcweir { 543*cdf0e10cSrcweir return null; 544*cdf0e10cSrcweir } 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir String module = null; 547*cdf0e10cSrcweir String shortName = null; 548*cdf0e10cSrcweir 549*cdf0e10cSrcweir if (aEntry.indexOf(".uno") == -1) 550*cdf0e10cSrcweir { 551*cdf0e10cSrcweir module = aEntry.substring(0, aEntry.indexOf('.')); 552*cdf0e10cSrcweir shortName = aEntry.substring(aEntry.indexOf('.') + 1); 553*cdf0e10cSrcweir } 554*cdf0e10cSrcweir else 555*cdf0e10cSrcweir { 556*cdf0e10cSrcweir module = aEntry.substring(0, aEntry.lastIndexOf('.')); 557*cdf0e10cSrcweir shortName = aEntry.substring(aEntry.lastIndexOf('.') + 1); 558*cdf0e10cSrcweir } 559*cdf0e10cSrcweir 560*cdf0e10cSrcweir DescEntry theEntry = new DescEntry(); 561*cdf0e10cSrcweir theEntry.entryName = aEntry; 562*cdf0e10cSrcweir theEntry.longName = aEntry; 563*cdf0e10cSrcweir theEntry.isOptional = false; 564*cdf0e10cSrcweir theEntry.EntryType = "component"; 565*cdf0e10cSrcweir theEntry.isToTest = true; 566*cdf0e10cSrcweir 567*cdf0e10cSrcweir BufferedReader csvFile = null; 568*cdf0e10cSrcweir 569*cdf0e10cSrcweir java.net.URL url = this.getClass().getResource("/objdsc/" + module); 570*cdf0e10cSrcweir 571*cdf0e10cSrcweir if (url == null) 572*cdf0e10cSrcweir { 573*cdf0e10cSrcweir return setErrorDescription(theEntry, 574*cdf0e10cSrcweir "couldn't find module '" + module + "'"); 575*cdf0e10cSrcweir } 576*cdf0e10cSrcweir 577*cdf0e10cSrcweir try 578*cdf0e10cSrcweir { 579*cdf0e10cSrcweir java.net.URLConnection con = url.openConnection(); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir String sEndsWithCSVName = "." + shortName.trim() + ".csv"; 582*cdf0e10cSrcweir if (con instanceof java.net.JarURLConnection) 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir // get Jar file from connection 585*cdf0e10cSrcweir java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile(); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // Enumerate over all entries 588*cdf0e10cSrcweir java.util.Enumeration e = f.entries(); 589*cdf0e10cSrcweir 590*cdf0e10cSrcweir String sStartModule = "/" + module + "/"; 591*cdf0e10cSrcweir while (e.hasMoreElements()) 592*cdf0e10cSrcweir { 593*cdf0e10cSrcweir 594*cdf0e10cSrcweir String entry = e.nextElement().toString(); 595*cdf0e10cSrcweir 596*cdf0e10cSrcweir // if (debug) { 597*cdf0e10cSrcweir // System.out.println("### Read from connetion: " + entry); 598*cdf0e10cSrcweir // } 599*cdf0e10cSrcweir 600*cdf0e10cSrcweir if ((entry.lastIndexOf(sStartModule) != -1) && 601*cdf0e10cSrcweir entry.endsWith(sEndsWithCSVName)) 602*cdf0e10cSrcweir { 603*cdf0e10cSrcweir InputStream input = this.getClass().getResourceAsStream("/" + entry); 604*cdf0e10cSrcweir csvFile = new BufferedReader(new InputStreamReader(input)); 605*cdf0e10cSrcweir break; 606*cdf0e10cSrcweir } 607*cdf0e10cSrcweir } 608*cdf0e10cSrcweir } 609*cdf0e10cSrcweir else 610*cdf0e10cSrcweir { 611*cdf0e10cSrcweir InputStream in = con.getInputStream(); 612*cdf0e10cSrcweir java.io.BufferedReader buf = new java.io.BufferedReader(new InputStreamReader(in)); 613*cdf0e10cSrcweir boolean found = false; 614*cdf0e10cSrcweir 615*cdf0e10cSrcweir while (buf.ready() && !found) 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir String entry = buf.readLine(); 618*cdf0e10cSrcweir 619*cdf0e10cSrcweir if (entry.endsWith(sEndsWithCSVName)) 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir System.out.println("FOUND ####"); 622*cdf0e10cSrcweir InputStream input = this.getClass().getResourceAsStream("/objdsc/" + 623*cdf0e10cSrcweir module + 624*cdf0e10cSrcweir "/" + 625*cdf0e10cSrcweir entry); 626*cdf0e10cSrcweir csvFile = new BufferedReader( 627*cdf0e10cSrcweir new InputStreamReader(input)); 628*cdf0e10cSrcweir found = true; 629*cdf0e10cSrcweir } 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir 632*cdf0e10cSrcweir buf.close(); 633*cdf0e10cSrcweir } 634*cdf0e10cSrcweir } 635*cdf0e10cSrcweir catch (java.io.IOException e) 636*cdf0e10cSrcweir { 637*cdf0e10cSrcweir e.printStackTrace(); 638*cdf0e10cSrcweir } 639*cdf0e10cSrcweir 640*cdf0e10cSrcweir if (csvFile == null) 641*cdf0e10cSrcweir { 642*cdf0e10cSrcweir return setErrorDescription(theEntry, 643*cdf0e10cSrcweir "couldn't find component '" + 644*cdf0e10cSrcweir theEntry.entryName + "'"); 645*cdf0e10cSrcweir } 646*cdf0e10cSrcweir 647*cdf0e10cSrcweir DescEntry[] subEntries = getSubEntries(csvFile, theEntry, debug); 648*cdf0e10cSrcweir 649*cdf0e10cSrcweir theEntry.SubEntryCount = subEntries.length; 650*cdf0e10cSrcweir theEntry.SubEntries = subEntries; 651*cdf0e10cSrcweir 652*cdf0e10cSrcweir return theEntry; 653*cdf0e10cSrcweir } 654*cdf0e10cSrcweir 655*cdf0e10cSrcweir protected static DescEntry getFromDirectory(String descPath, String entry, 656*cdf0e10cSrcweir boolean debug) 657*cdf0e10cSrcweir { 658*cdf0e10cSrcweir int dotindex = entry.indexOf('.'); 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir if (dotindex == -1) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir return null; 663*cdf0e10cSrcweir } 664*cdf0e10cSrcweir 665*cdf0e10cSrcweir String fs = System.getProperty("file.separator"); 666*cdf0e10cSrcweir String module = null; 667*cdf0e10cSrcweir String shortName = null; 668*cdf0e10cSrcweir 669*cdf0e10cSrcweir if (entry.indexOf(".uno") == -1) 670*cdf0e10cSrcweir { 671*cdf0e10cSrcweir module = entry.substring(0, entry.indexOf('.')); 672*cdf0e10cSrcweir shortName = entry.substring(entry.indexOf('.') + 1); 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir else 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir module = entry.substring(0, entry.lastIndexOf('.')); 677*cdf0e10cSrcweir shortName = entry.substring(entry.lastIndexOf('.') + 1); 678*cdf0e10cSrcweir } 679*cdf0e10cSrcweir 680*cdf0e10cSrcweir DescEntry aEntry = new DescEntry(); 681*cdf0e10cSrcweir aEntry.entryName = entry; 682*cdf0e10cSrcweir aEntry.longName = entry; 683*cdf0e10cSrcweir aEntry.isOptional = false; 684*cdf0e10cSrcweir aEntry.EntryType = "component"; 685*cdf0e10cSrcweir aEntry.isToTest = true; 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir if (debug) 688*cdf0e10cSrcweir { 689*cdf0e10cSrcweir System.out.println("Parsing Description Path: " + descPath); 690*cdf0e10cSrcweir System.out.println("Searching module: " + module); 691*cdf0e10cSrcweir System.out.println("For the Component " + shortName); 692*cdf0e10cSrcweir } 693*cdf0e10cSrcweir 694*cdf0e10cSrcweir File modPath = new File(descPath + fs + module); 695*cdf0e10cSrcweir 696*cdf0e10cSrcweir if (!modPath.exists()) 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir return setErrorDescription(aEntry, 699*cdf0e10cSrcweir "couldn't find module '" + module + "'"); 700*cdf0e10cSrcweir } 701*cdf0e10cSrcweir 702*cdf0e10cSrcweir String[] files = modPath.list(); 703*cdf0e10cSrcweir String found = "none"; 704*cdf0e10cSrcweir 705*cdf0e10cSrcweir for (int i = 0; i < files.length; i++) 706*cdf0e10cSrcweir { 707*cdf0e10cSrcweir if (files[i].endsWith("." + shortName + ".csv")) 708*cdf0e10cSrcweir { 709*cdf0e10cSrcweir found = files[i]; 710*cdf0e10cSrcweir System.out.println("found " + found); 711*cdf0e10cSrcweir break; 712*cdf0e10cSrcweir } 713*cdf0e10cSrcweir } 714*cdf0e10cSrcweir 715*cdf0e10cSrcweir if (found.equals("none")) 716*cdf0e10cSrcweir { 717*cdf0e10cSrcweir return setErrorDescription(aEntry, 718*cdf0e10cSrcweir "couldn't find component '" + entry + "'"); 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir 721*cdf0e10cSrcweir String aUrl = descPath + fs + module + fs + found; 722*cdf0e10cSrcweir 723*cdf0e10cSrcweir BufferedReader csvFile = null; 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir try 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir csvFile = new BufferedReader(new FileReader(aUrl)); 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir catch (java.io.FileNotFoundException fnfe) 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir return setErrorDescription(aEntry, "couldn't find file '" + aUrl + "'"); 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir DescEntry[] subEntries = getSubEntries(csvFile, aEntry, debug); 735*cdf0e10cSrcweir 736*cdf0e10cSrcweir aEntry.SubEntryCount = subEntries.length; 737*cdf0e10cSrcweir aEntry.SubEntries = subEntries; 738*cdf0e10cSrcweir 739*cdf0e10cSrcweir return aEntry; 740*cdf0e10cSrcweir } 741*cdf0e10cSrcweir 742*cdf0e10cSrcweir protected ArrayList getSubInterfaces(String job) 743*cdf0e10cSrcweir { 744*cdf0e10cSrcweir ArrayList namesList = new ArrayList(); 745*cdf0e10cSrcweir StringTokenizer st = new StringTokenizer(job, ","); 746*cdf0e10cSrcweir 747*cdf0e10cSrcweir for (int i = 0; st.hasMoreTokens(); i++) 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir String token = st.nextToken(); 750*cdf0e10cSrcweir 751*cdf0e10cSrcweir if (token.indexOf(".") < 0) 752*cdf0e10cSrcweir { 753*cdf0e10cSrcweir namesList.add(token); 754*cdf0e10cSrcweir } 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir 757*cdf0e10cSrcweir return namesList; 758*cdf0e10cSrcweir } 759*cdf0e10cSrcweir 760*cdf0e10cSrcweir protected ArrayList getSubObjects(String job) 761*cdf0e10cSrcweir { 762*cdf0e10cSrcweir ArrayList namesList = new ArrayList(); 763*cdf0e10cSrcweir StringTokenizer st = new StringTokenizer(job, ","); 764*cdf0e10cSrcweir 765*cdf0e10cSrcweir for (int i = 0; st.hasMoreTokens(); i++) 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir namesList.add(st.nextToken()); 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir 770*cdf0e10cSrcweir return namesList; 771*cdf0e10cSrcweir } 772*cdf0e10cSrcweir 773*cdf0e10cSrcweir protected String[] createScenario(String descPath, String job, 774*cdf0e10cSrcweir boolean debug) 775*cdf0e10cSrcweir { 776*cdf0e10cSrcweir String[] scenario = null; 777*cdf0e10cSrcweir 778*cdf0e10cSrcweir if (descPath != null) 779*cdf0e10cSrcweir { 780*cdf0e10cSrcweir if (debug) 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir System.out.println("## reading from File " + descPath); 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir 785*cdf0e10cSrcweir scenario = getScenarioFromDirectory(descPath, job, debug); 786*cdf0e10cSrcweir } 787*cdf0e10cSrcweir else 788*cdf0e10cSrcweir { 789*cdf0e10cSrcweir if (debug) 790*cdf0e10cSrcweir { 791*cdf0e10cSrcweir System.out.println("## reading from jar"); 792*cdf0e10cSrcweir } 793*cdf0e10cSrcweir 794*cdf0e10cSrcweir scenario = getScenarioFromClassPath(job, debug); 795*cdf0e10cSrcweir } 796*cdf0e10cSrcweir 797*cdf0e10cSrcweir return scenario; 798*cdf0e10cSrcweir } 799*cdf0e10cSrcweir 800*cdf0e10cSrcweir protected String[] getScenarioFromDirectory(String descPath, String job, 801*cdf0e10cSrcweir boolean debug) 802*cdf0e10cSrcweir { 803*cdf0e10cSrcweir String[] modules = null; 804*cdf0e10cSrcweir ArrayList componentList = new ArrayList(); 805*cdf0e10cSrcweir 806*cdf0e10cSrcweir if (!job.equals("unknown") && !job.equals("listall")) 807*cdf0e10cSrcweir { 808*cdf0e10cSrcweir modules = new String[] 809*cdf0e10cSrcweir { 810*cdf0e10cSrcweir job 811*cdf0e10cSrcweir }; 812*cdf0e10cSrcweir } 813*cdf0e10cSrcweir else 814*cdf0e10cSrcweir { 815*cdf0e10cSrcweir File dirs = new File(descPath); 816*cdf0e10cSrcweir 817*cdf0e10cSrcweir if (!dirs.exists()) 818*cdf0e10cSrcweir { 819*cdf0e10cSrcweir modules = null; 820*cdf0e10cSrcweir } 821*cdf0e10cSrcweir else 822*cdf0e10cSrcweir { 823*cdf0e10cSrcweir modules = dirs.list(); 824*cdf0e10cSrcweir } 825*cdf0e10cSrcweir } 826*cdf0e10cSrcweir 827*cdf0e10cSrcweir for (int i = 0; i < modules.length; i++) 828*cdf0e10cSrcweir { 829*cdf0e10cSrcweir if (!isUnusedModule(modules[i])) 830*cdf0e10cSrcweir { 831*cdf0e10cSrcweir File moduleDir = new File(descPath + System.getProperty("file.separator") + modules[i]); 832*cdf0e10cSrcweir if (moduleDir.exists()) 833*cdf0e10cSrcweir { 834*cdf0e10cSrcweir String[] components = moduleDir.list(); 835*cdf0e10cSrcweir for (int j = 0; j < components.length; j++) 836*cdf0e10cSrcweir { 837*cdf0e10cSrcweir if (components[j].endsWith(".csv")) 838*cdf0e10cSrcweir { 839*cdf0e10cSrcweir String toAdd = getComponentForString(components[j], modules[i]); 840*cdf0e10cSrcweir toAdd = "-o " + modules[i] + "." + toAdd; 841*cdf0e10cSrcweir componentList.add(toAdd); 842*cdf0e10cSrcweir } 843*cdf0e10cSrcweir } 844*cdf0e10cSrcweir } 845*cdf0e10cSrcweir } 846*cdf0e10cSrcweir } 847*cdf0e10cSrcweir 848*cdf0e10cSrcweir String[] scenario = new String[componentList.size()]; 849*cdf0e10cSrcweir Collections.sort(componentList); 850*cdf0e10cSrcweir 851*cdf0e10cSrcweir for (int i = 0; i < componentList.size(); i++) 852*cdf0e10cSrcweir { 853*cdf0e10cSrcweir scenario[i] = (String) componentList.get(i); 854*cdf0e10cSrcweir } 855*cdf0e10cSrcweir 856*cdf0e10cSrcweir return scenario; 857*cdf0e10cSrcweir 858*cdf0e10cSrcweir } 859*cdf0e10cSrcweir 860*cdf0e10cSrcweir protected String[] getScenarioFromClassPath(String job, boolean debug) 861*cdf0e10cSrcweir { 862*cdf0e10cSrcweir String subdir = "/"; 863*cdf0e10cSrcweir 864*cdf0e10cSrcweir if (!job.equals("unknown") && !job.equals("listall")) 865*cdf0e10cSrcweir { 866*cdf0e10cSrcweir subdir += job; 867*cdf0e10cSrcweir } 868*cdf0e10cSrcweir 869*cdf0e10cSrcweir java.net.URL url = this.getClass().getResource("/objdsc" + subdir); 870*cdf0e10cSrcweir 871*cdf0e10cSrcweir if (url == null) 872*cdf0e10cSrcweir { 873*cdf0e10cSrcweir return null; 874*cdf0e10cSrcweir } 875*cdf0e10cSrcweir 876*cdf0e10cSrcweir ArrayList scenarioList = new ArrayList(); 877*cdf0e10cSrcweir 878*cdf0e10cSrcweir try 879*cdf0e10cSrcweir { 880*cdf0e10cSrcweir java.net.URLConnection con = url.openConnection(); 881*cdf0e10cSrcweir 882*cdf0e10cSrcweir if (con instanceof java.net.JarURLConnection) 883*cdf0e10cSrcweir { 884*cdf0e10cSrcweir // get Jar file from connection 885*cdf0e10cSrcweir java.util.jar.JarFile f = ((java.net.JarURLConnection) con).getJarFile(); 886*cdf0e10cSrcweir 887*cdf0e10cSrcweir // Enumerate over all entries 888*cdf0e10cSrcweir java.util.Enumeration e = f.entries(); 889*cdf0e10cSrcweir 890*cdf0e10cSrcweir while (e.hasMoreElements()) 891*cdf0e10cSrcweir { 892*cdf0e10cSrcweir String entry = e.nextElement().toString(); 893*cdf0e10cSrcweir 894*cdf0e10cSrcweir if (entry.startsWith("objdsc" + subdir) && 895*cdf0e10cSrcweir (entry.indexOf("CVS") < 0) && 896*cdf0e10cSrcweir !entry.endsWith("/")) 897*cdf0e10cSrcweir { 898*cdf0e10cSrcweir int startMod = entry.indexOf("/"); 899*cdf0e10cSrcweir int endMod = entry.lastIndexOf("/"); 900*cdf0e10cSrcweir String module = entry.substring(startMod + 1, endMod); 901*cdf0e10cSrcweir String component = getComponentForString( 902*cdf0e10cSrcweir entry.substring(endMod + 1, 903*cdf0e10cSrcweir entry.length()), 904*cdf0e10cSrcweir module); 905*cdf0e10cSrcweir 906*cdf0e10cSrcweir if (!isUnusedModule(module)) 907*cdf0e10cSrcweir { 908*cdf0e10cSrcweir scenarioList.add("-o " + module + "." + 909*cdf0e10cSrcweir component); 910*cdf0e10cSrcweir } 911*cdf0e10cSrcweir } 912*cdf0e10cSrcweir } 913*cdf0e10cSrcweir } 914*cdf0e10cSrcweir } 915*cdf0e10cSrcweir catch (java.io.IOException e) 916*cdf0e10cSrcweir { 917*cdf0e10cSrcweir e.printStackTrace(); 918*cdf0e10cSrcweir } 919*cdf0e10cSrcweir 920*cdf0e10cSrcweir String[] scenario = new String[scenarioList.size()]; 921*cdf0e10cSrcweir Collections.sort(scenarioList); 922*cdf0e10cSrcweir 923*cdf0e10cSrcweir for (int i = 0; i < scenarioList.size(); i++) 924*cdf0e10cSrcweir { 925*cdf0e10cSrcweir scenario[i] = (String) scenarioList.get(i); 926*cdf0e10cSrcweir } 927*cdf0e10cSrcweir 928*cdf0e10cSrcweir return scenario; 929*cdf0e10cSrcweir } 930*cdf0e10cSrcweir 931*cdf0e10cSrcweir protected String getComponentForString(String full, String module) 932*cdf0e10cSrcweir { 933*cdf0e10cSrcweir String component = ""; 934*cdf0e10cSrcweir 935*cdf0e10cSrcweir 936*cdf0e10cSrcweir //cutting .csv 937*cdf0e10cSrcweir full = full.substring(0, full.length() - 4); 938*cdf0e10cSrcweir 939*cdf0e10cSrcweir //cutting component 940*cdf0e10cSrcweir int lastdot = full.lastIndexOf("."); 941*cdf0e10cSrcweir component = full.substring(lastdot + 1, full.length()); 942*cdf0e10cSrcweir 943*cdf0e10cSrcweir if (module.equals("file") || module.equals("xmloff")) 944*cdf0e10cSrcweir { 945*cdf0e10cSrcweir String withoutComponent = full.substring(0, lastdot); 946*cdf0e10cSrcweir int preLastDot = withoutComponent.lastIndexOf("."); 947*cdf0e10cSrcweir component = withoutComponent.substring(preLastDot + 1, 948*cdf0e10cSrcweir withoutComponent.length()) + 949*cdf0e10cSrcweir "." + component; 950*cdf0e10cSrcweir } 951*cdf0e10cSrcweir 952*cdf0e10cSrcweir return component; 953*cdf0e10cSrcweir } 954*cdf0e10cSrcweir 955*cdf0e10cSrcweir protected boolean isUnusedModule(String moduleName) 956*cdf0e10cSrcweir { 957*cdf0e10cSrcweir ArrayList removed = new ArrayList(); 958*cdf0e10cSrcweir removed.add("acceptor"); 959*cdf0e10cSrcweir removed.add("brdgfctr"); 960*cdf0e10cSrcweir removed.add("connectr"); 961*cdf0e10cSrcweir removed.add("corefl"); 962*cdf0e10cSrcweir removed.add("cpld"); 963*cdf0e10cSrcweir removed.add("defreg"); 964*cdf0e10cSrcweir removed.add("dynamicloader"); 965*cdf0e10cSrcweir removed.add("impreg"); 966*cdf0e10cSrcweir removed.add("insp"); 967*cdf0e10cSrcweir removed.add("inv"); 968*cdf0e10cSrcweir removed.add("invadp"); 969*cdf0e10cSrcweir removed.add("javaloader"); 970*cdf0e10cSrcweir removed.add("jen"); 971*cdf0e10cSrcweir removed.add("namingservice"); 972*cdf0e10cSrcweir removed.add("proxyfac"); 973*cdf0e10cSrcweir removed.add("rdbtdp"); 974*cdf0e10cSrcweir removed.add("remotebridge"); 975*cdf0e10cSrcweir removed.add("simreg"); 976*cdf0e10cSrcweir removed.add("smgr"); 977*cdf0e10cSrcweir removed.add("stm"); 978*cdf0e10cSrcweir removed.add("tcv"); 979*cdf0e10cSrcweir removed.add("tdmgr"); 980*cdf0e10cSrcweir removed.add("ucprmt"); 981*cdf0e10cSrcweir removed.add("uuresolver"); 982*cdf0e10cSrcweir 983*cdf0e10cSrcweir return removed.contains(moduleName); 984*cdf0e10cSrcweir } 985*cdf0e10cSrcweir } 986