use of org.tinystruct.handler.Reforward in project bible-online by m0ver.
the class error method process.
public void process() throws ApplicationException {
this.request = (HttpServletRequest) this.context.getAttribute(HTTP_REQUEST);
this.response = (HttpServletResponse) this.context.getAttribute(HTTP_RESPONSE);
this.response.setStatus(HttpServletResponse.SC_FORBIDDEN);
this.reforward = new Reforward(this.request, this.response);
this.setVariable("from", this.reforward.getFromURL());
HttpSession session = this.request.getSession();
if (session.getAttribute("error") != null) {
ApplicationException exception = (ApplicationException) session.getAttribute("error");
String message = exception.getRootCause().getMessage();
if (message != null)
this.setVariable("exception.message", message);
else
this.setVariable("exception.message", "Unknown error");
this.setVariable("exception.details", this.getDetail(exception).toString());
this.response.setStatus(Integer.valueOf(exception.getStatus()));
} else {
this.reforward.forward();
}
}
use of org.tinystruct.handler.Reforward in project bible-online by m0ver.
the class login method logout.
public void logout() {
HttpServletRequest request = (HttpServletRequest) this.context.getAttribute(HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) this.context.getAttribute(HTTP_RESPONSE);
try {
this.passport = new passport(request, response, "waslogined");
this.passport.logout();
if (request.getCookies() != null) {
Cookie[] cookies = request.getCookies();
int i = 0;
Cookie cookie;
while (cookies.length > i) {
cookie = cookies[i];
cookie.setMaxAge(0);
cookie.setValue("");
response.addCookie(cookie);
i++;
}
}
Reforward reforward = new Reforward(request, response);
reforward.setDefault(this.getLink(this.getConfiguration("default.login.page")));
reforward.forward();
} catch (ApplicationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of org.tinystruct.handler.Reforward in project bible-online by m0ver.
the class login method execute.
public void execute(String provider) throws ApplicationException {
HttpServletRequest http_request = (HttpServletRequest) this.context.getAttribute(HTTP_REQUEST);
HttpServletResponse http_response = (HttpServletResponse) this.context.getAttribute(HTTP_RESPONSE);
Reforward reforward = new Reforward(http_request, http_response);
this.setVariable("from", reforward.getFromURL());
System.out.println("From:" + reforward.getFromURL());
try {
HttpSession session = http_request.getSession();
if (session.getAttribute("usr") == null)
reforward.setDefault(createRequestString(oAuth2Provider.valueOf(provider.toUpperCase())));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
throw new ApplicationException(e.getMessage(), e);
}
reforward.forward();
}
use of org.tinystruct.handler.Reforward in project bible-online by m0ver.
the class sender method update.
public boolean update(String id) throws ApplicationException {
report report = new report();
report.setId(id);
report.findOneById();
bible bible = new bible();
if (this.getLocale().toString().equalsIgnoreCase(Locale.US.toString())) {
bible.setTableName("NIV");
} else if (this.getLocale().toString().equalsIgnoreCase(Locale.UK.toString())) {
bible.setTableName("KJV");
} else {
bible.setTableName(this.getLocale().toString());
}
bible.setId(report.getBibleId());
bible.setContent(report.getUpdatedContent());
report.setStatus(1);
if (bible.update() && report.update()) {
this.request = (HttpServletRequest) this.context.getAttribute(HTTP_REQUEST);
this.response = (HttpServletResponse) this.context.getAttribute(HTTP_RESPONSE);
bible.findOneById();
this.reforward = new Reforward(this.request, this.response);
this.reforward.setDefault(this.getLink("bible") + "/" + bible.getBookId() + "/" + bible.getChapterId() + "/" + bible.getPartId());
this.reforward.forward();
return true;
}
return false;
}
use of org.tinystruct.handler.Reforward in project bible-online by m0ver.
the class login method validate.
public Object validate() {
HttpServletRequest request = (HttpServletRequest) this.context.getAttribute(HTTP_REQUEST);
HttpServletResponse response = (HttpServletResponse) this.context.getAttribute(HTTP_RESPONSE);
Cookie cookie = StringUtilities.getCookieByName(request.getCookies(), "username");
if (cookie != null) {
this.setVariable("username", cookie.getValue());
String user_field = cookie.getValue() + "<input class=\"text\" id=\"username\" name=\"username\" type=\"hidden\" value=\"" + cookie.getValue() + "\"/> <a href=\"javascript:void(0)\" onclick=\"restoreField()\">[%login.user.change%]</a>";
this.setVariable("user_field", user_field);
} else {
this.setVariable("username", "");
this.setVariable("user_field", "<input class=\"text\" id=\"username\" name=\"username\" type=\"text\" value=\"\"/>");
}
this.setText("login.tips.text", this.getLink("bible"));
try {
Reforward reforward = new Reforward(request, response);
if (request.getMethod().equalsIgnoreCase("post")) {
this.passport = new passport(request, response, "waslogined");
if (this.passport.login()) {
reforward.forward();
}
}
this.setVariable("from", reforward.getFromURL());
} catch (ApplicationException e) {
this.setVariable("error", "<div class=\"error\">" + e.getRootCause().getMessage() + "</div>");
}
this.setVariable("action", String.valueOf(this.context.getAttribute("HTTP_HOST")) + this.context.getAttribute("REQUEST_ACTION").toString());
HttpSession session = request.getSession();
if (session.getAttribute("usr") != null) {
this.usr = (User) session.getAttribute("usr");
this.setVariable("user.status", "");
this.setVariable("user.profile", "<a href=\"javascript:void(0)\" onmousedown=\"profileMenu.show(event,'1')\">" + this.usr.getEmail() + "</a>");
} else {
this.setVariable("user.status", "<a href=\"" + this.getLink("user/login") + "\">" + this.getProperty("page.login.caption") + "</a>");
this.setVariable("user.profile", "");
}
return this;
}
Aggregations