return trustedIdentities.containsEntry(origin.getIdentity(), target.getIdentity());
}
- public Optional<Post> getPost(String postId) {
- return database.getPost(postId);
- }
-
- public Collection<Post> getPosts(String soneId) {
- return database.getPosts(soneId);
- }
-
- public Collection<Post> getDirectedPosts(final String recipientId) {
- checkNotNull(recipientId, "recipient must not be null");
- return database.getDirectedPosts(recipientId);
- }
-
@Override
public Optional<PostReply> getPostReply(String replyId) {
return database.getPostReply(replyId);
Set<Post> posts = new HashSet<Post>();
synchronized (bookmarkedPosts) {
for (String bookmarkedPostId : bookmarkedPosts) {
- Optional<Post> post = getPost(bookmarkedPostId);
+ Optional<Post> post = database.getPost(bookmarkedPostId);
if (post.isPresent()) {
posts.add(post.get());
}
protected Post getPost(SimpleFieldSet simpleFieldSet, String parameterName) throws FcpException {
try {
String postId = simpleFieldSet.getString(parameterName);
- Optional<Post> post = core.getPost(postId);
+ Optional<Post> post = core.getDatabase().getPost(postId);
if (!post.isPresent()) {
throw new FcpException("Could not load post from “" + postId + "”.");
}
}
allPosts.addAll(friendSone.get().getPosts());
}
- allPosts.addAll(getCore().getDirectedPosts(sone.getId()));
+ allPosts.addAll(getCore().getDatabase().getDirectedPosts(sone.getId()));
allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER);
List<Post> sortedPosts = new ArrayList<Post>(allPosts);
String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
if (request.getMethod() == Method.POST) {
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent()) {
throw new RedirectException("noPermission.html");
}
if (request.getMethod() == Method.GET) {
String postId = request.getHttpRequest().getParam("post");
String returnPage = request.getHttpRequest().getParam("returnPage");
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent()) {
throw new RedirectException("noPermission.html");
}
} else if (request.getMethod() == Method.POST) {
String postId = request.getHttpRequest().getPartAsStringFailsafe("post", 36);
String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 256);
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent() || !post.get().getSone().isLocal()) {
throw new RedirectException("noPermission.html");
}
for (StringTokenizer idTokenizer = new StringTokenizer(ids); idTokenizer.hasMoreTokens();) {
String id = idTokenizer.nextToken();
if (type.equals("post")) {
- Optional<Post> post = webInterface.getCore().getPost(id);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
if (!post.isPresent()) {
continue;
}
*/
private String getPostId(String phrase) {
String postId = phrase.startsWith("post://") ? phrase.substring(7) : phrase;
- return (webInterface.getCore().getPost(postId).isPresent()) ? postId : null;
+ return (webInterface.getCore().getDatabase().getPost(postId).isPresent()) ? postId : null;
}
/**
@Override
protected String getPageTitle(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
String title = "";
if (post.isPresent()) {
title = post.get().getText().substring(0, Math.min(20, post.get().getText().length())) + "…";
super.processTemplate(request, templateContext);
String postId = request.getHttpRequest().getParam("post");
boolean raw = request.getHttpRequest().getParam("raw").equals("true");
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
templateContext.set("post", post.orNull());
templateContext.set("raw", raw);
}
return;
}
List<Post> sonePosts = sone.get().getPosts();
- sonePosts.addAll(webInterface.getCore().getDirectedPosts(sone.get().getId()));
+ sonePosts.addAll(webInterface.getCore().getDatabase().getDirectedPosts(sone.get().getId()));
Collections.sort(sonePosts, Post.TIME_COMPARATOR);
Pagination<Post> postPagination = new Pagination<Post>(sonePosts, webInterface.getCore().getPreferences().getPostsPerPage()).setPage(Numbers.safeParseInteger(request.getHttpRequest().getParam("postPage"), 0));
templateContext.set("postPagination", postPagination);
if (!sender.isPresent()) {
sender = of(getCurrentSone(request.getToadletContext()));
}
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent()) {
return createErrorJsonObject("invalid-post-id");
}
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent()) {
return createErrorJsonObject("invalid-post-id");
}
return createErrorJsonObject("invalid-" + type + "-id");
}
if ("post".equals(type)) {
- Optional<Post> post = webInterface.getCore().getPost(id);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
if (!post.isPresent()) {
return createErrorJsonObject("invalid-post-id");
}
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
- Optional<Post> post = webInterface.getCore().getPost(postId);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(postId);
if (!post.isPresent()) {
return createErrorJsonObject("invalid-post-id");
}
if (allIds.length() > 0) {
String[] ids = allIds.split(",");
for (String id : ids) {
- Optional<Post> post = webInterface.getCore().getPost(id);
+ Optional<Post> post = webInterface.getCore().getDatabase().getPost(id);
if (!post.isPresent()) {
continue;
}
Core core = webInterface.getCore();
for (String id : ids) {
if (type.equals("post")) {
- Optional<Post> post = core.getPost(id);
+ Optional<Post> post = core.getDatabase().getPost(id);
if (!post.isPresent()) {
continue;
}