use of org.finos.waltz.model.user_agent_info.UserAgentInfo in project waltz by khartec.
the class UserAgentInfoHarness method main.
public static void main(String[] args) {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(DIConfiguration.class);
UserAgentInfoDao userLoginDao = ctx.getBean(UserAgentInfoDao.class);
DSLContext dsl = ctx.getBean(DSLContext.class);
List<UserAgentInfo> infos = userLoginDao.findLoginsForUser("admin", 10);
System.out.println(infos);
userLoginDao.save(infos.get(0));
}
use of org.finos.waltz.model.user_agent_info.UserAgentInfo in project waltz by khartec.
the class UserAgentInfoEndpoint method register.
@Override
public void register() {
String findForUserPath = WebUtilities.mkPath(BASE_URL, "user", ":userName");
String recordLoginPath = WebUtilities.mkPath(BASE_URL);
ListRoute<UserAgentInfo> findForUserRoute = ((request, response) -> {
String userName = request.params("userName");
String limitStr = request.queryParams("limit");
int limit = limitStr == null || limitStr.equals("") ? DEFAULT_LIMIT : Integer.parseInt(limitStr);
return userAgentInfoService.findLoginsForUser(userName, limit);
});
DatumRoute<Integer> recordLoginRoute = (request, response) -> {
BrowserInfo browserInfo = WebUtilities.readBody(request, BrowserInfo.class);
UserAgentInfo userAgentInfo = ImmutableUserAgentInfo.builder().userName(WebUtilities.getUsername(request)).userAgent(request.userAgent()).operatingSystem(browserInfo.operatingSystem()).resolution(browserInfo.resolution()).loginTimestamp(DateTimeUtilities.nowUtc()).ipAddress(request.ip()).build();
return userAgentInfoService.save(userAgentInfo);
};
EndpointUtilities.getForList(findForUserPath, findForUserRoute);
EndpointUtilities.postForDatum(recordLoginPath, recordLoginRoute);
}
Aggregations