use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.
the class ApplicationSessionDAOITest method getPageTest.
/**
* Gets the page test.
*
* @return the page test
* @throws Exception
* the exception
*/
@Test
public void getPageTest() throws Exception {
final ApplicationSession applicationSession = createApplicationSession();
final int resultPerPage = 1;
final List<ApplicationSession> pageList = applicationSessionDAO.getPage(1, resultPerPage);
assertNotNull(pageList);
assertFalse(pageList.isEmpty());
assertEquals(resultPerPage, pageList.size());
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.
the class ApplicationSessionDAOITest method deleteTest.
/**
* Delete test.
*
* @throws Exception
* the exception
*/
@Test
public void deleteTest() throws Exception {
final ApplicationSession applicationSession = createApplicationSession();
final List<ApplicationSession> all = applicationSessionDAO.getAll();
final ApplicationSession firstValue = all.iterator().next();
final Long hjid = firstValue.getHjid();
applicationSessionDAO.delete(firstValue);
final ApplicationSession loadDeleted = applicationSessionDAO.load(hjid);
assertNull(loadDeleted);
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.
the class CreateApplicationEventService method processService.
@Override
public CreateApplicationEventResponse processService(final CreateApplicationEventRequest serviceRequest) {
final CreateApplicationEventResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
if (applicationSession != null) {
final ApplicationActionEvent applicationActionEvent = new ApplicationActionEvent();
applicationActionEvent.setEventGroup(serviceRequest.getEventGroup());
applicationActionEvent.setCreatedDate(new Date());
applicationActionEvent.setSessionId(serviceRequest.getSessionId());
applicationActionEvent.setPage(serviceRequest.getPage());
applicationActionEvent.setPageMode(serviceRequest.getPageMode());
applicationActionEvent.setElementId(serviceRequest.getElementId());
applicationActionEvent.setApplicationOperation(serviceRequest.getApplicationOperation());
applicationActionEvent.setActionName(serviceRequest.getActionName());
applicationActionEvent.setUserId(serviceRequest.getUserId());
if (serviceRequest.getUserId() != null && ApplicationSessionType.ANONYMOUS == applicationSession.getSessionType()) {
applicationSession.setSessionType(ApplicationSessionType.REGISTERED_USER);
applicationSession.setUserId(serviceRequest.getUserId());
}
applicationActionEvent.setApplicationMessage(serviceRequest.getApplicationMessage());
applicationActionEvent.setErrorMessage(serviceRequest.getErrorMessage());
applicationSession.getEvents().add(applicationActionEvent);
applicationSessionDAO.persist(applicationSession);
return new CreateApplicationEventResponse(ServiceResult.SUCCESS);
} else {
return new CreateApplicationEventResponse(ServiceResult.FAILURE);
}
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.
the class CreateApplicationSessionService method processService.
@Secured({ "ROLE_ANONYMOUS" })
@Override
public CreateApplicationSessionResponse processService(final CreateApplicationSessionRequest serviceRequest) {
final ApplicationSession applicationSession = new ApplicationSession();
applicationSession.setCreatedDate(new Date());
applicationSession.setSessionId(serviceRequest.getSessionId());
applicationSession.setIpInformation(serviceRequest.getIpInformation());
applicationSession.setLocale(serviceRequest.getLocale());
applicationSession.setTimeZone(serviceRequest.getTimeZone());
applicationSession.setScreenSize(serviceRequest.getScreenSize());
applicationSession.setOperatingSystem(serviceRequest.getOperatingSystem());
applicationSession.setUserAgentInformation(serviceRequest.getUserAgentInformation());
applicationSession.setSessionType(serviceRequest.getSessionType());
applicationSession.setEvents(new ArrayList<>());
applicationSession.setSessionType(ApplicationSessionType.ANONYMOUS);
applicationSessionDAO.persist(applicationSession);
LOGGER.info("Create application session:{}", applicationSession);
return new CreateApplicationSessionResponse(ServiceResult.SUCCESS);
}
use of com.hack23.cia.model.internal.application.system.impl.ApplicationSession in project cia by Hack23.
the class DestroyApplicationSessionService method processService.
@Override
@Secured({ "ROLE_ANONYMOUS" })
public DestroyApplicationSessionResponse processService(final DestroyApplicationSessionRequest serviceRequest) {
final DestroyApplicationSessionResponse inputValidation = inputValidation(serviceRequest);
if (inputValidation != null) {
return inputValidation;
}
final ApplicationSession applicationSession = applicationSessionDAO.findFirstByProperty(ApplicationSession_.sessionId, serviceRequest.getSessionId());
if (applicationSession != null) {
LOGGER.info("Destroy Application session: {}", applicationSession.getSessionId());
applicationSession.setDestroyedDate(new Date());
applicationSessionDAO.persist(applicationSession);
return new DestroyApplicationSessionResponse(ServiceResult.SUCCESS);
} else {
LOGGER.warn("Failed to destroy Application session, no session found for id: {}", serviceRequest.getSessionId());
return new DestroyApplicationSessionResponse(ServiceResult.FAILURE);
}
}
Aggregations