Search in sources :

Example 1 with SessionNotFoundException

use of com.axway.ats.agent.webapp.restservice.exceptions.SessionNotFoundException in project ats-framework by Axway.

the class BaseRestServiceImpl method getSessionData.

protected SessionData getSessionData(HttpServletRequest request, BasePojo basePojo) throws Exception {
    String uid = null;
    SessionData sd = null;
    uid = getUid(request, basePojo, false);
    sd = sessions.get(uid);
    if (sd == null) {
        /*
             * new Session (SessionData) is created when:
             * <ul>
             * <li>initializeDbConnection is called - this is done, when monitoring is requested by REST API</li>
             * <li>initializeMonitoring is called - this is done when the ATS Framework is sending a system monitoring operation</li> 
             * </ul>
             *  
             * */
        if (request.getRequestURI().contains("initializeDbConnection") || request.getRequestURI().contains("initializeMonitoring")) {
            // create new session
            sd = new SessionData();
            sessions.put(uid, sd);
        } else {
            throw new SessionNotFoundException("Could not obtain session with uid '" + uid + "'. It is possible that the agent had been restarted so no sessions are available");
        }
    }
    sd.updateLastUsedFlag();
    return sd;
}
Also used : SessionData(com.axway.ats.agent.webapp.restservice.model.SessionData) SessionNotFoundException(com.axway.ats.agent.webapp.restservice.exceptions.SessionNotFoundException)

Aggregations

SessionNotFoundException (com.axway.ats.agent.webapp.restservice.exceptions.SessionNotFoundException)1 SessionData (com.axway.ats.agent.webapp.restservice.model.SessionData)1