private IBasicOutput CreateReturnValue(SoapMessage message) { Exception ex = Misc.GetDeepestInnerException(message.Exception); var ret = Utilities.Reflection.CreateInstance(message.MethodInfo.ReturnType); var output = ret as Schemas.Part.IBasicOutput; if (ex is XmlException) { output.StandardRetur = StandardReturType.MalformedXml(); } else if (ex is HeaderException) { output.StandardRetur = StandardReturType.NullInput("applicationHeader"); } else if (ex is MissingRequestException) { output.StandardRetur = StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, string.Format("Missing request element: {0}", message.MethodInfo.Name)); } else if (ex is InvalidOperationException && Misc.ExceptionTreeContainsText(message.Exception, "XML")) { output.StandardRetur = StandardReturType.RequestUnreadable(ex.Message); } else { output.StandardRetur = StandardReturType.UnspecifiedError(); } return(output); }
public override StandardReturType ValidateInput() { if (Input == null) { return(StandardReturType.NullInput()); } foreach (var dp in Input) { if (dp == null || string.IsNullOrEmpty(dp.TypeName) || dp.Attributes == null) { return(StandardReturType.NullInput()); } var dataProvider = Reflection.CreateInstance <IExternalDataProvider>(dp.TypeName); if (dataProvider == null) { return(StandardReturType.UnknownObject(dp.TypeName)); } var propNames = dataProvider.ConfigurationKeys; foreach (var propInfo in propNames) { var propName = propInfo.Name; var prop = dp.Attributes.FirstOrDefault(p => p.Name.ToLower() == propName.ToLower()); if (prop == null || (propInfo.Required && string.IsNullOrEmpty(prop.Value))) { return(StandardReturType.NullInput(propName)); } } } return(StandardReturType.OK()); }
public virtual StandardReturType BaseValidate <TOutput>(MethodHeader header, TInputElement[] input) { // Initialize context try { BrokerContext.Initialize(header.ApplicationToken, header.UserToken); } catch (Exception ex) { return(StandardReturType.InvalidApplicationToken(header.ApplicationToken)); } // Validate input if (input == null || input.Length == 0) { return(StandardReturType.NullInput()); } var ret = Validate(input); if (ret == null) { ret = StandardReturType.UnspecifiedError("Validation failed"); } return(ret); }
public override StandardReturType ValidateInput() { if (string.IsNullOrEmpty(string.Format("{0}", ApplicationName).Trim())) { return(StandardReturType.NullInput()); } if (Data.Applications.Application.NameExists(ApplicationName)) { return(StandardReturType.ApplicationNameExists(ApplicationName)); } return(StandardReturType.OK()); }
public static StandardReturType ValidateChannel(ChannelBaseType notificationChannel) { if (notificationChannel == null) { return(StandardReturType.NullInput("NotificationChannel")); } if (notificationChannel is WebServiceChannelType) { if (string.IsNullOrEmpty((notificationChannel as WebServiceChannelType).WebServiceUrl)) { return(StandardReturType.NullInput("WebServiceUrl")); } } else if (notificationChannel is FileShareChannelType) { if (string.IsNullOrEmpty((notificationChannel as FileShareChannelType).Path)) { return(StandardReturType.NullInput("Path")); } } else { return(StandardReturType.UnknownObject("Unknown channel type")); } var dbChannel = Data.Channel.FromXmlType(notificationChannel); if (dbChannel == null) { return(StandardReturType.UnknownObject("NotificationChannel")); } var channel = Notifications.Channel.Create(dbChannel); try { if (channel == null || !channel.IsAlive()) { // TODO: Call StandardReturType.UnreachableChannel() return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, "Unreachable channel")); } } catch (Exception ex) { Engine.Local.Admin.LogException(ex); // TODO: Call StandardReturType.UnreachableChannel() return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, "Unreachable channel")); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (string.IsNullOrEmpty(Input)) { return(StandardReturType.NullInput()); } if (!PartInterface.Strings.IsValidPersonNumber(Input)) { return(StandardReturType.InvalidCprNumber(Input)); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (Input == null) { return(StandardReturType.NullInput()); } if (!Strings.IsGuid(Input.UUID)) { return(StandardReturType.InvalidUuid(Input.UUID)); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (PersonUuids == null) { return(StandardReturType.NullInput()); } else { /* * I'm not entirely sure if any single element is allowed to be empty, but not the entire set or if no element may be empty. * Therefore the two different attempts. */ // Not any empty elements are allowed foreach (Guid person in PersonUuids) { if (person == Guid.Empty || person == null) { return(StandardReturType.NullInput()); } } // Random empty elements are allowed, but not the entire set int count = 0; foreach (Guid person in PersonUuids) { if (person != null && person != Guid.Empty) { count++; } } if (PersonIdentifiers.Length != count) { return(StandardReturType.NullInput()); } } PersonIdentifiers = PersonMapping.GetPersonIdentifiers(PersonUuids); foreach (PersonIdentifier pi in PersonIdentifiers) { if (pi == null) { return(StandardReturType.NullInput()); } } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (string.IsNullOrEmpty(string.Format("{0}", TargetApplicationToken).Trim())) { return(StandardReturType.NullInput()); } using (ApplicationDataContext context = new ApplicationDataContext()) { var application = context.Applications.SingleOrDefault(app => app.Token == TargetApplicationToken); if (application == null) { return(StandardReturType.UnknownObject("AppToken", TargetApplicationToken)); } } return(StandardReturType.OK()); }
public StandardReturType Validate() { if (UUIDs == null || UUIDs.Length == 0) { return(StandardReturType.NullInput()); } foreach (var uuid in UUIDs) { if (string.IsNullOrEmpty(uuid)) { return(StandardReturType.NullInput()); } } var invalidUuids = (from uuid in UUIDs where !Strings.IsGuid(uuid) select uuid).ToArray(); if (invalidUuids.Length > 0) { return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, String.Join(",", invalidUuids))); } // Now validate the dates if (!EffectDateFrom.HasValue && !EffectDateTo.HasValue) // both null { EffectDateFrom = EffectDateTo = DateTime.Today; } else if (!EffectDateFrom.HasValue) // null from date { return(StandardReturType.NullInput("VirkningFraDato")); } else if (!EffectDateTo.HasValue) // null to date { return(StandardReturType.NullInput("VirkningTilDato")); } else if (EffectDateTo < EffectDateFrom) // both have values { return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, string.Format("tilVirkningDato {0} must be >= fraVirkningDato {1}", EffectDateTo, EffectDateFrom))); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (SubscriptionId == Guid.Empty) { return(StandardReturType.NullInput()); } using (var dataContext = new Data.EventBrokerDataContext()) { var subscription = (from sub in dataContext.Subscriptions where sub.SubscriptionId == SubscriptionId && sub.SubscriptionTypeId == (int)this.SubscriptionType select sub ).SingleOrDefault(); if (subscription == null) { return(StandardReturType.InvalidUuid(SubscriptionId.ToString())); } } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (input == null || input.UUID == null || input.UUID.Length == 0) { return(StandardReturType.NullInput()); } foreach (var uuid in input.UUID) { if (string.IsNullOrEmpty(uuid)) { return(StandardReturType.NullInput()); } } var invalidUuids = (from uuid in input.UUID where !Strings.IsGuid(uuid) select uuid).ToArray(); if (invalidUuids.Length > 0) { return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, String.Join(",", invalidUuids))); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (input == null || input.Length == 0) { return(StandardReturType.NullInput()); } foreach (var pnr in input) { if (string.IsNullOrEmpty(pnr)) { return(StandardReturType.NullInput()); } } var invalidPnrs = (from pnr in input where !PartInterface.Strings.IsValidPersonNumber(pnr) select pnr).ToArray(); if (invalidPnrs.Length > 0) { return(StandardReturType.Create(HttpErrorCode.BAD_CLIENT_REQUEST, String.Join(",", invalidPnrs))); } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { if (Input == null) { return(StandardReturType.NullInput()); } if (Input.SoegObjekt == null) { return(StandardReturType.NullInput("SoegObjekt")); } if (!string.IsNullOrEmpty(Input.SoegObjekt.UUID) && !Strings.IsGuid(Input.SoegObjekt.UUID)) { return(StandardReturType.InvalidUuid(Input.SoegObjekt.UUID)); } // Start index & max results if (!string.IsNullOrEmpty(Input.FoersteResultatReference)) { int startResult; if (!int.TryParse(Input.FoersteResultatReference, out startResult)) { return(StandardReturType.InvalidValue("FoersteResultatReference", Input.FoersteResultatReference)); } if (startResult < 0) { return(StandardReturType.ValueOutOfRange("FoersteResultatReference", Input.FoersteResultatReference)); } } if (!string.IsNullOrEmpty(Input.MaksimalAntalKvantitet)) { int maxResults; if (!int.TryParse(Input.MaksimalAntalKvantitet, out maxResults)) { return(StandardReturType.InvalidValue("MaksimalAntalKvantitet", Input.MaksimalAntalKvantitet)); } if (maxResults < 0) { return(StandardReturType.ValueOutOfRange("MaksimalAntalKvantitet", Input.MaksimalAntalKvantitet)); } } // Not implemented criteria if (Input.SoegObjekt.SoegRegistrering != null) { return(StandardReturType.NotImplemented("SoegRegistrering")); } if (Input.SoegObjekt.SoegRelationListe != null) { return(StandardReturType.NotImplemented("SoegRelationListe")); } if (Input.SoegObjekt.SoegTilstandListe != null) { return(StandardReturType.NotImplemented("SoegTilstandListe")); } if (Input.SoegObjekt.SoegVirkning != null) { return(StandardReturType.NotImplemented("SoegVirkning")); } // Now validate attribute lists if (Input.SoegObjekt.SoegAttributListe != null) { if (Input.SoegObjekt.SoegAttributListe.LokalUdvidelse != null) { return(StandardReturType.NotImplemented("SoegAttributListe.LokalUdvidelse")); } if (Input.SoegObjekt.SoegAttributListe.SoegRegisterOplysning != null) { return(StandardReturType.NotImplemented("SoegAttributListe.SoegRegisterOplysning")); } if (Input.SoegObjekt.SoegAttributListe.SoegSundhedOplysning != null) { return(StandardReturType.NotImplemented("SoegAttributListe.SoegSundhedOplysning")); } if (Input.SoegObjekt.SoegAttributListe.SoegEgenskab != null) { foreach (var egen in Input.SoegObjekt.SoegAttributListe.SoegEgenskab) { if (egen.AndreAdresser != null) { return(StandardReturType.NotImplemented("AndreAdresser")); } if (!string.IsNullOrEmpty(egen.FoedestedNavn)) { return(StandardReturType.NotImplemented("FoedestedNavn")); } if (!string.IsNullOrEmpty(egen.FoedselsregistreringMyndighedNavn)) { return(StandardReturType.NotImplemented("FoedselsregistreringMyndighedNavn")); } if (egen.KontaktKanal != null) { return(StandardReturType.NotImplemented("KontaktKanal")); } if (egen.NaermestePaaroerende != null) { return(StandardReturType.NotImplemented("NaermestePaaroerende")); } if (egen.SoegVirkning != null) { return(StandardReturType.NotImplemented("SoegVirkning")); } if (egen.SoegVirkning != null) { return(StandardReturType.NotImplemented("SoegVirkning")); } } } } return(StandardReturType.OK()); }
public override StandardReturType ValidateInput() { /* * Do the validation here */ if (Criterion == null) { return(StandardReturType.NullInput("SoegObjekt")); } if (Criterion.SoegAttributListe == null) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe")); } else { if (Criterion.SoegAttributListe.SoegRegisterOplysning == null) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe.SoegRegisterOplysning")); } else { int index = 0; foreach (var prop in Criterion.SoegAttributListe.SoegRegisterOplysning) { if (prop == null) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe.SoegRegisterOplysning[" + index + "]")); } else { if (prop.Item == null) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe.SoegRegisterOplysning[" + index + "].CprBorger")); } else { CprBroker.Schemas.Part.CprBorgerType cprBorger = (CprBroker.Schemas.Part.CprBorgerType)prop.Item; CprBroker.Schemas.Part.DanskAdresseType danskAdresse = (CprBroker.Schemas.Part.DanskAdresseType)cprBorger.FolkeregisterAdresse.Item; if (danskAdresse == null) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe.SoegRegisterOplysning[" + index + "].CprBorger.DanskAdresse")); } else { if (String.IsNullOrEmpty(danskAdresse.AddressComplete.AddressAccess.MunicipalityCode)) { return(StandardReturType.NullInput("SoegObjekt.SoegAttributListe.SoegRegisterOplysning[" + index + "].CprBorger.DanskAdresse.AddressComplete.AddressAccess.MunicipalityCode")); } } } } index++; } } } var channelValidationResult = ValidateChannel(NotificationChannel); if (!StandardReturType.IsSucceeded(channelValidationResult)) { return(channelValidationResult); } return(StandardReturType.OK()); }