protected ImportJobBase(
     ImportConnectionInfo connectionInfo,
     ImportContext context)
 {
     this.ConnectionInfo = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
     this.context        = context ?? throw new ArgumentNullException(nameof(context));
 }
 /// <summary>
 /// Creates an import client that's compatible with the Relativity instance defined by <paramref name="connectionInfo"/>.
 /// </summary>
 /// <param name="relativityVersion">
 /// The Relativity version that was retrieved by REST API.
 /// </param>
 /// <param name="connectionInfo">
 /// The import connection information.
 /// </param>
 /// <param name="context">
 /// The import context.
 /// </param>
 /// <returns>
 /// The <see cref="IImportClient"/> instance.
 /// </returns>
 /// <remarks>
 /// The async/await pattern cannot be used because none of the constructs are marked with <see cref="SerializableAttribute"/>.
 /// </remarks>
 /// <exception cref="NotSupportedException">Thrown when there is an attempt to create an unsupported client</exception>
 public IImportClient CreateImportClient(
     Version relativityVersion,
     ImportConnectionInfo connectionInfo,
     ImportContext context)
 {
     this.Initialize();
     // We can add a flag here to state we'll only allow construction of one or the other, but never both
     return(this.pluginSearch.CreateImportClient(relativityVersion, connectionInfo, context));
 }
 public ImportClient(
     [Import("ImportConnectionInfo")]
     ImportConnectionInfo connectionInfo,
     [Import("ImportContext")]
     ImportContext context)
 {
     this.connectionInfo = connectionInfo ?? throw new ArgumentNullException(nameof(connectionInfo));
     this.context        = context ?? throw new ArgumentNullException(nameof(context));
 }
예제 #4
0
 public BulkArtifactImportJob(
     ImportBulkArtifactJob job,
     ImportConnectionInfo connectionInfo,
     ImportContext context)
     : base(connectionInfo, context)
 {
     this.job      = job ?? throw new ArgumentNullException(nameof(job));
     this.Settings = new BulkArtifactImportSettings(this.job.Settings)
     {
         WorkspaceId = this.ConnectionInfo.WorkspaceId
     };
 }
예제 #5
0
        public IImportClient CreateImportClient(Version relativityVersion, ImportConnectionInfo connectionInfo,
                                                ImportContext context)
        {
            string pluginDirectory = relativityVersion >= MinSdkVersion
                                ? this.pluginConfiguration.SdkPluginDirectory
                                : this.pluginConfiguration.LegacyPluginDirectory;

            if (!string.IsNullOrEmpty(previousPluginDirectory) &&
                string.Compare(pluginDirectory, previousPluginDirectory, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new NotSupportedException("There was an attempt to create different versioned Import API clients in the same app domain. This is unsupported.");
            }
            previousPluginDirectory = pluginDirectory;
            return(this.FindClient(pluginDirectory, connectionInfo, context));
        }
예제 #6
0
        private IImportClient FindClient(
            string pluginDirectory,
            ImportConnectionInfo connectionInfo,
            ImportContext context)
        {
            container?.Dispose();
            catalog?.Dispose();
            // We can add logic here to check for multiple constructions of the import client from the same app domain,
            // but with different version requests. Compare the plugin directory that was passed in, against a static plugin
            // directory variable -----------------NOTE - is this not already happening in the calling method?

            // Note: You MUST use a specific enough filename filter for your plugins and prevent MEF from trying
            //       to do things like load native binaries.
            this.catalog   = new DirectoryCatalog(pluginDirectory, "Relativity.DataExchange.Wrapper.*.dll");
            this.container = new CompositionContainer(catalog);
            this.ImportClients.Clear();
            container.ComposeExportedValue("ImportConnectionInfo", connectionInfo);
            container.ComposeExportedValue("ImportContext", context);
            container.ComposeParts(this);
            if (this.ImportClients.Count == 0)
            {
                throw new InvalidOperationException(
                          "The import cannot be completed because no plugins were discovered.");
            }

            List <Lazy <IImportClient> > candidates = this.ImportClients.ToList();

            if (candidates.Count > 1)
            {
                throw new InvalidOperationException(
                          "The import cannot be completed because more than 1 plugin was discovered.");
            }

            IImportClient client = candidates[0].Value;

            return(client);
        }