use of nl.uva.cs.lobcder.resources.Credential in project lobcder by skoulouzis.
the class JDBCatalogue method getCredentials.
private Collection<Credential> getCredentials(Connection connection) throws SQLException {
try (PreparedStatement preparedStatement = connection.prepareStatement("select * from credential_table")) {
ResultSet rs = preparedStatement.executeQuery();
Collection<Credential> res = new ArrayList<>();
while (rs.next()) {
Credential c = new Credential();
c.setId(rs.getLong(1));
c.setStorageSiteUsername(rs.getString(2));
c.setStorageSitePassword(rs.getString(3));
res.add(c);
}
return res;
}
}
use of nl.uva.cs.lobcder.resources.Credential in project lobcder by skoulouzis.
the class JDBCatalogue method getStorageSites.
public Collection<StorageSite> getStorageSites(Connection connection, Boolean isCache, Boolean includePrivate) throws SQLException {
try (Statement s = connection.createStatement()) {
try (ResultSet rs = s.executeQuery("SELECT storageSiteId, resourceURI, " + "currentNum, currentSize, quotaNum, quotaSize, username, " + "password, encrypt, private FROM storage_site_table " + "JOIN credential_table ON credentialRef = credintialId " + "WHERE isCache = " + isCache + " AND removing = FALSE")) {
ArrayList<StorageSite> res = new ArrayList<>();
while (rs.next()) {
StorageSite ss = new StorageSite();
ss.setStorageSiteId(rs.getLong(1));
ss.setResourceURI(rs.getString(2));
ss.setCurrentNum(rs.getLong(3));
ss.setCurrentSize(rs.getLong(4));
ss.setQuotaNum(rs.getLong(5));
ss.setQuotaSize(rs.getLong(6));
Credential c = new Credential();
c.setStorageSiteUsername(rs.getString(7));
c.setStorageSitePassword(rs.getString(8));
ss.setCredential(c);
ss.setEncrypt(rs.getBoolean(9));
ss.setCache(isCache);
if (rs.getBoolean(10) && includePrivate) {
res.add(ss);
} else if (!rs.getBoolean(10)) {
res.add(ss);
}
}
return res;
}
}
}
use of nl.uva.cs.lobcder.resources.Credential in project lobcder by skoulouzis.
the class FastestSiteReplicationPolicy method getStorageSites.
private Map<String, StorageSite> getStorageSites(Connection connection) throws SQLException {
try (Statement s = connection.createStatement()) {
ResultSet rs = s.executeQuery("SELECT storageSiteId, resourceURI, " + "currentNum, currentSize, quotaNum, quotaSize, username, " + "password, encrypt FROM storage_site_table JOIN credential_table ON " + "credentialRef = credintialId " + "WHERE private=FALSE AND removing=FALSE AND isCache=FALSE AND readOnly = FALSE");
Map<String, StorageSite> res = new HashMap<>();
while (rs.next()) {
Credential c = new Credential();
c.setStorageSiteUsername(rs.getString(7));
c.setStorageSitePassword(rs.getString(8));
StorageSite ss = new StorageSite();
ss.setStorageSiteId(rs.getLong(1));
ss.setCredential(c);
String uri = rs.getString(2);
ss.setResourceURI(uri);
ss.setCurrentNum(rs.getLong(3));
ss.setCurrentSize(rs.getLong(4));
ss.setQuotaNum(rs.getLong(5));
ss.setQuotaSize(rs.getLong(6));
ss.setEncrypt(rs.getBoolean(9));
res.put(uri, ss);
}
return res;
}
}
Aggregations