19 package org.turro.acceptance;
21 import java.io.IOException;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import javax.servlet.ServletContext;
25 import javax.servlet.http.HttpServletRequest;
26 import javax.servlet.http.HttpServletResponse;
27 import org.turro.string.Strings;
28 import org.turro.action.Contacts;
29 import org.turro.action.IAcceptances;
30 import org.turro.action.Plugins;
31 import org.turro.auth.Authentication;
32 import org.turro.elephant.context.Application;
33 import org.turro.elephant.context.ElephantContext;
34 import org.turro.elephant.context.IConstructor;
35 import org.turro.elephant.direct.DirectContent;
36 import org.turro.elephant.direct.DirectContents;
37 import org.turro.elephant.direct.IDirectContent;
38 import org.turro.marker.ElephantMarker;
39 import org.turro.plugin.contacts.IContact;
40 import org.turro.util.IdGenerator;
46 @DirectContent(identifier=
"petition-create")
50 return createPetition(path, contact, link,
null);
56 marker.
put(
"uniqueId", IdGenerator.generateHex());
57 marker.
put(
"path", path);
58 marker.
put(
"contact", contact);
60 marker.
put(
"redirect", link);
61 return marker.
parse(
"acceptance", Strings.isBlank(
template) ?
"petition" :
template);
69 public boolean itsMe(String
id) {
70 return getIdentifier().equals(
id);
74 public boolean myTurn(HttpServletRequest request) {
79 public void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response) {
83 String path = request.getParameter(
"path");
84 String comment = request.getParameter(
"comment");
85 String redirect = request.getParameter(
"redirect");
87 if(contact.
isValid() && !Strings.isBlank(path) && !Strings.isBlank(comment)) {
94 if(!Strings.isBlank(redirect)) {
97 }
catch (IOException ex) {
static String createPetition(String path, IContact contact, String link, String template)
static String getIdentifier()
boolean myTurn(HttpServletRequest request)
void execute(ServletContext context, HttpServletRequest request, HttpServletResponse response)
static String createPetition(String path, IContact contact, String link)
static< T > T loadImplementation(Class< T > jclass)
static IContact getIContact()
IConstructor getConstructor()
static Application getApplication()
static String logMsg(String msg)
static boolean isYourTurn(HttpServletRequest request, String path)
static String createRelativeURL(String id)
String parse(String rootTmpl, String tmpl)
Object put(Object key, Object value)
IAcceptance request(IContact petitioner, IContact contact, String path, String comment)
void redirect(String path)