@Test public void testSendSubsequentInvitation() throws Exception { String msg = "Invitation text for subsequent invitation"; long time = 43L; byte[] signature = getRandomBytes(43); expectGetSession(oneResult, sessionId, contactGroup.getId()); context.checking(new Expectations() {{ oneOf(db).startTransaction(false); will(returnValue(txn)); oneOf(db).getContact(txn, contactId); will(returnValue(contact)); oneOf(contactGroupFactory).createContactGroup(CLIENT_ID, MAJOR_VERSION, contact); will(returnValue(contactGroup)); oneOf(sessionParser) .parseCreatorSession(contactGroup.getId(), bdfSession); will(returnValue(creatorSession)); oneOf(creatorEngine).onInviteAction(with(txn), with(any(CreatorSession.class)), with(msg), with(time), with(signature)); will(returnValue(creatorSession)); }}); expectStoreSession(creatorSession, storageMessage.getId()); context.checking(new Expectations() {{ oneOf(db).commitTransaction(txn); oneOf(db).endTransaction(txn); }}); groupInvitationManager.sendInvitation(privateGroup.getId(), contactId, msg, time, signature); }
@Override public void sendInvitation(GroupId privateGroupId, ContactId c, @Nullable String message, long timestamp, byte[] signature) throws DbException { SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(false); try { Contact contact = db.getContact(txn, c); GroupId contactGroupId = getContactGroup(contact).getId(); StoredSession ss = getSession(txn, contactGroupId, sessionId); CreatorSession session; MessageId storageId; if (ss == null) { session = new CreatorSession(contactGroupId, privateGroupId); storageId = createStorageId(txn, contactGroupId); } else { session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); storageId = ss.storageId; } session = creatorEngine.onInviteAction(txn, session, message, timestamp, signature); storeSession(txn, storageId, session); db.commitTransaction(txn); } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public void sendInvitation(GroupId privateGroupId, ContactId c, @Nullable String message, long timestamp, byte[] signature) throws DbException { SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(false); try { Contact contact = db.getContact(txn, c); GroupId contactGroupId = getContactGroup(contact).getId(); StoredSession ss = getSession(txn, contactGroupId, sessionId); CreatorSession session; MessageId storageId; if (ss == null) { session = new CreatorSession(contactGroupId, privateGroupId); storageId = createStorageId(txn, contactGroupId); } else { session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); storageId = ss.storageId; } session = creatorEngine.onInviteAction(txn, session, message, timestamp, signature); storeSession(txn, storageId, session); db.commitTransaction(txn); } catch (FormatException e) { throw new DbException(e); } finally { db.endTransaction(txn); } } }
GroupInvitationManagerImpl extends ConversationClientImpl implements GroupInvitationManager, Client, ContactHook,
		PrivateGroupHook, ClientVersioningHook { @Override public void sendInvitation(GroupId privateGroupId, ContactId c, @Nullable String message, long timestamp, byte[] signature) throws DbException { SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(false); try { Contact contact = db.getContact(txn, c); GroupId contactGroupId = getContactGroup(contact).getId(); StoredSession ss = getSession(txn, contactGroupId, sessionId); CreatorSession session; MessageId storageId; if (ss == null) { session = new CreatorSession(contactGroupId, privateGroupId); storageId = createStorageId(txn, contactGroupId); } else { session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); storageId = ss.storageId; } session = creatorEngine.onInviteAction(txn, session, message, timestamp, signature); storeSession(txn, storageId, session); db.commitTransaction(txn); } 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 void sendInvitation(GroupId privateGroupId, ContactId c, @Nullable String message, long timestamp, byte[] signature) throws DbException { SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(false); try { Contact contact = db.getContact(txn, c); GroupId contactGroupId = getContactGroup(contact).getId(); StoredSession ss = getSession(txn, contactGroupId, sessionId); CreatorSession session; MessageId storageId; if (ss == null) { session = new CreatorSession(contactGroupId, privateGroupId); storageId = createStorageId(txn, contactGroupId); } else { session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); storageId = ss.storageId; } session = creatorEngine.onInviteAction(txn, session, message, timestamp, signature); storeSession(txn, storageId, session); db.commitTransaction(txn); } 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 void sendInvitation(GroupId privateGroupId, ContactId c, @Nullable String message, long timestamp, byte[] signature) throws DbException { SessionId sessionId = getSessionId(privateGroupId); Transaction txn = db.startTransaction(false); try { Contact contact = db.getContact(txn, c); GroupId contactGroupId = getContactGroup(contact).getId(); StoredSession ss = getSession(txn, contactGroupId, sessionId); CreatorSession session; MessageId storageId; if (ss == null) { session = new CreatorSession(contactGroupId, privateGroupId); storageId = createStorageId(txn, contactGroupId); } else { session = sessionParser .parseCreatorSession(contactGroupId, ss.bdfSession); storageId = ss.storageId; } session = creatorEngine.onInviteAction(txn, session, message, timestamp, signature); storeSession(txn, storageId, session); db.commitTransaction(txn); } 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);  }