Omaha #3708 collaboration feed room supports blacklists
refactored SiteConfigurationManager Change-Id: I74282074862674cac6b9190adafe38ed6d607dc5 Former-commit-id:5b24d1fd57
[formerly7d4dbd204e
] [formerlyc33a5ad562
] [formerlyc33a5ad562
[formerlydfb43fda31
]] [formerly2a7feaebfe
[formerlyc33a5ad562
[formerlydfb43fda31
] [formerly2a7feaebfe
[formerly 9b2e76141b7cdd49c145d9d54f83e49ba3ea0d78]]]] Former-commit-id:2a7feaebfe
Former-commit-id: ec25518bcff8e636c4518c64db05b12419fa2eb4 [formerly f8802ed9ae8429e0853425985fe3dec6fe60d41d] [formerly4429a04d2c
[formerly38b4d2683c
]] Former-commit-id:4429a04d2c
Former-commit-id:844cd86c28
This commit is contained in:
parent
3e90cda57e
commit
0d814e7b16
15 changed files with 1122 additions and 458 deletions
|
@ -0,0 +1,170 @@
|
|||
/**
|
||||
* 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.info;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
/**
|
||||
* Collaboration host configuration object
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2014 3708 bclement moved from SiteConfigurationInformation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class HostConfig {
|
||||
@XmlAttribute
|
||||
private String hostname;
|
||||
|
||||
@XmlAttribute
|
||||
private String prettyName;
|
||||
|
||||
@XmlAttribute
|
||||
private boolean removed = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public HostConfig() {
|
||||
}
|
||||
|
||||
public HostConfig(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname
|
||||
* the hostname to set
|
||||
*/
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the prettyName
|
||||
*/
|
||||
public String getPrettyName() {
|
||||
return prettyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prettyName
|
||||
* the prettyName to set
|
||||
*/
|
||||
public void setPrettyName(String prettyName) {
|
||||
this.prettyName = prettyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format for display to the user
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (prettyName == null) {
|
||||
return "Site Server : " + hostname;
|
||||
} else {
|
||||
return prettyName + " : " + hostname;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove description name from hostname
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public static String removeDescription(String text) {
|
||||
int firstColon = text.indexOf(':');
|
||||
if (firstColon >= 0) {
|
||||
text = text.substring(firstColon + 1);
|
||||
}
|
||||
return text.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the removed
|
||||
*/
|
||||
public boolean isRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param removed
|
||||
* the removed to set
|
||||
*/
|
||||
public void setRemoved(boolean removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((hostname == null) ? 0 : hostname.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
HostConfig other = (HostConfig) obj;
|
||||
if (hostname == null) {
|
||||
if (other.hostname != null)
|
||||
return false;
|
||||
} else if (!hostname.equals(other.hostname))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* 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.info;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlValue;
|
||||
|
||||
/**
|
||||
* Collaboration site configuration object. Stores site specific white/black
|
||||
* lists used for message filtering and forecaster roles. Roles are not
|
||||
* restricted by an enum, but usually are short term or long term forecaster.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2014 3708 bclement moved from SiteConfigurationInformation
|
||||
* added blacklist support
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class SiteConfig {
|
||||
|
||||
public static enum ListType {
|
||||
WHITELIST, BLACKLIST
|
||||
};
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public static class ListEntry {
|
||||
@XmlValue
|
||||
private String value;
|
||||
|
||||
@XmlAttribute
|
||||
private boolean removed = false;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ListEntry() {
|
||||
}
|
||||
|
||||
public ListEntry(String value, boolean removed) {
|
||||
this.value = value;
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param value
|
||||
* the value to set
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the removed
|
||||
*/
|
||||
public boolean isRemoved() {
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param removed
|
||||
* the removed to set
|
||||
*/
|
||||
public void setRemoved(boolean removed) {
|
||||
this.removed = removed;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAttribute
|
||||
private String site;
|
||||
|
||||
@XmlAttribute
|
||||
private ListType listType;
|
||||
|
||||
@XmlElement(name = "listEntry")
|
||||
private ListEntry[] listEntries;
|
||||
|
||||
@XmlElement
|
||||
private String[] roles;
|
||||
|
||||
/**
|
||||
* @return the site
|
||||
*/
|
||||
public String getSite() {
|
||||
return site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param site
|
||||
* the site to set
|
||||
*/
|
||||
public void setSite(String site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the role
|
||||
*/
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param role
|
||||
* the role to set
|
||||
*/
|
||||
public void setRoles(String[] roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the listType
|
||||
*/
|
||||
public ListType getListType() {
|
||||
return listType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listType
|
||||
* the listType to set
|
||||
*/
|
||||
public void setListType(ListType listType) {
|
||||
this.listType = listType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the listEntries
|
||||
*/
|
||||
public ListEntry[] getListEntries() {
|
||||
return listEntries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param listEntries
|
||||
* the listEntries to set
|
||||
*/
|
||||
public void setListEntries(ListEntry[] listEntries) {
|
||||
this.listEntries = listEntries;
|
||||
}
|
||||
|
||||
}
|
|
@ -23,7 +23,6 @@ import java.util.List;
|
|||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
@ -36,8 +35,9 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 12, 2012 mnash Initial creation
|
||||
* Jun 12, 2012 mnash Initial creation
|
||||
* Jan 08, 2014 2563 bclement added format/parse methods to HostConfig
|
||||
* Oct 10, 2014 3708 bclement moved HostConfig and SiteConfig to separate files
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -89,127 +89,4 @@ public class SiteConfigInformation {
|
|||
this.config = config;
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public static class HostConfig {
|
||||
@XmlAttribute
|
||||
private String hostname;
|
||||
|
||||
@XmlAttribute
|
||||
private String prettyName;
|
||||
|
||||
/**
|
||||
* @return the hostname
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param hostname
|
||||
* the hostname to set
|
||||
*/
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the prettyName
|
||||
*/
|
||||
public String getPrettyName() {
|
||||
return prettyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param prettyName
|
||||
* the prettyName to set
|
||||
*/
|
||||
public void setPrettyName(String prettyName) {
|
||||
this.prettyName = prettyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format for display to the user
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if (prettyName == null) {
|
||||
return "Site Server : " + hostname;
|
||||
} else {
|
||||
return prettyName + " : " + hostname;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove description name from hostname
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
public static String removeDescription(String text) {
|
||||
int firstColon = text.indexOf(':');
|
||||
if (firstColon >= 0) {
|
||||
text = text.substring(firstColon + 1);
|
||||
}
|
||||
return text.trim();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public static class SiteConfig {
|
||||
|
||||
@XmlAttribute
|
||||
private String site;
|
||||
|
||||
@XmlElement
|
||||
private String[] subscribedSites;
|
||||
|
||||
@XmlElement
|
||||
private String[] roles;
|
||||
|
||||
/**
|
||||
* @return the site
|
||||
*/
|
||||
public String getSite() {
|
||||
return site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param site
|
||||
* the site to set
|
||||
*/
|
||||
public void setSite(String site) {
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subscribedSites
|
||||
*/
|
||||
public String[] getSubscribedSites() {
|
||||
return subscribedSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subscribedSites
|
||||
* the subscribedSites to set
|
||||
*/
|
||||
public void setSubscribedSites(String[] subscribedSites) {
|
||||
this.subscribedSites = subscribedSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the role
|
||||
*/
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param role
|
||||
* the role to set
|
||||
*/
|
||||
public void setRoles(String[] roles) {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
import com.raytheon.uf.common.localization.LocalizationFile;
|
||||
import com.raytheon.uf.common.localization.PathManager;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor;
|
||||
|
||||
/**
|
||||
* Site coloring configuration manager
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 10, 2014 3708 bclement Moved color methods from SiteConfigurationManager
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SiteColorConfigManager {
|
||||
|
||||
private static SiteColorInformation colorInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private SiteColorConfigManager() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the colorInfo.xml file out to user localization so that the user
|
||||
* can retrieve it on CAVE restart
|
||||
*
|
||||
* @param information
|
||||
*/
|
||||
public static void writeSiteColorInformation(
|
||||
SiteColorInformation information) {
|
||||
colorInfo = information;
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lContext = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile file = pathMgr.getLocalizationFile(lContext,
|
||||
"collaboration" + File.separator + "colorInfo.xml");
|
||||
try {
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(SiteColorInformation.class);
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
|
||||
new Boolean(true));
|
||||
marshaller.marshal(information, file.getFile());
|
||||
file.save();
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.error(
|
||||
"Unable to write color information to file: "
|
||||
+ file.getName() + " in context " + lContext, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the colorInfo object so that the colors can be read in from
|
||||
* the colorInfo.xml file and retrieved from localization
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static SiteColorInformation getSiteColorInformation() {
|
||||
if (colorInfo == null) {
|
||||
PathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
Map<LocalizationLevel, LocalizationFile> files = pm
|
||||
.getTieredLocalizationFile(LocalizationType.CAVE_STATIC,
|
||||
"collaboration" + File.separator + "colorInfo.xml");
|
||||
LocalizationLevel[] levels = LocalizationLevel.values();
|
||||
|
||||
for (int i = levels.length - 1; i >= 0 && colorInfo == null; --i) {
|
||||
LocalizationLevel level = levels[i];
|
||||
if (level == LocalizationLevel.SITE
|
||||
|| level == LocalizationLevel.USER) {
|
||||
LocalizationFile file = files.get(level);
|
||||
if (file != null) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = file.openInputStream();
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(SiteColorInformation.class);
|
||||
Unmarshaller unmarshaller = context
|
||||
.createUnmarshaller();
|
||||
colorInfo = (SiteColorInformation) unmarshaller
|
||||
.unmarshal(in);
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.error(
|
||||
"Unable to read color information from file: "
|
||||
+ file.getName() + " in level "
|
||||
+ level, e);
|
||||
}
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
Activator.statusHandler.error(
|
||||
"Problem closing color information file: "
|
||||
+ file.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return colorInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of colors from site information config
|
||||
*/
|
||||
public static List<SiteColor> getSiteColors() {
|
||||
SiteColorInformation colorInfo = getSiteColorInformation();
|
||||
if (colorInfo != null) {
|
||||
return getSiteColorInformation().getColors();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -23,19 +23,23 @@ import java.io.File;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.xml.bind.DataBindingException;
|
||||
import javax.xml.bind.JAXB;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import com.raytheon.uf.common.localization.IPathManager;
|
||||
import org.apache.commons.collections.map.LRUMap;
|
||||
|
||||
import com.raytheon.uf.common.localization.FileUpdatedMessage;
|
||||
import com.raytheon.uf.common.localization.ILocalizationFileObserver;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
|
||||
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType;
|
||||
|
@ -47,10 +51,11 @@ import com.raytheon.uf.common.localization.exception.LocalizationException;
|
|||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig.ListEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig.ListType;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor;
|
||||
|
||||
/**
|
||||
* Parse a file to grab attributes about a user
|
||||
|
@ -61,10 +66,13 @@ import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 12, 2012 mnash Initial creation
|
||||
* Jun 12, 2012 mnash Initial creation
|
||||
* Jan 08, 2014 2563 bclement duplicate code elimination
|
||||
* added methods to partially modify user config
|
||||
* Jan 27, 2014 2700 bclement fixed null list from jaxb object
|
||||
* Oct 10, 2014 3708 bclement refactored to support blacklisting
|
||||
* moved color config to SiteColorConfigManager
|
||||
* site level now combined with site config
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -73,24 +81,39 @@ import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor;
|
|||
*/
|
||||
public class SiteConfigurationManager {
|
||||
|
||||
private static final IUFStatusHandler log = UFStatus.getHandler(SiteConfigurationManager.class);
|
||||
private static final IUFStatusHandler log = UFStatus
|
||||
.getHandler(SiteConfigurationManager.class);
|
||||
|
||||
private static SiteConfigInformation instance;
|
||||
private static final String PRIMARY_CONF_FILE = "config.xml";
|
||||
|
||||
private static SiteConfigInformation userInstance;
|
||||
private static SiteConfigInformation _siteInstance;
|
||||
|
||||
private static final ReentrantLock userConfigLock = new ReentrantLock();
|
||||
private static LocalizationFile siteConfigInfoFile;
|
||||
|
||||
private static SiteColorInformation colorInfo;
|
||||
private static SiteConfigInformation _userInstance;
|
||||
|
||||
private static LocalizationFile userConfigInfoFile;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static final Map<String, SiteVisiblityConfig> siteVisibilityMap = new LRUMap(
|
||||
2);
|
||||
|
||||
private static final ILocalizationFileObserver siteConfigObserver = new ILocalizationFileObserver() {
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedMessage message) {
|
||||
clear();
|
||||
}
|
||||
};
|
||||
|
||||
// level hierarchy for site config
|
||||
private static final LocalizationLevel[] siteLevels;
|
||||
|
||||
static{
|
||||
static {
|
||||
// load site levels with all levels except for USER
|
||||
PathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
LocalizationLevel[] available = pm.getAvailableLevels();
|
||||
List<LocalizationLevel> levels = new ArrayList<LocalizationLevel>(available.length -1);
|
||||
List<LocalizationLevel> levels = new ArrayList<LocalizationLevel>(
|
||||
available.length - 1);
|
||||
for (int i = available.length - 1; i >= 0; --i) {
|
||||
if (!available[i].equals(LocalizationLevel.USER)) {
|
||||
levels.add(available[i]);
|
||||
|
@ -102,15 +125,17 @@ public class SiteConfigurationManager {
|
|||
/**
|
||||
* Get first localization file for SiteConfigInformation found in levels
|
||||
*
|
||||
* @param filename
|
||||
* config file name
|
||||
* @param levels
|
||||
* localization levels to search in order
|
||||
* @return null if none found
|
||||
*/
|
||||
private static LocalizationFile findConfigLocalizationFile(
|
||||
private static LocalizationFile findConfigLocalizationFile(String filename,
|
||||
LocalizationLevel[] levels) {
|
||||
LocalizationFile rval = null;
|
||||
for (LocalizationLevel level : levels) {
|
||||
rval = getConfigLocalizationFile(level);
|
||||
rval = getConfigLocalizationFile(filename, level);
|
||||
if (rval != null && rval.exists()) {
|
||||
break;
|
||||
}
|
||||
|
@ -121,29 +146,28 @@ public class SiteConfigurationManager {
|
|||
/**
|
||||
* Get LocalizationFile for SiteConfigInformation at specified level.
|
||||
*
|
||||
* @param filename
|
||||
* config file name
|
||||
* @param level
|
||||
* @return
|
||||
*/
|
||||
private static LocalizationFile getConfigLocalizationFile(
|
||||
private static LocalizationFile getConfigLocalizationFile(String filename,
|
||||
LocalizationLevel level) {
|
||||
PathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
LocalizationContext localContext = pm.getContext(
|
||||
LocalizationType.CAVE_STATIC, level);
|
||||
return pm.getLocalizationFile(localContext, "collaboration"
|
||||
+ File.separator + "config.xml");
|
||||
+ File.separator + filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read configuration file from file system. Must be externally
|
||||
* synchronized.
|
||||
*
|
||||
* @param levels
|
||||
* localization levels to search in order
|
||||
* @return null if configuration file wasn't found or an error occurred
|
||||
*/
|
||||
private static SiteConfigInformation readConfigInformation(
|
||||
LocalizationLevel[] levels) {
|
||||
LocalizationFile file = findConfigLocalizationFile(levels);
|
||||
LocalizationFile file) {
|
||||
SiteConfigInformation rval = null;
|
||||
if (file != null && file.exists()) {
|
||||
InputStream in = null;
|
||||
|
@ -182,7 +206,8 @@ public class SiteConfigurationManager {
|
|||
private static void writeConfigInformation(LocalizationLevel level,
|
||||
SiteConfigInformation config) throws JAXBException,
|
||||
LocalizationException {
|
||||
LocalizationFile file = getConfigLocalizationFile(level);
|
||||
LocalizationFile file = getConfigLocalizationFile(PRIMARY_CONF_FILE,
|
||||
level);
|
||||
LocalizationFileOutputStream out = null;
|
||||
try {
|
||||
out = file.openOutputStream();
|
||||
|
@ -191,7 +216,7 @@ public class SiteConfigurationManager {
|
|||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
|
||||
new Boolean(true));
|
||||
marshaller.marshal(userInstance, out);
|
||||
marshaller.marshal(config, out);
|
||||
} finally {
|
||||
if (out != null) {
|
||||
try {
|
||||
|
@ -204,16 +229,19 @@ public class SiteConfigurationManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Go to the config.xml file and grab the user information, for use in
|
||||
* determining what kind of user you are in collaboration
|
||||
* Read site level configuration file
|
||||
*
|
||||
* @return
|
||||
* @return null if no file was found or file is invalid
|
||||
*/
|
||||
public static synchronized SiteConfigInformation getSiteConfigInformation() {
|
||||
if (instance == null) {
|
||||
SiteConfigInformation info = readConfigInformation(siteLevels);
|
||||
private static SiteConfigInformation getSiteConfigInformation() {
|
||||
if (_siteInstance == null) {
|
||||
LocalizationFile file = findConfigLocalizationFile(
|
||||
PRIMARY_CONF_FILE, siteLevels);
|
||||
SiteConfigInformation info = readConfigInformation(file);
|
||||
if (isValid(info)) {
|
||||
instance = info;
|
||||
_siteInstance = info;
|
||||
file.addFileUpdatedObserver(siteConfigObserver);
|
||||
siteConfigInfoFile = file;
|
||||
} else {
|
||||
log.handle(Priority.PROBLEM,
|
||||
"Misconfigured config.xml file at site level. "
|
||||
|
@ -223,50 +251,28 @@ public class SiteConfigurationManager {
|
|||
+ " attributes.");
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
return _siteInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the colorInfo.xml file out to user localization so that the user
|
||||
* can retrieve it on CAVE restart
|
||||
* Read user level configuration file. Creates new file if not found.
|
||||
*
|
||||
* @param information
|
||||
* @return
|
||||
*/
|
||||
public static void writeSiteColorInformation(
|
||||
SiteColorInformation information) {
|
||||
colorInfo = information;
|
||||
IPathManager pathMgr = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lContext = pathMgr.getContext(
|
||||
LocalizationType.CAVE_STATIC, LocalizationLevel.USER);
|
||||
LocalizationFile file = pathMgr.getLocalizationFile(lContext,
|
||||
"collaboration" + File.separator + "colorInfo.xml");
|
||||
try {
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(SiteColorInformation.class);
|
||||
Marshaller marshaller = context.createMarshaller();
|
||||
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
|
||||
new Boolean(true));
|
||||
marshaller.marshal(information, file.getFile());
|
||||
file.save();
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows users to have their own extra configured sites, but does not check
|
||||
* for validity as we don't have to have a role or a site specified. Must be
|
||||
* externally synchronized.
|
||||
*/
|
||||
private static void readUserSiteConfigInformation() {
|
||||
// we always want to read/write the same localization file, only give
|
||||
// one level to search
|
||||
userInstance = readConfigInformation(new LocalizationLevel[] { LocalizationLevel.USER });
|
||||
if (userInstance == null) {
|
||||
// user config doesn't exist, create a new one
|
||||
userInstance = new SiteConfigInformation();
|
||||
private static SiteConfigInformation getUserConfigInformation() {
|
||||
if (_userInstance == null) {
|
||||
LocalizationFile file = getConfigLocalizationFile(
|
||||
PRIMARY_CONF_FILE, LocalizationLevel.USER);
|
||||
SiteConfigInformation info = readConfigInformation(file);
|
||||
if (info == null) {
|
||||
// user config doesn't exist, create a new one
|
||||
info = new SiteConfigInformation();
|
||||
file.addFileUpdatedObserver(siteConfigObserver);
|
||||
userConfigInfoFile = file;
|
||||
}
|
||||
_userInstance = info;
|
||||
}
|
||||
return _userInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -274,31 +280,34 @@ public class SiteConfigurationManager {
|
|||
*
|
||||
* @param userEnabledSites
|
||||
*/
|
||||
public static void writeUserEnabledSites(String[] userEnabledSites) {
|
||||
userConfigLock.lock();
|
||||
private static void writeUserConfiguredVisibility(
|
||||
SiteVisiblityConfig visibility) {
|
||||
try {
|
||||
if (userInstance == null) {
|
||||
readUserSiteConfigInformation();
|
||||
}
|
||||
// update object
|
||||
List<SiteConfig> configs = userInstance.getConfig();
|
||||
SiteConfig config;
|
||||
if (configs == null || configs.isEmpty()) {
|
||||
configs = new ArrayList<SiteConfigInformation.SiteConfig>(1);
|
||||
config = new SiteConfig();
|
||||
configs.add(config);
|
||||
userInstance.setConfig(configs);
|
||||
} else {
|
||||
config = configs.get(0);
|
||||
}
|
||||
config.setSubscribedSites(userEnabledSites);
|
||||
SiteConfigInformation userInstance = getUserConfigInformation();
|
||||
Map<String, ListEntry> userSpecificConfigs = visibility
|
||||
.getUserSpecificConfigs();
|
||||
if (!userSpecificConfigs.isEmpty()) {
|
||||
String site = visibility.getActingSite();
|
||||
SiteConfig siteConfig = getSiteConfig(userInstance, site);
|
||||
if (siteConfig == null) {
|
||||
siteConfig = new SiteConfig();
|
||||
siteConfig.setSite(site);
|
||||
List<SiteConfig> configs = userInstance.getConfig();
|
||||
if (configs == null) {
|
||||
configs = new ArrayList<>(1);
|
||||
userInstance.setConfig(configs);
|
||||
}
|
||||
configs.add(siteConfig);
|
||||
}
|
||||
ListEntry[] entries = userSpecificConfigs.values().toArray(
|
||||
new ListEntry[0]);
|
||||
siteConfig.setListEntries(entries);
|
||||
|
||||
// update on file system
|
||||
writeConfigInformation(LocalizationLevel.USER, userInstance);
|
||||
// update on file system
|
||||
writeConfigInformation(LocalizationLevel.USER, userInstance);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.handle(Priority.PROBLEM, e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
userConfigLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -308,40 +317,54 @@ public class SiteConfigurationManager {
|
|||
*
|
||||
* @param config
|
||||
*/
|
||||
public static void addUserHostConfig(HostConfig config){
|
||||
userConfigLock.lock();
|
||||
try{
|
||||
if(userInstance == null){
|
||||
readUserSiteConfigInformation();
|
||||
}
|
||||
synchronized public static void addUserHostConfig(HostConfig config) {
|
||||
updateUserHostConfig(config, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update user level host overrides
|
||||
*
|
||||
* @param config
|
||||
* @param remove
|
||||
* true if the host entry specifies that the user doesn't want to
|
||||
* see the host in the UI
|
||||
*/
|
||||
private static void updateUserHostConfig(HostConfig config, boolean remove) {
|
||||
try {
|
||||
SiteConfigInformation userInstance = getUserConfigInformation();
|
||||
List<HostConfig> servers = userInstance.getServer();
|
||||
if (servers == null){
|
||||
servers = new ArrayList<SiteConfigInformation.HostConfig>(1);
|
||||
if (servers == null) {
|
||||
servers = new ArrayList<HostConfig>(1);
|
||||
userInstance.setServer(servers);
|
||||
}
|
||||
if (!hasHost(servers, config)) {
|
||||
HostConfig existing = findHost(servers, config);
|
||||
if (existing == null) {
|
||||
config.setRemoved(remove);
|
||||
servers.add(config);
|
||||
writeConfigInformation(LocalizationLevel.USER, userInstance);
|
||||
} else if (existing.isRemoved() != remove) {
|
||||
existing.setRemoved(remove);
|
||||
existing.setPrettyName(config.getPrettyName());
|
||||
writeConfigInformation(LocalizationLevel.USER, userInstance);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
userConfigLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param servers
|
||||
* @param config
|
||||
* @return true if the hostname in config matches any in servers
|
||||
* @return null if matching host config not found
|
||||
*/
|
||||
private static boolean hasHost(List<HostConfig> servers, HostConfig config) {
|
||||
private static HostConfig findHost(List<HostConfig> servers,
|
||||
HostConfig config) {
|
||||
for (HostConfig hc : servers) {
|
||||
if (hc.getHostname().equalsIgnoreCase(config.getHostname())) {
|
||||
return true;
|
||||
return hc;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -351,100 +374,58 @@ public class SiteConfigurationManager {
|
|||
* @param serverAddress
|
||||
*/
|
||||
public static void removeUserHostConfig(String serverAddress) {
|
||||
userConfigLock.lock();
|
||||
try {
|
||||
if (userInstance == null) {
|
||||
readUserSiteConfigInformation();
|
||||
}
|
||||
List<HostConfig> servers = userInstance.getServer();
|
||||
if (servers != null) {
|
||||
List<HostConfig> newServers = new ArrayList<HostConfig>();
|
||||
for (HostConfig hc : servers) {
|
||||
if (!hc.getHostname().equalsIgnoreCase(serverAddress)) {
|
||||
newServers.add(hc);
|
||||
}
|
||||
}
|
||||
userInstance.setServer(newServers);
|
||||
writeConfigInformation(LocalizationLevel.USER, userInstance);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getLocalizedMessage(), e);
|
||||
} finally {
|
||||
userConfigLock.unlock();
|
||||
}
|
||||
updateUserHostConfig(new HostConfig(serverAddress), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get host configuration added by this user.
|
||||
* Constructs a list of host configs from the site level configs and the
|
||||
* user level overrides
|
||||
*
|
||||
* @return empty list if none are found
|
||||
* @return empty list if none found
|
||||
*/
|
||||
public static List<HostConfig> getUserHostConfig() {
|
||||
List<HostConfig> rval;
|
||||
userConfigLock.lock();
|
||||
try {
|
||||
if (userInstance == null) {
|
||||
readUserSiteConfigInformation();
|
||||
synchronized public static Collection<HostConfig> getHostConfigs() {
|
||||
List<HostConfig> userConfigured = getUserHostConfigs();
|
||||
SiteConfigInformation siteConfigInformation = getSiteConfigInformation();
|
||||
if (siteConfigInformation == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<HostConfig> siteConfigured = siteConfigInformation.getServer();
|
||||
if (siteConfigured == null) {
|
||||
siteConfigured = new ArrayList<>(0);
|
||||
}
|
||||
|
||||
Collection<HostConfig> rval;
|
||||
if (userConfigured.isEmpty()) {
|
||||
rval = siteConfigured;
|
||||
} else {
|
||||
rval = new HashSet<HostConfig>(siteConfigured);
|
||||
for (HostConfig user : userConfigured) {
|
||||
if (user.isRemoved()) {
|
||||
rval.remove(user);
|
||||
} else {
|
||||
rval.add(user);
|
||||
}
|
||||
}
|
||||
List<HostConfig> servers = userInstance.getServer();
|
||||
if (servers == null) {
|
||||
rval = new ArrayList<HostConfig>(0);
|
||||
} else {
|
||||
rval = new ArrayList<HostConfig>(servers);
|
||||
}
|
||||
} finally {
|
||||
userConfigLock.unlock();
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the colorInfo object so that the colors can be read in from
|
||||
* the colorInfo.xml file and retrieved from localization
|
||||
* Get host configuration added by this user. Must be externally read
|
||||
* locked.
|
||||
*
|
||||
* @return
|
||||
* @return empty list if none are found
|
||||
*/
|
||||
public static SiteColorInformation getSiteColorInformation() {
|
||||
if (colorInfo == null) {
|
||||
PathManager pm = (PathManager) PathManagerFactory.getPathManager();
|
||||
Map<LocalizationLevel, LocalizationFile> files = pm
|
||||
.getTieredLocalizationFile(LocalizationType.CAVE_STATIC,
|
||||
"collaboration" + File.separator + "colorInfo.xml");
|
||||
LocalizationLevel[] levels = LocalizationLevel.values();
|
||||
|
||||
for (int i = levels.length - 1; i >= 0 && colorInfo == null; --i) {
|
||||
LocalizationLevel level = levels[i];
|
||||
if (level == LocalizationLevel.SITE
|
||||
|| level == LocalizationLevel.USER) {
|
||||
LocalizationFile file = files.get(level);
|
||||
if (file != null) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
in = file.openInputStream();
|
||||
JAXBContext context = JAXBContext
|
||||
.newInstance(SiteColorInformation.class);
|
||||
Unmarshaller unmarshaller = context
|
||||
.createUnmarshaller();
|
||||
colorInfo = (SiteColorInformation) unmarshaller
|
||||
.unmarshal(in);
|
||||
} catch (Exception e) {
|
||||
Activator.statusHandler.handle(Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
Activator.statusHandler.handle(
|
||||
Priority.PROBLEM,
|
||||
e.getLocalizedMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static List<HostConfig> getUserHostConfigs() {
|
||||
List<HostConfig> rval;
|
||||
SiteConfigInformation userInstance = getUserConfigInformation();
|
||||
List<HostConfig> servers = userInstance.getServer();
|
||||
if (servers == null) {
|
||||
rval = new ArrayList<HostConfig>(0);
|
||||
} else {
|
||||
rval = new ArrayList<HostConfig>(servers);
|
||||
}
|
||||
return colorInfo;
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -464,70 +445,157 @@ public class SiteConfigurationManager {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get list of subscribed sites from site configuration
|
||||
* Gets configuration objects for sites. Does not include user level
|
||||
* overrides.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
synchronized public static Collection<SiteConfig> getSiteConfigs() {
|
||||
Collection<SiteConfig> rval;
|
||||
SiteConfigInformation info = getSiteConfigInformation();
|
||||
if (info == null) {
|
||||
rval = Collections.emptyList();
|
||||
} else {
|
||||
List<SiteConfig> configs = info.getConfig();
|
||||
if (configs == null) {
|
||||
rval = Collections.emptyList();
|
||||
} else {
|
||||
rval = configs;
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actingSite
|
||||
* @param otherSite
|
||||
* @return true if the configuration for the acting site shows the other
|
||||
* site as visible (takes into account user level overrides)
|
||||
*/
|
||||
synchronized public static boolean isVisible(String actingSite,
|
||||
String otherSite) {
|
||||
SiteVisiblityConfig config = getSiteVisibilityConfig(actingSite);
|
||||
return config.isVisible(otherSite);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user level override for the acting site config to set the other
|
||||
* site as visible
|
||||
*
|
||||
* @param actingSite
|
||||
* @param otherSite
|
||||
*/
|
||||
synchronized public static void showSite(String actingSite, String otherSite) {
|
||||
SiteVisiblityConfig config = getSiteVisibilityConfig(actingSite);
|
||||
config.show(otherSite);
|
||||
writeUserConfiguredVisibility(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user level override for the acting site config to set the other
|
||||
* site as not visible
|
||||
*
|
||||
* @param actingSite
|
||||
* @param otherSite
|
||||
*/
|
||||
synchronized public static void hideSite(String actingSite, String otherSite) {
|
||||
SiteVisiblityConfig config = getSiteVisibilityConfig(actingSite);
|
||||
config.hide(otherSite);
|
||||
writeUserConfiguredVisibility(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get site visibility configuration for acting site
|
||||
*
|
||||
* @param site
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getSubscribeList(String site) {
|
||||
List<String> subscribed = new ArrayList<String>();
|
||||
if (instance.getConfig() != null) {
|
||||
for (SiteConfig config : instance.getConfig()) {
|
||||
if (config.getSite().equals(site)) {
|
||||
subscribed = Arrays.asList(config.getSubscribedSites());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return subscribed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the user subscribe list
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<String> getUserSubscribeList() {
|
||||
List<String> subscribed = new ArrayList<String>();
|
||||
userConfigLock.lock();
|
||||
try {
|
||||
if (userInstance == null) {
|
||||
readUserSiteConfigInformation();
|
||||
}
|
||||
if (userInstance != null && userInstance.getConfig() != null) {
|
||||
for (SiteConfig config : userInstance.getConfig()) {
|
||||
if (config.getSubscribedSites() != null) {
|
||||
subscribed = new ArrayList<String>();
|
||||
for (String item : config.getSubscribedSites()) {
|
||||
subscribed.add(item);
|
||||
}
|
||||
private static SiteVisiblityConfig getSiteVisibilityConfig(String site) {
|
||||
SiteVisiblityConfig rval = null;
|
||||
rval = siteVisibilityMap.get(site);
|
||||
if (rval == null) {
|
||||
Map<String, ListEntry> userSpecificConfigs = getUserSpecificConfigs(site);
|
||||
SiteConfigInformation siteInstance = getSiteConfigInformation();
|
||||
if (siteInstance != null && siteInstance.getConfig() != null) {
|
||||
for (SiteConfig config : siteInstance.getConfig()) {
|
||||
if (config.getSite().equals(site)) {
|
||||
rval = new SiteVisiblityConfig(config,
|
||||
userSpecificConfigs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
userConfigLock.unlock();
|
||||
if (rval == null) {
|
||||
/*
|
||||
* this shouldn't happen since you have to have an entry in the
|
||||
* site configuration file to log in
|
||||
*/
|
||||
log.warn("No configuration found for site '" + site
|
||||
+ "'. Defaulting to showing all sites.");
|
||||
rval = new SiteVisiblityConfig(site, new HashSet<String>(0),
|
||||
ListType.BLACKLIST, userSpecificConfigs);
|
||||
} else {
|
||||
siteVisibilityMap.put(site, rval);
|
||||
}
|
||||
}
|
||||
return subscribed;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of colors from site information config
|
||||
* Get user level overrides for site visibility
|
||||
*
|
||||
* @param site
|
||||
* @return site configs indexed by name
|
||||
*/
|
||||
public static List<SiteColor> getSiteColors() {
|
||||
SiteColorInformation colorInfo = getSiteColorInformation();
|
||||
if (colorInfo != null) {
|
||||
return getSiteColorInformation().getColors();
|
||||
} else {
|
||||
return null;
|
||||
private static Map<String, ListEntry> getUserSpecificConfigs(String site) {
|
||||
Map<String, ListEntry> rval = new HashMap<>();
|
||||
SiteConfigInformation userInstance = getUserConfigInformation();
|
||||
SiteConfig siteConfig = getSiteConfig(userInstance, site);
|
||||
if (siteConfig != null) {
|
||||
ListEntry[] entries = siteConfig.getListEntries();
|
||||
if (entries != null) {
|
||||
for (ListEntry entry : entries) {
|
||||
rval.put(entry.getValue(), entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param info
|
||||
* @param site
|
||||
* @return null if no config exists for privided site in info
|
||||
*/
|
||||
private static SiteConfig getSiteConfig(SiteConfigInformation info,
|
||||
String site) {
|
||||
SiteConfig rval = null;
|
||||
if (info.getConfig() != null) {
|
||||
for (SiteConfig config : info.getConfig()) {
|
||||
if (config.getSite().equals(site)) {
|
||||
rval = config;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset in-memory configuration
|
||||
*/
|
||||
public static void nullifySiteConfigInstance() {
|
||||
instance = null;
|
||||
userInstance = null;
|
||||
synchronized private static void clear() {
|
||||
if (siteConfigInfoFile != null) {
|
||||
siteConfigInfoFile.removeFileUpdatedObserver(siteConfigObserver);
|
||||
siteConfigInfoFile = null;
|
||||
}
|
||||
_siteInstance = null;
|
||||
if (userConfigInfoFile != null) {
|
||||
userConfigInfoFile.removeFileUpdatedObserver(siteConfigObserver);
|
||||
userConfigInfoFile = null;
|
||||
}
|
||||
_userInstance = null;
|
||||
siteVisibilityMap.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig.ListEntry;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig.ListType;
|
||||
|
||||
/**
|
||||
* Configuration that determines if the user should see messages from other
|
||||
* sites
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 9, 2014 3708 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SiteVisiblityConfig {
|
||||
|
||||
private final String actingSite;
|
||||
|
||||
private final Set<String> sites;
|
||||
|
||||
private final Map<String, ListEntry> userSpecificConfigs;
|
||||
|
||||
private final ListType listType;
|
||||
|
||||
/**
|
||||
* @param config
|
||||
* @param userSpecificConfigs
|
||||
*/
|
||||
public SiteVisiblityConfig(SiteConfig config,
|
||||
Map<String, ListEntry> userSpecificConfigs) {
|
||||
ListType lt = config.getListType();
|
||||
if (lt == null) {
|
||||
lt = ListType.WHITELIST;
|
||||
}
|
||||
this.listType = lt;
|
||||
this.actingSite = config.getSite();
|
||||
this.userSpecificConfigs = userSpecificConfigs;
|
||||
ListEntry[] listEntries = config.getListEntries();
|
||||
if (listEntries != null) {
|
||||
this.sites = new HashSet<String>(listEntries.length);
|
||||
for (ListEntry entry : listEntries) {
|
||||
this.sites.add(entry.getValue());
|
||||
}
|
||||
} else {
|
||||
this.sites = Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actingSite
|
||||
* @param sites
|
||||
* @param listType
|
||||
* @param userSpecificConfigs
|
||||
*/
|
||||
public SiteVisiblityConfig(String actingSite, Set<String> sites,
|
||||
ListType listType, Map<String, ListEntry> userSpecificConfigs) {
|
||||
this.sites = sites;
|
||||
this.listType = listType;
|
||||
this.actingSite = actingSite;
|
||||
this.userSpecificConfigs = userSpecificConfigs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param site
|
||||
* @return true if messages from site should be shown to user
|
||||
*/
|
||||
public boolean isVisible(String site) {
|
||||
ListEntry userSettings = userSpecificConfigs.get(site);
|
||||
if (userSettings != null) {
|
||||
return !userSettings.isRemoved();
|
||||
} else {
|
||||
if (isWhitelist()) {
|
||||
return sites.contains(site);
|
||||
} else {
|
||||
return !sites.contains(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow messages from site to be seen
|
||||
*
|
||||
* @param site
|
||||
*/
|
||||
public void show(String site) {
|
||||
userSpecificConfigs.put(site, new ListEntry(site, false));
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't show messages from site
|
||||
*
|
||||
* @param site
|
||||
*/
|
||||
public void hide(String site) {
|
||||
userSpecificConfigs.put(site, new ListEntry(site, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return filter list for sites. see {@link #isWhitelist()}
|
||||
*/
|
||||
public String[] getSites() {
|
||||
return sites.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if filter list is a whitelist, false if it is a blacklist
|
||||
*/
|
||||
public boolean isWhitelist() {
|
||||
return listType.equals(ListType.WHITELIST);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actingSite
|
||||
*/
|
||||
public String getActingSite() {
|
||||
return actingSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the userSpecificConfigs
|
||||
*/
|
||||
public Map<String, ListEntry> getUserSpecificConfigs() {
|
||||
return userSpecificConfigs;
|
||||
}
|
||||
|
||||
}
|
|
@ -31,8 +31,8 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
|
||||
|
@ -46,6 +46,7 @@ import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 5, 2012 bsteffen Initial creation
|
||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -122,13 +123,11 @@ public class ChangeRoleAction extends Action {
|
|||
}
|
||||
|
||||
private void fill() {
|
||||
SiteConfigInformation siteInfo = SiteConfigurationManager
|
||||
.getSiteConfigInformation();
|
||||
Presence presence = CollaborationConnection.getConnection()
|
||||
.getPresence();
|
||||
String currentSite = (String) presence
|
||||
.getProperty(SiteConfigInformation.SITE_NAME);
|
||||
for (SiteConfig config : siteInfo.getConfig()) {
|
||||
for (SiteConfig config : SiteConfigurationManager.getSiteConfigs()) {
|
||||
if (config.getSite().equals(currentSite)) {
|
||||
for (String role : config.getRoles()) {
|
||||
Action action = new ChangeRoleAction(role);
|
||||
|
|
|
@ -31,11 +31,11 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
|
|||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SubscribeList;
|
||||
import com.raytheon.uf.viz.collaboration.ui.session.SiteChangeEvent;
|
||||
|
||||
/**
|
||||
* Change the site for the logged in user
|
||||
|
@ -47,6 +47,7 @@ import com.raytheon.uf.viz.collaboration.ui.session.SubscribeList;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 5, 2012 bsteffen Initial creation
|
||||
* Oct 10, 2014 3708 bclement added SiteChangeEvent
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -91,11 +92,8 @@ public class ChangeSiteAction extends Action {
|
|||
|
||||
Presence presence = connection.getPresence();
|
||||
presence.setProperty(SiteConfigInformation.SITE_NAME, site);
|
||||
// now need to send the new subscribe list out to those who are
|
||||
// listening for it
|
||||
SubscribeList list = new SubscribeList();
|
||||
list.setEnabledSites(SiteConfigurationManager.getSubscribeList(site));
|
||||
connection.postEvent(list);
|
||||
/* now need to send the new site out to those who are listening for it */
|
||||
connection.postEvent(new SiteChangeEvent(site));
|
||||
|
||||
try {
|
||||
connection.getAccountManager().sendPresence(presence);
|
||||
|
@ -129,9 +127,7 @@ public class ChangeSiteAction extends Action {
|
|||
}
|
||||
|
||||
private void fill() {
|
||||
SiteConfigInformation siteInfo = SiteConfigurationManager
|
||||
.getSiteConfigInformation();
|
||||
for (SiteConfig config : siteInfo.getConfig()) {
|
||||
for (SiteConfig config : SiteConfigurationManager.getSiteConfigs()) {
|
||||
Action action = new ChangeSiteAction(config.getSite());
|
||||
IContributionItem contrib = new ActionContributionItem(action);
|
||||
contrib.fill(menu, -1);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui.login;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -45,12 +46,11 @@ import org.jivesoftware.smack.packet.Presence;
|
|||
import org.jivesoftware.smack.packet.Presence.Mode;
|
||||
import org.jivesoftware.smack.packet.Presence.Type;
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.CollaborationException;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.SiteConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.Tools;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnectionData;
|
||||
|
@ -79,6 +79,7 @@ import com.raytheon.uf.viz.collaboration.ui.prefs.CollabPrefConstants;
|
|||
* Apr 11, 2014 2903 bclement added success flag, moved login logic to static method
|
||||
* fixed populating server with previous, removed password from heap
|
||||
* Apr 23, 2014 2822 bclement added version to initial presence
|
||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -171,19 +172,13 @@ public class LoginDialog extends Dialog {
|
|||
serverText.setLayoutData(gd);
|
||||
|
||||
// retrieve the servers
|
||||
SiteConfigInformation information = SiteConfigurationManager
|
||||
.getSiteConfigInformation();
|
||||
List<HostConfig> siteServers = information.getServer();
|
||||
if (siteServers == null) {
|
||||
siteServers = new ArrayList<SiteConfigInformation.HostConfig>(0);
|
||||
}
|
||||
List<HostConfig> userServers = SiteConfigurationManager
|
||||
.getUserHostConfig();
|
||||
Collection<HostConfig> servers = SiteConfigurationManager
|
||||
.getHostConfigs();
|
||||
|
||||
// put configured as true so we don't disable the login button
|
||||
serverText.setData("configured", true);
|
||||
String[] names = new String[siteServers.size() + userServers.size()];
|
||||
Iterator<HostConfig> iter = Iterators.concat(siteServers.iterator(),
|
||||
userServers.iterator());
|
||||
String[] names = new String[servers.size()];
|
||||
Iterator<HostConfig> iter = servers.iterator();
|
||||
int index = 0;
|
||||
String prevServer = loginData.getServer();
|
||||
for (int i = 0; iter.hasNext() && i < names.length; i++) {
|
||||
|
@ -264,11 +259,11 @@ public class LoginDialog extends Dialog {
|
|||
comp.setLayoutData(gd);
|
||||
|
||||
// TODO: Default to previous settings
|
||||
SiteConfigInformation information = SiteConfigurationManager
|
||||
.getSiteConfigInformation();
|
||||
Collection<SiteConfig> configs = SiteConfigurationManager
|
||||
.getSiteConfigs();
|
||||
List<String> sites = new ArrayList<String>();
|
||||
final Map<String, String[]> roles = new HashMap<String, String[]>();
|
||||
for (SiteConfig conf : information.getConfig()) {
|
||||
for (SiteConfig conf : configs) {
|
||||
sites.add(conf.getSite());
|
||||
roles.put(conf.getSite(), conf.getRoles());
|
||||
}
|
||||
|
@ -387,7 +382,6 @@ public class LoginDialog extends Dialog {
|
|||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
SiteConfigurationManager.nullifySiteConfigInstance();
|
||||
shell.dispose();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui.login;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.jface.window.Window;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
|
@ -31,7 +31,7 @@ import org.eclipse.swt.widgets.Event;
|
|||
import org.eclipse.swt.widgets.Listener;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformation.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.comm.identity.info.HostConfig;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
|
||||
/**
|
||||
|
@ -49,6 +49,7 @@ import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
|||
* Jan 07, 2014 2563 bclement updated default xmpp port
|
||||
* Jan 08, 2014 2563 bclement renamed from ServerInput to ServerListListener
|
||||
* moved input responsibility to ServerInputDialog
|
||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -115,11 +116,10 @@ public class ServerListListener implements Listener {
|
|||
*/
|
||||
private void remove() {
|
||||
Shell shell = Display.getCurrent().getActiveShell();
|
||||
List<HostConfig> userHosts = SiteConfigurationManager
|
||||
.getUserHostConfig();
|
||||
if (!userHosts.isEmpty()) {
|
||||
String[] options = new String[userHosts.size()];
|
||||
Iterator<HostConfig> iter = userHosts.iterator();
|
||||
Collection<HostConfig> hosts = SiteConfigurationManager.getHostConfigs();
|
||||
if (!hosts.isEmpty()) {
|
||||
String[] options = new String[hosts.size()];
|
||||
Iterator<HostConfig> iter = hosts.iterator();
|
||||
for (int i = 0; iter.hasNext() && i < options.length; ++i) {
|
||||
options[i] = iter.next().toString();
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
|
@ -40,6 +39,7 @@ import com.raytheon.uf.viz.collaboration.comm.provider.user.UserId;
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.display.data.SessionColorManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
|
||||
/**
|
||||
* Generate the Participant's label and icon image.
|
||||
|
@ -57,6 +57,7 @@ import com.raytheon.uf.viz.collaboration.ui.AbstractUserLabelProvider;
|
|||
* Feb 13, 2014 2751 bclement VenueParticipant refactor
|
||||
* Feb 13, 2014 2751 njensen Added leader icons
|
||||
* Feb 18, 2014 2751 bclement changed tooltip from JID to UserId
|
||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager changes, added actingSite
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,7 +70,7 @@ public class ParticipantsLabelProvider extends
|
|||
|
||||
protected String sessionId = null;
|
||||
|
||||
private List<String> enabledSites;
|
||||
private String actingSite;
|
||||
|
||||
protected Map<RGB, Color> colors = new HashMap<RGB, Color>();
|
||||
|
||||
|
@ -220,8 +221,13 @@ public class ParticipantsLabelProvider extends
|
|||
if (presence != null) {
|
||||
String site = String.valueOf(presence
|
||||
.getProperty(SiteConfigInformation.SITE_NAME));
|
||||
if (enabledSites != null && enabledSites.contains(site)) {
|
||||
builder.append("\n").append("Subscribed");
|
||||
if (actingSite != null
|
||||
&& SiteConfigurationManager.isVisible(actingSite, site)) {
|
||||
builder.append("\n").append(
|
||||
"Messages from " + site + " are shown");
|
||||
} else {
|
||||
builder.append("\n").append(
|
||||
"Messages from " + site + " are hidden");
|
||||
}
|
||||
}
|
||||
if (isSomeKindOfLeader(user)) {
|
||||
|
@ -235,8 +241,11 @@ public class ParticipantsLabelProvider extends
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
protected void setEnabledSites(List<String> enabledSites) {
|
||||
this.enabledSites = enabledSites;
|
||||
/**
|
||||
* @param actingSite
|
||||
*/
|
||||
public void setActingSite(String actingSite) {
|
||||
this.actingSite = actingSite;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.raytheon.uf.viz.collaboration.comm.identity.info.SiteConfigInformatio
|
|||
import com.raytheon.uf.viz.collaboration.comm.provider.connection.CollaborationConnection;
|
||||
import com.raytheon.uf.viz.collaboration.comm.provider.user.VenueParticipant;
|
||||
import com.raytheon.uf.viz.collaboration.ui.Activator;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteColorConfigManager;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteColorInformation.SiteColor;
|
||||
import com.raytheon.uf.viz.collaboration.ui.SiteConfigurationManager;
|
||||
|
@ -75,6 +76,7 @@ import com.raytheon.uf.viz.core.icon.IconUtil;
|
|||
* Mar 25, 2014 2938 mpduff Show status message for site and role changes.
|
||||
* Apr 01, 2014 2938 mpduff Update logic for site and role changes.
|
||||
* Apr 22, 2014 3038 bclement added initialized flag to differentiate between roster population and new joins
|
||||
* Oct 10, 2014 3708 bclement SiteConfigurationManager refactor
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -94,16 +96,14 @@ public class SessionFeedView extends SessionView {
|
|||
|
||||
private Action userRemoveSiteAction;
|
||||
|
||||
private List<String> enabledSites;
|
||||
|
||||
private final List<String> userEnabledSites;
|
||||
|
||||
private List<SiteColor> colors;
|
||||
|
||||
private String actingSite;
|
||||
|
||||
/**
|
||||
* Set of users logged in.
|
||||
*/
|
||||
private final ConcurrentHashMap<String, Presence> enabledUsers = new ConcurrentHashMap<String, Presence>();
|
||||
private final ConcurrentHashMap<String, Presence> otherParticipants = new ConcurrentHashMap<String, Presence>();
|
||||
|
||||
private volatile boolean initialized = false;
|
||||
|
||||
|
@ -112,11 +112,9 @@ public class SessionFeedView extends SessionView {
|
|||
*/
|
||||
public SessionFeedView() {
|
||||
super();
|
||||
String actingSite = CollaborationConnection.getConnection()
|
||||
actingSite = CollaborationConnection.getConnection()
|
||||
.getPresence().getProperty(SiteConfigInformation.SITE_NAME)
|
||||
.toString();
|
||||
enabledSites = SiteConfigurationManager.getSubscribeList(actingSite);
|
||||
userEnabledSites = SiteConfigurationManager.getUserSubscribeList();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -129,7 +127,7 @@ public class SessionFeedView extends SessionView {
|
|||
@Override
|
||||
protected void initComponents(Composite parent) {
|
||||
super.initComponents(parent);
|
||||
colors = SiteConfigurationManager.getSiteColors();
|
||||
colors = SiteColorConfigManager.getSiteColors();
|
||||
if (colors != null) {
|
||||
for (VenueParticipant user : session.getVenue().getParticipants()) {
|
||||
setColorForSite(user);
|
||||
|
@ -141,8 +139,8 @@ public class SessionFeedView extends SessionView {
|
|||
}
|
||||
|
||||
@Subscribe
|
||||
public void refreshBlockList(SubscribeList list) {
|
||||
enabledSites = list.getEnabledSites();
|
||||
public void refreshBlockList(SiteChangeEvent event) {
|
||||
this.actingSite = event.getNewSite();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -209,17 +207,19 @@ public class SessionFeedView extends SessionView {
|
|||
}
|
||||
});
|
||||
|
||||
userAddSiteAction = new Action("Subscribe") {
|
||||
userAddSiteAction = new Action("Show Messages from Site") {
|
||||
@Override
|
||||
public void run() {
|
||||
userEnabledSites.add(getSelectedSite());
|
||||
SiteConfigurationManager
|
||||
.showSite(actingSite, getSelectedSite());
|
||||
};
|
||||
};
|
||||
|
||||
userRemoveSiteAction = new Action("Unsubscribe") {
|
||||
userRemoveSiteAction = new Action("Hide Messages from Site") {
|
||||
@Override
|
||||
public void run() {
|
||||
userEnabledSites.remove(getSelectedSite());
|
||||
SiteConfigurationManager
|
||||
.hideSite(actingSite, getSelectedSite());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -240,13 +240,12 @@ public class SessionFeedView extends SessionView {
|
|||
super.fillContextMenu(manager);
|
||||
manager.add(colorChangeAction);
|
||||
String site = getSelectedSite();
|
||||
if (userEnabledSites.contains(site) == false
|
||||
&& enabledSites.contains(site) == false) {
|
||||
userAddSiteAction.setText("Subscribe to " + getSelectedSite());
|
||||
if (!SiteConfigurationManager.isVisible(actingSite, site)) {
|
||||
userAddSiteAction
|
||||
.setText("Show Messages from " + getSelectedSite());
|
||||
manager.add(userAddSiteAction);
|
||||
} else if (enabledSites.contains(site) == false
|
||||
&& userEnabledSites.contains(site)) {
|
||||
userRemoveSiteAction.setText("Unsubscribe from "
|
||||
} else {
|
||||
userRemoveSiteAction.setText("Hide Messages from "
|
||||
+ getSelectedSite());
|
||||
manager.add(userRemoveSiteAction);
|
||||
}
|
||||
|
@ -262,7 +261,7 @@ public class SessionFeedView extends SessionView {
|
|||
@Override
|
||||
protected void setParticipantValues(ParticipantsLabelProvider labelProvider) {
|
||||
super.setParticipantValues(labelProvider);
|
||||
labelProvider.setEnabledSites(enabledSites);
|
||||
labelProvider.setActingSite(actingSite);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -293,8 +292,9 @@ public class SessionFeedView extends SessionView {
|
|||
}
|
||||
|
||||
// should we append?
|
||||
if (site == null || enabledSites.contains(site)
|
||||
|| userEnabledSites.contains(site)) {
|
||||
if (site == null
|
||||
|| SiteConfigurationManager
|
||||
.isVisible(actingSite, site.toString())) {
|
||||
appendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
@ -433,10 +433,9 @@ public class SessionFeedView extends SessionView {
|
|||
String siteName = getSiteName(presence);
|
||||
|
||||
// only show sites you care about
|
||||
if (enabledSites.contains(siteName)
|
||||
|| userEnabledSites.contains(siteName)) {
|
||||
if (SiteConfigurationManager.isVisible(actingSite, siteName)) {
|
||||
String user = participant.getName();
|
||||
Presence prev = enabledUsers.get(user);
|
||||
Presence prev = otherParticipants.get(user);
|
||||
|
||||
String roleName = getRoleName(presence);
|
||||
if (presence.isAvailable()) {
|
||||
|
@ -447,7 +446,7 @@ public class SessionFeedView extends SessionView {
|
|||
sendSystemMessage(message);
|
||||
}
|
||||
|
||||
enabledUsers.put(user, presence);
|
||||
otherParticipants.put(user, presence);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -536,7 +535,7 @@ public class SessionFeedView extends SessionView {
|
|||
@Override
|
||||
protected void participantDeparted(VenueParticipant participant,
|
||||
String description) {
|
||||
if (enabledUsers.remove(participant.getName()) != null) {
|
||||
if (otherParticipants.remove(participant.getName()) != null) {
|
||||
super.participantDeparted(participant, description);
|
||||
}
|
||||
}
|
||||
|
@ -551,11 +550,7 @@ public class SessionFeedView extends SessionView {
|
|||
super.dispose();
|
||||
SiteColorInformation information = new SiteColorInformation();
|
||||
information.setColors(this.colors);
|
||||
SiteConfigurationManager.writeSiteColorInformation(information);
|
||||
|
||||
// write out the user enabled sites information to a file
|
||||
String[] sites = userEnabledSites.toArray(new String[userEnabledSites
|
||||
.size()]);
|
||||
SiteConfigurationManager.writeUserEnabledSites(sites);
|
||||
// TODO should color config be written more often?
|
||||
SiteColorConfigManager.writeSiteColorInformation(information);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.viz.collaboration.ui.session;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
* Event fired when the user changes the acting site
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -33,30 +28,29 @@ import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 7, 2012 mnash Initial creation
|
||||
* Oct 9, 2014 3708 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mnash
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class SubscribeList {
|
||||
@DynamicSerializeElement
|
||||
private List<String> enabledSites;
|
||||
public class SiteChangeEvent {
|
||||
|
||||
private final String newSite;
|
||||
|
||||
/**
|
||||
* @return the enabledUsers
|
||||
*
|
||||
*/
|
||||
public List<String> getEnabledSites() {
|
||||
return enabledSites;
|
||||
public SiteChangeEvent(String newSite) {
|
||||
this.newSite = newSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param enabledUsers
|
||||
* the enabledUsers to set
|
||||
* @return the newSite
|
||||
*/
|
||||
public void setEnabledSites(List<String> enabledSites) {
|
||||
this.enabledSites = enabledSites;
|
||||
public String getNewSite() {
|
||||
return newSite;
|
||||
}
|
||||
|
||||
}
|
30
deltaScripts/14.4.1/DR3708/updateCollaborationConfig.sh
Executable file
30
deltaScripts/14.4.1/DR3708/updateCollaborationConfig.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/bin/bash
|
||||
# DR3708 updates collaboration config to support blacklists
|
||||
|
||||
IFS=$'\n'
|
||||
files=`find /awips2/edex/data/utility/cave_static/*/*/collaboration/ -name 'config.xml'`
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "No files found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Press Enter to perform the updates Ctrl-C to quit."
|
||||
read done
|
||||
|
||||
MY_DIR=`dirname $0`
|
||||
for f in $files; do
|
||||
echo "Updating $f"
|
||||
xml=$(python $MY_DIR/util/updateCollaborationConfig.py $f)
|
||||
if [[ $? != 0 ]]
|
||||
then
|
||||
echo "ERROR: Problem updating file $f"
|
||||
elif [[ -n $xml ]]
|
||||
then
|
||||
echo $xml | xmllint --format - > $f
|
||||
echo "Successfully updated"
|
||||
else
|
||||
echo "No update needed for $f"
|
||||
fi
|
||||
done
|
37
deltaScripts/14.4.1/DR3708/util/updateCollaborationConfig.py
Executable file
37
deltaScripts/14.4.1/DR3708/util/updateCollaborationConfig.py
Executable file
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python
|
||||
# DR3708 utility for updating collaboration config to support blacklists
|
||||
# this script is not intended to be run standalone
|
||||
# see shell script in parent directory
|
||||
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
CONFIG_TAG="config"
|
||||
LIST_TYPE_ATTRIBUTE="listType"
|
||||
WHITELIST_ATTRIB_VALUE="WHITELIST"
|
||||
SUB_SITE_TAG="subscribedSites"
|
||||
LIST_ENTRY_TAG="listEntry"
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write("Usage: %s [xml inputfile file]" % (sys.argv[0]))
|
||||
sys.exit(1)
|
||||
|
||||
tree = ET.parse(sys.argv[1])
|
||||
root = tree.getroot()
|
||||
|
||||
matches = root.findall(CONFIG_TAG)
|
||||
|
||||
if len(matches) < 1:
|
||||
sys.stderr.write("No matches found, exiting\n")
|
||||
sys.exit(0)
|
||||
|
||||
for match in matches:
|
||||
if LIST_TYPE_ATTRIBUTE not in match.attrib:
|
||||
match.attrib[LIST_TYPE_ATTRIBUTE] = WHITELIST_ATTRIB_VALUE
|
||||
subSites = match.findall(SUB_SITE_TAG)
|
||||
for subSite in subSites :
|
||||
lt = ET.SubElement(match, LIST_ENTRY_TAG)
|
||||
lt.text = subSite.text
|
||||
match.remove(subSite)
|
||||
|
||||
tree.write(sys.stdout)
|
Loading…
Add table
Reference in a new issue