Skip to main content

Config.Archives

Class Config.Archives Extends (%Persistent, Config.CommonMultipleMethods, Config.CommonProperties, %SYSTEM.Help) [ Final, Inheritance = right, System = 4 ]

This class allows you to modify and view the [Archives] section of the CPF file through programatic APIs. While properties are usually modified through the System Management portal, there may be some occasion where modifying them through the API's is best for your system. In all the Config methods, if you do not specify the CPFFile parameter, the currently active CPF file is used. If you wish to modify a CPF file which is not the currently active one, then specify the CPFFile you wish to modify in the method call.
The Flags parameter does not normally need to be specified; the defaults are usually sufficient for most cases.
You can use either the provided API's (Create/Get/Modify/Delete) to modify the properties by passing in the correct parameters, or use Object sytax to open and directly manipulate the config objects (Open() and Exists()). Most objects created here need only to specify the Name of the object, and 1 or 2 properties since the the defaults are what are commonly used for most cases.

EXAMPLE:

; Use class methods to create an instance %SYS>s Name="ABC" %SYS>s Properties("Type")="s3" %SYS>s Properties("Location")="s3://myBucket/" %SYS>s Status=##Class(Config.Archives).Create(Name,.Properties) %SYS>i '$$$ISOK(Status) w !,"Error="$SYSTEM.Status.GetErrorText(Status) ; Use class methods to modify properties %SYS>s Status=##Class(Config.Archives).Get(Name,.Properties) %SYS>i '$$$ISOK(Status) w !,"Error="$SYSTEM.Status.GetErrorText(Status) %SYS>zw Properties Properties("Type")="s3" Properties("Location")="s3://myBucket/" %SYS>s Properties("Location")="s3://myBucket2/" %SYS>s Status=##Class(Config.Archives).Modify(Name,.Properties) %SYS>i '$$$ISOK(Status) w !,"Error="$SYSTEM.Status.GetErrorText(Status) ; Now use Objects to modify properties %SYS>s Obj=##Class(Config.Archives).Open(Name) ; We could have used i ##Class(Config.Archives).Exists(Name,.Obj) instead of Open() %SYS>w Obj.Type s3 %SYS>s Obj.Location="s3://myBucket/" %SYS>s Status=Obj.%Save() %SYS>i '$$$ISOK(Status) w !,"Error="$SYSTEM.Status.GetErrorText(Status) ; Now delete the object we just created %SYS>s Status=##Class(Config.Archives).Delete(Name) %SYS>i '$$$ISOK(Status) w !,"Error="_$SYSTEM.Status.GetErrorText(Status)

Parameters

CPFFlags

Parameter CPFFlags [ Internal ] = {1};

{$$$CPFSave};

CAPITALNAME

Parameter CAPITALNAME = 1;

Archive name is always capitalized.

EMSSERVICE

Parameter EMSSERVICE [ Internal ] = "Namespace";

Properties

Type

Property Type As %String;

Location

Property Location As %String(MAXLEN = 4096);

Methods

NameSet

Method NameSet(Val) As %Status [ Internal ]

Force the name to be uppercase.

CreateCallBack

ClassMethod CreateCallBack(Obj As %ObjectHandle, Data As %String) As %Status [ Internal ]

Called by the Create method during import from a CPF file.

ArchiveByName

ClassMethod ArchiveByName(Name As %String) As %String

Return Type,Location of a named archive target.

Default

ClassMethod Default(CPFFile As %String, Platform As %String) As %Status [ Internal ]

Write a default Archives section in a CPF file.

GetLocation

ClassMethod GetLocation(Name As %String) As %String [ Internal ]

Get the archive target's location.
If the archive does not exist in the configuration, it will return null.

Load

ClassMethod Load(Obj As %ObjectHandle = "", Flags As %Integer = 1) As %Status [ Internal ]

Load the parameters into memory and activate.
Parameters:
Obj = Handle to the object which caused the load. If "", then load everything, only called from STU.
If a delete operation, then Obj is the NAME of the item which was deleted since the oject itself has already been deleted.
Flags = Type of modification.
0 - Modify
1 - Create/Insert
2 - Delete

Modify

ClassMethod Modify(Name As %String, ByRef Properties As %String, ByRef CPFFile As %String = "", Flags As %Integer = {$$$CPFSave+$$$CPFWrite+$$$CPFActivate}) As %Status

Modify Dataset section instance in CPF file. If the Server or Directory path is changed, it will be reflected on all Namespaces referring this DB.

