CreateContentDescriptor() public method

Resource descriptors are the way to link resources to data set versions (and some other entity types, too). The resources can be persisted in the local or a remote file system or any other location reachable via a URL. The resource itself can be any type of file, service returning a resource, a normal webpage, and so on. The method creates a resource descriptor, links it to the provided data set version and persists the descriptor.
The method does not have access to the resource itself, and does not persist it.
public CreateContentDescriptor ( string name, string mimeType, string uri, Int32 orderNo, DatasetVersion datasetVersion ) : ContentDescriptor
name string A friendly name for the resource, mainly used in the UI
mimeType string The type of the resource. Used in the methods that transfer and/or process the resource
uri string The URI of the resource, may contain protocol, access method, authorization information , etc.
orderNo System.Int32 The order of the resource in the list of all resources associated to the same dataset version.
datasetVersion BExIS.Dlm.Entities.Data.DatasetVersion
return BExIS.Dlm.Entities.Data.ContentDescriptor
Example #1
0
        private static void storeGeneratedFilePathToContentDiscriptor(long datasetId, DatasetVersion datasetVersion, string title, string ext)
        {
            string name = "";
            string mimeType = "";

            if (ext.Contains("xml"))
            {
                name = "metadata";
                mimeType = "text/xml";
            }

            // create the generated FileStream and determine its location
            string dynamicPath = OutputDatasetManager.GetDynamicDatasetStorePath(datasetId, datasetVersion.Id, title, ext);
            //Register the generated data FileStream as a resource of the current dataset version
            //ContentDescriptor generatedDescriptor = new ContentDescriptor()
            //{
            //    OrderNo = 1,
            //    Name = name,
            //    MimeType = mimeType,
            //    URI = dynamicPath,
            //    DatasetVersion = datasetVersion,
            //};

            DatasetManager dm = new DatasetManager();
            if (datasetVersion.ContentDescriptors.Count(p => p.Name.Equals(name)) > 0)
            {   // remove the one contentdesciptor
                foreach (ContentDescriptor cd in datasetVersion.ContentDescriptors)
                {
                    if (cd.Name == name)
                    {
                        cd.URI = dynamicPath;
                        dm.UpdateContentDescriptor(cd);
                    }
                }
            }
            else
            {
                // add current contentdesciptor to list
                //datasetVersion.ContentDescriptors.Add(generatedDescriptor);
                dm.CreateContentDescriptor(name, mimeType, dynamicPath, 1, datasetVersion);
            }

            //dm.EditDatasetVersion(datasetVersion, null, null, null);
        }