@Test public void testIsNotInvitationAllowed() throws Exception { expectIsInvitationAllowed(CreatorState.DISSOLVED); assertFalse(groupInvitationManager .isInvitationAllowed(contact, privateGroup.getId())); expectIsInvitationAllowed(CreatorState.ERROR); assertFalse(groupInvitationManager .isInvitationAllowed(contact, privateGroup.getId())); expectIsInvitationAllowed(CreatorState.INVITED); assertFalse(groupInvitationManager .isInvitationAllowed(contact, privateGroup.getId())); expectIsInvitationAllowed(CreatorState.JOINED); assertFalse(groupInvitationManager .isInvitationAllowed(contact, privateGroup.getId())); expectIsInvitationAllowed(CreatorState.LEFT); assertFalse(groupInvitationManager .isInvitationAllowed(contact, privateGroup.getId())); }
@Override public boolean isInvitationAllowed(Contact c, GroupId privateGroupId) throws DbException { GroupId contactGroupId = getContactGroup(c).getId(); SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(true); try { Visibility client = clientVersioningManager.getClientVisibility(txn, c.getId(), PrivateGroupManager.CLIENT_ID, PrivateGroupManager.MAJOR_VERSION); StoredSession ss = getSession(txn, contactGroupId, sessionId); db.commitTransaction(txn); if (client != SHARED) return false; if (ss == null) return true; CreatorSession session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); return session.getState() == START; } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public boolean isInvitationAllowed(Contact c, GroupId privateGroupId) throws DbException { GroupId contactGroupId = getContactGroup(c).getId(); SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(true); try { Visibility client = clientVersioningManager.getClientVisibility(txn, c.getId(), PrivateGroupManager.CLIENT_ID, PrivateGroupManager.MAJOR_VERSION); StoredSession ss = getSession(txn, contactGroupId, sessionId); db.commitTransaction(txn); if (client != SHARED) return false; if (ss == null) return true; CreatorSession session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); return session.getState() == START; } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } } }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public boolean isInvitationAllowed(Contact c, GroupId privateGroupId) throws DbException { GroupId contactGroupId = getContactGroup(c).getId(); SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(true); try { Visibility client = clientVersioningManager.getClientVisibility(txn, c.getId(), PrivateGroupManager.CLIENT_ID, PrivateGroupManager.MAJOR_VERSION); StoredSession ss = getSession(txn, contactGroupId, sessionId); db.commitTransaction(txn); if (client != SHARED) return false; if (ss == null) return true; CreatorSession session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); return session.getState() == START; } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } } @Inject  GroupInvitationManagerImpl(DatabaseComponent db,
			ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			MetadataParser metadataParser, MessageTracker messageTracker,
			ContactGroupFactory contactGroupFactory,
			PrivateGroupFactory privateGroupFactory,
			PrivateGroupManager privateGroupManager,
			MessageParser messageParser, SessionParser sessionParser,
			SessionEncoder sessionEncoder,
			ProtocolEngineFactory engineFactory); }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public boolean isInvitationAllowed(Contact c, GroupId privateGroupId) throws DbException { GroupId contactGroupId = getContactGroup(c).getId(); SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(true); try { Visibility client = clientVersioningManager.getClientVisibility(txn, c.getId(), PrivateGroupManager.CLIENT_ID, PrivateGroupManager.MAJOR_VERSION); StoredSession ss = getSession(txn, contactGroupId, sessionId); db.commitTransaction(txn); if (client != SHARED) return false; if (ss == null) return true; CreatorSession session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); return session.getState() == START; } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } } @Inject  GroupInvitationManagerImpl(DatabaseComponent db,
			ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			MetadataParser metadataParser, MessageTracker messageTracker,
			ContactGroupFactory contactGroupFactory,
			PrivateGroupFactory privateGroupFactory,
			PrivateGroupManager privateGroupManager,
			MessageParser messageParser, SessionParser sessionParser,
			SessionEncoder sessionEncoder,
			ProtocolEngineFactory engineFactory); @Override void createLocalState(Transaction txn); @Override void addingContact(Transaction txn, Contact c); @Override void removingContact(Transaction txn, Contact c); @Override Group getContactGroup(Contact c); @Override void sendInvitation(GroupId privateGroupId, ContactId c,
			@Nullable String message, long timestamp, byte[] signature); @Override void respondToInvitation(ContactId c, PrivateGroup g, boolean accept); @Override void respondToInvitation(ContactId c, SessionId sessionId,
			boolean accept); @Override void revealRelationship(ContactId c, GroupId g); @Override Collection<InvitationMessage> getInvitationMessages(ContactId c); @Override Collection<GroupInvitationItem> getInvitations(); @Override boolean isInvitationAllowed(Contact c, GroupId privateGroupId); @Override void addingMember(Transaction txn, GroupId privateGroupId, Author a); @Override void removingGroup(Transaction txn, GroupId privateGroupId); @Override void onClientVisibilityChanging(Transaction txn, Contact c,
			Visibility v); }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public boolean isInvitationAllowed(Contact c, GroupId privateGroupId) throws DbException { GroupId contactGroupId = getContactGroup(c).getId(); SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(true); try { Visibility client = clientVersioningManager.getClientVisibility(txn, c.getId(), PrivateGroupManager.CLIENT_ID, PrivateGroupManager.MAJOR_VERSION); StoredSession ss = getSession(txn, contactGroupId, sessionId); db.commitTransaction(txn); if (client != SHARED) return false; if (ss == null) return true; CreatorSession session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); return session.getState() == START; } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } } @Inject  GroupInvitationManagerImpl(DatabaseComponent db,
			ClientHelper clientHelper,
			ClientVersioningManager clientVersioningManager,
			MetadataParser metadataParser, MessageTracker messageTracker,
			ContactGroupFactory contactGroupFactory,
			PrivateGroupFactory privateGroupFactory,
			PrivateGroupManager privateGroupManager,
			MessageParser messageParser, SessionParser sessionParser,
			SessionEncoder sessionEncoder,
			ProtocolEngineFactory engineFactory); @Override void createLocalState(Transaction txn); @Override void addingContact(Transaction txn, Contact c); @Override void removingContact(Transaction txn, Contact c); @Override Group getContactGroup(Contact c); @Override void sendInvitation(GroupId privateGroupId, ContactId c,
			@Nullable String message, long timestamp, byte[] signature); @Override void respondToInvitation(ContactId c, PrivateGroup g, boolean accept); @Override void respondToInvitation(ContactId c, SessionId sessionId,
			boolean accept); @Override void revealRelationship(ContactId c, GroupId g); @Override Collection<InvitationMessage> getInvitationMessages(ContactId c); @Override Collection<GroupInvitationItem> getInvitations(); @Override boolean isInvitationAllowed(Contact c, GroupId privateGroupId); @Override void addingMember(Transaction txn, GroupId privateGroupId, Author a); @Override void removingGroup(Transaction txn, GroupId privateGroupId); @Override void onClientVisibilityChanging(Transaction txn, Contact c,
			Visibility v);  }