mirror of
https://github.com/zyphlar/LanternPowerMonitor.git
synced 2024-03-08 14:07:47 +00:00
Add a rules engine so I can be notified when I forget to close my garage door.
This commit is contained in:
@@ -71,6 +71,8 @@ public class MongoProxy extends AbstractDaoProxy {
|
||||
|
||||
public MongoProxy(List<String> _hosts, String _userName, String _password, String _clientKeystorePath, String _clientKeystorePassword, String _caKeystorePath, String _caKeystorePassword, String _dbName, String _authDbName) {
|
||||
List<ServerAddress> listAddresses = new LinkedList<>();
|
||||
if (CollectionUtils.isEmpty(_hosts))
|
||||
_hosts = CollectionUtils.asArrayList("localhost");
|
||||
for (String addr : _hosts) {
|
||||
int portIdx = addr.indexOf(":");
|
||||
if (portIdx > 0)
|
||||
@@ -108,7 +110,7 @@ public class MongoProxy extends AbstractDaoProxy {
|
||||
options = MongoClientOptions.builder().sslEnabled(false).build();
|
||||
}
|
||||
}
|
||||
client = new MongoClient(listAddresses, MongoCredential.createCredential(_userName, NullUtils.isNotEmpty(_authDbName) ? _authDbName : "admin", _password.toCharArray()), options);
|
||||
client = NullUtils.isEmpty(_userName) ? new MongoClient(listAddresses, options) : new MongoClient(listAddresses, MongoCredential.createCredential(_userName, NullUtils.isNotEmpty(_authDbName) ? _authDbName : "admin", _password.toCharArray()), options);
|
||||
dbName = _dbName;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package com.lanternsoftware.util.dao.mongo.dao;
|
||||
|
||||
import com.lanternsoftware.util.CollectionUtils;
|
||||
import com.lanternsoftware.util.NullUtils;
|
||||
import com.lanternsoftware.util.dao.AbstractDaoSerializer;
|
||||
import com.lanternsoftware.util.dao.DaoEntity;
|
||||
import com.lanternsoftware.util.dao.DaoProxyType;
|
||||
import com.lanternsoftware.util.dao.DaoSerializer;
|
||||
|
||||
import com.lanternsoftware.util.dao.mongo.MongoConfig;
|
||||
|
||||
import java.lang.String;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class MongoConfigSerializer extends AbstractDaoSerializer<MongoConfig>
|
||||
{
|
||||
@@ -17,11 +17,16 @@ public class MongoConfigSerializer extends AbstractDaoSerializer<MongoConfig>
|
||||
return MongoConfig.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DaoProxyType> getSupportedProxies() {
|
||||
return Collections.singletonList(DaoProxyType.MONGO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaoEntity toDaoEntity(MongoConfig _o)
|
||||
{
|
||||
DaoEntity d = new DaoEntity();
|
||||
d.put("hosts", CollectionUtils.commaSeparated(_o.getHosts()));
|
||||
d.put("hosts", _o.getHosts());
|
||||
d.put("username", _o.getUsername());
|
||||
d.put("password", _o.getPassword());
|
||||
d.put("client_keystore_path", _o.getClientKeystorePath());
|
||||
@@ -37,7 +42,7 @@ public class MongoConfigSerializer extends AbstractDaoSerializer<MongoConfig>
|
||||
public MongoConfig fromDaoEntity(DaoEntity _d)
|
||||
{
|
||||
MongoConfig o = new MongoConfig();
|
||||
o.setHosts(CollectionUtils.asArrayList(NullUtils.cleanSplit(DaoSerializer.getString(_d, "hosts"), ",")));
|
||||
o.setHosts(DaoSerializer.getList(_d, "hosts", String.class));
|
||||
o.setUsername(DaoSerializer.getString(_d, "username"));
|
||||
o.setPassword(DaoSerializer.getString(_d, "password"));
|
||||
o.setClientKeystorePath(DaoSerializer.getString(_d, "client_keystore_path"));
|
||||
|
||||
Reference in New Issue
Block a user