diff options
author | crupest <crupest@outlook.com> | 2021-04-30 17:53:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-04-30 17:53:40 +0800 |
commit | 5bd826d47c30f6e6ac6eded4fefb99f26786c3bc (patch) | |
tree | c9ad0a4706c70d3678945e6bce74b4a5da2a7eb5 /BackEnd | |
parent | 5d28f5d0eb352369c73e3908c7d00d868676c304 (diff) | |
download | timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.tar.gz timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.tar.bz2 timeline-5bd826d47c30f6e6ac6eded4fefb99f26786c3bc.zip |
refactor: ...
Diffstat (limited to 'BackEnd')
26 files changed, 509 insertions, 961 deletions
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs index 08857dc1..ac96ef9d 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/TokenTest.cs @@ -53,7 +53,7 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateDefaultClient();
await client.TestPostAssertErrorAsync(CreateTokenUrl,
new HttpCreateTokenRequest { Username = username, Password = password },
- errorCode: ErrorCodes.TokenController.Create_BadCredential);
+ errorCode: ErrorCodes.TokenController.CreateBadCredential);
}
[Fact]
@@ -79,7 +79,7 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateDefaultClient();
await client.TestPostAssertErrorAsync(VerifyTokenUrl,
new HttpVerifyTokenRequest { Token = "bad token hahaha" },
- errorCode: ErrorCodes.TokenController.Verify_BadFormat);
+ errorCode: ErrorCodes.TokenController.VerifyBadFormat);
}
[Fact]
@@ -98,7 +98,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestPostAssertErrorAsync(VerifyTokenUrl,
new HttpVerifyTokenRequest { Token = token },
- errorCode: ErrorCodes.TokenController.Verify_OldVersion);
+ errorCode: ErrorCodes.TokenController.VerifyOldVersion);
}
[Fact]
@@ -115,7 +115,7 @@ namespace Timeline.Tests.IntegratedTests await client.TestPostAssertErrorAsync(VerifyTokenUrl,
new HttpVerifyTokenRequest { Token = token },
- errorCode: ErrorCodes.TokenController.Verify_UserNotExist);
+ errorCode: ErrorCodes.TokenController.VerifyUserNotExist);
}
//[Fact]
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/UserAvatarTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/UserAvatarTest.cs index c2ccff64..52f04e52 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/UserAvatarTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/UserAvatarTest.cs @@ -99,9 +99,9 @@ namespace Timeline.Tests.IntegratedTests }
{
- await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", new[] { (byte)0x00 }, "image/png", errorCode: ErrorCodes.UserAvatar.BadFormat_CantDecode);
- await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", mockAvatar.Data, "image/jpeg", errorCode: ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat);
- await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", ImageHelper.CreatePngWithSize(100, 200), "image/png", errorCode: ErrorCodes.UserAvatar.BadFormat_BadSize);
+ await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", new[] { (byte)0x00 }, "image/png", errorCode: ErrorCodes.Image.CantDecode);
+ await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", mockAvatar.Data, "image/jpeg", errorCode: ErrorCodes.Image.UnmatchedFormat);
+ await client.TestPutByteArrayAssertErrorAsync("users/user1/avatar", ImageHelper.CreatePngWithSize(100, 200), "image/png", errorCode: ErrorCodes.Image.BadSize);
}
{
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/UserPermissionTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/UserPermissionTest.cs index 83dc51f9..26714c24 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/UserPermissionTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/UserPermissionTest.cs @@ -41,10 +41,10 @@ namespace Timeline.Tests.IntegratedTests using var client = await CreateClientAsAdministrator();
await client.TestPutAssertErrorAsync($"users/admin/permissions/{permission}",
- errorCode: ErrorCodes.UserController.ChangePermission_RootUser);
+ errorCode: ErrorCodes.UserController.InvalidOperationOnRootUser);
await client.TestDeleteAssertErrorAsync($"users/admin/permissions/{permission}",
- errorCode: ErrorCodes.UserController.ChangePermission_RootUser);
+ errorCode: ErrorCodes.UserController.InvalidOperationOnRootUser);
}
[Theory]
diff --git a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs index 7286e12e..d34bcaf9 100644 --- a/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs +++ b/BackEnd/Timeline.Tests/IntegratedTests/UserTest.cs @@ -183,7 +183,7 @@ namespace Timeline.Tests.IntegratedTests public async Task DeleteRootUser_Should_Error()
{
using var client = await CreateClientAsAdministrator();
- await client.TestDeleteAssertErrorAsync("users/admin", errorCode: ErrorCodes.UserController.Delete_RootUser);
+ await client.TestDeleteAssertErrorAsync("users/admin", errorCode: ErrorCodes.UserController.InvalidOperationOnRootUser);
}
[Fact]
@@ -310,7 +310,7 @@ namespace Timeline.Tests.IntegratedTests public async Task Op_ChangePassword_BadOldPassword()
{
using var client = await CreateClientAsUser();
- await client.TestPostAssertErrorAsync(changePasswordUrl, new HttpChangePasswordRequest { OldPassword = "???", NewPassword = "???" }, errorCode: ErrorCodes.UserController.ChangePassword_BadOldPassword);
+ await client.TestPostAssertErrorAsync(changePasswordUrl, new HttpChangePasswordRequest { OldPassword = "???", NewPassword = "???" }, errorCode: ErrorCodes.UserController.ChangePasswordBadOldPassword);
}
[Fact]
diff --git a/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs b/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs index 76a8b7ae..a3da73fa 100644 --- a/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs +++ b/BackEnd/Timeline/Controllers/ActionResultControllerExtensions.cs @@ -1,11 +1,22 @@ -using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
using Timeline.Models.Http;
namespace Timeline.Controllers
{
public static class ActionResultControllerExtensions
{
- public static BadRequestObjectResult BadRequestWithCodeAndMessage(this ControllerBase controller, int code, string message)
+ public static ObjectResult StatusCodeWithCommonResponse(this ControllerBase controller, int statusCode, int code, string message)
+ {
+ return controller.StatusCode(statusCode, new CommonResponse(code, message));
+ }
+
+ public static ObjectResult ForbidWithMessage(this ControllerBase controller, string? message = null)
+ {
+ return controller.StatusCode(StatusCodes.Status403Forbidden, new CommonResponse(ErrorCodes.Common.Forbid, message ?? Resource.MessageForbid));
+ }
+
+ public static BadRequestObjectResult BadRequestWithCommonResponse(this ControllerBase controller, int code, string message)
{
return controller.BadRequest(new CommonResponse(code, message));
}
diff --git a/BackEnd/Timeline/Controllers/Resource.Designer.cs b/BackEnd/Timeline/Controllers/Resource.Designer.cs index c2dfd3cd..f3d7264a 100644 --- a/BackEnd/Timeline/Controllers/Resource.Designer.cs +++ b/BackEnd/Timeline/Controllers/Resource.Designer.cs @@ -70,6 +70,150 @@ namespace Timeline.Controllers { }
/// <summary>
+ /// Looks up a localized string similar to You have no permission to access this..
+ /// </summary>
+ internal static string MessageForbid {
+ get {
+ return ResourceManager.GetString("MessageForbid", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to You can't do this unless you are administrator..
+ /// </summary>
+ internal static string MessageForbidNotAdministrator {
+ get {
+ return ResourceManager.GetString("MessageForbidNotAdministrator", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to You can't do this unless you are administrator or resource owner..
+ /// </summary>
+ internal static string MessageForbidNotAdministratorOrOwner {
+ get {
+ return ResourceManager.GetString("MessageForbidNotAdministratorOrOwner", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Image is not a square..
+ /// </summary>
+ internal static string MessageImageBadSize {
+ get {
+ return ResourceManager.GetString("MessageImageBadSize", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Image decode failed..
+ /// </summary>
+ internal static string MessageImageDecodeFailed {
+ get {
+ return ResourceManager.GetString("MessageImageDecodeFailed", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Specified image format does not match the actual one ..
+ /// </summary>
+ internal static string MessageImageFormatUnmatch {
+ get {
+ return ResourceManager.GetString("MessageImageFormatUnmatch", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Unknown error happened to image..
+ /// </summary>
+ internal static string MessageImageUnknownError {
+ get {
+ return ResourceManager.GetString("MessageImageUnknownError", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to You can't do this because it is the root user..
+ /// </summary>
+ internal static string MessageInvalidOperationOnRootUser {
+ get {
+ return ResourceManager.GetString("MessageInvalidOperationOnRootUser", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The old password is wrong..
+ /// </summary>
+ internal static string MessageOldPasswordWrong {
+ get {
+ return ResourceManager.GetString("MessageOldPasswordWrong", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The user specified by query param "relate" does not exist..
+ /// </summary>
+ internal static string MessageTimelineListQueryRelateNotExist {
+ get {
+ return ResourceManager.GetString("MessageTimelineListQueryRelateNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to '{0}' is an unkown visibility in the query parameter 'visibility'. .
+ /// </summary>
+ internal static string MessageTimelineListQueryVisibilityUnknown {
+ get {
+ return ResourceManager.GetString("MessageTimelineListQueryVisibilityUnknown", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Username or password is invalid..
+ /// </summary>
+ internal static string MessageTokenCreateBadCredential {
+ get {
+ return ResourceManager.GetString("MessageTokenCreateBadCredential", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token is of bad format. It might not be created by the server..
+ /// </summary>
+ internal static string MessageTokenVerifyBadFormat {
+ get {
+ return ResourceManager.GetString("MessageTokenVerifyBadFormat", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to Token has an old version. User might have update some info..
+ /// </summary>
+ internal static string MessageTokenVerifyOldVersion {
+ get {
+ return ResourceManager.GetString("MessageTokenVerifyOldVersion", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The token is expired..
+ /// </summary>
+ internal static string MessageTokenVerifyTimeExpired {
+ get {
+ return ResourceManager.GetString("MessageTokenVerifyTimeExpired", resourceCulture);
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to User does not exist. Administrator might have deleted this user..
+ /// </summary>
+ internal static string MessageTokenVerifyUserNotExist {
+ get {
+ return ResourceManager.GetString("MessageTokenVerifyUserNotExist", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to A user with given username already exists..
/// </summary>
internal static string MessageUsernameConflict {
diff --git a/BackEnd/Timeline/Controllers/Resource.resx b/BackEnd/Timeline/Controllers/Resource.resx index 8939dfd8..90c6bdd6 100644 --- a/BackEnd/Timeline/Controllers/Resource.resx +++ b/BackEnd/Timeline/Controllers/Resource.resx @@ -120,6 +120,54 @@ <data name="ExceptionNoUserId" xml:space="preserve">
<value>Can't get user id.</value>
</data>
+ <data name="MessageForbid" xml:space="preserve">
+ <value>You have no permission to access this.</value>
+ </data>
+ <data name="MessageForbidNotAdministrator" xml:space="preserve">
+ <value>You can't do this unless you are administrator.</value>
+ </data>
+ <data name="MessageForbidNotAdministratorOrOwner" xml:space="preserve">
+ <value>You can't do this unless you are administrator or resource owner.</value>
+ </data>
+ <data name="MessageImageBadSize" xml:space="preserve">
+ <value>Image is not a square.</value>
+ </data>
+ <data name="MessageImageDecodeFailed" xml:space="preserve">
+ <value>Image decode failed.</value>
+ </data>
+ <data name="MessageImageFormatUnmatch" xml:space="preserve">
+ <value>Specified image format does not match the actual one .</value>
+ </data>
+ <data name="MessageImageUnknownError" xml:space="preserve">
+ <value>Unknown error happened to image.</value>
+ </data>
+ <data name="MessageInvalidOperationOnRootUser" xml:space="preserve">
+ <value>You can't do this because it is the root user.</value>
+ </data>
+ <data name="MessageOldPasswordWrong" xml:space="preserve">
+ <value>The old password is wrong.</value>
+ </data>
+ <data name="MessageTimelineListQueryRelateNotExist" xml:space="preserve">
+ <value>The user specified by query param "relate" does not exist.</value>
+ </data>
+ <data name="MessageTimelineListQueryVisibilityUnknown" xml:space="preserve">
+ <value>'{0}' is an unkown visibility in the query parameter 'visibility'. </value>
+ </data>
+ <data name="MessageTokenCreateBadCredential" xml:space="preserve">
+ <value>Username or password is invalid.</value>
+ </data>
+ <data name="MessageTokenVerifyBadFormat" xml:space="preserve">
+ <value>The token is of bad format. It might not be created by the server.</value>
+ </data>
+ <data name="MessageTokenVerifyOldVersion" xml:space="preserve">
+ <value>Token has an old version. User might have update some info.</value>
+ </data>
+ <data name="MessageTokenVerifyTimeExpired" xml:space="preserve">
+ <value>The token is expired.</value>
+ </data>
+ <data name="MessageTokenVerifyUserNotExist" xml:space="preserve">
+ <value>User does not exist. Administrator might have deleted this user.</value>
+ </data>
<data name="MessageUsernameConflict" xml:space="preserve">
<value>A user with given username already exists.</value>
</data>
diff --git a/BackEnd/Timeline/Controllers/TimelineController.cs b/BackEnd/Timeline/Controllers/TimelineController.cs index bb770ea0..f04982dc 100644 --- a/BackEnd/Timeline/Controllers/TimelineController.cs +++ b/BackEnd/Timeline/Controllers/TimelineController.cs @@ -82,7 +82,7 @@ namespace Timeline.Controllers }
else
{
- return BadRequest(ErrorResponse.Common.CustomMessage_InvalidModel(Resources.Messages.TimelineController_QueryVisibilityUnknown, item));
+ return this.BadRequestWithCommonResponse(ErrorCodes.Common.InvalidModel, string.Format(Resource.MessageTimelineListQueryVisibilityUnknown, visibility));
}
}
}
@@ -100,7 +100,7 @@ namespace Timeline.Controllers }
catch (EntityNotExistException)
{
- return BadRequest(ErrorResponse.TimelineController.QueryRelateNotExist());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, Resource.MessageTimelineListQueryRelateNotExist);
}
}
@@ -143,7 +143,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _service.HasManagePermissionAsync(timelineId, this.GetUserId()))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
await _service.ChangePropertyAsync(timelineId, _mapper.AutoMapperMap<TimelineChangePropertyParams>(body));
@@ -169,7 +169,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !(await _service.HasManagePermissionAsync(timelineId, this.GetUserId())))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
var userId = await _userService.GetUserIdByUsernameAsync(member);
@@ -194,7 +194,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !(await _service.HasManagePermissionAsync(timelineId, this.GetUserId())))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
@@ -239,7 +239,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !(await _service.HasManagePermissionAsync(timelineId, this.GetUserId())))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
await _service.DeleteTimelineAsync(timelineId);
diff --git a/BackEnd/Timeline/Controllers/TimelinePostController.cs b/BackEnd/Timeline/Controllers/TimelinePostController.cs index 70f672d1..21102400 100644 --- a/BackEnd/Timeline/Controllers/TimelinePostController.cs +++ b/BackEnd/Timeline/Controllers/TimelinePostController.cs @@ -69,7 +69,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _timelineService.HasReadPermissionAsync(timelineId, this.GetOptionalUserId()))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
var posts = await _postService.GetPostsAsync(timelineId, modifiedSince, includeDeleted ?? false);
@@ -94,7 +94,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _timelineService.HasReadPermissionAsync(timelineId, this.GetOptionalUserId()))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
var post = await _postService.GetPostAsync(timelineId, postId);
@@ -140,7 +140,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _timelineService.HasReadPermissionAsync(timelineId, this.GetOptionalUserId()))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
return await DataCacheHelper.GenerateActionResult(this,
@@ -176,7 +176,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _timelineService.IsMemberOfAsync(timelineId, userId))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
var createRequest = new TimelinePostCreateRequest()
@@ -235,7 +235,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _postService.HasPostModifyPermissionAsync(timelineId, post, this.GetUserId(), true))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
var entity = await _postService.PatchPostAsync(timelineId, post, new TimelinePostPatchRequest { Time = body.Time, Color = body.Color });
@@ -262,7 +262,7 @@ namespace Timeline.Controllers if (!UserHasAllTimelineManagementPermission && !await _postService.HasPostModifyPermissionAsync(timelineId, post, this.GetUserId(), true))
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage();
}
await _postService.DeletePostAsync(timelineId, post);
diff --git a/BackEnd/Timeline/Controllers/TokenController.cs b/BackEnd/Timeline/Controllers/TokenController.cs index 915f710d..080a4dc4 100644 --- a/BackEnd/Timeline/Controllers/TokenController.cs +++ b/BackEnd/Timeline/Controllers/TokenController.cs @@ -57,11 +57,11 @@ namespace Timeline.Controllers }
catch (EntityNotExistException)
{
- return BadRequest(ErrorResponse.TokenController.Create_BadCredential());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.CreateBadCredential, Resource.MessageTokenCreateBadCredential);
}
catch (BadPasswordException)
{
- return BadRequest(ErrorResponse.TokenController.Create_BadCredential());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.CreateBadCredential, Resource.MessageTokenCreateBadCredential);
}
}
@@ -85,19 +85,19 @@ namespace Timeline.Controllers }
catch (UserTokenTimeExpiredException)
{
- return BadRequest(ErrorResponse.TokenController.Verify_TimeExpired());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.VerifyTimeExpired, Resource.MessageTokenVerifyTimeExpired);
}
catch (UserTokenVersionExpiredException)
{
- return BadRequest(ErrorResponse.TokenController.Verify_OldVersion());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.VerifyOldVersion, Resource.MessageTokenVerifyOldVersion);
}
catch (UserTokenBadFormatException)
{
- return BadRequest(ErrorResponse.TokenController.Verify_BadFormat());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.VerifyBadFormat, Resource.MessageTokenVerifyBadFormat);
}
catch (UserTokenUserNotExistException)
{
- return BadRequest(ErrorResponse.TokenController.Verify_UserNotExist());
+ return this.BadRequestWithCommonResponse(ErrorCodes.TokenController.VerifyUserNotExist, Resource.MessageTokenVerifyUserNotExist);
}
}
}
diff --git a/BackEnd/Timeline/Controllers/UserAvatarController.cs b/BackEnd/Timeline/Controllers/UserAvatarController.cs index 5d9becaa..05c73aa2 100644 --- a/BackEnd/Timeline/Controllers/UserAvatarController.cs +++ b/BackEnd/Timeline/Controllers/UserAvatarController.cs @@ -65,7 +65,7 @@ namespace Timeline.Controllers {
if (!this.UserHasPermission(UserPermission.UserManagement) && User.Identity!.Name != username)
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage(Resource.MessageForbidNotAdministratorOrOwner);
}
long id = await _userService.GetUserIdByUsernameAsync(username);
@@ -82,10 +82,10 @@ namespace Timeline.Controllers {
return BadRequest(e.Error switch
{
- ImageException.ErrorReason.CantDecode => ErrorResponse.UserAvatar.BadFormat_CantDecode(),
- ImageException.ErrorReason.UnmatchedFormat => ErrorResponse.UserAvatar.BadFormat_UnmatchedFormat(),
- ImageException.ErrorReason.BadSize => ErrorResponse.UserAvatar.BadFormat_BadSize(),
- _ => throw new Exception()
+ ImageException.ErrorReason.CantDecode => new CommonResponse(ErrorCodes.Image.CantDecode, Resource.MessageImageDecodeFailed),
+ ImageException.ErrorReason.UnmatchedFormat => new CommonResponse(ErrorCodes.Image.UnmatchedFormat, Resource.MessageImageFormatUnmatch),
+ ImageException.ErrorReason.BadSize => new CommonResponse(ErrorCodes.Image.BadSize, Resource.MessageImageBadSize),
+ _ => new CommonResponse(ErrorCodes.Image.Unknown, Resource.MessageImageUnknownError)
});
}
}
@@ -108,7 +108,7 @@ namespace Timeline.Controllers {
if (!this.UserHasPermission(UserPermission.UserManagement) && User.Identity!.Name != username)
{
- return StatusCode(StatusCodes.Status403Forbidden, ErrorResponse.Common.Forbid());
+ return this.ForbidWithMessage(Resource.MessageForbidNotAdministratorOrOwner);
}
long id = await _userService.GetUserIdByUsernameAsync(username);
diff --git a/BackEnd/Timeline/Controllers/UserController.cs b/BackEnd/Timeline/Controllers/UserController.cs index bdf9c0b7..ec732caa 100644 --- a/BackEnd/Timeline/Controllers/UserController.cs +++ b/BackEnd/Timeline/Controllers/UserController.cs @@ -102,16 +102,13 @@ namespace Timeline.Controllers else
{
if (User.Identity!.Name != username)
- return StatusCode(StatusCodes.Status403Forbidden,
- ErrorResponse.Common.CustomMessage_Forbid(Resources.Messages.Common_Forbid_NotSelf));
+ return this.ForbidWithMessage(Resource.MessageForbidNotAdministratorOrOwner);
if (body.Username != null)
- return StatusCode(StatusCodes.Status403Forbidden,
- ErrorResponse.Common.CustomMessage_Forbid(Resources.Messages.UserController_Patch_Forbid_Username));
+ return this.ForbidWithMessage(Resource.MessageForbidNotAdministrator);
if (body.Password != null)
- return StatusCode(StatusCodes.Status403Forbidden,
- ErrorResponse.Common.CustomMessage_Forbid(Resources.Messages.UserController_Patch_Forbid_Password));
+ return this.ForbidWithMessage(Resource.MessageForbidNotAdministrator);
var user = await _userService.ModifyUserAsync(this.GetUserId(), _mapper.AutoMapperMap<ModifyUserParams>(body));
return await _mapper.MapAsync<HttpUser>(user, Url, User);
@@ -140,7 +137,7 @@ namespace Timeline.Controllers }
catch (InvalidOperationOnRootUserException)
{
- return BadRequest(ErrorResponse.UserController.Delete_RootUser());
+ return this.BadRequestWithCommonResponse(ErrorCodes.UserController.InvalidOperationOnRootUser, Resource.MessageInvalidOperationOnRootUser);
}
}
@@ -160,7 +157,7 @@ namespace Timeline.Controllers }
catch (BadPasswordException)
{
- return BadRequest(ErrorResponse.UserController.ChangePassword_BadOldPassword());
+ return this.BadRequestWithCommonResponse(ErrorCodes.UserController.ChangePasswordBadOldPassword, Resource.MessageOldPasswordWrong);
}
// User can't be non-existent or the token is bad.
}
@@ -181,7 +178,7 @@ namespace Timeline.Controllers }
catch (InvalidOperationOnRootUserException)
{
- return BadRequest(ErrorResponse.UserController.ChangePermission_RootUser());
+ return this.BadRequestWithCommonResponse(ErrorCodes.UserController.InvalidOperationOnRootUser, Resource.MessageInvalidOperationOnRootUser);
}
}
@@ -201,7 +198,7 @@ namespace Timeline.Controllers }
catch (InvalidOperationOnRootUserException)
{
- return BadRequest(ErrorResponse.UserController.ChangePermission_RootUser());
+ return this.BadRequestWithCommonResponse(ErrorCodes.UserController.InvalidOperationOnRootUser, Resource.MessageInvalidOperationOnRootUser);
}
}
}
diff --git a/BackEnd/Timeline/ErrorCodes.cs b/BackEnd/Timeline/ErrorCodes.cs index 06952822..79054a6f 100644 --- a/BackEnd/Timeline/ErrorCodes.cs +++ b/BackEnd/Timeline/ErrorCodes.cs @@ -56,25 +56,25 @@ public static class TokenController
{
- public const int Create_BadCredential = 1_101_01_01;
- public const int Verify_BadFormat = 1_101_02_01;
- public const int Verify_UserNotExist = 1_101_02_02;
- public const int Verify_OldVersion = 1_101_02_03;
- public const int Verify_TimeExpired = 1_101_02_04;
+ public const int CreateBadCredential = 1_101_01_01;
+ public const int VerifyBadFormat = 1_101_02_01;
+ public const int VerifyUserNotExist = 1_101_02_02;
+ public const int VerifyOldVersion = 1_101_02_03;
+ public const int VerifyTimeExpired = 1_101_02_04;
}
public static class UserController
{
- public const int ChangePassword_BadOldPassword = 1_102_02_01;
- public const int ChangePermission_RootUser = 1_102_03_01;
- public const int Delete_RootUser = 1_102_04_01;
+ public const int ChangePasswordBadOldPassword = 1_102_01_01;
+ public const int InvalidOperationOnRootUser = 1_102_02_01;
}
- public static class UserAvatar
+ public static class Image
{
- public const int BadFormat_CantDecode = 1_103_00_01;
- public const int BadFormat_UnmatchedFormat = 1_103_00_02;
- public const int BadFormat_BadSize = 1_103_00_03;
+ public const int CantDecode = 1_103_00_01;
+ public const int UnmatchedFormat = 1_103_00_02;
+ public const int BadSize = 1_103_00_03;
+ public const int Unknown = 1_103_00_04;
}
public static class TimelineController
diff --git a/BackEnd/Timeline/Filters/MaxContentLengthAttribute.cs b/BackEnd/Timeline/Filters/MaxContentLengthAttribute.cs new file mode 100644 index 00000000..507a6404 --- /dev/null +++ b/BackEnd/Timeline/Filters/MaxContentLengthAttribute.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.Mvc;
+
+namespace Timeline.Filters
+{
+ /// <summary>
+ /// Restrict max content length.
+ /// </summary>
+ public class MaxContentLengthAttribute : TypeFilterAttribute
+ {
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="maxByteLength">Max length.</param>
+ public MaxContentLengthAttribute(long maxByteLength)
+ : base(typeof(MaxContentLengthFilter))
+ {
+ MaxByteLength = maxByteLength;
+ Arguments = new object[] { maxByteLength };
+ }
+
+ /// <summary>
+ /// Max length.
+ /// </summary>
+ public long MaxByteLength { get; }
+ }
+}
diff --git a/BackEnd/Timeline/Filters/Header.cs b/BackEnd/Timeline/Filters/MaxContentLengthFilter.cs index cc5ddd9f..0127971a 100644 --- a/BackEnd/Timeline/Filters/Header.cs +++ b/BackEnd/Timeline/Filters/MaxContentLengthFilter.cs @@ -34,30 +34,10 @@ namespace Timeline.Filters var contentLength = context.HttpContext.Request.ContentLength;
if (contentLength != null && contentLength > MaxByteLength)
{
- context.Result = new BadRequestObjectResult(ErrorResponse.Common.Content.TooBig(MaxByteLength + "B"));
+ context.Result = new BadRequestObjectResult(
+ new CommonResponse(ErrorCodes.Common.Content.TooBig,
+ string.Format(Resource.MessageContentLengthTooBig, MaxByteLength + "B")));
}
}
}
-
- /// <summary>
- /// Restrict max content length.
- /// </summary>
- public class MaxContentLengthAttribute : TypeFilterAttribute
- {
- /// <summary>
- ///
- /// </summary>
- /// <param name="maxByteLength">Max length.</param>
- public MaxContentLengthAttribute(long maxByteLength)
- : base(typeof(MaxContentLengthFilter))
- {
- MaxByteLength = maxByteLength;
- Arguments = new object[] { maxByteLength };
- }
-
- /// <summary>
- /// Max length.
- /// </summary>
- public long MaxByteLength { get; }
- }
}
diff --git a/BackEnd/Timeline/Filters/Resource.Designer.cs b/BackEnd/Timeline/Filters/Resource.Designer.cs index 8ae6d288..d5b533d4 100644 --- a/BackEnd/Timeline/Filters/Resource.Designer.cs +++ b/BackEnd/Timeline/Filters/Resource.Designer.cs @@ -61,6 +61,15 @@ namespace Timeline.Filters { }
/// <summary>
+ /// Looks up a localized string similar to Content length is too big. It can't be bigger than {0}..
+ /// </summary>
+ internal static string MessageContentLengthTooBig {
+ get {
+ return ResourceManager.GetString("MessageContentLengthTooBig", resourceCulture);
+ }
+ }
+
+ /// <summary>
/// Looks up a localized string similar to The entity you want to create already exists. Entity type is {0}. Constraints are {1}..
/// </summary>
internal static string MessageEntityAlreadyExist {
diff --git a/BackEnd/Timeline/Filters/Resource.resx b/BackEnd/Timeline/Filters/Resource.resx index e9a5fbf9..d55e996c 100644 --- a/BackEnd/Timeline/Filters/Resource.resx +++ b/BackEnd/Timeline/Filters/Resource.resx @@ -117,6 +117,9 @@ <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
+ <data name="MessageContentLengthTooBig" xml:space="preserve">
+ <value>Content length is too big. It can't be bigger than {0}.</value>
+ </data>
<data name="MessageEntityAlreadyExist" xml:space="preserve">
<value>The entity you want to create already exists. Entity type is {0}. Constraints are {1}.</value>
</data>
diff --git a/BackEnd/Timeline/Helpers/Cache/DataCacheHelper.cs b/BackEnd/Timeline/Helpers/Cache/DataCacheHelper.cs index b7d86b18..1d1ab64e 100644 --- a/BackEnd/Timeline/Helpers/Cache/DataCacheHelper.cs +++ b/BackEnd/Timeline/Helpers/Cache/DataCacheHelper.cs @@ -48,7 +48,7 @@ namespace Timeline.Helpers.Cache {
if (!EntityTagHeaderValue.TryParseList(ifNonMatchHeaderValue, out var eTagList))
{
- return controller.BadRequest(ErrorResponse.Common.Header.IfNonMatch_BadFormat());
+ return controller.BadRequest(new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, "Header If-None-Match is of bad format."));
}
if (eTagList.FirstOrDefault(e => e.Equals(eTag)) != null)
diff --git a/BackEnd/Timeline/Helpers/InvalidModelResponseFactory.cs b/BackEnd/Timeline/Helpers/InvalidModelResponseFactory.cs index 9b253e7d..121aee6a 100644 --- a/BackEnd/Timeline/Helpers/InvalidModelResponseFactory.cs +++ b/BackEnd/Timeline/Helpers/InvalidModelResponseFactory.cs @@ -19,7 +19,7 @@ namespace Timeline.Helpers messageBuilder.AppendLine(error.ErrorMessage);
}
- return new BadRequestObjectResult(ErrorResponse.Common.CustomMessage_InvalidModel(messageBuilder.ToString()));
+ return new BadRequestObjectResult(new CommonResponse(ErrorCodes.Common.InvalidModel, $"Request format is bad. {messageBuilder}"));
}
}
}
diff --git a/BackEnd/Timeline/Models/Http/ErrorResponse.cs b/BackEnd/Timeline/Models/Http/ErrorResponse.cs deleted file mode 100644 index 7ab520a7..00000000 --- a/BackEnd/Timeline/Models/Http/ErrorResponse.cs +++ /dev/null @@ -1,216 +0,0 @@ -using static Timeline.Resources.Messages;
-
-namespace Timeline.Models.Http
-{
- public static class ErrorResponse
- {
- public static class Common
- {
- public static CommonResponse InvalidModel(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(Common_InvalidModel, formatArgs));
- }
-
- public static CommonResponse CustomMessage_InvalidModel(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.InvalidModel, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Forbid(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(Common_Forbid, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Forbid(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Forbid, string.Format(message, formatArgs));
- }
-
- public static CommonResponse UnknownEndpoint(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.UnknownEndpoint, string.Format(Common_UnknownEndpoint, formatArgs));
- }
-
- public static CommonResponse CustomMessage_UnknownEndpoint(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.UnknownEndpoint, string.Format(message, formatArgs));
- }
-
- public static class Header
- {
- public static CommonResponse IfNonMatch_BadFormat(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(Common_Header_IfNonMatch_BadFormat, formatArgs));
- }
-
- public static CommonResponse CustomMessage_IfNonMatch_BadFormat(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Header.IfNonMatch_BadFormat, string.Format(message, formatArgs));
- }
-
- }
-
- public static class Content
- {
- public static CommonResponse TooBig(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(Common_Content_TooBig, formatArgs));
- }
-
- public static CommonResponse CustomMessage_TooBig(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.Common.Content.TooBig, string.Format(message, formatArgs));
- }
-
- }
-
- }
-
- public static class TokenController
- {
- public static CommonResponse Create_BadCredential(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(TokenController_Create_BadCredential, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Create_BadCredential(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Create_BadCredential, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Verify_BadFormat(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(TokenController_Verify_BadFormat, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Verify_BadFormat(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_BadFormat, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Verify_UserNotExist(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(TokenController_Verify_UserNotExist, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Verify_UserNotExist(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_UserNotExist, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Verify_OldVersion(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(TokenController_Verify_OldVersion, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Verify_OldVersion(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_OldVersion, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Verify_TimeExpired(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(TokenController_Verify_TimeExpired, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Verify_TimeExpired(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TokenController.Verify_TimeExpired, string.Format(message, formatArgs));
- }
-
- }
-
- public static class UserController
- {
- public static CommonResponse ChangePassword_BadOldPassword(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(UserController_ChangePassword_BadOldPassword, formatArgs));
- }
-
- public static CommonResponse CustomMessage_ChangePassword_BadOldPassword(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.ChangePassword_BadOldPassword, string.Format(message, formatArgs));
- }
-
- public static CommonResponse ChangePermission_RootUser(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.ChangePermission_RootUser, string.Format(UserController_ChangePermission_RootUser, formatArgs));
- }
-
- public static CommonResponse CustomMessage_ChangePermission_RootUser(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.ChangePermission_RootUser, string.Format(message, formatArgs));
- }
-
- public static CommonResponse Delete_RootUser(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.Delete_RootUser, string.Format(UserController_Delete_RootUser, formatArgs));
- }
-
- public static CommonResponse CustomMessage_Delete_RootUser(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserController.Delete_RootUser, string.Format(message, formatArgs));
- }
-
- }
-
- public static class UserAvatar
- {
- public static CommonResponse BadFormat_CantDecode(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(UserAvatar_BadFormat_CantDecode, formatArgs));
- }
-
- public static CommonResponse CustomMessage_BadFormat_CantDecode(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_CantDecode, string.Format(message, formatArgs));
- }
-
- public static CommonResponse BadFormat_UnmatchedFormat(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(UserAvatar_BadFormat_UnmatchedFormat, formatArgs));
- }
-
- public static CommonResponse CustomMessage_BadFormat_UnmatchedFormat(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_UnmatchedFormat, string.Format(message, formatArgs));
- }
-
- public static CommonResponse BadFormat_BadSize(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(UserAvatar_BadFormat_BadSize, formatArgs));
- }
-
- public static CommonResponse CustomMessage_BadFormat_BadSize(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.UserAvatar.BadFormat_BadSize, string.Format(message, formatArgs));
- }
-
- }
-
- public static class TimelineController
- {
- public static CommonResponse QueryRelateNotExist(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(TimelineController_QueryRelateNotExist, formatArgs));
- }
-
- public static CommonResponse CustomMessage_QueryRelateNotExist(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.TimelineController.QueryRelateNotExist, string.Format(message, formatArgs));
- }
-
- public static CommonResponse PostNotExist(params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.NotExist.TimelinePost, string.Format(TimelineController_PostNotExist, formatArgs));
- }
-
- public static CommonResponse CustomMessage_PostNotExist(string message, params object?[] formatArgs)
- {
- return new CommonResponse(ErrorCodes.NotExist.TimelinePost, string.Format(message, formatArgs));
- }
- }
-
- }
-
-}
diff --git a/BackEnd/Timeline/Resources/Messages.Designer.cs b/BackEnd/Timeline/Resources/Messages.Designer.cs deleted file mode 100644 index c6b7d5e7..00000000 --- a/BackEnd/Timeline/Resources/Messages.Designer.cs +++ /dev/null @@ -1,414 +0,0 @@ -//------------------------------------------------------------------------------
-// <auto-generated>
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-// </auto-generated>
-//------------------------------------------------------------------------------
-
-namespace Timeline.Resources {
- using System;
-
-
- /// <summary>
- /// A strongly-typed resource class, for looking up localized strings, etc.
- /// </summary>
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Messages {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Messages() {
- }
-
- /// <summary>
- /// Returns the cached ResourceManager instance used by this class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Resources.Messages", typeof(Messages).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- /// <summary>
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- /// </summary>
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Body is too big. It can't be bigger than {0}..
- /// </summary>
- internal static string Common_Content_TooBig {
- get {
- return ResourceManager.GetString("Common_Content_TooBig", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Actual body length is bigger than it in header..
- /// </summary>
- internal static string Common_Content_UnmatchedLength_Bigger {
- get {
- return ResourceManager.GetString("Common_Content_UnmatchedLength_Bigger", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Actual body length is smaller than it in header..
- /// </summary>
- internal static string Common_Content_UnmatchedLength_Smaller {
- get {
- return ResourceManager.GetString("Common_Content_UnmatchedLength_Smaller", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You have no permission to do the operation..
- /// </summary>
- internal static string Common_Forbid {
- get {
- return ResourceManager.GetString("Common_Forbid", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You are not the resource owner..
- /// </summary>
- internal static string Common_Forbid_NotSelf {
- get {
- return ResourceManager.GetString("Common_Forbid_NotSelf", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Header Content-Length is missing or of bad format..
- /// </summary>
- internal static string Common_Header_ContentLength_Missing {
- get {
- return ResourceManager.GetString("Common_Header_ContentLength_Missing", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Header Content-Length must not be 0..
- /// </summary>
- internal static string Common_Header_ContentLength_Zero {
- get {
- return ResourceManager.GetString("Common_Header_ContentLength_Zero", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Header Content-Type is missing..
- /// </summary>
- internal static string Common_Header_ContentType_Missing {
- get {
- return ResourceManager.GetString("Common_Header_ContentType_Missing", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Header If-Non-Match is of bad format..
- /// </summary>
- internal static string Common_Header_IfNonMatch_BadFormat {
- get {
- return ResourceManager.GetString("Common_Header_IfNonMatch_BadFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Model is of bad format..
- /// </summary>
- internal static string Common_InvalidModel {
- get {
- return ResourceManager.GetString("Common_InvalidModel", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The api endpoint you request is unknown. You might get the wrong api entry..
- /// </summary>
- internal static string Common_UnknownEndpoint {
- get {
- return ResourceManager.GetString("Common_UnknownEndpoint", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Unknown type of post content..
- /// </summary>
- internal static string TimelineController_ContentUnknownType {
- get {
- return ResourceManager.GetString("TimelineController_ContentUnknownType", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Data field is not a valid base64 string in image content..
- /// </summary>
- internal static string TimelineController_ImageContentDataNotBase64 {
- get {
- return ResourceManager.GetString("TimelineController_ImageContentDataNotBase64", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Data field is not a valid image after base64 decoding in image content..
- /// </summary>
- internal static string TimelineController_ImageContentDataNotImage {
- get {
- return ResourceManager.GetString("TimelineController_ImageContentDataNotImage", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Data field is required for image content..
- /// </summary>
- internal static string TimelineController_ImageContentDataRequired {
- get {
- return ResourceManager.GetString("TimelineController_ImageContentDataRequired", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The user to set as member does not exist..
- /// </summary>
- internal static string TimelineController_MemberPut_NotExist {
- get {
- return ResourceManager.GetString("TimelineController_MemberPut_NotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to A timeline with given name already exists..
- /// </summary>
- internal static string TimelineController_NameConflict {
- get {
- return ResourceManager.GetString("TimelineController_NameConflict", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The timeline with given name does not exist..
- /// </summary>
- internal static string TimelineController_NotExist {
- get {
- return ResourceManager.GetString("TimelineController_NotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The post of that type has no data..
- /// </summary>
- internal static string TimelineController_PostNoData {
- get {
- return ResourceManager.GetString("TimelineController_PostNoData", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The post to operate on does not exist..
- /// </summary>
- internal static string TimelineController_PostNotExist {
- get {
- return ResourceManager.GetString("TimelineController_PostNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The user specified by query param "relate" does not exist..
- /// </summary>
- internal static string TimelineController_QueryRelateNotExist {
- get {
- return ResourceManager.GetString("TimelineController_QueryRelateNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to '{0}' is an unkown visibility in the query parameter 'visibility'. .
- /// </summary>
- internal static string TimelineController_QueryVisibilityUnknown {
- get {
- return ResourceManager.GetString("TimelineController_QueryVisibilityUnknown", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Text field is required for text content..
- /// </summary>
- internal static string TimelineController_TextContentTextRequired {
- get {
- return ResourceManager.GetString("TimelineController_TextContentTextRequired", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Username or password is invalid..
- /// </summary>
- internal static string TokenController_Create_BadCredential {
- get {
- return ResourceManager.GetString("TokenController_Create_BadCredential", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The token is of bad format. It might not be created by the server..
- /// </summary>
- internal static string TokenController_Verify_BadFormat {
- get {
- return ResourceManager.GetString("TokenController_Verify_BadFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Token has an old version. User might have update some info..
- /// </summary>
- internal static string TokenController_Verify_OldVersion {
- get {
- return ResourceManager.GetString("TokenController_Verify_OldVersion", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The token is expired..
- /// </summary>
- internal static string TokenController_Verify_TimeExpired {
- get {
- return ResourceManager.GetString("TokenController_Verify_TimeExpired", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to User does not exist. Administrator might have deleted this user..
- /// </summary>
- internal static string TokenController_Verify_UserNotExist {
- get {
- return ResourceManager.GetString("TokenController_Verify_UserNotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Image is not a square..
- /// </summary>
- internal static string UserAvatar_BadFormat_BadSize {
- get {
- return ResourceManager.GetString("UserAvatar_BadFormat_BadSize", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Image decode failed..
- /// </summary>
- internal static string UserAvatar_BadFormat_CantDecode {
- get {
- return ResourceManager.GetString("UserAvatar_BadFormat_CantDecode", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Image format does not match the one in header..
- /// </summary>
- internal static string UserAvatar_BadFormat_UnmatchedFormat {
- get {
- return ResourceManager.GetString("UserAvatar_BadFormat_UnmatchedFormat", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to The user to operate on does not exist..
- /// </summary>
- internal static string UserCommon_NotExist {
- get {
- return ResourceManager.GetString("UserCommon_NotExist", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to Old password is wrong..
- /// </summary>
- internal static string UserController_ChangePassword_BadOldPassword {
- get {
- return ResourceManager.GetString("UserController_ChangePassword_BadOldPassword", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You can't change permission of root user..
- /// </summary>
- internal static string UserController_ChangePermission_RootUser {
- get {
- return ResourceManager.GetString("UserController_ChangePermission_RootUser", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You can't delete root user..
- /// </summary>
- internal static string UserController_Delete_RootUser {
- get {
- return ResourceManager.GetString("UserController_Delete_RootUser", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You can't set permission unless you are administrator..
- /// </summary>
- internal static string UserController_Patch_Forbid_Administrator {
- get {
- return ResourceManager.GetString("UserController_Patch_Forbid_Administrator", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You can't set password unless you are administrator. If you want to change password, use /userop/changepassword ..
- /// </summary>
- internal static string UserController_Patch_Forbid_Password {
- get {
- return ResourceManager.GetString("UserController_Patch_Forbid_Password", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to You can't set username unless you are administrator..
- /// </summary>
- internal static string UserController_Patch_Forbid_Username {
- get {
- return ResourceManager.GetString("UserController_Patch_Forbid_Username", resourceCulture);
- }
- }
-
- /// <summary>
- /// Looks up a localized string similar to A user with given username already exists..
- /// </summary>
- internal static string UserController_UsernameConflict {
- get {
- return ResourceManager.GetString("UserController_UsernameConflict", resourceCulture);
- }
- }
- }
-}
diff --git a/BackEnd/Timeline/Resources/Messages.resx b/BackEnd/Timeline/Resources/Messages.resx deleted file mode 100644 index 2386d1eb..00000000 --- a/BackEnd/Timeline/Resources/Messages.resx +++ /dev/null @@ -1,237 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?>
-<root>
- <!--
- Microsoft ResX Schema
-
- Version 2.0
-
- The primary goals of this format is to allow a simple XML format
- that is mostly human readable. The generation and parsing of the
- various data types are done through the TypeConverter classes
- associated with the data types.
-
- Example:
-
- ... ado.net/XML headers & schema ...
- <resheader name="resmimetype">text/microsoft-resx</resheader>
- <resheader name="version">2.0</resheader>
- <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
- <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
- <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
- <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
- <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
- <value>[base64 mime encoded serialized .NET Framework object]</value>
- </data>
- <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
- <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
- <comment>This is a comment</comment>
- </data>
-
- There are any number of "resheader" rows that contain simple
- name/value pairs.
-
- Each data row contains a name, and value. The row also contains a
- type or mimetype. Type corresponds to a .NET class that support
- text/value conversion through the TypeConverter architecture.
- Classes that don't support this are serialized and stored with the
- mimetype set.
-
- The mimetype is used for serialized objects, and tells the
- ResXResourceReader how to depersist the object. This is currently not
- extensible. For a given mimetype the value must be set accordingly:
-
- Note - application/x-microsoft.net.object.binary.base64 is the format
- that the ResXResourceWriter will generate, however the reader can
- read any of the formats listed below.
-
- mimetype: application/x-microsoft.net.object.binary.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.soap.base64
- value : The object must be serialized with
- : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
- : and then encoded with base64 encoding.
-
- mimetype: application/x-microsoft.net.object.bytearray.base64
- value : The object must be serialized into a byte array
- : using a System.ComponentModel.TypeConverter
- : and then encoded with base64 encoding.
- -->
- <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
- <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
- <xsd:element name="root" msdata:IsDataSet="true">
- <xsd:complexType>
- <xsd:choice maxOccurs="unbounded">
- <xsd:element name="metadata">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" />
- </xsd:sequence>
- <xsd:attribute name="name" use="required" type="xsd:string" />
- <xsd:attribute name="type" type="xsd:string" />
- <xsd:attribute name="mimetype" type="xsd:string" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="assembly">
- <xsd:complexType>
- <xsd:attribute name="alias" type="xsd:string" />
- <xsd:attribute name="name" type="xsd:string" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
- <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
- <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
- <xsd:attribute ref="xml:space" />
- </xsd:complexType>
- </xsd:element>
- <xsd:element name="resheader">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
- </xsd:sequence>
- <xsd:attribute name="name" type="xsd:string" use="required" />
- </xsd:complexType>
- </xsd:element>
- </xsd:choice>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <resheader name="resmimetype">
- <value>text/microsoft-resx</value>
- </resheader>
- <resheader name="version">
- <value>2.0</value>
- </resheader>
- <resheader name="reader">
- <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <resheader name="writer">
- <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
- </resheader>
- <data name="Common_Content_TooBig" xml:space="preserve">
- <value>Body is too big. It can't be bigger than {0}.</value>
- </data>
- <data name="Common_Content_UnmatchedLength_Bigger" xml:space="preserve">
- <value>Actual body length is bigger than it in header.</value>
- </data>
- <data name="Common_Content_UnmatchedLength_Smaller" xml:space="preserve">
- <value>Actual body length is smaller than it in header.</value>
- </data>
- <data name="Common_Forbid" xml:space="preserve">
- <value>You have no permission to do the operation.</value>
- </data>
- <data name="Common_Forbid_NotSelf" xml:space="preserve">
- <value>You are not the resource owner.</value>
- </data>
- <data name="Common_Header_ContentLength_Missing" xml:space="preserve">
- <value>Header Content-Length is missing or of bad format.</value>
- </data>
- <data name="Common_Header_ContentLength_Zero" xml:space="preserve">
- <value>Header Content-Length must not be 0.</value>
- </data>
- <data name="Common_Header_ContentType_Missing" xml:space="preserve">
- <value>Header Content-Type is missing.</value>
- </data>
- <data name="Common_Header_IfNonMatch_BadFormat" xml:space="preserve">
- <value>Header If-Non-Match is of bad format.</value>
- </data>
- <data name="Common_InvalidModel" xml:space="preserve">
- <value>Model is of bad format.</value>
- </data>
- <data name="Common_UnknownEndpoint" xml:space="preserve">
- <value>The api endpoint you request is unknown. You might get the wrong api entry.</value>
- </data>
- <data name="TimelineController_ContentUnknownType" xml:space="preserve">
- <value>Unknown type of post content.</value>
- </data>
- <data name="TimelineController_ImageContentDataNotBase64" xml:space="preserve">
- <value>Data field is not a valid base64 string in image content.</value>
- </data>
- <data name="TimelineController_ImageContentDataNotImage" xml:space="preserve">
- <value>Data field is not a valid image after base64 decoding in image content.</value>
- </data>
- <data name="TimelineController_ImageContentDataRequired" xml:space="preserve">
- <value>Data field is required for image content.</value>
- </data>
- <data name="TimelineController_MemberPut_NotExist" xml:space="preserve">
- <value>The user to set as member does not exist.</value>
- </data>
- <data name="TimelineController_NameConflict" xml:space="preserve">
- <value>A timeline with given name already exists.</value>
- </data>
- <data name="TimelineController_NotExist" xml:space="preserve">
- <value>The timeline with given name does not exist.</value>
- </data>
- <data name="TimelineController_PostNoData" xml:space="preserve">
- <value>The post of that type has no data.</value>
- </data>
- <data name="TimelineController_PostNotExist" xml:space="preserve">
- <value>The post to operate on does not exist.</value>
- </data>
- <data name="TimelineController_QueryRelateNotExist" xml:space="preserve">
- <value>The user specified by query param "relate" does not exist.</value>
- </data>
- <data name="TimelineController_QueryVisibilityUnknown" xml:space="preserve">
- <value>'{0}' is an unkown visibility in the query parameter 'visibility'. </value>
- </data>
- <data name="TimelineController_TextContentTextRequired" xml:space="preserve">
- <value>Text field is required for text content.</value>
- </data>
- <data name="TokenController_Create_BadCredential" xml:space="preserve">
- <value>Username or password is invalid.</value>
- </data>
- <data name="TokenController_Verify_BadFormat" xml:space="preserve">
- <value>The token is of bad format. It might not be created by the server.</value>
- </data>
- <data name="TokenController_Verify_OldVersion" xml:space="preserve">
- <value>Token has an old version. User might have update some info.</value>
- </data>
- <data name="TokenController_Verify_TimeExpired" xml:space="preserve">
- <value>The token is expired.</value>
- </data>
- <data name="TokenController_Verify_UserNotExist" xml:space="preserve">
- <value>User does not exist. Administrator might have deleted this user.</value>
- </data>
- <data name="UserAvatar_BadFormat_BadSize" xml:space="preserve">
- <value>Image is not a square.</value>
- </data>
- <data name="UserAvatar_BadFormat_CantDecode" xml:space="preserve">
- <value>Image decode failed.</value>
- </data>
- <data name="UserAvatar_BadFormat_UnmatchedFormat" xml:space="preserve">
- <value>Image format does not match the one in header.</value>
- </data>
- <data name="UserCommon_NotExist" xml:space="preserve">
- <value>The user to operate on does not exist.</value>
- </data>
- <data name="UserController_ChangePassword_BadOldPassword" xml:space="preserve">
- <value>Old password is wrong.</value>
- </data>
- <data name="UserController_ChangePermission_RootUser" xml:space="preserve">
- <value>You can't change permission of root user.</value>
- </data>
- <data name="UserController_Delete_RootUser" xml:space="preserve">
- <value>You can't delete root user.</value>
- </data>
- <data name="UserController_Patch_Forbid_Administrator" xml:space="preserve">
- <value>You can't set permission unless you are administrator.</value>
- </data>
- <data name="UserController_Patch_Forbid_Password" xml:space="preserve">
- <value>You can't set password unless you are administrator. If you want to change password, use /userop/changepassword .</value>
- </data>
- <data name="UserController_Patch_Forbid_Username" xml:space="preserve">
- <value>You can't set username unless you are administrator.</value>
- </data>
- <data name="UserController_UsernameConflict" xml:space="preserve">
- <value>A user with given username already exists.</value>
- </data>
-</root>
\ No newline at end of file diff --git a/BackEnd/Timeline/Routes/Resource.Designer.cs b/BackEnd/Timeline/Routes/Resource.Designer.cs new file mode 100644 index 00000000..1fbbb704 --- /dev/null +++ b/BackEnd/Timeline/Routes/Resource.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------
+// <auto-generated>
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Timeline.Routes {
+ using System;
+
+
+ /// <summary>
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ /// </summary>
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resource {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resource() {
+ }
+
+ /// <summary>
+ /// Returns the cached ResourceManager instance used by this class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Timeline.Routes.Resource", typeof(Resource).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ /// <summary>
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ /// </summary>
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ /// <summary>
+ /// Looks up a localized string similar to The api endpoint you request is unknown. You might get the wrong api entry..
+ /// </summary>
+ internal static string MessageUnknownEndpoint {
+ get {
+ return ResourceManager.GetString("MessageUnknownEndpoint", resourceCulture);
+ }
+ }
+ }
+}
diff --git a/BackEnd/Timeline/Routes/Resource.resx b/BackEnd/Timeline/Routes/Resource.resx new file mode 100644 index 00000000..f7e2aec9 --- /dev/null +++ b/BackEnd/Timeline/Routes/Resource.resx @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <data name="MessageUnknownEndpoint" xml:space="preserve">
+ <value>The api endpoint you request is unknown. You might get the wrong api entry.</value>
+ </data>
+</root>
\ No newline at end of file diff --git a/BackEnd/Timeline/Routes/UnknownEndpointMiddleware.cs b/BackEnd/Timeline/Routes/UnknownEndpointMiddleware.cs index 25ec563c..d3f78fd9 100644 --- a/BackEnd/Timeline/Routes/UnknownEndpointMiddleware.cs +++ b/BackEnd/Timeline/Routes/UnknownEndpointMiddleware.cs @@ -24,7 +24,9 @@ namespace Timeline.Routes context.Response.StatusCode = StatusCodes.Status400BadRequest;
context.Response.ContentType = MediaTypeNames.Application.Json;
- var body = JsonSerializer.SerializeToUtf8Bytes(ErrorResponse.Common.UnknownEndpoint(), new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+ var body = JsonSerializer.SerializeToUtf8Bytes(
+ new CommonResponse(ErrorCodes.Common.UnknownEndpoint, Resource.MessageUnknownEndpoint),
+ new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
context.Response.ContentLength = body.Length;
await context.Response.Body.WriteAsync(body);
diff --git a/BackEnd/Timeline/Timeline.csproj b/BackEnd/Timeline/Timeline.csproj index fb111cef..96f65301 100644 --- a/BackEnd/Timeline/Timeline.csproj +++ b/BackEnd/Timeline/Timeline.csproj @@ -68,11 +68,6 @@ <AutoGen>True</AutoGen>
<DependentUpon>DataCacheHelper.resx</DependentUpon>
</Compile>
- <Compile Update="Resources\Messages.Designer.cs">
- <DesignTime>True</DesignTime>
- <AutoGen>True</AutoGen>
- <DependentUpon>Messages.resx</DependentUpon>
- </Compile>
<Compile Update="Models\Http\Resource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@@ -93,6 +88,11 @@ <AutoGen>True</AutoGen>
<DependentUpon>Validator.resx</DependentUpon>
</Compile>
+ <Compile Update="Routes\Resource.Designer.cs">
+ <DesignTime>True</DesignTime>
+ <AutoGen>True</AutoGen>
+ <DependentUpon>Resource.resx</DependentUpon>
+ </Compile>
<Compile Update="Services\DatabaseManagement\Resource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
@@ -157,10 +157,6 @@ <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>DataCacheHelper.Designer.cs</LastGenOutput>
</EmbeddedResource>
- <EmbeddedResource Update="Resources\Messages.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <LastGenOutput>Messages.Designer.cs</LastGenOutput>
- </EmbeddedResource>
<EmbeddedResource Update="Models\Http\Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
@@ -177,6 +173,10 @@ <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Validator.Designer.cs</LastGenOutput>
</EmbeddedResource>
+ <EmbeddedResource Update="Routes\Resource.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <LastGenOutput>Resource.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
<EmbeddedResource Update="Services\DatabaseManagement\Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
|