1 package org.openslx.imagemaster.db.mappers;
3 import java.nio.ByteBuffer;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.util.ArrayList;
7 import java.util.Arrays;
10 import org.apache.logging.log4j.LogManager;
11 import org.apache.logging.log4j.Logger;
12 import org.
openslx.bwlp.thrift.iface.Satellite;
30 public static List<Satellite>
getSatellites( UserInfo ui )
throws SQLException
37 public static List<Satellite>
getSatellites( String organizationId )
throws SQLException
39 if ( organizationId == null )
42 MysqlStatement stmt = connection.prepareStatement(
"SELECT satellitename, addresses, certsha256"
43 +
" FROM satellite WHERE organizationid = :organizationid" );
44 stmt.
setString(
"organizationid", organizationId );
46 List<Satellite> list =
new ArrayList<>();
48 List<String> al = Arrays.asList( Json.deserialize( rs.getString(
"addresses" ), String[].class ) );
49 byte[] certBytes = rs.getBytes(
"certsha256" );
50 ByteBuffer cert = null;
51 if ( certBytes != null ) {
52 cert = ByteBuffer.wrap( certBytes );
54 list.add(
new Satellite( al, rs.getString(
"satellitename" ), cert ) );
57 }
catch ( SQLException e ) {
58 LOGGER.error(
"Query failed in DbSatellite.getSatellites()", e );
63 public static LocalSatellite get( String organizationId, String displayName )
static List< Satellite > getSatellites(String organizationId)
static MysqlConnection getConnection()
Get a connection to the database.
ResultSet executeQuery()
Executes the statement, which must be a query.
static List< Satellite > getSatellites(UserInfo ui)
void setString(String name, String value)
Sets a parameter.
Class for creating PreparedStatements with named parameters.
static final Logger LOGGER