package com.wizzardo.servlet;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionContext;
import java.util.Enumeration;

/**
 * @author: wizzardo
 * Date: 17.10.14
 */
public class Session implements HttpSession {

    private com.wizzardo.http.Session session;
    private long creationTime = System.currentTimeMillis();
    private long lastAccessedTime;

    Session(com.wizzardo.http.Session session) {
        this.session = session;
    }

    @Override
    public long getCreationTime() {
        return creationTime;
    }

    @Override
    public String getId() {
        return session.getId();
    }

    @Override
    public long getLastAccessedTime() {
        return lastAccessedTime;
    }

    @Override
    public ServletContext getServletContext() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void setMaxInactiveInterval(int interval) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public int getMaxInactiveInterval() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public HttpSessionContext getSessionContext() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public Object getAttribute(String name) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public Object getValue(String name) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public Enumeration<String> getAttributeNames() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public String[] getValueNames() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void setAttribute(String name, Object value) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void putValue(String name, Object value) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void removeAttribute(String name) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void removeValue(String name) {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public void invalidate() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }

    @Override
    public boolean isNew() {
        throw new UnsupportedOperationException("Not implemented yet.");
    }
}

@@ -163,27 +163,104 @@
 va.util.
-Enumeration
+Collections;%0Aimport java.util.Enumeration;%0Aimport java.util.concurrent.ConcurrentHashMap
 ;%0A%0A/**%0A 
@@ -391,24 +391,115 @@
 on session;%0A
+    private ConcurrentHashMap%3CString, Object%3E map;%0A    private boolean newSession = false;%0A
     private 
@@ -659,24 +659,260 @@
  = session;%0A
+        map = (ConcurrentHashMap%3CString, Object%3E) session.get(%22data%22);%0A        if (map == null) %7B%0A            map = new ConcurrentHashMap%3CString, Object%3E();%0A            newSession = true;%0A            session.put(%22data%22, map);%0A        %7D%0A
     %7D%0A%0A    @
@@ -1390,70 +1390,39 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+session.setTTL(interval * 1000l
 );%0A 
@@ -1495,70 +1495,45 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+return (int) (session.getTTL() / 1000
 );%0A 
@@ -1756,70 +1756,27 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+return map.get(name
 );%0A 
@@ -1849,70 +1849,32 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+return getAttribute(name
 );%0A 
@@ -1958,70 +1958,51 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+return Collections.enumeration(map.keySet()
 );%0A 
@@ -2071,70 +2071,58 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+return map.keySet().toArray(new String%5Bmap.size()%5D
 );%0A 
@@ -2211,70 +2211,27 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+map.put(name, value
 );%0A 
@@ -2316,70 +2316,32 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+setAttribute(name, value
 );%0A 
@@ -2419,70 +2419,23 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+map.remove(name
 );%0A 
@@ -2509,70 +2509,28 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22
+removeAttribute(name
 );%0A 
@@ -2592,194 +2592,96 @@
     
-throw new UnsupportedOperationException(%22Not implemented yet.%22);%0A    %7D%0A%0A    @Override%0A    public boolean isNew() %7B%0A        throw new UnsupportedOperationException(%22Not implemented yet.%22)
+map.clear();%0A    %7D%0A%0A    @Override%0A    public boolean isNew() %7B%0A        return newSession
 ;%0A  

implement main logic for Session