mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Fix FCM and configuration fetching issues
This commit is contained in:
parent
ecca2b3f19
commit
28e0c88222
@ -64,7 +64,7 @@ public class FCMNotificationStrategy implements NotificationStrategy {
|
||||
if (NOTIFIER_TYPE_FCM.equals(config.getType())) {
|
||||
Device device = FCMDataHolder.getInstance().getDeviceManagementProviderService()
|
||||
.getDeviceWithTypeProperties(ctx.getDeviceId());
|
||||
if(getFCMToken(device.getProperties()) != null) {
|
||||
if(device.getProperties() != null && getFCMToken(device.getProperties()) != null) {
|
||||
this.sendWakeUpCall(ctx.getOperation().getCode(), device);
|
||||
}
|
||||
} else {
|
||||
@ -92,6 +92,7 @@ public class FCMNotificationStrategy implements NotificationStrategy {
|
||||
|
||||
private void sendWakeUpCall(String message, Device device) throws IOException,
|
||||
PushNotificationExecutionFailedException {
|
||||
if (device.getProperties() != null) {
|
||||
OutputStream os = null;
|
||||
byte[] bytes = getFCMRequest(message, getFCMToken(device.getProperties())).getBytes();
|
||||
|
||||
@ -121,6 +122,7 @@ public class FCMNotificationStrategy implements NotificationStrategy {
|
||||
"error code '" + status + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFCMRequest(String message, String registrationId) {
|
||||
JsonObject fcmRequest = new JsonObject();
|
||||
|
||||
@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProfileOperation extends ConfigOperation implements Serializable {
|
||||
private static final long serialVersionUID = -3322674908775087365L;
|
||||
private List<Integer> correctiveActionIds;
|
||||
|
||||
private List<Integer> reactiveActionIds;
|
||||
|
||||
@ -36,6 +36,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.template;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.CarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceStatusTaskPluginConfig;
|
||||
@ -336,7 +337,19 @@ public class DeviceTypeManagerService implements DeviceManagementService {
|
||||
private Map<String, String> getConfigProperty(List<ConfigurationEntry> configs) {
|
||||
Map<String, String> propertMap = new HashMap<>();
|
||||
for (ConfigurationEntry entry : configs) {
|
||||
if (entry != null && entry.getValue() != null && entry.getName() != null) {
|
||||
propertMap.put(entry.getName(), entry.getValue().toString());
|
||||
} else {
|
||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
String domain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||
String message = "Could not find a property in tenant id: " + tenantId + ", " +
|
||||
"domain: " + domain;
|
||||
if (entry != null && entry.getName() != null) {
|
||||
message += ", missing value for properly: " + entry.getName();
|
||||
}
|
||||
|
||||
log.error(message);
|
||||
}
|
||||
}
|
||||
return propertMap;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user