package i5.las2peer.webConnector;

import i5.las2peer.api.Service;
import i5.las2peer.restMapper.RESTMapper;
import i5.las2peer.restMapper.annotations.ContentParam;
import i5.las2peer.restMapper.annotations.Version;
import i5.las2peer.security.UserAgent;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;

/**
 * Service to test the web connector
 *
 */
@Version("0.2")
public class TestService2 extends Service
{

	/**
	 * constructor, initializes RESTMapper
	 */
	public TestService2()
	{

	}

	/**
	 * get all annotation and method data to allow mapping
	 */

	public String getRESTMapping()
	{
		String result = "";
		try {
			result = RESTMapper.getMethodsAsXML(this.getClass());
		} catch (Exception e) {

			e.printStackTrace();
		}
		return result;
	}

	@POST
	@Path("/do/{a}/{b}")
	public String concat(@PathParam("a") String a, @PathParam("b") String b,
			@ContentParam String c)
	{
		return a + b + c;
	}

	@GET
	@Path("/userinfo")
	public String getUserInfo() {
		if (this.getActiveAgent() instanceof UserAgent) {
			UserAgent u = (UserAgent) this.getActiveAgent();
			return "{'id':'" + u.getId() + ", 'name':'" + u.getLoginName() + "','email':'" + u.getEmail() + "'}";
		} else {
			return "Shit happened...";
		}
	}

}

@@ -28,16 +28,121 @@
 ector;%0A%0A
+import javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.PathParam;%0A%0A
 import i
@@ -346,122 +346,52 @@
 ity.
-User
 Agent;%0A
-%0A
 import 
-javax.ws.rs.GET;%0Aimport javax.ws.rs.POST;%0Aimport javax.ws.rs.Path;%0Aimport javax.ws.rs.PathParam
+i5.las2peer.security.UserAgent
 ;%0A%0A/
@@ -1064,33 +1064,62 @@
 %7B%0A%09%09
-if (this.getActiveAgent()
+Agent agent = getContext().getMainAgent();%0A%09%09if (agent
  ins
@@ -1172,29 +1172,13 @@
 nt) 
-this.getActiveA
+a
 gent
-()
 ;%0A%09%09

replace deprecated api calls