private @ Nullable Conversation loadConversationFromMetadata ( ConversationMetadata metadata ) throws SerializerException , ConversationLoadException { // we're going to scan metadata in attempt to find existing conversations ConversationMetadataItem item ; // if the user was logged in previously - we should have an active conversation item = metadata . findItem ( LOGGED_IN ) ; if ( item != null ) { ApptentiveLog . i ( CONVERSATION , "Loading 'logged-in' conversation..." ) ; return loadConversation ( item ) ; } // if no users were logged in previously - we might have an anonymous conversation item = metadata . findItem ( ANONYMOUS ) ; if ( item != null ) { ApptentiveLog . i ( CONVERSATION , "Loading 'anonymous' conversation..." ) ; return loadConversation ( item ) ; } // check if we have a 'pending' anonymous conversation item = metadata . findItem ( ANONYMOUS_PENDING ) ; if ( item != null ) { ApptentiveLog . i ( CONVERSATION , "Loading 'anonymous pending' conversation..." ) ; final Conversation conversation = loadConversation ( item ) ; fetchConversationToken ( conversation ) ; return conversation ; } // check if we have a 'legacy pending' conversation item = metadata . findItem ( LEGACY_PENDING ) ; if ( item != null ) { ApptentiveLog . i ( CONVERSATION , "Loading 'legacy pending' conversation..." ) ; final Conversation conversation = loadConversation ( item ) ; fetchLegacyConversation ( conversation ) ; return conversation ; } // we only have LOGGED_OUT conversations ApptentiveLog . i ( CONVERSATION , "No active conversations to load: only 'logged-out' conversations available" ) ; return null ; }
Attempts to load an existing conversation based on metadata file