Deleting documents and versions of documents
Getting a document by its name shows how to retrieve a document when you know its name (i.e., its unique identifier). The logic is very similar to deleting a document and deleting a version of a document.
To delete a document when you know its name, call
IxiaDocumentServices.RemoveDocuments
:
// The document to be deleted:
String documentName = ... ;
...
// Delete the document from this document base:
IxiaDocBaseServices docbase = ... ;
...
// Get a DocumentServices object for the docbase
IxiaDocumentServices ds = docbase.DocumentServices;
// An array of documents to be deleted. We need only one element:
String [] documents = new String[1];
// Insert the one document into the array:
documents[0] = documentName;
// This call will delete <documentName> from <docbase>:
ds.RemoveDocuments (documents);
To delete one version of a document without deleting the rest of the documents,
append the version number to the document's name, then call
IxiaDocumentServices.RemoveVersions
:
// We'll delete version 2 of this document:
String documentName = ... ;
String documentAndVersion = documentName + ";2" ;
...
// We'll delete <documentAndVersion> from this document base:
IxiaDocBaseServices docbase = ... ;
...
// Get a DocumentServices object for the docbase:
IxiaDocumentServices ds = docbase.DocumentServices;
// An array of document;versions to be deleted. We need only one element:
String [] documents = new String[1];
// Insert <documentAndVersion> into the array:
documents[0] = documentAndVersion;
// This call will delete version 2 of <documentName> from <docbase>,
// while leaving other versions untouched:
ds.RemoveVersions (documents);
Note: There are several overloaded versions of
RemoveDocuments
and
RemoveVersions
: see class
IxiaDocumentServices and/or class
IxiaMetaServices. Use them to delete documents and versions
from multiple document bases, to use various data structures to store the list of
documents, and so forth.