From c2690d77ab1611fa58d4e6ce2e223a39573373b9 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Fri, 28 Jun 2024 15:53:10 -0400 Subject: [PATCH] Updated to support API changes in Unreal 5.4 --- Source/Unrealzilla/Private/ServerAPI.cpp | 18 ++-- .../Unrealzilla/Private/ServerBugzillaAPI.cpp | 12 +-- Source/Unrealzilla/Private/ServerJiraAPI.cpp | 100 +++++++++--------- Source/Unrealzilla/Public/ServerAPI.h | 2 +- 4 files changed, 69 insertions(+), 63 deletions(-) diff --git a/Source/Unrealzilla/Private/ServerAPI.cpp b/Source/Unrealzilla/Private/ServerAPI.cpp index 1345139..12750e5 100644 --- a/Source/Unrealzilla/Private/ServerAPI.cpp +++ b/Source/Unrealzilla/Private/ServerAPI.cpp @@ -26,15 +26,21 @@ void UServerAPI::SendFormData(const FUnrealzillaPostData &PostData) } -void UServerAPI::ServerConnectionError(const EHttpRequestStatus::Type Status) +void UServerAPI::ServerConnectionError(const EHttpRequestStatus::Type Status, const EHttpFailureReason Reason) { switch (Status) { - case EHttpRequestStatus::Failed_ConnectionError: - this->CreateError("There was an error connecting to the server. Please retry.", true); - break; case EHttpRequestStatus::Failed: - this->CreateError("Connection to the server completed but then failed.", true); - break; + switch (Reason) { + case EHttpFailureReason::ConnectionError: + this->CreateError("There was an error connecting to the server. Please retry.", true); + break; + case EHttpFailureReason::Cancelled: + this->CreateError("Connection to the server was cancelled.", true); + break; + default: + this->CreateError("Connection to the server completed but then failed.", true); + break; + } case EHttpRequestStatus::NotStarted: this->CreateError("Connection was not started."); break; diff --git a/Source/Unrealzilla/Private/ServerBugzillaAPI.cpp b/Source/Unrealzilla/Private/ServerBugzillaAPI.cpp index c12bdf4..85d9f8f 100644 --- a/Source/Unrealzilla/Private/ServerBugzillaAPI.cpp +++ b/Source/Unrealzilla/Private/ServerBugzillaAPI.cpp @@ -252,7 +252,7 @@ void UServerBugzillaAPI::ServerPOSTResponse(FHttpRequestPtr Request, FHttpRespon } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -293,7 +293,7 @@ void UServerBugzillaAPI::ServerPOSTUpdateMarkerResponse(FHttpRequestPtr Request, } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -340,7 +340,7 @@ void UServerBugzillaAPI::ServerProductInfoResponse(FHttpRequestPtr Request, FHtt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -372,7 +372,7 @@ void UServerBugzillaAPI::ServerSeverityInfoResponse(FHttpRequestPtr Request, FHt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -404,7 +404,7 @@ void UServerBugzillaAPI::ServerPlatformInfoResponse(FHttpRequestPtr Request, FHt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -436,7 +436,7 @@ void UServerBugzillaAPI::ServerOSInfoResponse(FHttpRequestPtr Request, FHttpResp } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } diff --git a/Source/Unrealzilla/Private/ServerJiraAPI.cpp b/Source/Unrealzilla/Private/ServerJiraAPI.cpp index 692743e..81fbd04 100644 --- a/Source/Unrealzilla/Private/ServerJiraAPI.cpp +++ b/Source/Unrealzilla/Private/ServerJiraAPI.cpp @@ -47,17 +47,17 @@ void UServerJiraAPI::ListOfBoardsResponse(FHttpRequestPtr Request, FHttpResponse const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - const TArray> &BoardsArray = JSON->GetArrayField("values"); + const TArray>& BoardsArray = JSON->GetArrayField(TEXT("values")); for (const TSharedPtr &BoardValue : BoardsArray) { const TSharedPtr &Board = BoardValue->AsObject(); - const TSharedPtr &Location = Board->GetObjectField("location"); - if (Location->GetStringField("projectName") == GetDefault()->JiraProjectName) + const TSharedPtr& Location = Board->GetObjectField(TEXT("location")); + if (Location->GetStringField(TEXT("projectName")) == GetDefault()->JiraProjectName) { - this->BoardID = Board->GetIntegerField("id"); - this->ProjectID = Location->GetIntegerField("projectId"); - this->ProjectKey = Location->GetStringField("projectKey"); - this->ProjectAvatarURI = Location->GetStringField("avatarURI"); + this->BoardID = Board->GetIntegerField(TEXT("id")); + this->ProjectID = Location->GetIntegerField(TEXT("projectId")); + this->ProjectKey = Location->GetStringField(TEXT("projectKey")); + this->ProjectAvatarURI = Location->GetStringField(TEXT("avatarURI")); } } } @@ -81,12 +81,12 @@ void UServerJiraAPI::ListOfFieldsResponse(FHttpRequestPtr Request, FHttpResponse const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - const TArray> &FieldArray = JSON->GetArrayField("fields"); + const TArray>& FieldArray = JSON->GetArrayField(TEXT("fields")); for (const TSharedPtr &FieldValue : FieldArray) { const TSharedPtr &Field = FieldValue->AsObject(); - const FString &Name = Field->GetStringField("name"); - const FString &Key = Field->GetStringField("key"); + const FString& Name = Field->GetStringField(TEXT("name")); + const FString &Key = Field->GetStringField(TEXT("key")); if (Name == GetDefault()->JiraMapNameField) { this->MapNameCustomField = Key; @@ -154,25 +154,25 @@ void UServerJiraAPI::ListOfBugsResponse(FHttpRequestPtr Request, FHttpResponsePt const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - const TArray> &IssuesArray = JSON->GetArrayField("issues"); + const TArray> &IssuesArray = JSON->GetArrayField(TEXT("issues")); for (const TSharedPtr &IssueValue : IssuesArray) { const TSharedPtr &Issue = IssueValue->AsObject(); - const TSharedPtr &Fields = Issue->GetObjectField("fields"); - const TSharedPtr &Status = Fields->GetObjectField("status"); - const FString StatusName = Status->GetStringField("name"); + const TSharedPtr& Fields = Issue->GetObjectField(TEXT("fields")); + const TSharedPtr& Status = Fields->GetObjectField(TEXT("status")); + const FString StatusName = Status->GetStringField(TEXT("name")); if ((GetDefault()->bShowUnresolvedBugs && GetDefault()->UnresolvedStatuses.Contains(StatusName)) || (GetDefault()->bShowInProgressBugs && GetDefault()->InProgressStatuses.Contains(StatusName)) || (GetDefault()->bShowResolvedBugs && GetDefault()->ResolvedStatuses.Contains(StatusName))) { - const TSharedPtr &Priority = Fields->GetObjectField("priority"); + const TSharedPtr& Priority = Fields->GetObjectField(TEXT("priority")); FUnrealzillaBugData Bug; - Bug.ID = Issue->GetNumberField("id"); + Bug.ID = Issue->GetNumberField(TEXT("id")); Bug.Status = StatusName; - Bug.Summary = Fields->GetStringField("summary"); - Bug.Severity = Priority->GetStringField("name"); + Bug.Summary = Fields->GetStringField(TEXT("summary")); + Bug.Severity = Priority->GetStringField(TEXT("name")); //Bug.Component = BugzillaData.component; //Bug.Platform = BugzillaData.platform; //Bug.OperatingSystem = BugzillaData.op_sys; @@ -201,7 +201,7 @@ void UServerJiraAPI::ListOfBugsResponse(FHttpRequestPtr Request, FHttpResponsePt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -247,52 +247,52 @@ void UServerJiraAPI::ServerFieldOptionsResponse(FHttpRequestPtr Request, FHttpRe const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - const TArray> &ProjectsArray = JSON->GetArrayField("projects"); + const TArray>& ProjectsArray = JSON->GetArrayField(TEXT("projects")); for (const TSharedPtr &ProjectValue : ProjectsArray) { const TSharedPtr &Project = ProjectValue->AsObject(); - if (Project->GetStringField("name") == GetDefault()->JiraProjectName) + if (Project->GetStringField(TEXT("name")) == GetDefault()->JiraProjectName) { - const TArray> &IssueTypes = Project->GetArrayField("issuetypes"); + const TArray> &IssueTypes = Project->GetArrayField(TEXT("issuetypes")); for (const TSharedPtr &IssueTypeValue : IssueTypes) { const TSharedPtr &IssueType = IssueTypeValue->AsObject(); - const TSharedPtr &Fields = IssueType->GetObjectField("fields"); + const TSharedPtr& Fields = IssueType->GetObjectField(TEXT("fields")); // After all that boilerplate code, finally get all available field options here { // Components const TSharedPtr &Department = Fields->GetObjectField(this->DepartmentCustomField); - const TArray> &AllowedDepartmentsArray = Department->GetArrayField("allowedValues"); + const TArray>& AllowedDepartmentsArray = Department->GetArrayField(TEXT("allowedValues")); for (const TSharedPtr &AllowedDepartmentsValue : AllowedDepartmentsArray) { const TSharedPtr &Value = AllowedDepartmentsValue->AsObject(); - this->ComponentsList.Add(Value->GetStringField("value")); + this->ComponentsList.Add(Value->GetStringField(TEXT("value"))); } // Bug severity const TSharedPtr &Severity = Fields->GetObjectField(this->SeverityCustomField); - const TArray> &AllowedSeveritiesArray = Severity->GetArrayField("allowedValues"); + const TArray>& AllowedSeveritiesArray = Severity->GetArrayField(TEXT("allowedValues")); for (const TSharedPtr &AllowedSeveritiesValue : AllowedSeveritiesArray) { const TSharedPtr &Value = AllowedSeveritiesValue->AsObject(); - this->SeverityList.Add(Value->GetStringField("value")); + this->SeverityList.Add(Value->GetStringField(TEXT("value"))); } // Platform const TSharedPtr &Platform = Fields->GetObjectField(this->PlatformCustomField); - const TArray> &PlatformsArray = Platform->GetArrayField("allowedValues"); + const TArray>& PlatformsArray = Platform->GetArrayField(TEXT("allowedValues")); for (const TSharedPtr &PlatformsValue : PlatformsArray) { const TSharedPtr &Value = PlatformsValue->AsObject(); - this->PlatformsList.Add(Value->GetStringField("value")); + this->PlatformsList.Add(Value->GetStringField(TEXT("value"))); // Also get children and add them to the OS list here - const TArray> &ChildrenArray = Value->GetArrayField("children"); + const TArray>& ChildrenArray = Value->GetArrayField(TEXT("children")); for (const TSharedPtr &ChildValue : ChildrenArray) { const TSharedPtr &Child = ChildValue->AsObject(); - this->OSList.AddUnique(Child->GetStringField("value")); + this->OSList.AddUnique(Child->GetStringField(TEXT("value"))); } } } @@ -311,7 +311,7 @@ void UServerJiraAPI::ServerFieldOptionsResponse(FHttpRequestPtr Request, FHttpRe } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } void UServerJiraAPI::ServerVersionsResponse(FHttpRequestPtr Request, FHttpResponsePtr Response, bool Success) @@ -324,11 +324,11 @@ void UServerJiraAPI::ServerVersionsResponse(FHttpRequestPtr Request, FHttpRespon const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - const TArray> &ValuesArray = JSON->GetArrayField("values"); + const TArray> &ValuesArray = JSON->GetArrayField(TEXT("values")); for (const TSharedPtr &ValueObject : ValuesArray) { const TSharedPtr &Value = ValueObject->AsObject(); - this->VersionsList.Add(Value->GetStringField("name")); + this->VersionsList.Add(Value->GetStringField(TEXT("name"))); } this->CheckIfAllFormResponsesAreIn(); @@ -340,7 +340,7 @@ void UServerJiraAPI::ServerVersionsResponse(FHttpRequestPtr Request, FHttpRespon } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } void UServerJiraAPI::CheckIfAllFormResponsesAreIn() @@ -513,13 +513,13 @@ void UServerJiraAPI::ServerPOSTResponse(FHttpRequestPtr Request, FHttpResponsePt if (FJsonSerializer::Deserialize(Reader, JSON)) { // I'm not sure what is meant to show up in the "errorMessages" array, but this is where we handle that. - const TArray> &ErrorMessageArray = JSON->GetArrayField("errorMessages"); + const TArray>& ErrorMessageArray = JSON->GetArrayField(TEXT("errorMessages")); if (!ErrorMessageArray.IsEmpty()) { // Handle error messages here } - const TSharedPtr &Errors = JSON->GetObjectField("errors"); + const TSharedPtr &Errors = JSON->GetObjectField(TEXT("errors")); TArray ErrorStringBuilder; TArray ErrorKeys; Errors->Values.GenerateKeyArray(ErrorKeys); @@ -539,7 +539,7 @@ void UServerJiraAPI::ServerPOSTResponse(FHttpRequestPtr Request, FHttpResponsePt //const int32 &NewBugID = FCString::Atoi(*JSON->GetStringField("id")); //const FString &NewBugKey = JSON->GetStringField("key"); - const FString &NewBugURI = JSON->GetStringField("self"); + const FString& NewBugURI = JSON->GetStringField(TEXT("self")); FHttpModule &HttpModule = FHttpModule::Get(); TSharedRef NewBugRequest = HttpModule.CreateRequest(); @@ -557,7 +557,7 @@ void UServerJiraAPI::ServerPOSTResponse(FHttpRequestPtr Request, FHttpResponsePt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } @@ -571,23 +571,23 @@ void UServerJiraAPI::ServerPOSTUpdateMarkerResponse(FHttpRequestPtr Request, FHt const TSharedRef> &Reader = TJsonReaderFactory<>::Create(JSONResponse); if (FJsonSerializer::Deserialize(Reader, JSON)) { - if (JSON->HasTypedField("fields")) + if (JSON->HasTypedField(TEXT("fields"))) { - const TSharedPtr &Fields = JSON->GetObjectField("fields"); + const TSharedPtr &Fields = JSON->GetObjectField(TEXT("fields")); const TSharedPtr &PlatformFields = Fields->GetObjectField(this->PlatformCustomField); TArray BugData; FUnrealzillaBugData Bug; - Bug.ID = JSON->GetIntegerField("id"); - Bug.Summary = Fields->GetStringField("summary"); - Bug.Component = Fields->GetObjectField(this->DepartmentCustomField)->GetStringField("value"); + Bug.ID = JSON->GetIntegerField(TEXT("id")); + Bug.Summary = Fields->GetStringField(TEXT("summary")); + Bug.Component = Fields->GetObjectField(this->DepartmentCustomField)->GetStringField(TEXT("value")); Bug.MapName = Fields->GetStringField(this->MapNameCustomField); Bug.MarkerLocation = Fields->GetStringField(this->MarkerLocationCustomField); - Bug.Platform = PlatformFields->GetStringField("value"); - Bug.OperatingSystem = PlatformFields->GetObjectField("child")->GetStringField("value"); - Bug.Severity = Fields->GetObjectField(this->SeverityCustomField)->GetStringField("value"); - Bug.Status = Fields->GetObjectField("status")->GetStringField("name"); - Bug.Resolution = Fields->GetStringField("resolution"); + Bug.Platform = PlatformFields->GetStringField(TEXT("value")); + Bug.OperatingSystem = PlatformFields->GetObjectField(TEXT("child"))->GetStringField(TEXT("value")); + Bug.Severity = Fields->GetObjectField(this->SeverityCustomField)->GetStringField(TEXT("value")); + Bug.Status = Fields->GetObjectField(TEXT("status"))->GetStringField(TEXT("name")); + Bug.Resolution = Fields->GetStringField(TEXT("resolution")); BugData.Add(Bug); this->BugDataResponse.Execute(BugData); } @@ -599,7 +599,7 @@ void UServerJiraAPI::ServerPOSTUpdateMarkerResponse(FHttpRequestPtr Request, FHt } else { - this->ServerConnectionError(Request->GetStatus()); + this->ServerConnectionError(Request->GetStatus(), Request->GetFailureReason()); } } diff --git a/Source/Unrealzilla/Public/ServerAPI.h b/Source/Unrealzilla/Public/ServerAPI.h index acb10c5..c20fe82 100644 --- a/Source/Unrealzilla/Public/ServerAPI.h +++ b/Source/Unrealzilla/Public/ServerAPI.h @@ -42,7 +42,7 @@ public: FServerErrorResponseDelegate ErrorResponse; protected: - void ServerConnectionError(const EHttpRequestStatus::Type Status); + void ServerConnectionError(const EHttpRequestStatus::Type Status, const EHttpFailureReason Reason); void CreateError(const EErrorVerb &Verb, const FBugzillaJSONPostResponse &Data); void CreateError(const EErrorVerb &Verb, const FBugzillaJSONProductResponse &Data);