19 package org.turro.alliance.service;
21 import java.io.IOException;
22 import java.net.URLDecoder;
23 import java.nio.charset.StandardCharsets;
24 import java.util.Objects;
25 import javax.servlet.ServletException;
26 import javax.servlet.annotation.WebServlet;
27 import javax.servlet.http.HttpServlet;
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.http.HttpServletResponse;
30 import org.turro.collections.KeyValueMap;
31 import org.turro.elephant.context.Application;
32 import org.turro.elephant.context.ElephantApplication;
33 import org.turro.http.Respond;
34 import org.turro.json.Jsons;
35 import org.turro.ws.WsServer;
36 import org.turro.ws.WsServerPK;
37 import org.turro.ws.service.member.Servers;
38 import org.turro.ws.service.p2p.P2Ps;
44 @WebServlet(name =
"P2PClient", urlPatterns = {
"/p2pc/*"})
47 private void processP2P(
Application application, String path, KeyValueMap map)
throws IOException {
48 if(Objects.equals(
"/attach", path)) {
51 Jsons criteria = Jsons.object().add(
"attachId", map.get(Long.class,
"a"));
52 Respond.to(response).name(map.get(
"n")).flush(
58 protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
59 KeyValueMap map =
new KeyValueMap();
60 for(String key : request.getParameterMap().keySet()) {
61 map.put(key, URLDecoder.decode(request.getParameter(key), StandardCharsets.UTF_8));
67 protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
68 processRequest(request, response);
72 protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
73 processRequest(request, response);
78 return "P2P client servlet";
static final String AX_P2P_SERVICE
static final String SERVER_SERVICE
void doGet(HttpServletRequest request, HttpServletResponse response)
void doPost(HttpServletRequest request, HttpServletResponse response)
void processRequest(HttpServletRequest request, HttpServletResponse response)
abstract HttpServletResponse getHttpServletResponse()
static WsServerPK from(String serverDomain, String service)