Updated to support API changes in Unreal 5.4

This commit is contained in:
Jamie Greunbaum 2024-06-28 15:53:10 -04:00
parent 80afa2a4b4
commit c2690d77ab
4 changed files with 69 additions and 63 deletions

View File

@ -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;

View File

@ -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());
}
}

View File

@ -47,17 +47,17 @@ void UServerJiraAPI::ListOfBoardsResponse(FHttpRequestPtr Request, FHttpResponse
const TSharedRef<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
const TArray<TSharedPtr<FJsonValue>> &BoardsArray = JSON->GetArrayField("values");
const TArray<TSharedPtr<FJsonValue>>& BoardsArray = JSON->GetArrayField(TEXT("values"));
for (const TSharedPtr<FJsonValue> &BoardValue : BoardsArray)
{
const TSharedPtr<FJsonObject> &Board = BoardValue->AsObject();
const TSharedPtr<FJsonObject> &Location = Board->GetObjectField("location");
if (Location->GetStringField("projectName") == GetDefault<UUnrealzillaGlobalSettings>()->JiraProjectName)
const TSharedPtr<FJsonObject>& Location = Board->GetObjectField(TEXT("location"));
if (Location->GetStringField(TEXT("projectName")) == GetDefault<UUnrealzillaGlobalSettings>()->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<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
const TArray<TSharedPtr<FJsonValue>> &FieldArray = JSON->GetArrayField("fields");
const TArray<TSharedPtr<FJsonValue>>& FieldArray = JSON->GetArrayField(TEXT("fields"));
for (const TSharedPtr<FJsonValue> &FieldValue : FieldArray)
{
const TSharedPtr<FJsonObject> &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<UUnrealzillaGlobalSettings>()->JiraMapNameField)
{
this->MapNameCustomField = Key;
@ -154,25 +154,25 @@ void UServerJiraAPI::ListOfBugsResponse(FHttpRequestPtr Request, FHttpResponsePt
const TSharedRef<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
const TArray<TSharedPtr<FJsonValue>> &IssuesArray = JSON->GetArrayField("issues");
const TArray<TSharedPtr<FJsonValue>> &IssuesArray = JSON->GetArrayField(TEXT("issues"));
for (const TSharedPtr<FJsonValue> &IssueValue : IssuesArray)
{
const TSharedPtr<FJsonObject> &Issue = IssueValue->AsObject();
const TSharedPtr<FJsonObject> &Fields = Issue->GetObjectField("fields");
const TSharedPtr<FJsonObject> &Status = Fields->GetObjectField("status");
const FString StatusName = Status->GetStringField("name");
const TSharedPtr<FJsonObject>& Fields = Issue->GetObjectField(TEXT("fields"));
const TSharedPtr<FJsonObject>& Status = Fields->GetObjectField(TEXT("status"));
const FString StatusName = Status->GetStringField(TEXT("name"));
if ((GetDefault<UUnrealzillaGlobalSettings>()->bShowUnresolvedBugs && GetDefault<UUnrealzillaGlobalSettings>()->UnresolvedStatuses.Contains(StatusName)) ||
(GetDefault<UUnrealzillaGlobalSettings>()->bShowInProgressBugs && GetDefault<UUnrealzillaGlobalSettings>()->InProgressStatuses.Contains(StatusName)) ||
(GetDefault<UUnrealzillaGlobalSettings>()->bShowResolvedBugs && GetDefault<UUnrealzillaGlobalSettings>()->ResolvedStatuses.Contains(StatusName)))
{
const TSharedPtr<FJsonObject> &Priority = Fields->GetObjectField("priority");
const TSharedPtr<FJsonObject>& 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<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
const TArray<TSharedPtr<FJsonValue>> &ProjectsArray = JSON->GetArrayField("projects");
const TArray<TSharedPtr<FJsonValue>>& ProjectsArray = JSON->GetArrayField(TEXT("projects"));
for (const TSharedPtr<FJsonValue> &ProjectValue : ProjectsArray)
{
const TSharedPtr<FJsonObject> &Project = ProjectValue->AsObject();
if (Project->GetStringField("name") == GetDefault<UUnrealzillaGlobalSettings>()->JiraProjectName)
if (Project->GetStringField(TEXT("name")) == GetDefault<UUnrealzillaGlobalSettings>()->JiraProjectName)
{
const TArray<TSharedPtr<FJsonValue>> &IssueTypes = Project->GetArrayField("issuetypes");
const TArray<TSharedPtr<FJsonValue>> &IssueTypes = Project->GetArrayField(TEXT("issuetypes"));
for (const TSharedPtr<FJsonValue> &IssueTypeValue : IssueTypes)
{
const TSharedPtr<FJsonObject> &IssueType = IssueTypeValue->AsObject();
const TSharedPtr<FJsonObject> &Fields = IssueType->GetObjectField("fields");
const TSharedPtr<FJsonObject>& Fields = IssueType->GetObjectField(TEXT("fields"));
// After all that boilerplate code, finally get all available field options here
{
// Components
const TSharedPtr<FJsonObject> &Department = Fields->GetObjectField(this->DepartmentCustomField);
const TArray<TSharedPtr<FJsonValue>> &AllowedDepartmentsArray = Department->GetArrayField("allowedValues");
const TArray<TSharedPtr<FJsonValue>>& AllowedDepartmentsArray = Department->GetArrayField(TEXT("allowedValues"));
for (const TSharedPtr<FJsonValue> &AllowedDepartmentsValue : AllowedDepartmentsArray)
{
const TSharedPtr<FJsonObject> &Value = AllowedDepartmentsValue->AsObject();
this->ComponentsList.Add(Value->GetStringField("value"));
this->ComponentsList.Add(Value->GetStringField(TEXT("value")));
}
// Bug severity
const TSharedPtr<FJsonObject> &Severity = Fields->GetObjectField(this->SeverityCustomField);
const TArray<TSharedPtr<FJsonValue>> &AllowedSeveritiesArray = Severity->GetArrayField("allowedValues");
const TArray<TSharedPtr<FJsonValue>>& AllowedSeveritiesArray = Severity->GetArrayField(TEXT("allowedValues"));
for (const TSharedPtr<FJsonValue> &AllowedSeveritiesValue : AllowedSeveritiesArray)
{
const TSharedPtr<FJsonObject> &Value = AllowedSeveritiesValue->AsObject();
this->SeverityList.Add(Value->GetStringField("value"));
this->SeverityList.Add(Value->GetStringField(TEXT("value")));
}
// Platform
const TSharedPtr<FJsonObject> &Platform = Fields->GetObjectField(this->PlatformCustomField);
const TArray<TSharedPtr<FJsonValue>> &PlatformsArray = Platform->GetArrayField("allowedValues");
const TArray<TSharedPtr<FJsonValue>>& PlatformsArray = Platform->GetArrayField(TEXT("allowedValues"));
for (const TSharedPtr<FJsonValue> &PlatformsValue : PlatformsArray)
{
const TSharedPtr<FJsonObject> &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<TSharedPtr<FJsonValue>> &ChildrenArray = Value->GetArrayField("children");
const TArray<TSharedPtr<FJsonValue>>& ChildrenArray = Value->GetArrayField(TEXT("children"));
for (const TSharedPtr<FJsonValue> &ChildValue : ChildrenArray)
{
const TSharedPtr<FJsonObject> &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<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
const TArray<TSharedPtr<FJsonValue>> &ValuesArray = JSON->GetArrayField("values");
const TArray<TSharedPtr<FJsonValue>> &ValuesArray = JSON->GetArrayField(TEXT("values"));
for (const TSharedPtr<FJsonValue> &ValueObject : ValuesArray)
{
const TSharedPtr<FJsonObject> &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<TSharedPtr<FJsonValue>> &ErrorMessageArray = JSON->GetArrayField("errorMessages");
const TArray<TSharedPtr<FJsonValue>>& ErrorMessageArray = JSON->GetArrayField(TEXT("errorMessages"));
if (!ErrorMessageArray.IsEmpty())
{
// Handle error messages here
}
const TSharedPtr<FJsonObject> &Errors = JSON->GetObjectField("errors");
const TSharedPtr<FJsonObject> &Errors = JSON->GetObjectField(TEXT("errors"));
TArray<FString> ErrorStringBuilder;
TArray<FString> 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<IHttpRequest, ESPMode::ThreadSafe> 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<TJsonReader<>> &Reader = TJsonReaderFactory<>::Create(JSONResponse);
if (FJsonSerializer::Deserialize(Reader, JSON))
{
if (JSON->HasTypedField<EJson::Object>("fields"))
if (JSON->HasTypedField<EJson::Object>(TEXT("fields")))
{
const TSharedPtr<FJsonObject> &Fields = JSON->GetObjectField("fields");
const TSharedPtr<FJsonObject> &Fields = JSON->GetObjectField(TEXT("fields"));
const TSharedPtr<FJsonObject> &PlatformFields = Fields->GetObjectField(this->PlatformCustomField);
TArray<FUnrealzillaBugData> 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());
}
}

View File

@ -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);