64 if(!ElephantPost.isValid(request))
return;
65 Map<String, String[]> pars = request.getParameterMap();
66 HandshakeAction ha = HandshakeAction.getAction(pars.containsKey(
"action") ? pars.get(
"action")[0] :
null);
69 case HANDSHAKE_STATUS:
70 hc = HandshakeContract.createHandshakeFromJson(pars.containsKey(
"contract") ? pars.get(
"contract")[0] :
null);
72 HandshakeStatus status;
74 status = HandshakeStatus.HS_NO_HANDSHAKE;
76 ContractHandshake ch = HandshakeContract.getContractHandshakeFromHandshake(hc);
78 status = HandshakeStatus.HS_NO_HANDSHAKE;
79 }
else if(!ch.getContract().isActive()) {
80 status = HandshakeStatus.HS_BROKEN;
82 status = HandshakeStatus.HS_ESTABLISHED;
85 ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_CORRECT,
"HANDSHAKE SERVER", status.toString());
87 case HANDSHAKE_PETITION:
88 hc = HandshakeContract.createHandshakeFromJson(pars.containsKey(
"contract") ? pars.get(
"contract")[0] :
null);
90 HandshakeContract.saveHandshakePetition(hc);
91 status = HandshakeStatus.HS_NO_HANDSHAKE;
92 ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_CORRECT,
"HANDSHAKE SERVER: PETITION SEND", status.toString());
94 case HANDSHAKE_ACCEPTANCE:
95 hc = HandshakeContract.createHandshakeFromJson(pars.containsKey(
"contract") ? pars.get(
"contract")[0] :
null);
97 if(HandshakeContract.updateRemoteId(
98 pars.containsKey(
"remoteServer") ? pars.get(
"remoteServer")[0] :
null,
99 pars.containsKey(
"remoteId") ? pars.get(
"remoteId")[0] :
null,
101 status = HandshakeStatus.HS_ESTABLISHED;
102 ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_CORRECT,
"HANDSHAKE SERVER: PETITION ACCEPTED", status.toString());
104 status = HandshakeStatus.HS_BROKEN;
105 ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_FAILED,
"HANDSHAKE SERVER: PETITION FAILED", status.toString());
108 case HANDSHAKE_DOCUMENT:
109 HandshakeDocument hd = HandshakeDocument.createHandshakeFromJson(pars.containsKey(
"document") ? pars.get(
"document")[0] :
null);
111 HandshakeDocument.saveHandshakeDocument(hd);
112 status = HandshakeStatus.HS_ESTABLISHED;
113 ElephantResponse.writeToResponse(response, ElephantResponseType.RESPONSE_CORRECT,
"HANDSHAKE SERVER: DOCUMENT ACCEPTED", status.toString());
116 case HANDSHAKE_PRODUCT:
119 }
catch (IOException ex) {
120 Logger.getLogger(HandshakeUtil.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);