Package Torello.Java
Class GSUTIL
- java.lang.Object
-
- Torello.Java.OSCommands
-
- Torello.Java.GSUTIL
-
- All Implemented Interfaces:
java.lang.Cloneable
public class GSUTIL extends OSCommands implements java.lang.Cloneable
This Class ExtendsOSCommands
:
ClassOSCommands
is the parent class for all classes which invoke Operating-System Processes using the Java-Standardjava.lang.Process
Object-Utility.OSCommands
has several constructors inherited by this class which allow a user to configure this class for sending its output in any number of ways toAppendable
instances / loggers of your choice. Read this class documentation about invoking a constructor using any number of log-configurations, for sending text-output to any neccessary destination.
All Methods ReturnOSResponse
:
In addition to real-time process-output printing, this class will collect any all text sent to Standard-Output and Error-Output and save theString
-data for return to the user. All Operating-System calls in this class (which are all invoked by these methods, below) will always return an instance ofOSResponse
.
ClassOSResponse
also contains the fieldresponse
, which signals what the OS-Process' return-value was. Operating-Systems, generally, return a'0'
to indicate the process ran to completion without errors, and some other value to signal an error occurred.
ClassOSExtras
has All Additionaljava.lang.Process
Features:java.lang.Process
allows a user to redirect output, and collect-input to and from any number of additional sources. There is copious documentation aboutOSExtras
, explaining these features.
To specialize an Operating-System call with anOSExtras
instance, just call this class'setOSExtras(...)
method, with any neccessary configurations.This class wraps the Google Cloud command-line tool'gsutil'
, simply using the standard Javajava.lang.Process
object (in addition to Java HTML'sOSResponse
) thereby providing a simple Java-API for these operating-system calls.
This class provides an API into Google Cloud Server functions for manipulating Google Cloud's Storage Buckets. This Class facilitates automating calls to the Google Cloud Shell Command-Line utility named'gsutil'
. Making calls to this UNIX-BASH Executable Command can be very cumbersome. This class will help you save repeated calls to this utility inside into Java Class Files, thereby simplifying the development process quite a bit.
The primary advantage of using this class over BASH Shell Scripts ('.sh'
executable-files), is that it allows for a more unified development process.
Google Cloud Server Account:
Realize, use of this class requires a Google Cloud Account, and it requires being logged onto an instance of Google Cloud Shell. None of the classes in theJava HTML JAR Library
require using GCP - except this one!
Wild Cards:
When the GCP Executable'gsutil'
receives a command that contains Wild Cards (which in'gsutil'
include'*'
,'**'
and'?'
), it will expand and handle them. However, the shell instance running the command will not.
WORA:
In its inception, Java made the "Write Once, Run Anywhere" (WORA) pledge. The methods in this class are not in any way "Java-ized" versions of the Operating System Calls. Rather, they are just wrappers aroundjava.lang.Process
allowing a user to BOTH make Operating System calls easily AND to efficiently retrieve the generated text-output produced by the calls.
The bulk-work of the classes in this JAR Library were written and tested in a UNIX environment. While everything in the HTML Package ofJava HTML JAR
is indeed, O/S Independent (adhering to 'WORA'), this class and all classes which extendOSCommands
are highly O/S dependent. The methods in these classes are (for all intents and purposes) a set of hooks into native Operating System calls.
This means that an invocation of these methods while running in the wrong Operating System will just return a bunch of error-output results and thrown exceptions.
Synchronized Methods:
The vast majority of the methods in classOSCommands
are synchronized. Specifically, the methods are declared using the Java Key-Wordsynchronized
(even though Java Doc doesn't output that particular word into its method declarations). This also means that all classes extending and inheritingOSCommands
will all have Thread-Safe andsynchronized
methods.
Whenever a command is issued to this class, execution control for the current thread will not proceed / continue until the external operating system process has finished What that does mean, is that if this class were used by two different threads inside of a multi-threaded application, only one thread would ever be allowed to use this class. If you have a program that needs more than one thread making O/S calls, simply construct a second instance of this class (one for each thread), and any 'locking problems' should be resolved.- See Also:
OSCommands
,OSResponse
Hi-Lited Source-Code:- View Here: Torello/Java/GSUTIL.java
- Open New Browser-Tab: Torello/Java/GSUTIL.java
-
-
Field Summary
'Content-Type' HTTP Meta-Data String-Constants Modifier and Type Field static String
SCT_HTML_UTF8
static String
SCT_JAVASCRIPT
static String
SCT_JAVASCRIPT_UTF8
static String
SCT_TEXT_UTF8
-
Fields inherited from class Torello.Java.OSCommands
appendable, cmdOrCmdAndOutput, errorOutput, osExtras, printCmdAppendable, standardOutput
-
-
Constructor Summary
Constructors Constructor GSUTIL()
GSUTIL(Appendable appendable, boolean cmdOrCmdAndOutput, Appendable printCmdAppendable)
GSUTIL(Appendable appendable, boolean cmdOrCmdAndOutput, Appendable printCmdAppendable, Appendable standardOutput, Appendable errorOutput)
GSUTIL(Appendable standardOutput, Appendable errorOutput)
-
Method Summary
Storage Bucket Contents: Copy Files & Directories Modifier and Type Method OSResponse
CP(Iterable<String> sources, String target, String... switches)
OSResponse
CP(String[] sources, String target, String... switches)
OSResponse
CP(String source, String target, String... switches)
Storage Bucket Contents: Move Files & Directories Modifier and Type Method OSResponse
MV(Iterable<String> sources, String target, String... switches)
OSResponse
MV(String[] sources, String target, String... switches)
OSResponse
MV(String source, String target, String... switches)
Storage Bucket Contents: Delete Files & Directories Modifier and Type Method OSResponse
RM(Iterable<String> iterable, String... switches)
OSResponse
RM(String[] sArr, String... switches)
OSResponse
RM(String s, String... switches)
Storage Bucket Contents: List Files & Directories Modifier and Type Method OSResponse
LS(String s1, String... switches)
Storage Bucket Contents: Synchronize Files & Directories Modifier and Type Method OSResponse
RSYNC(String sources, String target, String... switches)
Google Storage: Make Files Publicly Viewable Modifier and Type Method OSResponse
MP(Iterable<String> iterable, String... extraSwitches)
OSResponse
MP(String[] sArr, String... extraSwitches)
OSResponse
MP(String s1, String... extraSwitches)
Google Storage: Stop Files from being Publicly Viewable Modifier and Type Method OSResponse
SP(Iterable<String> iterable, String... extraSwitches)
OSResponse
SP(String[] sArr, String... extraSwitches)
OSResponse
SP(String s1, String... extraSwitches)
Setting HTTP-Headers for Files: Set Browser-Cache Max-Age Modifier and Type Method OSResponse
SMA(Iterable<String> iterable, int seconds, String... extraSwitches)
OSResponse
SMA(String[] s1Arr, int seconds, String... extraSwitches)
OSResponse
SMA(String s1, int seconds, String... extraSwitches)
Setting HTTP-Headers for Files: Browser-Cache Modifier and Type Method OSResponse
CACHE_CONTROL(Iterable<String> iterable, String cacheControlTags, String... extraSwitches)
OSResponse
CACHE_CONTROL(String[] s1Arr, String cacheControlTags, String... extraSwitches)
OSResponse
CACHE_CONTROL(String s1, String cacheControlTags, String... extraSwitches)
Setting HTTP-Headers for Files: Content-Disposition Modifier and Type Method OSResponse
CONTENT_DISPOSITION(Iterable<String> iterable, String contentDispositionTags, String... extraSwitches)
OSResponse
CONTENT_DISPOSITION(String[] s1Arr, String contentDispositionTags, String... extraSwitches)
OSResponse
CONTENT_DISPOSITION(String s1, String contentDispositionTags, String... extraSwitches)
Setting HTTP-Headers for Files: Content-Encoding Modifier and Type Method OSResponse
CONTENT_ENCODING(Iterable<String> iterable, String contentEncodingTags, String... extraSwitches)
OSResponse
CONTENT_ENCODING(String[] s1Arr, String contentEncodingTags, String... extraSwitches)
OSResponse
CONTENT_ENCODING(String s1, String contentEncodingTags, String... extraSwitches)
Setting HTTP-Headers for Files: Content-Tye Modifier and Type Method OSResponse
CONTENT_TYPE(Iterable<String> iterable, String type, String... extraSwitches)
OSResponse
CONTENT_TYPE(String[] s1Arr, String type, String... extraSwitches)
OSResponse
CONTENT_TYPE(String source, String type, String... extraSwitches)
Setting HTTP-Headers for Files: Customized Meta Data Modifier and Type Method OSResponse
CUSTOM_METADATA(Iterable<String> iterable, String tags, String... extraSwitches)
OSResponse
CUSTOM_METADATA(String[] s1Arr, String metaTag, String... extraSwitches)
OSResponse
CUSTOM_METADATA(String s1, String metaTag, String... extraSwitches)
Methods: interface java.lang.Cloneable Modifier and Type Method GSUTIL
clone()
-
Methods inherited from class Torello.Java.OSCommands
appendable, commandToString, equals, errorOutput, printAndRun, printCmdAppendable, run, run, setAll, setAppendable, setOSExtras, setStandardAndErrorOutput, standardOutput, toString
-
-
-
-
Field Detail
-
SCT_TEXT_UTF8
public static final java.lang.String SCT_TEXT_UTF8
Text-File, Plain, UTF-8. NOTE: May be used for calls toSCT(String s1, String type);
- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final String SCT_TEXT_UTF8 = "text/plain; charset=utf-8";
-
SCT_HTML_UTF8
public static final java.lang.String SCT_HTML_UTF8
Text-File, HTML, UTF-8. NOTE: May be used for calls toSCT(String s1, String type);
- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final String SCT_HTML_UTF8 = "text/html; charset=utf-8";
-
SCT_JAVASCRIPT_UTF8
public static final java.lang.String SCT_JAVASCRIPT_UTF8
Text-file, Java-Script, UTF-8. NOTE: This is to be used for calls toSCT(String s1, String type);
- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final String SCT_JAVASCRIPT_UTF8 = "application/javascript; charset=utf-8";
-
SCT_JAVASCRIPT
public static final java.lang.String SCT_JAVASCRIPT
Text-file, Java-Script. NOTE: This is to be used for calls toSCT(String s1, String type);
- See Also:
- Constant Field Values
- Code:
- Exact Field Declaration Expression:
public static final String SCT_JAVASCRIPT = "application/javascript";
-
-
Constructor Detail
-
GSUTIL
public GSUTIL()
Default constructor for instances inheriting this class. This constructor assigns the default values to all of the output loggingAppendable's
. This constructor's "See Also" section has a link to each of the loggingAppendable's
provided by this class.
Note that all of them are assigned 'null' - meaing their output will not be logged - except for the primary fieldthis.appendable
. This field is assignedSystem.out
, meaning that all text output by a process will be sent to the terminal window.
Description copied in entirety from:OSCommands()
- See Also:
OSCommands()
- Code:
- Exact Constructor Body:
super();
-
GSUTIL
public GSUTIL(java.lang.Appendable appendable, boolean cmdOrCmdAndOutput, java.lang.Appendable printCmdAppendable)
This constructor allows a user to assign theAppendable's
:appendable
&printCmdAppendable
.
The first collects all text-output generated by the processes and prints it using theAppendable's
printing methods. This includes text generated for BOTHStandard-Output
ANDError-Output
. This text is collected in real time as it is output by the underlying process.
The secondAppendable
merely accepts the requested command, itself, as an outputString
. ThisString
is printed using theAppendable's
append(...)
methods.
NOTE: Either of theseAppendable's
may be assigned null, and if they are, they are simply ignored.NullPointerException
won't throw, and the output text will simply not be printed.
Description copied in entirety from:OSCommands(Appendable, boolean, Appendable)
- Parameters:
appendable
- This parameter's reference is assigned directly to theOSCommands
field:appendable
. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendable
that is synonymously namedappendable
simply collects all output text generated by a processes as it executes, and sends it to the reference'sappend(...)
method. This text will include that sent to BOTHStandard-Output
AND text sent toError-Output
. The text that is printed is transmitted in the order it is received from the reader-threads that read the underlying process' text-pipes.
By default this parameter is assignedSystem.out
. When this default value is used, it means that as the process executes, any and all text it prints is sent to the UNIX or MS-DOS Operating System Terminal Window.
This field may be assigned null, and when so it is just ignored. Assigning null toappendable
. will not produce aNullPointerException
.cmdOrCmdAndOutput
- Thisboolean
is assigned to theOSCommands
field namedcmdOrCmdAndOutput
.
Please review the documentation for that field to understand clearly the use of this parameter.printCmdAppendable
- Thisjava.lang.Appendable
allows for yet another output mechanism when executing operating system commands. The sole purpose of thisAppendable
is to print the process command, itself, as a JavaString
- exactly as it was issued to the operating system.
This allows a type of "Monitor Log" to store all commands being issued to the Operating-System, without having to include the full-text output that those process calls have produced. The value passed to this parameter is assigned to theOSCommands
field namedprintCmdAppendable
.
This parameter may be null, and if it is, no such output will be generated.- See Also:
OSCommands.appendable
,OSCommands.cmdOrCmdAndOutput
,OSCommands.printCmdAppendable
,OSCommands(Appendable, boolean, Appendable)
- Code:
- Exact Constructor Body:
super(appendable, cmdOrCmdAndOutput, printCmdAppendable);
-
GSUTIL
public GSUTIL(java.lang.Appendable appendable, boolean cmdOrCmdAndOutput, java.lang.Appendable printCmdAppendable, java.lang.Appendable standardOutput, java.lang.Appendable errorOutput)
Constructor that allows for assigning all four text-collectingAppendable's
. Please review the documentation for each of these fields to understand better how theseAppendable's
may be used.
NOTE: Any of theseAppendable's
may be assigned null, and if they are, they are simply ignored.NullPointerException
won't throw, and the relevant output text that would normally be appended to it, will simply not be appended.
Description copied in entirety from:OSCommands(Appendable, boolean, Appendable, Appendable, Appendable)
- Parameters:
appendable
- This parameter's reference is assigned directly to theOSCommands
field:appendable
. To clearly understand the use of this field, please review the documentation linked for that field. To summarize, thejava.lang.Appendable
that is synonymously namedappendable
simply collects all output text generated by a processes as it executes, and sends it to the reference'sappend(...)
method. This text will include that sent to BOTHStandard-Output
AND text sent toError-Output
. The text that is printed is transmitted in the order it is received from the reader-threads that read the underlying process' text-pipes.
By default this parameter is assignedSystem.out
. When this default value is used, it means that as the process executes, any and all text it prints is sent to the UNIX or MS-DOS Operating System Terminal Window.
This field may be assigned null, and when so it is just ignored. Assigning null toappendable
. will not produce aNullPointerException
.cmdOrCmdAndOutput
- Thisboolean
is assigned to theOSCommands
field namedcmdOrCmdAndOutput
.
Please review the documentation for that field to understand clearly the use of this parameter.printCmdAppendable
- Thisjava.lang.Appendable
allows for yet another output mechanism when executing operating system commands. The sole purpose of thisAppendable
is to print the process command, itself, as a JavaString
- exactly as it was issued to the operating system.
This allows a type of "Monitor Log" to store all commands being issued to the Operating-System, without having to include the full-text output that those process calls have produced. The value passed to this parameter is assigned to theOSCommands
field namedprintCmdAppendable
.
This parameter may be null, and if it is, no such output will be generated.standardOutput
- ThisAppendable
is assigned to the internalOSCommands
field:standardOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toStandard-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.errorOutput
- ThisAppendable
is assigned to the internalOSCommands
field:errorOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toError-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.- See Also:
OSCommands.appendable
,OSCommands.cmdOrCmdAndOutput
,OSCommands.printCmdAppendable
,OSCommands.standardOutput
,OSCommands.errorOutput
,OSCommands(Appendable, boolean, Appendable, Appendable, Appendable)
- Code:
- Exact Constructor Body:
super(appendable, cmdOrCmdAndOutput, printCmdAppendable, standardOutput, errorOutput);
-
GSUTIL
public GSUTIL(java.lang.Appendable standardOutput, java.lang.Appendable errorOutput)
This constructor retains all default values for the internal fields of this class, except for the twoOSCommands
Appendable
fields listed, namely:standardOutput
anderrorOutput
Description copied in entirety from:OSCommands(Appendable, Appendable)
- Parameters:
standardOutput
- ThisAppendable
is assigned to the internalOSCommands
field:standardOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toStandard-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.errorOutput
- ThisAppendable
is assigned to the internalOSCommands
field:errorOutput
. ThisAppendabe
, as the name hopefully implies, allows a user to collect any / all text sent by the process toError-Output
.
Please review the documentation for that field to better understand it's use. Also, keep in mind that null may be passed to this parameter, and if / when it is the correspondingAppendable
field will simply be ignored during the process execution.- See Also:
OSCommands.standardOutput
,OSCommands.errorOutput
,OSCommands(Appendable, Appendable)
- Code:
- Exact Constructor Body:
super(standardOutput, errorOutput);
-
-
Method Detail
-
clone
public GSUTIL clone()
Creates a clone of'this'
instance. Though unlikely of much use, this could conceivably have some function if similar, but non-identical, output mechanisms were being used.- Specified by:
clone
in classOSCommands
- Returns:
- An exact copy of
'this'
instance ofGSUTIL
- one in which all outputAppendable's
have had their references copied into the new instance. - Code:
- Exact Method Body:
return new GSUTIL( this.appendable, this.cmdOrCmdAndOutput, this.printCmdAppendable, this.standardOutput, this.errorOutput );
-
RM
public OSResponse RM(java.lang.String s, java.lang.String... switches) throws java.io.IOException
Calls gsutil with"rm"
arguments.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m rm <switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s
- The GCS bucket-storage address of files to delete. Can Include wildcards:'*'
and'**'
switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "rm" }, switches, s, NO_TARGET); return printAndRun(command);
-
RM
public OSResponse RM(java.lang.Iterable<java.lang.String> iterable, java.lang.String... switches) throws java.io.IOException
- Code:
- Exact Method Body:
return RM(TO_ARRAY(iterable), switches);
-
RM
public OSResponse RM(java.lang.String[] sArr, java.lang.String... switches) throws java.io.IOException
Calls gsutil with"rm"
arguments.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m rm <switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sArr
- The list GCS bucket-storage address of files to delete. Can Include wildcards:'*'
and'**'
switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "rm" }, switches, sArr, NO_TARGET); return printAndRun(command);
-
MV
public OSResponse MV(java.lang.String source, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Calls gsutil with"mv"
arguments.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m mv <switches> <source(s)> <target>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
source
- The GCS bucket-storage source-address. Can Include wildcards:'*'
and'**'
target
- The GCS bucket-storage target-address.switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "mv" }, switches, source, target); return printAndRun(command);
-
MV
public OSResponse MV(java.lang.Iterable<java.lang.String> sources, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Convenience Method
Invokes:MV(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return MV(TO_ARRAY(sources), target, switches);
-
MV
public OSResponse MV(java.lang.String[] sources, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Calls gsutil with"mv"
arguments.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m mv <switches> <source(s)> <target>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sources
- A list of arguments that need to be copied, as an array. Can Include wildcards:'*'
and'**'
target
- The target/destination address for the list of files to be copied.switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "mv" }, switches, sources, target); return printAndRun(command);
-
CP
public OSResponse CP(java.lang.String source, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Calls gsutil with the"cp"
argument.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m cp <switches> <source(s)> <target>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
source
- The GCS bucket-storage source-address, or local BASH shell source-address. Can Include wildcards:'*'
and'**'
target
- The GCS bucket-storage target-address, or local BASH shell target-address.switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "cp" }, switches, source, target); return printAndRun(command);
-
CP
public OSResponse CP(java.lang.Iterable<java.lang.String> sources, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Convenience Method
Invokes:CP(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CP(TO_ARRAY(sources), target, switches);
-
CP
public OSResponse CP(java.lang.String[] sources, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Calls gsutil with the"cp"
argument.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m cp <switches> <source(s)> <target>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sources
- A list of arguments that need to be copied, as an array. Can Include wildcards:'*'
and'**'
target
- The target/destination address for the list of files to be copied.switches
- This may be appended to the command, providing Google's'gsutil'
with switches.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "cp" }, switches, sources, target); return printAndRun(command);
-
RSYNC
public OSResponse RSYNC(java.lang.String sources, java.lang.String target, java.lang.String... switches) throws java.io.IOException
Calls gsutil with arguments:"-m rsync ..."
. This method synchronizes a local directory with the directory in a Google Cloud Storage Bucket.
NOTE: 'rsync' crashed my whole cloud-shell... Use at your discretion. The command was properly formed, to the best of my knowledge. It complained of 'egress' for quite a few days after using gsutil with the'rsync'
option.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m rsync <switches> <source(s)> <target>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sources
- The source-address.target
- The target-address.switches
- This may be appended to the command, providing Google's'gsutil'
with switches.
'-d' : This will inform GSUTIL to remove files that are not found in the users directory, but are sitting on the Storage Bucket Server Location - in the corresponding / same directory
'-r' : This will cause the sync to run recursively.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND (new String[] { "gsutil", "-m", "rsync" }, switches, sources, target); return printAndRun(command);
-
MP
public OSResponse MP(java.lang.String s1, java.lang.String... extraSwitches) throws java.io.IOException
MP stands for "Make Public" - and this method is used to force the target file or files on Google Cloud Server to become "visible" to the public. It updates the Access Control List.
SPECIFICALLY: It grants read access to the public / "AllUsers". This is the most-common means I have found for allowing the Google-Web-Server to serve up files from a Google Cloud Storage Bucket. Remember, this only works if you have registered your bucket with a domain-name server. This is usually around $12 per year.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m acl ch -u AllUsers:R <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- The GCS bucket file or directory address. Note'*'
or'**'
may be used here.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "acl", "ch", "-u", "AllUsers:R" }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
MP
public OSResponse MP(java.lang.Iterable<java.lang.String> iterable, java.lang.String... extraSwitches) throws java.io.IOException
- Code:
- Exact Method Body:
return MP(TO_ARRAY(iterable), extraSwitches);
-
MP
public OSResponse MP(java.lang.String[] sArr, java.lang.String... extraSwitches) throws java.io.IOException
MP stands for "Make Public" - and this method is used to force the target file or files on Google Cloud Server to become "visible" to the public. It updates the Access Control List.
SPECIFICALLY: It grants read access to the public / "AllUsers". This is the most-common means I have found for allowing the Google-Web-Server to serve up files from a Google Cloud Storage Bucket. Remember, this only works if you have registered your bucket with a domain-name server. This is usually around $12 per year.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m acl ch -u AllUsers:R <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sArr
- The GCS bucket file or directory addresses. Note'*'
or'**'
may be used here.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "acl", "ch", "-u", "AllUsers:R" }, extraSwitches, sArr, NO_TARGET ); return printAndRun(command);
-
SP
public OSResponse SP(java.lang.String s1, java.lang.String... extraSwitches) throws java.io.IOException
SP stands for "Stop Public" - and this method is used to force the target file or files on Google Cloud Server to become "invisible" to the public. It updates the Access Control List.
SPECIFICALLY: It revokes read access to the public / "AllUsers".
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m acl ch -d AllUsers <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- The GCS bucket file or directory address. Note'*'
or'**'
may be used here.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to stop the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "acl", "ch", "-d", "AllUsers" }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
SP
public OSResponse SP(java.lang.Iterable<java.lang.String> iterable, java.lang.String... extraSwitches) throws java.io.IOException
- Code:
- Exact Method Body:
return SP(TO_ARRAY(iterable), extraSwitches);
-
SP
public OSResponse SP(java.lang.String[] sArr, java.lang.String... extraSwitches) throws java.io.IOException
SP stands for "Stop Public" - and this method is used to force the target file or files on Google Cloud Server to become "invisible" to the public. It updates the Access Control List.
SPECIFICALLY: It revokes read access to the public / "AllUsers".
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m acl ch -d AllUsers <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
sArr
- The GCS bucket file or directory address. Note'*'
or'**'
may be used here.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to stop the public-visibility of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "acl", "ch", "-d", "AllUsers" }, extraSwitches, sArr, NO_TARGET ); return printAndRun(command);
-
SMA
public OSResponse SMA(java.lang.String s1, int seconds, java.lang.String... extraSwitches) throws java.io.IOException
SMA is short of "Set Max Age." This handles the problem of browsers that cache stale output data. When the "max-age" meta-tag is set to zero, your browser will always poll the Google Cloud Server for new page-information, rather than relying on cached pages. This method is extremely helpful if you are debugging and changing web-content while hosting a web-site domain using GCS Storage Buckets.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Cache-Control:public, max-age=<seconds>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- The GCS bucket-storage address. gs://bucket-name/directoryname/filename
NOTE: "filename" may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.seconds
- This parameter is added to the end of the max-age= string in the cmdSMA argument list. It represents the number of seconds a browser is allowed to cache a page.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the max-age of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", ("Cache-Control:public, max-age=" + seconds + "") }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
SMA
public OSResponse SMA(java.lang.Iterable<java.lang.String> iterable, int seconds, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:SMA(String[], int, String[])
.
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return SMA(TO_ARRAY(iterable), seconds, extraSwitches);
-
SMA
public OSResponse SMA(java.lang.String[] s1Arr, int seconds, java.lang.String... extraSwitches) throws java.io.IOException
SMA is short of "Set Max Age." This handles the problem of browsers that cache stale output data. When the "max-age" meta-tag is set to zero, your browser will always poll the Google Cloud Server for new page-information, rather than relying on cached pages. This method is extremely helpful if you are debugging and changing web-content while hosting a web-site domain using GCS Storage Buckets.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Cache-Control:public, max-age=<seconds>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
seconds
- This parameter is added to the end of the max-age= string in the cmdSMA argument list. It represents the number of seconds a browser is allowed to cache a page.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the max-age of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", ("Cache-Control:public, max-age=" + seconds + "") }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
CONTENT_TYPE
public OSResponse CONTENT_TYPE(java.lang.String source, java.lang.String type, java.lang.String... extraSwitches) throws java.io.IOException
Whenever programming involves foreign-languages or UTF-8, this can be a meta-tag (or web-server setting) that has to be set. It is not mandatory to set this meta-tag with Google-Cloud-Server when working with higher-order UTF-8 character-data, because the meta-information can be placed inside the HTML page itself. However, this is an "alternative-option" to putting meta-information inside your server pages header-sections.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Type: <type>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
NOTE: Most often, I use this command to set files to "UTF-8" and not Plain-Old ASCII (like here):"Content-Type: text/plain; charset=utf-8"
- Parameters:
source
- This is the parameter is supposed to be a file, directory, or expression sequence.
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.type
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Type". There are several pre-defined content-type strings defined in this class that make reasonable values for this parameter.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-type of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
SCT_TEXT_UTF8
,SCT_HTML_UTF8
,SCT_JAVASCRIPT
,OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Type: " + type }, extraSwitches, source, NO_TARGET ); return printAndRun(command);
-
CONTENT_TYPE
public OSResponse CONTENT_TYPE (java.lang.Iterable<java.lang.String> iterable, java.lang.String type, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:CONTENT_TYPE(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CONTENT_TYPE(TO_ARRAY(iterable), type, extraSwitches);
-
CONTENT_TYPE
public OSResponse CONTENT_TYPE(java.lang.String[] s1Arr, java.lang.String type, java.lang.String... extraSwitches) throws java.io.IOException
Whenever programming involves foreign-languages or UTF-8, this can be a meta-tag (or web-server setting) that has to be set. It is not mandatory to set this meta-tag with Google-Cloud-Server when working with higher-order UTF-8 character-data, because the meta-information can be placed inside the HTML page itself. However, this is an "alternative-option" to putting meta-information inside your server pages header-sections.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Type: <type>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.
NOTE: Most often, I use this command to set files to "UTF-8" and not Plain-Old ASCII (like here):"Content-Type: text/plain; charset=utf-8"
- Parameters:
s1Arr
- The GCS bucket-storage address list. gs://bucket-name/directoryname/filename
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.type
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Type". There are several pre-defined content-type strings defined in this class that make reasonable values for this parameter.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-type of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
SCT_TEXT_UTF8
,SCT_HTML_UTF8
,SCT_JAVASCRIPT
,OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Type: " + type }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
CACHE_CONTROL
public OSResponse CACHE_CONTROL(java.lang.String s1, java.lang.String cacheControlTags, java.lang.String... extraSwitches) throws java.io.IOException
Cache-Control
is an HTTP setting, much likeContent-Type
. This HTTP-Handshake setting informs a web-browser what the rules need to be as far as caching web-pages. Some web-pages have extremely static-content that will never change, and when a browser caches this content, there will be no loss of information to the end-user. Other-times web-pages are returned from live-data-feeds that change the content of the page often. This method here is a more generalized version of the method above namedpublic static void SMA(...)
- which stands for 'set max age'. Setting the max-age allows a web-programmer to specify that certain files should not be cached by the web-browser.
AS AN ASIDE: A very large head-ache in the development process with Google Cloud Server Storage Buckets is remembering to set the "Max-Age" to ZERO, to guarantee that after each iteration of coding or developing, when HTML files are updated and replaced, the browser being used to look at the HTML does not cache the previous iteration/data results.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Cache-Control: <cacheControlTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- This is the parameter is supposed to be a file, directory, or expression sequence
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.cacheControlTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Cache-Control"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the cache-control of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Cache-Control: " + cacheControlTags }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
CACHE_CONTROL
public OSResponse CACHE_CONTROL (java.lang.Iterable<java.lang.String> iterable, java.lang.String cacheControlTags, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:CACHE_CONTROL(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CACHE_CONTROL(TO_ARRAY(iterable), cacheControlTags, extraSwitches);
-
CACHE_CONTROL
public OSResponse CACHE_CONTROL(java.lang.String[] s1Arr, java.lang.String cacheControlTags, java.lang.String... extraSwitches) throws java.io.IOException
Cache-Control
is an HTTP setting, much likeContent-Type
. This HTTP-Handshake setting informs a web-browser what the rules need to be as far as caching web-pages. Some web-pages have extremely static-content that will never change, and when a browser caches this content, there will be no loss of information to the end-user. Other-times web-pages are returned from live-data-feeds that change the content of the page often. This method here is a more generalized version of the method above namedpublic static void SMA(...)
- which stands for 'set max age'. Setting the max-age allows a web-programmer to specify that certain files should not be cached by the web-browser.
AS AN ASIDE: A very large head-ache in the development process with Google Cloud Server Storage Buckets is remembering to set the "Max-Age" to ZERO, to guarantee that after each iteration of coding or developing, when HTML files are updated and replaced, the browser being used to look at the HTML does not cache the previous iteration/data results.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Cache-Control: <cacheControlTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1Arr
- This is the parameter is supposed to be a file, directory, or expression sequence.
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.cacheControlTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Cache-Control"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the cache-control of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Cache-Control: " + cacheControlTags }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
CONTENT_ENCODING
public OSResponse CONTENT_ENCODING(java.lang.String s1, java.lang.String contentEncodingTags, java.lang.String... extraSwitches) throws java.io.IOException
Content-Encoding
is an HTTP setting, much likeContent-Type
, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Encoding: <contentEncodingTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- This is the parameter is supposed to be a file, directory, or expression sequence
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.contentEncodingTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Encoding"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-encoding of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Encoding: " + contentEncodingTags }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
CONTENT_ENCODING
public OSResponse CONTENT_ENCODING(java.lang.String[] s1Arr, java.lang.String contentEncodingTags, java.lang.String... extraSwitches) throws java.io.IOException
Content-Encoding
is an HTTP setting, much likeContent-Type
, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Encoding: <contentEncodingTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1Arr
- This is the parameter is supposed to be a file, directory, or expression sequence.
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.contentEncodingTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Encoding"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-encoding of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Encoding: " + contentEncodingTags }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
CONTENT_ENCODING
public OSResponse CONTENT_ENCODING (java.lang.Iterable<java.lang.String> iterable, java.lang.String contentEncodingTags, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:CONTENT_ENCODING(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CONTENT_ENCODING(TO_ARRAY(iterable), contentEncodingTags, extraSwitches);
-
CONTENT_DISPOSITION
public OSResponse CONTENT_DISPOSITION (java.lang.String s1, java.lang.String contentDispositionTags, java.lang.String... extraSwitches) throws java.io.IOException
Content-Disposition
is an HTTP setting, much likeContent-Type
, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Disposition: <contentDispositionTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- This is the parameter is supposed to be a file, directory, or expression sequence
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.contentDispositionTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Disposition"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-disposition of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Disposition: " + contentDispositionTags }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
CONTENT_DISPOSITION
public OSResponse CONTENT_DISPOSITION (java.lang.Iterable<java.lang.String> iterable, java.lang.String contentDispositionTags, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:CONTENT_DISPOSITION(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CONTENT_DISPOSITION(TO_ARRAY(iterable), contentDispositionTags, extraSwitches);
-
CONTENT_DISPOSITION
public OSResponse CONTENT_DISPOSITION (java.lang.String[] s1Arr, java.lang.String contentDispositionTags, java.lang.String... extraSwitches) throws java.io.IOException
Content-Disposition
is an HTTP setting, much likeContent-Type
, but for the purposes of News-Scraping and other Internet Publishing, it has not been used much, if at all, during the development of these packages.
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h "Content-Disposition: <contentDispositionTags>" <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, in case multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1Arr
- This is the parameter is supposed to be a file, directory, or expression sequence.
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.contentDispositionTags
- This is any'String'
that may be used with Google Cloud Server. Must pertain to "Content-Disposition"extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the content-disposition of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", "Content-Disposition: " + contentDispositionTags }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
CUSTOM_METADATA
public OSResponse CUSTOM_METADATA(java.lang.String s1, java.lang.String metaTag, java.lang.String... extraSwitches) throws java.io.IOException
This just allows you to set custom HTTP-Header tags. When reviewing the Google Cloud Server Documentation Pages for'GSUTIL'
they provide this example of a "Custom Meta HTTP Tag." The following text-and-example are directly copied from:
https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadataAll fields and their values must consist only of ASCII characters, with the exception of values for x-goog-meta- fields, which may contain arbitrary Unicode values. Note that when setting metadata using the XML API, which sends custom metadata as HTTP headers, Unicode characters will be encoded using UTF-8, then url-encoded to ASCII. For example:
UNIX or DOS Shell Command:
gsutil setmeta -h "x-goog-meta-foo: ã" gs://bucket/objectwould store the custom metadata key-value pair of"foo"
and"%C3%A3".
Subsequently, running"ls -L"
using the JSON API to list the object's metadata would print"%C3%A3"
, while"ls -L"
using the XML API would url-decode this value automatically, printing the character"ã".
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h <metaTag> <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- This is the parameter is supposed to be a file, directory, or expression sequence
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.metaTag
- This is any'String'
that may be used with Google Cloud Server's'setmeta'
parameter forgsutil
.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the meta-information of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", metaTag }, extraSwitches, s1, NO_TARGET ); return printAndRun(command);
-
CUSTOM_METADATA
public OSResponse CUSTOM_METADATA (java.lang.Iterable<java.lang.String> iterable, java.lang.String tags, java.lang.String... extraSwitches) throws java.io.IOException
Convenience Method
Invokes:CUSTOM_METADATA(String[], String, String[])
Converts:Iterable<String>
toString[] Array
- Code:
- Exact Method Body:
return CUSTOM_METADATA(TO_ARRAY(iterable), tags, extraSwitches);
-
CUSTOM_METADATA
public OSResponse CUSTOM_METADATA(java.lang.String[] s1Arr, java.lang.String metaTag, java.lang.String... extraSwitches) throws java.io.IOException
This just allows you to set custom HTTP-Header tags. When reviewing the Google Cloud Server Documentation Pages for'GSUTIL'
they provide this example of a "Custom Meta HTTP Tag." The following text-and-example are directly copied from:
https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadataAll fields and their values must consist only of ASCII characters, with the exception of values for x-goog-meta- fields, which may contain arbitrary Unicode values. Note that when setting metadata using the XML API, which sends custom metadata as HTTP headers, Unicode characters will be encoded using UTF-8, then url-encoded to ASCII. For example:
UNIX or DOS Shell Command:
gsutil setmeta -h "x-goog-meta-foo: ã" gs://bucket/objectwould store the custom metadata key-value pair of"foo"
and"%C3%A3".
Subsequently, running"ls -L"
using the JSON API to list the object's metadata would print"%C3%A3"
, while"ls -L"
using the XML API would url-decode this value automatically, printing the character"ã".
The four primary "HTTP Settings" according to Google Cloud Server Storage Buckets include:Content-Type, Content-Encoding, Content-Disposition, Content-Language, Cache-Control
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil -m setmeta -h <metaTag> <extra-switches> <source(s)>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1Arr
- This is the parameter is supposed to be a file, directory, or expression sequence.
NOTE: The'source(s)'
may contain the asterisks'*'
or anything that would normally be passed to gsutil on the shell command-line.metaTag
- This is any'String'
that may be used with Google Cloud Server's'setmeta'
parameter forgsutil
.extraSwitches
- This may be appended to the command, providing Google's'gsutil'
with switches. The salient arguments to set the meta-information of a web-page have already been included. This parameter is only important if there are other switches, in addition to the ones already used by the constructor for this command.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- If there are any problems while invoking the operating-system command- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND( new String[] { "gsutil", "-m", "setmeta", "-h", metaTag }, extraSwitches, s1Arr, NO_TARGET ); return printAndRun(command);
-
LS
public OSResponse LS(java.lang.String s1, java.lang.String... switches) throws java.io.IOException
Lists the contents of a directory in a Google Cloud Storage Bucket.
Google Cloud Shell Equivalent:
user@cloudshell:
~
(project-ID)
$ gsutil ls <fileOrDir>
Google Note: Google expects that when multiple files or directories are processed, that a'-m'
flag is passed to the command to increase efficiency. Therefore, whenever multiple files or directories are passed to the source parameters, this flag is added to the command, automatically.- Parameters:
s1
- The GCS storage file or directory. Note:'*'
or'**'
may be used.- Returns:
- Returns an instance of
OSResponse
. This response-Object
(data-record) class holds threepublic, final
fields:
① Processresponse-code
② Text sent toStandard-Output
(as ajava.lang.String
)
③ Text sent toError-Output
(also as aString
)
ThisOSResponse
instance may be discarded without any effect onProcess
Execution. It is only provided as a convenience in case more information is required about the results of theO/S
command invocation.
Process Status: Upon completion of this method, theOperating-System java.lang.Process
is guaranteed to have run to completion. - Throws:
java.io.IOException
- See Also:
OSCommands.printAndRun(String[])
- Code:
- Exact Method Body:
String[] command = BUILD_COMMAND(new String[] { "gsutil", "ls" }, switches, s1, NO_TARGET); return printAndRun(command);
-
-