The example of using the GetObjects operation to get description of the repository object by its identifier. The request contains identifier of the searched object and additional parameters for searching and filtering objects. The search includes all repository folders (hidden folders included), and various container objects. The response contains description of the found object.
{
"GetObjects" :
{
"tParent" :
{
"id" : "S1!M!0"
},
"tFilter" :
{
"levels" : "-1",
"includeRoot" : "false",
"hideEmptyFolders" : "true",
"hideAllFolders" : "true",
"limit" : "1",
"findInfo" :
{
"active" : "true",
"text" : "NEWFORM",
"attribute" : "Ident",
"caseSensitive" : "false",
"wholeWordsOnly" : "true",
"scanNestedNamespaces" : "true",
"scanHiddenFolders" : "true"
}
},
"tArg" :
{
"pattern" : ""
}
}
}
{
"GetObjectsResult" :
{
"id" :
{
"id" : "S1!M!0"
},
"objects" :
{
"its" :
{
"d" :
{
"@isShortcut" : "0",
"@isLink" : "0",
"@hf" : "0",
"i" : "NEWFORM",
"n" : "NewForm",
"k" : "176175",
"c" : "1538",
"p" : "0",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
}
}
}
}
}
The FindObjectById function specified below searches for the repository object by its identifier and returns its description in case of a successful search. The repository connection moniker and identifier of the required object must be sent as input parameters of the function. The unction results in the object description, or the null value if the object is not found.
public static Od FindObjectById(MbId mb, string id)
{
var somClient = new SomPortTypeClient(); //Proxy object for operation execution
//Operation execution parameters
var tObject = new GetObjects()
{
//Object filtering parameters
tArg = new GetObjectsArg()
{
pattern = new OdsPattern()
},
tFilter = new OdsFilt()
{
limit = 1,
levels = -1,
includeRoot = false,
hideAllFolders = true,
hideEmptyFolders = true,
findInfo = new OdFindInfo()
{
active = true,
attribute = OdFindAttribute.Ident,
caseSensitive = false,
scanHiddenFolders = true,
scanNestedNamespaces = true,
text = id,
wholeWordsOnly = true
}
},
//Specify identifier of the object, which child object are used in search
tParent = new OdId()
{
id = mb.id + "!0" //0 - key of repository root folder
}
};
//Get list of objects according to the specified selection parameters
var result = somClient.GetObjects(tObject);
//Check list of descriptions and return the first found description
//If the list if empty, return Null
var ods = result.objects;
if (ods.its.Length 0)
return ods.its[0];
else
return null;
}
See also: