_imcounter += 1
DEBUG("Replaying [%s/%s] %s", shortClassNameOf(imEvent), _imcounter, imEvent)
- if(_imcounter == 1 && !MessageHelpers.isIMEventCreate(imEvent)) {
+ if(_imcounter == 1 && !MessageHelpers.isUserCreationIMEvent(imEvent)) {
// The very first event must be a CREATE event. Otherwise we abort initialization.
// This will normally happen during devops :)
INFO("Ignoring first %s since it is not CREATE", shortClassNameOf(imEvent))
)
}
- private[this] def loadLastKnownUserStateAndUpdateAgreements(historyMsg: UserAgreementHistoryMsg) {
- val userID = historyMsg.getUserID
- val latestUserStateOpt = aquarium.userStateStore.findLatestUserState(userID)
- latestUserStateOpt match {
+ private[this] def loadLastKnownUserStateAndUpdateAgreements() {
+ val userID = this._userStateModel.userID
+ aquarium.userStateStore.findLatestUserState(userID) match {
case None ⇒
// First user state ever
saveFirstUserState(userID)
case Some(latestUserState) ⇒
this._userStateModel.updateUserStateMsg(latestUserState)
- this._userStateModel.updateUserAgreementHistoryMsg(historyMsg)
}
}
+ private[this] def processResourceEventsAfterLastKnownUserState() {
+ // Update the user state snapshot with fresh (ie not previously processed) events.
+
+ }
+
+ private[this] def makeUserStateMsgUpToDate() {
+ loadLastKnownUserStateAndUpdateAgreements()
+ processResourceEventsAfterLastKnownUserState()
+ }
+
private[this] def checkInitial(nextThing: () ⇒ Any = () ⇒ {}): Boolean = {
if(!isInitial) {
return false
val (userCreated, imEventsCount) = createUserAgreementHistoryFromIMEvents(userID)
if(userCreated) {
- loadLastKnownUserStateAndUpdateAgreements(this._userStateModel.userAgreementHistoryMsg)
+ makeUserStateMsgUpToDate()
}
nextThing()
this._userStateModel.insertUserAgreementMsgFromIMEvent(imEvent)
this._imMsgCount += 1
- if(haveUserCreationEvent) {
- loadLastKnownUserStateAndUpdateAgreements(this._userStateModel.userAgreementHistoryMsg)
+ if(MessageHelpers.isUserCreationIMEvent(imEvent)) {
+ makeUserStateMsgUpToDate()
}
DEBUG("Agreements: %s", this._userStateModel.userAgreementHistoryMsg)
!isOccurredWithinMillis(event, billingStartMillis, billingStopMillis)
}
- @inline final def isIMEventCreate(msg: IMEventMsg) = {
+ @inline final def isUserCreationIMEvent(msg: IMEventMsg) = {
msg.getEventType().toLowerCase() == MessageConstants.IMEventMsg.EventTypes.create
}
- @inline final def isIMEventModify(msg: IMEventMsg) = {
+ @inline final def isUserModificationIMEvent(msg: IMEventMsg) = {
msg.getEventType().toLowerCase() == MessageConstants.IMEventMsg.EventTypes.modify
}
agreement.getRelatedIMEventMsg match {
case null ⇒
case imEvent ⇒
- if(isIMEventCreate(imEvent)) {
+ if(isUserCreationIMEvent(imEvent)) {
history.setUserCreationTimeMillis(imEvent.getOccurredMillis)
}
}