public long getCreationTime() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } return creationTime; }
public void setInvalidateWhenReady(boolean invalidateWhenReady) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } this.invalidateWhenReady = invalidateWhenReady; }
public boolean getInvalidateWhenReady() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } return invalidateWhenReady; }
public ServletTimer getTimer(String id) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } if(servletTimers != null) { return servletTimers.get(id); } return null; }
public Collection<ServletTimer> getTimers() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } if(servletTimers != null) { return servletTimers.values(); } return new HashMap<String, ServletTimer>().values(); }
public boolean isReadyToInvalidate() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } updateReadyToInvalidateState(); return readyToInvalidate; }
/** * {@inheritDoc} */ public Object getAttribute(String name) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } return this.getAttributeMap().get(name); }
public Iterator<String> getAttributeNames() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } return this.getAttributeMap().keySet().iterator(); }
@SuppressWarnings(value="unchecked") public Iterator<?> getSessions() { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } Set<MobicentsSipSession> sipSessions = getSipSessions(false); Set<HttpSession> httpSessions = getHttpSessions(); Set protocolSessions = new HashSet(); protocolSessions.addAll(httpSessions); protocolSessions.addAll(sipSessions); return protocolSessions.iterator(); }
public long getExpirationTime() { if(!isValid()) { throw new IllegalStateException("this sip application session is not valid anymore"); } if(expirationTimerTask == null) { return 0; } long delay = expirationTimerTask.getDelay(); if(delay <= 0) { return 0; } if(expired) { return Long.MIN_VALUE; } return this.expirationTime; }
public Iterator<?> getSessions(String protocol) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } if(protocol == null) { throw new NullPointerException("protocol given in argument is null"); } if("SIP".equalsIgnoreCase(protocol)) { return getSipSessions(false).iterator(); } else if("HTTP".equalsIgnoreCase(protocol)) { return getHttpSessions().iterator(); } else { throw new IllegalArgumentException(protocol + " sessions are not handled by this container"); } } // internal flag in parameter added for https://github.com/Mobicents/sip-servlets/issues/43 so that we return the facade object
/** * {@inheritDoc} */ public Object getSession(String id, Protocol protocol) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } if(id == null) { throw new NullPointerException("id is null"); } if(protocol == null) { throw new NullPointerException("protocol is null"); } switch (protocol) { case SIP : return getSipSession(id); case HTTP : return findHttpSession(id); default : break; } return null; }
/** * {@inheritDoc} * Adds a get parameter to the URL like this: * http://hostname/link -> http://hostname/link?org.mobicents.servlet.sip.ApplicationSessionKey=0 * http://hostname/link?something=1 -> http://hostname/link?something=1&org.mobicents.servlet.sip.ApplicationSessionKey=0 */ public URL encodeURL(URL url) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } String urlStr = url.toExternalForm(); try { URL ret; if (urlStr.contains("?")) { ret = new URL(url + "&" + SIP_APPLICATION_KEY_PARAM_NAME + "=" + getId()); } else { ret = new URL(url + "?" + SIP_APPLICATION_KEY_PARAM_NAME + "=" + getId()); } return ret; } catch (Exception e) { throw new IllegalArgumentException("Failed encoding URL : " + url, e); } }
public SipSession getSipSession(String id) { if(!isValid()) { throw new IllegalStateException("SipApplicationSession already invalidated !"); } if(logger.isDebugEnabled()) { logger.debug("Trying to find a session with the id " + id); dumpSipSessions(); } boolean isPresent = false; SipSessionKey sipSessionKey = null; try { sipSessionKey = SessionManagerUtil.parseSipSessionKey(id); isPresent = sipSessions.contains(sipSessionKey); } catch (ParseException e) { //can happen if the id passed is invalid } if(isPresent) { return sipContext.getSipManager().getSipSession(sipSessionKey, false, null, this).getFacade(); } else { return null; } }
@SuppressWarnings(value="unchecked") public int setExpires(int deltaMinutes) { if(!isValid()) { throw new IllegalStateException("Impossible to change the sip application " + "session timeout when it has been invalidated !");
public void removeAttribute(String name, boolean byPassValidCheck) { if (!byPassValidCheck && !isValid()) throw new IllegalStateException( "Can not bind object to session that has been invalidated!!");
public void setAttribute(String key, Object attribute) { if (!isValid()) throw new IllegalStateException( "Can not bind object to session that has been invalidated!!");