}
}
- /** {@inheritDocs} */
@Override
public Collection<Sone> getSones() {
synchronized (sones) {
}
}
- /**
- * Returns the Sone with the given ID, regardless whether it’s local or
- * remote.
- *
- * @param id
- * The ID of the Sone to get
- * @return The Sone with the given ID, or {@code null} if there is no such
- * Sone
- */
@Override
public Optional<Sone> getSone(String id) {
synchronized (sones) {
}
}
- /** {@inheritDocs} */
@Override
public Collection<Sone> getLocalSones() {
synchronized (sones) {
return from(database.getSone(id).asSet()).firstMatch(LOCAL_SONE_FILTER);
}
- /** {@inheritDocs} */
@Override
public Collection<Sone> getRemoteSones() {
synchronized (sones) {
return trustedIdentities.containsEntry(origin.getIdentity(), target.getIdentity());
}
- /** {@inheritDoc} */
@Override
public Optional<Post> getPost(String postId) {
return database.getPost(postId);
}
- /** {@inheritDocs} */
@Override
public Collection<Post> getPosts(String soneId) {
return database.getPosts(soneId);
}
- /** {@inheritDoc} */
@Override
public Collection<Post> getDirectedPosts(final String recipientId) {
checkNotNull(recipientId, "recipient must not be null");
return database.getDirectedPosts(recipientId);
}
- /** {@inheritDoc} */
@Override
public Optional<PostReply> getPostReply(String replyId) {
return database.getPostReply(replyId);
}
- /** {@inheritDoc} */
@Override
public List<PostReply> getReplies(final String postId) {
return database.getReplies(postId);
// SERVICE METHODS
//
- /** Starts the core. */
@Override
public void serviceStart() {
loadConfiguration();
database.start();
}
- /** {@inheritDoc} */
@Override
public void serviceRun() {
long lastSaved = System.currentTimeMillis();
}
}
- /** Stops the core. */
@Override
public void serviceStop() {
localElementTicker.shutdownNow();
// INTERFACE ClientPutCallback
//
- /**
- * {@inheritDoc}
- */
@Override
public void onMajorProgress(ObjectContainer objectContainer) {
/* ignore, we don’t care. */
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("synthetic-access")
public void onFailure(InsertException insertException, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void onFetchable(BaseClientPutter clientPutter, ObjectContainer objectContainer) {
/* ignore, we don’t care. */
}
- /**
- * {@inheritDoc}
- */
@Override
public void onGeneratedMetadata(Bucket metadata, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
/* ignore, we don’t care. */
}
- /**
- * {@inheritDoc}
- */
@Override
public void onGeneratedURI(FreenetURI generatedUri, BaseClientPutter clientPutter, ObjectContainer objectContainer) {
resultingUri = generatedUri;
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("synthetic-access")
public void onSuccess(BaseClientPutter clientPutter, ObjectContainer objectContainer) {
this.optionWatcher = optionWatcher;
}
- /**
- * {@inheritDoc}
- */
@Override
public T getDefault() {
return defaultValue;
}
- /**
- * {@inheritDoc}
- */
@Override
public T get() {
return (value != null) ? value : defaultValue;
}
- /**
- * Returns the real value of the option. This will also return an unset
- * value (usually {@code null})!
- *
- * @return The real value of the option
- */
@Override
public T getReal() {
return value;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean validate(T value) {
return (validator == null) || (value == null) || validator.apply(value);
}
- /**
- * {@inheritDoc}
- */
@Override
public void set(T value) {
if ((value != null) && (validator != null) && (!validator.apply(value))) {
// SERVICE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void serviceStop() {
for (Sone sone : sones) {
import net.pterodactylus.util.template.TemplateParser;
import net.pterodactylus.util.template.XmlFilter;
+import freenet.client.async.ManifestElement;
+import freenet.keys.FreenetURI;
+
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Ordering;
import com.google.common.eventbus.EventBus;
-import freenet.client.async.ManifestElement;
-import freenet.keys.FreenetURI;
-
/**
* A Sone inserter is responsible for inserting a Sone if it has changed.
*
// SERVICE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void serviceRun() {
long lastModificationTime = 0;
// SERVICE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void serviceRun() {
while (!shouldStop()) {
// SERVICE METHODS
//
- /** {@inheritDoc} */
@Override
protected void serviceRun() {
while (!shouldStop()) {
}
}
- /** {@inheritDoc} */
@Override
protected void serviceStop() {
try {
this.comment = comment;
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("synthetic-access")
public void run() {
// OBJECT METHODS
//
- /** {@inheritDoc} */
@Override
public boolean equals(Object object) {
if ((object == null) || !object.getClass().equals(getClass())) {
return ((truster == null) ? (updateJob.truster == null) : updateJob.truster.equals(truster)) && ((trustee == null) ? (updateJob.trustee == null) : updateJob.trustee.equals(trustee));
}
- /** {@inheritDoc} */
@Override
public int hashCode() {
return getClass().hashCode() ^ ((truster == null) ? 0 : truster.hashCode()) ^ ((trustee == null) ? 0 : trustee.hashCode());
}
- /** {@inheritDoc} */
@Override
public String toString() {
return String.format("%s[truster=%s,trustee=%s]", getClass().getSimpleName(), (truster == null) ? null : truster.getId(), (trustee == null) ? null : trustee.getId());
// OBJECT METHODS
//
- /** {@inheritDoc} */
@Override
public boolean equals(Object object) {
if ((object == null) || !object.getClass().equals(getClass())) {
return updateJob.ownIdentity.equals(ownIdentity) && updateJob.context.equals(context);
}
- /** {@inheritDoc} */
@Override
public int hashCode() {
return getClass().hashCode() ^ ownIdentity.hashCode() ^ context.hashCode();
}
- /** {@inheritDoc} */
@Override
public String toString() {
return String.format("%s[ownIdentity=%s,context=%s]", getClass().getSimpleName(), ownIdentity, context);
super(ownIdentity, context);
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("synthetic-access")
public void run() {
super(ownIdentity, context);
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("synthetic-access")
public void run() {
this.propertyValue = propertyValue;
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("synthetic-access")
public void run() {
// OBJECT METHODS
//
- /** {@inheritDoc} */
@Override
public boolean equals(Object object) {
if ((object == null) || !object.getClass().equals(getClass())) {
return updateJob.ownIdentity.equals(ownIdentity) && updateJob.propertyName.equals(propertyName);
}
- /** {@inheritDoc} */
@Override
public int hashCode() {
return getClass().hashCode() ^ ownIdentity.hashCode() ^ propertyName.hashCode();
}
- /** {@inheritDoc} */
@Override
public String toString() {
return String.format("%s[ownIdentity=%s,propertyName=%s]", getClass().getSimpleName(), ownIdentity, propertyName);
// POSTBUILDER METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public PostBuilder withId(String id) {
this.id = fromNullable(id);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public PostBuilder withTime(long time) {
this.time = of(time);
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public PostBuilder withText(String text) {
this.text = text;
return this;
}
- /**
- * {@inheritDoc}
- */
@Override
public PostBuilder to(Optional<String> recipientId) {
this.recipientId = recipientId;
this.senderId = senderId;
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("unchecked")
public B withId(String id) {
return (B) this;
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("unchecked")
public B withTime(long time) {
return (B) this;
}
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("unchecked")
public B withText(String text) {
// ACCESSORS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getId() {
return id.toString();
}
- /**
- * {@inheritDoc}
- */
@Override
public Sone getSone() {
return database.getSone(soneId).get();
}
- /**
- * {@inheritDocs}
- */
@Override
public Optional<String> getRecipientId() {
return Optional.fromNullable(recipientId);
}
- /**
- * {@inheritDoc}
- */
@Override
public Optional<Sone> getRecipient() {
return database.getSone(recipientId);
}
- /**
- * {@inheritDoc}
- */
@Override
public long getTime() {
return time;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getText() {
return text;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isKnown() {
return known;
}
- /**
- * {@inheritDoc}
- */
@Override
public DefaultPost setKnown(boolean known) {
this.known = known;
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public int hashCode() {
return id.hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object object) {
if (!(object instanceof DefaultPost)) {
return post.id.equals(id);
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return String.format("%s[id=%s,sone=%s,recipient=%s,time=%d,text=%s]", getClass().getName(), id, soneId, recipientId, time, text);
super(database, soneId);
}
- /** {@inheritDoc} */
@Override
public Post build(Optional<PostCreated> postCreated) {
validate();
// ACCESSORS
//
- /** {@inheritDocs} */
@Override
public String getPostId() {
return postId;
}
- /** {@inheritDoc} */
@Override
public Optional<Post> getPost() {
return database.getPost(postId);
this.database = database;
}
- /**
- * {@inheritDoc}
- */
@Override
public PostReply build(Optional<PostReplyCreated> postReplyCreated) {
validate();
this.text = text;
}
- /** {@inheritDoc} */
@Override
public String getId() {
return id;
}
- /** {@inheritDoc} */
@Override
public Sone getSone() {
return database.getSone(soneId).get();
}
- /** {@inheritDoc} */
@Override
public long getTime() {
return time;
}
- /** {@inheritDoc} */
@Override
public String getText() {
return text;
}
- /** {@inheritDoc} */
@Override
public boolean isKnown() {
return known;
}
- /** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
public T setKnown(boolean known) {
// OBJECT METHODS
//
- /** {@inheritDoc} */
@Override
public int hashCode() {
return id.hashCode();
}
- /** {@inheritDoc} */
@Override
public boolean equals(Object object) {
if (!(object instanceof Reply<?>)) {
return reply.getId().equals(id);
}
- /** {@inheritDoc} */
@Override
public String toString() {
return String.format("%s[id=%s,sone=%s,time=%d,text=%s]", getClass().getName(), id, soneId, time, text);
// ACCESSORS
//
- /**
- * Returns the identity of this Sone.
- *
- * @return The identity of this Sone
- */
public String getId() {
return id;
}
- /**
- * Returns the identity of this Sone.
- *
- * @return The identity of this Sone
- */
public Identity getIdentity() {
return identity;
}
- /**
- * Sets the identity of this Sone. The {@link Identity#getId() ID} of the
- * identity has to match this Sone’s {@link #getId()}.
- *
- * @param identity
- * The identity of this Sone
- * @return This Sone (for method chaining)
- * @throws IllegalArgumentException
- * if the ID of the identity does not match this Sone’s ID
- */
public DefaultSone setIdentity(Identity identity) throws IllegalArgumentException {
if (!identity.getId().equals(id)) {
throw new IllegalArgumentException("Identity’s ID does not match Sone’s ID!");
return this;
}
- /**
- * Returns the name of this Sone.
- *
- * @return The name of this Sone
- */
public String getName() {
return (identity != null) ? identity.getNickname() : null;
}
- /**
- * Returns whether this Sone is a local Sone.
- *
- * @return {@code true} if this Sone is a local Sone, {@code false} otherwise
- */
public boolean isLocal() {
return local;
}
- /**
- * Returns the request URI of this Sone.
- *
- * @return The request URI of this Sone
- */
public FreenetURI getRequestUri() {
return (requestUri != null) ? requestUri.setSuggestedEdition(latestEdition) : null;
}
- /**
- * Sets the request URI of this Sone.
- *
- * @param requestUri
- * The request URI of this Sone
- * @return This Sone (for method chaining)
- */
public Sone setRequestUri(FreenetURI requestUri) {
if (this.requestUri == null) {
this.requestUri = requestUri.setKeyType("USK").setDocName("Sone").setMetaString(new String[0]);
return this;
}
- /**
- * Returns the insert URI of this Sone.
- *
- * @return The insert URI of this Sone
- */
public FreenetURI getInsertUri() {
return (insertUri != null) ? insertUri.setSuggestedEdition(latestEdition) : null;
}
- /**
- * Sets the insert URI of this Sone.
- *
- * @param insertUri
- * The insert URI of this Sone
- * @return This Sone (for method chaining)
- */
public Sone setInsertUri(FreenetURI insertUri) {
if (this.insertUri == null) {
this.insertUri = insertUri.setKeyType("USK").setDocName("Sone").setMetaString(new String[0]);
return this;
}
- /**
- * Returns the latest edition of this Sone.
- *
- * @return The latest edition of this Sone
- */
public long getLatestEdition() {
return latestEdition;
}
- /**
- * Sets the latest edition of this Sone. If the given latest edition is not
- * greater than the current latest edition, the latest edition of this Sone is
- * not changed.
- *
- * @param latestEdition
- * The latest edition of this Sone
- */
public void setLatestEdition(long latestEdition) {
if (!(latestEdition > this.latestEdition)) {
logger.log(Level.FINE, String.format("New latest edition %d is not greater than current latest edition %d!", latestEdition, this.latestEdition));
this.latestEdition = latestEdition;
}
- /**
- * Return the time of the last inserted update of this Sone.
- *
- * @return The time of the update (in milliseconds since Jan 1, 1970 UTC)
- */
public long getTime() {
return time;
}
- /**
- * Sets the time of the last inserted update of this Sone.
- *
- * @param time
- * The time of the update (in milliseconds since Jan 1, 1970 UTC)
- * @return This Sone (for method chaining)
- */
public Sone setTime(long time) {
this.time = time;
return this;
}
- /**
- * Returns the status of this Sone.
- *
- * @return The status of this Sone
- */
public SoneStatus getStatus() {
return status;
}
- /**
- * Sets the new status of this Sone.
- *
- * @param status
- * The new status of this Sone
- * @return This Sone
- * @throws IllegalArgumentException
- * if {@code status} is {@code null}
- */
public Sone setStatus(SoneStatus status) {
this.status = checkNotNull(status, "status must not be null");
return this;
}
- /**
- * Returns a copy of the profile. If you want to update values in the profile
- * of this Sone, update the values in the returned {@link Profile} and use
- * {@link #setProfile(Profile)} to change the profile in this Sone.
- *
- * @return A copy of the profile
- */
public Profile getProfile() {
return new Profile(profile);
}
- /**
- * Sets the profile of this Sone. A copy of the given profile is stored so that
- * subsequent modifications of the given profile are not reflected in this
- * Sone!
- *
- * @param profile
- * The profile to set
- */
public void setProfile(Profile profile) {
this.profile = new Profile(profile);
}
- /**
- * Returns the client used by this Sone.
- *
- * @return The client used by this Sone, or {@code null}
- */
public Client getClient() {
return client;
}
- /**
- * Sets the client used by this Sone.
- *
- * @param client
- * The client used by this Sone, or {@code null}
- * @return This Sone (for method chaining)
- */
public Sone setClient(Client client) {
this.client = client;
return this;
}
- /**
- * Returns whether this Sone is known.
- *
- * @return {@code true} if this Sone is known, {@code false} otherwise
- */
public boolean isKnown() {
return known;
}
- /**
- * Sets whether this Sone is known.
- *
- * @param known
- * {@code true} if this Sone is known, {@code false} otherwise
- * @return This Sone
- */
public Sone setKnown(boolean known) {
this.known = known;
return this;
}
- /**
- * Returns all friend Sones of this Sone.
- *
- * @return The friend Sones of this Sone
- */
public List<String> getFriends() {
List<String> friends = new ArrayList<String>(friendSones);
return friends;
}
- /**
- * Returns whether this Sone has the given Sone as a friend Sone.
- *
- * @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(String friendSoneId) {
return friendSones.contains(friendSoneId);
}
- /**
- * Adds the given Sone as a friend Sone.
- *
- * @param friendSone
- * The friend Sone to add
- * @return This Sone (for method chaining)
- */
public Sone addFriend(String friendSone) {
if (!friendSone.equals(id)) {
friendSones.add(friendSone);
return this;
}
- /**
- * Removes the given Sone as a friend Sone.
- *
- * @param friendSoneId
- * The ID of the friend Sone to remove
- * @return This Sone (for method chaining)
- */
public Sone removeFriend(String friendSoneId) {
friendSones.remove(friendSoneId);
return this;
}
- /**
- * Returns the list of posts of this Sone, sorted by time, newest first.
- *
- * @return All posts of this Sone
- */
public List<Post> getPosts() {
List<Post> sortedPosts;
synchronized (this) {
return sortedPosts;
}
- /**
- * Sets all posts of this Sone at once.
- *
- * @param posts
- * The new (and only) posts of this Sone
- * @return This Sone (for method chaining)
- */
public Sone setPosts(Collection<Post> posts) {
synchronized (this) {
this.posts.clear();
return this;
}
- /**
- * Adds the given post to this Sone. The post will not be added if its {@link
- * Post#getSone() Sone} is not this Sone.
- *
- * @param post
- * The post to add
- */
public void addPost(Post post) {
if (post.getSone().equals(this) && posts.add(post)) {
logger.log(Level.FINEST, String.format("Adding %s to “%s”.", post, getName()));
}
}
- /**
- * Removes the given post from this Sone.
- *
- * @param post
- * The post to remove
- */
public void removePost(Post post) {
if (post.getSone().equals(this)) {
posts.remove(post);
}
}
- /**
- * Returns all replies this Sone made.
- *
- * @return All replies this Sone made
- */
public Set<PostReply> getReplies() {
return Collections.unmodifiableSet(replies);
}
- /**
- * Sets all replies of this Sone at once.
- *
- * @param replies
- * The new (and only) replies of this Sone
- * @return This Sone (for method chaining)
- */
public Sone setReplies(Collection<PostReply> replies) {
this.replies.clear();
this.replies.addAll(replies);
return this;
}
- /**
- * Adds a reply to this Sone. If the given reply was not made by this Sone,
- * nothing is added to this Sone.
- *
- * @param reply
- * The reply to add
- */
public void addReply(PostReply reply) {
if (reply.getSone().equals(this)) {
replies.add(reply);
}
}
- /**
- * Removes a reply from this Sone.
- *
- * @param reply
- * The reply to remove
- */
public void removeReply(PostReply reply) {
if (reply.getSone().equals(this)) {
replies.remove(reply);
}
}
- /**
- * Returns the IDs of all liked posts.
- *
- * @return All liked posts’ IDs
- */
public Set<String> getLikedPostIds() {
return Collections.unmodifiableSet(likedPostIds);
}
- /**
- * Sets the IDs of all liked posts.
- *
- * @param likedPostIds
- * All liked posts’ IDs
- * @return This Sone (for method chaining)
- */
public Sone setLikePostIds(Set<String> likedPostIds) {
this.likedPostIds.clear();
this.likedPostIds.addAll(likedPostIds);
return this;
}
- /**
- * Checks whether the given post ID is liked by this Sone.
- *
- * @param postId
- * The ID of the post
- * @return {@code true} if this Sone likes the given post, {@code false}
- * otherwise
- */
public boolean isLikedPostId(String postId) {
return likedPostIds.contains(postId);
}
- /**
- * Adds the given post ID to the list of posts this Sone likes.
- *
- * @param postId
- * The ID of the post
- * @return This Sone (for method chaining)
- */
public Sone addLikedPostId(String postId) {
likedPostIds.add(postId);
return this;
}
- /**
- * Removes the given post ID from the list of posts this Sone likes.
- *
- * @param postId
- * The ID of the post
- * @return This Sone (for method chaining)
- */
public Sone removeLikedPostId(String postId) {
likedPostIds.remove(postId);
return this;
}
- /**
- * Returns the IDs of all liked replies.
- *
- * @return All liked replies’ IDs
- */
public Set<String> getLikedReplyIds() {
return Collections.unmodifiableSet(likedReplyIds);
}
- /**
- * Sets the IDs of all liked replies.
- *
- * @param likedReplyIds
- * All liked replies’ IDs
- * @return This Sone (for method chaining)
- */
public Sone setLikeReplyIds(Set<String> likedReplyIds) {
this.likedReplyIds.clear();
this.likedReplyIds.addAll(likedReplyIds);
return this;
}
- /**
- * Checks whether the given reply ID is liked by this Sone.
- *
- * @param replyId
- * The ID of the reply
- * @return {@code true} if this Sone likes the given reply, {@code false}
- * otherwise
- */
public boolean isLikedReplyId(String replyId) {
return likedReplyIds.contains(replyId);
}
- /**
- * Adds the given reply ID to the list of replies this Sone likes.
- *
- * @param replyId
- * The ID of the reply
- * @return This Sone (for method chaining)
- */
public Sone addLikedReplyId(String replyId) {
likedReplyIds.add(replyId);
return this;
}
- /**
- * Removes the given post ID from the list of replies this Sone likes.
- *
- * @param replyId
- * The ID of the reply
- * @return This Sone (for method chaining)
- */
public Sone removeLikedReplyId(String replyId) {
likedReplyIds.remove(replyId);
return this;
}
- /**
- * Returns the root album that contains all visible albums of this Sone.
- *
- * @return The root album of this Sone
- */
public Album getRootAlbum() {
return rootAlbum;
}
- /**
- * Returns Sone-specific options.
- *
- * @return The options of this Sone
- */
public Options getOptions() {
return options;
}
- /**
- * Sets the options of this Sone.
- *
- * @param options
- * The options of this Sone
- */
/* TODO - remove this method again, maybe add an option provider */
public void setOptions(Options options) {
this.options = options;
// FINGERPRINTABLE METHODS
//
- /** {@inheritDoc} */
@Override
public synchronized String getFingerprint() {
Hasher hash = Hashing.sha256().newHasher();
// INTERFACE Comparable<Sone>
//
- /** {@inheritDoc} */
@Override
public int compareTo(Sone sone) {
return NICE_NAME_COMPARATOR.compare(this, sone);
// OBJECT METHODS
//
- /** {@inheritDoc} */
@Override
public int hashCode() {
return id.hashCode();
}
- /** {@inheritDoc} */
@Override
public boolean equals(Object object) {
if (!(object instanceof Sone)) {
return ((Sone) object).getId().equals(id);
}
- /** {@inheritDoc} */
@Override
public String toString() {
return getClass().getName() + "[identity=" + identity + ",requestUri=" + requestUri + ",insertUri(" + String.valueOf(insertUri).length() + "),friends(" + friendSones.size() + "),posts(" + posts.size() + "),replies(" + replies.size() + "),albums(" + getRootAlbum().getAlbums().size() + ")]";
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.database.Database;
import net.pterodactylus.sone.database.DatabaseException;
-import net.pterodactylus.sone.database.PostBuilder;
import net.pterodactylus.sone.database.PostDatabase;
-import net.pterodactylus.sone.database.PostReplyBuilder;
import net.pterodactylus.sone.database.SoneBuilder;
import net.pterodactylus.util.config.Configuration;
import net.pterodactylus.util.config.ConfigurationException;
// DATABASE METHODS
//
- /**
- * Saves the database.
- *
- * @throws DatabaseException
- * if an error occurs while saving
- */
@Override
public void save() throws DatabaseException {
saveKnownPosts();
// SERVICE METHODS
//
- /** {@inheritDocs} */
@Override
protected void doStart() {
loadKnownPosts();
notifyStarted();
}
- /** {@inheritDocs} */
@Override
protected void doStop() {
try {
// POSTPROVIDER METHODS
//
- /** {@inheritDocs} */
@Override
public Optional<Post> getPost(String postId) {
lock.readLock().lock();
}
}
- /** {@inheritDocs} */
@Override
public Collection<Post> getPosts(String soneId) {
return new HashSet<Post>(getPostsFrom(soneId));
}
- /** {@inheritDocs} */
@Override
public Collection<Post> getDirectedPosts(String recipientId) {
lock.readLock().lock();
// POSTSTORE METHODS
//
- /** {@inheritDocs} */
@Override
public void storePost(Post post) {
checkNotNull(post, "post must not be null");
}
}
- /** {@inheritDocs} */
@Override
public void removePost(Post post) {
checkNotNull(post, "post must not be null");
}
}
- /** {@inheritDocs} */
@Override
public void storePosts(Sone sone, Collection<Post> posts) throws IllegalArgumentException {
checkNotNull(sone, "sone must not be null");
}
}
- /** {@inheritDocs} */
@Override
public void removePosts(Sone sone) {
checkNotNull(sone, "sone must not be null");
// POSTREPLYPROVIDER METHODS
//
- /** {@inheritDocs} */
@Override
public Optional<PostReply> getPostReply(String id) {
lock.readLock().lock();
}
}
- /** {@inheritDocs} */
@Override
public List<PostReply> getReplies(String postId) {
lock.readLock().lock();
// POSTREPLYSTORE METHODS
//
- /** {@inheritDocs} */
@Override
public void storePostReply(PostReply postReply) {
lock.writeLock().lock();
}
}
- /** {@inheritDocs} */
@Override
public void storePostReplies(Sone sone, Collection<PostReply> postReplies) {
checkNotNull(sone, "sone must not be null");
}
}
- /** {@inheritDocs} */
@Override
public void removePostReply(PostReply postReply) {
lock.writeLock().lock();
}
}
- /** {@inheritDocs} */
@Override
public void removePostReplies(Sone sone) {
checkNotNull(sone, "sone must not be null");
import net.pterodactylus.sone.freenet.fcp.FcpException;
import net.pterodactylus.sone.template.SoneAccessor;
-import com.google.common.base.Optional;
-import com.google.common.collect.Collections2;
-
import freenet.node.FSParseException;
import freenet.support.SimpleFieldSet;
+import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
+
/**
* Abstract base implementation of a {@link Command} with Sone-related helper
* methods.
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return getClass().getName() + "[writeAccess=" + writeAccess + "]";
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Sone sone = getSone(parameters, "Sone", true);
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Sone sone = getSone(parameters, "Sone", true);
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Post post = getPost(parameters, "Post");
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
PostReply reply = getReply(parameters, "Reply");
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
return new Response("ListLocalSones", encodeSones(getCore().getLocalSones(), "LocalSones."));
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Post post = getPost(parameters, "Post");
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.fcp.FcpException;
-import com.google.common.base.Optional;
-import com.google.common.collect.Collections2;
-
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
+import com.google.common.base.Optional;
+import com.google.common.collect.Collections2;
+
/**
* Implementation of an FCP interface for other clients or plugins to
* communicate with Sone.
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Sone sone = getSone(parameters, "Sone", true);
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Sone sone = getSone(parameters, "Sone", false);
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.freenet.fcp.FcpException;
-import com.google.common.base.Optional;
-
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
+import com.google.common.base.Optional;
+
/**
* Implements the “GetSone“ FCP command which returns {@link Profile}
* information about a {@link Sone}.
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Sone sone = getSone(parameters, "Sone", false);
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
int startSone = getInt(parameters, "StartSone", 0);
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
Post post = getPost(parameters, "Post");
super(core, true);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) throws FcpException {
PostReply reply = getReply(parameters, "Reply");
super(core);
}
- /**
- * {@inheritDoc}
- */
@Override
public Response execute(SimpleFieldSet parameters, Bucket data, AccessType accessType) {
return new Response("Version", new SimpleFieldSetBuilder().put("Version", SonePlugin.VERSION.toString()).put("ProtocolVersion", 1).get());
this.webInterface = webInterface;
}
- /**
- * {@inheritDoc}
- */
@Override
public String format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
if (parameters.isEmpty()) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public String getValue(String attribute) throws ConfigurationException {
if (!pluginStore.strings.containsKey(attribute)) {
return pluginStore.strings.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void putValue(String attribute, String value) throws ConfigurationException {
pluginStore.strings.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Boolean getBooleanValue(String attribute) throws ConfigurationException {
if (!pluginStore.booleans.containsKey(attribute)) {
return pluginStore.booleans.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setBooleanValue(String attribute, Boolean value) throws ConfigurationException {
pluginStore.booleans.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Double getDoubleValue(String attribute) throws ConfigurationException {
if (!pluginStore.strings.containsKey(attribute)) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void setDoubleValue(String attribute, Double value) throws ConfigurationException {
pluginStore.strings.put(attribute, String.valueOf(value));
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Integer getIntegerValue(String attribute) throws ConfigurationException {
if (!pluginStore.integers.containsKey(attribute)) {
return pluginStore.integers.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setIntegerValue(String attribute, Integer value) throws ConfigurationException {
pluginStore.integers.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public Long getLongValue(String attribute) throws ConfigurationException {
if (!pluginStore.longs.containsKey(attribute)) {
return pluginStore.longs.get(attribute);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setLongValue(String attribute, Long value) throws ConfigurationException {
pluginStore.longs.put(attribute, value);
save();
}
- /**
- * {@inheritDoc}
- */
@Override
public void save() throws ConfigurationException {
try {
import java.io.OutputStream;
import java.nio.charset.Charset;
-import com.db4o.ObjectContainer;
-
import freenet.support.api.Bucket;
+import com.db4o.ObjectContainer;
/**
* {@link Bucket} implementation wrapped around a {@link String}.
this.encoding = encoding;
}
- /**
- * {@inheritDoc}
- */
@Override
public Bucket createShadow() {
return new StringBucket(string);
}
- /**
- * {@inheritDoc}
- */
@Override
public void free() {
/* ignore. */
}
- /**
- * {@inheritDoc}
- */
@Override
public InputStream getInputStream() {
return new ByteArrayInputStream(string.getBytes(encoding));
}
- /**
- * {@inheritDoc}
- */
@Override
public String getName() {
return getClass().getName() + "@" + hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
public OutputStream getOutputStream() {
return null;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isReadOnly() {
return true;
}
- /**
- * {@inheritDoc}
- */
@Override
public void removeFrom(ObjectContainer objectContainer) {
/* ignore. */
}
- /**
- * {@inheritDoc}
- */
@Override
public void setReadOnly() {
/* ignore, it is already read-only. */
}
- /**
- * {@inheritDoc}
- */
@Override
public long size() {
return string.getBytes(encoding).length;
}
- /**
- * {@inheritDoc}
- */
@Override
public void storeTo(ObjectContainer objectContainer) {
/* ignore. */
import net.pterodactylus.sone.freenet.plugin.event.ReceivedReplyEvent;
-import com.google.common.eventbus.EventBus;
-import com.google.inject.Inject;
-
import freenet.pluginmanager.FredPluginTalker;
import freenet.pluginmanager.PluginNotFoundException;
import freenet.pluginmanager.PluginRespirator;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
+import com.google.common.eventbus.EventBus;
+import com.google.inject.Inject;
+
/**
* Interface for talking to other plugins. Other plugins are identified by their
* name and a unique connection identifier.
// INTERFACE FredPluginTalker
//
- /**
- * {@inheritDoc}
- */
@Override
public void onReply(String pluginName, String identifier, SimpleFieldSet params, Bucket data) {
eventBus.post(new ReceivedReplyEvent(this, pluginName, identifier, params, data));
// ACCESSORS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getId() {
return id;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getNickname() {
return nickname;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getRequestUri() {
return requestUri;
}
- /**
- * {@inheritDoc}
- */
@Override
public Set<String> getContexts() {
return Collections.unmodifiableSet(contexts);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean hasContext(String context) {
return contexts.contains(context);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setContexts(Collection<String> contexts) {
this.contexts.clear();
this.contexts.addAll(contexts);
}
- /**
- * {@inheritDoc}
- */
@Override
public void addContext(String context) {
contexts.add(context);
}
- /**
- * {@inheritDoc}
- */
@Override
public void removeContext(String context) {
contexts.remove(context);
}
- /**
- * {@inheritDoc}
- */
@Override
public Map<String, String> getProperties() {
return Collections.unmodifiableMap(properties);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setProperties(Map<String, String> properties) {
this.properties.clear();
this.properties.putAll(properties);
}
- /**
- * {@inheritDoc}
- */
@Override
public String getProperty(String name) {
return properties.get(name);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setProperty(String name, String value) {
properties.put(name, value);
}
- /**
- * {@inheritDoc}
- */
@Override
public void removeProperty(String name) {
properties.remove(name);
}
- /**
- * {@inheritDoc}
- */
@Override
public Trust getTrust(OwnIdentity ownIdentity) {
return trustCache.get(ownIdentity);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setTrust(OwnIdentity ownIdentity, Trust trust) {
trustCache.put(ownIdentity, trust);
}
- /**
- * {@inheritDoc}
- */
@Override
public void removeTrust(OwnIdentity ownIdentity) {
trustCache.remove(ownIdentity);
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public int hashCode() {
return getId().hashCode();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object object) {
if (!(object instanceof Identity)) {
return identity.getId().equals(getId());
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return getClass().getSimpleName() + "[id=" + id + ",nickname=" + nickname + ",contexts=" + contexts + ",properties=" + properties + "]";
// ACCESSORS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getInsertUri() {
return insertUri;
// SERVICE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void serviceRun() {
Map<OwnIdentity, Map<String, Identity>> oldIdentities = Collections.emptyMap();
return distance;
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return getClass().getName() + "[explicit=" + explicit + ",implicit=" + implicit + ",distance=" + distance + "]";
import net.pterodactylus.util.logging.LoggingListener;
import net.pterodactylus.util.version.Version;
-import com.google.common.eventbus.EventBus;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Singleton;
-import com.google.inject.TypeLiteral;
-import com.google.inject.matcher.Matchers;
-import com.google.inject.name.Names;
-import com.google.inject.spi.InjectionListener;
-import com.google.inject.spi.TypeEncounter;
-import com.google.inject.spi.TypeListener;
-
import freenet.client.async.DatabaseDisabledException;
import freenet.l10n.BaseL10n.LANGUAGE;
import freenet.l10n.PluginL10n;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
+import com.google.common.eventbus.EventBus;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+import com.google.inject.matcher.Matchers;
+import com.google.inject.name.Names;
+import com.google.inject.spi.InjectionListener;
+import com.google.inject.spi.TypeEncounter;
+import com.google.inject.spi.TypeListener;
+
/**
* This class interfaces with Freenet. It is the class that is loaded by the
* node and starts up the whole Sone system.
// FREDPLUGIN METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public void runPlugin(PluginRespirator pluginRespirator) {
this.pluginRespirator = pluginRespirator;
}
}
- /**
- * {@inheritDoc}
- */
@Override
public void terminate() {
try {
// INTERFACE FredPluginFCP
//
- /**
- * {@inheritDoc}
- */
@Override
public void handle(PluginReplySender pluginReplySender, SimpleFieldSet parameters, Bucket data, int accessType) {
fcpInterface.handle(pluginReplySender, parameters, data, accessType);
// INTERFACE FredPluginL10n
//
- /**
- * {@inheritDoc}
- */
@Override
public String getString(String key) {
return l10n.getBase().getString(key);
}
- /**
- * {@inheritDoc}
- */
@Override
public void setLanguage(LANGUAGE newLanguage) {
l10n = new PluginL10n(this, newLanguage);
// INTERFACE FredPluginBaseL10n
//
- /**
- * {@inheritDoc}
- */
@Override
public String getL10nFilesBasePath() {
return "i18n";
}
- /**
- * {@inheritDoc}
- */
@Override
public String getL10nFilesMask() {
return "sone.${lang}.properties";
}
- /**
- * {@inheritDoc}
- */
@Override
public String getL10nOverrideFilesMask() {
return "sone.${lang}.override.properties";
}
- /**
- * {@inheritDoc}
- */
@Override
public ClassLoader getPluginClassLoader() {
return SonePlugin.class.getClassLoader();
// INTERFACE FredPluginVersioned
//
- /**
- * {@inheritDoc}
- */
@Override
public String getVersion() {
return VERSION.toString();
// ABSTRACTNOTIFICATION METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public void dismiss() {
super.dismiss();
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public int hashCode() {
int hashCode = super.hashCode();
return hashCode;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object object) {
if (!(object instanceof ListNotification)) {
*/
public class AlbumAccessor extends ReflectionAccessor {
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Album album = (Album) object;
*/
public class CollectionAccessor extends ReflectionAccessor {
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
if (object == null) {
*/
public class CssClassNameFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
return String.valueOf(data).replaceAll("[^a-zA-Z0-9-]", "_");
*/
public class GetPagePlugin implements Plugin {
- /**
- * {@inheritDoc}
- */
@Override
public void execute(TemplateContext templateContext, Map<String, String> parameters) {
String requestKey = parameters.get("request");
*/
public class HttpRequestAccessor extends ReflectionAccessor {
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Object parentValue = super.get(templateContext, object, member);
this.core = core;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Identity identity = (Identity) object;
*/
public class ImageAccessor extends ReflectionAccessor {
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Image image = (Image) object;
this.templateContextFactory = templateContextFactory;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
Image image = null;
*/
public class JavascriptFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
StringBuilder javascriptString = new StringBuilder();
this.soneTextParser = soneTextParser;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
String text = String.valueOf(data);
this.core = core;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Post post = (Post) object;
this.core = core;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Profile profile = (Profile) object;
this.core = core;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
PostReply reply = (PostReply) object;
*/
public class ReplyGroupFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
@SuppressWarnings("unchecked")
*/
public class RequestChangeFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
FreenetRequest request = (FreenetRequest) data;
this.core = core;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Sone sone = (Sone) object;
*/
public class SubstringFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
String startString = String.valueOf(parameters.get("start"));
*/
public class TrustAccessor extends ReflectionAccessor {
- /**
- * {@inheritDoc}
- */
@Override
public Object get(TemplateContext templateContext, Object object, String member) {
Trust trust = (Trust) object;
*/
public class UniqueElementFilter implements Filter {
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
if (!(data instanceof Collection<?>)) {
this.unknownKey = unknownKey;
}
- /**
- * {@inheritDoc}
- */
@Override
public Object format(TemplateContext templateContext, Object data, Map<String, Object> parameters) {
if (data instanceof Long) {
// PART METHODS
//
- /**
- * Returns the text of this part.
- *
- * @return The text of this part
- */
@Override
public String getText() {
return text;
// PART METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getText() {
StringBuilder partText = new StringBuilder();
// ITERABLE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("synthetic-access")
public Iterator<Part> iterator() {
// PART METHODS
//
- /**
- * Returns the text of this part.
- *
- * @return The text of this part
- */
@Override
public String getText() {
return text;
// PART METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getText() {
return post.getText();
// PART METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getText() {
return SoneAccessor.getNiceName(sone);
// PART METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public Iterable<Part> parse(SoneTextParserContext context, Reader source) throws IOException {
PartContainer parts = new PartContainer();
// PREDICATE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public boolean apply(Integer value) {
return (value != null) && (value >= lowerBound) && (value <= upperBound);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPATH METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
super("deleteAlbum.html", template, "Page.DeleteAlbum.Title", webInterface, true);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
package net.pterodactylus.sone.web;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
+import com.google.common.base.Optional;
+
/**
* Lets the user delete a post they made.
*
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
package net.pterodactylus.sone.web;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
+import com.google.common.base.Optional;
+
/**
* Page that lets the user distrust another Sone. This will assign a
* configurable (negative) amount of trust to an identity.
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
super("editAlbum.html", template, "Page.EditAlbum.Title", webInterface, true);
}
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
package net.pterodactylus.sone.web;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
+import com.google.common.base.Optional;
+
/**
* This page lets the user follow another Sone.
*
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
this.webInterface = webInterface;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getPath() {
return "getImage.html";
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isPrefixPage() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public Response handleRequest(FreenetRequest request, Response response) throws IOException {
String imageId = request.getHttpRequest().getParam("image");
return response.setStatusCode(200).setStatusText("OK").setContentType(contentType).addHeader("Content-Disposition", "attachment; filename=" + temporaryImage.getId() + "." + contentType.substring(contentType.lastIndexOf('/') + 1)).write(temporaryImage.getImageData());
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return false;
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
templateContext.set("sone", sone);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return true;
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
templateContext.set("identitiesWithoutSone", ownIdentitiesWithoutSone);
}
- /**
- * {@inheritDoc}
- */
@Override
protected String getRedirectTarget(FreenetRequest request) {
if (getCurrentSone(request.getToadletContext(), false) != null) {
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
setCurrentSone(request.getToadletContext(), null);
throw new RedirectException("index.html");
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
import java.util.List;
import java.util.Set;
-import com.google.common.collect.Collections2;
-
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.notify.ListNotificationFilters;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
+import com.google.common.collect.Collections2;
+
/**
* Page that displays all new posts and replies. The posts are filtered using
* {@link ListNotificationFilters#filterPosts(java.util.Collection, net.pterodactylus.sone.data.Sone)}
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
@SuppressWarnings("synthetic-access")
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
this.complete = complete;
}
- /**
- * {@inheritDoc}
- */
@Override
public String generateString(Sone sone) {
StringBuilder soneString = new StringBuilder();
*/
private class PostStringGenerator implements StringGenerator<Post> {
- /**
- * {@inheritDoc}
- */
@Override
public String generateString(Post post) {
StringBuilder postString = new StringBuilder();
// OBJECT METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public int hashCode() {
return phrase.hashCode() ^ ((optionality == Optionality.FORBIDDEN) ? (0xaaaaaaaa) : ((optionality == Optionality.REQUIRED) ? 0x55555555 : 0));
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean equals(Object object) {
if (!(object instanceof Phrase)) {
*/
private static class HitMapper<T> implements Function<Hit<T>, T> {
- /**
- * {@inheritDoc}
- */
@Override
public T apply(Hit<T> input) {
return input.getObject();
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
import freenet.clients.http.SessionManager.Session;
import freenet.clients.http.ToadletContext;
import freenet.support.api.HTTPRequest;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
/**
* Base page for the Sone web interface.
*
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected String getPageTitle(FreenetRequest request) {
if (pageTitleKey != null) {
return "";
}
- /**
- * {@inheritDoc}
- */
@Override
protected List<Map<String, String>> getAdditionalLinkNodes(FreenetRequest request) {
return ImmutableList.<Map<String, String>> builder().add(ImmutableMap.<String, String> builder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").build()).build();
}
- /**
- * {@inheritDoc}
- */
@Override
protected Collection<String> getStyleSheets() {
return Arrays.asList("css/sone.css");
}
- /**
- * {@inheritDoc}
- */
@Override
protected String getShortcutIcon() {
return "images/icon.png";
return requireLogin;
}
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
templateContext.set("notificationHash", notifications.hashCode());
}
- /**
- * {@inheritDoc}
- */
@Override
protected String getRedirectTarget(FreenetRequest request) {
if (requiresLogin() && (getCurrentSone(request.getToadletContext(), false) == null)) {
return null;
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean isFullAccessOnly() {
return webInterface.getCore().getPreferences().isRequireFullAccess();
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !toadletContext.isAllowedFullAccess()) {
package net.pterodactylus.sone.web;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
+import com.google.common.base.Optional;
+
/**
* Page that lets the user trust another Sone. This will assign a configurable
* amount of trust to an identity.
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
package net.pterodactylus.sone.web;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
+import com.google.common.base.Optional;
+
/**
* Page that lets the user untrust another Sone. This will remove all trust
* assignments for an identity.
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
// SONETEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
import java.net.URI;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.template.SoneAccessor;
import net.pterodactylus.sone.web.page.FreenetRequest;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
+import com.google.common.base.Optional;
+
/**
* This page lets the user view a post and all its replies.
*
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected String getPageTitle(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
return title;
}
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
templateContext.set("raw", raw);
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return true;
// TEMPLATEPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected String getPageTitle(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
return webInterface.getL10n().getString("Page.ViewSone.Page.TitleWithoutSone");
}
- /**
- * {@inheritDoc}
- */
@Override
protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException {
super.processTemplate(request, templateContext);
templateContext.set("repliedPosts", repliedPostPagination.getItems());
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return true;
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String id = request.getHttpRequest().getParam("post", null);
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
super("createPost.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone sone = getCurrentSone(request.getToadletContext());
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* This AJAX page deletes a post.
*
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
super("deleteProfileField.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String fieldId = request.getHttpRequest().getParam("field");
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* This AJAX page deletes a reply.
*
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String replyId = request.getHttpRequest().getParam("reply");
super("dismissNotification.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String notificationId = request.getHttpRequest().getParam("notification");
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* AJAX page that lets the user distrust a Sone.
*
super("distrustSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext(), false);
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String albumId = request.getHttpRequest().getParam("album");
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String imageId = request.getHttpRequest().getParam("image");
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String fieldId = request.getHttpRequest().getParam("field");
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* AJAX page that lets a Sone follow another Sone.
*
super("followSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type", null);
return createErrorJsonObject("invalid-type");
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext(), false);
package net.pterodactylus.sone.web.ajax;
-import java.io.StringWriter;
import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance;
-import com.google.common.base.Optional;
+import java.io.StringWriter;
import net.pterodactylus.sone.data.Post;
import net.pterodactylus.sone.data.Sone;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Optional;
/**
* This AJAX handler retrieves information and rendered representation of a
this.postTemplate = postTemplate;
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String postId = request.getHttpRequest().getParam("post");
return createSuccessJsonObject().put("post", createJsonPost(request, post.get(), getCurrentSone(request.getToadletContext())));
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
package net.pterodactylus.sone.web.ajax;
-import java.io.StringWriter;
import static com.fasterxml.jackson.databind.node.JsonNodeFactory.instance;
-import com.google.common.base.Optional;
+import java.io.StringWriter;
import net.pterodactylus.sone.data.PostReply;
import net.pterodactylus.sone.data.Sone;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.base.Optional;
/**
* This AJAX page returns the details of a reply.
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String replyId = request.getHttpRequest().getParam("reply");
return createSuccessJsonObject().put("reply", createJsonReply(request, reply.get(), getCurrentSone(request.getToadletContext())));
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
super("getStatus.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
final Sone currentSone = getCurrentSone(request.getToadletContext(), false);
return createSuccessJsonObject().put("loggedIn", currentSone != null).put("options", createJsonOptions(currentSone)).put("sones", jsonSones).put("notificationHash", notifications.hashCode()).put("newPosts", jsonPosts).put("newReplies", jsonReplies);
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
super("getTimes.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String allIds = request.getHttpRequest().getParam("posts");
return createSuccessJsonObject().put("postTimes", postTimes).put("replyTimes", replyTimes);
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String key = request.getHttpRequest().getParam("key");
return createSuccessJsonObject().put("value", translation);
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean needsFormPassword() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
import net.pterodactylus.util.web.Page;
import net.pterodactylus.util.web.Response;
-import com.fasterxml.jackson.databind.ObjectMapper;
import freenet.clients.http.SessionManager.Session;
import freenet.clients.http.ToadletContext;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
/**
* A JSON page is a specialized {@link Page} that will always return a JSON
* object to the browser, e.g. for use with AJAX or other scripting frameworks.
// PAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public String getPath() {
return path;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isPrefixPage() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public Response handleRequest(FreenetRequest request, Response response) throws IOException {
if (webInterface.getCore().getPreferences().isRequireFullAccess() && !request.getToadletContext().isAllowedFullAccess()) {
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return false;
super("like.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type", null);
super("lockSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
super("markAsKnown.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type");
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext());
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* AJAX page that lets the user trust a Sone.
*
super("trustSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext(), false);
// JSONPAGE METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String id = request.getHttpRequest().getParam("post", null);
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
super("unfollowSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
super("unlike.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String type = request.getHttpRequest().getParam("type", null);
super("unlockSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
String soneId = request.getHttpRequest().getParam("sone");
return createSuccessJsonObject();
}
- /**
- * {@inheritDoc}
- */
@Override
protected boolean requiresLogin() {
return false;
package net.pterodactylus.sone.web.ajax;
-import com.google.common.base.Optional;
-
import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.WebInterface;
import net.pterodactylus.sone.web.page.FreenetRequest;
+import com.google.common.base.Optional;
+
/**
* AJAX page that lets the user untrust a Sone.
*
super("untrustSone.ajax", webInterface);
}
- /**
- * {@inheritDoc}
- */
@Override
protected JsonReturnObject createJsonObject(FreenetRequest request) {
Sone currentSone = getCurrentSone(request.getToadletContext(), false);
this.invalidFormPasswordRedirectTarget = invalidFormPasswordRedirectTarget;
}
- /**
- * {@inheritDoc}
- */
@Override
public String getPath() {
return path;
return null;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isPrefixPage() {
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public Response handleRequest(FreenetRequest request, Response response) throws IOException {
String redirectTarget = getRedirectTarget(request);
return false;
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return false;
// INTERFACE LinkEnabledCallback
//
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
return !isFullAccessOnly();
return menuName;
}
- /**
- * {@inheritDoc}
- */
@Override
public String path() {
return pathPrefix + page.getPath();
handleRequest(new FreenetRequest(uri, Method.POST, httpRequest, toadletContext));
}
- /**
- * {@inheritDoc}
- */
@Override
public String toString() {
return getClass().getName() + "[path=" + path() + ",page=" + page + "]";
}
}
- /**
- * {@inheritDoc}
- */
@Override
public boolean isEnabled(ToadletContext toadletContext) {
if (page instanceof LinkEnabledCallback) {
// LINKFILTEREXCEPTEDTOADLET METHODS
//
- /**
- * {@inheritDoc}
- */
@Override
public boolean isLinkExcepted(URI link) {
return (page instanceof FreenetPage) ? ((FreenetPage) page).isLinkExcepted(link) : false;