19 package org.turro.agreements;
21 import java.io.IOException;
22 import java.io.UnsupportedEncodingException;
23 import java.net.URLDecoder;
24 import java.net.URLEncoder;
25 import java.util.HashMap;
26 import java.util.logging.Level;
27 import java.util.logging.Logger;
28 import javax.servlet.ServletContext;
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31 import org.turro.string.ObjectString;
32 import org.turro.action.Actions;
33 import org.turro.collections.KeyValueMap;
34 import org.turro.elephant.context.ElephantContext;
35 import org.turro.elephant.context.IConstructor;
36 import org.turro.elephant.direct.DirectContent;
37 import org.turro.elephant.direct.DirectContents;
38 import org.turro.elephant.direct.IDirectContent;
39 import org.turro.elephant.entities.db.AgreementSignature;
40 import org.turro.elephant.security.IUser;
41 import org.turro.plugin.contacts.IContact;
47 @DirectContent(identifier=
"agreement-action")
51 HashMap<String, String> values =
new HashMap<>();
54 values.put(
"agreementId", ObjectString.formatNativeObject(signature.getAgreement().getId(),
false));
55 values.put(
"contactId", contact.getId());
56 values.put(
"accept", ObjectString.formatNativeObject(Boolean.valueOf(accept),
false));
67 public boolean itsMe(String
id) {
68 return getIdentifier().equals(
id);
72 public boolean myTurn(HttpServletRequest request) {
77 public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
84 (Long) ObjectString.parseNativeString(map.get(
"agreementId"), Long.class,
true),
85 (Boolean) ObjectString.parseNativeString(map.get(
"accept"), Boolean.class,
true));
86 response.sendRedirect(URLDecoder.decode(map.get(
Actions.REDIR_PAR),
"UTF-8"));
88 }
catch (IOException ex) {
static String createAction(String email, String redir)
static final String USER_PAR
static KeyValueMap getAction(IConstructor constructor)
static boolean prepareActions(IConstructor constructor, KeyValueMap values)
static String createURL(IConstructor constructor, AgreementSignature signature, IContact contact, boolean accept)
boolean myTurn(HttpServletRequest request)
static String getIdentifier()
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
void sign(Agreement agreement, boolean agreed)
static IConstructor getConstructor(HttpServletRequest request, HttpServletResponse response)
static String getRootWebPath()
static String logMsg(String msg)
static boolean isYourTurn(HttpServletRequest request, String path)
static final String DIRECT_CONTENT_PATH
static final String CONNECTOR_EMAIL