mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding pluggable push notification framework
This commit is contained in:
parent
7051af8d80
commit
a375252a94
@ -0,0 +1,147 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>device-mgt-extensions</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>WSO2 Carbon - GCM Based Push Notification Provider Implementation</name>
|
||||||
|
<description>WSO2 Carbon - GCM Based Push Notification Provider Implementation</description>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.governance</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.governance.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
<artifactId>axiom-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.orbit.org.scannotation</groupId>
|
||||||
|
<artifactId>scannotation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.axis2.wso2</groupId>
|
||||||
|
<artifactId>axis2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang.wso2</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json.wso2</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>GCM Based Push Notification Provider Bundle</Bundle-Description>
|
||||||
|
<Export-Package>
|
||||||
|
!org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal,
|
||||||
|
org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.*
|
||||||
|
</Export-Package>
|
||||||
|
<Import-Package>
|
||||||
|
com.google.gson,
|
||||||
|
org.osgi.service.component,
|
||||||
|
org.wso2.carbon.device.mgt.common.operation.mgt,
|
||||||
|
org.wso2.carbon.device.mgt.common.push.notification,
|
||||||
|
org.apache.commons.logging,
|
||||||
|
org.wso2.carbon.device.mgt.common,
|
||||||
|
org.wso2.carbon.device.mgt.core.service
|
||||||
|
</Import-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
|
|
||||||
|
public class GCMBasedPushNotificationProvider implements PushNotificationProvider {
|
||||||
|
|
||||||
|
private static final String PS_PROVIDER_GCM = "GCM";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return PS_PROVIDER_GCM;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) {
|
||||||
|
return new GCMNotificationStrategy(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||||
|
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMDataHolder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GCMNotificationStrategy implements NotificationStrategy {
|
||||||
|
|
||||||
|
private static final String GCM_TOKEN = "GCM_TOKEN";
|
||||||
|
private final static String GCM_ENDPOINT = "https://gcm-http.googleapis.com/gcm/send";
|
||||||
|
private static final String GCM_API_KEY = "gcmAPIKey";
|
||||||
|
private static final int TIME_TO_LIVE = 60;
|
||||||
|
private static final int HTTP_STATUS_CODE_OK = 200;
|
||||||
|
private PushNotificationConfig config;
|
||||||
|
|
||||||
|
public GCMNotificationStrategy(PushNotificationConfig config) {
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||||
|
try {
|
||||||
|
Device device =
|
||||||
|
GCMDataHolder.getInstance().getDeviceManagementProviderService().getDevice(ctx.getDeviceId());
|
||||||
|
this.sendWakeUpCall(ctx.getOperation().getCode(), device);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new PushNotificationExecutionFailedException("Error occurred while retrieving device information", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new PushNotificationExecutionFailedException("Error occurred while sending push notification", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationContext buildContext() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendWakeUpCall(String message,
|
||||||
|
Device device) throws IOException, PushNotificationExecutionFailedException {
|
||||||
|
OutputStream os = null;
|
||||||
|
byte[] bytes = getGCMRequest(message, getGCMToken(device.getProperties())).getBytes();
|
||||||
|
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
try {
|
||||||
|
conn = (HttpURLConnection) (new URL(config.getProperty(GCM_ENDPOINT)).openConnection());
|
||||||
|
conn.setDoOutput(true);
|
||||||
|
conn.setUseCaches(false);
|
||||||
|
conn.setFixedLengthStreamingMode(bytes.length);
|
||||||
|
conn.setRequestMethod("POST");
|
||||||
|
conn.setRequestProperty("Content-Type", "application/json");
|
||||||
|
conn.setRequestProperty("Authorization", "key=" + config.getProperty(GCM_API_KEY));
|
||||||
|
|
||||||
|
os = conn.getOutputStream();
|
||||||
|
os.write(bytes);
|
||||||
|
} finally {
|
||||||
|
if (os != null) {
|
||||||
|
os.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int status = conn.getResponseCode();
|
||||||
|
if (status != HTTP_STATUS_CODE_OK) {
|
||||||
|
throw new PushNotificationExecutionFailedException("Push notification sending failed with the HTTP " +
|
||||||
|
"error code '" + status + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getGCMRequest(String message, String registrationId) {
|
||||||
|
JsonObject gcmRequest = new JsonObject();
|
||||||
|
gcmRequest.addProperty("delay_while_idle", false);
|
||||||
|
gcmRequest.addProperty("time_to_live", TIME_TO_LIVE);
|
||||||
|
|
||||||
|
//Add message to GCM request
|
||||||
|
JsonObject data = new JsonObject();
|
||||||
|
if (message != null && !message.isEmpty()) {
|
||||||
|
data.addProperty("data", message);
|
||||||
|
gcmRequest.add("data", data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Set device reg-id
|
||||||
|
JsonArray regIds = new JsonArray();
|
||||||
|
regIds.add(new JsonPrimitive(registrationId));
|
||||||
|
|
||||||
|
gcmRequest.add("registration_ids", regIds);
|
||||||
|
return gcmRequest.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getGCMToken(List<Device.Property> properties) {
|
||||||
|
String gcmToken = null;
|
||||||
|
for (Device.Property property : properties) {
|
||||||
|
if (GCM_TOKEN.equals(property.getName())) {
|
||||||
|
gcmToken = property.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gcmToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
public class GCMDataHolder {
|
||||||
|
|
||||||
|
private DeviceManagementProviderService deviceManagementProviderService;
|
||||||
|
private static GCMDataHolder thisInstance = new GCMDataHolder();
|
||||||
|
|
||||||
|
public static GCMDataHolder getInstance() {
|
||||||
|
return thisInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceManagementProviderService getDeviceManagementProviderService() {
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
this.deviceManagementProviderService = deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.osgi.service.component.ComponentContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.GCMPushNotificationServiceComponent" immediate="true"
|
||||||
|
* @scr.reference name="carbon.device.mgt.provider"
|
||||||
|
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
|
||||||
|
* cardinality="1..1"
|
||||||
|
* policy="dynamic"
|
||||||
|
* bind="setDeviceManagementProviderService"
|
||||||
|
* unbind="unsetDeviceManagementProviderService"
|
||||||
|
*/
|
||||||
|
public class GCMPushNotificationServiceComponent {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(GCMPushNotificationServiceComponent.class);
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
protected void activate(ComponentContext componentContext) {
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing GCM based push notification provider implementation bundle");
|
||||||
|
}
|
||||||
|
//Do nothing
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("GCM based push notification provider implementation bundle has been successfully " +
|
||||||
|
"initialized");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Error occurred while initializing GCM based push notification provider " +
|
||||||
|
"implementation bundle", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deactivate(ComponentContext componentContext) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
GCMDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,148 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>device-mgt-extensions</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>WSO2 Carbon - MQTT Based Push Notification Provider Implementation</name>
|
||||||
|
<description>WSO2 Carbon - MQTT Based Push Notification Provider Implementation</description>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.governance</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.governance.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
<artifactId>axiom-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.orbit.org.scannotation</groupId>
|
||||||
|
<artifactId>scannotation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.axis2.wso2</groupId>
|
||||||
|
<artifactId>axis2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang.wso2</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json.wso2</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>MQTT Based Push Notification Provider Bundle</Bundle-Description>
|
||||||
|
<Export-Package>
|
||||||
|
!org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal,
|
||||||
|
org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.*
|
||||||
|
</Export-Package>
|
||||||
|
<Import-Package>
|
||||||
|
org.apache.commons.logging,
|
||||||
|
org.osgi.service.component,
|
||||||
|
org.wso2.carbon.context,
|
||||||
|
org.wso2.carbon.device.mgt.common.operation.mgt,
|
||||||
|
org.wso2.carbon.device.mgt.common.push.notification,
|
||||||
|
org.wso2.carbon.device.mgt.core.service,
|
||||||
|
org.wso2.carbon.event.output.adapter.core,
|
||||||
|
org.wso2.carbon.event.output.adapter.core.exception
|
||||||
|
</Import-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
|
|
||||||
|
public class MQTTBasedPushNotificationProvider implements PushNotificationProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "MQTT";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationStrategy getNotificationStrategy(PushNotificationConfig config) {
|
||||||
|
return new MQTTNotificationStrategy(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||||
|
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.MQTTDataHolder;
|
||||||
|
import org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util.MQTTAdapterConstants;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.MessageType;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterConfiguration;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.exception.OutputEventAdapterException;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class MQTTNotificationStrategy implements NotificationStrategy {
|
||||||
|
|
||||||
|
private static final String MQTT_ADAPTER_PROPERTY_NAME = "mqtt.adapter.name";
|
||||||
|
private static final String MQTT_ADAPTER_TOPIC = "mqtt.adapter.topic";
|
||||||
|
private static final String MQTT_ADAPTER_NAME = "mqtt.push.notification.publisher";
|
||||||
|
|
||||||
|
public MQTTNotificationStrategy(PushNotificationConfig config) {
|
||||||
|
OutputEventAdapterConfiguration adapterConfig = new OutputEventAdapterConfiguration();
|
||||||
|
adapterConfig.setType(MQTTAdapterConstants.MQTT_ADAPTER_TYPE);
|
||||||
|
adapterConfig.setName(MQTT_ADAPTER_NAME);
|
||||||
|
adapterConfig.setMessageFormat(MessageType.JSON);
|
||||||
|
|
||||||
|
Map<String, String> configProperties = new HashMap<String, String>();
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_BROKER_URL));
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_USERNAME));
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_DCR_URL,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_DCR_URL));
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_CLEAR_SESSION));
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_SCOPES));
|
||||||
|
configProperties.put(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_MESSAGE_QOS,
|
||||||
|
config.getProperty(MQTTAdapterConstants.MQTT_ADAPTER_PROPERTY_MESSAGE_QOS));
|
||||||
|
adapterConfig.setStaticProperties(configProperties);
|
||||||
|
try {
|
||||||
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().create(adapterConfig);
|
||||||
|
} catch (OutputEventAdapterException e) {
|
||||||
|
throw new RuntimeException("Error occurred while initializing MQTT output event adapter", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||||
|
Map<String, String> dynamicProperties = ctx.getProperties();
|
||||||
|
dynamicProperties.put("topic", (String) ctx.getOperation().getProperties().get(MQTT_ADAPTER_TOPIC));
|
||||||
|
MQTTDataHolder.getInstance().getOutputEventAdapterService().publish(MQTT_ADAPTER_NAME, dynamicProperties,
|
||||||
|
ctx.getOperation().getPayLoad());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationContext buildContext() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.CarbonContext;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
|
||||||
|
|
||||||
|
public class MQTTPushNotificationStrategyUtil {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MQTTPushNotificationStrategyUtil.class);
|
||||||
|
|
||||||
|
public static String getAuthenticatedUser() {
|
||||||
|
CarbonContext carbonContext = CarbonContext.getThreadLocalCarbonContext();
|
||||||
|
String username = carbonContext.getUsername();
|
||||||
|
String tenantDomain = carbonContext.getTenantDomain();
|
||||||
|
if (username.endsWith(tenantDomain)) {
|
||||||
|
return username.substring(0, username.lastIndexOf("@"));
|
||||||
|
}
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getAuthenticatedUserTenantDomain() {
|
||||||
|
return CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
|
||||||
|
|
||||||
|
public class MQTTDataHolder {
|
||||||
|
|
||||||
|
private OutputEventAdapterService outputEventAdapterService;
|
||||||
|
private DeviceManagementProviderService deviceManagementProviderService;
|
||||||
|
private static MQTTDataHolder thisInstance = new MQTTDataHolder();
|
||||||
|
|
||||||
|
public static MQTTDataHolder getInstance() {
|
||||||
|
return thisInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceManagementProviderService getDeviceManagementProviderService() {
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
this.deviceManagementProviderService = deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService) {
|
||||||
|
this.outputEventAdapterService = outputEventAdapterService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public OutputEventAdapterService getOutputEventAdapterService() {
|
||||||
|
return outputEventAdapterService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.osgi.service.component.ComponentContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.MQTTPushNotificationServiceComponent" immediate="true"
|
||||||
|
* @scr.reference name="carbon.device.mgt.provider"
|
||||||
|
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
|
||||||
|
* cardinality="1..1"
|
||||||
|
* policy="dynamic"
|
||||||
|
* bind="setDeviceManagementProviderService"
|
||||||
|
* unbind="unsetDeviceManagementProviderService"
|
||||||
|
* @scr.reference name="event.output.adapter.service"
|
||||||
|
* interface="org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService"
|
||||||
|
* cardinality="1..1" policy="dynamic" bind="setOutputEventAdapterService"
|
||||||
|
* unbind="unsetOutputEventAdapterService"
|
||||||
|
*/
|
||||||
|
public class MQTTPushNotificationServiceComponent {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(MQTTPushNotificationServiceComponent.class);
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
protected void activate(ComponentContext componentContext) {
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing MQTT based push notification provider implementation bundle");
|
||||||
|
}
|
||||||
|
//Do nothing
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("MQTT based push notification provider implementation bundle has been successfully " +
|
||||||
|
"initialized");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Error occurred while initializing MQTT based push notification provider " +
|
||||||
|
"implementation bundle", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deactivate(ComponentContext componentContext) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
MQTTDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
MQTTDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService){
|
||||||
|
MQTTDataHolder.getInstance().setOutputEventAdapterService(outputEventAdapterService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetOutputEventAdapterService(OutputEventAdapterService outputEventAdapterService){
|
||||||
|
MQTTDataHolder.getInstance().setOutputEventAdapterService(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.internal.util;
|
||||||
|
|
||||||
|
public final class MQTTAdapterConstants {
|
||||||
|
|
||||||
|
private MQTTAdapterConstants() {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String MQTT_ADAPTER_TYPE = "oauth-mqtt";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_BROKER_URL = "url";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_USERNAME = "username";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_DCR_URL = "dcrUrl";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_SCOPES = "scopes";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_PASSWORD = "password";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_CLIENT_ID = "clientId";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_CLEAR_SESSION = "cleanSession";
|
||||||
|
public static final String MQTT_ADAPTER_PROPERTY_MESSAGE_QOS = "qos";
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,144 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>device-mgt-extensions</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</artifactId>
|
||||||
|
<packaging>bundle</packaging>
|
||||||
|
<name>WSO2 Carbon - XMPP Based Push Notification Provider Implementation</name>
|
||||||
|
<description>WSO2 Carbon - XMPP Based Push Notification Provider Implementation</description>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.governance</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.governance.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.registry.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
|
<artifactId>axiom-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.orbit.org.scannotation</groupId>
|
||||||
|
<artifactId>scannotation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.osgi</groupId>
|
||||||
|
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.tomcat</groupId>
|
||||||
|
<artifactId>tomcat-servlet-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
<artifactId>jsr311-api</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.axis2.wso2</groupId>
|
||||||
|
<artifactId>axis2</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang.wso2</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json.wso2</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-bundle-plugin</artifactId>
|
||||||
|
<extensions>true</extensions>
|
||||||
|
<configuration>
|
||||||
|
<instructions>
|
||||||
|
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
|
||||||
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
|
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
|
||||||
|
<Bundle-Description>XMPP Based Push Notification Provider Bundle</Bundle-Description>
|
||||||
|
<Export-Package>
|
||||||
|
!org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.internal,
|
||||||
|
org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.*
|
||||||
|
</Export-Package>
|
||||||
|
<Import-Package>
|
||||||
|
org.apache.commons.logging,
|
||||||
|
org.osgi.service.component,
|
||||||
|
org.wso2.carbon.device.mgt.common.push.notification,
|
||||||
|
org.wso2.carbon.device.mgt.core.service
|
||||||
|
</Import-Package>
|
||||||
|
</instructions>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
|
|
||||||
|
public class XMPPBasedPushNotificationProvider implements PushNotificationProvider {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "XMPP";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationStrategy getNotificationStrategy(PushNotificationConfig pushNotificationConfig) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||||
|
|
||||||
|
public class XMPPNotificationStrategy implements NotificationStrategy {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NotificationContext buildContext() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.internal;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
public class XMPPDataHolder {
|
||||||
|
|
||||||
|
private DeviceManagementProviderService deviceManagementProviderService;
|
||||||
|
private static XMPPDataHolder thisInstance = new XMPPDataHolder();
|
||||||
|
|
||||||
|
public static XMPPDataHolder getInstance() {
|
||||||
|
return thisInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceManagementProviderService getDeviceManagementProviderService() {
|
||||||
|
return deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
this.deviceManagementProviderService = deviceManagementProviderService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.osgi.service.component.ComponentContext;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @scr.component name="org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.internal.XMPPPushNotificationServiceComponent" immediate="true"
|
||||||
|
* @scr.reference name="carbon.device.mgt.provider"
|
||||||
|
* interface="org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService"
|
||||||
|
* cardinality="1..1"
|
||||||
|
* policy="dynamic"
|
||||||
|
* bind="setDeviceManagementProviderService"
|
||||||
|
* unbind="unsetDeviceManagementProviderService"
|
||||||
|
*/
|
||||||
|
public class XMPPPushNotificationServiceComponent {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(XMPPPushNotificationServiceComponent.class);
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
protected void activate(ComponentContext componentContext) {
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing XMPP based push notification provider implementation bundle");
|
||||||
|
}
|
||||||
|
//Do nothing
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("XMPP based push notification provider implementation bundle has been successfully " +
|
||||||
|
"initialized");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Error occurred while initializing XMPP based push notification provider " +
|
||||||
|
"implementation bundle", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deactivate(ComponentContext componentContext) {
|
||||||
|
//Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
XMPPDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetDeviceManagementProviderService(
|
||||||
|
DeviceManagementProviderService deviceManagementProviderService) {
|
||||||
|
XMPPDataHolder.getInstance().setDeviceManagementProviderService(deviceManagementProviderService);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
42
components/device-mgt-extensions/pom.xml
Normal file
42
components/device-mgt-extensions/pom.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<artifactId>carbon-devicemgt</artifactId>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>device-mgt-extensions</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>WSO2 Carbon - Device Management Extensions</name>
|
||||||
|
<description>WSO2 Carbon - Device Management Extensions</description>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm</module>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</module>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -128,7 +128,14 @@ public class OperationImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Opera
|
|||||||
ResponsePayload responseMsg = new ResponsePayload();
|
ResponsePayload responseMsg = new ResponsePayload();
|
||||||
try {
|
try {
|
||||||
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
|
dmService = DeviceMgtAPIUtils.getDeviceManagementService();
|
||||||
int operationId = dmService.addOperation(operationContext.getOperation(), operationContext.getDevices());
|
|
||||||
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
List<DeviceIdentifier> deviceIdentifiers = operationContext.getDevices();
|
||||||
|
if (deviceIdentifiers.size() > 0) {
|
||||||
|
type = deviceIdentifiers.get(0).getType();
|
||||||
|
}
|
||||||
|
int operationId = dmService.addOperation(type, operationContext.getOperation(), operationContext.getDevices());
|
||||||
if (operationId > 0) {
|
if (operationId > 0) {
|
||||||
responseMsg.setStatusCode(HttpStatus.SC_CREATED);
|
responseMsg.setStatusCode(HttpStatus.SC_CREATED);
|
||||||
responseMsg.setMessageFromServer("Operation has added successfully.");
|
responseMsg.setMessageFromServer("Operation has added successfully.");
|
||||||
|
|||||||
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.common.push.notification;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class NotificationContext {
|
||||||
|
|
||||||
|
private DeviceIdentifier deviceId;
|
||||||
|
|
||||||
|
private Operation operation;
|
||||||
|
|
||||||
|
private Map<String, String> properties;
|
||||||
|
|
||||||
|
public NotificationContext(DeviceIdentifier deviceId) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationContext(DeviceIdentifier deviceId, Operation operation) {
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DeviceIdentifier getDeviceId() {
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Operation getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.common.push.notification;
|
||||||
|
|
||||||
|
public interface NotificationStrategy {
|
||||||
|
|
||||||
|
void init();
|
||||||
|
|
||||||
|
void execute(NotificationContext ctx) throws PushNotificationExecutionFailedException;
|
||||||
|
|
||||||
|
NotificationContext buildContext();
|
||||||
|
|
||||||
|
}
|
||||||
@ -18,24 +18,32 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.common.push.notification;
|
package org.wso2.carbon.device.mgt.common.push.notification;
|
||||||
|
|
||||||
import java.util.Set;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@XmlRootElement(name = "PushNotificationProviderConfiguration")
|
||||||
public class PushNotificationConfig {
|
public class PushNotificationConfig {
|
||||||
|
|
||||||
private String type;
|
private String type;
|
||||||
private Set<String> properties;
|
Map<String, String> properties;
|
||||||
|
|
||||||
public PushNotificationConfig(String type, Set<String> properties) {
|
public PushNotificationConfig(String type, Map<String, String> properties) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@XmlElement(name = "Type", required = true)
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getProperties() {
|
public Map<String, String> getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProperty(String name) {
|
||||||
|
return properties.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.common.push.notification;
|
||||||
|
|
||||||
|
public class PushNotificationExecutionFailedException extends Exception {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279311923070297L;
|
||||||
|
|
||||||
|
public PushNotificationExecutionFailedException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationExecutionFailedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationExecutionFailedException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationExecutionFailedException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationExecutionFailedException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.common.push.notification;
|
||||||
|
|
||||||
|
public interface PushNotificationProvider {
|
||||||
|
|
||||||
|
String getType();
|
||||||
|
|
||||||
|
NotificationStrategy getNotificationStrategy(PushNotificationConfig config);
|
||||||
|
|
||||||
|
}
|
||||||
@ -91,6 +91,7 @@
|
|||||||
!org.wso2.carbon.device.mgt.core.internal,
|
!org.wso2.carbon.device.mgt.core.internal,
|
||||||
org.wso2.carbon.device.mgt.core.*
|
org.wso2.carbon.device.mgt.core.*
|
||||||
</Export-Package>
|
</Export-Package>
|
||||||
|
<DynamicImport-Package>*</DynamicImport-Package>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|||||||
@ -94,17 +94,19 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIds)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
try {
|
try {
|
||||||
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, deviceIds);
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (deviceIds.size() > 0) {
|
||||||
|
type = deviceIds.get(0).getType();
|
||||||
|
}
|
||||||
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(type, operation,
|
||||||
|
deviceIds);
|
||||||
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().notifyOperationToDevices
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().notifyOperationToDevices
|
||||||
(operation, deviceIds);
|
(operation, deviceIds);
|
||||||
} catch (OperationManagementException opeEx) {
|
} catch (OperationManagementException e) {
|
||||||
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
throw new ApplicationManagementException("Error in add operation at app installation", e);
|
||||||
log.error(errorMsg, opeEx);
|
} catch (DeviceManagementException e) {
|
||||||
throw new ApplicationManagementException(errorMsg, opeEx);
|
throw new ApplicationManagementException("Error in notify operation at app installation", e);
|
||||||
}catch (DeviceManagementException deviceEx){
|
|
||||||
String errorMsg = "Error in notify operation at app installation:" + deviceEx.getErrorMessage();
|
|
||||||
log.error(errorMsg, deviceEx);
|
|
||||||
throw new ApplicationManagementException(errorMsg, deviceEx);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +121,6 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
DeviceIdentifier deviceIdentifier;
|
DeviceIdentifier deviceIdentifier;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (String user : userNameList) {
|
for (String user : userNameList) {
|
||||||
userName = user;
|
userName = user;
|
||||||
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevicesOfUser
|
deviceList = DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().getDevicesOfUser
|
||||||
@ -132,18 +133,20 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
deviceIdentifierList.add(deviceIdentifier);
|
deviceIdentifierList.add(deviceIdentifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (deviceIdentifierList.size() > 0) {
|
||||||
|
type = deviceIdentifierList.get(0).getType();
|
||||||
|
}
|
||||||
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
||||||
.addOperation(operation, deviceIdentifierList);
|
.addOperation(type, operation, deviceIdentifierList);
|
||||||
|
|
||||||
} catch (DeviceManagementException devEx) {
|
} catch (DeviceManagementException e) {
|
||||||
String errorMsg = "Error in get devices for user: "+userName+ " in app installation:" + devEx.getErrorMessage();
|
throw new ApplicationManagementException("Error in get devices for user: " + userName +
|
||||||
log.error(errorMsg, devEx);
|
" in app installation", e);
|
||||||
throw new ApplicationManagementException(errorMsg, devEx);
|
|
||||||
|
|
||||||
} catch (OperationManagementException opeEx) {
|
} catch (OperationManagementException e) {
|
||||||
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
throw new ApplicationManagementException("Error in add operation at app installation", e);
|
||||||
log.error(errorMsg, opeEx);
|
|
||||||
throw new ApplicationManagementException(errorMsg, opeEx);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -170,19 +173,20 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
|
|||||||
deviceIdentifierList.add(deviceIdentifier);
|
deviceIdentifierList.add(deviceIdentifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider()
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
.addOperation(operation, deviceIdentifierList);
|
String type = null;
|
||||||
|
if (deviceIdentifierList.size() > 0) {
|
||||||
|
type = deviceIdentifierList.get(0).getType();
|
||||||
|
}
|
||||||
|
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(type, operation,
|
||||||
|
deviceIdentifierList);
|
||||||
|
|
||||||
} catch (DeviceManagementException devEx) {
|
} catch (DeviceManagementException e) {
|
||||||
String errorMsg = "Error in get devices for user role "+userRole+ " in app installation:"
|
throw new ApplicationManagementException("Error in get devices for user role " + userRole +
|
||||||
+ devEx.getErrorMessage();
|
" in app installation", e);
|
||||||
log.error(errorMsg, devEx);
|
|
||||||
throw new ApplicationManagementException(errorMsg, devEx);
|
|
||||||
|
|
||||||
} catch (OperationManagementException opeEx) {
|
} catch (OperationManagementException e) {
|
||||||
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
|
throw new ApplicationManagementException("Error in add operation at app installation", e);
|
||||||
log.error(errorMsg, opeEx);
|
|
||||||
throw new ApplicationManagementException(errorMsg, opeEx);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,13 +31,14 @@ import java.util.List;
|
|||||||
* Represents Device Mgt configuration.
|
* Represents Device Mgt configuration.
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "DeviceMgtConfiguration")
|
@XmlRootElement(name = "DeviceMgtConfiguration")
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public final class DeviceManagementConfig {
|
public final class DeviceManagementConfig {
|
||||||
|
|
||||||
private DeviceManagementConfigRepository deviceManagementConfigRepository;
|
private DeviceManagementConfigRepository deviceManagementConfigRepository;
|
||||||
private TaskConfiguration taskConfiguration;
|
private TaskConfiguration taskConfiguration;
|
||||||
private IdentityConfigurations identityConfigurations;
|
private IdentityConfigurations identityConfigurations;
|
||||||
private PolicyConfiguration policyConfiguration;
|
private PolicyConfiguration policyConfiguration;
|
||||||
//private List<String> pushNotificationProviders;
|
private List<String> pushNotificationProviders;
|
||||||
private DTConfiguration dTDepyloymentConfiguration;
|
private DTConfiguration dTDepyloymentConfiguration;
|
||||||
|
|
||||||
@XmlElement(name = "ManagementRepository", required = true)
|
@XmlElement(name = "ManagementRepository", required = true)
|
||||||
@ -86,15 +87,16 @@ public final class DeviceManagementConfig {
|
|||||||
this.dTDepyloymentConfiguration = dTDeploymentConfiguration;
|
this.dTDepyloymentConfiguration = dTDeploymentConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @XmlElementWrapper(name = "PushNotificationProviders", required = true)
|
|
||||||
// @XmlElement(name = "Provider", required = true)
|
@XmlElementWrapper(name = "PushNotificationProviders", required = true)
|
||||||
// public List<String> getPushNotificationProviders() {
|
@XmlElement(name = "Provider", required = true)
|
||||||
// return pushNotificationProviders;
|
public List<String> getPushNotificationProviders() {
|
||||||
// }
|
return pushNotificationProviders;
|
||||||
//
|
}
|
||||||
// public void setPushNotificationProviders(List<String> pushNotificationProviders) {
|
|
||||||
// this.pushNotificationProviders = pushNotificationProviders;
|
public void setPushNotificationProviders(List<String> pushNotificationProviders) {
|
||||||
// }
|
this.pushNotificationProviders = pushNotificationProviders;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
|
||||||
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||||
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
|
import org.wso2.carbon.email.sender.core.service.EmailSenderService;
|
||||||
@ -53,6 +54,7 @@ public class DeviceManagementDataHolder {
|
|||||||
private GroupManagementProviderService groupManagementProviderService;
|
private GroupManagementProviderService groupManagementProviderService;
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
private EmailSenderService emailSenderService;
|
private EmailSenderService emailSenderService;
|
||||||
|
private PushNotificationProviderRepository pushNotificationProviderRepository;
|
||||||
|
|
||||||
private DeviceManagementDataHolder() {}
|
private DeviceManagementDataHolder() {}
|
||||||
|
|
||||||
@ -196,4 +198,13 @@ public class DeviceManagementDataHolder {
|
|||||||
this.emailSenderService = emailSenderService;
|
this.emailSenderService = emailSenderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPushNotificationProviderRepository(
|
||||||
|
PushNotificationProviderRepository pushNotificationProviderRepository) {
|
||||||
|
this.pushNotificationProviderRepository = pushNotificationProviderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationProviderRepository getPushNotificationProviderRepository() {
|
||||||
|
return pushNotificationProviderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,8 @@ import org.wso2.carbon.device.mgt.common.notification.mgt.NotificationManagement
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
|
import org.wso2.carbon.device.mgt.common.permission.mgt.PermissionManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
||||||
@ -49,6 +51,8 @@ import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManageme
|
|||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
|
||||||
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
import org.wso2.carbon.device.mgt.core.permission.mgt.PermissionManagerServiceImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationConfigRepository;
|
||||||
|
import org.wso2.carbon.device.mgt.core.push.notification.mgt.PushNotificationProviderRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
||||||
@ -153,8 +157,19 @@ public class DeviceManagementServiceComponent {
|
|||||||
NotificationManagementDAOFactory.init(dsConfig);
|
NotificationManagementDAOFactory.init(dsConfig);
|
||||||
|
|
||||||
OperationManagementDAOFactory.init(dsConfig);
|
OperationManagementDAOFactory.init(dsConfig);
|
||||||
|
|
||||||
/* Initialize Operation Manager */
|
/* Initialize Operation Manager */
|
||||||
this.initOperationsManager();
|
this.initOperationsManager();
|
||||||
|
|
||||||
|
PushNotificationProviderRepository pushNotificationRepo = new PushNotificationProviderRepository();
|
||||||
|
List<String> pushNotificationProviders = config.getPushNotificationProviders();
|
||||||
|
if (pushNotificationProviders != null) {
|
||||||
|
for (String pushNoteProvider : pushNotificationProviders) {
|
||||||
|
pushNotificationRepo.addProvider(pushNoteProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DeviceManagementDataHolder.getInstance().setPushNotificationProviderRepository(pushNotificationRepo);
|
||||||
|
|
||||||
/* If -Dsetup option enabled then create device management database schema */
|
/* If -Dsetup option enabled then create device management database schema */
|
||||||
String setupOption =
|
String setupOption =
|
||||||
System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP);
|
System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP);
|
||||||
|
|||||||
@ -27,6 +27,9 @@ import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants;
|
|||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
@ -62,6 +65,7 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
private OperationMappingDAO operationMappingDAO;
|
private OperationMappingDAO operationMappingDAO;
|
||||||
private OperationDAO operationDAO;
|
private OperationDAO operationDAO;
|
||||||
private DeviceDAO deviceDAO;
|
private DeviceDAO deviceDAO;
|
||||||
|
private NotificationStrategy notificationStrategy;
|
||||||
|
|
||||||
public OperationManagerImpl() {
|
public OperationManagerImpl() {
|
||||||
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
|
commandOperationDAO = OperationManagementDAOFactory.getCommandOperationDAO();
|
||||||
@ -73,6 +77,11 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OperationManagerImpl(NotificationStrategy notificationStrategy) {
|
||||||
|
this();
|
||||||
|
this.notificationStrategy = notificationStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int addOperation(Operation operation,
|
public int addOperation(Operation operation,
|
||||||
List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
||||||
@ -83,28 +92,15 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
deviceIdentifier.getType() + "]");
|
deviceIdentifier.getType() + "]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
List<DeviceIdentifier> authorizedDeviceList;
|
List<DeviceIdentifier> authorizedDeviceList = this.getAuthorizedDevices(operation, deviceIds);
|
||||||
if (operation != null && isAuthenticationSkippedOperation(operation)) {
|
if (authorizedDeviceList.size() <= 0) {
|
||||||
authorizedDeviceList = deviceIds;
|
log.info("User : " + getUser() + " is not authorized to perform operations on given device-list.");
|
||||||
} else {
|
return -1;
|
||||||
authorizedDeviceList = DeviceManagementDataHolder.getInstance().
|
|
||||||
getDeviceAccessAuthorizationService().isUserAuthorized(deviceIds, DeviceGroupConstants.
|
|
||||||
Permissions.DEFAULT_OPERATOR_PERMISSIONS).getAuthorizedDevices();
|
|
||||||
}
|
}
|
||||||
if (authorizedDeviceList.size() > 0) {
|
|
||||||
|
List<EnrolmentInfo> enrolments = this.getEnrollmentsByStatus(deviceIds);
|
||||||
try {
|
try {
|
||||||
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
||||||
List<EnrolmentInfo> enrolments;
|
|
||||||
try {
|
|
||||||
DeviceManagementDAOFactory.openConnection();
|
|
||||||
enrolments = deviceDAO.getEnrolmentsByStatus(authorizedDeviceList, EnrolmentInfo.Status.ACTIVE, tenantId);
|
|
||||||
} catch (SQLException e) {
|
|
||||||
throw new OperationManagementException("Error occurred while opening a connection the data " +
|
|
||||||
"source", e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOFactory.closeConnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
OperationManagementDAOFactory.beginTransaction();
|
OperationManagementDAOFactory.beginTransaction();
|
||||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation operationDto =
|
||||||
@ -118,28 +114,67 @@ public class OperationManagerImpl implements OperationManager {
|
|||||||
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED);
|
org.wso2.carbon.device.mgt.core.dto.operation.mgt.Operation.Status.REPEATED);
|
||||||
}
|
}
|
||||||
operationMappingDAO.addOperationMapping(operationId, enrolmentInfo.getId());
|
operationMappingDAO.addOperationMapping(operationId, enrolmentInfo.getId());
|
||||||
|
if (notificationStrategy != null) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
notificationStrategy.execute(new NotificationContext(
|
||||||
|
new DeviceIdentifier(enrolmentInfo.getDevice().getDeviceIdentifier(),
|
||||||
|
enrolmentInfo.getDevice().getType())));
|
||||||
|
} catch (PushNotificationExecutionFailedException e) {
|
||||||
|
log.error("Error occurred while sending push notifications to " +
|
||||||
|
enrolmentInfo.getDevice().getType() + " device carrying id '" +
|
||||||
|
enrolmentInfo.getDevice().getDeviceIdentifier() + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OperationManagementDAOFactory.commitTransaction();
|
OperationManagementDAOFactory.commitTransaction();
|
||||||
return operationId;
|
return operationId;
|
||||||
} catch (OperationManagementDAOException e) {
|
} catch (OperationManagementDAOException e) {
|
||||||
OperationManagementDAOFactory.rollbackTransaction();
|
OperationManagementDAOFactory.rollbackTransaction();
|
||||||
throw new OperationManagementException("Error occurred while adding operation", e);
|
throw new OperationManagementException("Error occurred while adding operation", e);
|
||||||
} catch (DeviceManagementDAOException e) {
|
|
||||||
OperationManagementDAOFactory.rollbackTransaction();
|
|
||||||
throw new OperationManagementException("Error occurred while retrieving device metadata", e);
|
|
||||||
} catch (TransactionManagementException e) {
|
} catch (TransactionManagementException e) {
|
||||||
throw new OperationManagementException("Error occurred while initiating the transaction", e);
|
throw new OperationManagementException("Error occurred while initiating the transaction", e);
|
||||||
} finally {
|
} finally {
|
||||||
OperationManagementDAOFactory.closeConnection();
|
OperationManagementDAOFactory.closeConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<DeviceIdentifier> getAuthorizedDevices(
|
||||||
|
Operation operation, List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
||||||
|
List<DeviceIdentifier> authorizedDeviceList;
|
||||||
|
try {
|
||||||
|
if (operation != null && isAuthenticationSkippedOperation(operation)) {
|
||||||
|
authorizedDeviceList = deviceIds;
|
||||||
} else {
|
} else {
|
||||||
log.info("User : " + getUser() + " is not authorized to perform operations on given device-list.");
|
authorizedDeviceList = DeviceManagementDataHolder.getInstance().
|
||||||
|
getDeviceAccessAuthorizationService().isUserAuthorized(deviceIds).getAuthorizedDevices();
|
||||||
}
|
}
|
||||||
} catch (DeviceAccessAuthorizationException e) {
|
} catch (DeviceAccessAuthorizationException e) {
|
||||||
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
throw new OperationManagementException("Error occurred while authorizing access to the devices for user :" +
|
||||||
this.getUser(), e);
|
this.getUser(), e);
|
||||||
}
|
}
|
||||||
return -1;
|
return authorizedDeviceList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EnrolmentInfo> getEnrollmentsByStatus(
|
||||||
|
List<DeviceIdentifier> deviceIds) throws OperationManagementException {
|
||||||
|
List<EnrolmentInfo> enrolments;
|
||||||
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
|
try {
|
||||||
|
DeviceManagementDAOFactory.openConnection();
|
||||||
|
enrolments = deviceDAO.getEnrolmentsByStatus(deviceIds, EnrolmentInfo.Status.ACTIVE, tenantId);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new OperationManagementException("Error occurred while opening a connection the data " +
|
||||||
|
"source", e);
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
OperationManagementDAOFactory.rollbackTransaction();
|
||||||
|
throw new OperationManagementException(
|
||||||
|
"Error occurred while retrieving enrollments by status", e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOFactory.closeConnection();
|
||||||
|
}
|
||||||
|
return enrolments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.operation.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class OperationManagerRepository {
|
||||||
|
|
||||||
|
private Map<String, OperationManager> operationManagers;
|
||||||
|
|
||||||
|
public OperationManagerRepository() {
|
||||||
|
operationManagers = new ConcurrentHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addOperationManager(String type, OperationManager operationManager) {
|
||||||
|
operationManagers.put(type, operationManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationManager getOperationManager(String type) {
|
||||||
|
return operationManagers.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeOperationManager(String type) {
|
||||||
|
operationManagers.remove(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||||
|
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationExecutionFailedException;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PushNotificationBasedOperationManager implements OperationManager {
|
||||||
|
|
||||||
|
private OperationManager operationManager;
|
||||||
|
private NotificationStrategy notificationProvider;
|
||||||
|
|
||||||
|
public PushNotificationBasedOperationManager(
|
||||||
|
OperationManager operationManager, NotificationStrategy notificationProvider) {
|
||||||
|
this.operationManager = operationManager;
|
||||||
|
this.notificationProvider = notificationProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addOperation(Operation operation,
|
||||||
|
List<DeviceIdentifier> devices) throws OperationManagementException {
|
||||||
|
int operationId = this.operationManager.addOperation(operation, devices);
|
||||||
|
for (DeviceIdentifier deviceId : devices) {
|
||||||
|
try {
|
||||||
|
this.notificationProvider.execute(new NotificationContext(deviceId));
|
||||||
|
} catch (PushNotificationExecutionFailedException e) {
|
||||||
|
throw new OperationManagementException("Error occurred while sending push notification to device", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return operationId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException {
|
||||||
|
return this.operationManager.getOperations(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaginationResult getOperations(DeviceIdentifier deviceId,
|
||||||
|
PaginationRequest request) throws OperationManagementException {
|
||||||
|
return this.operationManager.getOperations(deviceId, request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Operation> getPendingOperations(
|
||||||
|
DeviceIdentifier deviceId) throws OperationManagementException {
|
||||||
|
return this.operationManager.getPendingOperations(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException {
|
||||||
|
return this.operationManager.getNextPendingOperation(deviceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateOperation(DeviceIdentifier deviceId,
|
||||||
|
Operation operation) throws OperationManagementException {
|
||||||
|
this.operationManager.updateOperation(deviceId, operation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteOperation(int operationId) throws OperationManagementException {
|
||||||
|
this.operationManager.deleteOperation(operationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation getOperationByDeviceAndOperationId(
|
||||||
|
DeviceIdentifier deviceId, int operationId) throws OperationManagementException {
|
||||||
|
return this.operationManager.getOperationByDeviceAndOperationId(deviceId, operationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Operation> getOperationsByDeviceAndStatus(
|
||||||
|
DeviceIdentifier deviceId,
|
||||||
|
Operation.Status status) throws OperationManagementException {
|
||||||
|
try {
|
||||||
|
return this.operationManager.getOperationsByDeviceAndStatus(deviceId, status);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
throw new OperationManagementException("Error occurred while retrieving the list of operations by " +
|
||||||
|
"device and status", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation getOperation(int operationId) throws OperationManagementException {
|
||||||
|
return this.operationManager.getOperation(operationId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Operation getOperationByActivityId(String activity) throws OperationManagementException {
|
||||||
|
return this.operationManager.getOperationByActivityId(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.context.CarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PushNotificationConfigRepository {
|
||||||
|
|
||||||
|
private Map<Integer, PushNotificationConfig> configs;
|
||||||
|
|
||||||
|
public PushNotificationConfigRepository() {
|
||||||
|
configs = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addConfig(PushNotificationConfig config) {
|
||||||
|
configs.put(CarbonContext.getThreadLocalCarbonContext().getTenantId(), config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationConfig getConfig() {
|
||||||
|
return configs.get(CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
|
|
||||||
|
public class PushNotificationEnabledDeviceManagementService {
|
||||||
|
|
||||||
|
public PushNotificationEnabledDeviceManagementService(
|
||||||
|
DeviceManagementService provider, NotificationStrategy strategy) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
|
|
||||||
|
public class PushNotificationProviderFactory {
|
||||||
|
|
||||||
|
public static PushNotificationProvider getPushNotificationFactory(String type) {
|
||||||
|
PushNotificationProvider provider =
|
||||||
|
DeviceManagementDataHolder.getInstance().getPushNotificationProviderRepository().getProvider(type);
|
||||||
|
if (provider == null) {
|
||||||
|
throw new UnsupportedPushNotificationProviderException("Push notification type '" + type +
|
||||||
|
"' is not supported");
|
||||||
|
}
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationProvider;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public class PushNotificationProviderRepository {
|
||||||
|
|
||||||
|
private Map<String, PushNotificationProvider> providers;
|
||||||
|
private static final Log log = LogFactory.getLog(PushNotificationProviderRepository.class);
|
||||||
|
|
||||||
|
public PushNotificationProviderRepository() {
|
||||||
|
this.providers = new ConcurrentHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProvider(PushNotificationProvider provider) {
|
||||||
|
providers.put(provider.getType(), provider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProvider(String className) {
|
||||||
|
try {
|
||||||
|
Class<?> clz = Class.forName(className);
|
||||||
|
PushNotificationProvider provider = (PushNotificationProvider) clz.newInstance();
|
||||||
|
providers.put(provider.getType(), provider);
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
log.error("Provided push notification provider implementation '" + className + "' cannot be found", e);
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
log.error("Error occurred while instantiating push notification provider implementation '" +
|
||||||
|
className + "'", e);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
log.error("Error occurred while adding push notification provider implementation '" + className + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public PushNotificationProvider getProvider(String type) {
|
||||||
|
return providers.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.wso2.carbon.device.mgt.core.push.notification.mgt;
|
||||||
|
|
||||||
|
public class UnsupportedPushNotificationProviderException extends RuntimeException {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -3151279321923070297L;
|
||||||
|
|
||||||
|
public UnsupportedPushNotificationProviderException(String msg, Exception nestedEx) {
|
||||||
|
super(msg, nestedEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsupportedPushNotificationProviderException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsupportedPushNotificationProviderException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsupportedPushNotificationProviderException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnsupportedPushNotificationProviderException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -27,6 +27,7 @@ import org.wso2.carbon.device.mgt.common.PaginationResult;
|
|||||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ import java.util.List;
|
|||||||
* Proxy class for all Device Management related operations that take the corresponding plugin type in
|
* Proxy class for all Device Management related operations that take the corresponding plugin type in
|
||||||
* and resolve the appropriate plugin implementation
|
* and resolve the appropriate plugin implementation
|
||||||
*/
|
*/
|
||||||
public interface DeviceManagementProviderService extends OperationManager {
|
public interface DeviceManagementProviderService {
|
||||||
|
|
||||||
List<Device> getAllDevices(String deviceType) throws DeviceManagementException;
|
List<Device> getAllDevices(String deviceType) throws DeviceManagementException;
|
||||||
|
|
||||||
@ -212,6 +213,35 @@ public interface DeviceManagementProviderService extends OperationManager {
|
|||||||
boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
|
boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
|
||||||
EnrolmentInfo.Status status) throws DeviceManagementException;
|
EnrolmentInfo.Status status) throws DeviceManagementException;
|
||||||
|
|
||||||
void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds) throws DeviceManagementException;
|
void notifyOperationToDevices(Operation operation,
|
||||||
|
List<DeviceIdentifier> deviceIds) throws DeviceManagementException;
|
||||||
|
|
||||||
|
int addOperation(String type, Operation operation,
|
||||||
|
List<DeviceIdentifier> devices) throws OperationManagementException;
|
||||||
|
|
||||||
|
List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException;
|
||||||
|
|
||||||
|
PaginationResult getOperations(DeviceIdentifier deviceId,
|
||||||
|
PaginationRequest request) throws OperationManagementException;
|
||||||
|
|
||||||
|
List<? extends Operation> getPendingOperations(
|
||||||
|
DeviceIdentifier deviceId) throws OperationManagementException;
|
||||||
|
|
||||||
|
Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException;
|
||||||
|
|
||||||
|
void updateOperation(DeviceIdentifier deviceId, Operation operation) throws OperationManagementException;
|
||||||
|
|
||||||
|
void deleteOperation(String type, int operationId) throws OperationManagementException;
|
||||||
|
|
||||||
|
Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
|
||||||
|
throws OperationManagementException;
|
||||||
|
|
||||||
|
List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
|
||||||
|
Operation.Status status)
|
||||||
|
throws OperationManagementException, DeviceManagementException;
|
||||||
|
|
||||||
|
Operation getOperation(String type, int operationId) throws OperationManagementException;
|
||||||
|
|
||||||
|
Operation getOperationByActivityId(String activity) throws OperationManagementException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,8 @@ import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
|||||||
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy;
|
||||||
|
import org.wso2.carbon.device.mgt.common.push.notification.PushNotificationConfig;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
|
||||||
@ -46,6 +48,8 @@ import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
|||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
|
||||||
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||||
|
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||||
import org.wso2.carbon.email.sender.core.ContentProviderInfo;
|
import org.wso2.carbon.email.sender.core.ContentProviderInfo;
|
||||||
import org.wso2.carbon.email.sender.core.EmailContext;
|
import org.wso2.carbon.email.sender.core.EmailContext;
|
||||||
@ -70,9 +74,11 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
private DeviceTypeDAO deviceTypeDAO;
|
private DeviceTypeDAO deviceTypeDAO;
|
||||||
private EnrollmentDAO enrollmentDAO;
|
private EnrollmentDAO enrollmentDAO;
|
||||||
private DeviceManagementPluginRepository pluginRepository;
|
private DeviceManagementPluginRepository pluginRepository;
|
||||||
|
private OperationManagerRepository operationManagerRepository;
|
||||||
|
|
||||||
public DeviceManagementProviderServiceImpl() {
|
public DeviceManagementProviderServiceImpl() {
|
||||||
this.pluginRepository = new DeviceManagementPluginRepository();
|
this.pluginRepository = new DeviceManagementPluginRepository();
|
||||||
|
this.operationManagerRepository = new OperationManagerRepository();
|
||||||
initDataAccessObjects();
|
initDataAccessObjects();
|
||||||
/* Registering a listener to retrieve events when some device management service plugin is installed after
|
/* Registering a listener to retrieve events when some device management service plugin is installed after
|
||||||
* the component is done getting initialized */
|
* the component is done getting initialized */
|
||||||
@ -88,7 +94,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public boolean saveConfiguration(TenantConfiguration configuration) throws DeviceManagementException {
|
public boolean saveConfiguration(TenantConfiguration configuration) throws DeviceManagementException {
|
||||||
DeviceManager dms =
|
DeviceManager dms =
|
||||||
this.getPluginRepository().getDeviceManagementService(configuration.getType(), this.getTenantId()).getDeviceManager();
|
pluginRepository.getDeviceManagementService(configuration.getType(),
|
||||||
|
this.getTenantId()).getDeviceManager();
|
||||||
return dms.saveConfiguration(configuration);
|
return dms.saveConfiguration(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +107,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
@Override
|
@Override
|
||||||
public TenantConfiguration getConfiguration(String deviceType) throws DeviceManagementException {
|
public TenantConfiguration getConfiguration(String deviceType) throws DeviceManagementException {
|
||||||
DeviceManager dms =
|
DeviceManager dms =
|
||||||
this.getPluginRepository().getDeviceManagementService(deviceType, this.getTenantId()).getDeviceManager();
|
pluginRepository.getDeviceManagementService(deviceType, this.getTenantId()).getDeviceManager();
|
||||||
if (dms == null) {
|
if (dms == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Device type '" + deviceType + "' does not have an associated device management " +
|
log.debug("Device type '" + deviceType + "' does not have an associated device management " +
|
||||||
@ -758,7 +765,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
for (DeviceIdentifier deviceId : deviceIds) {
|
for (DeviceIdentifier deviceId : deviceIds) {
|
||||||
DeviceManagementService dms =
|
DeviceManagementService dms =
|
||||||
getPluginRepository().getDeviceManagementService(deviceId.getType(), this.getTenantId());
|
pluginRepository.getDeviceManagementService(deviceId.getType(), this.getTenantId());
|
||||||
//TODO FIX THIS WITH PUSH NOTIFICATIONS
|
//TODO FIX THIS WITH PUSH NOTIFICATIONS
|
||||||
//dms.notifyOperationToDevices(operation, deviceIds);
|
//dms.notifyOperationToDevices(operation, deviceIds);
|
||||||
}
|
}
|
||||||
@ -808,12 +815,8 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DeviceManagementPluginRepository getPluginRepository() {
|
|
||||||
return pluginRepository;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int addOperation(Operation operation,
|
public int addOperation(String type, Operation operation,
|
||||||
List<DeviceIdentifier> devices) throws OperationManagementException {
|
List<DeviceIdentifier> devices) throws OperationManagementException {
|
||||||
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
|
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
|
||||||
}
|
}
|
||||||
@ -846,7 +849,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteOperation(int operationId) throws OperationManagementException {
|
public void deleteOperation(String type, int operationId) throws OperationManagementException {
|
||||||
DeviceManagementDataHolder.getInstance().getOperationManager().deleteOperation(operationId);
|
DeviceManagementDataHolder.getInstance().getOperationManager().deleteOperation(operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -866,7 +869,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation getOperation(int operationId) throws OperationManagementException {
|
public Operation getOperation(String type, int operationId) throws OperationManagementException {
|
||||||
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperation(operationId);
|
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperation(operationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,7 +913,6 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
devices.add(device);
|
devices.add(device);
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1147,6 +1149,17 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
public void registerDeviceManagementService(DeviceManagementService deviceManagementService) {
|
public void registerDeviceManagementService(DeviceManagementService deviceManagementService) {
|
||||||
try {
|
try {
|
||||||
pluginRepository.addDeviceManagementProvider(deviceManagementService);
|
pluginRepository.addDeviceManagementProvider(deviceManagementService);
|
||||||
|
PushNotificationConfig pushNoteConfig = deviceManagementService.getPushNotificationConfig();
|
||||||
|
if (pushNoteConfig != null) {
|
||||||
|
NotificationStrategy notificationStrategy =
|
||||||
|
DeviceManagementDataHolder.getInstance().getPushNotificationProviderRepository().getProvider(
|
||||||
|
pushNoteConfig.getType()).getNotificationStrategy(pushNoteConfig);
|
||||||
|
operationManagerRepository.addOperationManager(
|
||||||
|
deviceManagementService.getType(), new OperationManagerImpl(notificationStrategy));
|
||||||
|
} else {
|
||||||
|
operationManagerRepository.addOperationManager(
|
||||||
|
deviceManagementService.getType(), new OperationManagerImpl());
|
||||||
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
log.error("Error occurred while registering device management plugin '" +
|
log.error("Error occurred while registering device management plugin '" +
|
||||||
deviceManagementService.getType() + "'", e);
|
deviceManagementService.getType() + "'", e);
|
||||||
@ -1157,6 +1170,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
public void unregisterDeviceManagementService(DeviceManagementService deviceManagementService) {
|
public void unregisterDeviceManagementService(DeviceManagementService deviceManagementService) {
|
||||||
try {
|
try {
|
||||||
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
|
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
|
||||||
|
operationManagerRepository.removeOperationManager(deviceManagementService.getType());
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
log.error("Error occurred while un-registering device management plugin '" +
|
log.error("Error occurred while un-registering device management plugin '" +
|
||||||
deviceManagementService.getType() + "'", e);
|
deviceManagementService.getType() + "'", e);
|
||||||
@ -1230,7 +1244,7 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
|
|
||||||
private DeviceManager getDeviceManager(String deviceType) {
|
private DeviceManager getDeviceManager(String deviceType) {
|
||||||
DeviceManagementService deviceManagementService =
|
DeviceManagementService deviceManagementService =
|
||||||
this.getPluginRepository().getDeviceManagementService(deviceType, this.getTenantId());
|
pluginRepository.getDeviceManagementService(deviceType, this.getTenantId());
|
||||||
if (deviceManagementService == null) {
|
if (deviceManagementService == null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Device type '" + deviceType + "' does not have an associated device management " +
|
log.debug("Device type '" + deviceType + "' does not have an associated device management " +
|
||||||
|
|||||||
@ -95,7 +95,13 @@ public class DeviceTaskManagerImpl implements DeviceTaskManager {
|
|||||||
operation.setEnabled(true);
|
operation.setEnabled(true);
|
||||||
operation.setType(Operation.Type.COMMAND);
|
operation.setType(Operation.Type.COMMAND);
|
||||||
operation.setCode(str);
|
operation.setCode(str);
|
||||||
deviceManagementProviderService.addOperation(operation, DeviceManagerUtil.convertDevices(devices));
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (devices.size() > 0) {
|
||||||
|
type = devices.get(0).getType();
|
||||||
|
}
|
||||||
|
deviceManagementProviderService.addOperation(type, operation,
|
||||||
|
DeviceManagerUtil.convertDevices(devices));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
|
|||||||
@ -50,6 +50,10 @@
|
|||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.ws.commons.axiom</groupId>
|
<groupId>org.apache.ws.commons.axiom</groupId>
|
||||||
<artifactId>axiom-api</artifactId>
|
<artifactId>axiom-api</artifactId>
|
||||||
@ -91,8 +95,21 @@
|
|||||||
<artifactId>commons-lang</artifactId>
|
<artifactId>commons-lang</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.eclipse.paho</groupId>
|
||||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.json.wso2</groupId>
|
||||||
|
<artifactId>json</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
@ -96,7 +96,13 @@ public class PolicyManagerServiceImpl implements PolicyManagerService {
|
|||||||
}
|
}
|
||||||
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<DeviceIdentifier>();
|
List<DeviceIdentifier> deviceIdentifiers = new ArrayList<DeviceIdentifier>();
|
||||||
deviceIdentifiers.add(deviceIdentifier);
|
deviceIdentifiers.add(deviceIdentifier);
|
||||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(
|
|
||||||
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (deviceIdentifiers.size() > 0) {
|
||||||
|
type = deviceIdentifiers.get(0).getType();
|
||||||
|
}
|
||||||
|
PolicyManagementDataHolder.getInstance().getDeviceManagementService().addOperation(type,
|
||||||
PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers);
|
PolicyManagerUtil.transformPolicy(policy), deviceIdentifiers);
|
||||||
return policy;
|
return policy;
|
||||||
} catch (PolicyEvaluationException e) {
|
} catch (PolicyEvaluationException e) {
|
||||||
|
|||||||
@ -160,8 +160,14 @@ public class ComplianceDecisionPointImpl implements ComplianceDecisionPoint {
|
|||||||
}
|
}
|
||||||
policyOperation.setProfileOperations(profileOperationList);
|
policyOperation.setProfileOperations(profileOperationList);
|
||||||
policyOperation.setPayLoad(policyOperation.getProfileOperations());
|
policyOperation.setPayLoad(policyOperation.getProfileOperations());
|
||||||
|
|
||||||
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (deviceIdentifiers.size() > 0) {
|
||||||
|
type = deviceIdentifiers.get(0).getType();
|
||||||
|
}
|
||||||
PolicyManagementDataHolder.getInstance().getDeviceManagementService().
|
PolicyManagementDataHolder.getInstance().getDeviceManagementService().
|
||||||
addOperation(policyOperation, deviceIdentifiers);
|
addOperation(type, policyOperation, deviceIdentifiers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -402,8 +402,13 @@ public class MonitoringManagerImpl implements MonitoringManager {
|
|||||||
// appListOperation.setType(Operation.Type.COMMAND);
|
// appListOperation.setType(Operation.Type.COMMAND);
|
||||||
// appListOperation.setCode(OPERATION_APP_LIST);
|
// appListOperation.setCode(OPERATION_APP_LIST);
|
||||||
|
|
||||||
|
//TODO: Fix this properly later adding device type to be passed in when the task manage executes "addOperations()"
|
||||||
|
String type = null;
|
||||||
|
if (deviceIdentifiers.size() > 0) {
|
||||||
|
type = deviceIdentifiers.get(0).getType();
|
||||||
|
}
|
||||||
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
DeviceManagementProviderService service = new DeviceManagementProviderServiceImpl();
|
||||||
service.addOperation(monitoringOperation, deviceIdentifiers);
|
service.addOperation(type, monitoringOperation, deviceIdentifiers);
|
||||||
// service.addOperation(infoOperation, deviceIdentifiers);
|
// service.addOperation(infoOperation, deviceIdentifiers);
|
||||||
// service.addOperation(appListOperation, deviceIdentifiers);
|
// service.addOperation(appListOperation, deviceIdentifiers);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<name>WSO2 Carbon - GCM Based Push Notification Provider Feature</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>src/main/resources</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>build.properties</include>
|
||||||
|
<include>p2.inf</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.wso2.maven</groupId>
|
||||||
|
<artifactId>carbon-p2-plugin</artifactId>
|
||||||
|
<version>${carbon.p2.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>p2-feature-generation</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>p2-feature-gen</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm</id>
|
||||||
|
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||||
|
<adviceFile>
|
||||||
|
<properties>
|
||||||
|
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||||
|
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
|
||||||
|
</properties>
|
||||||
|
</adviceFile>
|
||||||
|
<bundles>
|
||||||
|
<bundleDef>
|
||||||
|
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm:${carbon.device.mgt.version}
|
||||||
|
</bundleDef>
|
||||||
|
</bundles>
|
||||||
|
<importFeatures>
|
||||||
|
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
|
||||||
|
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}</importFeatureDef>
|
||||||
|
</importFeatures>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
custom = true
|
||||||
@ -0,0 +1 @@
|
|||||||
|
instructions.configure = \
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<name>WSO2 Carbon - MQTT Based Push Notification Provider Feature</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
<description>WSO2 Carbon - MQTT Based Push Notification Provider Feature</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>src/main/resources</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>build.properties</include>
|
||||||
|
<include>p2.inf</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.wso2.maven</groupId>
|
||||||
|
<artifactId>carbon-p2-plugin</artifactId>
|
||||||
|
<version>${carbon.p2.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>p2-feature-generation</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>p2-feature-gen</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</id>
|
||||||
|
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||||
|
<adviceFile>
|
||||||
|
<properties>
|
||||||
|
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||||
|
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
|
||||||
|
</properties>
|
||||||
|
</adviceFile>
|
||||||
|
<bundles>
|
||||||
|
<bundleDef>
|
||||||
|
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt:${carbon.device.mgt.version}
|
||||||
|
</bundleDef>
|
||||||
|
</bundles>
|
||||||
|
<importFeatures>
|
||||||
|
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
|
||||||
|
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}</importFeatureDef>
|
||||||
|
</importFeatures>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
custom = true
|
||||||
@ -0,0 +1 @@
|
|||||||
|
instructions.configure = \
|
||||||
@ -0,0 +1,106 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<name>WSO2 Carbon - XMPP Based Push Notification Provider Feature</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
<description>WSO2 Carbon - XMPP Based Push Notification Provider Feature</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>src/main/resources</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>build.properties</include>
|
||||||
|
<include>p2.inf</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.wso2.maven</groupId>
|
||||||
|
<artifactId>carbon-p2-plugin</artifactId>
|
||||||
|
<version>${carbon.p2.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>p2-feature-generation</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>p2-feature-gen</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<id>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</id>
|
||||||
|
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||||
|
<adviceFile>
|
||||||
|
<properties>
|
||||||
|
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||||
|
<propertyDef>org.eclipse.equinox.p2.type.group:false</propertyDef>
|
||||||
|
</properties>
|
||||||
|
</adviceFile>
|
||||||
|
<bundles>
|
||||||
|
<bundleDef>
|
||||||
|
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp:${carbon.device.mgt.version}
|
||||||
|
</bundleDef>
|
||||||
|
</bundles>
|
||||||
|
<importFeatures>
|
||||||
|
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}</importFeatureDef>
|
||||||
|
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}</importFeatureDef>
|
||||||
|
</importFeatures>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1 @@
|
|||||||
|
custom = true
|
||||||
@ -0,0 +1 @@
|
|||||||
|
instructions.configure = \
|
||||||
41
features/device-mgt-extensions/pom.xml
Normal file
41
features/device-mgt-extensions/pom.xml
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
~
|
||||||
|
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
~ Version 2.0 (the "License"); you may not use this file except
|
||||||
|
~ in compliance with the License.
|
||||||
|
~ You may obtain a copy of the License at
|
||||||
|
~
|
||||||
|
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
~
|
||||||
|
~ Unless required by applicable law or agreed to in writing,
|
||||||
|
~ software distributed under the License is distributed on an
|
||||||
|
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
~ KIND, either express or implied. See the License for the
|
||||||
|
~ specific language governing permissions and limitations
|
||||||
|
~ under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>carbon-devicemgt</artifactId>
|
||||||
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
|
<relativePath>../../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>device-mgt-extensions-feature</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>WSO2 Carbon - Device Management Extensions Feature</name>
|
||||||
|
<url>http://wso2.org</url>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.feature</module>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.feature</module>
|
||||||
|
<module>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.feature</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -25,6 +25,10 @@
|
|||||||
</JndiLookupDefinition>
|
</JndiLookupDefinition>
|
||||||
</DataSourceConfiguration>
|
</DataSourceConfiguration>
|
||||||
</ManagementRepository>
|
</ManagementRepository>
|
||||||
|
<PushNotificationProviders>
|
||||||
|
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm.GCMBasedPushNotificationProvider</Provider>
|
||||||
|
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider>
|
||||||
|
</PushNotificationProviders>
|
||||||
<IdentityConfiguration>
|
<IdentityConfiguration>
|
||||||
<ServerUrl>https://localhost:9443</ServerUrl>
|
<ServerUrl>https://localhost:9443</ServerUrl>
|
||||||
<AdminUsername>admin</AdminUsername>
|
<AdminUsername>admin</AdminUsername>
|
||||||
|
|||||||
27
pom.xml
27
pom.xml
@ -17,7 +17,8 @@
|
|||||||
~ under the License.
|
~ under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
@ -36,6 +37,7 @@
|
|||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>components/device-mgt</module>
|
<module>components/device-mgt</module>
|
||||||
|
<module>components/device-mgt-extensions</module>
|
||||||
<module>components/apimgt-extensions</module>
|
<module>components/apimgt-extensions</module>
|
||||||
<module>components/policy-mgt</module>
|
<module>components/policy-mgt</module>
|
||||||
<module>components/certificate-mgt</module>
|
<module>components/certificate-mgt</module>
|
||||||
@ -51,6 +53,7 @@
|
|||||||
<module>features/oauth-extensions</module>
|
<module>features/oauth-extensions</module>
|
||||||
<module>features/email-sender</module>
|
<module>features/email-sender</module>
|
||||||
<module>features/jwt-client</module>
|
<module>features/jwt-client</module>
|
||||||
|
<module>features/device-mgt-extensions</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -1472,6 +1475,28 @@
|
|||||||
<artifactId>servlet-api</artifactId>
|
<artifactId>servlet-api</artifactId>
|
||||||
<version>${servlet-api.version}</version>
|
<version>${servlet-api.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.analytics-common</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.event.output.adapter.core</artifactId>
|
||||||
|
<version>${carbon.analytics.common.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.gcm</artifactId>
|
||||||
|
<version>${carbon.device.mgt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt</artifactId>
|
||||||
|
<version>${carbon.device.mgt.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp</artifactId>
|
||||||
|
<version>${carbon.device.mgt.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user