Parameters:
Name - Name of the archive target to modify.
Properties (byref) - List of the properties to modify in Properties(Name)=Value format. See the subclass for a list of valid properties. If a specific property is not passed in the properties array, the value is not modified.
CPFFile (byref) - Name of the CPF file to use, Default=current active CPF file.
Flags - Bit string of options to perform. See the Create method for values.

Return values:
CPFFile (byref) - Name of the CPF file the modification was made in.

MoveToActive

ClassMethod MoveToActive(Obj As %ObjectHandle = "", Flags As %Integer = 1) As %Status [ Internal ]

Move the CPF data into the active config global. This also check if any Archive is added/removed/updated in CPF file since last shutdown. And those archives will affect journal setting.

Parameters:
Obj - Handle to Object causing the move

Rename

ClassMethod Rename(OldName As %String, NewName As %String, ByRef CPFFile As %String = "") As %Status

Rename the archive name in the CPF file.

Parameters:
OldName - Name of the archive to rename.
NewName (byref) - New name of the archive.
CPFFile (byref) - Name of the CPF file to use, Default=current active CPF file.

Return values:
CPFFile (byref) - Name of the CPF file the modification was made in.

SynonymArchives

ClassMethod SynonymArchives(Name As DBName, ByRef ArcList As %String, CPFFile As %String = "", Flags As %Integer = 0) As %Status [ Internal ]

Returns a list of archive names whose Type/Location properties are the same as the ones for a given archive for the current configuration.
This will return the passed archive name as one of the matching ones.

IsInUse

ClassMethod IsInUse(Name As DBName) As %Status [ Internal ]

Return whether an archive target is in use (for journal).

%OnAddToSaveSet

Method %OnAddToSaveSet(depth As %Integer = 3, insert As %Integer = 0, callcount As %Integer = 0) As %Status [ Private, ServerOnly = 1 ]

Called from %Save().
Validate the archive info here, and possibly change it.

%OnDeleteCallBack

ClassMethod %OnDeleteCallBack(Obj As %ObjectHandle) As %Status [ Internal ]

Called from %OnDelete.
Returning an error here will keep the archive from being deleted.

%OnValidateObject

Method %OnValidateObject() As %Status [ Internal ]

Called from %Save().
Validate that the archive being created has all its parameters set correctly.
Any error returned here will abort the creation of the archive.

ListExecute

ClassMethod ListExecute(ByRef qHandle As %Binary, Names As %String = "*", CPFFile As %String = "", Flags As %Integer = 0, Format As %Integer = 0) As %Status [ Internal ]

List Archives in a CPF file.

Parameters:
Names - Comma separated list of Archive names
"*" - All records match
"String,String1" - Any records matching one of these elements
"String*" - Any record starting with "String"
"String,String1*,String2" - Any record matching one of these elements, or starting with "String1"
CPFFile - Name of the CPF file to use. A null string means use the active CPF file.
Flags - Type of archives to return 0 - All archives 1 - rsync archives 2 - s3 archives Format
0 - Standard report list format
1 - ^CONFIG global format
2 - CPF file format
Note: This query may change in future versions

ListFetch

ClassMethod ListFetch(ByRef qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ Internal, PlaceAfter = ListExecute ]

ListClose

ClassMethod ListClose(ByRef qHandle As %Binary) As %Status [ Internal, PlaceAfter = ListExecute ]

List1Execute

ClassMethod List1Execute(ByRef %qHandle As %Binary, Names As %String = "*", CPFFile As %String = "", Flags As %Boolean = 0) As %Status [ Internal ]

List Archives in a CPF file. Used internally by the List Query.

Parameters:
Names - Comma separated list of Archive names
"*" - All records match
"String,String1" - Any records matching one of these elements
"String*" - Any record starting with "String"
"String,String1*,String2" - Any record matching one of these elements, or starting with "String1"
CPFFile - Name of the CPF file to use. A null string means use the active CPF file.
Flags - Type of archives to return 0 - All archives 1 - Local archives 2 - Remote archives Note: This query may change in future versions

List1Flags

ClassMethod List1Flags(Flags, Server) As %Boolean [ Internal, SqlProc ]

List1Fetch

ClassMethod List1Fetch(ByRef %qHandle As %Binary, ByRef Row As %List, ByRef AtEnd As %Integer = 0) As %Status [ Internal, PlaceAfter = List1Execute ]

List1Close

ClassMethod List1Close(ByRef %qHandle As %Binary) As %Status [ Internal, PlaceAfter = List1Execute ]

%OnOpen

Method %OnOpen() As %Status [ Private, ServerOnly = 1 ]

This callback method is invoked by the %Open method to provide notification that the object specified by oid is being opened.

If this method returns an error then the object will not be opened.