001package Torello.Java.Build;
002
003import Torello.Java.GSUTIL;
004import Torello.Java.OSResponse;
005
006import Torello.Java.Additional.AppendableSafe;
007import Torello.Java.Additional.BiAppendable;
008
009import static Torello.Java.C.*;
010
011import java.io.IOException;
012import java.io.File;
013
014/**
015 * This is the last 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 involve setting a simple Browser
020 * {@code 'CACHE-CONTROL'} configuration for all Java-Documentation Files on the relevant Google
021 * Cloud Server Storage-Bucket.  The setting prevents browsers from caching Java-Doc Web-Pages so
022 * that development efforts where classes and their members are changing frequently won't be cached
023 * by the browser (and, therefore, won't impede developer-progress)!
024 * 
025 * <EMBED CLASS=external-html DATA-FILE-ID=STAGE_PRIVATE_NOTE>
026 * <EMBED CLASS='external-html' DATA-FILE-ID=S08_SET_MAX_AGE>
027 */
028@Torello.JavaDoc.StaticFunctional
029public class S08_SetMaxAge
030{
031    // Completely irrelevant, and the 'private' modifier keeps it off of JavaDoc
032    private S08_SetMaxAge() { }
033
034    public static void set(BuilderRecord brec) throws IOException
035    {
036        brec.timers.startStage08();
037        Printing.startStep(8);
038
039        StringBuilder logOnly = new StringBuilder();
040
041        final AppendableSafe logAndScreen = new AppendableSafe(
042            new BiAppendable(System.out, logOnly),
043            AppendableSafe.USE_APPENDABLE_ERROR
044        );
045
046
047        // Uses Shell-Contructor:
048        // (outputAppendable, commandStrAppendable, standardOutput, errorOutput)
049
050        // GSUTIL gsutil = new GSUTIL(logOnly, logAndScreen, null, null);
051        brec.cloudSync.initStage(logOnly, logAndScreen);
052
053        OSResponse osr = null;
054
055        if (brec.stage8GCSDirs == null)
056            // osr = gsutil.SMA(brec.cli.GCS_DIR + "**", 120);
057            osr = brec.cloudSync.setMaxAgeAll();
058
059        else
060        {
061            logAndScreen.append(BGREEN + "Set Max Age (Browser-Cache):\n\n" + RESET);
062            for (String gcsDir : brec.stage8GCSDirs) logAndScreen.append('\t' + gcsDir + "\n");
063            logAndScreen.append('\n');
064
065            // osr = gsutil.SMA(brec.stage8GCSDirs, 120);
066            osr = brec.cloudSync.setMaxAgeSome();
067        }
068
069        Util.HALT_ON_ERROR(osr);
070
071        brec.logs.write_S08_LOG(logOnly.toString());
072        brec.cloudSync.endStage();
073        brec.timers.endStage08();
074    }
075}