Content Management and Capture

 View Only
  • 1.  Update storage policy in class definition

    Posted Tue February 01, 2022 06:24 AM
    Hi,

    I would like to update the storage policy of all document class definition (p.e. StoreSearches, Code modules, ...) programmatically.
    I fetch all DocumentClassDefinition objects but the property StoragePolicy is not in the property cache even if fetched with a property filter.

    How to retrieve and update this proeprty ? It is possible for a class definition in the ACCE interface.

    Thanks for help

    ------------------------------
    Yannick Martin
    ------------------------------


  • 2.  RE: Update storage policy in class definition

    IBM Champion
    Posted Wed February 02, 2022 11:22 AM
    The following C# Fragment creates a file system storage device, a advanced storage area, storage policy and assigns it to a document class. It is a fragment plus it contains ugly comments in German, so take some drugs beforehand :-) but you will get the idea. It was just a  prototyped code, so nevermind coding style.
    And don't be frustrated, it took me half a day to figure it out.

    have fun,
    /gerold

    IObjectStore TargetOS = ObjectStore.FetchInstance(domain, configComponents[OBJECTSTORE], null);

    //Create the Filesystem Storage Device
    Console.WriteLine(DateTime.Now + " Erzeugen des Filesystem Storage Devices " + configComponents[STORAGEDEVICEDISPLAYNAME] + " auf" + configComponents[ROOTPATH]);

    FileNet.Api.Admin.ICmFileSystemStorageDevice fssd = Factory.CmFileSystemStorageDevice.CreateInstance(TargetOS, null);
    fssd.DescriptiveText = configComponents[STORAGEDEVICEDESCRIPTIVETEXT];
    fssd.DisplayName = configComponents[STORAGEDEVICEDISPLAYNAME];
    fssd.RootDirectoryPath = configComponents[ROOTPATH];
    fssd.UpperDirectoryCount = Convert.ToInt32(configComponents[UPPERDIR]);
    fssd.LowerDirectoryCount = Convert.ToInt32(configComponents[LOWERDIR]);
    fssd.Save(FileNet.Api.Constants.RefreshMode.REFRESH);
    Console.WriteLine(DateTime.Now + " Filesystem Storage Device erfolgreich erzeugt");
    Console.WriteLine(DateTime.Now + " Erzeugen einer Storage Device Connection");

    //Create a Storage Device Connection
    FileNet.Api.Admin.ICmStorageDeviceConnection sdc = Factory.CmStorageDeviceConnection.CreateInstance(TargetOS);
    sdc.ReplicaSynchronizationType = FileNet.Api.Constants.ReplicaSynchronizationType.PRIMARY;
    sdc.StorageDevice = fssd;

    Console.WriteLine(DateTime.Now + " Erzeugen einer Storage Device Connection LIST");
    //Create a Storage Device Connection LIST
    FileNet.Api.Collection.ICmStorageDeviceConnectionList sdcl = Factory.CmStorageDeviceConnection.CreateList();
    //Add connection to list
    sdcl.Add(sdc);

    Console.WriteLine(DateTime.Now + " Erzeugen einer Advanced Storage Area");

    //Create an advanced storage area
    FileNet.Api.Admin.ICmAdvancedStorageArea asa = Factory.CmAdvancedStorageArea.CreateInstance(TargetOS, null);
    //Add the device connection list...
    asa.CmStorageDeviceConnections = sdcl;
    asa.CmSynchronousReplicasDesired = 1;
    asa.DisplayName = configComponents[ADVSTORAGEAREADISPLAYNAME];
    //... and save
    asa.Save(FileNet.Api.Constants.RefreshMode.REFRESH);
    FileNet.Api.Util.Id asaid = asa.Id;

    Console.WriteLine(DateTime.Now + " Advanced Storage Area mit Storage Devices erfolgreich erzeugt");

    Console.WriteLine(DateTime.Now + " Erzeugen der Storage Policy " + configComponents[STORAGEPOLICYDISPLAYNAME]);
    FileNet.Api.Admin.IStoragePolicy sp = Factory.StoragePolicy.CreateInstance(TargetOS);

    sp.DisplayName = configComponents[STORAGEPOLICYDISPLAYNAME];
    sp.FilterExpression = " ID IN (" + asaid.ToString() + ")";
    sp.Save(FileNet.Api.Constants.RefreshMode.REFRESH);
    Console.WriteLine(DateTime.Now + " Storage Policy erstellt");

    Console.WriteLine(DateTime.Now + " Instanzieren der Dokumentenklasse " + configComponents[DOCCLASSNAME]);

    IDocumentClassDefinition dcd = Factory.DocumentClassDefinition.FetchInstance(TargetOS, configComponents[DOCCLASSNAME], null);

    Console.WriteLine(DateTime.Now + " Dokumentenklasse " + configComponents[DOCCLASSNAME] + " erfolgreich instanziert");

    FileNet.Api.Collection.IPropertyDefinitionList pdl = dcd.PropertyDefinitions;

    Console.WriteLine(DateTime.Now + " Durchsuchen aller PropertyDefinitions");

    foreach (IPropertyDefinition pd in pdl)
    {
    if (pd.SymbolicName == PropertyNames.STORAGE_POLICY)
    {
    Console.WriteLine(DateTime.Now + " PropertyDefinition " + PropertyNames.STORAGE_POLICY + " gefunden");
    IPropertyDefinitionObject pdo = (IPropertyDefinitionObject)pd;
    Console.WriteLine(DateTime.Now + " StoragePolicy gesetzt");
    pdo.PropertyDefaultObject = sp;
    dcd.Save(FileNet.Api.Constants.RefreshMode.REFRESH);
    Console.WriteLine(DateTime.Now + " Dokumentenklasse " + configComponents[DOCCLASSNAME] + " erfolgreich aktialisiert");

    }
    }


    ------------------------------
    Gerold Krommer
    ------------------------------



  • 3.  RE: Update storage policy in class definition

    Posted Thu February 03, 2022 04:01 AM
    Hi Gerold,

    thanks for help.

    Best regards

    ------------------------------
    Yannick Martin
    ------------------------------