BrightSide Workbench Full Report + Source Code
org.turro.acceptance.PetitionCtrl Class Reference
Inheritance diagram for org.turro.acceptance.PetitionCtrl:
Collaboration diagram for org.turro.acceptance.PetitionCtrl:

Public Member Functions

boolean itsMe (String id)
 
boolean myTurn (HttpServletRequest request)
 
void execute (ServletContext context, HttpServletRequest request, HttpServletResponse response)
 

Static Public Member Functions

static String createPetition (String path, IContact contact, String link)
 
static String createPetition (String path, IContact contact, String link, String template)
 
static String getIdentifier ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 47 of file PetitionCtrl.java.

Member Function Documentation

◆ createPetition() [1/2]

static String org.turro.acceptance.PetitionCtrl.createPetition ( String  path,
IContact  contact,
String  link 
)
static

Definition at line 49 of file PetitionCtrl.java.

49  {
50  return createPetition(path, contact, link, null);
51  }
static String createPetition(String path, IContact contact, String link)
Here is the caller graph for this function:

◆ createPetition() [2/2]

static String org.turro.acceptance.PetitionCtrl.createPetition ( String  path,
IContact  contact,
String  link,
String  template 
)
static

Definition at line 53 of file PetitionCtrl.java.

53  {
54  ElephantMarker marker = new ElephantMarker(Application.getApplication().getConstructor());
55  marker.put("action", DirectContents.createRelativeURL(getIdentifier()));
56  marker.put("uniqueId", IdGenerator.generateHex());
57  marker.put("path", path);
58  marker.put("contact", contact);
59  marker.put("petitioner", Authentication.getIContact());
60  marker.put("redirect", link);
61  return marker.parse("acceptance", Strings.isBlank(template) ? "petition" : template);
62  }
Here is the call graph for this function:

◆ execute()

void org.turro.acceptance.PetitionCtrl.execute ( ServletContext  context,
HttpServletRequest  request,
HttpServletResponse  response 
)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 79 of file PetitionCtrl.java.

79  {
80  IConstructor constructor = Application.getApplication().getConstructor();
81  IContact petitioner = Contacts.getContactById(request.getParameter("petitioner"));
82  IContact contact = Contacts.getContactById(request.getParameter("contact"));
83  String path = request.getParameter("path");
84  String comment = request.getParameter("comment");
85  String redirect = request.getParameter("redirect");
86  if(petitioner.isValid()) {
87  if(contact.isValid() && !Strings.isBlank(path) && !Strings.isBlank(comment)) {
88  IAcceptances acceptances = Plugins.loadImplementation(IAcceptances.class);
89  new AcceptanceMail(acceptances.request(petitioner, contact, path, comment)).sendMail();
90  }
91  } else {
92  redirect = "/user";
93  }
94  if(!Strings.isBlank(redirect)) {
95  try {
96  constructor.redirect(redirect);
97  } catch (IOException ex) {
98  Logger.getLogger(PetitionCtrl.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
99  }
100  }
101  }
Here is the call graph for this function:

◆ getIdentifier()

static String org.turro.acceptance.PetitionCtrl.getIdentifier ( )
static

Definition at line 64 of file PetitionCtrl.java.

64  {
65  return PetitionCtrl.class.getAnnotation(DirectContent.class).identifier();
66  }

◆ itsMe()

boolean org.turro.acceptance.PetitionCtrl.itsMe ( String  id)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 69 of file PetitionCtrl.java.

69  {
70  return getIdentifier().equals(id);
71  }

◆ myTurn()

boolean org.turro.acceptance.PetitionCtrl.myTurn ( HttpServletRequest  request)

Implements org.turro.elephant.direct.IDirectContent.

Definition at line 74 of file PetitionCtrl.java.

74  {
75  return DirectContents.isYourTurn(request, getIdentifier());
76  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: