/// <summary> /// SchematronHelper /// </summary> /// <param name="schematronEndpoint">Endpoint Url. Either the test or prod instance</param> /// <param name="credential">NAAS Credentials. Must correspond to the schematronEndpoint environment</param> /// <param name="flowSchemaMap">Collection of Flow to Schema Version mappings</param> /// <param name="proxy">Web Proxy in case we are behind one</param> public SchematronHelper(string schematronEndpoint, AuthenticationCredentials credential, Dictionary <string, string> flowSchemaMap, IWebProxy proxy) { LOG.Debug("Configuring SchematronHelper with: " + schematronEndpoint); LOG.Debug(" credential: " + credential); LOG.Debug(" proxy: " + proxy); if (string.IsNullOrEmpty(schematronEndpoint)) { throw new ArgumentNullException("documentPath"); } if (credential == null) { throw new ArgumentNullException("credential"); } if (flowSchemaMap == null || flowSchemaMap.Count == 0) { throw new ArgumentException("FlowSchemaMap not configured"); } _schematronClient = new Windsor.Node.Schematron.SchematronHelper(); _schematronClient.Configure(schematronEndpoint, credential.UserName, credential.Password, proxy); _flowSchemaMap = flowSchemaMap; }
/// <summary> /// Add all the input documents to the node. /// </summary> public IList <string> AddDocuments(string transactionId, IList <Document> documents) { if (CollectionUtils.IsNullOrEmpty(documents)) { return(null); } List <string> newDocumentIds = new List <string>(documents.Count); try { LOG.Debug("Saving documents"); // First, generate ids for new documents foreach (Windsor.Node2008.WNOSDomain.Document document in documents) { if (CollectionUtils.IsNullOrEmpty(document.Content)) { throw new ArgumentException(string.Format("Document does not contain any content: \"{0}\".", document)); } document.Id = IdProvider.Get(); if (string.IsNullOrEmpty(document.DocumentId)) { document.DocumentId = document.Id; // If not specified, set this to DB id } if (string.IsNullOrEmpty(document.DocumentName)) { // If not specified, set this to DB id + extension document.DocumentName = Path.ChangeExtension(document.Id, CommonContentAndFormatProvider.GetFileExtension(document.Type)); } newDocumentIds.Add(document.Id); CheckToCompressDocument(document); } // Next, save the new documents to the DB _documentDao.CreateDocuments(transactionId, documents); // Finally, save document content to repository int index = 0; foreach (Windsor.Node2008.WNOSDomain.Document document in documents) { LOG.Debug("Saving document: \"{0}\"", document); _documentContentManager.SaveDocumentContent(transactionId, newDocumentIds[index++], document.Content, false); } return(newDocumentIds); } catch (Exception) { RollbackDocuments(transactionId, newDocumentIds); throw; } }
public override void ProcessMessage(SoapEnvelope envelope) { SoapContext reqContext = envelope.Context; if (reqContext != null) { //now we need to extract href hash from the context Dictionary <string, string> table = reqContext["hrefs"] as Dictionary <string, string>; if (table != null) { XmlElement element = envelope.DocumentElement; XmlNodeList list = element.GetElementsByTagName("NodeDocument", "http://www.ExchangeNetwork.net/schema/v1.0/node.xsd"); foreach (XmlNode node in list) { XmlElement nameElement = node["name"]; LOG.Debug("NameElement: " + nameElement); //now lets check in the table to get the href for that name String id = table[nameElement.InnerText]; LOG.Debug("Id: " + id); //lets create the content tag XmlNode newNode = envelope.CreateNode(XmlNodeType.Element, "content", "http://xml.apache.org/xml-soap"); XmlAttribute attrib = envelope.CreateAttribute("href"); attrib.Value = id; LOG.Debug("Attrib: " + attrib); newNode.Attributes.Append(attrib); node.AppendChild(newNode); } } } }
/// <summary> /// Fetches interface implementation from the specified context /// </summary> /// <typeparam name="T">Desired type</typeparam> /// <param name="applicationContext">spring app context</param> /// <param name="throwOnNull">indcator whetehr or now to throw on null object</param> /// <returns>found type or null</returns> public static T GetServiceImplementation <T>(IApplicationContext applicationContext, bool throwOnNull) where T : class { Type serviceType = typeof(T); LOG.Debug("Getting service using specified context: " + applicationContext); LOG.Debug("Service type: " + serviceType.FullName); IDictionary objects = applicationContext.GetObjectsOfType(serviceType, true, false); // string[] objectNames = applicationContext.GetObjectDefinitionNames(); if (objects != null && objects.Count > 0) { object rtnObject = null; foreach (DictionaryEntry entry in objects) { // Return closest match if (entry.Value.GetType() == serviceType) { rtnObject = entry.Value; break; } else { rtnObject = entry.Value; } } if (rtnObject != null) { return((T)rtnObject); } } if (throwOnNull) { throw new ArgumentException("GetServiceImplementation() could not locate object of type: " + serviceType.ToString()); } else { return(null); } }
/// <summary> /// Makes Admin Activity /// </summary> /// <param name="visit"></param> /// <param name="activityType"></param> /// <param name="method"></param> /// <returns></returns> protected Activity MakeAdminActivity(AdminVisit visit, ActivityType activityType, string message) { LOG.Debug("Creating admin activity"); if (visit == null) { throw new ArgumentNullException(); } Activity activity = new Activity(); activity.Type = activityType; activity.IP = visit.IP; activity.AppendFormat("Visit created on {0}. ", visit.CreatedOn); activity.Append(message); LOG.Debug(" Activity: " + activity); return(activity); }
/// <summary> /// Get Auth rewquest Visit /// </summary> /// <param name="username"></param> /// <param name="password"></param> /// <param name="domain"></param> /// <param name="method"></param> /// <returns></returns> public AuthEndpointVisit GetVisit(string username, string password, string domain, string method) { LOG.Debug(string.Format( "Visit from (username: {0} password: *********** domain: {1} method: {2}", username, domain, method)); AuthEndpointVisit visit = GetVisit <AuthEndpointVisit>(); visit.AuthMethod = method; visit.Credentials = new AuthenticationCredentials(username, password, domain); LOG.Debug("Visit: " + visit); return(visit); }
public void ProcessSolicit(string requestId) { LOG.DebugEnter(MethodBase.GetCurrentMethod(), requestId); LazyInit(); _dataRequest = _requestManager.GetDataRequest(requestId); if (TryGetParameter(_dataRequest, PARAM_NAAS_SUBMIT_USERNAME, 0, ref _submitUsername)) { if (_naasUsernameToPasswordMap == null) { throw new ArgumentException(string.Format("A request parameter \"{0}\" = \"{1}\" was specified, but the service does not specify a \"{2}\" config parameter", PARAM_NAAS_SUBMIT_USERNAME, _submitUsername, CONFIG_NAAS_USER_MAPPING_FILE_PATH)); } if (!_naasUsernameToPasswordMap.ContainsKey(_submitUsername.ToUpper())) { throw new ArgumentException(string.Format("A request parameter \"{0}\" = \"{1}\" was specified, but the username was not found in the mapping file specified by the \"{2}\" config parameter", PARAM_NAAS_SUBMIT_USERNAME, _submitUsername, CONFIG_NAAS_USER_MAPPING_FILE_PATH)); } UserSubmitInfo userSubmitInfo = _naasUsernameToPasswordMap[_submitUsername.ToUpper()]; _rcraInfoUserId = userSubmitInfo.RCRAInfoUserID; } object returnData = GetObjectFromRequest(_dataRequest); string serializedFilePath = null; if (_addHeader) { LOG.Debug("Serializing results and making header..."); AppendAuditLogEvent("Serializing results and making header..."); serializedFilePath = MakeHeaderFile(returnData); } else { LOG.Debug("Serializing results to file..."); AppendAuditLogEvent("Serializing results to file..."); serializedFilePath = _serializationHelper.SerializeToTempFile(returnData); if (_validateXml) { ValidateXmlFileAndAttachErrorsAndFileToTransaction(serializedFilePath, "xml_schema.xml_schema.zip", null, _dataRequest.TransactionId); } } LOG.Debug("Serialized file path: " + serializedFilePath); AppendAuditLogEvent("Serialized file path: " + serializedFilePath); LOG.Debug("Compressing serialized file..."); AppendAuditLogEvent("Compressing serialized file..."); string compressedFilePath = _compressionHelper.CompressFile(serializedFilePath); LOG.Debug("Compressed file path: " + compressedFilePath); AppendAuditLogEvent("Compressed file path: " + compressedFilePath); LOG.Debug("Adding document..."); AppendAuditLogEvent("Adding document..."); _documentManager.AddDocument(_dataRequest.TransactionId, CommonTransactionStatusCode.Processed, "Request Processed: " + _dataRequest.ToString(), compressedFilePath); if (_submitUsername != null) { SubmitFile(compressedFilePath, _dataRequest.TransactionId); } LOG.Debug("OK"); AppendAuditLogEvent("ProcessQuery: OK"); }
/// <summary> /// Write to node transaction log /// </summary> /// <param name="message">Event to write out to log</param> private void WriteOut(string strMessage) { LOG.Debug(strMessage); AppendAuditLogEvent(strMessage); }
public byte[] GetDocumentContent(string transactionId, string id) { LOG.Debug(string.Format("GetDocumentContent({0}, {1})", transactionId, id)); return(_documentContentDao.GetDocumentContent(transactionId, id)); }
private void Init() { _service11Provider = HttpContext.Current.Cache[SERVICE_PROVIDER_NAME] as ENService11Provider; if (_service11Provider == null) { LOG.Debug("Configuring service provider..."); IApplicationContext ctx = ContextRegistry.GetContext(); _service11Provider = ctx.GetObject(SERVICE_PROVIDER_NAME) as ENService11Provider; if (_service11Provider == null) { throw new ArgumentException("Unable to find ENService20Provider reference"); } HttpContext.Current.Cache.Insert(SERVICE_PROVIDER_NAME, _service11Provider, null, Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(20), CacheItemPriority.NotRemovable, null); LOG.Debug("Service Provider configured"); } }
public PaginatedContentResult ProcessQuery(string requestId) { LOG.DebugEnter(MethodBase.GetCurrentMethod(), requestId); LazyInit(); DataRequest request = _requestManager.GetDataRequest(requestId); object returnData = GetObjectFromRequest(request); LOG.Debug("Creating PaginatedContentResult"); PaginatedContentResult result = new PaginatedContentResult(); result.Paging = new PaginationIndicator(request.RowIndex, request.MaxRowCount, true); LOG.Debug("Serializing data"); result.Content = new SimpleContent(CommonContentType.XML, _serializationHelper.Serialize(returnData)); LOG.Debug("OK"); return(result); }
/// <summary> /// Fetches interface implementation from the application context /// </summary> /// <returns>Instance of the specfied type based on the Spring context defenition</returns> public void GetServiceImplementation <T>(out T implementation) where T : class { LOG.Debug("Getting service using default application context"); implementation = GetServiceImplementationPriv <T>(); }
public void Init() { FieldNotInitializedException.ThrowIfEmptyString(this, ref _repositoryDirectoryPath); FieldNotInitializedException.ThrowIfEmptyString(this, ref _documentExtension); if (!Directory.Exists(_repositoryDirectoryPath)) { throw new DirectoryNotFoundException(string.Format("Repository directory does not exist: \"{0}\"", _repositoryDirectoryPath)); } string testFilePath = Path.Combine(_repositoryDirectoryPath, Guid.NewGuid().ToString()); try { LOG.Debug("Configuring DocumentContentManager with: " + _repositoryDirectoryPath); LOG.Debug("Writing test file to assure the provider has necessary rights: " + testFilePath); File.WriteAllText(testFilePath, DateTime.Now.ToString()); LOG.Debug("Deleting test file to ensure the provider has necessary rights: " + testFilePath); File.Delete(testFilePath); LOG.Debug("OK"); } catch (Exception ex) { FileUtils.SafeDeleteFile(testFilePath); throw new UnauthorizedAccessException(string.Format("Repository directory is not writable: \"{0}\"", _repositoryDirectoryPath), ex); } }
public object Merge(string templatePath, IDaoTemplateHelper helper, string outputPath, NameValueCollection additionalArgs) { _logger.DebugEnter(MethodBase.GetCurrentMethod(), templatePath, helper, outputPath); if (helper == null) { throw new ApplicationException("null helper"); } VelocityContext context = new VelocityContext(); context.Put(helper.Name, helper); if (additionalArgs != null) { foreach (string key in additionalArgs.AllKeys) { context.Put(key, additionalArgs[key]); } } Merge(templatePath, context, outputPath); _logger.Debug("Result: {0}", helper.GetResult()); return(helper.GetResult()); }
internal void DebugAndAudit(string message, params object[] args) { AppendAuditLogEvent(message, args); LOG.Debug(message, args); }