001package Torello.Java.Build;
002
003import Torello.Java.GSUTIL;
004import Torello.Java.Shell;
005import Torello.Java.OSResponse;
006
007import Torello.Java.UnreachableError;
008
009import Torello.JDUInternal.Parse.Java.JSCF.JavaSourceCodeFile;
010
011import java.io.IOException;
012import java.io.File;
013
014/**
015 * This is the seventh Build-Stage, and it is part of the synchronization of a project with Google
016 * Cloud Platform Stroage Buckets.  This class relies heavily on the GCP Shell-Command
017 * {@code 'gsutil'} and it's Java implementation - {@link GSUTIL Torello.Java.GSUTIL}.
018 * 
019 * <BR /><BR />This class' synchronization-efforts entail copying the local / File-System 
020 * Log-Files onto the (User-Specified) Google Cloud Server Storage-Bucket.
021 * 
022 * <EMBED CLASS=external-html DATA-FILE-ID=STAGE_PRIVATE_NOTE>
023 * <EMBED CLASS='external-html' DATA-FILE-ID=S07_SYNC_LOGS>
024 */
025@Torello.JavaDoc.StaticFunctional
026public class S07_SyncLogs
027{
028    // Completely irrelevant, and the 'private' modifier keeps it off of JavaDoc
029    private S07_SyncLogs() { }
030
031
032    // ********************************************************************************************
033    // ********************************************************************************************
034    // Copies The Log Files to GCS
035    // ********************************************************************************************
036    // ********************************************************************************************
037
038
039    public static void sync(final BuilderRecord brec) throws IOException
040    {
041        brec.timers.startStage07();
042        Printing.startStep(7);
043
044
045        // final String CLOUD_LOG_DIR = brec.cli.GCS_DIR + "logs/";
046        // 
047        // Uses Shell-Contructor:
048        // (outputAppendable, commandStrAppendable, standardOutput, errorOutput)
049
050        // GSUTIL gsutil = new GSUTIL(System.out, System.out, null, null);
051        brec.cloudSync.initStageLogSync();
052
053        // OSResponse osr = gsutil.CP(brec.logs.LOG_DIR + '*', GCS_LOG_DIR);
054        OSResponse osr = brec.cloudSync.copyLogDirToCloud();
055        Util.HALT_ON_ERROR(osr);
056        System.out.println();
057
058        // osr = gsutil.CONTENT_TYPE(GCS_LOG_DIR + "*.html", GSUTIL.SCT_HTML_UTF8);
059        osr = brec.cloudSync.setCloudLogsContentType();
060        Util.HALT_ON_ERROR(osr);
061        System.out.println();
062
063
064        // JavaHTML.torello.directory has bucket-level public access
065        // if (brec.RUN_MAKE_PUBLIC)
066    
067        if (brec.cloudSync.shouldRunMakePublic)
068        {
069            // osr = gsutil.MP(CLOUD_LOG_DIR + "*");
070            osr = brec.cloudSync.makeLogsPublic();
071            Util.HALT_ON_ERROR(osr);
072            System.out.println();
073        }
074
075        brec.cloudSync.endStage();
076        brec.timers.endStage07();
077    }
078}