Update blog backend to match current usage

This commit is contained in:
Torsten Grote
2016-10-27 12:55:54 -02:00
parent a18317e912
commit 9e553ef9c8
28 changed files with 154 additions and 386 deletions

View File

@@ -7,14 +7,14 @@ import org.briarproject.api.clients.ClientHelper;
import org.briarproject.api.data.BdfList;
import org.briarproject.api.identity.Author;
import org.briarproject.api.identity.AuthorFactory;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.Group;
import org.briarproject.api.sync.GroupFactory;
import org.jetbrains.annotations.NotNull;
import javax.inject.Inject;
import static org.briarproject.api.blogs.BlogConstants.PERSONAL_BLOG_NAME;
@NotNullByDefault
class BlogFactoryImpl implements BlogFactory {
private final GroupFactory groupFactory;
@@ -31,39 +31,29 @@ class BlogFactoryImpl implements BlogFactory {
}
@Override
public Blog createPersonalBlog(@NotNull Author a) {
return createBlog(PERSONAL_BLOG_NAME, "", a);
}
@Override
public Blog createBlog(@NotNull String name, @NotNull String description,
@NotNull Author author) {
public Blog createBlog(Author a) {
try {
BdfList blog = BdfList.of(
name,
author.getName(),
author.getPublicKey()
a.getName(),
a.getPublicKey()
);
byte[] descriptor = clientHelper.toByteArray(blog);
Group g = groupFactory
.createGroup(BlogManagerImpl.CLIENT_ID, descriptor);
return new Blog(g, name, description, author);
return new Blog(g, a);
} catch (FormatException e) {
throw new RuntimeException(e);
}
}
@Override
public Blog parseBlog(@NotNull Group g, @NotNull String description)
throws FormatException {
public Blog parseBlog(@NotNull Group g) throws FormatException {
byte[] descriptor = g.getDescriptor();
// Blog Name, Author Name, Public Key
// Author Name, Public Key
BdfList blog = clientHelper.toList(descriptor);
String name = blog.getString(0);
Author a =
authorFactory.createAuthor(blog.getString(1), blog.getRaw(2));
return new Blog(g, name, description, a);
authorFactory.createAuthor(blog.getString(0), blog.getRaw(1));
return new Blog(g, a);
}
}

View File

@@ -58,7 +58,6 @@ import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR;
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_ID;
import static org.briarproject.api.blogs.BlogConstants.KEY_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.KEY_COMMENT;
import static org.briarproject.api.blogs.BlogConstants.KEY_DESCRIPTION;
import static org.briarproject.api.blogs.BlogConstants.KEY_ORIGINAL_MSG_ID;
import static org.briarproject.api.blogs.BlogConstants.KEY_ORIGINAL_PARENT_MSG_ID;
import static org.briarproject.api.blogs.BlogConstants.KEY_PARENT_MSG_ID;
@@ -113,16 +112,14 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
@Override
public void createLocalState(Transaction txn) throws DbException {
// Ensure every identity does have its own personal blog
// TODO this can probably be removed once #446 is resolved and all users migrated to a new version
for (LocalAuthor a : db.getLocalAuthors(txn)) {
Blog b = blogFactory.createPersonalBlog(a);
Group g = b.getGroup();
if (!db.containsGroup(txn, g.getId())) {
db.addGroup(txn, g);
for (ContactId c : db.getContacts(txn, a.getId())) {
db.setVisibleToContact(txn, c, g.getId(), true);
}
// Ensure that the local identity has its own personal blog
LocalAuthor la = identityManager.getLocalAuthor(txn);
Blog b = blogFactory.createBlog(la);
Group g = b.getGroup();
if (!db.containsGroup(txn, g.getId())) {
db.addGroup(txn, g);
for (ContactId c : db.getContacts(txn, la.getId())) {
db.setVisibleToContact(txn, c, g.getId(), true);
}
}
// Ensure that we have the personal blogs of all pre-existing contacts
@@ -132,7 +129,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
@Override
public void addingContact(Transaction txn, Contact c) throws DbException {
// get personal blog of the contact
Blog b = blogFactory.createPersonalBlog(c.getAuthor());
Blog b = blogFactory.createBlog(c.getAuthor());
Group g = b.getGroup();
if (!db.containsGroup(txn, g.getId())) {
// add the personal blog of the contact
@@ -141,7 +138,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
// share our personal blog with the new contact
LocalAuthor a = db.getLocalAuthor(txn, c.getLocalAuthorId());
Blog b2 = blogFactory.createPersonalBlog(a);
Blog b2 = blogFactory.createBlog(a);
db.setVisibleToContact(txn, c.getId(), b2.getId(), true);
}
}
@@ -149,7 +146,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
@Override
public void removingContact(Transaction txn, Contact c) throws DbException {
if (c != null) {
Blog b = blogFactory.createPersonalBlog(c.getAuthor());
Blog b = blogFactory.createBlog(c.getAuthor());
db.removeGroup(txn, b.getGroup());
}
}
@@ -160,7 +157,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
// add a personal blog for the new identity
LOG.info("New Personal Blog Added.");
Blog b = blogFactory.createPersonalBlog(a);
Blog b = blogFactory.createBlog(a);
db.addGroup(txn, b.getGroup());
}
@@ -169,7 +166,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
throws DbException {
// remove the personal blog of that identity
Blog b = blogFactory.createPersonalBlog(a);
Blog b = blogFactory.createBlog(a);
db.removeGroup(txn, b.getGroup());
}
@@ -219,29 +216,6 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
return false;
}
@Override
public Blog addBlog(LocalAuthor localAuthor, String name,
String description) throws DbException {
Blog b = blogFactory
.createBlog(name, description, localAuthor);
BdfDictionary metadata = BdfDictionary.of(
new BdfEntry(KEY_DESCRIPTION, b.getDescription())
);
Transaction txn = db.startTransaction(false);
try {
db.addGroup(txn, b.getGroup());
clientHelper.mergeGroupMetadata(txn, b.getId(), metadata);
txn.setComplete();
} catch (FormatException e) {
throw new DbException(e);
} finally {
db.endTransaction(txn);
}
return b;
}
@Override
public boolean canBeRemoved(GroupId g) throws DbException {
Transaction txn = db.startTransaction(true);
@@ -453,8 +427,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
public Blog getBlog(Transaction txn, GroupId g) throws DbException {
try {
Group group = db.getGroup(txn, g);
String description = getBlogDescription(txn, g);
return blogFactory.parseBlog(group, description);
return blogFactory.parseBlog(group);
} catch (FormatException e) {
throw new DbException(e);
}
@@ -476,7 +449,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
@Override
public Blog getPersonalBlog(Author author) {
return blogFactory.createPersonalBlog(author);
return blogFactory.createBlog(author);
}
@Override
@@ -488,8 +461,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
try {
groups = db.getGroups(txn, CLIENT_ID);
for (Group g : groups) {
String description = getBlogDescription(txn, g.getId());
blogs.add(blogFactory.parseBlog(g, description));
blogs.add(blogFactory.parseBlog(g));
}
txn.setComplete();
} finally {
@@ -613,12 +585,6 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
removeHooks.add(hook);
}
private String getBlogDescription(Transaction txn, GroupId g)
throws DbException, FormatException {
BdfDictionary d = clientHelper.getGroupMetadataAsDictionary(txn, g);
return d.getString(KEY_DESCRIPTION, "");
}
private BlogPostHeader getPostHeaderFromMetadata(Transaction txn,
GroupId groupId, MessageId id) throws DbException, FormatException {
BdfDictionary meta =

View File

@@ -100,7 +100,7 @@ class BlogPostValidator extends BdfMessageValidator {
byte[] sig = body.getRaw(1);
checkLength(sig, 1, MAX_SIGNATURE_LENGTH);
BdfList signed = BdfList.of(g.getId(), m.getTimestamp(), postBody);
Blog b = blogFactory.parseBlog(g, ""); // description doesn't matter
Blog b = blogFactory.parseBlog(g);
Author a = b.getAuthor();
try {
clientHelper.verifySignature(sig, a.getPublicKey(), signed);
@@ -145,7 +145,7 @@ class BlogPostValidator extends BdfMessageValidator {
BdfList signed =
BdfList.of(g.getId(), m.getTimestamp(), comment, pOriginalId,
currentId);
Blog b = blogFactory.parseBlog(g, ""); // description doesn't matter
Blog b = blogFactory.parseBlog(g);
Author a = b.getAuthor();
try {
clientHelper.verifySignature(sig, a.getPublicKey(), signed);

View File

@@ -3,53 +3,40 @@ package org.briarproject.sharing;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.data.BdfDictionary;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
@NotThreadSafe
@NotNullByDefault
public class BlogInviteeSessionState extends InviteeSessionState {
private final String blogTitle;
private final String blogDesc;
private final String blogAuthorName;
private final byte[] blogPublicKey;
public BlogInviteeSessionState(SessionId sessionId, MessageId storageId,
GroupId groupId, State state, ContactId contactId, GroupId blogId,
String blogTitle, String blogDesc, String blogAuthorName,
byte[] blogPublicKey, @NotNull MessageId invitationId) {
String blogAuthorName, byte[] blogPublicKey,
@NotNull MessageId invitationId) {
super(sessionId, storageId, groupId, state, contactId, blogId,
invitationId);
this.blogTitle = blogTitle;
this.blogDesc = blogDesc;
this.blogAuthorName = blogAuthorName;
this.blogPublicKey = blogPublicKey;
}
public BdfDictionary toBdfDictionary() {
BdfDictionary d = super.toBdfDictionary();
d.put(BLOG_TITLE, getBlogTitle());
d.put(BLOG_DESC, getBlogDesc());
d.put(BLOG_AUTHOR_NAME, getBlogAuthorName());
d.put(BLOG_PUBLIC_KEY, getBlogPublicKey());
return d;
}
public String getBlogTitle() {
return blogTitle;
}
public String getBlogDesc() {
return blogDesc;
}
public String getBlogAuthorName() {
return blogAuthorName;
}

View File

@@ -3,52 +3,41 @@ package org.briarproject.sharing;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.data.BdfDictionary;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.Nullable;
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
import javax.annotation.concurrent.NotThreadSafe;
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
@NotThreadSafe
@NotNullByDefault
public class BlogSharerSessionState extends SharerSessionState {
private final String blogTitle;
private final String blogDesc;
private final String blogAuthorName;
private final byte[] blogPublicKey;
public BlogSharerSessionState(SessionId sessionId, MessageId storageId,
GroupId groupId, State state, ContactId contactId, GroupId blogId,
String blogTitle, String blogDesc, String blogAuthorName,
byte[] blogPublicKey, @Nullable MessageId responseId) {
String blogAuthorName,byte[] blogPublicKey,
@Nullable MessageId responseId) {
super(sessionId, storageId, groupId, state, contactId, blogId,
responseId);
this.blogTitle = blogTitle;
this.blogDesc = blogDesc;
this.blogAuthorName = blogAuthorName;
this.blogPublicKey = blogPublicKey;
}
public BdfDictionary toBdfDictionary() {
BdfDictionary d = super.toBdfDictionary();
d.put(BLOG_TITLE, getBlogTitle());
d.put(BLOG_DESC, getBlogDesc());
d.put(BLOG_AUTHOR_NAME, getBlogAuthorName());
d.put(BLOG_PUBLIC_KEY, getBlogPublicKey());
return d;
}
public String getBlogTitle() {
return blogTitle;
}
public String getBlogDesc() {
return blogDesc;
}
public String getBlogAuthorName() {
return blogAuthorName;
}

View File

@@ -40,9 +40,7 @@ import java.security.SecureRandom;
import javax.inject.Inject;
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
import static org.briarproject.api.sharing.SharingConstants.INVITATION_ID;
import static org.briarproject.api.sharing.SharingConstants.RESPONSE_ID;
@@ -54,8 +52,7 @@ class BlogSharingManagerImpl extends
"bee438b5de0b3a685badc4e49d76e72d"
+ "21e01c4b569a775112756bdae267a028"));
@Inject
IdentityManager identityManager;
private final IdentityManager identityManager;
private final BlogManager blogManager;
private final SFactory sFactory;
@@ -70,12 +67,14 @@ class BlogSharingManagerImpl extends
BlogManager blogManager, ClientHelper clientHelper, Clock clock,
DatabaseComponent db, MessageQueueManager messageQueueManager,
MetadataEncoder metadataEncoder, MetadataParser metadataParser,
ContactGroupFactory contactGroupFactory, SecureRandom random) {
ContactGroupFactory contactGroupFactory, SecureRandom random,
IdentityManager identityManager) {
super(db, messageQueueManager, clientHelper, metadataParser,
metadataEncoder, random, contactGroupFactory, clock);
this.blogManager = blogManager;
this.identityManager = identityManager;
sFactory = new SFactory(authorFactory, blogFactory, blogManager);
iFactory = new IFactory();
isFactory = new ISFactory();
@@ -175,9 +174,12 @@ class BlogSharingManagerImpl extends
@Override
public BdfList encode(Blog f) {
return BdfList.of(f.getName(), f.getDescription(),
BdfList.of(f.getAuthor().getName(),
f.getAuthor().getPublicKey()));
return BdfList.of(
BdfList.of(
f.getAuthor().getName(),
f.getAuthor().getPublicKey()
)
);
}
@Override
@@ -189,19 +191,16 @@ class BlogSharingManagerImpl extends
@Override
public Blog parse(BdfList shareable) throws FormatException {
Author author = authorFactory
.createAuthor(shareable.getList(2).getString(0),
shareable.getList(2).getRaw(1));
return blogFactory
.createBlog(shareable.getString(0), shareable.getString(1),
author);
.createAuthor(shareable.getList(0).getString(0),
shareable.getList(0).getRaw(1));
return blogFactory.createBlog(author);
}
@Override
public Blog parse(BlogInvitation msg) {
Author author = authorFactory.createAuthor(msg.getBlogAuthorName(),
msg.getBlogPublicKey());
return blogFactory
.createBlog(msg.getBlogTitle(), msg.getBlogDesc(), author);
return blogFactory.createBlog(author);
}
@Override
@@ -209,9 +208,7 @@ class BlogSharingManagerImpl extends
Author author = authorFactory
.createAuthor(state.getBlogAuthorName(),
state.getBlogPublicKey());
return blogFactory
.createBlog(state.getBlogTitle(), state.getBlogDesc(),
author);
return blogFactory.createBlog(author);
}
@Override
@@ -219,9 +216,7 @@ class BlogSharingManagerImpl extends
Author author = authorFactory
.createAuthor(state.getBlogAuthorName(),
state.getBlogPublicKey());
return blogFactory
.createBlog(state.getBlogTitle(), state.getBlogDesc(),
author);
return blogFactory.createBlog(author);
}
}
@@ -237,8 +232,7 @@ class BlogSharingManagerImpl extends
public BlogInvitation build(BlogSharerSessionState localState,
long time) {
return new BlogInvitation(localState.getGroupId(),
localState.getSessionId(), localState.getBlogTitle(),
localState.getBlogDesc(), localState.getBlogAuthorName(),
localState.getSessionId(), localState.getBlogAuthorName(),
localState.getBlogPublicKey(), time,
localState.getMessage());
}
@@ -251,14 +245,12 @@ class BlogSharingManagerImpl extends
MessageId storageId, GroupId groupId,
InviteeSessionState.State state, ContactId contactId,
GroupId blogId, BdfDictionary d) throws FormatException {
String blogTitle = d.getString(BLOG_TITLE);
String blogDesc = d.getString(BLOG_DESC);
String blogAuthorName = d.getString(BLOG_AUTHOR_NAME);
byte[] blogPublicKey = d.getRaw(BLOG_PUBLIC_KEY);
MessageId invitationId = new MessageId(d.getRaw(INVITATION_ID));
return new BlogInviteeSessionState(sessionId, storageId,
groupId, state, contactId, blogId, blogTitle, blogDesc,
blogAuthorName, blogPublicKey, invitationId);
groupId, state, contactId, blogId, blogAuthorName,
blogPublicKey, invitationId);
}
@Override
@@ -267,9 +259,9 @@ class BlogSharingManagerImpl extends
InviteeSessionState.State state, ContactId contactId,
Blog blog, MessageId invitationId) {
return new BlogInviteeSessionState(sessionId, storageId,
groupId, state, contactId, blog.getId(), blog.getName(),
blog.getDescription(), blog.getAuthor().getName(),
blog.getAuthor().getPublicKey(), invitationId);
groupId, state, contactId, blog.getId(),
blog.getAuthor().getName(), blog.getAuthor().getPublicKey(),
invitationId);
}
}
@@ -280,8 +272,6 @@ class BlogSharingManagerImpl extends
MessageId storageId, GroupId groupId,
SharerSessionState.State state, ContactId contactId,
GroupId blogId, BdfDictionary d) throws FormatException {
String blogTitle = d.getString(BLOG_TITLE);
String blogDesc = d.getString(BLOG_DESC);
String blogAuthorName = d.getString(BLOG_AUTHOR_NAME);
byte[] blogPublicKey = d.getRaw(BLOG_PUBLIC_KEY);
MessageId responseId = null;
@@ -289,8 +279,8 @@ class BlogSharingManagerImpl extends
if (responseIdBytes != null)
responseId = new MessageId(responseIdBytes);
return new BlogSharerSessionState(sessionId, storageId,
groupId, state, contactId, blogId, blogTitle, blogDesc,
blogAuthorName, blogPublicKey, responseId);
groupId, state, contactId, blogId, blogAuthorName,
blogPublicKey, responseId);
}
@Override
@@ -299,9 +289,9 @@ class BlogSharingManagerImpl extends
SharerSessionState.State state, ContactId contactId,
Blog blog) {
return new BlogSharerSessionState(sessionId, storageId,
groupId, state, contactId, blog.getId(), blog.getName(),
blog.getDescription(), blog.getAuthor().getName(),
blog.getAuthor().getPublicKey(), null);
groupId, state, contactId, blog.getId(),
blog.getAuthor().getName(), blog.getAuthor().getPublicKey(),
null);
}
}
@@ -333,7 +323,6 @@ class BlogSharingManagerImpl extends
@Override
public BlogInvitationResponseReceivedEvent build(
BlogSharerSessionState localState, boolean accept, long time) {
String title = localState.getBlogTitle();
ContactId c = localState.getContactId();
MessageId responseId = localState.getResponseId();
if (responseId == null)
@@ -343,7 +332,7 @@ class BlogSharingManagerImpl extends
localState.getSessionId(), localState.getGroupId(),
localState.getContactId(), accept, time, false,
false, false, false);
return new BlogInvitationResponseReceivedEvent(title, c, response);
return new BlogInvitationResponseReceivedEvent(c, response);
}
}
}

