use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.SolaceTopicsDTO in project carbon-apimgt by wso2.
the class SolaceStoreUtils method populateSolaceTopics.
/**
* Populate Solace Topics from the response body
*
* @param solaceTopicsObjectDTO Solace Topic Object DTO
* @param permissionsObject Json Object of the body
* @param syntax Protocol Syntax
*/
private static void populateSolaceTopics(SolaceTopicsObjectDTO solaceTopicsObjectDTO, org.json.JSONObject permissionsObject, String syntax) {
SolaceTopicsDTO topicsDTO = new SolaceTopicsDTO();
if (permissionsObject.getJSONArray("publish") != null) {
List<String> publishTopics = new ArrayList<>();
for (int j = 0; j < permissionsObject.getJSONArray("publish").length(); j++) {
org.json.JSONObject channelObject = permissionsObject.getJSONArray("publish").getJSONObject(j);
for (Object x : channelObject.keySet()) {
org.json.JSONObject channel = channelObject.getJSONObject(x.toString());
JSONArray channelPermissions = channel.getJSONArray("permissions");
for (int k = 0; k < channelPermissions.length(); k++) {
if (!publishTopics.contains(channelPermissions.getString(k))) {
publishTopics.add(channelPermissions.getString(k));
}
}
}
}
topicsDTO.setPublishTopics(publishTopics);
}
if (permissionsObject.getJSONArray("subscribe") != null) {
List<String> subscribeTopics = new ArrayList<>();
for (int j = 0; j < permissionsObject.getJSONArray("subscribe").length(); j++) {
org.json.JSONObject channelObject = permissionsObject.getJSONArray("subscribe").getJSONObject(j);
for (Object x : channelObject.keySet()) {
org.json.JSONObject channel = channelObject.getJSONObject(x.toString());
JSONArray channelPermissions = channel.getJSONArray("permissions");
for (int k = 0; k < channelPermissions.length(); k++) {
if (!subscribeTopics.contains(channelPermissions.getString(k))) {
subscribeTopics.add(channelPermissions.getString(k));
}
}
}
}
topicsDTO.setSubscribeTopics(subscribeTopics);
}
if (SolaceConstants.MQTT_TRANSPORT_PROTOCOL_NAME.equalsIgnoreCase(syntax)) {
solaceTopicsObjectDTO.setMqttSyntax(topicsDTO);
} else {
solaceTopicsObjectDTO.setDefaultSyntax(topicsDTO);
}
}
use of org.wso2.carbon.apimgt.rest.api.store.v1.dto.SolaceTopicsDTO in project carbon-apimgt by wso2.
the class AdditionalSubscriptionInfoMappingUtil method mapSolaceTopicObjects.
/**
* Map SolaceTopicsObjectDTO details from Solace package to DevPortal DTOs
*
* @param solaceTopicsObject SolaceTopicsObjectDTO object from Solace package
* @return AdditionalSubscriptionInfoSolaceTopicsObjectDTO object
*/
private static AdditionalSubscriptionInfoSolaceTopicsObjectDTO mapSolaceTopicObjects(SolaceTopicsObjectDTO solaceTopicsObject) {
AdditionalSubscriptionInfoSolaceTopicsObjectDTO solaceTopicsObjectDTO = new AdditionalSubscriptionInfoSolaceTopicsObjectDTO();
// Set default syntax object
org.wso2.carbon.apimgt.solace.dtos.SolaceTopicsDTO defaultSyntaxObject = solaceTopicsObject.getDefaultSyntax();
SolaceTopicsDTO storeDefaultSolaceTopicObject = new SolaceTopicsDTO();
storeDefaultSolaceTopicObject.setPublishTopics(defaultSyntaxObject.getPublishTopics());
storeDefaultSolaceTopicObject.setSubscribeTopics(defaultSyntaxObject.getSubscribeTopics());
solaceTopicsObjectDTO.setDefaultSyntax(storeDefaultSolaceTopicObject);
// Set mqtt syntax object
org.wso2.carbon.apimgt.solace.dtos.SolaceTopicsDTO mqttSyntaxObject = solaceTopicsObject.getMqttSyntax();
SolaceTopicsDTO storeMQTTSolaceTopicObject = new SolaceTopicsDTO();
storeMQTTSolaceTopicObject.setPublishTopics(mqttSyntaxObject.getPublishTopics());
storeMQTTSolaceTopicObject.setSubscribeTopics(mqttSyntaxObject.getSubscribeTopics());
solaceTopicsObjectDTO.setMqttSyntax(storeMQTTSolaceTopicObject);
return solaceTopicsObjectDTO;
}
Aggregations