pre cutover push
This commit is contained in:
		| @ -42,9 +42,10 @@ $insert APP_INSERTS | ||||
| $insert API_SETUP | ||||
| $insert HTTP_INSERTS | ||||
| $insert REACTOR_LOG_EQUATES | ||||
| $insert OI_WIZARD_EQUATES | ||||
|  | ||||
| Declare function   Reactor_Log_Services, OI_Wizard_Services | ||||
| Declare subroutine Database_Services, Reactor_Log_Services | ||||
| Declare function   Reactor_Log_Services, OI_Wizard_Services, MemberOf | ||||
| Declare subroutine Database_Services, Reactor_Log_Services, Override_Log_Services | ||||
|  | ||||
| GoToAPI else | ||||
|     // The specific resource endpoint doesn't have a API handler yet. | ||||
| @ -92,6 +93,7 @@ API ReactorLogs.ID.PUT | ||||
|         If Body NE '' then | ||||
|             // The POST string will have been encoded so use percent (URL) decoding. | ||||
|             ReactorLogJSON = HTTP_Services('DecodePercentString', Body) | ||||
|             hReactorLog    = '' | ||||
|             ParseResponse  = SRP_JSON(hReactorLog, 'PARSE', ReactorLogJSON) | ||||
|             If (ParseResponse EQ '') then | ||||
|                 NewReactorLogRec = Reactor_Log_Services('ConvertJSONToRecord', ReactorLogJSON) | ||||
| @ -111,7 +113,14 @@ API ReactorLogs.ID.PUT | ||||
|                                 GoSub CreateHALItem | ||||
|                             end else | ||||
|                                 ErrorMsg = Error_Services('GetMessage') | ||||
|                                 HTTP_Services('SetResponseStatus', 500, 'Error in the ' : CurrentAPI : ' API. Message: ': ErrorMsg) | ||||
|                                 If IndexC(ErrorMsg, 'NICA order(s)', 1) then | ||||
|                                 	// NICA override required, so return specific status code and override information. | ||||
|                                 	HTTP_Services('SetResponseStatus', 300, ErrorMsg) | ||||
|                                 	ResBody = '{"username":"","password":"","groups":["SUPERVISOR","MAINTENANCE"]}' | ||||
|                                 	HTTP_Services('SetResponseBody', ResBody, False$, 'application/hal+json') | ||||
|                                 end else | ||||
|                                 	HTTP_Services('SetResponseStatus', 500, 'Error in the ' : CurrentAPI : ' API. Message: ': ErrorMsg) | ||||
|                                 end | ||||
|                                 Reactor_Log_Services('ClearSignature', RLKey) | ||||
|                             end | ||||
|                         end else | ||||
| @ -140,6 +149,81 @@ API ReactorLogs.ID.PUT | ||||
| end api | ||||
|  | ||||
|  | ||||
| API ReactorLogs.ID.nicaOverride.POST | ||||
| 	 | ||||
| 	OIWizardID = '' | ||||
|     Cookies    = HTTP_Services('GetHTTPCookie') | ||||
|     For each Cookie in Cookies using ';' | ||||
|         Key = Trim(Field(Cookie, '=', 1)) | ||||
|         If Key EQ 'sessionID' then | ||||
|             OIWizardID = Field(Cookie, '=', 2) | ||||
|         end | ||||
|         If Key EQ 'userID' then | ||||
|             CurrUser = Field(Cookie, '=', 2) | ||||
|         end | ||||
|     Next Cookie | ||||
|      | ||||
|     ValidSession = OI_Wizard_Services('ValidateSession', OIWizardID) | ||||
|  | ||||
|     If ValidSession then | ||||
|     	OverrideUser   = Xlate('OI_WIZARD', OIWizardID, OI_WIZARD.EMPLOYEE_ID$, 'X') | ||||
|     	OverrideGroups = 'SUPERVISOR,MAINTENANCE' | ||||
|     	If RowExists('LSL_USERS', OverrideUser) then | ||||
|     		If ( MemberOf(OverrideUser, 'SUPERVISOR') or MemberOf(OverrideUser, 'MAINTENANCE') ) then | ||||
|     			RLKey = ParentSegment | ||||
| 				If RowExists('REACTOR_LOG', RLKey) then | ||||
| 					// Parse out override comment from body | ||||
| 					Body = HTTP_Services('GetHTTPPostString') | ||||
| 					If Body NE '' then | ||||
| 						// The POST string will have been encoded so use percent (URL) decoding. | ||||
| 						ReactorLogJSON = HTTP_Services('DecodePercentString', Body) | ||||
| 						hReactorLog    = '' | ||||
| 						ParseResponse  = SRP_JSON(hReactorLog, 'PARSE', ReactorLogJSON) | ||||
| 						If (ParseResponse EQ '') then | ||||
| 							OverrideComment = SRP_JSON(hReactorLog, 'GetValue', 'overrideComment') | ||||
| 							SRP_JSON(hReactorLog, 'Release') | ||||
| 							If OverrideComment NE '' then | ||||
| 								Override_Log_Services('Create', 'REACTOR_LOG', RLKey, OverrideUser, OverrideComment, 'REACTOR_LOG_PM', '') | ||||
| 								If Error_Services('NoError') then  | ||||
| 									// Cancel all ReactorLog PMs | ||||
| 									ActivePMKeys = Xlate('REACTOR_LOG', RLKey, REACTOR_LOG_CHECKLIST_ORDER_ID$, 'X') | ||||
| 									If ActivePMKeys NE '' then | ||||
| 										For each ActivePMKey in ActivePMKeys using @VM setting vPos | ||||
| 											Reactor_Log_Services('CancelReactorLogPMOrder', RLKey, ActivePMKey) | ||||
| 										Until Error_Services('HasError') | ||||
| 										Next ActivePMKey | ||||
| 									end | ||||
| 									If Error_Services('NoError') then | ||||
| 										HTTP_Services('SetResponseStatus', 200, 'Nica orders canceled for REACTOR_LOG "':RLKey:'".') | ||||
| 									end | ||||
| 								end else | ||||
| 									Http_Services('SetResponseStatus', 500, Error_Services('GetMessage')) | ||||
| 								end | ||||
| 							end else | ||||
| 								HTTP_Services('SetResponseStatus', 400, 'No override comment passed in!') | ||||
| 							end | ||||
| 						end else | ||||
| 							HTTP_Services('SetResponseStatus', 400, 'Unable to parse the JSON data from the request.') | ||||
| 						end | ||||
| 					end else | ||||
| 						HTTP_Services('SetResponseStatus', 400, 'JSON object is missing in the body of the request.') | ||||
| 					end | ||||
| 				end else | ||||
| 					HTTP_Services('SetResponseStatus', 500, 'REACTOR_LOG "':RLKey:'" does not exist!') | ||||
| 				end | ||||
|     		end else | ||||
|     			HTTP_Services('SetResponseStatus', 500, 'User is not a member of SUPERVISOR or MAINTENANCE groups.') | ||||
|     		end | ||||
|     	end else | ||||
|     		HTTP_Services('SetResponseStatus', 500, 'User "':OverrideUser:'" does not exist!.') | ||||
|     	end | ||||
|  | ||||
|     end else | ||||
|         HTTP_Services('SetResponseStatus', 500, 'Invalid session. Reauthentication required.') | ||||
|     end | ||||
| 	 | ||||
| end api | ||||
|  | ||||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| // Internal GoSubs | ||||
| //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||||
| @ -170,3 +254,10 @@ CreateHALItem: | ||||
|  | ||||
| return | ||||
|  | ||||
|  | ||||
| API reactorlogs.ID.nicaoverride.PUT | ||||
|  | ||||
|     HTTP_Resource_Services('LoremIpsum') | ||||
|  | ||||
| end api | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user