projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix exception message.
[Sone.git]
/
src
/
main
/
java
/
net
/
pterodactylus
/
sone
/
web
/
FollowSonePage.java
diff --git
a/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
b/src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
index
2e9f2fe
..
bb90ce0
100644
(file)
--- a/
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
+++ b/
src/main/java/net/pterodactylus/sone/web/FollowSonePage.java
@@
-18,7
+18,7
@@
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Sone;
package net.pterodactylus.sone.web;
import net.pterodactylus.sone.data.Sone;
-import net.pterodactylus.sone.
data.SoneShell
;
+import net.pterodactylus.sone.
web.page.Page.Request.Method
;
import net.pterodactylus.util.template.Template;
/**
import net.pterodactylus.util.template.Template;
/**
@@
-35,7
+35,7
@@
public class FollowSonePage extends SoneTemplatePage {
* The Sone web interface
*/
public FollowSonePage(Template template, WebInterface webInterface) {
* The Sone web interface
*/
public FollowSonePage(Template template, WebInterface webInterface) {
- super("followSone.html", template, "Page.FollowSone.Title", webInterface);
+ super("followSone.html", template, "Page.FollowSone.Title", webInterface
, true
);
}
//
}
//
@@
-48,25
+48,17
@@
public class FollowSonePage extends SoneTemplatePage {
@Override
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
@Override
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
- String soneId = request.getHttpRequest().getParam("sone");
-
Sone sone = webInterface.core().getSone(soneId
);
- if (!(sone instanceof SoneShell)) {
+ if (request.getMethod() == Method.POST) {
+
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44
);
+ String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
Sone currentSone = getCurrentSone(request.getToadletContext());
Sone currentSone = getCurrentSone(request.getToadletContext());
- currentSone.addFriendSone(sone);
+ Sone sone = webInterface.getCore().getSone(soneId);
+ if (!sone.equals(currentSone)) {
+ currentSone.addFriend(sone);
+ webInterface.getCore().saveSone(currentSone);
+ }
+ throw new RedirectException(returnPage);
}
}
- throw new RedirectException("viewSone.html?sone=" + soneId);
- }
-
- //
- // SONETEMPLATEPAGE METHODS
- //
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected boolean requiresLogin() {
- return true;
}
}
}
}