Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes related to mutl-domain deployments #238

Merged
merged 20 commits into from
Oct 10, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0434fb2
Removing unused variables and useless imports.
abmargb Sep 19, 2014
542c8ff
Removing unused fields from tests
abmargb Sep 19, 2014
a0141de
Fixing style (missing brackets, weird one-liners...)
abmargb Sep 19, 2014
123ed47
more missing braces
abmargb Sep 19, 2014
80968eb
Fixes #235
abmargb Sep 19, 2014
f717b61
Returns every node from every domain in /firehose. Refers to #234.
abmargb Sep 19, 2014
7aaf853
firehose: fixing pagination with rsm
abmargb Sep 23, 2014
dd68f8c
Addressing @lloydwatkin 's comments on
abmargb Sep 23, 2014
e1fa775
Fixing ISO 8601 regex for timestamps with TZ != 0
abmargb Sep 25, 2014
67e95ff
Removing unnecessary syso
abmargb Sep 25, 2014
afaf36f
external-domain-checker returning a csv list of local domains
abmargb Sep 27, 2014
31ea960
Making it work with Postgres' regex
abmargb Sep 27, 2014
89d4e9c
removing unnecessary commented lines
abmargb Sep 27, 2014
a7392fd
replacing ~ with regexp_matches in the DatabaseTester level
abmargb Sep 27, 2014
78fe33c
creates getLocalNodes and getRemoteNodes methods in the node store
abmargb Sep 29, 2014
01ff69b
Merge remote-tracking branch 'origin/master' into multi-domain-fixes
abmargb Sep 29, 2014
e7712ad
Considering 'local' access model when retrieving /firehose. Various
abmargb Sep 30, 2014
ebdecf9
Moving checks for local domains, jids and nodes to the Configuration
abmargb Oct 6, 2014
bc01763
Merge remote-tracking branch 'origin/master' into multi-domain-fixes
abmargb Oct 9, 2014
102761c
fixing checkstyle violations
abmargb Oct 10, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ private void setupManagers() throws ComponentException {
throw new ComponentException(e);
}

channelManagerFactory = new ChannelManagerFactoryImpl(configuration, nodeStoreFactory);
federatedQueueManager = new FederatedQueueManager(this, configuration);
channelManagerFactory = new ChannelManagerFactoryImpl(nodeStoreFactory);
federatedQueueManager = new FederatedQueueManager(this,
configuration);
onlineUsers = new OnlineResourceManager(configuration, channelManagerFactory.create());
}

Expand Down
64 changes: 50 additions & 14 deletions src/main/java/org/buddycloud/channelserver/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Properties;

import org.apache.log4j.Logger;
import org.buddycloud.channelserver.channel.LocalDomainChecker;
import org.xmpp.packet.JID;

