Merge "Issue #2700 fixed subscribe request group input" into development
Former-commit-id:d8e2d2837e
[formerly2643d01b74
[formerly af0e70e20c2a5ca276e9b819285d34c0113cafe7]] Former-commit-id:2643d01b74
Former-commit-id:f2b32fa1ae
This commit is contained in:
commit
ec6d8585e1
5 changed files with 143 additions and 18 deletions
|
@ -33,6 +33,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
* Mar 16, 2012 jkorman Initial creation
|
* Mar 16, 2012 jkorman Initial creation
|
||||||
* Jan 27, 2014 2700 bclement handle subscribe request returns a boolean
|
* Jan 27, 2014 2700 bclement handle subscribe request returns a boolean
|
||||||
* all methods take user id instead of qualified id
|
* all methods take user id instead of qualified id
|
||||||
|
* Feb 13, 2014 2755 bclement handleSubscribeRequest now returns SubscriptionResponse
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -48,7 +49,7 @@ public interface ISubscriptionResponder {
|
||||||
* @param fromID
|
* @param fromID
|
||||||
* @return true if the subscribe request is accepted.
|
* @return true if the subscribe request is accepted.
|
||||||
*/
|
*/
|
||||||
public boolean handleSubscribeRequest(UserId fromID);
|
public SubscriptionResponse handleSubscribeRequest(UserId fromID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered when a contact subscribes to user
|
* Triggered when a contact subscribes to user
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
/**
|
||||||
|
* This software was developed and / or modified by Raytheon Company,
|
||||||
|
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||||
|
*
|
||||||
|
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||||
|
* This software product contains export-restricted data whose
|
||||||
|
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||||
|
* to non-U.S. persons whether in the United States or abroad requires
|
||||||
|
* an export license or other authorization.
|
||||||
|
*
|
||||||
|
* Contractor Name: Raytheon Company
|
||||||
|
* Contractor Address: 6825 Pine Street, Suite 340
|
||||||
|
* Mail Stop B8
|
||||||
|
* Omaha, NE 68106
|
||||||
|
* 402.291.0100
|
||||||
|
*
|
||||||
|
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||||
|
* further licensing information.
|
||||||
|
**/
|
||||||
|
package com.raytheon.uf.viz.collaboration.comm.identity.roster;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response to subscription (contacts) request. Includes user input from prompt
|
||||||
|
* dialog.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
*
|
||||||
|
* SOFTWARE HISTORY
|
||||||
|
*
|
||||||
|
* Date Ticket# Engineer Description
|
||||||
|
* ------------ ---------- ----------- --------------------------
|
||||||
|
* Feb 13, 2014 2755 bclement Initial creation
|
||||||
|
*
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @author bclement
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class SubscriptionResponse {
|
||||||
|
|
||||||
|
private String group;
|
||||||
|
|
||||||
|
private boolean accepted;
|
||||||
|
|
||||||
|
public SubscriptionResponse() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param accepted
|
||||||
|
* true if contact request was accepted
|
||||||
|
* @param group
|
||||||
|
* optional group to add user to
|
||||||
|
*/
|
||||||
|
public SubscriptionResponse(boolean accepted, String group) {
|
||||||
|
this.accepted = accepted;
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param accepted
|
||||||
|
* true if contact request was accepted
|
||||||
|
*/
|
||||||
|
public SubscriptionResponse(boolean accepted) {
|
||||||
|
this(accepted, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true if user should be added to group
|
||||||
|
*/
|
||||||
|
public boolean addToGroup() {
|
||||||
|
return !StringUtils.isBlank(group);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group
|
||||||
|
*/
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the accepted
|
||||||
|
*/
|
||||||
|
public boolean isAccepted() {
|
||||||
|
return accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param group
|
||||||
|
* the group to set
|
||||||
|
*/
|
||||||
|
public void setGroup(String group) {
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param accepted
|
||||||
|
* the accepted to set
|
||||||
|
*/
|
||||||
|
public void setAccepted(boolean accepted) {
|
||||||
|
this.accepted = accepted;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -41,6 +41,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
|
import com.raytheon.uf.viz.collaboration.comm.identity.event.IRosterChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
|
import com.raytheon.uf.viz.collaboration.comm.identity.event.RosterChangeType;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.SubscriptionResponse;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.RosterChangeEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.RosterChangeEvent;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent;
|
import com.raytheon.uf.viz.collaboration.comm.provider.event.UserPresenceChangedEvent;
|
||||||
|
@ -69,6 +70,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
* Jan 27, 2014 2700 bclement changes to subscription request responders
|
* Jan 27, 2014 2700 bclement changes to subscription request responders
|
||||||
* Jan 31, 2014 2700 bclement fixed subscribe back after accepting subscription
|
* Jan 31, 2014 2700 bclement fixed subscribe back after accepting subscription
|
||||||
* Feb 12, 2014 2797 bclement added protective copy to sendPresence
|
* Feb 12, 2014 2797 bclement added protective copy to sendPresence
|
||||||
|
* Feb 13, 2014 2755 bclement added user input for which group to add contact to
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -98,11 +100,13 @@ public class AccountManager implements IAccountManager {
|
||||||
UserId fromId = IDConverter.convertFrom(pres.getFrom());
|
UserId fromId = IDConverter.convertFrom(pres.getFrom());
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case subscribe:
|
case subscribe:
|
||||||
boolean accept = true;
|
SubscriptionResponse response;
|
||||||
if (responder != null) {
|
if (responder != null) {
|
||||||
accept = responder.handleSubscribeRequest(fromId);
|
response = responder.handleSubscribeRequest(fromId);
|
||||||
|
} else {
|
||||||
|
response = new SubscriptionResponse(true);
|
||||||
}
|
}
|
||||||
handleSubRequest(fromId, accept);
|
handleSubRequest(fromId, response);
|
||||||
break;
|
break;
|
||||||
case subscribed:
|
case subscribed:
|
||||||
if (responder != null) {
|
if (responder != null) {
|
||||||
|
@ -157,11 +161,12 @@ public class AccountManager implements IAccountManager {
|
||||||
*
|
*
|
||||||
* @param fromId
|
* @param fromId
|
||||||
*/
|
*/
|
||||||
private void handleSubRequest(UserId fromId, boolean accept) {
|
private void handleSubRequest(UserId fromId,
|
||||||
|
SubscriptionResponse response) {
|
||||||
Presence.Type subscribedType;
|
Presence.Type subscribedType;
|
||||||
ContactsManager cm = sessionManager.getContactsManager();
|
ContactsManager cm = sessionManager.getContactsManager();
|
||||||
boolean addToRoster = false;
|
boolean addToRoster = false;
|
||||||
if (accept) {
|
if (response.isAccepted()) {
|
||||||
subscribedType = Presence.Type.subscribed;
|
subscribedType = Presence.Type.subscribed;
|
||||||
RosterEntry entry = cm.getRosterEntry(fromId);
|
RosterEntry entry = cm.getRosterEntry(fromId);
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
|
@ -175,8 +180,13 @@ public class AccountManager implements IAccountManager {
|
||||||
try {
|
try {
|
||||||
sendPresence(fromId, presence);
|
sendPresence(fromId, presence);
|
||||||
if (addToRoster) {
|
if (addToRoster) {
|
||||||
|
if (response.addToGroup()) {
|
||||||
|
cm.addToGroup(response.getGroup(), fromId);
|
||||||
|
} else {
|
||||||
cm.addToRoster(fromId);
|
cm.addToRoster(fromId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
} catch (CollaborationException e) {
|
} catch (CollaborationException e) {
|
||||||
AccountManager.this.log.error("Unable to send presence", e);
|
AccountManager.this.log.error("Unable to send presence", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.swt.widgets.Shell;
|
||||||
import org.jivesoftware.smack.RosterGroup;
|
import org.jivesoftware.smack.RosterGroup;
|
||||||
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.ContactsManager;
|
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,6 +50,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 27, 2014 2700 bclement Initial creation
|
* Jan 27, 2014 2700 bclement Initial creation
|
||||||
* Jan 31, 2014 2700 bclement don't prompt for group if user is already in one
|
* Jan 31, 2014 2700 bclement don't prompt for group if user is already in one
|
||||||
|
* Feb 13, 2014 2755 bclement roster addition now done in account manager, user input passed back
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -67,6 +67,8 @@ public class SubRequestDialog extends Dialog {
|
||||||
|
|
||||||
private Combo groupCombo;
|
private Combo groupCombo;
|
||||||
|
|
||||||
|
private String group;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param parentShell
|
* @param parentShell
|
||||||
*/
|
*/
|
||||||
|
@ -97,7 +99,6 @@ public class SubRequestDialog extends Dialog {
|
||||||
if (buttonId == IDialogConstants.OK_ID) {
|
if (buttonId == IDialogConstants.OK_ID) {
|
||||||
int count = groupCombo.getItemCount();
|
int count = groupCombo.getItemCount();
|
||||||
int index = groupCombo.getSelectionIndex();
|
int index = groupCombo.getSelectionIndex();
|
||||||
String group = null;
|
|
||||||
if ( index == count - 1){
|
if ( index == count - 1){
|
||||||
// new group
|
// new group
|
||||||
CreateGroupDialog dialog = new CreateGroupDialog(Display
|
CreateGroupDialog dialog = new CreateGroupDialog(Display
|
||||||
|
@ -107,11 +108,6 @@ public class SubRequestDialog extends Dialog {
|
||||||
} else if ( index >= 0){
|
} else if ( index >= 0){
|
||||||
group = groupCombo.getItem(index);
|
group = groupCombo.getItem(index);
|
||||||
}
|
}
|
||||||
CollaborationConnection connection = CollaborationConnection.getConnection();
|
|
||||||
if ( group != null && connection != null){
|
|
||||||
ContactsManager cm = connection.getContactsManager();
|
|
||||||
cm.addToGroup(group, userid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
super.buttonPressed(buttonId);
|
super.buttonPressed(buttonId);
|
||||||
}
|
}
|
||||||
|
@ -188,4 +184,11 @@ public class SubRequestDialog extends Dialog {
|
||||||
createButton(parent, IDialogConstants.CANCEL_ID, "Deny", false);
|
createButton(parent, IDialogConstants.CANCEL_ID, "Deny", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the group
|
||||||
|
*/
|
||||||
|
public String getGroup() {
|
||||||
|
return group;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||||
import com.raytheon.uf.common.status.UFStatus;
|
import com.raytheon.uf.common.status.UFStatus;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager;
|
import com.raytheon.uf.viz.collaboration.comm.identity.IAccountManager;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.ISubscriptionResponder;
|
||||||
|
import com.raytheon.uf.viz.collaboration.comm.identity.roster.SubscriptionResponse;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
||||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserSearch;
|
import com.raytheon.uf.viz.collaboration.comm.provider.user.UserSearch;
|
||||||
|
@ -50,6 +51,7 @@ import com.raytheon.uf.viz.core.VizApp;
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Jan 24, 2014 2700 bclement Initial creation
|
* Jan 24, 2014 2700 bclement Initial creation
|
||||||
* Feb 3, 2014 2699 bclement fixed assumption that username search was exact
|
* Feb 3, 2014 2699 bclement fixed assumption that username search was exact
|
||||||
|
* Feb 13, 2014 2755 bclement added user input for which group to add contact to
|
||||||
*
|
*
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -163,7 +165,8 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean handleSubscribeRequest(final UserId fromID) {
|
public SubscriptionResponse handleSubscribeRequest(
|
||||||
|
final UserId fromID) {
|
||||||
String displayName = getDisplayName(fromID);
|
String displayName = getDisplayName(fromID);
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(fromID.getFQName());
|
builder.append(fromID.getFQName());
|
||||||
|
@ -172,7 +175,7 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener {
|
||||||
}
|
}
|
||||||
builder.append(" wants to add you to his or her contacts list.");
|
builder.append(" wants to add you to his or her contacts list.");
|
||||||
final String msg = builder.toString();
|
final String msg = builder.toString();
|
||||||
final boolean[] rval = new boolean[1];
|
final SubscriptionResponse rval = new SubscriptionResponse();
|
||||||
VizApp.runSync(new Runnable() {
|
VizApp.runSync(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,11 +184,13 @@ public class AutoSubscribePropertyListener implements IPropertyChangeListener {
|
||||||
SubRequestDialog dlg = new SubRequestDialog(shell,
|
SubRequestDialog dlg = new SubRequestDialog(shell,
|
||||||
"Authorize Collaboration Contact", msg, fromID);
|
"Authorize Collaboration Contact", msg, fromID);
|
||||||
int index = dlg.open();
|
int index = dlg.open();
|
||||||
rval[0] = index == Window.OK;
|
|
||||||
|
rval.setAccepted(index == Window.OK);
|
||||||
|
rval.setGroup(dlg.getGroup());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return rval[0];
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue