String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
if (text.length() != 0) {
Sone currentSone = getCurrentSone(request.getToadletContext());
- webInterface.core().createPost(currentSone, System.currentTimeMillis(), text);
+ webInterface.getCore().createPost(currentSone, System.currentTimeMillis(), text);
throw new RedirectException(returnPage);
}
template.set("errorTextEmpty", true);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
if (request.getMethod() == Method.POST) {
- Post post = webInterface.core().getPost(postId);
+ Post post = webInterface.getCore().getPost(postId);
if (text.length() > 0) {
Sone currentSone = getCurrentSone(request.getToadletContext());
- webInterface.core().createReply(currentSone, post, text);
+ webInterface.getCore().createReply(currentSone, post, text);
throw new RedirectException(returnPage);
}
template.set("errorTextEmpty", true);
@Override
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
- List<OwnIdentity> ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.core());
+ List<OwnIdentity> ownIdentitiesWithoutSone = getOwnIdentitiesWithoutSone(webInterface.getCore());
template.set("identitiesWithoutSone", ownIdentitiesWithoutSone);
if (request.getMethod() == Method.POST) {
String id = request.getHttpRequest().getPartAsStringFailsafe("identity", 44);
return;
}
/* create Sone. */
- webInterface.core().getIdentityManager().addContext(selectedIdentity, "Sone");
- Sone sone = webInterface.core().createSone(selectedIdentity);
+ webInterface.getCore().getIdentityManager().addContext(selectedIdentity, "Sone");
+ Sone sone = webInterface.getCore().createSone(selectedIdentity);
if (sone == null) {
logger.log(Level.SEVERE, "Could not create Sone for OwnIdentity: %s", selectedIdentity);
/* TODO - go somewhere else */
if (request.getMethod() == Method.GET) {
String postId = request.getHttpRequest().getParam("post");
String returnPage = request.getHttpRequest().getParam("returnPage");
- Post post = webInterface.core().getPost(postId);
+ Post post = webInterface.getCore().getPost(postId);
template.set("post", post);
template.set("returnPage", returnPage);
return;
} else if (request.getMethod() == Method.POST) {
String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
- Post post = webInterface.core().getPost(postId);
+ Post post = webInterface.getCore().getPost(postId);
Sone currentSone = getCurrentSone(request.getToadletContext());
if (!post.getSone().equals(currentSone)) {
throw new RedirectException("noPermission.html");
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
String replyId = request.getHttpRequest().getPartAsStringFailsafe("reply", 36);
- Reply reply = webInterface.core().getReply(replyId);
+ Reply reply = webInterface.getCore().getReply(replyId);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
if (request.getMethod() == Method.POST) {
Sone currentSone = getCurrentSone(request.getToadletContext());
throw new RedirectException("noPermission.html");
}
if (request.getHttpRequest().isPartSet("confirmDelete")) {
- webInterface.core().deleteReply(reply);
+ webInterface.getCore().deleteReply(reply);
throw new RedirectException(returnPage);
} else if (request.getHttpRequest().isPartSet("abortDelete")) {
throw new RedirectException(returnPage);
if (request.getMethod() == Method.POST) {
if (request.getHttpRequest().isPartSet("deleteSone")) {
Sone currentSone = getCurrentSone(request.getToadletContext());
- webInterface.core().deleteSone(currentSone);
+ webInterface.getCore().deleteSone(currentSone);
}
throw new RedirectException("index.html");
}
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.core().getSone(soneId);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (!sone.equals(currentSone)) {
currentSone.addFriend(sone);
- webInterface.core().saveSone(currentSone);
+ webInterface.getCore().saveSone(currentSone);
}
throw new RedirectException(returnPage);
}
@Override
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
- List<Sone> knownSones = new ArrayList<Sone>(webInterface.core().getSones());
+ List<Sone> knownSones = new ArrayList<Sone>(webInterface.getCore().getSones());
Collections.sort(knownSones, Sone.NICE_NAME_COMPARATOR);
template.set("knownSones", knownSones);
}
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
/* get all own identities. */
- List<Sone> localSones = new ArrayList<Sone>(webInterface.core().getLocalSones());
+ List<Sone> localSones = new ArrayList<Sone>(webInterface.getCore().getLocalSones());
Collections.sort(localSones, Sone.NICE_NAME_COMPARATOR);
template.set("sones", localSones);
if (request.getMethod() == Method.POST) {
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone-id", 100);
Sone selectedSone = null;
- for (Sone sone : webInterface.core().getSones()) {
+ for (Sone sone : webInterface.getCore().getSones()) {
if (sone.getId().equals(soneId)) {
selectedSone = sone;
break;
throw new RedirectException("index.html");
}
}
- List<OwnIdentity> ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.core());
+ List<OwnIdentity> ownIdentitiesWithoutSone = CreateSonePage.getOwnIdentitiesWithoutSone(webInterface.getCore());
template.set("identitiesWithoutSone", ownIdentitiesWithoutSone);
}
@Override
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
- Options options = webInterface.core().getOptions();
+ Options options = webInterface.getCore().getOptions();
if (request.getMethod() == Method.POST) {
Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
options.getIntegerOption("InsertionDelay").set(insertionDelay);
if (soneId == null) {
return null;
}
- for (Sone sone : webInterface.core().getSones()) {
+ for (Sone sone : webInterface.getCore().getSones()) {
if (sone.getId().equals(soneId)) {
return sone;
}
String soneId = request.getHttpRequest().getPartAsStringFailsafe("sone", 44);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
Sone currentSone = getCurrentSone(request.getToadletContext());
- Sone sone = webInterface.core().getSone(soneId);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (!sone.equals(currentSone)) {
currentSone.removeFriend(sone);
- webInterface.core().saveSone(currentSone);
+ webInterface.getCore().saveSone(currentSone);
}
throw new RedirectException(returnPage);
}
protected void processTemplate(Request request, Template template) throws RedirectException {
super.processTemplate(request, template);
String postId = request.getHttpRequest().getParam("post");
- Post post = webInterface.core().getPost(postId);
+ Post post = webInterface.getCore().getPost(postId);
template.set("post", post);
}
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);
+ Sone sone = webInterface.getCore().getSone(soneId);
template.set("sone", sone);
}
*
* @return The Sone core
*/
- public Core core() {
+ public Core getCore() {
return sonePlugin.core();
}
DefaultTemplateFactory templateFactory = new DefaultTemplateFactory();
templateFactory.addAccessor(Object.class, new ReflectionAccessor());
templateFactory.addAccessor(Collection.class, new CollectionAccessor());
- templateFactory.addAccessor(Sone.class, new SoneAccessor(core()));
- templateFactory.addAccessor(Post.class, new PostAccessor(core()));
- templateFactory.addAccessor(Reply.class, new ReplyAccessor(core()));
- templateFactory.addAccessor(Identity.class, new IdentityAccessor(core()));
+ templateFactory.addAccessor(Sone.class, new SoneAccessor(getCore()));
+ templateFactory.addAccessor(Post.class, new PostAccessor(getCore()));
+ templateFactory.addAccessor(Reply.class, new ReplyAccessor(getCore()));
+ templateFactory.addAccessor(Identity.class, new IdentityAccessor(getCore()));
templateFactory.addFilter("date", new DateFilter());
templateFactory.addFilter("l10n", new L10nFilter(getL10n()));
templateFactory.addFilter("substring", new SubstringFilter());
@Override
protected JsonObject createJsonObject(Request request) {
String postId = request.getHttpRequest().getParam("post");
- Post post = webInterface.core().getPost(postId);
+ Post post = webInterface.getCore().getPost(postId);
Sone currentSone = getCurrentSone(request.getToadletContext());
if (post == null) {
return new JsonObject().put("success", false).put("error", "invalid-post-id");
@Override
protected JsonObject createJsonObject(Request request) {
String replyId = request.getHttpRequest().getParam("reply");
- Reply reply = webInterface.core().getReply(replyId);
+ Reply reply = webInterface.getCore().getReply(replyId);
Sone currentSone = getCurrentSone(request.getToadletContext());
if (reply == null) {
return new JsonObject().put("success", false).put("error", "invalid-reply-id");
if (!reply.getSone().equals(currentSone)) {
return new JsonObject().put("success", false).put("error", "not-authorized");
}
- webInterface.core().deleteReply(reply);
+ webInterface.getCore().deleteReply(reply);
return new JsonObject().put("success", true);
}
@Override
protected JsonObject createJsonObject(Request request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.core().getSone(soneId);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (sone == null) {
return new JsonObject().put("success", false).put("error", "invalid-sone-id");
}
return new JsonObject().put("success", false).put("error", "auth-required");
}
currentSone.addFriend(sone);
- webInterface.core().saveSone(currentSone);
+ webInterface.getCore().saveSone(currentSone);
return new JsonObject().put("success", true);
}
return new JsonObject().put("success", false).put("error", "invalid-" + type + "-id");
}
if ("post".equals(type)) {
- Post post = webInterface.core().getPost(id);
- Set<Sone> sones = webInterface.core().getLikes(post);
+ Post post = webInterface.getCore().getPost(id);
+ Set<Sone> sones = webInterface.getCore().getLikes(post);
return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
} else if ("reply".equals(type)) {
- Reply reply = webInterface.core().getReply(id);
- Set<Sone> sones = webInterface.core().getLikes(reply);
+ Reply reply = webInterface.getCore().getReply(id);
+ Set<Sone> sones = webInterface.getCore().getLikes(reply);
return new JsonObject().put("success", true).put("likes", sones.size()).put("sones", getSones(sones));
}
return new JsonObject().put("success", false).put("error", "invalid-type");
@Override
protected JsonObject createJsonObject(Request request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.core().getSone(soneId);
- SoneStatus soneStatus = webInterface.core().getSoneStatus(sone);
+ Sone sone = webInterface.getCore().getSone(soneId);
+ SoneStatus soneStatus = webInterface.getCore().getSoneStatus(sone);
return new JsonObject().put("status", soneStatus.name()).put("name", SoneAccessor.getNiceName(sone)).put("modified", sone.getModificationCounter() > 0).put("lastUpdated", new SimpleDateFormat("MMM d, yyyy, HH:mm:ss").format(new Date(sone.getTime()))).put("age", (System.currentTimeMillis() - sone.getTime()) / 1000);
}
if (soneId == null) {
return null;
}
- for (Sone sone : webInterface.core().getSones()) {
+ for (Sone sone : webInterface.getCore().getSones()) {
if (sone.getId().equals(soneId)) {
return sone;
}
@Override
protected JsonObject createJsonObject(Request request) {
String soneId = request.getHttpRequest().getParam("sone");
- Sone sone = webInterface.core().getSone(soneId);
+ Sone sone = webInterface.getCore().getSone(soneId);
if (sone == null) {
return new JsonObject().put("success", false).put("error", "invalid-sone-id");
}
return new JsonObject().put("success", false).put("error", "auth-required");
}
currentSone.removeFriend(sone);
- webInterface.core().saveSone(currentSone);
+ webInterface.getCore().saveSone(currentSone);
return new JsonObject().put("success", true);
}