Changeset 37690 for main


Ignore:
Timestamp:
2023-04-20T20:30:20+12:00 (12 months ago)
Author:
anupama
Message:

One part of what Dr Bainbridge wanted done: on Cancel press (though perl propagates it as an error), *after* the SafeProcess has been terminated a processComplete() is fired: then we check if it the type was an import process and a cancel/error occurred, and if so, we check if archives_keepold exists. If it exists, we make this the archivse folder after getting rid of any archives of the prematurely terminated import process.

Location:
main/trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r37419 r37690  
    10171017    return getLoadedCollectionDirectoryPath() + "archives" + File.separator;
    10181018    }
     1019
     1020    /** Returns the absolute filename of the loaded collection's archives_keepold directory.
     1021     * Part of the file-level document-version (fldv) history mechanism.
     1022     */
     1023    static public String getLoadedCollectionArchivesKeepOldDirectoryPath()
     1024    {
     1025    return getLoadedCollectionDirectoryPath() + "archives_keepold" + File.separator;
     1026    }
     1027   
    10191028
    10201029    /** Returns the absolute filename of the loaded collection's export directory.
  • main/trunk/gli/src/org/greenstone/gatherer/gui/CreatePane.java

    r34287 r37690  
    342342
    343343
     344    // No archives_keepold/fldv file-level document-version history in remoteGS situations
     345    // Disable choice between incremental and full building buttons,
     346    // and ensure full build buttons are selected (already done above)
     347    if(Gatherer.isGsdlRemote) {     
     348        full_build_radio_button.setEnabled(false);
     349        incremental_build_radio_button.setEnabled(false);
     350        sfull_build_radio_button.setEnabled(false);
     351        sincremental_build_radio_button.setEnabled(false);
     352    }
     353
    344354        // Build control_pane
    345355        JPanel left = new JPanel();
     
    487497
    488498    /** All implementation of GShellListener must include this method so the listener can be informed of messages from the GShell.
    489      * @param event A <strong>GShellEvent</strong> that contains, amoung other things, the message.
     499     * @param event A <strong>GShellEvent</strong> that contains, among other things, the message.
    490500     */
    491501    public synchronized void message(GShellEvent event) {
     
    619629        document.setSpecialCharacter(OptionsPane.UNSUCCESSFUL);
    620630        }
     631
     632        // If import was cancelled OR an error occurred, move any archives_keepold to archives
     633        if(event.getType() == GShell.IMPORT &&
     634           (event.getStatus() == GShell.CANCELLED || event.getStatus() == GShell.ERROR)) {
     635        //System.err.println("********* in processComplete CANCELLED IMPORT");
     636        moveAnyKeepOldToArchives();
     637        }
     638       
    621639        options_pane.resetFileEntry();
    622640        if(Configuration.getMode() >= THRESHOLD) {
     
    627645    }
    628646
     647    /** Related to file-level document-version (fldv) history mechanism. Dr Bainbridge explained:
     648     * "When cancel is pressed, if there is an 'archives_keepold' then the incomplete 'archives'
     649     * should be removed, and 'archives_keepold' restored back to the 'archives' name."
     650     */
     651    private void moveAnyKeepOldToArchives() {
     652
     653        String archives_keepold = CollectionManager.getLoadedCollectionArchivesKeepOldDirectoryPath();
     654        File archives_keepold_dir = new File(archives_keepold);
     655        if(archives_keepold_dir.exists()) {
     656        String statusMsg = "archives_keepold folder detected. Attempting to restore it as archives...";
     657        //log_textarea.setCaretPosition(document.getLengthToNearestLine());
     658        //document.appendLine(statusMsg);
     659        System.err.println(statusMsg);
     660        this.shell.fireMessage(statusMsg);
     661       
     662        String archives = CollectionManager.getLoadedCollectionArchivesDirectoryPath();
     663        File archives_dir = new File(archives);
     664       
     665        if(archives_dir.exists()) {         
     666            // no special behaviour for remote GS or fedora. The minimal (incr) rebuild
     667            // button is already disabled for remote GS.
     668           
     669            // Locally delete archives dir, and if that worked, rename keepold
     670            if(Utility.delete(archives_dir)) {
     671            // move "archives_keepold" to "archives"
     672            if(!archives_keepold_dir.renameTo(archives_dir)) {
     673                statusMsg = "Failed to rename " + archives_keepold_dir
     674                + "\n  to " + archives_dir;
     675                //document.appendLine(statusMsg);
     676                System.err.println(statusMsg);
     677                this.shell.fireMessage(statusMsg);
     678            }
     679            } else {
     680            statusMsg = "Failed to delete " + archives_dir
     681                + "  in attempt to rename archives_keepold to archives";
     682            //document.appendLine(statusMsg);
     683            System.err.println(statusMsg);
     684            this.shell.fireMessage(statusMsg);
     685            }       
     686        }
     687        // do what the message() method does after appending to document (build log)
     688        //log_textarea.setCaretPosition(document.getLengthToNearestLine());
     689        }
     690    }
    629691
    630692    /** This method is invoked at any time there has been a significant change in the collection, such as saving, loading or creating.
     
    903965        //Gatherer.g_man.lockCollection(false, false);
    904966
    905         // Cancelling building:
    906     // For now, for a GS3 solr collection, we need to stop the GS3 server before building
    907     // and restart it after building is complete. If a cancel is pressed during build
    908     // then we also restart the GS3 server
    909     if(CollectionManager.isSolrCollection()) {
    910         /*GS3ServerThread thread = new GS3ServerThread(Configuration.gsdl3_src_path, "restart");
    911           thread.start();*/
    912     }
    913 
    914 
     967        // Cancelling building:
     968        // For now, for a GS3 solr collection, we need to stop the GS3 server before building
     969        // and restart it after building is complete. If a cancel is pressed during build
     970        // then we also restart the GS3 server
     971        if(CollectionManager.isSolrCollection()) {
     972        /*GS3ServerThread thread = new GS3ServerThread(Configuration.gsdl3_src_path, "restart");
     973          thread.start();*/
     974        }
     975       
    915976    }
    916977    }
  • main/trunk/gli/src/org/greenstone/gatherer/shell/GShell.java

    r31988 r37690  
    713713    // instance of this class for each stream. However, since multiple instances of this LineByLineHandler
    714714    // are firing off events to the same outputstream object (bos) in their own threads, several objects,
    715     // not just bost, needed to be made threadsafe. So gotLine needs to be synchronized, and created a
     715    // not just bos, needed to be made threadsafe. So gotLine needs to be synchronized, and created a
    716716    // synchronized setStatus() method above too.
    717717    // This class also handles exceptions that may occur when reading from the perl process' stderr or stout.
Note: See TracChangeset for help on using the changeset viewer.