/// <summary> /// Set the relevant settings from the DatamoverSettingsParser object. /// </summary> /// <param name="key">Key of the DatamoverSettingsParser map.</param> /// <param name="datamoverSettingsParser">DatamoverSettingsParser object.</param> private void Fill(string key, DatamoverSettingsParser datamoverSettingsParser) { this.InstallationSubDir = GetDatamoverJSLSubDirName(key); this.IncomingTarget = FileSystem.ChangeBackwardToForwardSlashesInPath(datamoverSettingsParser.Get(key, "incoming-target")); this.SkipAccessibilityTestOnIncoming = Utils.StringToBool(datamoverSettingsParser.Get(key, "skip-accessibility-test-on-incoming")); this.BufferDir = FileSystem.ChangeBackwardToForwardSlashesInPath(datamoverSettingsParser.Get(key, "buffer-dir")); if (Int32.TryParse(datamoverSettingsParser.Get(key, "buffer-dir-highwater-mark"), out int tmpBufferDirHighwaterMark)) { this.BufferDirHighwaterMark = tmpBufferDirHighwaterMark; } this.OutgoingTarget = datamoverSettingsParser.Get(key, "outgoing-target"); if (Int32.TryParse(datamoverSettingsParser.Get(key, "outgoing-target-highwater-mark"), out int tmpOutgoingTargetHighwaterMark)) { this.OutgoingTargetHighwaterMark = tmpOutgoingTargetHighwaterMark; } this.SkipAccessibilityTestOnOutgoing = Utils.StringToBool(datamoverSettingsParser.Get(key, "skip-accessibility-test-on-outgoing")); this.DataCompletedScript = FileSystem.ChangeBackwardToForwardSlashesInPath(datamoverSettingsParser.Get(key, "data-completed-script")); this.ManualInterventionDir = FileSystem.ChangeBackwardToForwardSlashesInPath(datamoverSettingsParser.Get(key, "manual-intervention-dir")); if (Int32.TryParse(datamoverSettingsParser.Get(key, "quiet-period"), out int tmpQuietPeriod)) { this.QuietPeriod = tmpQuietPeriod; } if (Int32.TryParse(datamoverSettingsParser.Get(key, "check-interval"), out int tmpCheckInterval)) { this.CheckInterval = tmpCheckInterval; } this.OutgoingHostLastchangedExecutable = this.DataCompletedScript = datamoverSettingsParser.Get(key, "outgoing-host-lastchanged-executable");; }
/// <summary> /// Alternative constructor. /// </summary> /// <param name="datamoverInstallationSubDir">Datamover installation subdirectory (relative to the oBIT installation directory.</param> /// <param name="DatamoverIncomingDir">Datamover incoming directory.</param> /// <param name="datamoverJslSettingsParser">A DatamoverJSLSettingsParser object.</param> /// <param name="datamoverSettingsParser">A DatamoverSettingsParser object.</param> public Datamover( string datamoverIncomingDir, DatamoverJSLSettingsParser datamoverJslSettingsParser, DatamoverSettingsParser datamoverSettingsParser) { // First, find the Datamover configuration that fits the client string datamoverJSLPath = ""; foreach (string key in datamoverSettingsParser.Configurations) { string path1 = datamoverSettingsParser.Get(key, "incoming-target"); if (path1 != null) { string path2 = datamoverIncomingDir; if (FileSystem.ComparePaths(path1, path2)) { // Found the correct setting; fill the values Fill(key, datamoverSettingsParser); // Store the path datamoverJSLPath = key; // Inform sLogger.Info("Processed Datamover configuration file from Datamover JSL parent folder '" + datamoverJSLPath + "'."); break; } } } // If we could not find the expected DatamoverJSL configuration that fits the client, // something is wrong in the configuration files. if (datamoverJSLPath.Equals("")) { string msg = "No known Datamover JSL configuration uses the incoming folder '" + datamoverIncomingDir + "'."; sLogger.Error(msg); throw new ConfigurationException(msg); } // Keep track of whether we find the DatamoverJSL configuration bool found = false; // Find the DatamoverJSL configuration that fits the client foreach (string key in datamoverJslSettingsParser.GetRelativeDatamoverJSLDirs()) { if (FileSystem.ComparePaths(key, datamoverJSLPath)) { // Found the correct setting; fill the values Fill(key, datamoverJslSettingsParser); // Inform sLogger.Info("Processed Datamover JSL configuration file from folder '" + key + "'."); // Set found to true found = true; break; } } if (!found) { string msg = "No known Datamover JSL configuration uses the incoming folder '" + datamoverIncomingDir + "'."; sLogger.Error(msg); throw new ConfigurationException(msg); } }