Issue #2699 added handle config to prefs
default handle autofills session dialogs is also used to connect to feed venue (error popup if already taken) Former-commit-id:1ff4ed1ae9
[formerly f10f42753c541d4003b4c67a84a1d50e033941d3] Former-commit-id:16c1aaed3e
This commit is contained in:
parent
fccefc9bb1
commit
7c867338c8
8 changed files with 306 additions and 23 deletions
|
@ -109,6 +109,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
|||
* Jan 28, 2014 2698 bclement fixed compression default
|
||||
* cleaned up createCollaborationVenue, removed getVenueInfo
|
||||
* Jan 30, 2014 2698 bclement changed arguments to create sessions, moved room connection from SessionView
|
||||
* Feb 3, 2014 2699 bclement removed unneeded catch in joinTextOnlyVenue
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -417,17 +418,12 @@ public class CollaborationConnection implements IEventPublisher {
|
|||
*/
|
||||
public IVenueSession joinTextOnlyVenue(String venueName, String handle)
|
||||
throws CollaborationException {
|
||||
try {
|
||||
VenueSession session = new VenueSession(eventBus, this);
|
||||
session.configureVenue(venueName, handle);
|
||||
session.connectToRoom();
|
||||
sessions.put(session.getSessionId(), session);
|
||||
postEvent(session);
|
||||
return session;
|
||||
} catch (Exception e) {
|
||||
throw new CollaborationException(
|
||||
"Error joining venue " + venueName, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -65,6 +65,7 @@ import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.ISharedEdito
|
|||
import com.raytheon.uf.viz.collaboration.display.roles.dataprovider.SharedEditorsManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.editor.CollaborationEditor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil;
|
||||
import com.raytheon.uf.viz.core.IDisplayPane;
|
||||
import com.raytheon.uf.viz.core.IDisplayPaneContainer;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
|
||||
|
@ -87,6 +88,7 @@ import com.raytheon.viz.ui.editor.IMultiPaneEditor;
|
|||
* Dec 19, 2013 2563 bclement disable shared display option if not supported by server
|
||||
* Jan 28, 2014 2698 bclement added error display text
|
||||
* Jan 30, 2014 2698 bclement added handle to join room with
|
||||
* Feb 3, 2014 2699 bclement added default handle preference
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -149,6 +151,7 @@ public class CreateSessionDialog extends CaveSWTDialog {
|
|||
label = new Label(body, SWT.NONE);
|
||||
label.setText("Handle: ");
|
||||
handleTF = new Text(body, SWT.BORDER);
|
||||
handleTF.setText(HandleUtil.getDefaultHandle());
|
||||
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
|
||||
handleTF.setLayoutData(gd);
|
||||
handleTF.addVerifyListener(validNameListener);
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.invite.SharedDisplayVenue
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.invite.VenueInvite;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.user.IQualifiedID;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
|
||||
|
||||
/**
|
||||
|
@ -58,6 +59,7 @@ import com.raytheon.viz.ui.dialogs.CaveSWTDialogBase;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 14, 2012 lvenable Initial creation.
|
||||
* Jan 30, 2014 2698 bclement added logic to join room and reprompt if failed
|
||||
* Feb 3, 2014 2699 bclement added default handle preference
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -188,6 +190,7 @@ public class InviteDialog extends CaveSWTDialogBase {
|
|||
}
|
||||
addLabel(labelTextComp, "Join With Handle:", true);
|
||||
handleText = new Text(labelTextComp, SWT.BORDER);
|
||||
handleText.setText(HandleUtil.getDefaultHandle());
|
||||
handleText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||
handleText.addVerifyListener(new VerifyListener() {
|
||||
|
||||
|
|
|
@ -23,7 +23,10 @@ import java.lang.ref.Reference;
|
|||
import java.lang.ref.WeakReference;
|
||||
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IPartListener;
|
||||
import org.eclipse.ui.IViewReference;
|
||||
import org.eclipse.ui.IWorkbenchPage;
|
||||
|
@ -39,7 +42,9 @@ import com.raytheon.uf.viz.collaboration.comm.identity.ISession;
|
|||
import com.raytheon.uf.viz.collaboration.comm.identity.IVenueSession;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.HandleUtil;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SessionFeedView;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.icon.IconUtil;
|
||||
import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
||||
|
||||
|
@ -56,6 +61,7 @@ import com.raytheon.viz.ui.views.CaveWorkbenchPageManager;
|
|||
* Dec 19, 2013 2563 bclement added check for feed venue existence
|
||||
* Jan 28, 2014 2698 bclement changed feed venue filter to match whole name
|
||||
* Jan 30, 2014 2698 bclement added default handle of username
|
||||
* Feb 3, 2014 2699 bclement use preference handle default, display error if handle taken
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -80,7 +86,7 @@ public class DisplayFeedAction extends Action {
|
|||
.getActiveWorkbenchWindow().getActivePage();
|
||||
page.addPartListener(new PartListener(this));
|
||||
if (isEnabled()) {
|
||||
String sessionId = getSessionId(false);
|
||||
String sessionId = getSessionId();
|
||||
if (sessionId != null) {
|
||||
IViewReference ref = page.findViewReference(SessionFeedView.ID,
|
||||
sessionId);
|
||||
|
@ -89,7 +95,10 @@ public class DisplayFeedAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
private static String getSessionId(boolean create) {
|
||||
/**
|
||||
* @return session ID of feed venue session or null if not found
|
||||
*/
|
||||
private static String getSessionId() {
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
String sessionId = null;
|
||||
|
@ -101,20 +110,38 @@ public class DisplayFeedAction extends Action {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (sessionId == null && create) {
|
||||
try {
|
||||
// TODO auto join with handle from preferences
|
||||
IVenueSession session = connection.joinTextOnlyVenue(
|
||||
FEED_VENUE, connection.getUser().getName());
|
||||
sessionId = session.getSessionId();
|
||||
} catch (CollaborationException e) {
|
||||
statusHandler.handle(Priority.PROBLEM,
|
||||
"Unable to join the collaboration feed", e);
|
||||
}
|
||||
}
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempt to join the feed venue on server using the handle set in
|
||||
* preferences. Displays and error and returns null if join wasn't
|
||||
* successful.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String joinFeedVenue() {
|
||||
try {
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
.getConnection();
|
||||
IVenueSession session = connection.joinTextOnlyVenue(FEED_VENUE,
|
||||
HandleUtil.getDefaultHandle());
|
||||
return session.getSessionId();
|
||||
} catch (CollaborationException e) {
|
||||
final String msg = e.getLocalizedMessage()
|
||||
+ "\n\nDefault handle options can be set in the Collaboration Preferences page.";
|
||||
VizApp.runAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Shell shell = new Shell(Display.getCurrent());
|
||||
MessageDialog.openError(shell,
|
||||
"Unable to join collaboration feed", msg);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
CollaborationConnection connection = CollaborationConnection
|
||||
|
@ -122,14 +149,27 @@ public class DisplayFeedAction extends Action {
|
|||
if (!connection.venueExistsOnServer(FEED_VENUE)) {
|
||||
statusHandler.info("Feed venue doesn't exist on server: "
|
||||
+ FEED_VENUE);
|
||||
setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
String sessionId;
|
||||
if (isChecked()) {
|
||||
sessionId = joinFeedVenue();
|
||||
if (sessionId == null) {
|
||||
// we couldn't join, stop action
|
||||
setChecked(false);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
sessionId = getSessionId();
|
||||
}
|
||||
|
||||
// handle if it is clicked to close or open the view as
|
||||
// necessary
|
||||
CaveWorkbenchPageManager page = CaveWorkbenchPageManager
|
||||
.getActiveInstance();
|
||||
String sessionId = getSessionId(isChecked());
|
||||
|
||||
if (!isChecked()) {
|
||||
IViewReference ref = page.findViewReference(SessionFeedView.ID,
|
||||
sessionId);
|
||||
|
@ -183,7 +223,7 @@ public class DisplayFeedAction extends Action {
|
|||
clean(part);
|
||||
if (part instanceof SessionFeedView) {
|
||||
SessionFeedView view = (SessionFeedView) part;
|
||||
if (view.getRoom().equals(getSessionId(false))) {
|
||||
if (view.getRoom().equals(getSessionId())) {
|
||||
setChecked(false);
|
||||
}
|
||||
}
|
||||
|
@ -199,7 +239,7 @@ public class DisplayFeedAction extends Action {
|
|||
clean(part);
|
||||
if (part instanceof SessionFeedView) {
|
||||
SessionFeedView view = (SessionFeedView) part;
|
||||
if (view.getRoom().equals(getSessionId(false))) {
|
||||
if (view.getRoom().equals(getSessionId())) {
|
||||
setChecked(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.prefs;
|
||||
|
||||
|
||||
/**
|
||||
* Collaboration preferences constants used to interact with preference store
|
||||
*
|
||||
|
@ -31,6 +32,7 @@ package com.raytheon.uf.viz.collaboration.ui.prefs;
|
|||
* Apr 24, 2012 njensen Initial creation
|
||||
* Jan 14, 2014 2630 bclement added away on idle constants
|
||||
* Jan 27, 2014 2700 bclement added auto accept subscribe
|
||||
* Feb 3, 2014 2699 bclement added handle preferences
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -55,6 +57,10 @@ public class CollabPrefConstants {
|
|||
|
||||
public static final String AUTO_ACCEPT_SUBSCRIBE = "autoAcceptSubscribe";
|
||||
|
||||
public static final String DEFAULT_HANDLE = "defaultHandle";
|
||||
|
||||
public static final String CUSTOM_HANDLE = "customHandle";
|
||||
|
||||
public static final int AWAY_TIMEOUT_DEFAULT = 10; // ten minutes
|
||||
|
||||
public class HttpCollaborationConfiguration {
|
||||
|
@ -62,4 +68,26 @@ public class CollabPrefConstants {
|
|||
|
||||
public static final String P_HTTP_SESSION_URL = "http.sessionURL";
|
||||
}
|
||||
|
||||
public static enum HandleOption {
|
||||
BLANK("Blank"), USERNAME("User Name"), FULLNAME("Full Name"), ROLE(
|
||||
"Role"), CUSTOM(
|
||||
"Custom");
|
||||
|
||||
public final String display;
|
||||
|
||||
private HandleOption(String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public static String[][] displayValues() {
|
||||
HandleOption[] values = values();
|
||||
String[][] rval = new String[values.length][2];
|
||||
for (int i = 0; i < rval.length; ++i) {
|
||||
HandleOption op = values[i];
|
||||
rval[i] = new String[] { op.display, op.name() };
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import com.raytheon.uf.viz.collaboration.ui.Activator;
|
|||
* Apr 24, 2012 njensen Initial creation
|
||||
* Jan 14, 2014 2630 bclement added away on idle defaults
|
||||
* Jan 27, 2014 2700 bclement added auto accept subscribe
|
||||
* Feb 3, 2014 2699 bclement added handle preferences
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,6 +70,9 @@ public class CollabPrefInitializer extends AbstractPreferenceInitializer {
|
|||
store.setDefault(CollabPrefConstants.AWAY_TIMEOUT,
|
||||
CollabPrefConstants.AWAY_TIMEOUT_DEFAULT);
|
||||
store.setDefault(CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE, false);
|
||||
store.setDefault(CollabPrefConstants.DEFAULT_HANDLE,
|
||||
CollabPrefConstants.HandleOption.BLANK.name());
|
||||
store.setDefault(CollabPrefConstants.CUSTOM_HANDLE, "");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,14 +20,17 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui.prefs;
|
||||
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.ComboFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IntegerFieldEditor;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.ui.IWorkbench;
|
||||
import org.eclipse.ui.IWorkbenchPreferencePage;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.session.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants.HandleOption;
|
||||
|
||||
/**
|
||||
* Collaboration specific preferences editor
|
||||
|
@ -41,6 +44,7 @@ import com.raytheon.uf.viz.collaboration.ui.Activator;
|
|||
* Apr 27, 2012 mnash Initial creation
|
||||
* Jan 14, 2014 2630 bclement added away on idle
|
||||
* Jan 27, 2014 2700 bclement added auto accept subscribe
|
||||
* Feb 3, 2014 2699 bclement added handle preferences
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,6 +54,10 @@ import com.raytheon.uf.viz.collaboration.ui.Activator;
|
|||
public class CollaborationPreferencePage extends FieldEditorPreferencePage
|
||||
implements IWorkbenchPreferencePage {
|
||||
|
||||
private FieldEditor awayTimeOut;
|
||||
|
||||
private FieldEditor customHandle;
|
||||
|
||||
public CollaborationPreferencePage() {
|
||||
super(GRID);
|
||||
}
|
||||
|
@ -85,18 +93,73 @@ public class CollaborationPreferencePage extends FieldEditorPreferencePage
|
|||
|
||||
FieldEditor toggleIdle = new BooleanFieldEditor(
|
||||
CollabPrefConstants.AWAY_ON_IDLE, "Change Status On Idle",
|
||||
getFieldEditorParent());
|
||||
getFieldEditorParent()) {
|
||||
@Override
|
||||
protected void fireValueChanged(String property, Object oldValue,
|
||||
Object newValue) {
|
||||
setEnabledForFieldEditor(awayTimeOut, (Boolean) newValue);
|
||||
}
|
||||
};
|
||||
this.addField(toggleIdle);
|
||||
FieldEditor awayTimeOut = new IntegerFieldEditor(
|
||||
|
||||
awayTimeOut = new IntegerFieldEditor(
|
||||
CollabPrefConstants.AWAY_TIMEOUT,
|
||||
"Minutes Before Becoming Idle:", getFieldEditorParent());
|
||||
boolean awayChecked = this.getPreferenceStore().getBoolean(
|
||||
CollabPrefConstants.AWAY_ON_IDLE);
|
||||
setEnabledForFieldEditor(awayTimeOut, awayChecked);
|
||||
this.addField(awayTimeOut);
|
||||
|
||||
FieldEditor autoSubscribe = new BooleanFieldEditor(
|
||||
CollabPrefConstants.AUTO_ACCEPT_SUBSCRIBE,
|
||||
"Automatically Accept Contact Requests",
|
||||
getFieldEditorParent());
|
||||
|
||||
this.addField(autoSubscribe);
|
||||
|
||||
FieldEditor defaultHandle = new ComboFieldEditor(
|
||||
CollabPrefConstants.DEFAULT_HANDLE, "Default Session Handle",
|
||||
CollabPrefConstants.HandleOption.displayValues(),
|
||||
getFieldEditorParent()) {
|
||||
@Override
|
||||
protected void fireValueChanged(String property, Object oldValue,
|
||||
Object newValue) {
|
||||
super.fireValueChanged(property, oldValue, newValue);
|
||||
setEnableForCustomHandle(newValue.toString());
|
||||
}
|
||||
};
|
||||
this.addField(defaultHandle);
|
||||
|
||||
customHandle = new StringFieldEditor(CollabPrefConstants.CUSTOM_HANDLE,
|
||||
"Custom Handle Text (see above)", getFieldEditorParent());
|
||||
String string = this.getPreferenceStore().getString(
|
||||
CollabPrefConstants.DEFAULT_HANDLE);
|
||||
setEnableForCustomHandle(string);
|
||||
this.addField(customHandle);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable customHandle field based on preference value
|
||||
*
|
||||
* @param preference
|
||||
*/
|
||||
private void setEnableForCustomHandle(String preference) {
|
||||
setEnabledForFieldEditor(
|
||||
customHandle,
|
||||
preference != null
|
||||
&& preference.equals(HandleOption.CUSTOM.name()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable or disable field editor
|
||||
*
|
||||
* @param editor
|
||||
* @param enabled
|
||||
*/
|
||||
private void setEnabledForFieldEditor(FieldEditor editor,
|
||||
boolean enabled){
|
||||
editor.setEnabled(enabled, getFieldEditorParent());
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,146 @@
|
|||
/**
|
||||
* 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.ui.prefs;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.jface.preference.IPersistentPreferenceStore;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Presence;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
|
||||
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.UserSearch;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants.HandleOption;
|
||||
|
||||
/**
|
||||
* Utility for default session handles
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Feb 3, 2014 2699 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HandleUtil {
|
||||
|
||||
private static final IUFStatusHandler log = UFStatus
|
||||
.getHandler(HandleUtil.class);
|
||||
|
||||
private static Map<String, String> fullNameMap = new HashMap<String, String>();
|
||||
|
||||
/**
|
||||
* @return default session handle from preferences
|
||||
*/
|
||||
public static String getDefaultHandle() {
|
||||
IPersistentPreferenceStore prefs = Activator.getDefault()
|
||||
.getPreferenceStore();
|
||||
String handlePrefStr = prefs
|
||||
.getString(CollabPrefConstants.DEFAULT_HANDLE);
|
||||
HandleOption handleOp = HandleOption.valueOf(handlePrefStr);
|
||||
|
||||
CollaborationConnection conn = CollaborationConnection.getConnection();
|
||||
|
||||
String rval = null;
|
||||
switch (handleOp) {
|
||||
case BLANK:
|
||||
rval = "";
|
||||
break;
|
||||
case USERNAME:
|
||||
rval = conn.getUser().getName();
|
||||
break;
|
||||
case FULLNAME:
|
||||
rval = getFullName(conn);
|
||||
break;
|
||||
case ROLE:
|
||||
Presence p = conn.getPresence();
|
||||
Object site = p.getProperty(SiteConfigInformation.SITE_NAME);
|
||||
Object role = p.getProperty(SiteConfigInformation.ROLE_NAME);
|
||||
if (site != null && role != null) {
|
||||
rval = site + " - " + role;
|
||||
} else {
|
||||
log.warn("Site and/or role not set in collaboration presence");
|
||||
}
|
||||
break;
|
||||
case CUSTOM:
|
||||
rval = prefs.getString(CollabPrefConstants.CUSTOM_HANDLE);
|
||||
break;
|
||||
}
|
||||
|
||||
if (rval == null) {
|
||||
rval = "";
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full name for account from server. Caches result. Returns null if
|
||||
* unable to search server and does not cache null.
|
||||
*
|
||||
* @param conn
|
||||
* @return
|
||||
*/
|
||||
public static String getFullName(CollaborationConnection conn) {
|
||||
String rval;
|
||||
UserId account = conn.getUser();
|
||||
synchronized (fullNameMap) {
|
||||
String fullName = fullNameMap.get(account.getNormalizedId());
|
||||
if (fullName == null) {
|
||||
String username = account.getName();
|
||||
UserSearch search = conn.createSearch();
|
||||
List<UserId> ids;
|
||||
try {
|
||||
ids = search.byUsername(username);
|
||||
} catch (XMPPException e) {
|
||||
log.error("Unable to search by username: " + username, e);
|
||||
ids = Collections.emptyList();
|
||||
}
|
||||
if (!ids.isEmpty()) {
|
||||
UserId id = ids.iterator().next();
|
||||
rval = id.getAlias();
|
||||
fullNameMap.put(account.getNormalizedId(), rval);
|
||||
} else {
|
||||
log.warn("Unable to find collaboration account via server search: "
|
||||
+ username);
|
||||
rval = null;
|
||||
}
|
||||
} else {
|
||||
rval = fullName;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue