public ArchiveType Identify(string metadataFileName) { var metadataXmlAsString = File.ReadAllText(metadataFileName); var metadata = SerializeUtil.DeserializeFromString <info>(metadataXmlAsString); return(Identify(metadata)); }
public ArchiveType Identify(string metadataFileName) { string metadataXmlAsString = File.ReadAllText(metadataFileName); ExternalModels.Info.info metadata = SerializeUtil.DeserializeFromString <ExternalModels.Info.info>(metadataXmlAsString); return(Identify(metadata)); }
public void ShouldSerializeWithRealElementError() { string xml = File.ReadAllText("xml/real-error.xml"); xml = xml.Replace(@"<gco:Real xmlns:gco=""http://www.isotc211.org/2005/gco"" />", ""); GetRecordByIdResponseType getRecordsByIdResponseType = SerializeUtil.DeserializeFromString <GetRecordByIdResponseType>(xml); Trace.WriteLine(SerializeUtil.SerializeToString(getRecordsByIdResponseType)); }
public void ShouldSerializeWithDateTimeError() { string xml = File.ReadAllText("xml/datetime-error.xml"); xml = xml.Replace(@"<gco:DateTime xmlns:gco=""http://www.isotc211.org/2005/gco"" />", ""); var getRecordsResponseType = SerializeUtil.DeserializeFromString <GetRecordsResponseType>(xml); Trace.WriteLine(SerializeUtil.SerializeToString(getRecordsResponseType)); }
public GetRecordsResponseType RunSearch(int startPosition) { Log.Debug("Running search with start position: " + startPosition); string responseBody = _httpRequestExecutor.PostRequest(EndpointUrlGeoNorgeCsw, "application/xml", "application/xml", CreateRequestBody(startPosition)); return(SerializeUtil.DeserializeFromString <GetRecordsResponseType>(responseBody)); }
public GetRecordsResponseType RunGetRecordsRequest(GetRecordsType getRecordsRequest) { var requestBody = SerializeUtil.SerializeToString(getRecordsRequest); Console.WriteLine(requestBody); string responseBody = _httpRequestExecutor.PostRequest(GetUrlForCswService(), ContentTypeXml, ContentTypeXml, requestBody); responseBody = FixInvalidXml(responseBody); return(SerializeUtil.DeserializeFromString <GetRecordsResponseType>(responseBody)); }
public MD_Metadata_Type GetRecordById(GetRecordByIdType request) { var requestBody = SerializeUtil.SerializeToString(request); string responseBody = _httpRequestExecutor.PostRequest(GetUrlForCswService(), ContentTypeXml, ContentTypeXml, requestBody); responseBody = FixInvalidXml(responseBody); GetRecordByIdResponseType response = SerializeUtil.DeserializeFromString <GetRecordByIdResponseType>(responseBody); MD_Metadata_Type metadataRecord = null; if (response != null && response.Items != null && response.Items.Length > 0) { metadataRecord = response.Items[0] as MD_Metadata_Type; } return(metadataRecord); }
private void LoadPredefinedMetadataFieldValues(FileInfo predefinedMetadataFieldValuesFileInfo) { var fileReader = new XmlTextReader(predefinedMetadataFieldValuesFileInfo.FullName) { Namespaces = false }; while (fileReader.Read()) { if (fileReader.Name.Equals("MetadataEntityInformationUnit") && fileReader.IsStartElement()) { string infoUnitXml = fileReader.ReadOuterXml(); var infoUnit = SerializeUtil.DeserializeFromString <MetadataEntityInformationUnit>(infoUnitXml); _metaDataEntityInformationUnits.Add(infoUnit); } } fileReader.Close(); }
public ValidationResult Validate(MetadataEntry metadataEntry, MD_Metadata_Type metadata, string rawXmlProcessed) { ValidationResult validationResult = new ValidationResult(); //if (metadataEntry.HasResourceType(ResourceTypeSoftware)) //{ // CheckDistributionUrl(metadata, validationResult); //} //else //{ string response = _httpRequestExecutor.GetRequest(EndpointValidatorInMetadataEditor + metadataEntry.Uuid, ContentTypeXml, ContentTypeXml); if (!string.IsNullOrWhiteSpace(response)) { External.MetadataEditor.MetadataEntry externalMetadataEntry = SerializeUtil.DeserializeFromString <External.MetadataEditor.MetadataEntry>(response); validationResult.Initialize(externalMetadataEntry); validationResult.Timestamp = DateTime.Now; } //} return(validationResult); }
public static addml ReadFromString(string xml) { return(SerializeUtil.DeserializeFromString <addml>(xml)); }
public MetadataEntry RetrieveAndValidate(string uuid) { MetadataEntry metadataEntry = null; try { var getCswRecordRequest = CreateGetCswRecordRequest(uuid); Log.Info("Henter metadata for uuid=" + uuid + " fra GeoNorge."); string cswRecordResponse = _httpRequestExecutor.PostRequest(EndpointUrlGeoNorgeCsw, ContentTypeXml, ContentTypeXml, getCswRecordRequest); /* Quick and dirty hacks to fix exceptions in serialization due to invalid xml */ Regex fixWrongDecimalInRealElements = new Regex("<gco:Real>([0-9]+),([0-9]+)</gco:Real>"); var fixedResponse = cswRecordResponse.Replace("<gco:Boolean />", "<gco:Boolean>false</gco:Boolean>") .Replace("<gco:Real />", "<gco:Real>0.0</gco:Real>") .Replace("<gco:DateTime />", "") .Replace("<gmd:MD_TopicCategoryCode />", ""); var rawXmlProcessed = fixWrongDecimalInRealElements.Replace(fixedResponse, "<gco:Real>$1.$2</gco:Real>"); GetRecordByIdResponseType getRecordResponse = SerializeUtil.DeserializeFromString <GetRecordByIdResponseType>(rawXmlProcessed); MD_Metadata_Type metadata = getRecordResponse.Items[0] as MD_Metadata_Type; metadataEntry = ParseCswRecordResponse(uuid, metadata); ValidationResult validationResult; if (metadataEntry.ResourceType == "unknown") { validationResult = new ValidationResult { Messages = "Unknown resource type, please check value of hierarchyLevel element.", Status = ValidationStatus.NotValidated, Timestamp = DateTime.Now }; Log.Info("Validation result: " + validationResult.Messages); metadataEntry.ValidationResults.Add(validationResult); } else { if (metadataEntry.InspireResource) { // Check validation state instead of valdating. Log.Info("Check validation state metadata with INSPIRE-validator."); validationResult = new InspireValidator(_httpRequestExecutor).CheckValidationState(uuid); Log.Info("Validation result: " + validationResult.Messages); metadataEntry.ValidationResults.Add(validationResult); } if (metadataEntry.Keywords.Contains("Norge digitalt")) { Log.Info("Validating metadata with Norge Digitalt-validator."); validationResult = new NorgeDigitaltValidator().Validate(metadataEntry, metadata, rawXmlProcessed); Log.Info("Validation result: " + validationResult.Messages); metadataEntry.ValidationResults.Add(validationResult); } } } catch (Exception e) { metadataEntry = ParseCswRecordResponse(uuid, null); string message = e.Message; if (e.InnerException != null) { message += e.InnerException.Message; } metadataEntry.ValidationResults.Add(new ValidationResult { Messages = "Exception during validation: " + message, Status = ValidationStatus.NotValidated, Timestamp = DateTime.Now }); Log.Error("Exception occured for uuid=" + uuid + ", not validated. " + message); } return(metadataEntry); }
public void LoadFormData(string archiveReference) { var data = _repo.GetFormData(archiveReference); _form = SerializeUtil.DeserializeFromString <T>(data); }