複製の操作
Content Engine Java™ API および .NET API には、複製をサポートするいくつかのクラスとプロパティーが組み込まれています。
複製の開始
以下のコード例では、複製可能オブジェクトの ReplicationGroup プロパティーを設定して、そのオブジェクトで複製を開始する方法を示します。
Java の例
// Enter the name of an object store
System.out.println("Enter the name of an object store:");
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
String strOSName = in.readLine();
ObjectStore objObjectStore = Factory.ObjectStore.fetchInstance(objDomain, strOSName, null);
objObjectStore.save(RefreshMode.REFRESH);
// Enter the name of a replication group
System.out.println("Enter the name of a replication group:");
String strSearchName = in.readLine();
// Get the ReplicationGroups collection from an existing Domain object
Iterator iter = objDomain.get_ReplicationGroups().iterator();
ReplicationGroup objReplicationGroup = null;
String strName;
// Loop until matching ReplicationGroup object found
while (iter.hasNext())
{
objReplicationGroup = (ReplicationGroup)iter.next();
strName = objReplicationGroup.get_DisplayName();
if (strName.equalsIgnoreCase(strSearchName))
{
// ReplicationGroup object found
System.out.println("Replication group selected: " + strName);
}
}
// Select the Document object on which to initiate replication
System.out.println("Type the path name of the Document (/<folder name>/<containment name>):");
String strPath = in.readLine();
// Retrieve Document object
Document objDoc = Factory.Document.fetchInstance(objObjectStore, strPath, null);
objDoc.save(RefreshMode.REFRESH);
// Set the ReplicationGroup property on the Document object
objDoc.set_ReplicationGroup(objReplicationGroup);
C# の例
// Enter the name of the object store
Console.WriteLine("Enter the name of the object store:");
String strOSName = Console.ReadLine();
IObjectStore objObjectStore = Factory.ObjectStore.FetchInstance(objDomain, strOSName, null);
objObjectStore.Save(RefreshMode.REFRESH);
// Enter the name of a replication group
Console.WriteLine("Enter the name of a replication group:");
String strRGSearchName = Console.ReadLine();
// Get the ReplicationGroups collection from an existing Domain object
IReplicationGroupSet objReplicationGroups = objDomain.ReplicationGroups;
IReplicationGroup objReplicationGroup = null;
String strName;
// Loop until matching ReplicationGroup object found
foreach (IReplicationGroup objRG in objReplicationGroups)
{
strName = objRG.DisplayName;
if (strName.Equals(strRGSearchName, StringComparison.OrdinalIgnoreCase))
{
// ReplicationGroup object found
Console.WriteLine("Replication group selected: " + objRG.DisplayName);
objReplicationGroup = objRG;
Console.WriteLine("Press any key to continue");
Console.ReadLine();
}
}
// Select the Document object on which to initiate replication
Console.WriteLine("Type the path name of the document (/<folder name>/document name>):");
String strPath = Console.ReadLine();
// Retrieve Document object
IDocument objDoc = Factory.Document.FetchInstance(objObjectStore, strPath, null);
// Set the ReplicationGroup property on the Document object
objDoc.ReplicationGroup = objReplicationGroup;
複製されたオブジェクト ID の取得
以下のコード例では、外部リポジトリーで複製されたオブジェクトの ID を取得する方法を示します。
Java の例
// Enter the name of the object store that contains the document
System.out.println("Enter the name of the object store:");
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
String strOSName = in.readLine();
ObjectStore objObjectStore = Factory.ObjectStore.fetchInstance(objDomain, strOSName, null);
objObjectStore.save(RefreshMode.REFRESH);
// Enter the name of the external repository that contains the replica
System.out.println("Enter the name of the external repository:");
String strSearchName = in.readLine();
// Select the Document object from which to retrieve the external replica identity
System.out.println("Type the path name of the Document (/<folder name>/<containment name>):");
String strPath = in.readLine();
// Retrieve document object
Document objDoc = Factory.Document.fetchInstance(objObjectStore, strPath, null);
objDoc.save(RefreshMode.REFRESH);
// Get the list of external replicas of the Document object
Iterator iter = objDoc.get_ExternalReplicaIdentities().iterator();
ExternalIdentity objExternalIdentity = null;
ExternalRepository objExternalRepository = null;
String strName;
// Loop until matching ExternalIdentity object found
while (iter.hasNext())
{
objExternalIdentity = (ExternalIdentity)iter.next();
objExternalRepository = objExternalIdentity.get_ExternalRepository();
strName = objExternalRepository.get_DisplayName();
if (strName.equalsIgnoreCase(strSearchName))
{
// objExternalIdentity object found
String strIdentity = objExternalIdentity.get_ExternalObjectIdentity();
System.out.println("Replica ID selected: " + strIdentity);
}
}
C# の例
// Enter the name of the object store that contains the document
Console.WriteLine("Enter the name of the object store:");
String strOSName = Console.ReadLine();
IObjectStore objObjectStore = Factory.ObjectStore.FetchInstance(objDomain, strOSName, null);
objObjectStore.Save(RefreshMode.REFRESH);
// Enter the name of the external repository containing the replica
Console.WriteLine("Enter the name of the external repository:");
String strSearchName = Console.ReadLine();
// Select the Document object from which to retrieve the external replica identity
Console.WriteLine("Type the path name of the document (/<folder name>/document name>):");
String strPath = Console.ReadLine();
// Retrieve the Document object
IDocument objDoc = Factory.Document.FetchInstance(objObjectStore, strPath, null);
objDoc.Save(RefreshMode.REFRESH);
// Get the list of external replicas of the Document object
IExternalIdentityList objExternalIdentities = objDoc.ExternalReplicaIdentities;
IExternalRepository objExternalRepository = null;
string strName;
// Loop until matching ExternalIdentity object found
foreach (IExternalIdentity objExternalIdentity in objExternalIdentities)
{
objExternalRepository = objExternalIdentity.ExternalRepository;
strName = objExternalRepository.DisplayName;
if (strName.Equals(strSearchName, StringComparison.OrdinalIgnoreCase))
{
// objExternalIdentity object found
String strIdentity = objExternalIdentity.ExternalObjectIdentity;
Console.WriteLine("Replica ID selected: " + strIdentity);
Console.WriteLine("Press any key to continue");
Console.ReadLine();
}
}