Search in sources :

Example 56 with RepositoryException

use of org.platformlayer.RepositoryException in project platformlayer by platformlayer.

the class JdbcUserRepository method listAllServiceAccounts.

@Override
@JdbcTransaction
public List<ServiceAccountEntity> listAllServiceAccounts(byte[] filterPublicKey) throws RepositoryException {
    DbHelper db = new DbHelper();
    try {
        List<ServiceAccountEntity> serviceAccounts = db.queries.listAllServiceAccounts();
        List<ServiceAccountEntity> ret = Lists.newArrayList();
        for (ServiceAccountEntity serviceAccount : serviceAccounts) {
            if (filterPublicKey != null) {
                if (!Objects.equal(filterPublicKey, serviceAccount.publicKeyData)) {
                    continue;
                }
            }
            ret.add(serviceAccount);
        }
        return ret;
    } catch (SQLException e) {
        throw new RepositoryException("Error listing service accounts", e);
    } finally {
        db.close();
    }
}
Also used : SQLException(java.sql.SQLException) RepositoryException(org.platformlayer.RepositoryException) JdbcTransaction(com.fathomdb.jdbc.JdbcTransaction)

Aggregations

RepositoryException (org.platformlayer.RepositoryException)56 JdbcTransaction (com.fathomdb.jdbc.JdbcTransaction)30 SQLException (java.sql.SQLException)30 OpsException (org.platformlayer.ops.OpsException)18 ProjectId (org.platformlayer.ids.ProjectId)14 ItemBase (org.platformlayer.core.model.ItemBase)10 CryptoKey (com.fathomdb.crypto.CryptoKey)8 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)7 ManagedItemId (org.platformlayer.ids.ManagedItemId)7 OpsContext (org.platformlayer.ops.OpsContext)7 ServiceProvider (org.platformlayer.xaas.services.ServiceProvider)7 IOException (java.io.IOException)6 AesCryptoKey (com.fathomdb.crypto.AesCryptoKey)5 PublicKey (java.security.PublicKey)4 JAXBException (javax.xml.bind.JAXBException)4 Tag (org.platformlayer.core.model.Tag)4 ServiceType (org.platformlayer.ids.ServiceType)4 JobData (org.platformlayer.jobs.model.JobData)4 JoinedQueryResult (com.fathomdb.jpa.impl.JoinedQueryResult)3 X509Certificate (java.security.cert.X509Certificate)3