@Singleton public class BrokerImpl extends Object implements BrokerBackend, Broker
| Modifier and Type | Class and Description |
|---|---|
static interface |
BrokerImpl.RequestInfoLoader |
| Constructor and Description |
|---|
BrokerImpl() |
BrokerImpl(DataSource brokerDB,
Path dataDirectory) |
| Modifier and Type | Method and Description |
|---|---|
Principal |
accessPrincipal(String clientKey,
String clientDn)
Add or retrieve the node principal.
|
void |
clearDataDirectory() |
void |
clearRequestTargets(int requestId) |
int |
createRequest() |
int |
createRequest(String mediaType,
Reader content) |
void |
deleteRequest(int id) |
List<Node> |
getAllNodes() |
protected int |
getLastInsertId(Connection dbc) |
Node |
getNode(int nodeId) |
DigestPathDataSource |
getNodeResource(int nodeId,
String resourceId) |
Reader |
getRequestDefinition(int requestId,
String mediaType) |
RequestInfo |
getRequestInfo(int requestId) |
Reader |
getRequestNodeStatusMessage(int requestId,
int nodeId) |
int[] |
getRequestTargets(int requestId) |
List<String> |
getRequestTypes(int requestId) |
List<RequestInfo> |
listAllRequests() |
List<RequestStatusInfo> |
listRequestNodeStatus(Integer requestId) |
List<RequestInfo> |
listRequestsForNode(int nodeId) |
boolean |
markRequestDeletedForNode(int nodeId,
int requestId) |
void |
setBrokerDB(DataSource brokerDB) |
void |
setDataDirectory(Path dataDir) |
void |
setRequestClosed(int requestId,
Instant timestamp) |
void |
setRequestDefinition(int requestId,
String mediaType,
Reader content) |
void |
setRequestNodeStatus(int requestId,
int nodeId,
RequestStatus status,
Instant timestamp) |
void |
setRequestNodeStatusMessage(int requestId,
int nodeId,
String mediaType,
Reader message) |
void |
setRequestPublished(int requestId,
Instant timestamp) |
void |
setRequestTargets(int requestId,
int[] nodes) |
void |
updateNodeLastSeen(int[] nodeIds,
long[] timestamps) |
void |
updateNodeResource(int nodeId,
String resourceId,
javax.ws.rs.core.MediaType mediaType,
InputStream content) |
static int |
updatePrincipalDN(DataSource ds,
Map<String,String> mapNodeDN)
Update the clientDN string for the nodes given in the provided map.
|
public BrokerImpl()
public BrokerImpl(DataSource brokerDB, Path dataDirectory) throws IOException
IOExceptionpublic void setBrokerDB(DataSource brokerDB)
setBrokerDB in interface BrokerBackendpublic void setDataDirectory(Path dataDir)
public void clearDataDirectory()
throws IOException
clearDataDirectory in interface BrokerBackendIOExceptionpublic List<Node> getAllNodes() throws SQLException
getAllNodes in interface BrokerSQLExceptionpublic Node getNode(int nodeId) throws SQLException
getNode in interface BrokerSQLExceptionprotected int getLastInsertId(Connection dbc) throws SQLException
SQLExceptionpublic int createRequest(String mediaType, Reader content) throws SQLException
createRequest in interface BrokerSQLExceptionpublic int createRequest()
throws SQLException
createRequest in interface BrokerSQLExceptionpublic void setRequestDefinition(int requestId,
String mediaType,
Reader content)
throws SQLException
setRequestDefinition in interface BrokerSQLExceptionpublic void deleteRequest(int id)
throws SQLException
deleteRequest in interface BrokerSQLExceptionpublic List<RequestInfo> listAllRequests() throws SQLException
listAllRequests in interface BrokerSQLExceptionpublic List<String> getRequestTypes(int requestId) throws SQLException
getRequestTypes in interface BrokerSQLExceptionpublic Reader getRequestDefinition(int requestId, String mediaType) throws SQLException, IOException
getRequestDefinition in interface BrokerSQLExceptionIOExceptionpublic List<RequestInfo> listRequestsForNode(int nodeId) throws SQLException
listRequestsForNode in interface BrokerSQLExceptionpublic RequestInfo getRequestInfo(int requestId) throws SQLException
getRequestInfo in interface BrokerSQLExceptionpublic void setRequestNodeStatus(int requestId,
int nodeId,
RequestStatus status,
Instant timestamp)
throws SQLException
setRequestNodeStatus in interface BrokerSQLExceptionpublic void setRequestNodeStatusMessage(int requestId,
int nodeId,
String mediaType,
Reader message)
throws SQLException
setRequestNodeStatusMessage in interface BrokerSQLExceptionpublic Reader getRequestNodeStatusMessage(int requestId, int nodeId) throws SQLException, IOException
getRequestNodeStatusMessage in interface BrokerSQLExceptionIOExceptionpublic boolean markRequestDeletedForNode(int nodeId,
int requestId)
throws SQLException
markRequestDeletedForNode in interface BrokerSQLExceptionpublic List<RequestStatusInfo> listRequestNodeStatus(Integer requestId) throws SQLException
listRequestNodeStatus in interface BrokerSQLExceptionpublic Principal accessPrincipal(String clientKey, String clientDn) throws SQLException
BrokerBackendaccessPrincipal in interface BrokerBackendclientKey - unique key for the node. E.g. Certificate serial number or API keyclientDn - optional X500 client DN stringSQLException - SQL errorpublic void setRequestPublished(int requestId,
Instant timestamp)
throws SQLException
setRequestPublished in interface BrokerSQLExceptionpublic void setRequestClosed(int requestId,
Instant timestamp)
throws SQLException
setRequestClosed in interface BrokerSQLExceptionpublic void updateNodeLastSeen(int[] nodeIds,
long[] timestamps)
throws SQLException
updateNodeLastSeen in interface BrokerBackendSQLExceptionpublic void setRequestTargets(int requestId,
int[] nodes)
throws SQLException
setRequestTargets in interface BrokerSQLExceptionpublic int[] getRequestTargets(int requestId)
throws SQLException
getRequestTargets in interface BrokerSQLExceptionpublic void clearRequestTargets(int requestId)
throws SQLException
clearRequestTargets in interface BrokerSQLExceptionpublic void updateNodeResource(int nodeId,
String resourceId,
javax.ws.rs.core.MediaType mediaType,
InputStream content)
throws IOException,
SQLException
updateNodeResource in interface BrokerBackendIOExceptionSQLExceptionpublic DigestPathDataSource getNodeResource(int nodeId, String resourceId) throws SQLException
getNodeResource in interface BrokerSQLExceptionpublic static int updatePrincipalDN(DataSource ds, Map<String,String> mapNodeDN) throws SQLException
ds - data sourcemapNodeDN - Map of node keys pointing to clientDN stringsSQLException - SQL errorCopyright © 2014–2019 Uniklinik RWTH Aachen. All rights reserved.