use of org.talend.repository.nosql.exceptions.NoSQLReflectionException in project tbd-studio-se by Talend.
the class CassandraOldVersionMetadataHandler method getKeySpaces.
private List<Object> getKeySpaces(NoSQLConnection connection) throws NoSQLServerException {
List<Object> keySpaces = new ArrayList<Object>();
try {
List<Object> ksDefs = (List<Object>) NoSQLReflection.invokeMethod(getOrCreateCluster(connection), // $NON-NLS-1$
"describeKeyspaces");
keySpaces.addAll(ksDefs);
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
return keySpaces;
}
use of org.talend.repository.nosql.exceptions.NoSQLReflectionException in project tbd-studio-se by Talend.
the class MongoDBConnectionUtil method getDatabaseNames.
public static synchronized List<String> getDatabaseNames(NoSQLConnection connection, Object mongoClient) throws NoSQLServerException {
List<String> databaseNames = null;
try {
databaseNames = Collections.synchronizedList(new ArrayList<String>());
if (isUpgradeVersion(connection)) {
String requireAuthAttr = connection.getAttributes().get(IMongoDBAttributes.REQUIRED_AUTHENTICATION);
boolean requireAuth = requireAuthAttr == null ? false : Boolean.valueOf(requireAuthAttr);
//
String requireEncryptionAttr = connection.getAttributes().get(IMongoDBAttributes.REQUIRED_ENCRYPTION);
boolean requireEncryption = requireEncryptionAttr == null ? false : Boolean.valueOf(requireEncryptionAttr);
if (mongoClient == null) {
mongoClient = getMongo(connection, requireAuth, requireEncryption);
}
Iterable mongoIterable = (Iterable) NoSQLReflection.invokeMethod(mongoClient, "listDatabaseNames");
for (Object dbname : mongoIterable) {
databaseNames.add((String) dbname);
}
} else {
if (mongoClient == null) {
mongoClient = getMongo(connection);
}
Iterable mongoIterable = (Iterable) NoSQLReflection.invokeMethod(mongoClient, "listDatabaseNames");
for (Object dbname : mongoIterable) {
databaseNames.add((String) dbname);
}
}
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
return databaseNames;
}
use of org.talend.repository.nosql.exceptions.NoSQLReflectionException in project tbd-studio-se by Talend.
the class Neo4jConnectionUtil method getResultIterator.
public static synchronized Iterator<Map<String, Object>> getResultIterator(NoSQLConnection connection, String cypher, Object db1) throws NoSQLServerException {
Iterator<Map<String, Object>> resultIterator = null;
Object db = db1;
try {
db = getDB(connection, true);
ClassLoader classLoader = NoSQLClassLoaderFactory.getClassLoader(connection);
String isRemoteAttr = connection.getAttributes().get(INeo4jAttributes.REMOTE_SERVER);
boolean isRemote = isRemoteAttr == null ? false : Boolean.valueOf(isRemoteAttr);
if (isRemote) {
Object queryResult = NoSQLReflection.invokeMethod(getQueryEngine(db, classLoader), "query", new Object[] { cypher, null }, String.class, // $NON-NLS-1$
Map.class);
resultIterator = (Iterator<Map<String, Object>>) // $NON-NLS-1$
NoSQLReflection.invokeMethod(// $NON-NLS-1$
queryResult, // $NON-NLS-1$
"iterator", new Object[0]);
} else {
Object executionResult = NoSQLReflection.invokeMethod(getExecutionEngine(db, classLoader, connection), "execute", // $NON-NLS-1$
new Object[] { cypher });
resultIterator = (Iterator<Map<String, Object>>) // $NON-NLS-1$
NoSQLReflection.invokeMethod(// $NON-NLS-1$
executionResult, // $NON-NLS-1$
"iterator", new Object[0]);
}
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
return resultIterator;
}
use of org.talend.repository.nosql.exceptions.NoSQLReflectionException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method checkConnection.
@Override
public boolean checkConnection(NoSQLConnection connection) throws NoSQLServerException {
Object session = null;
try {
cluster = null;
initCluster(connection);
ContextType contextType = null;
String ksName = connection.getAttributes().get(ICassandraAttributies.DATABASE);
if (connection.isContextMode()) {
contextType = ConnectionContextHelper.getContextTypeForContextMode(connection);
}
if (contextType != null) {
ksName = ContextParameterUtils.getOriginalValue(contextType, ksName);
}
// if cancel to interrupt check connection, throw exception
if (Thread.currentThread().interrupted()) {
// $NON-NLS-1$
throw new InterruptedException();
}
if (StringUtils.isEmpty(ksName)) {
// $NON-NLS-1$
session = NoSQLReflection.invokeMethod(cluster, "connect");
} else {
// $NON-NLS-1$
session = NoSQLReflection.invokeMethod(cluster, "connect", new Object[] { ksName });
}
return true;
} catch (Exception e) {
if (e instanceof InterruptedException) {
// $NON-NLS-1$
throw new NoSQLServerException(Messages.getString("noSQLConnectionTest.cancelCheckConnection"), e);
} else {
throw new NoSQLServerException(e);
}
} finally {
try {
if (session != null) {
// $NON-NLS-1$
NoSQLReflection.invokeMethod(session, "close");
}
} catch (NoSQLReflectionException e) {
// only for debug
e.printStackTrace();
}
}
}
use of org.talend.repository.nosql.exceptions.NoSQLReflectionException in project tbd-studio-se by Talend.
the class CassandraMetadataHandler method closeConnections.
@Override
public void closeConnections() throws NoSQLServerException {
try {
if (cluster != null) {
// $NON-NLS-1$
NoSQLReflection.invokeMethod(cluster, "close");
cluster = null;
}
} catch (NoSQLReflectionException e) {
throw new NoSQLServerException(e);
}
}
Aggregations