Source:
private synchronized void startNextProjectNegotiation() { ISarosSession currentSession = session; if (currentSession == null) { log.warn("could not add resources because there is no active session"); return; } if (!currentSession.hasWriteAccess()) { log.error("current local user has not enough privileges to add resources to the current session"); return; } List<IProject> projectsToShare = nextProjectNegotiation .getProjectsToShare(currentSession, SESSION_ID_GENERATOR); if (projectsToShare.isEmpty()) { log.warn("skipping project negotiation because no new projects were added to the current session"); return; } INegotiationHandler handler = negotiationHandler; if (handler == null) { log.warn("could not start a project negotiation because no handler is installed"); return; } List<AbstractOutgoingProjectNegotiation> negotiations = new ArrayList<AbstractOutgoingProjectNegotiation>(); if (!startStopSessionLock.tryLock()) { log.warn("could not start a project negotiation because the current session is about to stop"); return; } try { for (User user : currentSession.getRemoteUsers()) { TransferType type = TransferType.valueOf(currentSession .getUserProperties(user).getString( ProjectNegotiationTypeHook.KEY_TYPE)); AbstractOutgoingProjectNegotiation negotiation = negotiationFactory .newOutgoingProjectNegotiation(user.getJID(), type, projectsToShare, this, currentSession); negotiation.setNegotiationListener(negotiationListener); currentProjectNegotiations.add(negotiation); negotiations.add(negotiation); } } finally { startStopSessionLock.unlock(); } for (AbstractOutgoingProjectNegotiation negotiation : negotiations) handler.handleOutgoingProjectNegotiation(negotiation); }

Target:
private synchronized void startNextProjectNegotiation() { ISarosSession currentSession = session; if (currentSession == null) { log.warn("could not add resources because there is no active session"); return; } if (!currentSession.hasWriteAccess()) { log.error( "current local user has not enough privileges to add resources to the current session"); return; } List<IProject> projectsToShare = new ArrayList<IProject>(); Map<IProject, List<IResource>> mapping = nextProjectNegotiation.get(); for (Entry<IProject, List<IResource>> mapEntry : mapping.entrySet()) { final IProject project = mapEntry.getKey(); final List<IResource> resourcesList = mapEntry.getValue(); if (!currentSession.isCompletelyShared(project)) { String projectID = currentSession.getProjectID(project); if (projectID == null) { projectID = String.valueOf(SESSION_ID_GENERATOR.nextInt(Integer.MAX_VALUE)); } currentSession.addSharedResources(project, projectID, resourcesList); projectsToShare.add(project); } } if (projectsToShare.isEmpty()) { log.warn( "skipping project negotiation because no new projects were added to the current session"); return; } INegotiationHandler handler = negotiationHandler; if (handler == null) { log.warn("could not start a project negotiation because no handler is installed"); return; } List<AbstractOutgoingProjectNegotiation> negotiations = new ArrayList<AbstractOutgoingProjectNegotiation>(); if (!startStopSessionLock.tryLock()) { log.warn( "could not start a project negotiation because the current session is about to stop"); return; } try { for (User user : currentSession.getRemoteUsers()) { TransferType type = TransferType.valueOf( currentSession .getUserProperties(user) .getString(ProjectNegotiationTypeHook.KEY_TYPE)); AbstractOutgoingProjectNegotiation negotiation = negotiationFactory.newOutgoingProjectNegotiation( user.getJID(), type, projectsToShare, this, currentSession); negotiation.setNegotiationListener(negotiationListener); currentProjectNegotiations.add(negotiation); negotiations.add(negotiation); } } finally { startStopSessionLock.unlock(); } for (AbstractOutgoingProjectNegotiation negotiation : negotiations) handler.handleOutgoingProjectNegotiation(negotiation); }