View File

@@ -15,11 +15,7 @@ import org.briarproject.clients.BdfMessageValidator;
import javax.inject.Inject;
import static org.briarproject.api.blogs.BlogConstants.BLOG_AUTHOR_NAME;
import static org.briarproject.api.blogs.BlogConstants.BLOG_DESC;
import static org.briarproject.api.blogs.BlogConstants.BLOG_PUBLIC_KEY;
import static org.briarproject.api.blogs.BlogConstants.BLOG_TITLE;
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_DESC_LENGTH;
import static org.briarproject.api.blogs.BlogConstants.MAX_BLOG_TITLE_LENGTH;
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.api.sharing.SharingConstants.INVITATION_MSG;
@@ -52,30 +48,22 @@ class BlogSharingValidator extends BdfMessageValidator {
checkLength(id, SessionId.LENGTH);
if (type == SHARE_MSG_TYPE_INVITATION) {
checkSize(body, 5, 6);
checkSize(body, 3, 4);
String name = body.getString(2);
checkLength(name, 1, MAX_BLOG_TITLE_LENGTH);
String desc = body.getString(3);
checkLength(desc, 0, MAX_BLOG_DESC_LENGTH);
BdfList author = body.getList(4);
BdfList author = body.getList(2);
checkSize(author, 2);
String authorName = author.getString(0);
checkLength(name, 1, MAX_AUTHOR_NAME_LENGTH);
checkLength(authorName, 1, MAX_AUTHOR_NAME_LENGTH);
byte[] publicKey = author.getRaw(1);
checkLength(publicKey, 1, MAX_PUBLIC_KEY_LENGTH);
d.put(BLOG_TITLE, name);
d.put(BLOG_DESC, desc);
d.put(BLOG_AUTHOR_NAME, authorName);
d.put(BLOG_PUBLIC_KEY, publicKey);
if (body.size() > 5) {
String msg = body.getString(5);
if (body.size() > 3) {
String msg = body.getString(3);
checkLength(msg, 0, MAX_INVITATION_MESSAGE_LENGTH);
d.put(INVITATION_MSG, msg);
}

View File

@@ -3,10 +3,13 @@ package org.briarproject.sharing;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.data.BdfDictionary;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.NotNull;
import javax.annotation.concurrent.NotThreadSafe;
import static org.briarproject.api.sharing.SharingConstants.INVITATION_ID;
import static org.briarproject.api.sharing.SharingConstants.IS_SHARER;
import static org.briarproject.api.sharing.SharingConstants.SHARE_MSG_TYPE_ABORT;
@@ -19,7 +22,8 @@ import static org.briarproject.sharing.InviteeSessionState.Action.LOCAL_LEAVE;
import static org.briarproject.sharing.InviteeSessionState.Action.REMOTE_INVITATION;
import static org.briarproject.sharing.InviteeSessionState.Action.REMOTE_LEAVE;
// This class is not thread-safe
@NotThreadSafe
@NotNullByDefault
public abstract class InviteeSessionState extends SharingSessionState {
private State state;

View File

@@ -3,10 +3,13 @@ package org.briarproject.sharing;
import org.briarproject.api.clients.SessionId;
import org.briarproject.api.contact.ContactId;
import org.briarproject.api.data.BdfDictionary;
import org.briarproject.api.nullsafety.NotNullByDefault;
import org.briarproject.api.sync.GroupId;
import org.briarproject.api.sync.MessageId;
import org.jetbrains.annotations.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import static org.briarproject.api.sharing.SharingConstants.IS_SHARER;
import static org.briarproject.api.sharing.SharingConstants.RESPONSE_ID;
import static org.briarproject.api.sharing.SharingConstants.SHARE_MSG_TYPE_ABORT;
@@ -20,7 +23,8 @@ import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_ACCEPT;
import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_DECLINE;
import static org.briarproject.sharing.SharerSessionState.Action.REMOTE_LEAVE;
// This class is not thread-safe
@NotThreadSafe
@NotNullByDefault
public abstract class SharerSessionState extends SharingSessionState {
private State state;
@@ -58,6 +62,7 @@ public abstract class SharerSessionState extends SharingSessionState {
this.msg = msg;
}
@Nullable
public String getMessage() {
return this.msg;
}