use of org.wso2.ei.dashboard.core.exception.DashboardServerException in project product-mi-tooling by wso2.
the class MiArtifactsManager method updateArtifactDetails.
public boolean updateArtifactDetails() throws ManagementApiException {
if (updateArtifactObject != null) {
String groupId = updateArtifactObject.getGroupId();
String nodeId = updateArtifactObject.getNodeId();
String mgtApiUrl = updateArtifactObject.getMgtApiUrl();
String accessToken = databaseManager.getAccessToken(groupId, nodeId);
String artifactType = updateArtifactObject.getType();
String artifactName = updateArtifactObject.getName();
JsonObject details = getArtifactDetails(groupId, nodeId, mgtApiUrl, artifactType, artifactName, accessToken);
return databaseManager.updateDetails(artifactType, artifactName, groupId, nodeId, details.toString());
} else {
throw new DashboardServerException("Artifact details are invalid");
}
}
use of org.wso2.ei.dashboard.core.exception.DashboardServerException in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method getHeartbeatInterval.
@Override
public String getHeartbeatInterval(String groupId, String nodeId) {
String query = "SELECT HERTBEAT_INTERVAL FROM HEARTBEAT WHERE GROUP_ID=? AND NODE_ID=?;";
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(query)) {
statement.setString(1, groupId);
statement.setString(2, nodeId);
ResultSet resultSet = statement.executeQuery();
resultSet.next();
return resultSet.getString(1);
} catch (SQLException e) {
throw new DashboardServerException("Error occurred while fetching heartbeat interval of group " + groupId + " node " + nodeId, e);
}
}
use of org.wso2.ei.dashboard.core.exception.DashboardServerException in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method insertServerInformation.
@Override
public boolean insertServerInformation(HeartbeatObject heartbeat, String serverInfo) {
String query = "INSERT INTO SERVERS VALUES (?,?,?);";
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(query)) {
statement.setString(1, heartbeat.getGroupId());
statement.setString(2, heartbeat.getNodeId());
statement.setString(3, serverInfo);
return statement.executeUpdate() > 0;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred while inserting server information of node : " + heartbeat.getNodeId() + " in group: " + heartbeat.getGroupId(), e);
}
}
use of org.wso2.ei.dashboard.core.exception.DashboardServerException in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method getArtifactDetails.
private List<ArtifactDetails> getArtifactDetails(String getServicesQuery, String artifactName, String groupId, List<String> nodeList) {
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(getServicesQuery)) {
statement.setString(1, artifactName);
statement.setString(2, groupId);
for (int i = 0, j = 3; i < nodeList.size(); i++, j++) {
statement.setString(j, nodeList.get(i));
}
ResultSet resultSet = statement.executeQuery();
List<ArtifactDetails> artifactDetailsList = new ArrayList<>();
while (resultSet.next()) {
ArtifactDetails artifactDetails = new ArtifactDetails();
String nodeId = resultSet.getString("NODE_ID");
String details = resultSet.getString("DETAILS");
artifactDetails.setNodeId(nodeId);
artifactDetails.setDetails(details);
artifactDetailsList.add(artifactDetails);
}
return artifactDetailsList;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred while retrieving next row.", e);
}
}
use of org.wso2.ei.dashboard.core.exception.DashboardServerException in project product-mi-tooling by wso2.
the class JDBCDatabaseManager method fetchNodes.
@Override
public NodeList fetchNodes(String groupId) {
String query = "SELECT * FROM SERVERS WHERE GROUP_ID=?";
try (Connection con = getConnection();
PreparedStatement statement = con.prepareStatement(query)) {
statement.setString(1, groupId);
NodeList nodeList = new NodeList();
ResultSet resultSet = statement.executeQuery();
while (resultSet.next()) {
String nodeId = resultSet.getString("NODE_ID");
String details = resultSet.getString("DETAILS");
NodeListInner nodeListInner = new NodeListInner();
nodeListInner.setNodeId(nodeId);
nodeListInner.setDetails(details);
nodeList.add(nodeListInner);
}
return nodeList;
} catch (SQLException e) {
throw new DashboardServerException("Error occurred fetching servers.", e);
}
}
Aggregations