Skip to content
Snippets Groups Projects
Commit 00c19e01 authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Changed ProblemTypeEnum

parent 1f89529b
No related branches found
No related tags found
1 merge request!24AutoReject planning#594
......@@ -4,11 +4,11 @@ using Newtonsoft.Json;
namespace FitConnect.Models.v1.Api;
public class Problems {
public enum ProblemTypeEnum {
AttachmentMismatch,
MissingAttachments,
EncryptionIssue,
HashMismatch,
IncorrectAuthenticationTag,
InvalidEventLog,
MissingAuthenticationTag,
......@@ -26,18 +26,20 @@ public class Problems {
internal Problems() {
}
public Problems(ProblemTypeEnum problemType, string title, string detail, ProblemInstanceEnum problemInstance) {
this.type = problemType switch {
ProblemTypeEnum.MissingAttachments => "https://schema.fitko.de/fit-connect/events/problems/missing-attachment",
ProblemTypeEnum.AttachmentMismatch => "https://schema.fitko.de/fit-connect/problems/attachments-mismatch",
ProblemTypeEnum.EncryptionIssue => "https://schema.fitko.de/fit-connect/problems/encryption-issue",
ProblemTypeEnum.IncorrectAuthenticationTag => "https://schema.fitko.de/fit-connect/problems/incorrect-authentication-tag",
ProblemTypeEnum.InvalidEventLog => "https://schema.fitko.de/fit-connect/problems/invalid-event-log",
ProblemTypeEnum.MissingAuthenticationTag => "https://schema.fitko.de/fit-connect/problems/missing-authentication-tag",
ProblemTypeEnum.MissingSchema => "https://schema.fitko.de/fit-connect/problems/missing-schema",
ProblemTypeEnum.SchemaViolation => "https://schema.fitko.de/fit-connect/problems/schema-violation",
ProblemTypeEnum.SyntaxViolation => "https://schema.fitko.de/fit-connect/problems/syntax-violation",
ProblemTypeEnum.UnsupportedSchema => "https://schema.fitko.de/fit-connect/problems/unsupported-schema",
public Problems(ProblemTypeEnum problemType, string title, string detail,
ProblemInstanceEnum problemInstance) {
this.type = "https://schema.fitko.de/fit-connect/events/problems/" + problemType switch {
ProblemTypeEnum.MissingAttachments => "missing-attachment",
ProblemTypeEnum.AttachmentMismatch => "attachments-mismatch",
ProblemTypeEnum.EncryptionIssue => "encryption-issue",
ProblemTypeEnum.HashMismatch => "hash-mismatch",
ProblemTypeEnum.IncorrectAuthenticationTag => "incorrect-authentication-tag",
ProblemTypeEnum.InvalidEventLog => "invalid-event-log",
ProblemTypeEnum.MissingAuthenticationTag => "missing-authentication-tag",
ProblemTypeEnum.MissingSchema => "missing-schema",
ProblemTypeEnum.SchemaViolation => "schema-violation",
ProblemTypeEnum.SyntaxViolation => "syntax-violation",
ProblemTypeEnum.UnsupportedSchema => "unsupported-schema",
_ => throw new ArgumentOutOfRangeException(nameof(problemType), problemType, null)
};
......@@ -51,62 +53,66 @@ public class Problems {
};
}
public static readonly Problems AttachmentsMismatch =
public static readonly Problems AttachmentsMismatch =
new Problems(
ProblemTypeEnum.AttachmentMismatch,
ProblemTypeEnum.AttachmentMismatch,
"Fehlerhafte Anlagen-Liste",
"Die Liste der Anlagen in Submission und Event-Log stimmt nicht überein.",
ProblemInstanceEnum.Submission);
public static readonly Problems EncryptionIssue =
public static readonly Problems EncryptionIssue =
new Problems(
ProblemTypeEnum.EncryptionIssue,
"Entschlüsselungs-Fehler",
"Der Schlüssel {kid} ist nicht der zu diesem Zweck vorgesehene Schlüssel.",
ProblemInstanceEnum.Metadata
);
public static readonly Problems IncorrectAuthenticationTag =
new Problems(
public static readonly Problems IncorrectAuthenticationTag =
new Problems(
ProblemTypeEnum.IncorrectAuthenticationTag,
"Authentication-Tag ungültig",
"Das Authentication-Tag des Metadatensatzes ist ungültig.",
ProblemInstanceEnum.Metadata
);
public static readonly Problems InvalidEventLog =
new Problems (
public static readonly Problems InvalidEventLog =
new Problems(
ProblemTypeEnum.InvalidEventLog,
"Inkonsistentes Event-Log",
"Das Event-Log ist inkonsistent, da es nicht genau ein Event 'submit-submission' enthält.",
ProblemInstanceEnum.Submission
);
public static readonly Problems MissingAuthenticationTag =
new Problems (
public static readonly Problems MissingAuthenticationTag =
new Problems(
ProblemTypeEnum.MissingAuthenticationTag,
"Fehlende Authentication-Tags",
"Das Event 'submit-submission' enthält keine Authentication-Tags.",
ProblemInstanceEnum.Submission
);
public static readonly Problems MissingSchema = new Problems(
ProblemTypeEnum.MissingSchema,
"Schema-Referenz fehlt",
"Die Schema-Referenz fehlt im Metadatensatz.",
ProblemInstanceEnum.Metadata
);
public static readonly Problems SchemaViolation = new Problems (
public static readonly Problems SchemaViolation = new Problems(
ProblemTypeEnum.SchemaViolation,
"Schema-Fehler",
"Der Metadatensatz ist nicht schema-valide.",
ProblemInstanceEnum.Metadata
);
public static readonly Problems SyntaxViolation = new Problems(
ProblemTypeEnum.SyntaxViolation,
"Syntax-Fehler",
"Der Metadatensatz ist kein valides JSON.",
ProblemInstanceEnum.Metadata
);
public static readonly Problems UnsupportedSchema = new Problems(
ProblemTypeEnum.UnsupportedSchema,
"Metadatenschema nicht unterstützt",
......@@ -115,8 +121,6 @@ public class Problems {
);
[JsonProperty("instance", NullValueHandling = NullValueHandling.Ignore)]
public string instance { get; set; }
......@@ -134,5 +138,4 @@ public class Problems {
// [JsonProperty("items", NullValueHandling = NullValueHandling.Ignore)]
// public Items? items { get; set; }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment