From 1b07953f59084751e1259bfd9ef9450783d981a3 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 2 Mar 2021 23:03:11 +0000 Subject: [PATCH] --- docs/8.0/ayanova/docs/api-error-codes.md | 2 +- .../ControllerHelpers/ApiServerState.cs | 8 +++- .../Controllers/ServerStateController.cs | 8 ++-- server/AyaNova/biz/ApiErrorCode.cs | 43 ++++++++++--------- server/AyaNova/resource/de.json | 3 +- server/AyaNova/resource/en.json | 3 +- server/AyaNova/resource/es.json | 3 +- server/AyaNova/resource/fr.json | 3 +- 8 files changed, 41 insertions(+), 32 deletions(-) diff --git a/docs/8.0/ayanova/docs/api-error-codes.md b/docs/8.0/ayanova/docs/api-error-codes.md index 29ac14ac..56cfeff2 100644 --- a/docs/8.0/ayanova/docs/api-error-codes.md +++ b/docs/8.0/ayanova/docs/api-error-codes.md @@ -16,7 +16,7 @@ Here are all the API level error codes that can be returned by the API server: | 2003 | Authentication failed (HTTP STATUS 401), bad login or password, user not found | | 2004 | Not authorized (HTTP STATUS 403) - current user is not authorized for operation attempted on the resource (insufficient rights) | | 2005 | Object was changed by another user since retrieval (concurrency token mismatch). A record was attempted to be saved but another user has just modified it so it's invalid. (first save "wins") | -| 2006 | Authentication token replaced - A valid JWT token was presented, but it has been replaced by a more recent login | +| 2006 | API closed to allow migration from v7 using V8Migrate utility, SuperUser only login | | 2010 | Object not found - API could not find the object requested | | 2020 | PUT Id mismatch - object Id does not match route Id | | 2030 | Invalid operation - operation could not be completed, not valid, details in message property | diff --git a/server/AyaNova/ControllerHelpers/ApiServerState.cs b/server/AyaNova/ControllerHelpers/ApiServerState.cs index f9308598..c4a995ee 100644 --- a/server/AyaNova/ControllerHelpers/ApiServerState.cs +++ b/server/AyaNova/ControllerHelpers/ApiServerState.cs @@ -19,10 +19,12 @@ namespace AyaNova.Api.ControllerHelpers UNKNOWN = 0, ///No access for anyone API completely locked down. Not set by user but rather by internal server operations like importing or backup. Closed = 1, + ///Access only to SuperUser account for migration from AyaNova 7 + MigrateMode = 2, ///Access only to API Operations routes. Can be set by Ops user - OpsOnly = 2, + OpsOnly = 3, ///Open for all users (default). Can be set by Ops user - Open = 3 + Open = 4 } private ServerState _currentState = ServerState.Closed; @@ -121,6 +123,8 @@ namespace AyaNova.Api.ControllerHelpers throw new System.NotSupportedException("ApiServerState:ApiErrorCode - No error code is associated with server state OPEN"); case ServerState.OpsOnly: return ApiErrorCode.API_OPS_ONLY; + case ServerState.MigrateMode: + return ApiErrorCode.API_MIGRATE_MODE; case ServerState.Closed: return ApiErrorCode.API_CLOSED; diff --git a/server/AyaNova/Controllers/ServerStateController.cs b/server/AyaNova/Controllers/ServerStateController.cs index a14ff4d3..d3ee69d7 100644 --- a/server/AyaNova/Controllers/ServerStateController.cs +++ b/server/AyaNova/Controllers/ServerStateController.cs @@ -55,7 +55,7 @@ namespace AyaNova.Api.Controllers /// /// Set server state /// Valid parameters: - /// One of "OpsOnly" or "Open" + /// One of "OpsOnly", "MigrateMode" or "Open" /// /// {"serverState":"Open"} /// New server state @@ -73,11 +73,11 @@ namespace AyaNova.Api.Controllers ApiServerState.ServerState desiredState; if (!Enum.TryParse(state.ServerState, true, out desiredState)) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\" or \"Open\"")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\", \"MigrateMode\" or \"Open\"")); //don't allow a server to be set to closed, that's for internal ops only if (desiredState == ApiServerState.ServerState.Closed) - return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\" or \"Open\"")); + return BadRequest(new ApiErrorResponse(ApiErrorCode.VALIDATION_INVALID_VALUE, null, "Invalid state - must be one of \"OpsOnly\", \"MigrateMode\" or \"Open\"")); log.LogInformation($"ServerState change request by user {UserNameFromContext.Name(HttpContext.Items)} from current state of \"{serverState.GetState().ToString()}\" to \"{desiredState.ToString()}-{state.Reason}\""); @@ -97,7 +97,7 @@ namespace AyaNova.Api.Controllers public class ServerStateModel { /// - /// "OpsOnly" or "Open" + /// "OpsOnly", "MigrateMode" or "Open" /// /// [Required] diff --git a/server/AyaNova/biz/ApiErrorCode.cs b/server/AyaNova/biz/ApiErrorCode.cs index 433c6ac3..ffc09957 100644 --- a/server/AyaNova/biz/ApiErrorCode.cs +++ b/server/AyaNova/biz/ApiErrorCode.cs @@ -14,7 +14,8 @@ namespace AyaNova.Biz API_SERVER_ERROR = 2002, AUTHENTICATION_FAILED = 2003, NOT_AUTHORIZED = 2004, - CONCURRENCY_CONFLICT=2005, + CONCURRENCY_CONFLICT = 2005, + API_MIGRATE_MODE = 2006, NOT_FOUND = 2010, PUT_ID_MISMATCH = 2020, INVALID_OPERATION = 2030, @@ -29,27 +30,27 @@ namespace AyaNova.Biz VALIDATION_REFERENTIAL_INTEGRITY = 2208, VALIDATION_NOT_CHANGEABLE = 2209, CHILD_OBJECT_ERROR = 2210 -/* + /* -| 2000 | API closed - Server is running but access to the API has been closed to all users | -| 2001 | API closed all non OPS routes - Server is running but access to the API has been restricted to only server maintenance operations related functionality | -| 2002 | Internal error from the API server, details in [server log](common-log.md) file | -| 2003 | Authentication failed, bad login or password, user not found | -| 2004 | Not authorized - current user is not authorized for operation attempted on the resource (insufficient rights) | -| 2005 | Object was changed by another user since retrieval (concurrency token mismatch). A record was attempted to be saved but another user has just modified it so it's invalid. (first save "wins") | -| 2010 | Object not found - API could not find the object requested | -| 2020 | PUT Id mismatch - object Id does not match route Id | -| 2030 | Invalid operation - operation could not be completed, not valid, details in message property | -| 2200 | Validation error - general issue with object overall not valid, specifics in "details" property | -| 2201 | Validation error - Field is required but is empty or null | -| 2202 | Validation error - Field length exceeded. The limit will be returned in the `message` property of the validation error | -| 2203 | Validation error - invalid value. Usually an type mismatch or a logical or business rule mismatch (i.e. only certain values are valid for current state of object) | -| 2204 | Validation error - Customized form property is set to required but has an empty value | -| 2205 | Validation error - Required property is missing entirely. Usually a development or communications error | -| 2206 | Validation error - A text property is required to be unique but an existing record with an identical value was found in the database | -| 2207 | Validation error - When an object requires a start and end date the start date must be earlier than the end date | -| 2208 | Validation error - Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity | -| 2209 | Validation error - Indicates the attempted property change is invalid because the value is fixed and cannot be changed | */ + | 2000 | API closed - Server is running but access to the API has been closed to all users | + | 2001 | API closed all non OPS routes - Server is running but access to the API has been restricted to only server maintenance operations related functionality | + | 2002 | Internal error from the API server, details in [server log](common-log.md) file | + | 2003 | Authentication failed, bad login or password, user not found | + | 2004 | Not authorized - current user is not authorized for operation attempted on the resource (insufficient rights) | + | 2005 | Object was changed by another user since retrieval (concurrency token mismatch). A record was attempted to be saved but another user has just modified it so it's invalid. (first save "wins") | + | 2010 | Object not found - API could not find the object requested | + | 2020 | PUT Id mismatch - object Id does not match route Id | + | 2030 | Invalid operation - operation could not be completed, not valid, details in message property | + | 2200 | Validation error - general issue with object overall not valid, specifics in "details" property | + | 2201 | Validation error - Field is required but is empty or null | + | 2202 | Validation error - Field length exceeded. The limit will be returned in the `message` property of the validation error | + | 2203 | Validation error - invalid value. Usually an type mismatch or a logical or business rule mismatch (i.e. only certain values are valid for current state of object) | + | 2204 | Validation error - Customized form property is set to required but has an empty value | + | 2205 | Validation error - Required property is missing entirely. Usually a development or communications error | + | 2206 | Validation error - A text property is required to be unique but an existing record with an identical value was found in the database | + | 2207 | Validation error - When an object requires a start and end date the start date must be earlier than the end date | + | 2208 | Validation error - Modifying the object (usually a delete) would break the link to other records in the database and operation was disallowed to preserve data integrity | + | 2209 | Validation error - Indicates the attempted property change is invalid because the value is fixed and cannot be changed | */ } diff --git a/server/AyaNova/resource/de.json b/server/AyaNova/resource/de.json index a5e0dfec..5f3150ee 100644 --- a/server/AyaNova/resource/de.json +++ b/server/AyaNova/resource/de.json @@ -1778,7 +1778,8 @@ "ResetToDefault": "Auf Standard zurücksetzen", "ServerState": "Serverstatus", "ServerStateOpen": "Öffnen", - "ServerStateOps": "Nur Systembetrieb", + "ServerStateOps": "Nur Systembetrieb", + "ServerStateMigrateMode": "Server-Migrationsmodus", "ServerStateReason": "Grund", "TooManyResults": "Zu viele Ergebnisse, um alle anzuzeigen", "NoResults": "Keine Ergebnisse", diff --git a/server/AyaNova/resource/en.json b/server/AyaNova/resource/en.json index 3378064d..82e3e7f4 100644 --- a/server/AyaNova/resource/en.json +++ b/server/AyaNova/resource/en.json @@ -1778,7 +1778,8 @@ "ResetToDefault": "Reset to default", "ServerState": "Server state", "ServerStateOpen": "Open", - "ServerStateOps": "Server operations only", + "ServerStateOps": "Server operations only", + "ServerStateMigrateMode": "Server migration mode", "ServerStateReason": "Reason", "TooManyResults": "Too many results to show all", "NoResults": "No results", diff --git a/server/AyaNova/resource/es.json b/server/AyaNova/resource/es.json index 39a88459..9835cf74 100644 --- a/server/AyaNova/resource/es.json +++ b/server/AyaNova/resource/es.json @@ -1778,7 +1778,8 @@ "ResetToDefault": "Restablecen a los predeterminados", "ServerState": "Estado del servidor", "ServerStateOpen": "Abrir", - "ServerStateOps": "Solo operaciones del sistema", + "ServerStateOps": "Solo operaciones del sistema", + "ServerStateMigrateMode": "Modo de migración del servidor", "ServerStateReason": "Razón", "TooManyResults": "Demasiados resultados para mostrar todos", "NoResults": "No hay resultados", diff --git a/server/AyaNova/resource/fr.json b/server/AyaNova/resource/fr.json index 46233dca..fdd891fd 100644 --- a/server/AyaNova/resource/fr.json +++ b/server/AyaNova/resource/fr.json @@ -1778,7 +1778,8 @@ "ResetToDefault": "Rétablir la valeur par défaut", "ServerState": "État du serveur", "ServerStateOpen": "Ouvrir", - "ServerStateOps": "Opérations système uniquement", + "ServerStateOps": "Opérations système uniquement", + "ServerStateMigrateMode": "Mode de migration du serveur", "ServerStateReason": "Objectif", "TooManyResults": "Trop de résultats pour tout montrer", "NoResults": "Aucun résultat",