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