/**
* Returns whether this Sone has the given Sone as a friend Sone.
*
- * @param friendSone
- * The friend Sone to check for
+ * @param friendSoneId
+ * The ID of the Sone to check for
* @return {@code true} if this Sone has the given Sone as a friend,
* {@code false} otherwise
*/
- public boolean hasFriend(Sone friendSone) {
- return friendSones.contains(friendSone);
+ public boolean hasFriend(String friendSoneId) {
+ return friendSones.contains(friendSoneId);
}
/**
/**
* Removes the given Sone as a friend Sone.
*
- * @param friendSone
- * The friend Sone to remove
+ * @param friendSoneId
+ * The ID of the friend Sone to remove
* @return This Sone (for method chaining)
*/
- public Sone removeFriend(Sone friendSone) {
- friendSones.remove(friendSone);
+ public Sone removeFriend(String friendSoneId) {
+ friendSones.remove(friendSoneId);
return this;
}
return sone.getInsertUri() != null;
} else if (member.equals("friend")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
- return (currentSone != null) && currentSone.hasFriend(sone);
+ return (currentSone != null) && currentSone.hasFriend(sone.getId());
} else if (member.equals("current")) {
Sone currentSone = (Sone) dataProvider.getData("currentSone");
return (currentSone != null) && currentSone.equals(sone);
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.getCore().getSone(soneId);
- if (!sone.equals(currentSone)) {
- currentSone.removeFriend(sone);
- webInterface.getCore().saveSone(currentSone);
- }
+ currentSone.removeFriend(soneId);
+ webInterface.getCore().saveSone(currentSone);
throw new RedirectException(returnPage);
}
}
@Override
protected JsonObject createJsonObject(Request request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.getCore().getSone(soneId);
- if (sone == null) {
+ if (!webInterface.getCore().hasSone(soneId)) {
return new JsonObject().put("success", false).put("error", "invalid-sone-id");
}
Sone currentSone = getCurrentSone(request.getToadletContext());
if (currentSone == null) {
return new JsonObject().put("success", false).put("error", "auth-required");
}
- currentSone.removeFriend(sone);
+ currentSone.removeFriend(soneId);
webInterface.getCore().saveSone(currentSone);
return new JsonObject().put("success", true);
}