Search in sources :

Example 6 with Credential

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;
    }
}
Also used : Credential(nl.uva.cs.lobcder.resources.Credential)

Example 7 with Credential

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;
        }
    }
}
Also used : Credential(nl.uva.cs.lobcder.resources.Credential) StorageSite(nl.uva.cs.lobcder.resources.StorageSite)

Example 8 with Credential

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;
    }
}
Also used : Credential(nl.uva.cs.lobcder.resources.Credential) HashMap(java.util.HashMap) Statement(java.sql.Statement) StorageSite(nl.uva.cs.lobcder.resources.StorageSite) ResultSet(java.sql.ResultSet)

Aggregations

Credential (nl.uva.cs.lobcder.resources.Credential)8 StorageSite (nl.uva.cs.lobcder.resources.StorageSite)6 ArrayList (java.util.ArrayList)2 MalformedURLException (java.net.MalformedURLException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 HashMap (java.util.HashMap)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 MyPrincipal (nl.uva.cs.lobcder.auth.MyPrincipal)1 JDBCatalogue (nl.uva.cs.lobcder.catalogue.JDBCatalogue)1 StorageSiteWrapper (nl.uva.cs.lobcder.rest.wrappers.StorageSiteWrapper)1 StorageSiteWrapperList (nl.uva.cs.lobcder.rest.wrappers.StorageSiteWrapperList)1 VlException (nl.uva.vlet.exception.VlException)1 BdiiService (nl.uva.vlet.util.bdii.BdiiService)1 StorageArea (nl.uva.vlet.util.bdii.StorageArea)1 VFSClient (nl.uva.vlet.vfs.VFSClient)1