fixed issues in mqtt input adapter and thrift adapter after testing with multitenancy

revert-dabc3590
ayyoob 8 years ago
parent 1b4de09d7b
commit aaeac03cfb

@ -206,8 +206,14 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
} }
try { try {
mqttClient.subscribe(topic); mqttClient.subscribe(topic);
log.info("mqtt receiver subscribed to topic: " + topic);
} catch (MqttException e) { } catch (MqttException e) {
log.error("Failed to subscribe to topic: " + topic + ", Retrying....."); log.error("Failed to subscribe to topic: " + topic + ", Retrying.....");
try {
mqttClient.disconnect();
} catch (MqttException ex) {
// do nothing.
}
return false; return false;
} }
return true; return true;

@ -137,7 +137,7 @@ public class ThriftEventAdapterServiceComponent {
String tenantDomain = credentials.getDomainName(); String tenantDomain = credentials.getDomainName();
if (objects != null && objects.length > 0) { if (objects != null && objects.length > 0) {
if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) { if (tenantDomain.equals(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)) {
String[] splitValues = ((String) objects[0]).split("@@"); String[] splitValues = ((String) objects[0]).split("@");
if (splitValues.length > 1) { if (splitValues.length > 1) {
tenantDomain = splitValues[0]; tenantDomain = splitValues[0];
} }

@ -72,7 +72,7 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
private static final String UI_EXECUTE = "ui.execute"; private static final String UI_EXECUTE = "ui.execute";
private static Log log = LogFactory.getLog(DeviceAccessBasedMQTTAuthorizer.class); private static Log log = LogFactory.getLog(DeviceAccessBasedMQTTAuthorizer.class);
AuthorizationConfigurationManager MQTTAuthorizationConfiguration; private AuthorizationConfigurationManager MQTTAuthorizationConfiguration;
private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0"; private static final String CDMF_SERVER_BASE_CONTEXT = "/api/device-mgt/v1.0";
private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager"; private static final String CACHE_MANAGER_NAME = "mqttAuthorizationCacheManager";
private static final String CACHE_NAME = "mqttAuthorizationCache"; private static final String CACHE_NAME = "mqttAuthorizationCache";
@ -173,17 +173,15 @@ public class DeviceAccessBasedMQTTAuthorizer implements IAuthorizer {
} catch (FeignException e) { } catch (FeignException e) {
oAuthRequestInterceptor.resetApiApplicationKey(); oAuthRequestInterceptor.resetApiApplicationKey();
if (e.getMessage().contains(GATEWAY_ERROR_CODE)) { if (e.getMessage().contains(GATEWAY_ERROR_CODE)) {
log.error("Failed to connect to the device authorization service."); log.error("Failed to connect to the device authorization service.", e);
} else { } else {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
} }
log.error(e.getMessage(), e);
} }
return false;
} finally { } finally {
PrivilegedCarbonContext.endTenantFlow(); PrivilegedCarbonContext.endTenantFlow();
} }
return false;
} }
/** /**

Loading…
Cancel
Save