@@ -564,6 +564,7 @@ private static List<String> getExtensions(String name) {
564564 extensions .add (".bmp" );
565565 } else if (name .equals ("portfolios" )) {
566566 extensions .add (".csv" );
567+ extensions .add (".json" );
567568 } else if (name .equals ("watchlist" )) {
568569 extensions .add (".csv" );
569570 } else if (name .equals ("android" )) {
@@ -577,110 +578,10 @@ private static List<String> getExtensions(String name) {
577578 return java .util .Collections .unmodifiableList (extensions );
578579 }
579580
580- // Merely copy n paste code from getJStockZipFile
581- public static File getJStockZipFileForConversionErrorMessageJDialog (File destFile ) {
582- // Look for "user-defined-database.xml" for all countries.
583- final List <File > files = getUserDefinedDatabaseFiles ();
584- final List <FileEx > fileExs = new ArrayList <FileEx >();
585- for (File file : files ) {
586- final String filename = file .getAbsolutePath ();
587- final int index = filename .indexOf (Utils .getApplicationVersionString ());
588- if (index < 0 ) {
589- continue ;
590- }
591- final String output = filename .substring (index + Utils .getApplicationVersionString ().length () + File .separator .length ());
592- fileExs .add (FileEx .newInstance (file , output ));
593- }
594-
595- final JStockOptions jStockOptions = JStock .getInstance ().getJStockOptions ();
596- // User will sue us, if we store their Google account information in our server.
597- // Let's get a copy of JStockOptions, without any sensitive data.
598- final JStockOptions insensitiveJStockOptions = jStockOptions .insensitiveClone ();
599- try {
600- final File tempJStockOptions = File .createTempFile (Utils .getJStockUUID (), ".xml" );
601- // Delete temp file when program exits.
602- tempJStockOptions .deleteOnExit ();
603- org .yccheok .jstock .gui .Utils .toXML (insensitiveJStockOptions , tempJStockOptions );
604- fileExs .add (FileEx .newInstance (tempJStockOptions , "config" + File .separator + "options.xml" ));
605- } catch (IOException ex ) {
606- // Should we return null? As the saved information is not complete.
607- log .error (null , ex );
608- }
609-
610- final List <Country > countryWithWatchlistFilesBeingIgnored = new ArrayList <Country >();
611- getFileEx (fileExs , "config" , null );
612- getFileEx (fileExs , "indicator" , null );
613- getFileEx (fileExs , "logos" , null );
614- for (Country country : Country .values ()) {
615- getFileEx (fileExs , country + File .separator + "portfolios" , null );
616- // For legacy usage. Shall be removed after a few more release
617- // later than 1.0.5k
618- getFileEx (fileExs , country + File .separator + "config" , null );
619-
620- LastErrorCode lastErrorCode = new LastErrorCode ();
621- getFileEx (fileExs , country + File .separator + "watchlist" , null , lastErrorCode );
622- if (lastErrorCode .flag ) {
623- // Watchlist file(s) is being ignored due to too much stocks in
624- // the watchlist.
625- countryWithWatchlistFilesBeingIgnored .add (country );
626- }
627- }
628-
629- //if (false == promptUserToContinue(countryWithWatchlistFilesBeingIgnored)) {
630- // return null;
631- //}
632-
633- // Create a buffer for reading the files
634- final byte [] buf = new byte [1024 ];
635-
636- ZipOutputStream out = null ;
637- File temp = destFile ;
638-
639- try {
640-
641- out = new ZipOutputStream (new FileOutputStream (temp ));
642-
643- // Compress the files
644- for (FileEx fileEx : fileExs ) {
645- FileInputStream in = null ;
646- try {
647- in = new FileInputStream (fileEx .input );
648- final String zipEntryName = fileEx .output ;
649- // Add ZIP entry to output stream.
650- out .putNextEntry (Utils .getZipEntry (zipEntryName ));
651-
652- // Transfer bytes from the file to the ZIP file
653- int len ;
654- while ((len = in .read (buf )) > 0 ) {
655- out .write (buf , 0 , len );
656- }
657- }
658- catch (IOException exp ) {
659- log .error (null , exp );
660- // Should we return null? As the saved information is not complete.
661- continue ;
662- }
663- finally {
664- // Complete the entry
665- Utils .closeEntry (out );
666- Utils .close (in );
667- }
668- }
669- }
670- catch (IOException exp ) {
671- // Should we return null? As the saved information is not complete.
672- log .error (null , exp );
673- }
674- finally {
675- Utils .close (out );
676- }
677- return temp ;
678- }
679-
680581 private File getJStockZipFile () {
681582 // Look for "user-defined-database.xml" for all countries.
682583 final List <File > files = getUserDefinedDatabaseFiles ();
683- final List <FileEx > fileExs = new ArrayList <FileEx >();
584+ final List <FileEx > fileExs = new ArrayList <>();
684585 for (File file : files ) {
685586 final String filename = file .getAbsolutePath ();
686587 final int index = filename .indexOf (Utils .getApplicationVersionString ());
@@ -706,7 +607,7 @@ private File getJStockZipFile() {
706607 log .error (null , ex );
707608 }
708609
709- final List <Country > countryWithWatchlistFilesBeingIgnored = new ArrayList <Country >();
610+ final List <Country > countryWithWatchlistFilesBeingIgnored = new ArrayList <>();
710611 getFileEx (fileExs , "config" , getExtensions ("config" ));
711612 getFileEx (fileExs , "indicator" , getExtensions ("indicator" ));
712613 getFileEx (fileExs , "logos" , getExtensions ("logos" ));
0 commit comments