use of com.networknt.eventuate.common.Int128 in project light-portal by networknt.
the class UserQueryWorkflow method create.
@EventHandlerMethod
public void create(DispatchedEvent<UserSignUpEvent> de) {
UserSignUpEvent event = de.getEvent();
String id = de.getEntityId();
UserDto userDto = event.getUserDto();
Int128 eventId = de.getEventId();
logger.info("**************** account version={}, {}", id, eventId);
String json = JSonMapper.toJson(userDto);
try {
User user = service.fromUserDto(userDto, id);
service.signup(user, userDto.getPassword(), true);
// TODO remove the following implemetation after confirm email implemented
Optional<ConfirmationToken> token = user.getConfirmationTokens().stream().findFirst();
if (token.isPresent()) {
// TODO send email
System.out.println("Link in the email:\n" + "http://localhost:8081/v1/user/token/" + user.getId() + "?token=" + token.get().getId());
}
} catch (Exception e) {
System.out.println("error:" + e.getMessage());
logger.error("user signup failed:", userDto + " error:" + e.getMessage());
// TODO handler excption, add log info?
}
}
use of com.networknt.eventuate.common.Int128 in project light-portal by networknt.
the class IdGeneratorImpl method genIdInternal.
public Int128 genIdInternal() {
long now = timeNow();
if (currentPeriod != now || counter == MAX_COUNTER) {
long oldPeriod = this.currentPeriod;
while ((this.currentPeriod = timeNow()) <= oldPeriod) {
// Just do nothing
}
counter = 0;
}
Int128 id = makeId();
counter = counter + 1;
return id;
}
Aggregations