public class Configuration extends Properties {
Expand All @@ -19,12 +20,13 @@ public class Configuration extends Properties {
private static final long serialVersionUID = 1L;

private static final String ARRAY_PROPERTY_SEPARATOR = ";";
private static final String INVALID_NODE = "Illegal node format";

public static final String CONFIGURATION_SERVER_DOMAIN = "server.domain";
public static final String CONFIGURATION_SERVER_CHANNELS_DOMAIN = "server.domain.channels";
public static final String CONFIGURATION_SERVER_TOPICS_DOMAIN = "server.domain.topics";
public static final String CONFIGURATION_LOCAL_DOMAIN_CHECKER = "server.domain.checker";

public static final String CONFIGURATION_ADMIN_USERS = "users.admin";

public static final String CONFIGURATION_CHANNELS_AUTOSUBSCRIBE = "channels.autosubscribe";
Expand All @@ -33,17 +35,17 @@ public class Configuration extends Properties {
public static final String CONFIGURATION_CHANNELS_DEFAULT_ACCESSMODEL = "channel.configuration.default.accessmodel";
public static final String CONFIGURATION_CHANNELS_DEFAULT_DESCRIPTION = "channel.configuration.default.description";
public static final String CONFIGURATION_CHANNELS_DEFAULT_TITLE = "channel.configuration.default.title";

public static final String DISCOVERY_USE_DNS = "discovery.dns.enabled";

public static final String PERSIST_PRESENCE_DATA = "users.presence.persist";

public static final String NOTIFICATIONS_SENDTO = "notifications.sendTo";
public static final String NOTIFICATIONS_CONNECTED = "notifications.connected";

private static final String CONFIGURATION_FILE = "configuration.properties";

public static final String PURGE_REMOTE_ON_START = "sync.purge-on-start";
public static final String PURGE_REMOTE_ON_START = "sync.purge-on-start";

public static final String XMPP_PORT = "xmpp.port";

Expand All @@ -59,21 +61,23 @@ public class Configuration extends Properties {
private Configuration() {
try {
conf = new Properties();
InputStream confFile = this.getClass().getClassLoader().getResourceAsStream(CONFIGURATION_FILE);
InputStream confFile = this.getClass().getClassLoader()
.getResourceAsStream(CONFIGURATION_FILE);
if (confFile != null) {
load(confFile);
LOGGER.info("Loaded " + CONFIGURATION_FILE + " from classpath.");
} else {
File f = new File(CONFIGURATION_FILE);
load(new FileInputStream(f));
LOGGER.info("Loaded " + CONFIGURATION_FILE + " from working directory.");
LOGGER.info("Loaded " + CONFIGURATION_FILE
+ " from working directory.");
}
} catch (Exception e) {
LOGGER.error("Could not load " + CONFIGURATION_FILE + "!");
System.exit(1);
}
}

private void setupCollections() {
adminUsers = getJIDArrayProperty(CONFIGURATION_ADMIN_USERS);
autosubscribeChannels = getJIDArrayProperty(CONFIGURATION_CHANNELS_AUTOSUBSCRIBE);
Expand All @@ -93,18 +97,31 @@ public static Configuration getInstance() {
}
return instance;
}

public static void reset() {
instance = null;
}

public String getProperty(String key) {
return conf.getProperty(key);
}


@Override
public synchronized Object remove(Object key) {
return conf.remove(key);
}

public void clear() {
conf.clear();
}

public String getProperty(String key, String defaultValue) {
return conf.getProperty(key, defaultValue);
}

public void putProperty(String key, String value) {
conf.put(key, value);
}

public void load(InputStream inputStream) throws IOException {
conf.load(inputStream);
Expand All @@ -122,7 +139,6 @@ private Collection<String> getStringArrayProperty(String key) {
}

private Collection<JID> getJIDArrayProperty(String key) {
System.out.println(conf.getProperty(CONFIGURATION_CHANNELS_AUTOSUBSCRIBE));
Collection<String> props = getStringArrayProperty(key);

Collection<JID> jids = new ArrayList<JID>(props.size());
Expand All @@ -137,7 +153,7 @@ private Collection<JID> getJIDArrayProperty(String key) {

return jids;
}

public ArrayList<JID> getNotificationsList(String event) {
ArrayList<JID> notify = new ArrayList<JID>();
if (!getBooleanProperty(event, false)) {
Expand Down Expand Up @@ -168,7 +184,8 @@ public String getServerTopicsDomain() {
return getProperty(CONFIGURATION_SERVER_TOPICS_DOMAIN);
}

public boolean getBooleanProperty(final String key, final boolean defaultValue) {
public boolean getBooleanProperty(final String key,
final boolean defaultValue) {
String value = getProperty(key);

if (value != null) {
Expand All @@ -178,17 +195,36 @@ public boolean getBooleanProperty(final String key, final boolean defaultValue)
if (value.equalsIgnoreCase("false")) {
return false;
}
LOGGER.warn("Invalid boolean property value for " + key + ": " + value);
LOGGER.warn("Invalid boolean property value for " + key + ": "
+ value);
}

return defaultValue;
}

public String getComponentPort() {
public String getComponentPort() {
return this.getProperty(XMPP_PORT, "5347");
}

public String getXmppHost() {
return this.getProperty(XMPP_HOST, "127.0.0.1");
}

public boolean isLocalDomain(String domain) {
return LocalDomainChecker.isLocal(domain, this);
}

public boolean isLocalNode(String nodeId) {
if (false == nodeId.matches("/user/.+@.+/.+")) {
LOGGER.debug("Node " + nodeId + " has an invalid format");
throw new IllegalArgumentException(INVALID_NODE);
}
String domain = new JID(nodeId.split("/")[2]).getDomain();
return isLocalDomain(domain);
}

public boolean isLocalJID(JID jid) {
String domain = jid.getDomain();
return isLocalDomain(domain);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,6 @@ public interface ChannelManager extends NodeStore {
*/
void createPersonalChannel(JID ownerJID) throws NodeStoreException;

/**
* Determines whether the node id given refers to a local node.
*
* @param nodeId the node id
* @return <code>true</code> if the node appears to be local, <code>false</code> otherwise.
* @throws NodeStoreException
*/
boolean isLocalNode(String nodeId) throws NodeStoreException;

/**
* Determines whether the jid refers to a local user.
*
* @param jid the user's jid
* @return <code>true</code> if the jid appears to be local, <code>false</code> otherwise.
* @throws NodeStoreException
*/
boolean isLocalJID(JID jid) throws NodeStoreException;

/**
* Determines whether the domain is served by this server.
*
* @param domain the domain name
* @return <code>true</code> if the domain appears to be local, <code>false</code> otherwise.
* @throws NodeStoreException
*/
boolean isLocalDomain(String domain) throws NodeStoreException;


/**
* Deletes all data from remote nodes
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package org.buddycloud.channelserver.channel;

import java.util.Properties;

import org.buddycloud.channelserver.db.NodeStoreFactory;

public class ChannelManagerFactoryImpl implements ChannelManagerFactory {

private final Properties configuration;
private final NodeStoreFactory nodeStoreFactory;

public ChannelManagerFactoryImpl(final Properties configuration, final NodeStoreFactory nodeStoreFactory) {
this.configuration = configuration;
public ChannelManagerFactoryImpl(final NodeStoreFactory nodeStoreFactory) {
this.nodeStoreFactory = nodeStoreFactory;
}

@Override
public ChannelManager create() {
return new ChannelManagerImpl(nodeStoreFactory.create(), configuration);
return new ChannelManagerImpl(nodeStoreFactory.create());
}

}
Loading