func (agentMessage *AgentMessage) ParseAgentMessage(context context.T,
	messagesOrchestrationRootDir string,
	instanceId string,
	clientId string) (*contracts.DocumentState, error) {

	log := context.Log()

	// parse message to retrieve parameters
	parsedMessagePayload, err := deserializeAgentTaskPayload(log, *agentMessage)
	if err != nil {
		errorMsg := "Encountered error while parsing input - internal error"
		return nil, fmt.Errorf("%v", errorMsg)
	}

	log.Debugf("Receiving session id %s, clientId: %s", parsedMessagePayload.SessionId, clientId)
	log.Tracef("Processing start-session message %s", agentMessage.Payload)

	// adapt plugin configuration format from MGS to plugin expected format
	documentInfo := buildDocumentInfo(*agentMessage, parsedMessagePayload.SessionId, parsedMessagePayload, instanceId)
	messageOrchestrationDirectory := filepath.Join(messagesOrchestrationRootDir, parsedMessagePayload.SessionId)

	parserInfo := docparser.DocumentParserInfo{
		OrchestrationDir: messageOrchestrationDirectory,
		MessageId:        documentInfo.MessageID,
		DocumentId:       documentInfo.DocumentID,
	}
	docContent := &docparser.SessionDocContent{
		SchemaVersion: parsedMessagePayload.DocumentContent.SchemaVersion,
		Description:   parsedMessagePayload.DocumentContent.Description,
		SessionType:   parsedMessagePayload.DocumentContent.SessionType,
		Inputs:        parsedMessagePayload.DocumentContent.Inputs,
		Parameters:    parsedMessagePayload.DocumentContent.Parameters,
		Properties:    parsedMessagePayload.DocumentContent.Properties,
	}

	docState, err := docparser.InitializeDocState(
		log,
		contracts.StartSession,
		docContent,
		documentInfo,
		parserInfo,
		parsedMessagePayload.Parameters)
	if err != nil {
		return nil, fmt.Errorf("error initialing document state: %s", err)
	}

	log.Debugf("Docstate document ID after Initializing: %s", docState.DocumentInformation.DocumentID)
	return &docState, nil
}
// ParseAgentMessage parses session message to documentState object for processor.
ParseAgentMessage parses session message to documentState object for processor.
// ParseAgentMessage parses session message to documentState object for processor .
func (agentMessage *AgentMessage) ParseAgentMessage(context context.T,
	messagesOrchestrationRootDir string,
	instanceId string,
	clientId string) (*contracts.DocumentState, error) {
	log := context.Log()
	parsedMessagePayload, err := deserializeAgentTaskPayload(log, *agentMessage)
	if err != nil {
		errorMsg := "Encountered error while parsing input - internal error"
		return nil, fmt.Errorf("%v", errorMsg)
	}
	log.Debugf("Receiving session id %s, clientId: %s", parsedMessagePayload.SessionId, clientId)
	log.Tracef("Processing start-session message %s", agentMessage.Payload)
	documentInfo := buildDocumentInfo(*agentMessage, parsedMessagePayload.SessionId, parsedMessagePayload, instanceId)
	messageOrchestrationDirectory := filepath.Join(messagesOrchestrationRootDir, parsedMessagePayload.SessionId)
	parserInfo := docparser.DocumentParserInfo{
		OrchestrationDir: messageOrchestrationDirectory,
		MessageId:        documentInfo.MessageID,
		DocumentId:       documentInfo.DocumentID,
	}
	docContent := &docparser.SessionDocContent{
		SchemaVersion: parsedMessagePayload.DocumentContent.SchemaVersion,
		Description:   parsedMessagePayload.DocumentContent.Description,
		SessionType:   parsedMessagePayload.DocumentContent.SessionType,
		Inputs:        parsedMessagePayload.DocumentContent.Inputs,
		Parameters:    parsedMessagePayload.DocumentContent.Parameters,
		Properties:    parsedMessagePayload.DocumentContent.Properties,
	}
	docState, err := docparser.InitializeDocState(
		log,
		contracts.StartSession,
		docContent,
		documentInfo,
		parserInfo,
		parsedMessagePayload.Parameters)
	if err != nil {
		return nil, fmt.Errorf("error initialing document state: %s", err)
	}
	log.Debugf("Docstate document ID after Initializing: %s", docState.DocumentInformation.DocumentID)
	return &docState, nil
}
func ( agentMessage * AgentMessage ) ParseAgentMessage ( context context . T , messagesOrchestrationRootDir string , instanceId string , clientId string ) ( * contracts . DocumentState , error ) { log := context . Log ( ) parsedMessagePayload , err := deserializeAgentTaskPayload ( log , * agentMessage ) if err != nil { errorMsg := " " return nil , fmt . Errorf ( " " , errorMsg ) } log . Debugf ( " " , parsedMessagePayload . SessionId , clientId ) log . Tracef ( " " , agentMessage . Payload ) documentInfo := buildDocumentInfo ( * agentMessage , parsedMessagePayload . SessionId , parsedMessagePayload , instanceId ) messageOrchestrationDirectory := filepath . Join ( messagesOrchestrationRootDir , parsedMessagePayload . SessionId ) parserInfo := docparser . DocumentParserInfo { OrchestrationDir : messageOrchestrationDirectory , MessageId : documentInfo . MessageID , DocumentId : documentInfo . DocumentID , } docContent := & docparser . SessionDocContent { SchemaVersion : parsedMessagePayload . DocumentContent . SchemaVersion , Description : parsedMessagePayload . DocumentContent . Description , SessionType : parsedMessagePayload . DocumentContent . SessionType , Inputs : parsedMessagePayload . DocumentContent . Inputs , Parameters : parsedMessagePayload . DocumentContent . Parameters , Properties : parsedMessagePayload . DocumentContent . Properties , } docState , err := docparser . InitializeDocState ( log , contracts . StartSession , docContent , documentInfo , parserInfo , parsedMessagePayload . Parameters ) if err != nil { return nil , fmt . Errorf ( " " , err ) } log . Debugf ( " " , docState . DocumentInformation . DocumentID ) return & docState , nil }
ParseAgentMessage parses session message to documentState object for processor.
ParseAgentMessage parses session message to documentState object for processor .
// parse message to retrieve parameters // adapt plugin configuration format from MGS to plugin expected format