diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.cdmf.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.cdmf.analytics/pom.xml index a3c953d579..394084b9d1 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.cdmf.analytics/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.cdmf.analytics/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml index 202e187d0b..fcddbdb189 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/WSO2IoT-DeviceOperation-Publisher_1.0.0/WSO2IoT-DeviceOperation-Publisher_1.0.0.xml b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/WSO2IoT-DeviceOperation-Publisher_1.0.0/WSO2IoT-DeviceOperation-Publisher_1.0.0.xml index 326925a9b0..7d52806b57 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/WSO2IoT-DeviceOperation-Publisher_1.0.0/WSO2IoT-DeviceOperation-Publisher_1.0.0.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/WSO2IoT-DeviceOperation-Publisher_1.0.0/WSO2IoT-DeviceOperation-Publisher_1.0.0.xml @@ -19,24 +19,24 @@ - + { - "deviceIdentifiers": [ - {{meta_deviceIdentifier}} - ], + "deviceIdentifiers": {{meta_deviceIdentifiers}}, + "deviceType": "{{meta_deviceType}}", "operation": { - "code": {{code}}, - "type": {{type}}, + "code": "{{code}}", + "type": "{{type}}", "status": "PENDING", - "isEnabled": {{isEnabled}}, - "payLoad": {{payLoad}} + "isEnabled": "{{isEnabled}}", + "payLoad": "{{payLoad}}" } } HttpPost - https://localhost:9443/api/device-mgt/v1.0/devices/android/operations + https://localhost:9443/api/device-mgt/v1.0/devices/{deviceType}/operations + true - \ No newline at end of file + diff --git a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/org.wso2.iot.operation_1.0.0/org.wso2.iot.operation_1.0.0.json b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/org.wso2.iot.operation_1.0.0/org.wso2.iot.operation_1.0.0.json index 44a0b0a453..c5786c0daa 100755 --- a/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/org.wso2.iot.operation_1.0.0/org.wso2.iot.operation_1.0.0.json +++ b/components/analytics/iot-analytics/org.wso2.carbon.device.mgt.iot.analytics/src/main/resources/carbonapps/device_analytics/org.wso2.iot.operation_1.0.0/org.wso2.iot.operation_1.0.0.json @@ -1,11 +1,15 @@ { "name": "org.wso2.iot.operation", "version": "1.0.0", - "nickName": "", + "nickName": "Operation Stream", "description": "Operation stream for WSO2 IoT Devices", "metaData": [ { - "name": "deviceIdentifier", + "name": "deviceIdentifiers", + "type": "STRING" + }, + { + "name": "deviceType", "type": "STRING" } ], diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml index 9f415c4ee3..1da109c0b5 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.device.statistics.dashboard/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml index 1eb83c7a90..f390564b2e 100644 --- a/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml +++ b/components/analytics/iot-analytics/org.wso2.carbon.iot.geo.dashboard/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins iot-analytics - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/analytics/iot-analytics/pom.xml b/components/analytics/iot-analytics/pom.xml index eb97bbab88..2d6991ee43 100644 --- a/components/analytics/iot-analytics/pom.xml +++ b/components/analytics/iot-analytics/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins analytics - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/analytics/pom.xml b/components/analytics/pom.xml index d3a2fd8394..1ec113d0e5 100644 --- a/components/analytics/pom.xml +++ b/components/analytics/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java index 5354cc1ae6..bf532d00b2 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/RegisterActivity.java @@ -43,7 +43,6 @@ import org.wso2.carbon.iot.android.sense.util.dto.RegisterInfo; import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R; - /** * A login screen that offers to register the device. */ @@ -159,7 +158,6 @@ public class RegisterActivity extends Activity { startActivity(intent); } }); - } mUiHandler.post(new Runnable() { @Override @@ -167,11 +165,9 @@ public class RegisterActivity extends Activity { showProgress(false); } }); - } }); myThread.start(); - } } @@ -208,6 +204,4 @@ public class RegisterActivity extends Activity { deviceRegisterButton.setVisibility(show? View.VISIBLE : View.GONE); } } - } - diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java index 4ece0fe950..de4c14b3c0 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherReceiver.java @@ -34,5 +34,4 @@ public class DataPublisherReceiver extends BroadcastReceiver { PendingIntent pending = PendingIntent.getService(context, 0, i, 0); service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), ALARM_INTERVAL, pending); } - } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java index ecff96371b..09f254ddb5 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/DataPublisherService.java @@ -20,7 +20,6 @@ import android.hardware.Sensor; import android.os.IBinder; import android.support.annotation.Nullable; import android.util.Log; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; @@ -29,17 +28,17 @@ import org.wso2.carbon.iot.android.sense.constants.SenseConstants; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.AndroidSenseMQTTHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.TransportHandlerException; -import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData; -import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; -import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData; import org.wso2.carbon.iot.android.sense.event.streams.activity.ActivityData; import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; import org.wso2.carbon.iot.android.sense.event.streams.audio.AudioData; import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; import org.wso2.carbon.iot.android.sense.event.streams.call.CallData; import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData; +import org.wso2.carbon.iot.android.sense.event.streams.location.LocationData; import org.wso2.carbon.iot.android.sense.event.streams.screen.ScreenData; +import org.wso2.carbon.iot.android.sense.event.streams.sensor.SensorData; import org.wso2.carbon.iot.android.sense.event.streams.sms.SmsData; +import org.wso2.carbon.iot.android.sense.event.streams.speed.SpeedData; import org.wso2.carbon.iot.android.sense.speech.detector.util.ProcessWords; import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData; import org.wso2.carbon.iot.android.sense.util.LocalRegistry; @@ -65,257 +64,250 @@ public class DataPublisherService extends Service { public int onStartCommand(Intent intent, int flags, int startId) { context = this; Log.d(TAG, "service started"); -// Runnable runnable = new Runnable() { -// @Override -// public void run() { - try { - List events = new ArrayList<>(); - //retrieve sensor data. - List sensorDataMap = SenseDataHolder.getSensorDataHolder(); - if (!sensorDataMap.isEmpty()) { - for (SensorData sensorData : sensorDataMap) { - Event event = new Event(); - event.setTimestamp(sensorData.getTimestamp()); - switch (sensorData.getSensorType()) { - case Sensor.TYPE_ACCELEROMETER: - event.setAccelerometer(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_MAGNETIC_FIELD: - event.setMagnetic(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_GYROSCOPE: - event.setGyroscope(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_LIGHT: - event.setLight(sensorData.getSensorValues()[0]); - break; - case Sensor.TYPE_PRESSURE: - event.setPressure(sensorData.getSensorValues()[0]); - events.add(event); - break; - case Sensor.TYPE_PROXIMITY: - event.setProximity(sensorData.getSensorValues()[0]); - events.add(event); - break; - case Sensor.TYPE_GRAVITY: - event.setGravity(sensorData.getSensorValues()); - events.add(event); - break; - case Sensor.TYPE_GAME_ROTATION_VECTOR: - event.setRotation(sensorData.getSensorValues()); - events.add(event); - break; - } - } - } - SenseDataHolder.resetSensorDataHolder(); - - //retrieve battery data. - List batteryDataMap = SenseDataHolder.getBatteryDataHolder(); - if (!batteryDataMap.isEmpty()) { - for (BatteryData batteryData : batteryDataMap) { - Event event = new Event(); - event.setTimestamp(batteryData.getTimestamp()); - event.setBattery(batteryData.getLevel()); - event.setBatteryTemperature(batteryData.getTemperature()); - event.setBatteryStatus(batteryData.getStatus()); - event.setBatteryState(batteryData.getState().toString()); + try { + List events = new ArrayList<>(); + //retrieve sensor data. + List sensorDataMap = SenseDataHolder.getSensorDataHolder(); + if (!sensorDataMap.isEmpty()) { + for (SensorData sensorData : sensorDataMap) { + Event event = new Event(); + event.setTimestamp(sensorData.getTimestamp()); + switch (sensorData.getSensorType()) { + case Sensor.TYPE_ACCELEROMETER: + event.setAccelerometer(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_MAGNETIC_FIELD: + event.setMagnetic(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_GYROSCOPE: + event.setGyroscope(sensorData.getSensorValues()); + events.add(event); + break; + case Sensor.TYPE_LIGHT: + event.setLight(sensorData.getSensorValues()[0]); + break; + case Sensor.TYPE_PRESSURE: + event.setPressure(sensorData.getSensorValues()[0]); + events.add(event); + break; + case Sensor.TYPE_PROXIMITY: + event.setProximity(sensorData.getSensorValues()[0]); + events.add(event); + break; + case Sensor.TYPE_GRAVITY: + event.setGravity(sensorData.getSensorValues()); events.add(event); - } + break; + case Sensor.TYPE_GAME_ROTATION_VECTOR: + event.setRotation(sensorData.getSensorValues()); + events.add(event); + break; } - SenseDataHolder.resetBatteryDataHolder(); + } + } + SenseDataHolder.resetSensorDataHolder(); - //retrieve location data. - List locationDataMap = SenseDataHolder.getLocationDataHolder(); + //retrieve battery data. + List batteryDataMap = SenseDataHolder.getBatteryDataHolder(); + if (!batteryDataMap.isEmpty()) { + for (BatteryData batteryData : batteryDataMap) { + Event event = new Event(); + event.setTimestamp(batteryData.getTimestamp()); + event.setBattery(batteryData.getLevel()); + event.setBatteryTemperature(batteryData.getTemperature()); + event.setBatteryStatus(batteryData.getStatus()); + event.setBatteryState(batteryData.getState().toString()); + events.add(event); + } + } + SenseDataHolder.resetBatteryDataHolder(); - if (!locationDataMap.isEmpty()) { - for (LocationData locationData : locationDataMap) { - Event event = new Event(); - event.setTimestamp(locationData.getTimeStamp()); - event.setGps(new double[]{locationData.getLatitude(), locationData.getLongitude()}); - events.add(event); - } - } - SenseDataHolder.resetLocationDataHolder(); + //retrieve location data. + List locationDataMap = SenseDataHolder.getLocationDataHolder(); - //retrieve speed data. - List speedDataMap = SenseDataHolder.getSpeedDataHolder(); - if (!speedDataMap.isEmpty()) { - for (SpeedData speedData : speedDataMap) { - Event event = new Event(); - event.setTimestamp(speedData.getTimeStamp()); - event.setTurns(speedData.getTurns()); - event.setSpeed(speedData.getSpeed()); + if (!locationDataMap.isEmpty()) { + for (LocationData locationData : locationDataMap) { + Event event = new Event(); + event.setTimestamp(locationData.getTimeStamp()); + event.setGps(new double[]{locationData.getLatitude(), locationData.getLongitude()}); + events.add(event); + } + } + SenseDataHolder.resetLocationDataHolder(); - events.add(event); - } - } - SenseDataHolder.resetSpeedDataHolder(); + //retrieve speed data. + List speedDataMap = SenseDataHolder.getSpeedDataHolder(); + if (!speedDataMap.isEmpty()) { + for (SpeedData speedData : speedDataMap) { + Event event = new Event(); + event.setTimestamp(speedData.getTimeStamp()); + event.setTurns(speedData.getTurns()); + event.setSpeed(speedData.getSpeed()); - //retrieve speed data. - List beaconDataMap = SenseDataHolder.getBeaconScanedDataHolder(); - if (!speedDataMap.isEmpty()) { - for (BeaconScanedData beaconData : beaconDataMap) { - Event event = new Event(); - event.setBeaconMajor(beaconData.getBeaconMajor()); - event.setBeaconMinor(beaconData.getBeaconMinor()); - event.setBeaconProximity(beaconData.getBeaconProximity()); - event.setBeaconUuid(beaconData.getBeaconUuid()); + events.add(event); + } + } + SenseDataHolder.resetSpeedDataHolder(); - events.add(event); - } - } - SenseDataHolder.resetSpeedDataHolder(); + //retrieve speed data. + List beaconDataMap = SenseDataHolder.getBeaconScanedDataHolder(); + if (!speedDataMap.isEmpty()) { + for (BeaconScanedData beaconData : beaconDataMap) { + Event event = new Event(); + event.setBeaconMajor(beaconData.getBeaconMajor()); + event.setBeaconMinor(beaconData.getBeaconMinor()); + event.setBeaconProximity(beaconData.getBeaconProximity()); + event.setBeaconUuid(beaconData.getBeaconUuid()); - //retrieve words - ProcessWords.cleanAndPushToWordMap(); - List wordDatMap = SenseDataHolder.getWordDataHolder(); - for (WordData wordData : wordDatMap) { - if (wordData.getOccurences() == 0) { - continue; - } - for (int i = 0; i < wordData.getOccurences(); i++) { - Event event = new Event(); - event.setTimestamp(wordData.getTimestamp()); - event.setWord(wordData.getWord()); - String word = wordData.getWord(); - String status = word; - if ((!word.equals(SenseConstants.EVENT_LISTENER_STARTED)) && (!word.equals(SenseConstants - .EVENT_LISTENER_FINISHED))) { - status = SenseConstants.EVENT_LISTENER_ONGOING; - } - event.setWordStatus(status); - events.add(event); - } + events.add(event); + } + } + SenseDataHolder.resetSpeedDataHolder(); + + //retrieve words + ProcessWords.cleanAndPushToWordMap(); + List wordDatMap = SenseDataHolder.getWordDataHolder(); + for (WordData wordData : wordDatMap) { + if (wordData.getOccurences() == 0) { + continue; + } + for (int i = 0; i < wordData.getOccurences(); i++) { + Event event = new Event(); + event.setTimestamp(wordData.getTimestamp()); + event.setWord(wordData.getWord()); + String word = wordData.getWord(); + String status = word; + if ((!word.equals(SenseConstants.EVENT_LISTENER_STARTED)) && (!word.equals(SenseConstants + .EVENT_LISTENER_FINISHED))) { + status = SenseConstants.EVENT_LISTENER_ONGOING; } - SenseDataHolder.resetWordDataHolder(); + event.setWordStatus(status); + events.add(event); + } + } + SenseDataHolder.resetWordDataHolder(); - // retrieve call data. - List callDataList = SenseDataHolder.getCallDataHolder(); - if (!callDataList.isEmpty()) { - for (CallData callData : callDataList) { - Event event = new Event(); - event.setCallNumber(callData.getPhoneNumber()); - event.setCallType(callData.getType().toString().toLowerCase()); - event.setCallStartTime(callData.getStartTime()); - event.setCallEndTime(callData.getEndTime()); - event.setTimestamp(callData.getStartTime()); + // retrieve call data. + List callDataList = SenseDataHolder.getCallDataHolder(); + if (!callDataList.isEmpty()) { + for (CallData callData : callDataList) { + Event event = new Event(); + event.setCallNumber(callData.getPhoneNumber()); + event.setCallType(callData.getType().toString().toLowerCase()); + event.setCallStartTime(callData.getStartTime()); + event.setCallEndTime(callData.getEndTime()); + event.setTimestamp(callData.getStartTime()); - events.add(event); - } - } - SenseDataHolder.resetCallDataHolder(); + events.add(event); + } + } + SenseDataHolder.resetCallDataHolder(); - // retrieve screen data. - List screenDataList = SenseDataHolder.getScreenDataHolder(); - if (!screenDataList.isEmpty()) { - for (ScreenData screenData : screenDataList) { - Event event = new Event(); - event.setScreenState(screenData.getAction()); - event.setTimestamp(screenData.getTimestamp()); + // retrieve screen data. + List screenDataList = SenseDataHolder.getScreenDataHolder(); + if (!screenDataList.isEmpty()) { + for (ScreenData screenData : screenDataList) { + Event event = new Event(); + event.setScreenState(screenData.getAction()); + event.setTimestamp(screenData.getTimestamp()); - events.add(event); - } - } - SenseDataHolder.resetScreenDataHolder(); + events.add(event); + } + } + SenseDataHolder.resetScreenDataHolder(); - // retrieve audio data. - List audioDataList = SenseDataHolder.getAudioDataHolder(); - if (!audioDataList.isEmpty()) { - for (AudioData audioData : audioDataList) { - Event event = new Event(); - event.setTimestamp(audioData.getTimestamp()); - event.setAudioPlaying(audioData.isPlaying()); - event.setHeadsetOn(audioData.isHeadsetOn()); - event.setMusicVolume(audioData.getMusicVolume()); - events.add(event); - } - } - SenseDataHolder.resetAudioDataHolder(); + // retrieve audio data. + List audioDataList = SenseDataHolder.getAudioDataHolder(); + if (!audioDataList.isEmpty()) { + for (AudioData audioData : audioDataList) { + Event event = new Event(); + event.setTimestamp(audioData.getTimestamp()); + event.setAudioPlaying(audioData.isPlaying()); + event.setHeadsetOn(audioData.isHeadsetOn()); + event.setMusicVolume(audioData.getMusicVolume()); + events.add(event); + } + } + SenseDataHolder.resetAudioDataHolder(); - // retrieve activity data. - List activityDataList = SenseDataHolder.getActivityDataHolder(); - if (!activityDataList.isEmpty()) { - for (ActivityData activityData : activityDataList) { - Event event = new Event(); - event.setTimestamp(activityData.getTimestamp()); - event.setActivityType(activityData.getActivity()); - event.setConfidence(activityData.getConfidence()); - events.add(event); - } - } - SenseDataHolder.resetActivityDataHolder(); + // retrieve activity data. + List activityDataList = SenseDataHolder.getActivityDataHolder(); + if (!activityDataList.isEmpty()) { + for (ActivityData activityData : activityDataList) { + Event event = new Event(); + event.setTimestamp(activityData.getTimestamp()); + event.setActivityType(activityData.getActivity()); + event.setConfidence(activityData.getConfidence()); + events.add(event); + } + } + SenseDataHolder.resetActivityDataHolder(); - // retrieve sms data. - List smsDataList = SenseDataHolder.getSmsDataHolder(); - if (!smsDataList.isEmpty()) { - for (SmsData smsData : smsDataList) { - Event event = new Event(); - event.setTimestamp(smsData.getTimestamp()); - event.setSmsNumber(smsData.getPhoneNumber()); - events.add(event); - } - } - SenseDataHolder.resetSmsDataHolder(); + // retrieve sms data. + List smsDataList = SenseDataHolder.getSmsDataHolder(); + if (!smsDataList.isEmpty()) { + for (SmsData smsData : smsDataList) { + Event event = new Event(); + event.setTimestamp(smsData.getTimestamp()); + event.setSmsNumber(smsData.getPhoneNumber()); + events.add(event); + } + } + SenseDataHolder.resetSmsDataHolder(); - // retrieve application data. - List appDataList = SenseDataHolder.getApplicationDataHolder(); - if (!appDataList.isEmpty()) { - for (ApplicationData appData : appDataList) { - Event event = new Event(); - event.setTimestamp(appData.getTimestamp()); - event.setPackageName(appData.getPackageName()); - event.setAction(appData.getAction().toString()); - events.add(event); - } - } - SenseDataHolder.resetApplicationDataHolder(); + // retrieve application data. + List appDataList = SenseDataHolder.getApplicationDataHolder(); + if (!appDataList.isEmpty()) { + for (ApplicationData appData : appDataList) { + Event event = new Event(); + event.setTimestamp(appData.getTimestamp()); + event.setPackageName(appData.getPackageName()); + event.setAction(appData.getAction().toString()); + events.add(event); + } + } + SenseDataHolder.resetApplicationDataHolder(); - //Retrieve network data - List networkDataList = SenseDataHolder.getNetworkDataHolder(); - if (!networkDataList.isEmpty()) { - for (NetworkData networkData : networkDataList) { - Event event = new Event(); - event.setTimestamp(networkData.getTimeStamp()); - event.setDataType(networkData.getDataType()); - event.setDataReceived(networkData.getDataReceived()); - event.setDataSent(networkData.getDataSent()); - events.add(event); - } - } - SenseDataHolder.resetNetworkDataHolder(); + //Retrieve network data + List networkDataList = SenseDataHolder.getNetworkDataHolder(); + if (!networkDataList.isEmpty()) { + for (NetworkData networkData : networkDataList) { + Event event = new Event(); + event.setTimestamp(networkData.getTimeStamp()); + event.setDataType(networkData.getDataType()); + event.setDataReceived(networkData.getDataReceived()); + event.setDataSent(networkData.getDataSent()); + events.add(event); + } + } + SenseDataHolder.resetNetworkDataHolder(); - //publish the data - if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { - String user = LocalRegistry.getUsername(context); - String deviceId = LocalRegistry.getDeviceId(context); - JSONArray jsonArray = new JSONArray(); - for (Event event : events) { - event.setOwner(user); - event.setDeviceId(deviceId); - jsonArray.put(new JSONObject().put("event", event.getEvent())); - } + //publish the data + if (events.size() > 0 && LocalRegistry.isEnrolled(context)) { + String user = LocalRegistry.getUsername(context); + String deviceId = LocalRegistry.getDeviceId(context); + JSONArray jsonArray = new JSONArray(); + for (Event event : events) { + event.setOwner(user); + event.setDeviceId(deviceId); + jsonArray.put(new JSONObject().put("event", event.getEvent())); + } - MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); - if (!mqttTransportHandler.isConnected()) { - mqttTransportHandler.connect(); - } - String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants.DEVICE_TYPE + "/" + deviceId + "/data"; - mqttTransportHandler.publishDeviceData(user, deviceId, jsonArray.toString(), topic); - } - } catch (JSONException e) { - Log.e(TAG, "Json Data Parsing Exception", e); - } catch (TransportHandlerException e) { - Log.e(TAG, "Data Publish Failed", e); + MQTTTransportHandler mqttTransportHandler = AndroidSenseMQTTHandler.getInstance(context); + if (!mqttTransportHandler.isConnected()) { + mqttTransportHandler.connect(); } -// } -// }; -// Thread dataUploaderThread = new Thread(runnable); -// dataUploaderThread.start(); + String topic = LocalRegistry.getTenantDomain(context) + "/" + SenseConstants.DEVICE_TYPE + "/" + deviceId + "/data"; + mqttTransportHandler.publishDeviceData(user, deviceId, jsonArray.toString(), topic); + } + } catch (JSONException e) { + Log.e(TAG, "Json Data Parsing Exception", e); + } catch (TransportHandlerException e) { + Log.e(TAG, "Data Publish Failed", e); + } return Service.START_NOT_STICKY; } } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java index 62a3659761..cfce21dd97 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/Event.java @@ -552,5 +552,4 @@ public class Event { return jsonEvent; } - } \ No newline at end of file diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java index 5d607546fe..10f32a8ad6 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/data/publisher/mqtt/AndroidSenseMQTTHandler.java @@ -236,6 +236,5 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler { public void processIncomingMessage(MqttMessage message) throws TransportHandlerException { } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java index 4b76b5cca2..4e41343585 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseScheduleReceiver.java @@ -38,5 +38,4 @@ public class SenseScheduleReceiver extends BroadcastReceiver { cal.add(Calendar.SECOND, 10); service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), ALARM_INTERVAL, pending); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java index 7554f65244..3ad384e754 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/SenseService.java @@ -59,7 +59,6 @@ public class SenseService extends Service { SenseDataReceiverManager.registerNetworkDataReader(this); //service will not be stopped until we manually stop the service return Service.START_NOT_STICKY; - } @Override @@ -75,4 +74,4 @@ public class SenseService extends Service { SenseWakeLock.releaseCPUWakeLock(); super.onDestroy(); } -} \ No newline at end of file +} diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java index 541be98b45..885bd5c9b1 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/data/NetworkDataReader.java @@ -25,7 +25,6 @@ import android.net.TrafficStats; import android.os.AsyncTask; import android.os.Handler; import android.util.Log; - import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import java.util.Date; diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java index 0ddc42236d..b72754f44e 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/event/streams/sensor/SensorDataReader.java @@ -56,7 +56,6 @@ public class SensorDataReader extends DataReader implements SensorEventListener for (Sensor sensor : sensorList) { mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); } - } private void collectSensorData() { @@ -112,5 +111,4 @@ public class SensorDataReader extends DataReader implements SensorEventListener } } } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java index fd7bf2ae9e..41b661ec60 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/ActivitySelectSensor.java @@ -73,7 +73,6 @@ public class ActivitySelectSensor extends AppCompatActivity private ListView listView; private SensorManager sensorManager; private ArrayList sensors = new ArrayList<>(); -// private EditText sessionIdText; private RealTimeSensorReader sensorReader = null; private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver(); private SupportedSensors supportedSensors = SupportedSensors.getInstance(); @@ -87,22 +86,10 @@ public class ActivitySelectSensor extends AppCompatActivity Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); - //sessionIdText = (EditText) findViewById(R.id.sessionId); -// sessionIdText.setCursorVisible(false); - listView = (ListView) findViewById(R.id.senseListContainer); - //verifyBluetooth(); registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap")); -// sessionIdText.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// sessionIdText.setCursorVisible(true); -// -// } -// }); - //Publish data FloatingActionButton fbtnPublishData = (FloatingActionButton) findViewById(R.id.publish); @@ -126,35 +113,6 @@ public class ActivitySelectSensor extends AppCompatActivity } }); - //FloatingActionButton fbtnSpeechRecongnizer = (FloatingActionButton) findViewById(R.id.speech); -// fbtnSpeechRecongnizer.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// String sessionId = sessionIdText.getText().toString(); -// if (!sessionId.isEmpty()) { -// Intent intent = new Intent(getApplicationContext(), WordRecognitionActivity.class); -// intent.putExtra("sessionId", sessionId); -// startActivity(intent); -// } else { -// Toast.makeText(ActivitySelectSensor.this, "Please type a session id value", Toast.LENGTH_SHORT) -// .show(); -// } -// -// } -// }); - -// FloatingActionButton fbtnBeaconMonitor = (FloatingActionButton) findViewById(R.id.beacon); -// fbtnBeaconMonitor.setOnClickListener(new View.OnClickListener() { -// @Override -// public void onClick(View v) { -// Intent intent = new Intent(getApplicationContext(), BeaconMonitoringActivity.class); -// startActivity(intent); -// -// -// } -// }); - - sharedPreferences = getSharedPreferences(SupportedSensors.SELECTED_SENSORS, 0); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); @@ -223,7 +181,6 @@ public class ActivitySelectSensor extends AppCompatActivity finish(); return true; } - return super.onOptionsItemSelected(item); } @@ -272,7 +229,6 @@ public class ActivitySelectSensor extends AppCompatActivity realTimeSensorChangeReceiver.updateOnChange(adaptor1); listView.setAdapter(adaptor1); - } public void update() { @@ -305,51 +261,10 @@ public class ActivitySelectSensor extends AppCompatActivity } } - /** * This method unregisters the real-time broadcast receiver. */ public void unregisterReceivers() { unregisterReceiver(realTimeSensorChangeReceiver); } - -// private void verifyBluetooth() { -// -// try { -// if (!BeaconManager.getInstanceForApplication(this).checkAvailability()) { -// final AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("Bluetooth not enabled"); -// builder.setMessage("Please enable bluetooth in settings and restart this application."); -// builder.setPositiveButton(android.R.string.ok, null); -// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { -// -// @Override -// public void onDismiss(DialogInterface dialog) { -// finish(); -// System.exit(0); -// } -// -// }); -// builder.show(); -// -// } -// } catch (RuntimeException e) { -// final AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("Bluetooth LE not available"); -// builder.setMessage("Sorry, this device does not support Bluetooth LE."); -// builder.setPositiveButton(android.R.string.ok, null); -// builder.setOnDismissListener(new DialogInterface.OnDismissListener() { -// -// @Override -// public void onDismiss(DialogInterface dialog) { -// finish(); -// System.exit(0); -// } -// -// }); -// builder.show(); -// -// } -// -// } } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java index 2e53438347..dd5a9f86a0 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/datastore/TempStore.java @@ -33,5 +33,4 @@ public class TempStore { * Array List which is used to populate the List view. */ public static ArrayList sensorArrayList = new ArrayList<>(); - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java index c231ac87ee..3413f4e433 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/RealTimeSensorChangeReceiver.java @@ -37,5 +37,4 @@ public class RealTimeSensorChangeReceiver extends BroadcastReceiver { TempStore.sensorArrayList.clear(); TempStore.sensorArrayList.addAll(TempStore.sensorDataMap.values()); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java index 6504e65ab4..441b251954 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/event/realtimesensor/RealTimeSensorReader.java @@ -58,5 +58,4 @@ public class RealTimeSensorReader implements SensorEventListener { @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java index 726c8cded2..e8cdfc8082 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/AvailableSensorsInDevice.java @@ -60,6 +60,4 @@ public class AvailableSensorsInDevice { editor.putStringSet(SupportedSensors.GET_AVAILABLE_SENSORS, sensorSet); editor.apply(); } - - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java index 2b0f5351be..d5113eb334 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/sensorlisting/SupportedSensors.java @@ -119,5 +119,4 @@ public class SupportedSensors { public String getType(int type) { return typeSensorMap.get(type); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java index 77f3f710c7..c526ab36b8 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/adaptor/SensorViewAdaptor.java @@ -83,7 +83,6 @@ public class SensorViewAdaptor extends BaseAdapter { holder.valuesZ.setText(data.getValueZ()); return view; - } private class ViewHolder { diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java index 5c163c8021..f04463353d 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.agent/app/src/main/java/org/wso2/carbon/iot/android/sense/realtimeviewer/view/sensor/selector/SelectSensorDialog.java @@ -36,7 +36,6 @@ import java.util.Set; * Get the user selections * Put them in to shared preferences */ - public class SelectSensorDialog extends DialogFragment { protected boolean[] selections = new boolean[SupportedSensors.SUPPORTED_SENSOR_COUNT]; @@ -79,7 +78,6 @@ public class SelectSensorDialog extends DialogFragment { Log.d("Click", "Ok"); //call sensorDataMap reading class sensorListListener.onDialogPositiveClick(SelectSensorDialog.this); - } }); @@ -96,7 +94,6 @@ public class SelectSensorDialog extends DialogFragment { } } }); - return builder.create(); } @@ -143,5 +140,4 @@ public class SelectSensorDialog extends DialogFragment { public interface SensorListListener { void onDialogPositiveClick(SelectSensorDialog dialog); } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml index 1d0ded0011..608b063fae 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/pom.xml @@ -21,7 +21,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml index f092a81dfc..d0e97eb7f5 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_accelerometer_stats_event_sink/iot_per_device_stream_android_accelerometer_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml index cb58d51c76..2df0ad03f7 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_script/AndroidActivityScript.xml @@ -1,4 +1,21 @@ + true AndroidActivityScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml index 5536405ef1..01d32787d6 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_activity_stats_event_sink/iot_per_device_stream_android_activity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml index d8ed723b30..d9be6dc159 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_audio_script/AndroidAudioScript.xml @@ -1,4 +1,21 @@ + true AndroidAudioScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml index 525d31c23a..76f3cd36ba 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_script/AndroidBatteryScript.xml @@ -1,4 +1,21 @@ + true AndroidBatteryScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml index 6a7d67d51c..00d4d1ce1f 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_battery_stats_event_sink/iot_per_device_stream_android_battery_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml index 422c8b864d..b939e8d261 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_script/AndroidCallScript.xml @@ -1,4 +1,21 @@ + true AndroidCallScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml index 7cf8dbb145..5a0c24e21e 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_call_stats_event_sink/iot_per_device_stream_android_call_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml index 7184778187..c4726c0ad9 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_script/AndroidDataScript.xml @@ -1,4 +1,21 @@ + true AndroidDataScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml index b2f5bf4d8d..71c3bbdd99 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_data_stats_event_sink/iot_per_device_stream_android_data_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml index a2fb1a3acf..4a767d1153 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_device_details_event_sink/iot_per_device_stream_android_device_details.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml index a686c52d97..21101d99fe 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_frequentcontacts_script/AndroidFrequentContactsScript.xml @@ -1,4 +1,21 @@ + true AndroidFrequentContactsScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml index 00a70f9fbc..f390c4f724 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gravity_stats_event_sink/iot_per_device_stream_android_gravity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml index a958cd10d5..170534b059 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_gyroscope_stats_event_sink/iot_per_device_stream_android_gyroscope_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml index 08acc1d8b1..2359881743 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_script/HeadsetScript.xml @@ -1,4 +1,21 @@ + true HeadsetScript diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml index d24d7b007b..a6a1fb84f5 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_headset_stats_event_sink/iot_per_device_stream_android_headset_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml index 2239d4b9ad..19441b9a4c 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_light_stats_event_sink/iot_per_device_stream_android_light_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml index 703d077251..888f151cd7 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_event_sink/iot_per_device_stream_android_location.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml index 8e63f319d7..9fa3c9a86c 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_location_stats_event_sink/iot_per_device_stream_android_location_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml index ac71c9df91..36bb991d8a 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_magnetic_stats_event_sink/iot_per_device_stream_android_magnetic_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml index 7cac9fff16..1b152c620a 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_pressure_stats_event_sink/iot_per_device_stream_android_pressure_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml index 17701ac0b5..b6501a60ec 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_proximity_stats_event_sink/iot_per_device_stream_android_proximity_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml index e8fec6a963..41ffd86c67 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_rotation_stats_event_sink/iot_per_device_stream_android_rotation_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml index d9e5d45a24..4ad1912b64 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_screen_stats_event_sink/iot_per_device_stream_android_screen_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml index 66d87162e9..685b95b3d8 100755 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.analytics/src/main/resources/carbonapps/androidsense/android_sms_stats_event_sink/iot_per_device_stream_android_sms_stats.xml @@ -1,4 +1,21 @@ + diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml index a81bfbb6f0..0cf22adb75 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/pom.xml @@ -3,7 +3,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java index 4cb0ccc9e3..b29458e95f 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.api/src/main/java/org/wso2/carbon/device/mgt/iot/androidsense/service/impl/listener/AndroidSensePermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class AndroidSensePermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(AndroidSensePermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class AndroidSensePermissionUpdateListener implements ServletContextListe getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME, AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Android Sense.", e); } } @@ -57,57 +61,44 @@ public class AndroidSensePermissionUpdateListener implements ServletContextListe } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml index d3358c14cc..8d06512800 100644 --- a/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml +++ b/components/device-types/androidsense-plugin/org.wso2.carbon.device.mgt.iot.androidsense.ui/pom.xml @@ -22,7 +22,7 @@ androidsense-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/androidsense-plugin/pom.xml b/components/device-types/androidsense-plugin/pom.xml index f2b9327a6e..0b5dd86d73 100644 --- a/components/device-types/androidsense-plugin/pom.xml +++ b/components/device-types/androidsense-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml index f4d2be2565..7772faafa7 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.analytics/pom.xml @@ -21,7 +21,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml index 621bdad3c1..f78737feca 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/pom.xml @@ -21,7 +21,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java index 353cdde5d4..d06a7dda9c 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/listener/ArduinoPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class ArduinoPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(ArduinoPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class ArduinoPermissionUpdateListener implements ServletContextListener { getAuthorizationManager().authorizeRole(ArduinoConstants.ROLE_NAME, ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Arduino.", e); } } @@ -57,57 +61,44 @@ public class ArduinoPermissionUpdateListener implements ServletContextListener { } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml index 51294bb51f..73066bbebc 100644 --- a/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml +++ b/components/device-types/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.ui/pom.xml @@ -23,7 +23,7 @@ arduino-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/arduino-plugin/pom.xml b/components/device-types/arduino-plugin/pom.xml index 0a5c5a257f..040e5d34aa 100644 --- a/components/device-types/arduino-plugin/pom.xml +++ b/components/device-types/arduino-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/pom.xml b/components/device-types/pom.xml index 70c2e98bc3..7efc1c95e1 100644 --- a/components/device-types/pom.xml +++ b/components/device-types/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml index 3252e8e06e..4525124d58 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics/pom.xml @@ -21,7 +21,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml index 082529dd3e..0734f0a9b1 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/pom.xml @@ -21,7 +21,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java index 20b8daee85..704ef518fc 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.api/src/main/java/org/wso2/carbon/device/mgt/iot/raspberrypi/service/impl/listener/RaspberryPIPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class RaspberryPIPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(RaspberryPIPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class RaspberryPIPermissionUpdateListener implements ServletContextListen getAuthorizationManager().authorizeRole(RaspberrypiConstants.ROLE_NAME, RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Raspberry PI.", e); } } @@ -57,57 +61,44 @@ public class RaspberryPIPermissionUpdateListener implements ServletContextListen } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - } diff --git a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml index 444d42f63b..62a641d9a2 100644 --- a/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml +++ b/components/device-types/raspberrypi-plugin/org.wso2.carbon.device.mgt.iot.raspberrypi.ui/pom.xml @@ -23,7 +23,7 @@ raspberrypi-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/raspberrypi-plugin/pom.xml b/components/device-types/raspberrypi-plugin/pom.xml index 9915b8aeda..559d848248 100644 --- a/components/device-types/raspberrypi-plugin/pom.xml +++ b/components/device-types/raspberrypi-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml index 9dcee7845b..29da38464d 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.agent.impl/pom.xml @@ -23,7 +23,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml index e306719c67..56eef35413 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics/pom.xml @@ -21,7 +21,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml index 449eb69bda..f9b65595c8 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/pom.xml @@ -21,7 +21,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java index 8298680108..16a6897b3e 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.api/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/listener/VirtualFireAlarmPermissionUpdateListener.java @@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener; public class VirtualFireAlarmPermissionUpdateListener implements ServletContextListener { private static Log log = LogFactory.getLog(VirtualFireAlarmPermissionUpdateListener.class); + private static PrivilegedCarbonContext threadLocalCarbonContext; + private static RealmService realmService; @Override public void contextInitialized(ServletContextEvent servletContextEvent) { - + threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null); UserStoreManager userStoreManager = getUserStoreManager(); try { if (userStoreManager != null) { @@ -47,7 +50,8 @@ public class VirtualFireAlarmPermissionUpdateListener implements ServletContextL getAuthorizationManager().authorizeRole(VirtualFireAlarmConstants.ROLE_NAME, VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); } - } } catch (UserStoreException e) { + } + } catch (UserStoreException e) { log.error("Error while creating a role and adding a user for Raspberry PI.", e); } } @@ -57,57 +61,44 @@ public class VirtualFireAlarmPermissionUpdateListener implements ServletContextL } - public static UserStoreManager getUserStoreManager() { - RealmService realmService; + private UserStoreManager getUserStoreManager() { UserStoreManager userStoreManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return userStoreManager; } - public static AuthorizationManager getAuthorizationManager() { - RealmService realmService; + private AuthorizationManager getAuthorizationManager() { AuthorizationManager authorizationManager; try { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - realmService = (RealmService) ctx.getOSGiService(RealmService.class, null); if (realmService == null) { String msg = "Realm service has not initialized."; - log.error(msg); throw new IllegalStateException(msg); } - int tenantId = ctx.getTenantId(); + int tenantId = threadLocalCarbonContext.getTenantId(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); } catch (UserStoreException e) { String msg = "Error occurred while retrieving current user store manager"; - log.error(msg, e); throw new IllegalStateException(msg); } return authorizationManager; } private Permission[] getPermissions() { - - Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM, - CarbonConstants.UI_PERMISSION_ACTION); - Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants - .UI_PERMISSION_ACTION); - - return new Permission[]{androidSense, view}; + Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM, + CarbonConstants.UI_PERMISSION_ACTION); + Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, + CarbonConstants.UI_PERMISSION_ACTION); + return new Permission[]{androidSense, view}; } - -} +} \ No newline at end of file diff --git a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml index 70907236e7..771cde9103 100644 --- a/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui/pom.xml @@ -23,7 +23,7 @@ virtual-fire-alarm-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/device-types/virtual-fire-alarm-plugin/pom.xml b/components/device-types/virtual-fire-alarm-plugin/pom.xml index bcb59b6257..c114fa5406 100644 --- a/components/device-types/virtual-fire-alarm-plugin/pom.xml +++ b/components/device-types/virtual-fire-alarm-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml index c9bac2c800..fec412acab 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.osgiconnector/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.devicemgt-plugins appm-connector - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml index 85e117f0f3..3ccad77642 100644 --- a/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml +++ b/components/extensions/appm-connector/org.wso2.carbon.appmgt.mdm.restconnector/pom.xml @@ -18,7 +18,7 @@ org.wso2.carbon.devicemgt-plugins appm-connector - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/appm-connector/pom.xml b/components/extensions/appm-connector/pom.xml index 55e57e43a8..748c7b495a 100644 --- a/components/extensions/appm-connector/pom.xml +++ b/components/extensions/appm-connector/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml index 1b5a85dc64..5512b92847 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.extension/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml index 912db3252b..16204984cf 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.http/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml index 159f0b5602..264e4268ab 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.mqtt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml index ff78a84d9a..86c5b49943 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.thrift/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml index 0cc2b84431..db1552569c 100644 --- a/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/input/org.wso2.carbon.device.mgt.input.adapter.xmpp/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml index 8d6ea7778e..8c1c32eac8 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapter.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapter.java index a37f49b71b..a069b586f6 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapter.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapter.java @@ -59,13 +59,17 @@ import java.net.UnknownHostException; import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public class HTTPEventAdapter implements OutputEventAdapter { @@ -181,6 +185,34 @@ public class HTTPEventAdapter implements OutputEventAdapter { .extractHeaders(dynamicProperties.get(HTTPEventAdapterConstants.ADAPTER_HEADERS)); String payload = message.toString(); + if ("true".equals(dynamicProperties.get(HTTPEventAdapterConstants.ADAPTER_MESSAGE_URL_TEMPLATED))) { + contentType = "application/json"; + payload = payload.replace("'", "\\\""); + try { + JSONParser jsonParser = new JSONParser(); + JSONObject jsonPayload = (JSONObject) jsonParser.parse(payload); + + List matchList = new ArrayList<>(); + Pattern regex = Pattern.compile("\\{(.*?)\\}"); + Matcher regexMatcher = regex.matcher(url); + + while (regexMatcher.find()) {//Finds Matching Pattern in String + matchList.add(regexMatcher.group(1));//Fetching Group from String + } + + for(String str:matchList) { + if (jsonPayload.containsKey(str)) { + url = url.replace("{" + str + "}", jsonPayload.get(str).toString()); + } + } + if (log.isDebugEnabled()) { + log.debug("Modified url: " + url); + } + } catch (ParseException e) { + log.error("Unable to parse request body to Json.", e); + } + } + try { executorService.submit(new HTTPSender(url, payload, headers, httpClient)); } catch (RejectedExecutionException e) { diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapterFactory.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapterFactory.java index 0aad85489a..e5450ebfc0 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapterFactory.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/HTTPEventAdapterFactory.java @@ -76,6 +76,12 @@ public class HTTPEventAdapterFactory extends OutputEventAdapterFactory { urlProp.setHint(resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_MESSAGE_URL_HINT)); urlProp.setRequired(true); + Property urlTemplateProp = new Property(HTTPEventAdapterConstants.ADAPTER_MESSAGE_URL_TEMPLATED); + urlTemplateProp.setDisplayName(resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_MESSAGE_URL_TEMPLATED)); + urlTemplateProp.setHint(resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_MESSAGE_URL_TEMPLATED_HINT)); + urlTemplateProp.setRequired(true); + urlTemplateProp.setOptions(new String[]{"true", "false"}); + Property usernameProp = new Property(HTTPEventAdapterConstants.ADAPTER_USERNAME); usernameProp.setDisplayName(resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_USERNAME)); usernameProp.setHint(resourceBundle.getString(HTTPEventAdapterConstants.ADAPTER_USERNAME_HINT)); @@ -94,6 +100,7 @@ public class HTTPEventAdapterFactory extends OutputEventAdapterFactory { headersProp.setRequired(false); dynamicPropertyList.add(urlProp); + dynamicPropertyList.add(urlTemplateProp); dynamicPropertyList.add(usernameProp); dynamicPropertyList.add(passwordProp); dynamicPropertyList.add(headersProp); diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/util/HTTPEventAdapterConstants.java b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/util/HTTPEventAdapterConstants.java index 212afe7367..296f51aa28 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/util/HTTPEventAdapterConstants.java +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/java/org/wso2/carbon/device/mgt/output/adapter/http/util/HTTPEventAdapterConstants.java @@ -21,6 +21,8 @@ public class HTTPEventAdapterConstants { public static final String ADAPTER_TYPE_HTTP = "oauth-http"; public static final String ADAPTER_MESSAGE_URL = "http.url"; + public static final String ADAPTER_MESSAGE_URL_TEMPLATED = "http.url.templated"; + public static final String ADAPTER_MESSAGE_URL_TEMPLATED_HINT = "http.url.templated.hint"; public static final String ADAPTER_MESSAGE_URL_HINT = "http.url.hint"; public static final String ADAPTER_CONF_DCR_URL = "dcrUrl"; public static final String ADAPTER_CONF_TOKEN_URL = "tokenUrl"; diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/http/i18n/Resources.properties b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/http/i18n/Resources.properties index 0ceb2d520a..a31fefd0ec 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/http/i18n/Resources.properties +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.http/src/main/resources/org/wso2/carbon/device/mgt/output/adapter/http/i18n/Resources.properties @@ -18,6 +18,8 @@ http.url=URL http.url.hint=The target HTTP/HTTPS URL, e.g. "http://yourhost:8080/service (URL will auto format for tenants)" +http.url.templated=URL Templated +http.url.templated.hint=The target HTTP/HTTPS URL has template value(s) to fill from event. e.g. "http://yourhost:8080/service/{variable1}/{variable2}" variable1 & variable2 should be available in the event and event should be in json format username=Username http.username.hint=Username to obtain oauth token. Leave empty to use default. password=Password diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml index c93f97edf1..eca45c4abe 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.mqtt/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml index d10d8dd018..d98bf190de 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket.endpoint/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml index e83e87b718..2eee742c6f 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.websocket/pom.xml @@ -21,7 +21,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml index 3a1d8ad153..b80978090a 100644 --- a/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml +++ b/components/extensions/cdmf-transport-adapters/output/org.wso2.carbon.device.mgt.output.adapter.xmpp/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins cdmf-transport-adapters - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/extensions/cdmf-transport-adapters/pom.xml b/components/extensions/cdmf-transport-adapters/pom.xml index c9bf8786ac..b93be1d254 100644 --- a/components/extensions/cdmf-transport-adapters/pom.xml +++ b/components/extensions/cdmf-transport-adapters/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml index 9db63d527f..9ba3a2c9b5 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.api/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mb-extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml index ea37601e2a..13d36e47c5 100644 --- a/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml +++ b/components/extensions/mb-extensions/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mb-extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/mb-extensions/pom.xml b/components/extensions/mb-extensions/pom.xml index 76944c96fa..d264cbf0a5 100644 --- a/components/extensions/mb-extensions/pom.xml +++ b/components/extensions/mb-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/pom.xml b/components/extensions/pom.xml index 9c33d17a19..202867f118 100644 --- a/components/extensions/pom.xml +++ b/components/extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml @@ -38,6 +38,7 @@ mb-extensions siddhi-extensions pull-notification-listeners + remote-session-extension diff --git a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml index 1a22621d81..8308d06f79 100644 --- a/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml +++ b/components/extensions/pull-notification-listeners/org.wso2.carbon.device.mgt.mqtt.notification.listener/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins pull-notification-listeners - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/pull-notification-listeners/pom.xml b/components/extensions/pull-notification-listeners/pom.xml index 241395efb8..76c21cb589 100644 --- a/components/extensions/pull-notification-listeners/pom.xml +++ b/components/extensions/pull-notification-listeners/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/pom.xml b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/pom.xml new file mode 100644 index 0000000000..2406f698c1 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/pom.xml @@ -0,0 +1,68 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + remote-session-extension + 4.0.100-SNAPSHOT + ../pom.xml + + + + 4.0.0 + org.wso2.carbon.device.mgt.extensions.remote.session.endpoint + war + WSO2 - Webapp for UI Remote Session + http://wso2.org + + + + junit + junit + test + + + org.apache.tomcat + tomcat-websocket-api + + + javax.ws.rs + javax.ws.rs-api + + + org.apache.cxf + cxf-rt-frontend-jaxrs + + + org.json.wso2 + json + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.extensions.remote.session + provided + + + + + remote#session + + diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/ClientSessionSubscriptionEndpoint.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/ClientSessionSubscriptionEndpoint.java new file mode 100644 index 0000000000..6fd1d99705 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/ClientSessionSubscriptionEndpoint.java @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * deviceId 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.remote.session.endpoint; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.utils.HttpSessionConfigurator; +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.utils.ServiceHolder; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; + +import javax.websocket.CloseReason; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; + +/** + * This class represents web socket endpoint to manage Remote Sessions + */ +@ServerEndpoint(value = "/clients/{deviceType}/{deviceId}", configurator = HttpSessionConfigurator.class) +public class ClientSessionSubscriptionEndpoint extends SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(ClientSessionSubscriptionEndpoint.class); + + /** + * Web socket onOpen use when client connect to web socket url + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnOpen + public void onOpen(Session session, @PathParam("deviceType") String deviceType, @PathParam("deviceId") String + deviceId) { + try { + ServiceHolder.getInstance().getRemoteSessionManagementService().initializeSession(session, deviceType, + deviceId); + } catch (RemoteSessionManagementException e) { + if (log.isDebugEnabled()) { + log.error("Error occurred while initializing session ", e); + } + try { + session.close(e.getCloseReason()); + } catch (IOException ex) { + log.error("Failed to disconnect the client.", ex); + } + } + } + + /** + * Web socket onMessage use when client sends a string message + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnMessage + public void onMessage(Session session, String message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onMessage(session, message, deviceType, deviceId); + } + + /** + * Web socket onMessage use when client sends a byte message + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param message - Byte message which needs to send to peer + */ + @OnMessage + public void onMessage(Session session, byte[] message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onMessage(session, message, deviceType, deviceId); + } + + /** + * Web socket onClose use to handle socket connection close + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param reason - Status code for web-socket close. + */ + @OnClose + public void onClose(Session session, CloseReason reason, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onClose(session, reason, deviceType, deviceId); + } + + /** + * Web socket onError use to handle socket connection error + * + * @param session - Registered session. + * @param throwable - Web socket exception + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnError + public void onError(Session session, Throwable throwable, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onError(session, throwable, deviceType, deviceId); + } +} \ No newline at end of file diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/DeviceSessionSubscriptionEndpoint.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/DeviceSessionSubscriptionEndpoint.java new file mode 100644 index 0000000000..de504eacfd --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/DeviceSessionSubscriptionEndpoint.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * deviceId 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.remote.session.endpoint; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.utils.HttpSessionConfigurator; +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.utils.ServiceHolder; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; + +import javax.websocket.CloseReason; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; +import java.io.IOException; + +/** + * This class represents web socket endpoint to manage Remote Sessions + */ +@ServerEndpoint(value = "/devices/{deviceType}/{deviceId}/{operationId}", configurator = HttpSessionConfigurator.class) +public class DeviceSessionSubscriptionEndpoint extends SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(DeviceSessionSubscriptionEndpoint.class); + + /** + * Web socket onOpen use when device connect to web socket url + * + * @param session - Web socket Session + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param operationId - Operations Id + */ + @OnOpen + public void onOpen(Session session, @PathParam("deviceType") String deviceType, @PathParam("deviceId") String + deviceId, @PathParam("operationId") String operationId) { + try { + ServiceHolder.getInstance().getRemoteSessionManagementService().initializeSession(session, deviceType, + deviceId, operationId); + } catch (RemoteSessionManagementException e) { + if (log.isDebugEnabled()) { + log.error("Error occurred while initializing session ", e); + } + try { + session.close(e.getCloseReason()); + } catch (IOException ex) { + log.error("Failed to disconnect the client.", ex); + } + } + } + + /** + * Web socket onMessage use when device sends a string message + * + * @param session - Registered session. + * @param message - String message which needs to send to peer + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnMessage + public void onMessage(Session session, String message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onMessage(session, message, deviceType, deviceId); + } + + /** + * Web socket onMessage use when device sends a byte message + * + * @param session - Registered session. + * @param message - Byte message which needs to send to peer + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnMessage + public void onMessage(Session session, byte[] message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onMessage(session, message, deviceType, deviceId); + } + + /** + * Web socket onClose use to handle socket connection close + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param reason - Status code for web-socket close. + */ + @OnClose + public void onClose(Session session, CloseReason reason, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onClose(session, reason, deviceType, deviceId); + } + + /** + * Web socket onError use to handle socket connection error + * + * @param session - Registered session. + * @param throwable - Web socket exception + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + @OnError + public void onError(Session session, Throwable throwable, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + super.onError(session, throwable, deviceType, deviceId); + } +} \ No newline at end of file diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/SubscriptionEndpoint.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/SubscriptionEndpoint.java new file mode 100644 index 0000000000..f3ed4cd305 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/SubscriptionEndpoint.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. licenses this file to you under the Apache License, + * deviceId 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.remote.session.endpoint; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.utils.ServiceHolder; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; + +import javax.websocket.CloseReason; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import java.io.IOException; + +/** + * This class represents common web socket endpoint to manage Remote Sessions + */ +public class SubscriptionEndpoint { + + private static final Log log = LogFactory.getLog(SubscriptionEndpoint.class); + + /** + * Web socket onMessage - When client sends a message + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param message - String Message which needs to send to peer + */ + public void onMessage(Session session, String message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + if (log.isDebugEnabled()) { + log.debug("Received message from client for RemoteSession id: " + session.getId() + " device type: " + + deviceType + " device id: " + deviceId); + } + try { + ServiceHolder.getInstance().getRemoteSessionManagementService().sendMessageToPeer(session, message); + } catch (RemoteSessionManagementException e) { + if (log.isDebugEnabled()) { + log.error("Error occurred while send message to peer session ", e); + } + try { + session.close(e.getCloseReason()); + } catch (IOException ex) { + if (log.isDebugEnabled()) { + log.error("Failed to disconnect the client.", ex); + } + } + } + } + + /** + * Web socket onMessage use When client sends a message + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param message - Byte Message which needs to send to peer + */ + public void onMessage(Session session, byte[] message, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + if (log.isDebugEnabled()) { + log.debug("Received message from client for RemoteSession id: " + session.getId() + " device type: " + + deviceType + " device id: " + deviceId); + } + try { + ServiceHolder.getInstance().getRemoteSessionManagementService().sendMessageToPeer(session, message); + } catch (RemoteSessionManagementException e) { + if (log.isDebugEnabled()) { + log.error("Error occurred while send message to peer session ", e); + } + try { + session.close(e.getCloseReason()); + } catch (IOException ex) { + if (log.isDebugEnabled()) { + log.error("Failed to disconnect the client.", ex); + } + } + } + } + + /** + * Web socket onClose use to handle socket connection close + * + * @param session - Registered session. + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + * @param reason - Status code for web-socket close. + */ + public void onClose(Session session, CloseReason reason, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + + ServiceHolder.getInstance().getRemoteSessionManagementService().endSession(session, "Remote session closed"); + if (log.isDebugEnabled()) { + log.debug("websocket closed due to " + reason.getReasonPhrase() + ", for session ID:" + session.getId + () + ", for request URI - " + session.getRequestURI() + " device type: " + deviceType + " device " + + "id: " + deviceId); + } + + } + + /** + * Web socket onError use to handle socket connection error + * + * @param session - Registered session. + * @param throwable - Web socket exception + * @param deviceType - DeviceType + * @param deviceId - Device Identifier + */ + public void onError(Session session, Throwable throwable, @PathParam("deviceType") String deviceType, @PathParam + ("deviceId") String deviceId) { + + if (throwable instanceof IOException) { + if (log.isDebugEnabled()) { + log.error("Error occurred in session ID: " + session.getId() + " device type: " + deviceType + + "device id: " + deviceId + ", for request URI - " + session.getRequestURI() + + ", " + throwable.getMessage(), throwable); + } + } else { + log.error("Error occurred in session ID: " + session.getId() + " device type: " + deviceType + " device " + + "id: " + deviceId + ", for request URI - " + session.getRequestURI() + ", " + throwable.getMessage + (), throwable); + } + try { + ServiceHolder.getInstance().getRemoteSessionManagementService().endSession(session, "Remote session closed"); + if (session.isOpen()) { + session.close(new CloseReason(CloseReason.CloseCodes.PROTOCOL_ERROR, "Unexpected Error Occurred")); + } + } catch (IOException ex) { + if (log.isDebugEnabled()) { + log.error("Failed to disconnect the client.", ex); + } + } + } +} \ No newline at end of file diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/constants/Constants.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/constants/Constants.java new file mode 100644 index 0000000000..544b58d573 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/constants/Constants.java @@ -0,0 +1,31 @@ +/* + * + * Copyright (c) 2017, 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.remote.session.endpoint.constants; + +/** + * This holds the constants related to remote session web socket endpoint + */ +public class Constants { + public static final String HTTP_HEADERS = "HttpHeaders"; + + private Constants() { + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/HttpSessionConfigurator.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/HttpSessionConfigurator.java new file mode 100644 index 0000000000..6d5513f958 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/HttpSessionConfigurator.java @@ -0,0 +1,39 @@ +/* + * + * Copyright (c) 2017, 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.remote.session.endpoint.utils; + +import org.wso2.carbon.device.mgt.extensions.remote.session.endpoint.constants.Constants; + +import javax.websocket.HandshakeResponse; +import javax.websocket.server.HandshakeRequest; +import javax.websocket.server.ServerEndpointConfig; +import java.util.List; +import java.util.Map; + +/** + * Class for handle HTTP session + */ +public class HttpSessionConfigurator extends ServerEndpointConfig.Configurator { + public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) { + Map> httpHeaders = request.getHeaders(); + config.getUserProperties().put(Constants.HTTP_HEADERS, httpHeaders); + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/ServiceHolder.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/ServiceHolder.java new file mode 100644 index 0000000000..570238bb8e --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/java/org/wso2/carbon/device/mgt/extensions/remote/session/endpoint/utils/ServiceHolder.java @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 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.remote.session.endpoint.utils; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.extensions.remote.session.RemoteSessionManagementService; + +/** + * Class for store remote management service instances + */ +public class ServiceHolder { + + private static ServiceHolder instance; + private static final Log log = LogFactory.getLog(ServiceHolder.class); + + private ServiceHolder() { + } + + public synchronized static ServiceHolder getInstance() { + if (instance == null) { + instance = new ServiceHolder(); + } + return instance; + } + + public RemoteSessionManagementService getRemoteSessionManagementService() { + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + RemoteSessionManagementService RemoteSessionManagementService = + (RemoteSessionManagementService) ctx.getOSGiService(RemoteSessionManagementService.class, null); + if (RemoteSessionManagementService == null) { + String msg = "Remote Session Management service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return RemoteSessionManagementService; + } + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/webapp/WEB-INF/web.xml b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000000..9f8a509b17 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session.endpoint/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,59 @@ + + + + + Remote Session + + HttpHeaderSecurityFilter + org.apache.catalina.filters.HttpHeaderSecurityFilter + + hstsEnabled + false + + + + + ContentTypeBasedCachePreventionFilter + org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter + + patterns + text/html" ,application/json" ,text/plain + + + filterAction + enforce + + + httpHeaders + Cache-Control: no-store, no-cache, must-revalidate, private + + + + + HttpHeaderSecurityFilter + /* + + + + ContentTypeBasedCachePreventionFilter + /* + + diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml new file mode 100644 index 0000000000..f04ec0ae6e --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/pom.xml @@ -0,0 +1,131 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + remote-session-extension + 4.0.100-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.device.mgt.extensions.remote.session + bundle + WSO2 Carbon - Remote Session Manager Implementation + WSO2 Carbon - Remote Session Manager Implementation + http://wso2.org + + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.wso2.carbon.identity.inbound.auth.oauth2 + org.wso2.carbon.identity.oauth.stub + + + commons-pool.wso2 + commons-pool + + + org.wso2.carbon.devicemgt + org.wso2.carbon.device.mgt.core + + + org.json.wso2 + json + + + + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${carbon.devicemgt.plugins.version} + Remote Session Manager Bundle + + !org.wso2.carbon.device.mgt.extensions.remote.session.internal, + org.wso2.carbon.device.mgt.extensions.remote.session.* + + + javax.websocket, + org.apache.axis2; version="${axis2.osgi.version.range}", + org.apache.axis2.client; version="${axis2.osgi.version.range}", + org.apache.axis2.context; version="${axis2.osgi.version.range}", + org.apache.axis2.transport.http; version="${axis2.osgi.version.range}", + org.apache.commons.httpclient, + org.apache.commons.httpclient.contrib.ssl, + org.apache.commons.httpclient.params, + org.apache.commons.httpclient.protocol, + org.apache.commons.logging, + org.apache.commons.pool, + org.apache.commons.pool.impl, + org.json, + org.osgi.framework, + org.osgi.service.component, + org.wso2.carbon.context, + org.wso2.carbon.core, + org.wso2.carbon.device.mgt.common.*, + org.wso2.carbon.device.mgt.core.*, + org.wso2.carbon.identity.oauth2.stub, + org.wso2.carbon.identity.oauth2.stub.dto, + org.wso2.carbon.utils.multitenancy + + + + + + + + + diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementService.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementService.java new file mode 100644 index 0000000000..ce6f155d12 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementService.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2017, 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.remote.session; + +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; + +import javax.websocket.Session; +import java.io.IOException; + +/** + * Class @{@link RemoteSessionManagementService} use for managing remote sessions + */ +public interface RemoteSessionManagementService { + + /** + * Initialize session based on web socket request .This method is used by the device to connect + * + * @param session Web socket RemoteSession + * @param deviceType Device Type + * @param deviceId Device Id + * @throws RemoteSessionManagementException throws when session has errors with accessing device resources + */ + void initializeSession(Session session, String deviceType, String deviceId) throws + RemoteSessionManagementException; + + /** + * Initialize session based on web socket request . This method is used by the device to connect + * + * @param session Web socket RemoteSession + * @param deviceType Device Type + * @param deviceId Device Id + * @param operationId Operation Id that device needs to connec + * @throws RemoteSessionManagementException throws when session has errors with accessing device resources + */ + void initializeSession(Session session, String deviceType, String deviceId, String operationId) throws + RemoteSessionManagementException; + + /** + * Send string message to connected remote device or client + * + * @param session Web socket RemoteSession + * @param message Message needs to send to peer connection client + * @throws RemoteSessionManagementException + */ + void sendMessageToPeer(Session session, String message) throws RemoteSessionManagementException; + + /** + * Send byte message to connected remote device or client + * + * @param session Web socket RemoteSession + * @param message Message needs to send to peer connection + * @throws RemoteSessionManagementException + */ + void sendMessageToPeer(Session session, byte[] message) throws RemoteSessionManagementException; + + /** + * Close the session + * + * @param session Web socket RemoteSession + */ + void endSession(Session session, String closeReason); + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java new file mode 100644 index 0000000000..1274d79214 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/RemoteSessionManagementServiceImpl.java @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2017, 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.remote.session; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONObject; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.InvalidDeviceException; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException; +import org.wso2.carbon.device.mgt.common.operation.mgt.Activity; +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.core.DeviceManagementConstants; +import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.OAuthAuthenticator; +import org.wso2.carbon.device.mgt.extensions.remote.session.constants.RemoteSessionConstants; +import org.wso2.carbon.device.mgt.extensions.remote.session.dto.RemoteSession; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; +import org.wso2.carbon.device.mgt.extensions.remote.session.internal.RemoteSessionManagementDataHolder; + +import javax.websocket.CloseReason; +import javax.websocket.Session; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * Class @{@link RemoteSessionManagementServiceImpl} is the implementation of @{@link RemoteSessionManagementService} + * which is used manage initial connection, sending messages to peer session, manage and close the session. + */ +public class RemoteSessionManagementServiceImpl implements RemoteSessionManagementService { + + private static final Log log = LogFactory.getLog(RemoteSessionManagementServiceImpl.class); + + @Override + public void initializeSession(Session session, String deviceType, String deviceId, String operationId) throws + RemoteSessionManagementException { + + // Check whether required configurations are enabled + if (!RemoteSessionManagementDataHolder.getInstance().isEnabled()) { + throw new RemoteSessionManagementException("Remote session feature is disabled."); + } else if (RemoteSessionManagementDataHolder.getInstance().getServerUrl() == null) { + throw new RemoteSessionManagementException("Server url has not been configured."); + } + + // Read Query Parameters for obtain the token + Map> sessionQueryParam = new HashMap(); + List sessionQueryParamList = new LinkedList<>(); + sessionQueryParamList.add(session.getQueryString()); + sessionQueryParam.put(RemoteSessionConstants.QUERY_STRING, sessionQueryParamList); + + // Validate the token + OAuthAuthenticator oAuthAuthenticator = RemoteSessionManagementDataHolder.getInstance().getOauthAuthenticator(); + AuthenticationInfo authenticationInfo = oAuthAuthenticator.isAuthenticated(sessionQueryParam); + + if (authenticationInfo != null && authenticationInfo.isAuthenticated()) { + try { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(authenticationInfo + .getTenantDomain() + , true); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(authenticationInfo.getUsername()); + if (deviceId != null && !deviceId.isEmpty() && deviceType != null && !deviceType.isEmpty()) { + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); + deviceIdentifier.setId(deviceId); + deviceIdentifier.setType(deviceType); + + // Check authorization of user for given device + boolean userAuthorized = RemoteSessionManagementDataHolder.getInstance() + .getDeviceAccessAuthorizationService() + .isUserAuthorized(deviceIdentifier, authenticationInfo.getUsername()); + if (userAuthorized) { + // set common settings for session + session.setMaxBinaryMessageBufferSize(RemoteSessionManagementDataHolder.getInstance() + .getMaxMessageBufferSize()); + session.setMaxTextMessageBufferSize(RemoteSessionManagementDataHolder.getInstance() + .getMaxMessageBufferSize()); + session.setMaxIdleTimeout(RemoteSessionManagementDataHolder.getInstance().getMaxIdleTimeout()); + + // if session initiated using operation id means request came from device + if (operationId != null) { + // create new device session + initializeDeviceSession(session, authenticationInfo.getTenantDomain(), deviceType, deviceId, + operationId); + } else { + // create new client session + initializeClientSession(session, authenticationInfo.getTenantDomain(), deviceType, + deviceId); + } + log.info("Current remote sessions count: " + RemoteSessionManagementDataHolder.getInstance() + .getSessionMap().size()); + + } else { + throw new RemoteSessionManagementException("Missing device Id or type "); + } + } else { + throw new RemoteSessionManagementException("Unauthorized Access for the device Type : " + deviceType + + " , deviceId : " + deviceId); + } + } catch (OperationManagementException | InvalidDeviceException e) { + throw new RemoteSessionManagementException("Error occurred while adding initial operation for the " + + "device Type : " + deviceType + " , deviceId : " + deviceId); + } catch (DeviceAccessAuthorizationException e) { + throw new RemoteSessionManagementException("Error occurred while device access authorization for the " + + "device Type : " + deviceType + " , " + "deviceId : " + deviceId); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + + } else { + throw new RemoteSessionManagementException("Invalid token"); + } + } + + @Override + public void initializeSession(Session session, String deviceType, String deviceId) throws + RemoteSessionManagementException { + initializeSession(session, deviceType, deviceId, null); + } + + /** + * Implements the behaviour of sending message to peer connection + * + * @param session Web socket RemoteSession + * @param message String message needs to send to peer connection + * @throws RemoteSessionManagementException throws when session cannot be made due to invalid data + * @throws RemoteSessionManagementException throws when session has error with accessing device resources + */ + @Override + public void sendMessageToPeer(Session session, String message) throws RemoteSessionManagementException { + JSONObject jsonObject = new JSONObject(message); + RemoteSession remoteSession = RemoteSessionManagementDataHolder.getInstance().getSessionMap().get(session + .getId()); + if (remoteSession != null) { + remoteSession.sendMessageToPeer(jsonObject.toString()); + } else { + throw new RemoteSessionManagementException("Remote Session cannot be found "); + } + } + + + /** + * Implements the behaviour of sending message to peer connection + * + * @param session Web socket RemoteSession + * @param message Byte message needs to send to peer connection + * @throws RemoteSessionManagementException throws when session cannot be made due to invalid data + * @throws RemoteSessionManagementException throws when session has error with accessing device resources + */ + @Override + public void sendMessageToPeer(Session session, byte[] message) throws RemoteSessionManagementException { + + RemoteSession remoteSession = RemoteSessionManagementDataHolder.getInstance().getSessionMap().get(session + .getId()); + if (remoteSession != null) { + remoteSession.sendMessageToPeer(message); + } else { + throw new RemoteSessionManagementException("Remote Session cannot be found "); + } + } + + /** + * Closing the session and cleanup the resources + * + * @param session Web socket Remote Session + */ + @Override + public void endSession(Session session, String closeReason) { + + RemoteSession remoteSession = RemoteSessionManagementDataHolder.getInstance().getSessionMap().remove(session + .getId()); + if (remoteSession != null) { + //String operationId = remoteSession.getOperationId(); + String deviceKey = remoteSession.getTenantDomain() + "/" + remoteSession.getDeviceType() + "/" + + remoteSession.getDeviceId(); + RemoteSession lastSession = RemoteSessionManagementDataHolder.getInstance() + .getActiveDeviceClientSessionMap().get(deviceKey); + if (lastSession != null && lastSession.getMySession().getId().equals(session.getId())) { + RemoteSessionManagementDataHolder.getInstance().getActiveDeviceClientSessionMap().remove + (deviceKey); + } + if (remoteSession.getPeerSession() != null) { + Session peerSession = remoteSession.getPeerSession().getMySession(); + if (peerSession != null) { + RemoteSessionManagementDataHolder.getInstance().getSessionMap().remove(peerSession.getId()); + if (lastSession != null && lastSession.getMySession().getId().equals(peerSession.getId())) { + RemoteSessionManagementDataHolder.getInstance().getActiveDeviceClientSessionMap().remove + (deviceKey); + } + if (peerSession.isOpen()) { + try { + peerSession.close(new CloseReason(CloseReason.CloseCodes.GOING_AWAY, closeReason)); + } catch (IOException ex) { + if (log.isDebugEnabled()) { + log.error("Failed to disconnect the client.", ex); + } + } + } + } + } + } + } + + + /** + * Starting new client session + * + * @param session Web socket Session + * @param tenantDomain Tenant domain + * @param deviceType Device Type + * @param deviceId Device Id + * @throws RemoteSessionManagementException throws when session has errors with accessing device resources + * @throws OperationManagementException throws when error occured during new operation + * @throws InvalidDeviceException throws when incorrect device identifier + */ + private void initializeClientSession(Session session, String tenantDomain, String deviceType, String deviceId) throws RemoteSessionManagementException, + OperationManagementException, InvalidDeviceException { + + RemoteSession clientRemote = new RemoteSession(session, tenantDomain, deviceType, deviceId, RemoteSessionConstants + .CONNECTION_TYPE.CLIENT); + String deviceKey = tenantDomain + "/" + deviceType + "/" + deviceId; + // Create new remote control operation to start the session + RemoteSession activeSession = RemoteSessionManagementDataHolder.getInstance().getActiveDeviceClientSessionMap + ().putIfAbsent(deviceKey, clientRemote); + if (activeSession != null && activeSession.getMySession().isOpen() && activeSession + .getPeerSession() == null) { + throw new RemoteSessionManagementException("Another client session waiting on device to connect."); + } else { + // if there is pending session exists but already closed, then we need to remove it. + if (activeSession != null) { + RemoteSessionManagementDataHolder.getInstance().getActiveDeviceClientSessionMap().remove + (deviceKey); + try { + activeSession.getMySession().close(new CloseReason(CloseReason.CloseCodes.GOING_AWAY, "Remote " + + "session closed due to new session request")); + } catch (IOException ex) { + if (log.isDebugEnabled()) { + log.error("Failed to disconnect the client.", ex); + } + } + // Use put if absent for adding session to waiting list since we need to overcome + // multithreaded session requests. + activeSession = RemoteSessionManagementDataHolder.getInstance().getActiveDeviceClientSessionMap() + .putIfAbsent(deviceKey, clientRemote); + } + // If another client tried to start session same time then active session will be + // exist. So we are adding session request only no parallel sessions added to map + if (activeSession == null) { + + // Create operation if session initiated by client + Operation operation = new ConfigOperation(); + operation.setCode(RemoteSessionConstants.REMOTE_CONNECT); + operation.setEnabled(true); + operation.setControl(Operation.Control.NO_REPEAT); + JSONObject payload = new JSONObject(); + payload.put("serverUrl", RemoteSessionManagementDataHolder.getInstance().getServerUrl()); + operation.setPayLoad(payload.toString()); + String date = new SimpleDateFormat(RemoteSessionConstants.DATE_FORMAT_NOW).format(new Date()); + operation.setCreatedTimeStamp(date); + List deviceIdentifiers = new ArrayList<>(); + deviceIdentifiers.add(new DeviceIdentifier(deviceId, deviceType)); + Activity activity = RemoteSessionManagementDataHolder.getInstance(). + getDeviceManagementProviderService().addOperation(deviceType, operation, deviceIdentifiers); + clientRemote.setOperationId(activity.getActivityId().replace(DeviceManagementConstants + .OperationAttributes.ACTIVITY, "")); + RemoteSessionManagementDataHolder.getInstance().getSessionMap().put(session.getId(), clientRemote); + log.info("Client remote session opened for session id: " + session.getId() + " device Type : " + + deviceType + " , " + "deviceId : " + deviceId); + } else { + throw new RemoteSessionManagementException("Another client session waiting on " + + "device to connect."); + } + } + } + + /** + * Starting new device session + * + * @param session Web socket Session + * @param tenantDomain Tenant domain + * @param deviceType Device Type + * @param deviceId Device Id + * @param operationId Operation id + * @throws RemoteSessionManagementException throws when session has errors with accessing device resources + */ + private void initializeDeviceSession(Session session, String tenantDomain, String deviceType, String deviceId, + String operationId) throws RemoteSessionManagementException { + String deviceKey = tenantDomain + "/" + deviceType + "/" + deviceId; + RemoteSession activeSession = RemoteSessionManagementDataHolder.getInstance() + .getActiveDeviceClientSessionMap().get(deviceKey); + if (activeSession != null) { + RemoteSession clientRemote = RemoteSessionManagementDataHolder.getInstance().getSessionMap().get + (activeSession.getMySession().getId()); + if (clientRemote != null) { + if (clientRemote.getOperationId().equals(operationId)) { + RemoteSession deviceRemote = new RemoteSession(session, tenantDomain, deviceType, deviceId, + RemoteSessionConstants.CONNECTION_TYPE.DEVICE); + deviceRemote.setOperationId(operationId); + deviceRemote.setPeerSession(clientRemote); + clientRemote.setPeerSession(deviceRemote); + RemoteSessionManagementDataHolder.getInstance().getSessionMap().put(session.getId(), deviceRemote); + // Send Remote connect response + JSONObject message = new JSONObject(); + message.put(RemoteSessionConstants.REMOTE_CONNECT_CODE, RemoteSessionConstants.REMOTE_CONNECT); + deviceRemote.sendMessageToPeer(message.toString()); + log.info("Device session opened for session id: " + session.getId() + " device Type : " + + deviceType + " , " + "deviceId : " + deviceId); + } else { + throw new RemoteSessionManagementException("Device and Operation information " + + "does not matched with client information for operation id: " + operationId + " device " + + "Type : " + deviceType + " , " + "deviceId : " + deviceId); + } + } else { + throw new RemoteSessionManagementException("Device session is inactive for " + "operation id: " + + operationId + " device Type : " + deviceType + " , " + "deviceId : " + deviceId); + } + } else { + throw new RemoteSessionManagementException("Device session is inactive for operation " + "id: " + + operationId + " device Type : " + deviceType + " , " + "deviceId : " + deviceId); + } + + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/AuthenticationInfo.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/AuthenticationInfo.java new file mode 100644 index 0000000000..e7d77e5bdb --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/AuthenticationInfo.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.remote.session.authentication; + +import java.util.Map; + +/** + * This is returned after authentication. + */ +public class AuthenticationInfo { + + /** + * this variable is used to check whether the client is authenticated. + */ + private boolean authenticated; + private String username; + private String tenantDomain; + + /** + * To hold authentication related properties eg: scopes in oauth + */ + private Map properties; + + /** + * returns whether the client is authenticated + */ + public boolean isAuthenticated() { + return authenticated; + } + + public void setAuthenticated(boolean authenticated) { + this.authenticated = authenticated; + } + + /** + * returns the authenticated client username + */ + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + /** + * return the authenticated client tenant domain + */ + public String getTenantDomain() { + return tenantDomain; + } + + public void setTenantDomain(String tenantDomain) { + this.tenantDomain = tenantDomain; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/OAuthAuthenticator.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/OAuthAuthenticator.java new file mode 100644 index 0000000000..b6832fc488 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/OAuthAuthenticator.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.remote.session.authentication; + + +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.oauth.OAuthTokenValidator; + +import java.util.List; +import java.util.Map; + +/** + * {@link OAuthAuthenticator} for validate tokens to web socket api + */ +public class OAuthAuthenticator { + OAuthTokenValidator oAuthTokenValidator; + + public void init(Map globalProperties) { + oAuthTokenValidator = new OAuthTokenValidator(globalProperties); + } + + public AuthenticationInfo isAuthenticated(Map> webSocketConnectionProperties) { + return oAuthTokenValidator.validateToken(webSocketConnectionProperties); + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidator.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidator.java new file mode 100644 index 0000000000..352289cf23 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidator.java @@ -0,0 +1,197 @@ +/* + * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed 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.remote.session.authentication.oauth; + +import org.apache.axis2.context.ServiceContext; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.pool.impl.GenericObjectPool; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.AuthenticationInfo; +import org.wso2.carbon.device.mgt.extensions.remote.session.constants.RemoteSessionConstants; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationRequestDTO_OAuth2AccessToken; +import org.wso2.carbon.identity.oauth2.stub.dto.OAuth2TokenValidationResponseDTO; +import org.wso2.carbon.utils.multitenancy.MultitenantUtils; + +import java.rmi.RemoteException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * This acts as a contract point for OAuth token validation. + */ +public class OAuthTokenValidator { + + private static String cookie; + private GenericObjectPool stubs; + private static Log log = LogFactory.getLog(OAuthTokenValidator.class); + private static OAuthTokenValidator oAuthTokenValidator; + + + public OAuthTokenValidator(Map globalProperties) { + this.stubs = new GenericObjectPool(new OAuthTokenValidatorStubFactory(globalProperties)); + } + + /** + * This method gets a string accessToken and validates it + * + * @param webSocketConnectionProperties WebSocket connection information including http headers + * @return AuthenticationInfo with the validated results. + */ + public AuthenticationInfo validateToken(Map> webSocketConnectionProperties) { + String token = getTokenFromSession(webSocketConnectionProperties); + if (token == null) { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setAuthenticated(false); + return authenticationInfo; + } + OAuth2TokenValidationServiceStub tokenValidationServiceStub = null; + try { + Object stub = this.stubs.borrowObject(); + if (stub != null) { + tokenValidationServiceStub = (OAuth2TokenValidationServiceStub) stub; + if (cookie != null) { + tokenValidationServiceStub._getServiceClient().getOptions().setProperty( + HTTPConstants.COOKIE_STRING, cookie); + } + return getAuthenticationInfo(token, tokenValidationServiceStub); + } else { + log.warn("Stub initialization failed."); + } + } catch (RemoteException e) { + log.error("Error on connecting with the validation endpoint.", e); + } catch (Exception e) { + log.error("Error occurred in borrowing an validation stub from the pool.", e); + + } finally { + try { + if (tokenValidationServiceStub != null) { + this.stubs.returnObject(tokenValidationServiceStub); + } + } catch (Exception e) { + log.warn("Error occurred while returning the object back to the oauth token validation service " + + "stub pool.", e); + } + } + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + authenticationInfo.setAuthenticated(false); + return authenticationInfo; + } + + /** + * This creates an AuthenticationInfo object that is used for authorization. This method will validate the token + * and + * sets the required parameters to the object. + * + * @param token that needs to be validated. + * @param tokenValidationServiceStub stub that is used to call the external service. + * @return AuthenticationInfo This contains the information related to authenticated client. + * @throws RemoteException that triggers when failing to call the external service.. + */ + private AuthenticationInfo getAuthenticationInfo(String token, + OAuth2TokenValidationServiceStub tokenValidationServiceStub) + throws RemoteException { + AuthenticationInfo authenticationInfo = new AuthenticationInfo(); + OAuth2TokenValidationRequestDTO validationRequest = new OAuth2TokenValidationRequestDTO(); + OAuth2TokenValidationRequestDTO_OAuth2AccessToken accessToken = + new OAuth2TokenValidationRequestDTO_OAuth2AccessToken(); + accessToken.setTokenType(RemoteSessionConstants.OAuthTokenValidator.TOKEN_TYPE); + accessToken.setIdentifier(token); + validationRequest.setAccessToken(accessToken); + boolean authenticated; + OAuth2TokenValidationResponseDTO tokenValidationResponse; + tokenValidationResponse = tokenValidationServiceStub.validate(validationRequest); + if (tokenValidationResponse == null) { + authenticationInfo.setAuthenticated(false); + return authenticationInfo; + } + authenticated = tokenValidationResponse.getValid(); + if (authenticated) { + String authorizedUser = tokenValidationResponse.getAuthorizedUser(); + String username = MultitenantUtils.getTenantAwareUsername(authorizedUser); + String tenantDomain = MultitenantUtils.getTenantDomain(authorizedUser); + authenticationInfo.setUsername(username); + authenticationInfo.setTenantDomain(tenantDomain); + String scopes[] = tokenValidationResponse.getScope(); + if (scopes != null) { + Map properties = new HashMap<>(); + properties.put(RemoteSessionConstants.SCOPE_IDENTIFIER, scopes); + authenticationInfo.setProperties(properties); + } + } else { + if (log.isDebugEnabled()) { + log.debug("Token validation failed for token: " + token); + } + } + ServiceContext serviceContext = tokenValidationServiceStub._getServiceClient() + .getLastOperationContext().getServiceContext(); + cookie = (String) serviceContext.getProperty(HTTPConstants.COOKIE_STRING); + authenticationInfo.setAuthenticated(authenticated); + return authenticationInfo; + } + + /** + * Retrieving the token from the http header + * + * @param webSocketConnectionProperties WebSocket connection information including http headers + * @return retrieved token + */ + private String getToken(Map> webSocketConnectionProperties) { + String cookieString = webSocketConnectionProperties.get(RemoteSessionConstants.OAuthTokenValidator.COOKIE) + .get(0); + String[] properties = cookieString.split(RemoteSessionConstants.OAuthTokenValidator.COOKIE_KEYPAIR_SEPERATOR); + String token; + for (String keyValuePair : properties) { + if (RemoteSessionConstants.OAuthTokenValidator.TOKEN_IDENTIFIER.equals((keyValuePair. + split(RemoteSessionConstants.OAuthTokenValidator.COOKIE_KEY_VALUE_SEPERATOR)[0]).trim())) { + token = (keyValuePair.split(RemoteSessionConstants.OAuthTokenValidator.COOKIE_KEY_VALUE_SEPERATOR) + [1]).trim(); + return token; + } + } + log.error("WebSocket token should be specified in cookie"); + return null; + } + + /** + * Retrieving the token from the http session + * + * @param webSocketConnectionProperties WebSocket connection information including http headers + * @return retrieved token + */ + private String getTokenFromSession(Map> webSocketConnectionProperties) { + String queryString = webSocketConnectionProperties.get(RemoteSessionConstants.OAuthTokenValidator + .QUERY_STRING).get(0); + if (queryString != null) { + String[] allQueryParamPairs = queryString.split(RemoteSessionConstants.OAuthTokenValidator + .QUERY_STRING_SEPERATOR); + for (String keyValuePair : allQueryParamPairs) { + String[] queryParamPair = keyValuePair.split(RemoteSessionConstants.OAuthTokenValidator + .QUERY_KEY_VALUE_SEPERATOR); + if (queryParamPair.length != 2) { + log.warn("Invalid query string [" + queryString + "] passed in."); + break; + } + if (queryParamPair[0].equals(RemoteSessionConstants.OAuthTokenValidator.TOKEN_IDENTIFIER)) { + return queryParamPair[1]; + } + } + } + return null; + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java new file mode 100644 index 0000000000..15723a2c89 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/OAuthTokenValidatorStubFactory.java @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2017, 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.remote.session.authentication.oauth; + +import org.apache.axis2.AxisFault; +import org.apache.axis2.Constants; +import org.apache.axis2.client.Options; +import org.apache.axis2.client.ServiceClient; +import org.apache.axis2.transport.http.HTTPConstants; +import org.apache.axis2.transport.http.HttpTransportProperties; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpConnectionManager; +import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; +import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; +import org.apache.commons.httpclient.params.HttpConnectionManagerParams; +import org.apache.commons.httpclient.protocol.Protocol; +import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.pool.BasePoolableObjectFactory; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.oauth.exception.OAuthTokenValidationException; +import org.wso2.carbon.device.mgt.extensions.remote.session.constants.RemoteSessionConstants; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; +import org.wso2.carbon.device.mgt.extensions.remote.session.util.PropertyUtils; +import org.wso2.carbon.identity.oauth2.stub.OAuth2TokenValidationServiceStub; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.security.GeneralSecurityException; +import java.util.Map; + + +/** + * This follows object pool pattern to manage the stub for oauth validation service. + */ +public class OAuthTokenValidatorStubFactory extends BasePoolableObjectFactory { + private static final Log log = LogFactory.getLog(OAuthTokenValidatorStubFactory.class); + private HttpClient httpClient; + Map tokenValidationProperties; + + public OAuthTokenValidatorStubFactory(Map globalProperties) { + this.tokenValidationProperties = globalProperties; + this.httpClient = createHttpClient(); + } + + /** + * This creates a OAuth2TokenValidationServiceStub object to the pool. + * + * @return an OAuthValidationStub object + * @throws Exception thrown when creating the object. + */ + @Override + public Object makeObject() throws Exception { + return this.generateStub(); + } + + /** + * This is used to clean up the OAuth validation stub and releases to the object pool. + * + * @param o object that needs to be released. + * @throws Exception throws when failed to release to the pool + */ + @Override + public void passivateObject(Object o) throws Exception { + if (o instanceof OAuth2TokenValidationServiceStub) { + OAuth2TokenValidationServiceStub stub = (OAuth2TokenValidationServiceStub) o; + stub._getServiceClient().cleanupTransport(); + } + } + + /** + * This is used to create a stub which will be triggered through object pool factory, which will create an + * instance of it. + * + * @return OAuth2TokenValidationServiceStub stub that is used to call an external service. + * @throws OAuthTokenValidationException will be thrown when initialization failed. + */ + private OAuth2TokenValidationServiceStub generateStub() throws OAuthTokenValidationException { + OAuth2TokenValidationServiceStub stub; + try { + URL hostURL = new URL(PropertyUtils.replaceProperty(tokenValidationProperties.get( + (RemoteSessionConstants.TOKEN_VALIDATION_ENDPOINT_URL))) + + RemoteSessionConstants.TOKEN_VALIDATION_CONTEX); + stub = new OAuth2TokenValidationServiceStub(hostURL.toString()); + ServiceClient client = stub._getServiceClient(); + client.getServiceContext().getConfigurationContext().setProperty( + HTTPConstants.CACHED_HTTP_CLIENT, httpClient); + + HttpTransportProperties.Authenticator auth = + new HttpTransportProperties.Authenticator(); + auth.setPreemptiveAuthentication(true); + String username = tokenValidationProperties.get(RemoteSessionConstants.USERNAME); + String password = tokenValidationProperties.get(RemoteSessionConstants.PASSWORD); + auth.setPassword(username); + auth.setUsername(password); + Options options = client.getOptions(); + options.setProperty(HTTPConstants.AUTHENTICATE, auth); + options.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE); + client.setOptions(options); + if (hostURL.getProtocol().equals("https")) { + // set up ssl factory since axis2 https notification is used. + EasySSLProtocolSocketFactory sslProtocolSocketFactory = createProtocolSocketFactory(); + Protocol authhttps = new Protocol(hostURL.getProtocol() + , (ProtocolSocketFactory) sslProtocolSocketFactory, hostURL.getPort()); + Protocol.registerProtocol(hostURL.getProtocol(), authhttps); + options.setProperty(HTTPConstants.CUSTOM_PROTOCOL_HANDLER, authhttps); + } + + } catch (AxisFault axisFault) { + throw new OAuthTokenValidationException( + "Error occurred while creating the OAuth2TokenValidationServiceStub.", axisFault); + } catch (MalformedURLException e) { + throw new OAuthTokenValidationException( + "Error occurred while parsing token endpoint URL", e); + } catch (RemoteSessionManagementException e) { + throw new OAuthTokenValidationException("Invalid token endpoint url", e); + } + + return stub; + } + + /** + * This is required to create a trusted connection with the external entity. + * Have to manually configure it since we use CommonHTTPTransport(axis2 notification) in axis2. + * + * @return an EasySSLProtocolSocketFactory for SSL communication. + */ + private EasySSLProtocolSocketFactory createProtocolSocketFactory() throws OAuthTokenValidationException { + try { + return new EasySSLProtocolSocketFactory(); + } catch (IOException e) { + String errorMsg = "Failed to initiate EasySSLProtocolSocketFactory."; + throw new OAuthTokenValidationException(errorMsg, e); + } catch (GeneralSecurityException e) { + String errorMsg = "Failed to set the key material in easy ssl factory."; + throw new OAuthTokenValidationException(errorMsg, e); + } + } + + /** + * This created httpclient pool that can be used to connect to external entity. This connection can be configured + * via broker.xml by setting up the required http connection parameters. + * + * @return an instance of HttpClient that is configured with MultiThreadedHttpConnectionManager + */ + private HttpClient createHttpClient() { + HttpConnectionManagerParams params = new HttpConnectionManagerParams(); + params.setDefaultMaxConnectionsPerHost(Integer.parseInt(tokenValidationProperties.get( + RemoteSessionConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST))); + params.setMaxTotalConnections(Integer.parseInt(tokenValidationProperties.get( + RemoteSessionConstants.MAXIMUM_TOTAL_HTTP_CONNECTION))); + HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); + connectionManager.setParams(params); + return new HttpClient(connectionManager); + } +} \ No newline at end of file diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/exception/OAuthTokenValidationException.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/exception/OAuthTokenValidationException.java new file mode 100644 index 0000000000..069aa11876 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/authentication/oauth/exception/OAuthTokenValidationException.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, 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.remote.session.authentication.oauth.exception; + +/** + * This Exception will be thrown, when there any interference with token validation flow. + */ +public class OAuthTokenValidationException extends Exception { + + public OAuthTokenValidationException(String msg, Exception nestedEx) { + super(msg, nestedEx); + } + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/constants/RemoteSessionConstants.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/constants/RemoteSessionConstants.java new file mode 100644 index 0000000000..33684eac20 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/constants/RemoteSessionConstants.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017, 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.remote.session.constants; + +/** + * This holds the constants related to remote session + */ +public class RemoteSessionConstants { + + public static final String SCOPE_IDENTIFIER = "scopes"; + public static final String TOKEN_VALIDATION_ENDPOINT_URL = "tokenValidationUrl"; + public static final String TOKEN_VALIDATION_CONTEX = "/services/OAuth2TokenValidationService"; + public static final String USERNAME = "username"; + public static final String PASSWORD = "password"; + public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss"; + public static final int MAX_BUFFER_SIZE = 640 * 1024; + + public enum CONNECTION_TYPE { + CLIENT, DEVICE + } + + public static final String QUERY_STRING = "queryString"; + public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection"; + public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost"; + public static final String DEFAULT_MAXIMUM_HTTP_CONNECTION_PER_HOST = "2"; + public static final String DEFAULT_MAXIMUM_TOTAL_HTTP_CONNECTIONS = "100"; + + // Initial remote connection operation related Constants + public static final String REMOTE_CONNECT = "REMOTE_CONNECT"; + public static final String REMOTE_CONNECT_CODE = "code"; + + private RemoteSessionConstants() { + } + + /** + * OAuthTokenValidator specific constants + */ + public final class OAuthTokenValidator { + public static final String COOKIE_KEY_VALUE_SEPERATOR = "="; + public static final String COOKIE_KEYPAIR_SEPERATOR = ";"; + public static final String COOKIE = "cookie"; + public static final String TOKEN_TYPE = "bearer"; + public static final String TOKEN_IDENTIFIER = "websocketToken"; + public static final String QUERY_STRING_SEPERATOR = "&"; + public static final String QUERY_KEY_VALUE_SEPERATOR = "="; + public static final String QUERY_STRING = "queryString"; + + private OAuthTokenValidator() { + } + } + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/RemoteSession.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/RemoteSession.java new file mode 100644 index 0000000000..5b2337c335 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/dto/RemoteSession.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017, 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.remote.session.dto; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.extensions.remote.session.constants.RemoteSessionConstants; +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; +import org.wso2.carbon.device.mgt.extensions.remote.session.internal.RemoteSessionManagementDataHolder; + +import javax.websocket.Session; +import java.io.IOException; +import java.nio.ByteBuffer; + +/** + * {@link RemoteSession} will represent remote websocket session + * This class implements the behaviours of sending message to the session in multithreaded context. + */ +public class RemoteSession { + + private static final Log log = LogFactory.getLog(RemoteSession.class); + private String tenantDomain, operationId, deviceType, deviceId; + private long lastMessageTimeStamp = System.currentTimeMillis(); + private RemoteSession peerSession; + private Session mySession; + private final Object writeLockObject = new Object(); + private int maxMessagesPerSecond; + private int messageAllowance; + private double messageRatePerSecond; + private RemoteSessionConstants.CONNECTION_TYPE connectionType; + + public RemoteSession(Session session, String tenantDomain, String deviceType, String deviceId, + RemoteSessionConstants.CONNECTION_TYPE connectionType) { + this.mySession = session; + this.deviceType = deviceType; + this.deviceId = deviceId; + this.tenantDomain = tenantDomain; + this.connectionType = connectionType; + maxMessagesPerSecond = RemoteSessionManagementDataHolder.getInstance().getMaxMessagesPerSecond(); + messageAllowance = maxMessagesPerSecond; + messageRatePerSecond = (double) maxMessagesPerSecond / 1000; + } + + private void sendMessage(Object message) throws RemoteSessionManagementException { + if (message != null) { + boolean isMessageCountExceed = false; + if (mySession != null && mySession.isOpen()) { + synchronized (writeLockObject) { + try { + isMessageCountExceed = applyRateLimit(); + if (!isMessageCountExceed) { + if (message instanceof String) { + mySession.getBasicRemote().sendText(message.toString()); + } else { + mySession.getBasicRemote().sendBinary(ByteBuffer.wrap((byte[]) message)); + } + this.lastMessageTimeStamp = System.currentTimeMillis(); + } else { + log.warn("Message count per second is exceeded for device id :" + deviceId); + } + } catch (IOException e) { + log.warn("Send data to session failed due to ", e); + } + } + } else { + throw new RemoteSessionManagementException("Peer Session already closed "); + } + } else { + throw new RemoteSessionManagementException("Message is empty"); + } + } + + public void sendMessageToPeer(Object message) throws RemoteSessionManagementException { + peerSession.sendMessage(message); + } + + /** + * Use for limit the messages for given time + * + * @return message rate applied + */ + private boolean applyRateLimit() { + long currentTime = System.currentTimeMillis(); + messageAllowance += (currentTime - lastMessageTimeStamp) * messageRatePerSecond; + if (messageAllowance > maxMessagesPerSecond) { + messageAllowance = maxMessagesPerSecond; + } + if (messageAllowance >= 1) { + lastMessageTimeStamp = currentTime; + messageAllowance -= 1; + return false; + } else { + return true; + } + } + + public Session getMySession() { + return mySession; + } + + public RemoteSession getPeerSession() { + return peerSession; + } + + public void setPeerSession(RemoteSession peerSession) { + this.peerSession = peerSession; + } + + public String getTenantDomain() { + return tenantDomain; + } + + public String getOperationId() { + return operationId; + } + + public void setOperationId(String operationId) { + this.operationId = operationId; + } + + public String getDeviceType() { + return deviceType; + } + + public String getDeviceId() { + return deviceId; + } + + public RemoteSessionConstants.CONNECTION_TYPE getConnectionType() { + return connectionType; + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/exception/RemoteSessionManagementException.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/exception/RemoteSessionManagementException.java new file mode 100644 index 0000000000..741f04e31a --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/exception/RemoteSessionManagementException.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 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.remote.session.exception; + + +import javax.websocket.CloseReason; + +/** + * This Exception will be thrown, when there any management issues with Remote Session. + */ +public class RemoteSessionManagementException extends Exception { + + CloseReason closeReason; + + public RemoteSessionManagementException(String msg) { + super(msg); + this.closeReason = new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, msg); + } + + public CloseReason getCloseReason() { + return closeReason; + } + + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java new file mode 100644 index 0000000000..ef92860f6f --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementDataHolder.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017, 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.remote.session.internal; + +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.OAuthAuthenticator; +import org.wso2.carbon.device.mgt.extensions.remote.session.dto.RemoteSession; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +/** + * Class {@link RemoteSessionManagementDataHolder} will hold the configurations and in memory storage strictures to + * manage remote sessions. + */ +public class RemoteSessionManagementDataHolder { + + private static RemoteSessionManagementDataHolder thisInstance = new RemoteSessionManagementDataHolder(); + private DeviceManagementProviderService deviceManagementProviderService; + private DeviceAccessAuthorizationService deviceAccessAuthorizationService; + private boolean isEnabled; + private String serverUrl; + private long maxIdleTimeout; + private int maxMessageBufferSize; + private int maxMessagesPerSecond; + private OAuthAuthenticator oAuthAuthenticator; + private Map activeDeviceClientSessionMap = new ConcurrentHashMap(); + private Map sessionMap = new ConcurrentHashMap(); + + public static RemoteSessionManagementDataHolder getInstance() { + return thisInstance; + } + + public DeviceManagementProviderService getDeviceManagementProviderService() { + return deviceManagementProviderService; + } + + public void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) { + this.deviceManagementProviderService = deviceManagementProviderService; + } + + public DeviceAccessAuthorizationService getDeviceAccessAuthorizationService() { + return deviceAccessAuthorizationService; + } + + public void setDeviceAccessAuthorizationService(DeviceAccessAuthorizationService deviceAccessAuthorizationService) { + this.deviceAccessAuthorizationService = deviceAccessAuthorizationService; + } + + public OAuthAuthenticator getOauthAuthenticator() { + return oAuthAuthenticator; + } + + public void setOauthAuthenticator(OAuthAuthenticator oAuthAuthenticator) { + this.oAuthAuthenticator = oAuthAuthenticator; + } + + public Map getSessionMap() { + return sessionMap; + } + + public Map getActiveDeviceClientSessionMap() { + return activeDeviceClientSessionMap; + } + + public boolean isEnabled() { + return isEnabled; + } + + public void setEnabled(boolean enabled) { + isEnabled = enabled; + } + + public String getServerUrl() { + return serverUrl; + } + + public void setServerUrl(String serverUrl) { + this.serverUrl = serverUrl; + } + + public int getMaxMessagesPerSecond() { + return maxMessagesPerSecond; + } + + public void setMaxMessagesPerSecond(int maxMessagesPerSecond) { + this.maxMessagesPerSecond = maxMessagesPerSecond; + } + + public long getMaxIdleTimeout() { + return maxIdleTimeout; + } + + public void setMaxIdleTimeout(long maxIdleTimeout) { + this.maxIdleTimeout = maxIdleTimeout; + } + + public int getMaxMessageBufferSize() { + return maxMessageBufferSize; + } + + public void setMaxMessageBufferSize(int MaxMessageBufferSize) { + this.maxMessageBufferSize = MaxMessageBufferSize; + } +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementServiceComponent.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementServiceComponent.java new file mode 100644 index 0000000000..da394210cd --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/internal/RemoteSessionManagementServiceComponent.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017, 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.remote.session.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.BundleContext; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.extensions.remote.session.RemoteSessionManagementService; +import org.wso2.carbon.device.mgt.extensions.remote.session.RemoteSessionManagementServiceImpl; +import org.wso2.carbon.device.mgt.extensions.remote.session.listener.RemoteSessionManagerStartupListener; + +/** + * @scr.component name="RemoteSessionManagementServiceComponent" 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="device.manager.service" + * interface="org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationService" + * cardinality="0..n" + * policy="dynamic" + * bind="setDeviceAccessAuthorizationService" + * unbind="unsetDeviceAccessAuthorizationService" + */ + +public class RemoteSessionManagementServiceComponent { + + private static final Log log = LogFactory.getLog(RemoteSessionManagementServiceComponent.class); + + protected void activate(ComponentContext componentContext) { + try { + + BundleContext bundleContext = componentContext.getBundleContext(); + bundleContext.registerService(ServerStartupObserver.class.getName(), new + RemoteSessionManagerStartupListener(), null); + bundleContext.registerService(RemoteSessionManagementService.class.getName(), new + RemoteSessionManagementServiceImpl(), null); + if (log.isDebugEnabled()) { + log.debug("Remote Session device access service implementation bundle has been successfully " + + "initialized"); + } + } catch (Throwable e) { + log.error("Error occurred while initializing Remote Session device access service " + + "implementation bundle", e); + } + } + + protected void deactivate(ComponentContext componentContext) { + //Do nothing + } + + protected void setDeviceManagementProviderService(DeviceManagementProviderService deviceManagementProviderService) { + RemoteSessionManagementDataHolder.getInstance() + .setDeviceManagementProviderService(deviceManagementProviderService); + } + + protected void unsetDeviceManagementProviderService(DeviceManagementProviderService + deviceManagementProviderService) { + RemoteSessionManagementDataHolder.getInstance().setDeviceManagementProviderService(null); + } + + protected void setDeviceAccessAuthorizationService(DeviceAccessAuthorizationService + deviceAccessAuthorizationService) { + RemoteSessionManagementDataHolder.getInstance() + .setDeviceAccessAuthorizationService(deviceAccessAuthorizationService); + } + + protected void unsetDeviceAccessAuthorizationService(DeviceAccessAuthorizationService + deviceAccessAuthorizationService) { + RemoteSessionManagementDataHolder.getInstance().setDeviceManagementProviderService(null); + } + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java new file mode 100644 index 0000000000..8236cb848b --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/listener/RemoteSessionManagerStartupListener.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2017, 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.remote.session.listener; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.core.ServerStartupObserver; +import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.keymanager.KeyManagerConfigurations; +import org.wso2.carbon.device.mgt.core.config.remote.session.RemoteSessionConfiguration; +import org.wso2.carbon.device.mgt.extensions.remote.session.authentication.OAuthAuthenticator; +import org.wso2.carbon.device.mgt.extensions.remote.session.constants.RemoteSessionConstants; +import org.wso2.carbon.device.mgt.extensions.remote.session.internal.RemoteSessionManagementDataHolder; +import org.wso2.carbon.utils.multitenancy.MultitenantConstants; + +import java.util.HashMap; +import java.util.Map; + +/** + * Startup listener is been used to make sure the receiver gets activated after the server start up to avoid + * Bundle not loading issues. + * This will configure the values for remote session management + */ +public class RemoteSessionManagerStartupListener implements ServerStartupObserver { + + private static final Log log = LogFactory.getLog(RemoteSessionManagerStartupListener.class); + + @Override + public void completingServerStartup() { + } + + @Override + public void completedServerStartup() { + PrivilegedCarbonContext.startTenantFlow(); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain( + MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true); + try { + RemoteSessionConfiguration rsConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig + ().getRemoteSessionConfiguration(); + KeyManagerConfigurations kmConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig() + .getKeyManagerConfigurations(); + + RemoteSessionManagementDataHolder.getInstance().setEnabled(rsConfig.isEnabled()); + RemoteSessionManagementDataHolder.getInstance().setServerUrl(rsConfig.getRemoteSessionServerUrl()); + Map configProperties = new HashMap<>(); + + // Set max idle timeout in milliseconds + RemoteSessionManagementDataHolder.getInstance().setMaxIdleTimeout((long) rsConfig.getSessionIdleTimeOut() * + 60000); + // Set max buffer size for messages. + if (rsConfig.getMaxMessageBufferSize() > 0) { + RemoteSessionManagementDataHolder.getInstance() + .setMaxMessageBufferSize(rsConfig.getMaxMessageBufferSize() * 1024); + } else { + RemoteSessionManagementDataHolder.getInstance(). + setMaxMessageBufferSize(RemoteSessionConstants.MAX_BUFFER_SIZE); + } + + // Set max messages per second. + if (rsConfig.getMaxMessagesPerSession() > 0) { + RemoteSessionManagementDataHolder.getInstance().setMaxMessagesPerSecond(rsConfig + .getMaxMessagesPerSession()); + } + // Token validation related configuration + configProperties.put(RemoteSessionConstants.TOKEN_VALIDATION_ENDPOINT_URL, kmConfig.getServerUrl()); + configProperties.put(RemoteSessionConstants.USERNAME, kmConfig.getAdminUsername()); + configProperties.put(RemoteSessionConstants.PASSWORD, kmConfig.getAdminPassword()); + if (rsConfig.getMaxHTTPConnectionPerHost() > 0) { + + configProperties.put(RemoteSessionConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST, + String.valueOf(rsConfig.getMaxHTTPConnectionPerHost())); + } else { + configProperties.put(RemoteSessionConstants.MAXIMUM_HTTP_CONNECTION_PER_HOST, RemoteSessionConstants + .DEFAULT_MAXIMUM_HTTP_CONNECTION_PER_HOST); + } + if (rsConfig.getMaxTotalHTTPConnections() > 0) { + configProperties.put(RemoteSessionConstants.MAXIMUM_TOTAL_HTTP_CONNECTION, String.valueOf(rsConfig + .getMaxTotalHTTPConnections())); + } else { + configProperties.put(RemoteSessionConstants.MAXIMUM_TOTAL_HTTP_CONNECTION, RemoteSessionConstants + .DEFAULT_MAXIMUM_TOTAL_HTTP_CONNECTIONS); + } + + OAuthAuthenticator oAuthAuthenticator = new OAuthAuthenticator(); + oAuthAuthenticator.init(configProperties); + RemoteSessionManagementDataHolder.getInstance().setOauthAuthenticator(oAuthAuthenticator); + + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + +} diff --git a/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/util/PropertyUtils.java b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/util/PropertyUtils.java new file mode 100644 index 0000000000..cb63b97ac8 --- /dev/null +++ b/components/extensions/remote-session-extension/org.wso2.carbon.device.mgt.extensions.remote.session/src/main/java/org/wso2/carbon/device/mgt/extensions/remote.session/util/PropertyUtils.java @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2017, 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.remote.session.util; + +import org.wso2.carbon.device.mgt.extensions.remote.session.exception.RemoteSessionManagementException; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Class for reading web socket url parameters + */ +public class PropertyUtils { + + /** + * Replace URL with placeholders with properties + * @param urlWithPlaceholders URL + * @return replaced url + * @throws RemoteSessionManagementException + */ + public static String replaceProperty(String urlWithPlaceholders) throws RemoteSessionManagementException { + String regex = "\\$\\{(.*?)\\}"; + Pattern pattern = Pattern.compile(regex); + Matcher matchPattern = pattern.matcher(urlWithPlaceholders); + while (matchPattern.find()) { + String sysPropertyName = matchPattern.group(1); + String sysPropertyValue = System.getProperty(sysPropertyName); + if (sysPropertyValue != null && !sysPropertyName.isEmpty()) { + urlWithPlaceholders = urlWithPlaceholders.replaceAll("\\$\\{(" + sysPropertyName + ")\\}", sysPropertyValue); + } else { + throw new RemoteSessionManagementException("System property - " + sysPropertyName + + " is not defined, hence cannot resolve : " + urlWithPlaceholders); + } + } + return urlWithPlaceholders; + } +} diff --git a/components/extensions/remote-session-extension/pom.xml b/components/extensions/remote-session-extension/pom.xml new file mode 100644 index 0000000000..0c0dc7e29f --- /dev/null +++ b/components/extensions/remote-session-extension/pom.xml @@ -0,0 +1,59 @@ + + + + + + + org.wso2.carbon.devicemgt-plugins + extensions + 4.0.100-SNAPSHOT + ../pom.xml + + + 4.0.0 + remote-session-extension + pom + WSO2 Carbon - Remote Sessions Extension + http://wso2.org + + + org.wso2.carbon.device.mgt.extensions.remote.session + org.wso2.carbon.device.mgt.extensions.remote.session.endpoint + + + + + + + org.apache.felix + maven-scr-plugin + ${maven.scr.version} + + + generate-scr-scrdescriptor + + scr + + + + + + + + diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/pom.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/pom.xml similarity index 89% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/pom.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/pom.xml index ba4de2247c..b6f55e1a31 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/pom.xml +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/pom.xml @@ -20,14 +20,14 @@ org.wso2.carbon.devicemgt-plugins siddhi-extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 - org.wso2.extension.siddhi.devicegroup + org.wso2.extension.siddhi.device bundle - WSO2 Siddhi Execution Extension - Check device belongs to a group + WSO2 Siddhi Execution Extension - Device management Core functionality as Siddhi extension http://wso2.org @@ -51,6 +51,10 @@ log4j log4j + + org.json.wso2 + json + com.h2database.wso2 h2-database-engine @@ -91,16 +95,6 @@ commons-logging-api RELEASE - - org.wso2.carbon.devicemgt-plugins - org.wso2.carbon.appmgt.mdm.restconnector - 4.0.91-SNAPSHOT - - - asm - asm - RELEASE - asm asm @@ -127,10 +121,11 @@ ${project.artifactId} ${project.artifactId} - org.wso2.extension.siddhi.devicegroup, - org.wso2.extension.siddhi.devicegroup.* + org.wso2.extension.siddhi.device, + org.wso2.extension.siddhi.device.* + org.json;version="${orbit.version.json.range}", org.wso2.siddhi.core.*, org.wso2.siddhi.query.api.*, org.wso2.carbon.device.mgt.core.*, diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfStatusFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfStatusFunctionExecutor.java new file mode 100644 index 0000000000..032021890a --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfStatusFunctionExecutor.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2017, 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.extension.siddhi.device; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +import java.util.List; + +/** + * getDevicesOfStatus(status [, deviceType]) + * Returns devices with specified status + * Accept Type(s): (STRING, STRING) + * Return Type(s): (STRING) + */ +public class GetDevicesOfStatusFunctionExecutor extends FunctionExecutor { + + private static Log log = LogFactory.getLog(GetDevicesOfStatusFunctionExecutor.class); + private Attribute.Type returnType = Attribute.Type.STRING; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 1 && attributeExpressionExecutors.length != 2) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to device:getDevicesOfStatus() function, required 2 but found " + + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument (status) of device:getDevicesOfStatus() " + + "function, required " + Attribute.Type.STRING + " as status, but found " + + attributeExpressionExecutors[0].getReturnType().toString()); + } + if (attributeExpressionExecutors.length == 2 + && attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument (device type) of device:getDevicesOfStatus() " + + "function, required " + Attribute.Type.STRING + " as device type, but found " + + attributeExpressionExecutors[1].getReturnType().toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfStatus() function. " + + "First argument cannot be null"); + } + if (data.length == 2 && data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfStatus() function. " + + "Second argument cannot be null"); + } + String status = (String) data[0]; + String deviceType = null; + if (data.length == 2) { + deviceType = (String) data[1]; + } + + JSONArray deviceIds = new JSONArray(); + try { + DeviceManagementProviderService deviceManagementProviderService = DeviceUtils.getDeviceManagementProviderService(); + List devices = deviceManagementProviderService.getDevicesByStatus(EnrolmentInfo.Status.valueOf(status), false); + for (Device device : devices) { + if (deviceType == null || deviceType.equalsIgnoreCase(device.getType())) { + deviceIds.put(device.getDeviceIdentifier()); + } + } + } catch (DeviceManagementException e) { + log.error("Error occurred while getting devices with status " + status, e); + } + return deviceIds.toString(); + } + + @Override + protected Object execute(Object data) { + return execute(new Object[]{data}); + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfUserFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfUserFunctionExecutor.java new file mode 100644 index 0000000000..27a82530eb --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/GetDevicesOfUserFunctionExecutor.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2017, 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.extension.siddhi.device; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +import java.util.List; + +/** + * getDevicesOfUser(user , deviceType [, status]) + * Returns list of ids of devices belongs to a user + * Accept Type(s): (STRING, STRING, STRING) + * Return Type(s): (STRING) + */ +public class GetDevicesOfUserFunctionExecutor extends FunctionExecutor { + + private static Log log = LogFactory.getLog(GetDevicesOfUserFunctionExecutor.class); + private Attribute.Type returnType = Attribute.Type.STRING; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 2 && attributeExpressionExecutors.length != 3) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to device:getDevicesOfUser() function, minimum 2, or 3 with " + + "optional. but found " + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument (user) of device:getDevicesOfUser() " + + "function, required " + Attribute.Type.STRING + " as user, but found " + + attributeExpressionExecutors[0].getReturnType().toString()); + } + if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument (device type) of device:getDevicesOfUser() " + + "function, required " + Attribute.Type.STRING + " as device type, but found " + + attributeExpressionExecutors[1].getReturnType().toString()); + } + if (attributeExpressionExecutors.length == 3 + && attributeExpressionExecutors[2].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid optional parameter type found for the third argument (status) of " + + "device:getDevicesOfUser() function, required " + Attribute.Type.STRING + " as status, but found " + + attributeExpressionExecutors[2].getReturnType().toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "First argument cannot be null"); + } + if (data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "Second argument cannot be null"); + } + if (data.length == 3 && data[2] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "Third argument cannot be null"); + } + String user = (String) data[0]; + String deviceType = (String) data[1]; + String status = null; + if (data.length == 3) { + status = (String) data[2]; + } + + JSONArray deviceIds = new JSONArray(); + try { + DeviceManagementProviderService deviceManagementProviderService = DeviceUtils.getDeviceManagementProviderService(); + List devices = deviceManagementProviderService.getDevicesOfUser(user, deviceType, false); + for (Device device : devices) { + if (status == null || status.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { + deviceIds.put(device.getDeviceIdentifier()); + } + } + } catch (DeviceManagementException e) { + log.error("Error occurred while getting " + deviceType + " devices of user " + user + + ", with status " + status, e); + } + return deviceIds.toString(); + } + + @Override + protected Object execute(Object data) { + return null; //Since the getDevicesOfUser function takes in 2 or 3 parameters, this method does not get called. Hence,not implemented. + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfStatusFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfStatusFunctionExecutor.java new file mode 100644 index 0000000000..944394a1b9 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfStatusFunctionExecutor.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2017, 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.extension.siddhi.device; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.EnrolmentInfo; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +import java.util.List; + +/** + * hasDevicesOfStatus(status [, deviceType]) + * Returns true if there are devices with specified status + * Accept Type(s): (STRING, STRING) + * Return Type(s): (BOOL) + */ +public class HasDevicesOfStatusFunctionExecutor extends FunctionExecutor { + + private static Log log = LogFactory.getLog(HasDevicesOfStatusFunctionExecutor.class); + private Attribute.Type returnType = Attribute.Type.BOOL; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 1 && attributeExpressionExecutors.length != 2) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to device:hasDevicesOfStatus() function, required 2 but found " + + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument (status) of device:hasDevicesOfStatus() " + + "function, required " + Attribute.Type.STRING + " as status, but found " + + attributeExpressionExecutors[0].getReturnType().toString()); + } + if (attributeExpressionExecutors.length == 2 + && attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument (device type) of device:hasDevicesOfStatus() " + + "function, required " + Attribute.Type.STRING + " as device type, but found " + + attributeExpressionExecutors[1].getReturnType().toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:hasDevicesOfStatus() function. " + + "First argument cannot be null"); + } + if (data.length == 2 && data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:hasDevicesOfStatus() function. " + + "Second argument cannot be null"); + } + String status = (String) data[0]; + String deviceType = null; + if (data.length == 2) { + deviceType = (String) data[1]; + } + try { + DeviceManagementProviderService deviceManagementProviderService = DeviceUtils.getDeviceManagementProviderService(); + List devices = deviceManagementProviderService.getDevicesByStatus(EnrolmentInfo.Status.valueOf(status), false); + if (deviceType == null) { + return !devices.isEmpty(); + } else { + for (Device device : devices) { + if (deviceType.equalsIgnoreCase(device.getType())) { + return true; + } + } + return false; + } + } catch (DeviceManagementException e) { + log.error("Error occurred while getting devices with status " + status, e); + } + return false; + } + + @Override + protected Object execute(Object data) { + return execute(new Object[]{data}); + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfUserFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfUserFunctionExecutor.java new file mode 100644 index 0000000000..ffb72c7f67 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/HasDevicesOfUserFunctionExecutor.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2017, 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.extension.siddhi.device; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.wso2.carbon.device.mgt.common.Device; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +import java.util.List; + +/** + * hasDevicesOfUser(user , deviceType [, status]) + * Returns true if there are devices belonging to user + * Accept Type(s): (STRING, STRING, STRING) + * Return Type(s): (BOOL) + */ +public class HasDevicesOfUserFunctionExecutor extends FunctionExecutor { + + private static Log log = LogFactory.getLog(HasDevicesOfUserFunctionExecutor.class); + private Attribute.Type returnType = Attribute.Type.BOOL; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 2 && attributeExpressionExecutors.length != 3) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to device:getDevicesOfUser() function, minimum 2, or 3 with " + + "optional. but found " + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument (user) of device:getDevicesOfUser() " + + "function, required " + Attribute.Type.STRING + " as user, but found " + + attributeExpressionExecutors[0].getReturnType().toString()); + } + if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument (device type) of device:getDevicesOfUser() " + + "function, required " + Attribute.Type.STRING + " as device type, but found " + + attributeExpressionExecutors[1].getReturnType().toString()); + } + if (attributeExpressionExecutors.length == 3 + && attributeExpressionExecutors[2].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid optional parameter type found for the third argument (status) of " + + "device:getDevicesOfUser() function, required " + Attribute.Type.STRING + " as status, but found " + + attributeExpressionExecutors[2].getReturnType().toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "First argument cannot be null"); + } + if (data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "Second argument cannot be null"); + } + if (data.length == 3 && data[2] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:getDevicesOfUser() function. " + + "Third argument cannot be null"); + } + String user = (String) data[0]; + String deviceType = (String) data[1]; + String status = null; + if (data.length == 3) { + status = (String) data[2]; + } + + try { + DeviceManagementProviderService deviceManagementProviderService = DeviceUtils.getDeviceManagementProviderService(); + List devices = deviceManagementProviderService.getDevicesOfUser(user, deviceType, false); + if (status == null) { + return !devices.isEmpty(); + } else { + for (Device device : devices) { + if (status.equalsIgnoreCase(device.getEnrolmentInfo().getStatus().toString())) { + return true; + } + } + return false; + } + } catch (DeviceManagementException e) { + log.error("Error occurred while getting " + deviceType + " devices of user " + user + + ", with status " + status, e); + } + return false; + } + + @Override + protected Object execute(Object data) { + return null; //Since the getDevicesOfUser function takes in 2 or 3 parameters, this method does not get called. Hence,not implemented. + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsEnrolledFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsEnrolledFunctionExecutor.java new file mode 100644 index 0000000000..f1893e33a3 --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsEnrolledFunctionExecutor.java @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2017, 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.extension.siddhi.device; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.device.mgt.common.DeviceIdentifier; +import org.wso2.carbon.device.mgt.common.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; +import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; +import org.wso2.siddhi.core.config.ExecutionPlanContext; +import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; +import org.wso2.siddhi.core.executor.ExpressionExecutor; +import org.wso2.siddhi.core.executor.function.FunctionExecutor; +import org.wso2.siddhi.query.api.definition.Attribute; +import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; + +/** + * isEnrolled(deviceId, deviceType) + * Returns true if device enrolled. + * Accept Type(s): (STRING, STRING) + * Return Type(s): (BOOL) + */ +public class IsEnrolledFunctionExecutor extends FunctionExecutor { + + private static Log log = LogFactory.getLog(IsEnrolledFunctionExecutor.class); + private Attribute.Type returnType = Attribute.Type.BOOL; + + @Override + protected void init(ExpressionExecutor[] attributeExpressionExecutors, + ExecutionPlanContext executionPlanContext) { + if (attributeExpressionExecutors.length != 2) { + throw new ExecutionPlanValidationException( + "Invalid no of arguments passed to device:isEnrolled() function, required 2, but found " + + attributeExpressionExecutors.length); + } + if (attributeExpressionExecutors[0].getReturnType()!= Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the first argument (deviceId) of device:isEnrolled() " + + "function, required " + Attribute.Type.STRING + ", but found " + + attributeExpressionExecutors[0].getReturnType().toString()); + } + if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { + throw new ExecutionPlanValidationException( + "Invalid parameter type found for the second argument (deviceType) of device:isEnrolled() " + + "function, required " + Attribute.Type.STRING + ", but found " + + attributeExpressionExecutors[1].getReturnType().toString()); + } + } + + @Override + protected Object execute(Object[] data) { + if (data[0] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:isEnrolled() function. " + + "First argument cannot be null"); + } + if (data[1] == null) { + throw new ExecutionPlanRuntimeException("Invalid input given to device:isEnrolled() function. " + + "Second argument cannot be null"); + } + + String deviceId = (String) data[0]; + String deviceType = (String) data[1]; + + DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); + try { + DeviceManagementProviderService deviceManagementService = DeviceUtils.getDeviceManagementProviderService(); + return deviceManagementService.isEnrolled(deviceIdentifier); + } catch (DeviceManagementException e) { + log.error("Error occurred while checking device is enrolled.", e); + } + return false; + } + + @Override + protected Object execute(Object data) { + return null; //Since the getDevicesOfUser function takes in 2 parameters, this method does not get called. Hence,not implemented. + } + + @Override + public void start() { + //Nothing to start + } + + @Override + public void stop() { + //Nothing to stop + } + + @Override + public Attribute.Type getReturnType() { + return returnType; + } + + @Override + public Object[] currentState() { + return null; //No need to maintain a state. + } + + @Override + public void restoreState(Object[] state) { + //Since there's no need to maintain a state, nothing needs to be done here. + } +} diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/IsDeviceInGroupFunctionExecutor.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsInGroupFunctionExecutor.java similarity index 83% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/IsDeviceInGroupFunctionExecutor.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsInGroupFunctionExecutor.java index 5072b6385c..56b52ef952 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/IsDeviceInGroupFunctionExecutor.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/IsInGroupFunctionExecutor.java @@ -16,14 +16,14 @@ * under the License. */ -package org.wso2.extension.siddhi.devicegroup; +package org.wso2.extension.siddhi.device; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; -import org.wso2.extension.siddhi.devicegroup.utils.DeviceGroupUtils; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; import org.wso2.siddhi.core.config.ExecutionPlanContext; import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException; import org.wso2.siddhi.core.executor.ExpressionExecutor; @@ -33,14 +33,14 @@ import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; /** - * isDeviceInGroup(deviceId , groupId) + * isInGroup(groupId, deviceId, deviceType) * Returns true if device belongs to group, otherwise false. - * Accept Type(s): (STRING, INTEGER) + * Accept Type(s): (INTEGER, STRING, STRING) * Return Type(s): (BOOL) */ -public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { +public class IsInGroupFunctionExecutor extends FunctionExecutor { - private static Log log = LogFactory.getLog(IsDeviceInGroupFunctionExecutor.class); + private static Log log = LogFactory.getLog(IsInGroupFunctionExecutor.class); private Attribute.Type returnType = Attribute.Type.BOOL; @Override @@ -48,24 +48,24 @@ public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { ExecutionPlanContext executionPlanContext) { if (attributeExpressionExecutors.length != 3) { throw new ExecutionPlanValidationException( - "Invalid no of arguments passed to group:isDeviceInGroup() function, required 3, but found " + "Invalid no of arguments passed to device:isInGroup() function, required 3, but found " + attributeExpressionExecutors.length); } if (attributeExpressionExecutors[0].getReturnType()!= Attribute.Type.INT) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the first argument (group id) of group:isDeviceInGroup() " + + "Invalid parameter type found for the first argument (group id) of device:isInGroup() " + "function, required " + Attribute.Type.INT + ", but found " + attributeExpressionExecutors[0].getReturnType().toString()); } if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the second argument (device id) of group:isDeviceInGroup() " + + "Invalid parameter type found for the second argument (device id) of device:isInGroup() " + "function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType().toString()); } if (attributeExpressionExecutors[2].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the third argument (device type) of group:isDeviceInGroup() " + + "Invalid parameter type found for the third argument (device type) of device:isInGroup() " + "function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[2].getReturnType().toString()); } @@ -74,15 +74,15 @@ public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { @Override protected Object execute(Object[] data) { if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to group:isDeviceInGroup() function. " + + throw new ExecutionPlanRuntimeException("Invalid input given to device:isInGroup() function. " + "First argument cannot be null"); } if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to group:isDeviceInGroup() function. " + + throw new ExecutionPlanRuntimeException("Invalid input given to device:isInGroup() function. " + "Second argument cannot be null"); } if (data[2] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to group:isDeviceInGroup() function. " + + throw new ExecutionPlanRuntimeException("Invalid input given to device:isInGroup() function. " + "Third argument cannot be null"); } Integer groupId = (Integer) data[0]; @@ -90,7 +90,7 @@ public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { String deviceType = (String) data[2]; DeviceIdentifier deviceIdentifier = new DeviceIdentifier(deviceId, deviceType); - GroupManagementProviderService groupManagementService = DeviceGroupUtils.getGroupManagementProviderService(); + GroupManagementProviderService groupManagementService = DeviceUtils.getGroupManagementProviderService(); try { return groupManagementService.isDeviceMappedToGroup(groupId, deviceIdentifier); } catch (GroupManagementException e) { @@ -101,7 +101,7 @@ public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { @Override protected Object execute(Object data) { - return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented. + return null; //Since the isInGroup function takes in 3 parameters, this method does not get called. Hence,not implemented. } @Override @@ -129,5 +129,3 @@ public class IsDeviceInGroupFunctionExecutor extends FunctionExecutor { //Since there's no need to maintain a state, nothing needs to be done here. } } - - diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/utils/DeviceGroupUtils.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/utils/DeviceUtils.java similarity index 54% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/utils/DeviceGroupUtils.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/utils/DeviceUtils.java index 700d5fa025..897e026c67 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/java/org/wso2/extension/siddhi/devicegroup/utils/DeviceGroupUtils.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/java/org/wso2/extension/siddhi/device/utils/DeviceUtils.java @@ -15,48 +15,53 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.extension.siddhi.devicegroup.utils; +package org.wso2.extension.siddhi.device.utils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService; /** * This class holds utility methods to retrieve data. */ -public class DeviceGroupUtils { +public class DeviceUtils { - private static Log log = LogFactory.getLog(DeviceGroupUtils.class); - private static GroupManagementProviderService groupManagementProviderServiceForTest; + private static Log log = LogFactory.getLog(DeviceUtils.class); + private static DeviceManagementProviderService deviceManagementProviderService; + private static GroupManagementProviderService groupManagementProviderService; - private DeviceGroupUtils(){ + private DeviceUtils(){ + } + public static DeviceManagementProviderService getDeviceManagementProviderService() { + if (deviceManagementProviderService != null) { + return deviceManagementProviderService; + } + PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); + deviceManagementProviderService = + (DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null); + if (deviceManagementProviderService == null) { + String msg = "Device Management service has not initialized."; + log.error(msg); + throw new IllegalStateException(msg); + } + return deviceManagementProviderService; } public static GroupManagementProviderService getGroupManagementProviderService() { - if (groupManagementProviderServiceForTest != null) { - return groupManagementProviderServiceForTest; + if (groupManagementProviderService != null) { + return groupManagementProviderService; } PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - GroupManagementProviderService groupManagementProviderService = + groupManagementProviderService = (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null); if (groupManagementProviderService == null) { - String msg = "GroupImpl Management service has not initialized."; + String msg = "Group Management service has not initialized."; log.error(msg); throw new IllegalStateException(msg); } return groupManagementProviderService; } - - /** - * This method is only to set groupManagementProviderService locally for testing as OSGi framework cannot start - * with testng to register the groupManagementProviderService. Hence setting groupManagementProviderService from - * CheckDeviceInGroupExtensionTestCase - * @param groupManagementProviderServiceForTest to be set. - */ - public static void setGroupManagementProviderServiceForTest( - GroupManagementProviderService groupManagementProviderServiceForTest) { - DeviceGroupUtils.groupManagementProviderServiceForTest = groupManagementProviderServiceForTest; - } } diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/resources/device.siddhiext b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/resources/device.siddhiext new file mode 100644 index 0000000000..84dd50b95f --- /dev/null +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/main/resources/device.siddhiext @@ -0,0 +1,24 @@ +# +# Copyright (c) 2017, 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. +# + +isInGroup=org.wso2.extension.siddhi.device.IsInGroupFunctionExecutor +getDevicesOfUser=org.wso2.extension.siddhi.device.GetDevicesOfUserFunctionExecutor +hasDevicesOfUser=org.wso2.extension.siddhi.device.HasDevicesOfUserFunctionExecutor +getDevicesOfStatus=org.wso2.extension.siddhi.device.GetDevicesOfStatusFunctionExecutor +hasDevicesOfStatus=org.wso2.extension.siddhi.device.HasDevicesOfStatusFunctionExecutor +isEnrolled=org.wso2.extension.siddhi.device.IsEnrolledFunctionExecutor diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/BaseDeviceManagementTest.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/BaseDeviceManagementTest.java similarity index 96% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/BaseDeviceManagementTest.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/BaseDeviceManagementTest.java index 93aac646b5..ce6130c06d 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/BaseDeviceManagementTest.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/BaseDeviceManagementTest.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.extension.siddhi.devicegroup; +package org.wso2.extension.siddhi.device; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -32,8 +32,8 @@ import org.wso2.carbon.device.mgt.core.dao.GroupManagementDAOFactory; import org.wso2.carbon.device.mgt.core.notification.mgt.dao.NotificationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory; import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil; -import org.wso2.extension.siddhi.devicegroup.test.util.DataSourceConfig; -import org.wso2.extension.siddhi.devicegroup.test.util.TestUtils; +import org.wso2.extension.siddhi.device.test.util.DataSourceConfig; +import org.wso2.extension.siddhi.device.test.util.TestUtils; import javax.sql.DataSource; import javax.xml.bind.JAXBContext; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/CheckDeviceInGroupExtensionTestCase.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/ExtensionTestCase.java similarity index 50% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/CheckDeviceInGroupExtensionTestCase.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/ExtensionTestCase.java index adb76beb37..801b9e93ab 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/CheckDeviceInGroupExtensionTestCase.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/ExtensionTestCase.java @@ -16,13 +16,12 @@ * under the License. */ -package org.wso2.extension.siddhi.devicegroup; +package org.wso2.extension.siddhi.device; import org.apache.log4j.Logger; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; -import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceManagementException; @@ -47,11 +46,11 @@ import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.user.core.UserStoreException; import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.utils.multitenancy.MultitenantConstants; -import org.wso2.extension.siddhi.devicegroup.test.util.SiddhiTestHelper; -import org.wso2.extension.siddhi.devicegroup.test.util.TestDataHolder; -import org.wso2.extension.siddhi.devicegroup.test.util.TestDeviceManagementService; -import org.wso2.extension.siddhi.devicegroup.test.util.TestUtils; -import org.wso2.extension.siddhi.devicegroup.utils.DeviceGroupUtils; +import org.wso2.extension.siddhi.device.test.util.SiddhiTestHelper; +import org.wso2.extension.siddhi.device.test.util.TestDataHolder; +import org.wso2.extension.siddhi.device.test.util.TestDeviceManagementService; +import org.wso2.extension.siddhi.device.test.util.TestUtils; +import org.wso2.extension.siddhi.device.utils.DeviceUtils; import org.wso2.siddhi.core.ExecutionPlanRuntime; import org.wso2.siddhi.core.SiddhiManager; import org.wso2.siddhi.core.event.Event; @@ -60,39 +59,56 @@ import org.wso2.siddhi.core.stream.input.InputHandler; import org.wso2.siddhi.core.util.EventPrinter; import java.io.InputStream; +import java.lang.reflect.Field; import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import static org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants.Permissions.DEFAULT_ADMIN_PERMISSIONS; import static org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroupConstants.Roles.DEFAULT_ADMIN_ROLE; -public class CheckDeviceInGroupExtensionTestCase extends BaseDeviceManagementTest { - private static final Logger log = Logger.getLogger(CheckDeviceInGroupExtensionTestCase.class); +public class ExtensionTestCase extends BaseDeviceManagementTest { + private static final Logger log = Logger.getLogger(ExtensionTestCase.class); private AtomicInteger count = new AtomicInteger(0); private volatile boolean eventArrived; private GroupManagementProviderService groupManagementProviderService; - private DeviceManagementProviderService deviceMgtService; + private DeviceManagementProviderService deviceManagementProviderService; private static String DEVICE_TYPE = "Test"; + private QueryCallback queryCallback = new QueryCallback() { + @Override + public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { + EventPrinter.print(timeStamp, inEvents, removeEvents); + for (Event event : inEvents) { + count.incrementAndGet(); + eventArrived = true; + } + } + }; + @BeforeClass @Override public void init() throws Exception { log.info("Initializing"); - count.set(0); - eventArrived = false; groupManagementProviderService = new GroupManagementProviderServiceImpl(); - deviceMgtService = new DeviceManagementProviderServiceImpl(); - DeviceGroupUtils.setGroupManagementProviderServiceForTest(groupManagementProviderService); + deviceManagementProviderService = new DeviceManagementProviderServiceImpl(); DeviceManagementServiceComponent.notifyStartupListeners(); - DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService); + DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProviderService); DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService()); DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl()); DeviceManagementDataHolder.getInstance().setGroupManagementProviderService(groupManagementProviderService); DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null); - deviceMgtService.registerDeviceType( + deviceManagementProviderService.registerDeviceType( new TestDeviceManagementService(DEVICE_TYPE, MultitenantConstants.SUPER_TENANT_DOMAIN_NAME)); + + Field deviceManagementProviderServiceField = DeviceUtils.class.getDeclaredField("deviceManagementProviderService"); + deviceManagementProviderServiceField.setAccessible(true); + deviceManagementProviderServiceField.set(null, deviceManagementProviderService); + + Field groupManagementProviderServiceField = DeviceUtils.class.getDeclaredField("groupManagementProviderService"); + groupManagementProviderServiceField.setAccessible(true); + groupManagementProviderServiceField.set(null, groupManagementProviderService); } private RegistryService getRegistryService() throws RegistryException, UserStoreException, @@ -119,7 +135,7 @@ public class CheckDeviceInGroupExtensionTestCase extends BaseDeviceManagementTes public void enrollDevice() { Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE); try { - boolean enrollmentStatus = deviceMgtService.enrollDevice(device); + boolean enrollmentStatus = deviceManagementProviderService.enrollDevice(device); Assert.assertTrue(enrollmentStatus); } catch (DeviceManagementException e) { String msg = "Error Occurred while enrolling device"; @@ -140,25 +156,18 @@ public class CheckDeviceInGroupExtensionTestCase extends BaseDeviceManagementTes } @Test(dependsOnMethods = {"addDevices"}) - public void testIsDeviceInGroupExtension() throws InterruptedException, GroupManagementException { - log.info("IsDeviceInGroup TestCase"); + public void testIsInGroupExtension() throws InterruptedException, GroupManagementException { + log.info("IsInGroup TestCase"); SiddhiManager siddhiManager = new SiddhiManager(); + count.set(0); + eventArrived = false; + String inStreamDefinition = "define stream inputStream (groupId int, deviceId string, deviceType string);"; - String query = ("@info(name = 'query1') from inputStream[devicegroup:isDeviceInGroup(groupId, deviceId, deviceType) == true] " + + String query = ("@info(name = 'query1') from inputStream[device:isInGroup(groupId, deviceId, deviceType)] " + "select deviceId insert into outputStream;"); ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); - - executionPlanRuntime.addCallback("query1", new QueryCallback() { - @Override - public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) { - EventPrinter.print(timeStamp, inEvents, removeEvents); - for (Event event : inEvents) { - count.incrementAndGet(); - eventArrived = true; - } - } - }); + executionPlanRuntime.addCallback("query1", queryCallback); InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); executionPlanRuntime.start(); @@ -172,4 +181,101 @@ public class CheckDeviceInGroupExtensionTestCase extends BaseDeviceManagementTes Assert.assertEquals(1, count.get()); executionPlanRuntime.shutdown(); } + + @Test(dependsOnMethods = {"testIsInGroupExtension"}) + public void testGetDevicesOfUserFunctionExecutor() throws InterruptedException, GroupManagementException { + log.info("GetDevicesOfUser without status TestCase"); + SiddhiManager siddhiManager = new SiddhiManager(); + + count.set(0); + eventArrived = false; + + String inStreamDefinition = "define stream inputStream (user string, deviceType string);"; + String query = ("@info(name = 'query1') from inputStream[device:hasDevicesOfUser(user, deviceType)] " + + "select device:getDevicesOfUser(user, deviceType) as devices insert into outputStream;"); + ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); + executionPlanRuntime.addCallback("query1", queryCallback); + + InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); + executionPlanRuntime.start(); + Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE); + inputHandler.send(new Object[]{device.getEnrolmentInfo().getOwner(), device.getType()}); + SiddhiTestHelper.waitForEvents(100, 1, count, 10000); + Assert.assertTrue(eventArrived); + Assert.assertEquals(1, count.get()); + executionPlanRuntime.shutdown(); + } + + @Test(dependsOnMethods = {"testGetDevicesOfUserFunctionExecutor"}) + public void testGetDevicesOfUserWithStatusFunctionExecutor() throws InterruptedException, GroupManagementException { + log.info("GetDevicesOfUser with status TestCase"); + SiddhiManager siddhiManager = new SiddhiManager(); + + count.set(0); + eventArrived = false; + + String inStreamDefinition = "define stream inputStream (user string, deviceType string, status string);"; + String query = ("@info(name = 'query1') from inputStream[device:hasDevicesOfUser(user, deviceType, status)] " + + "select device:getDevicesOfUser(user, deviceType, status) as devices insert into outputStream;"); + ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); + executionPlanRuntime.addCallback("query1", queryCallback); + + InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); + executionPlanRuntime.start(); + Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE); + inputHandler.send(new Object[]{device.getEnrolmentInfo().getOwner(), device.getType(), + device.getEnrolmentInfo().getStatus().toString()}); + SiddhiTestHelper.waitForEvents(100, 1, count, 10000); + Assert.assertTrue(eventArrived); + Assert.assertEquals(1, count.get()); + executionPlanRuntime.shutdown(); + } + + @Test(dependsOnMethods = {"testGetDevicesOfUserWithStatusFunctionExecutor"}) + public void testGetDevicesOfStatusFunctionExecutor() throws InterruptedException, GroupManagementException { + log.info("GetDevicesOfStatus without deviceType TestCase"); + SiddhiManager siddhiManager = new SiddhiManager(); + + count.set(0); + eventArrived = false; + + String inStreamDefinition = "define stream inputStream (status string);"; + String query = ("@info(name = 'query1') from inputStream[device:hasDevicesOfStatus(status)] " + + "select device:getDevicesOfStatus(status) as devices insert into outputStream;"); + ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); + executionPlanRuntime.addCallback("query1", queryCallback); + + InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); + executionPlanRuntime.start(); + Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE); + inputHandler.send(new Object[]{device.getEnrolmentInfo().getStatus().toString()}); + SiddhiTestHelper.waitForEvents(100, 1, count, 10000); + Assert.assertTrue(eventArrived); + Assert.assertEquals(1, count.get()); + executionPlanRuntime.shutdown(); + } + + @Test(dependsOnMethods = {"testGetDevicesOfStatusFunctionExecutor"}) + public void testGetDevicesOfStatusWithTypeFunctionExecutor() throws InterruptedException, GroupManagementException { + log.info("GetDevicesOfStatus with deviceType TestCase"); + SiddhiManager siddhiManager = new SiddhiManager(); + + count.set(0); + eventArrived = false; + + String inStreamDefinition = "define stream inputStream (status string, deviceType string);"; + String query = ("@info(name = 'query1') from inputStream[device:hasDevicesOfStatus(status, deviceType)] " + + "select device:getDevicesOfStatus(status, deviceType) as devices insert into outputStream;"); + ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query); + executionPlanRuntime.addCallback("query1", queryCallback); + + InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream"); + executionPlanRuntime.start(); + Device device = TestDataHolder.generateDummyDeviceData(DEVICE_TYPE); + inputHandler.send(new Object[]{device.getEnrolmentInfo().getStatus().toString(), device.getType()}); + SiddhiTestHelper.waitForEvents(100, 1, count, 10000); + Assert.assertTrue(eventArrived); + Assert.assertEquals(1, count.get()); + executionPlanRuntime.shutdown(); + } } diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/DataSourceConfig.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/DataSourceConfig.java similarity index 97% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/DataSourceConfig.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/DataSourceConfig.java index 74cc58aefb..f787d9b221 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/DataSourceConfig.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/DataSourceConfig.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/SiddhiTestHelper.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/SiddhiTestHelper.java similarity index 95% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/SiddhiTestHelper.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/SiddhiTestHelper.java index 7b0801d57e..820cbf1545 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/SiddhiTestHelper.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/SiddhiTestHelper.java @@ -16,7 +16,7 @@ * under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import java.util.concurrent.atomic.AtomicInteger; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDataHolder.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDataHolder.java similarity index 97% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDataHolder.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDataHolder.java index 67c2f774eb..6c2fe832ff 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDataHolder.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDataHolder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; @@ -45,7 +45,7 @@ public class TestDataHolder { enrolmentInfo.setDateOfLastUpdate(new Date().getTime()); enrolmentInfo.setOwner(OWNER); enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD); - enrolmentInfo.setStatus(EnrolmentInfo.Status.CREATED); + enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE); device.setEnrolmentInfo(enrolmentInfo); device.setDescription("Test Description"); device.setDeviceIdentifier(initialDeviceIdentifier); diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManagementService.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManagementService.java similarity index 98% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManagementService.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManagementService.java index 758facbb46..f1631b747f 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManagementService.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManagementService.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManager; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManager.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java similarity index 98% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManager.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java index eb6871ba82..7a152b9a37 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestDeviceManager.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestDeviceManager.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.DeviceIdentifier; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestUtils.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestUtils.java similarity index 98% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestUtils.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestUtils.java index 29a46fe16c..20ed04dae6 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/java/org/wso2/extension/siddhi/devicegroup/test/util/TestUtils.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/java/org/wso2/extension/siddhi/device/test/util/TestUtils.java @@ -15,7 +15,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.wso2.extension.siddhi.devicegroup.test.util; +package org.wso2.extension.siddhi.device.test.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/dbscripts/h2.sql b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/dbscripts/h2.sql similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/dbscripts/h2.sql rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/dbscripts/h2.sql diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/axis2.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/axis2_client.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/axis2/tenant-axis2.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/carbon.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/carbon.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/carbon.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/carbon.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/cdm-config.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/cdm-config.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/cdm-config.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/cdm-config.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/datasources/master-datasources.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/bundle-config/README.txt diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/carboncontext-osgi-services.properties diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/config-validation.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/jmx.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/jmx.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/jmx.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/jmx.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/launch.ini b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/launch.ini similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/launch.ini rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/launch.ini diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/logging-bridge.properties diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/mime.mappings b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/mime.mappings similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/mime.mappings rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/mime.mappings diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/mime.types b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/mime.types similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/mime.types rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/mime.types diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/etc/osgi-debug.options diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/log4j.properties b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/log4j.properties similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/log4j.properties rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/log4j.properties diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/registry.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/registry.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/registry.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/registry.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/security/authenticators.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/security/authenticators.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/security/authenticators.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/security/authenticators.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/carbon/META-INF/context.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/carbon/WEB-INF/web.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/catalina-server.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/tomcat-users.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/web.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/web.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/tomcat/web.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/tomcat/web.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/user-mgt.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/user-mgt.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/carbon-home/repository/conf/user-mgt.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/carbon-home/repository/conf/user-mgt.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/config/datasource/data-source-config.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/config/datasource/data-source-config.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/config/datasource/data-source-config.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/config/datasource/data-source-config.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/log4j.properties b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/log4j.properties similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/log4j.properties rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/log4j.properties diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/sql/h2.sql b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/sql/h2.sql similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/sql/h2.sql rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/sql/h2.sql diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/testng.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/testng.xml similarity index 83% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/testng.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/testng.xml index 01419c74c5..a2e39e52ee 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/testng.xml +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/testng.xml @@ -24,8 +24,8 @@ - - + + diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/user-test/user-mgt-registry-test.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/user-test/user-mgt-registry-test.xml similarity index 100% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/test/resources/user-test/user-mgt-registry-test.xml rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.device/src/test/resources/user-test/user-mgt-registry-test.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml index bcbed75dfa..54c6917659 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins siddhi-extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java similarity index 82% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java rename to components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java index 8f68577a60..6bb8ddd721 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionExtension.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/java/org/wso2/extension/siddhi/execution/json/GetPropertyFunctionExtension.java @@ -33,9 +33,9 @@ import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException; * Accept Type(s): (STRING, STRING) * Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT) */ -public class getPropertyFunctionExtension extends FunctionExecutor { +public class GetPropertyFunctionExtension extends FunctionExecutor { - Attribute.Type returnType = Attribute.Type.STRING; + private Attribute.Type returnType = Attribute.Type.STRING; @Override protected void init(ExpressionExecutor[] attributeExpressionExecutors, @@ -47,32 +47,34 @@ public class getPropertyFunctionExtension extends FunctionExecutor { } if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the first argument of json:getProperty() function, " + "required " + "Invalid parameter type found for the first argument of json:getProperty() function, required " + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType() .toString()); } if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { throw new ExecutionPlanValidationException( - "Invalid parameter type found for the second argument of json:getProperty() function, " + "required " - + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType() - .toString()); + "Invalid parameter type found for the second argument of json:getProperty() function, required " + + Attribute.Type.STRING + ", but found " + + attributeExpressionExecutors[1].getReturnType().toString()); } } @Override protected Object execute(Object[] data) { if (data[0] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. First argument cannot be null"); + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function." + + " First argument cannot be null"); } if (data[1] == null) { - throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. Second argument cannot be null"); + throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. " + + "Second argument cannot be null"); } String jsonString = (String) data[0]; String property = (String) data[1]; - JSONObject jsonObject = null; + Object jsonObject; try { - jsonObject = new JSONObject(jsonString); - return jsonObject.get(property).toString(); + jsonObject = new JSONObject(jsonString).get(property); + return jsonObject == null ? null : jsonObject.toString(); } catch (JSONException e) { throw new ExecutionPlanRuntimeException("Cannot parse JSON String in json:getPeroperty() function. " + e); } @@ -80,7 +82,8 @@ public class getPropertyFunctionExtension extends FunctionExecutor { @Override protected Object execute(Object data) { - return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented. + return null; //Since the getProperty function takes in 2 parameters, this method does not get called. + // Hence,not implemented. } @Override diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext index f1886dd63e..f2a86a7eba 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/main/resources/json.siddhiext @@ -16,4 +16,4 @@ # under the License. # -getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension +getProperty=org.wso2.extension.siddhi.execution.json.GetPropertyFunctionExtension diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java index 7bc66478c2..c1c49f7882 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java +++ b/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.execution.json/src/test/java/org/wso2/extension/siddhi/execution/json/getPropertyFunctionTestCase.java @@ -45,7 +45,7 @@ public class getPropertyFunctionTestCase { @Test public void testGetPropertyFunctionExtension() throws InterruptedException { - log.info("getPropertyFunctionExtension TestCase"); + log.info("GetPropertyFunctionExtension TestCase"); SiddhiManager siddhiManager = new SiddhiManager(); String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);"; diff --git a/components/extensions/siddhi-extensions/org.wso2.gpl.siddhi.extension.geo.script/pom.xml b/components/extensions/siddhi-extensions/org.wso2.gpl.siddhi.extension.geo.script/pom.xml index 2733f5c37b..77f1639252 100644 --- a/components/extensions/siddhi-extensions/org.wso2.gpl.siddhi.extension.geo.script/pom.xml +++ b/components/extensions/siddhi-extensions/org.wso2.gpl.siddhi.extension.geo.script/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.devicemgt-plugins siddhi-extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/extensions/siddhi-extensions/pom.xml b/components/extensions/siddhi-extensions/pom.xml index efa6a77776..05aa087574 100644 --- a/components/extensions/siddhi-extensions/pom.xml +++ b/components/extensions/siddhi-extensions/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins extensions - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml @@ -33,7 +33,7 @@ http://wso2.org - org.wso2.extension.siddhi.devicegroup + org.wso2.extension.siddhi.device org.wso2.extension.siddhi.execution.json org.wso2.gpl.siddhi.extension.geo.script diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml index b83fecae0a..bdb1d58360 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/pom.xml @@ -21,7 +21,7 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java index ac99f20047..ad5f65f8d3 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/main/java/org/wso2/carbon/mdm/services/android/util/AndroidDeviceUtils.java @@ -21,6 +21,7 @@ package org.wso2.carbon.mdm.services.android.util; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; +import com.google.gson.JsonNull; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.commons.logging.Log; @@ -371,13 +372,12 @@ public class AndroidDeviceUtils { // {"name":"BATTERY_LEVEL","value":"100"},{"name":"INTERNAL_TOTAL_MEMORY","value":"0.76"}] JsonElement jsonElement = new JsonParser().parse(properties); JsonArray jsonArray = jsonElement.getAsJsonArray(); - boolean exist = false; for (JsonElement element : jsonArray) { if (element.isJsonObject()) { JsonObject jsonObject = element.getAsJsonObject(); if (jsonObject.has("name") && jsonObject.get("name").getAsString().equalsIgnoreCase(needed)) { - if (jsonObject.has("value")) { + if (jsonObject.has("value") && jsonObject.get("value") != JsonNull.INSTANCE) { return jsonObject.get("value").getAsString().replace("%", ""); } else { return ""; diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java index d3c133ef72..0582210ae2 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.api/src/test/java/org/wso2/carbon/mdm/services/android/mocks/DeviceManagementProviderServiceMock.java @@ -38,6 +38,8 @@ import org.wso2.carbon.device.mgt.common.pull.notification.PullNotificationExecu import org.wso2.carbon.device.mgt.common.push.notification.NotificationStrategy; import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.dto.DeviceType; +import org.wso2.carbon.device.mgt.core.geo.GeoCluster; +import org.wso2.carbon.device.mgt.core.geo.geoHash.GeoCoordinate; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo; import org.wso2.carbon.mdm.services.android.utils.TestUtils; @@ -501,4 +503,9 @@ public class DeviceManagementProviderServiceMock implements DeviceManagementProv public List getDeviceEnrolledTenants() throws DeviceManagementException { return null; } + + @Override + public List findGeoClusters(GeoCoordinate geoCoordinate, GeoCoordinate geoCoordinate1, int i) throws DeviceManagementException { + return null; + } } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/pom.xml index b68f84da66..6644a6ebb5 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.emulator/pom.xml @@ -21,7 +21,7 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml index 021b9dd7ff..b3020d378d 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/pom.xml @@ -23,13 +23,13 @@ android-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.android.ui - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Mobile Android UI pom diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk index 02c497dde5..e158f2a6c9 100644 Binary files a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk and b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/android-web-agent/app/pages/mdm.page.enrollments.android.download-agent/public/asset/android-agent.apk differ diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs index 55379c2c7c..1c5038755f 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.hbs @@ -1,6 +1,8 @@ {{unit "cdmf.unit.lib.qrcode"}} {{unit "cdmf.unit.device.type.qr-modal"}} - +{{#zone "topCss"}} + {{css "css/terminal.css"}} +{{/zone}} {{#if deviceFound}} {{#if isAuthorized}} @@ -16,12 +18,12 @@ data-owner="{{device.owner}}" data-status="{{device.status}}"> {{device.owner}}'s {{device.name}} - - - - + + + {{#if device.model}}

{{device.vendor}} {{device.model}}

{{/if}} @@ -82,6 +84,7 @@
  • Applications
  • Policy Compliance
  • +
  • Remote Session
  • {{/zone}} {{#zone "device-view-tab-injected-conents"}} @@ -127,6 +130,213 @@
    +
    +
    + + +
    +
    +
    + + +
    +
    + + + + + + +
    +
    +
    +
    +
    + +
    + + +
    +
    + {{#if device.location}} + {{unit "cdmf.unit.geo-dashboard" device=device noGeoFencing=false hideSearch=true}} + {{else}} +
    +

    + + Device location information is not available. +

    +
    +

    +

    +

    + {{/if}} +
    +
    +
    + +
    + + +
    +
    + + + + + + +
    +
    +

    + + No applications found. +

    +

    Please try refreshing in a while.

    +
    +
    +
    +
    +
    {{/zone}} @@ -159,5 +369,7 @@ type="text/x-handlebars-template"> {{js "js/device-detail.js"}} + {{js "js/remote-session.js"}} + {{js "js/jquery.touchSwipe.min.js"}} {{/if}} {{/zone}} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js index 51eacbc501..7e33ea0361 100644 --- a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/device-view.js @@ -23,6 +23,8 @@ function onRequest(context) { var owner = request.getParameter("owner"); var deviceViewData = {}; var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"]; + var carbonServer = require("carbon").server; + var constants = require("/app/modules/constants.js") if (deviceType && deviceId) { var deviceModule = require("/app/modules/business-controllers/device.js")["deviceModule"]; @@ -183,6 +185,23 @@ function onRequest(context) { } else if (response["status"] == "notFound") { deviceViewData["deviceFound"] = false; } + + var remoteSessionEndpoint = devicemgtProps["remoteSessionWSURL"].replace("https", "wss"); + var jwtService = carbonServer.osgiService('org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService'); + var jwtClient = jwtService.getJWTClient(); + var encodedClientKeys = session.get(constants["ENCODED_TENANT_BASED_WEB_SOCKET_CLIENT_CREDENTIALS"]); + var token = ""; + if (encodedClientKeys) { + var tokenUtil = require("/app/modules/oauth/token-handler-utils.js")["utils"]; + var resp = tokenUtil.decode(encodedClientKeys).split(":"); + var tokenPair = jwtClient.getAccessToken(resp[0], resp[1], context.user.username,"default", {}); + if (tokenPair) { + token = tokenPair.accessToken; + } + } + remoteSessionEndpoint = remoteSessionEndpoint + "/remote/session/clients/" + deviceType + "/" + deviceId + + "?websocketToken=" + token + deviceViewData["remoteSessionEndpoint"] = remoteSessionEndpoint; } else { deviceViewData["deviceFound"] = false; } diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/css/terminal.css b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/css/terminal.css new file mode 100644 index 0000000000..c6899148fc --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/css/terminal.css @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 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. + */ + +.terminal { + background-color: #1f1d1d; + border: 1px solid #000; + color: #39ef39; + padding: 8px; + font-family: courier new; +} diff --git a/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/jquery.touchSwipe.min.js b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/jquery.touchSwipe.min.js new file mode 100644 index 0000000000..703634a25e --- /dev/null +++ b/components/mobile-plugins/android-plugin/org.wso2.carbon.device.mgt.mobile.android.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.android.device-view/public/js/jquery.touchSwipe.min.js @@ -0,0 +1,14 @@ +/*! + * @fileOverview TouchSwipe - jQuery Plugin + * @version 1.6.18 + * + * @author Matt Bryson http://www.github.com/mattbryson + * @see https://github.com/mattbryson/TouchSwipe-Jquery-Plugin + * @see http://labs.rampinteractive.co.uk/touchSwipe/ + * @see http://plugins.jquery.com/project/touchSwipe + * @license + * Copyright (c) 2010-2015 Matt Bryson + * Dual licensed under the MIT or GPL Version 2 licenses. + * + */ +!function(factory){"function"==typeof define&&define.amd&&define.amd.jQuery?define(["jquery"],factory):factory("undefined"!=typeof module&&module.exports?require("jquery"):jQuery)}(function($){"use strict";function init(options){return!options||void 0!==options.allowPageScroll||void 0===options.swipe&&void 0===options.swipeStatus||(options.allowPageScroll=NONE),void 0!==options.click&&void 0===options.tap&&(options.tap=options.click),options||(options={}),options=$.extend({},$.fn.swipe.defaults,options),this.each(function(){var $this=$(this),plugin=$this.data(PLUGIN_NS);plugin||(plugin=new TouchSwipe(this,options),$this.data(PLUGIN_NS,plugin))})}function TouchSwipe(element,options){function touchStart(jqEvent){if(!(getTouchInProgress()||$(jqEvent.target).closest(options.excludedElements,$element).length>0)){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(!event.pointerType||"mouse"!=event.pointerType||0!=options.fallbackToMouseEvents){var ret,touches=event.touches,evt=touches?touches[0]:event;return phase=PHASE_START,touches?fingerCount=touches.length:options.preventDefaultEvents!==!1&&jqEvent.preventDefault(),distance=0,direction=null,currentDirection=null,pinchDirection=null,duration=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,pinchDistance=0,maximumsMap=createMaximumsData(),cancelMultiFingerRelease(),createFingerData(0,evt),!touches||fingerCount===options.fingers||options.fingers===ALL_FINGERS||hasPinches()?(startTime=getTimeStamp(),2==fingerCount&&(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)),(options.swipeStatus||options.pinchStatus)&&(ret=triggerHandler(event,phase))):ret=!1,ret===!1?(phase=PHASE_CANCEL,triggerHandler(event,phase),ret):(options.hold&&(holdTimeout=setTimeout($.proxy(function(){$element.trigger("hold",[event.target]),options.hold&&(ret=options.hold.call($element,event,event.target))},this),options.longTapThreshold)),setTouchInProgress(!0),null)}}}function touchMove(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;if(phase!==PHASE_END&&phase!==PHASE_CANCEL&&!inMultiFingerRelease()){var ret,touches=event.touches,evt=touches?touches[0]:event,currentFinger=updateFingerData(evt);if(endTime=getTimeStamp(),touches&&(fingerCount=touches.length),options.hold&&clearTimeout(holdTimeout),phase=PHASE_MOVE,2==fingerCount&&(0==startTouchesDistance?(createFingerData(1,touches[1]),startTouchesDistance=endTouchesDistance=calculateTouchesDistance(fingerData[0].start,fingerData[1].start)):(updateFingerData(touches[1]),endTouchesDistance=calculateTouchesDistance(fingerData[0].end,fingerData[1].end),pinchDirection=calculatePinchDirection(fingerData[0].end,fingerData[1].end)),pinchZoom=calculatePinchZoom(startTouchesDistance,endTouchesDistance),pinchDistance=Math.abs(startTouchesDistance-endTouchesDistance)),fingerCount===options.fingers||options.fingers===ALL_FINGERS||!touches||hasPinches()){if(direction=calculateDirection(currentFinger.start,currentFinger.end),currentDirection=calculateDirection(currentFinger.last,currentFinger.end),validateDefaultEvent(jqEvent,currentDirection),distance=calculateDistance(currentFinger.start,currentFinger.end),duration=calculateDuration(),setMaxDistance(direction,distance),ret=triggerHandler(event,phase),!options.triggerOnTouchEnd||options.triggerOnTouchLeave){var inBounds=!0;if(options.triggerOnTouchLeave){var bounds=getbounds(this);inBounds=isInBounds(currentFinger.end,bounds)}!options.triggerOnTouchEnd&&inBounds?phase=getNextPhase(PHASE_MOVE):options.triggerOnTouchLeave&&!inBounds&&(phase=getNextPhase(PHASE_END)),phase!=PHASE_CANCEL&&phase!=PHASE_END||triggerHandler(event,phase)}}else phase=PHASE_CANCEL,triggerHandler(event,phase);ret===!1&&(phase=PHASE_CANCEL,triggerHandler(event,phase))}}function touchEnd(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent,touches=event.touches;if(touches){if(touches.length&&!inMultiFingerRelease())return startMultiFingerRelease(event),!0;if(touches.length&&inMultiFingerRelease())return!0}return inMultiFingerRelease()&&(fingerCount=fingerCountAtRelease),endTime=getTimeStamp(),duration=calculateDuration(),didSwipeBackToCancel()||!validateSwipeDistance()?(phase=PHASE_CANCEL,triggerHandler(event,phase)):options.triggerOnTouchEnd||options.triggerOnTouchEnd===!1&&phase===PHASE_MOVE?(options.preventDefaultEvents!==!1&&jqEvent.preventDefault(),phase=PHASE_END,triggerHandler(event,phase)):!options.triggerOnTouchEnd&&hasTap()?(phase=PHASE_END,triggerHandlerForGesture(event,phase,TAP)):phase===PHASE_MOVE&&(phase=PHASE_CANCEL,triggerHandler(event,phase)),setTouchInProgress(!1),null}function touchCancel(){fingerCount=0,endTime=0,startTime=0,startTouchesDistance=0,endTouchesDistance=0,pinchZoom=1,cancelMultiFingerRelease(),setTouchInProgress(!1)}function touchLeave(jqEvent){var event=jqEvent.originalEvent?jqEvent.originalEvent:jqEvent;options.triggerOnTouchLeave&&(phase=getNextPhase(PHASE_END),triggerHandler(event,phase))}function removeListeners(){$element.unbind(START_EV,touchStart),$element.unbind(CANCEL_EV,touchCancel),$element.unbind(MOVE_EV,touchMove),$element.unbind(END_EV,touchEnd),LEAVE_EV&&$element.unbind(LEAVE_EV,touchLeave),setTouchInProgress(!1)}function getNextPhase(currentPhase){var nextPhase=currentPhase,validTime=validateSwipeTime(),validDistance=validateSwipeDistance(),didCancel=didSwipeBackToCancel();return!validTime||didCancel?nextPhase=PHASE_CANCEL:!validDistance||currentPhase!=PHASE_MOVE||options.triggerOnTouchEnd&&!options.triggerOnTouchLeave?!validDistance&¤tPhase==PHASE_END&&options.triggerOnTouchLeave&&(nextPhase=PHASE_CANCEL):nextPhase=PHASE_END,nextPhase}function triggerHandler(event,phase){var ret,touches=event.touches;return(didSwipe()||hasSwipes())&&(ret=triggerHandlerForGesture(event,phase,SWIPE)),(didPinch()||hasPinches())&&ret!==!1&&(ret=triggerHandlerForGesture(event,phase,PINCH)),didDoubleTap()&&ret!==!1?ret=triggerHandlerForGesture(event,phase,DOUBLE_TAP):didLongTap()&&ret!==!1?ret=triggerHandlerForGesture(event,phase,LONG_TAP):didTap()&&ret!==!1&&(ret=triggerHandlerForGesture(event,phase,TAP)),phase===PHASE_CANCEL&&touchCancel(event),phase===PHASE_END&&(touches?touches.length||touchCancel(event):touchCancel(event)),ret}function triggerHandlerForGesture(event,phase,gesture){var ret;if(gesture==SWIPE){if($element.trigger("swipeStatus",[phase,direction||null,distance||0,duration||0,fingerCount,fingerData,currentDirection]),options.swipeStatus&&(ret=options.swipeStatus.call($element,event,phase,direction||null,distance||0,duration||0,fingerCount,fingerData,currentDirection),ret===!1))return!1;if(phase==PHASE_END&&validateSwipe()){if(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),$element.trigger("swipe",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipe&&(ret=options.swipe.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection),ret===!1))return!1;switch(direction){case LEFT:$element.trigger("swipeLeft",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeLeft&&(ret=options.swipeLeft.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case RIGHT:$element.trigger("swipeRight",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeRight&&(ret=options.swipeRight.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case UP:$element.trigger("swipeUp",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeUp&&(ret=options.swipeUp.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection));break;case DOWN:$element.trigger("swipeDown",[direction,distance,duration,fingerCount,fingerData,currentDirection]),options.swipeDown&&(ret=options.swipeDown.call($element,event,direction,distance,duration,fingerCount,fingerData,currentDirection))}}}if(gesture==PINCH){if($element.trigger("pinchStatus",[phase,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchStatus&&(ret=options.pinchStatus.call($element,event,phase,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData),ret===!1))return!1;if(phase==PHASE_END&&validatePinch())switch(pinchDirection){case IN:$element.trigger("pinchIn",[pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchIn&&(ret=options.pinchIn.call($element,event,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData));break;case OUT:$element.trigger("pinchOut",[pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData]),options.pinchOut&&(ret=options.pinchOut.call($element,event,pinchDirection||null,pinchDistance||0,duration||0,fingerCount,pinchZoom,fingerData))}}return gesture==TAP?phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),hasDoubleTap()&&!inDoubleTap()?(doubleTapStartTime=getTimeStamp(),singleTapTimeout=setTimeout($.proxy(function(){doubleTapStartTime=null,$element.trigger("tap",[event.target]),options.tap&&(ret=options.tap.call($element,event,event.target))},this),options.doubleTapThreshold)):(doubleTapStartTime=null,$element.trigger("tap",[event.target]),options.tap&&(ret=options.tap.call($element,event,event.target)))):gesture==DOUBLE_TAP?phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),clearTimeout(holdTimeout),doubleTapStartTime=null,$element.trigger("doubletap",[event.target]),options.doubleTap&&(ret=options.doubleTap.call($element,event,event.target))):gesture==LONG_TAP&&(phase!==PHASE_CANCEL&&phase!==PHASE_END||(clearTimeout(singleTapTimeout),doubleTapStartTime=null,$element.trigger("longtap",[event.target]),options.longTap&&(ret=options.longTap.call($element,event,event.target)))),ret}function validateSwipeDistance(){var valid=!0;return null!==options.threshold&&(valid=distance>=options.threshold),valid}function didSwipeBackToCancel(){var cancelled=!1;return null!==options.cancelThreshold&&null!==direction&&(cancelled=getMaxDistance(direction)-distance>=options.cancelThreshold),cancelled}function validatePinchDistance(){return null!==options.pinchThreshold?pinchDistance>=options.pinchThreshold:!0}function validateSwipeTime(){var result;return result=options.maxTimeThreshold?!(duration>=options.maxTimeThreshold):!0}function validateDefaultEvent(jqEvent,direction){if(options.preventDefaultEvents!==!1)if(options.allowPageScroll===NONE)jqEvent.preventDefault();else{var auto=options.allowPageScroll===AUTO;switch(direction){case LEFT:(options.swipeLeft&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case RIGHT:(options.swipeRight&&auto||!auto&&options.allowPageScroll!=HORIZONTAL)&&jqEvent.preventDefault();break;case UP:(options.swipeUp&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault();break;case DOWN:(options.swipeDown&&auto||!auto&&options.allowPageScroll!=VERTICAL)&&jqEvent.preventDefault();break;case NONE:}}}function validatePinch(){var hasCorrectFingerCount=validateFingers(),hasEndPoint=validateEndPoint(),hasCorrectDistance=validatePinchDistance();return hasCorrectFingerCount&&hasEndPoint&&hasCorrectDistance}function hasPinches(){return!!(options.pinchStatus||options.pinchIn||options.pinchOut)}function didPinch(){return!(!validatePinch()||!hasPinches())}function validateSwipe(){var hasValidTime=validateSwipeTime(),hasValidDistance=validateSwipeDistance(),hasCorrectFingerCount=validateFingers(),hasEndPoint=validateEndPoint(),didCancel=didSwipeBackToCancel(),valid=!didCancel&&hasEndPoint&&hasCorrectFingerCount&&hasValidDistance&&hasValidTime;return valid}function hasSwipes(){return!!(options.swipe||options.swipeStatus||options.swipeLeft||options.swipeRight||options.swipeUp||options.swipeDown)}function didSwipe(){return!(!validateSwipe()||!hasSwipes())}function validateFingers(){return fingerCount===options.fingers||options.fingers===ALL_FINGERS||!SUPPORTS_TOUCH}function validateEndPoint(){return 0!==fingerData[0].end.x}function hasTap(){return!!options.tap}function hasDoubleTap(){return!!options.doubleTap}function hasLongTap(){return!!options.longTap}function validateDoubleTap(){if(null==doubleTapStartTime)return!1;var now=getTimeStamp();return hasDoubleTap()&&now-doubleTapStartTime<=options.doubleTapThreshold}function inDoubleTap(){return validateDoubleTap()}function validateTap(){return(1===fingerCount||!SUPPORTS_TOUCH)&&(isNaN(distance)||distanceoptions.longTapThreshold&&DOUBLE_TAP_THRESHOLD>distance}function didTap(){return!(!validateTap()||!hasTap())}function didDoubleTap(){return!(!validateDoubleTap()||!hasDoubleTap())}function didLongTap(){return!(!validateLongTap()||!hasLongTap())}function startMultiFingerRelease(event){previousTouchEndTime=getTimeStamp(),fingerCountAtRelease=event.touches.length+1}function cancelMultiFingerRelease(){previousTouchEndTime=0,fingerCountAtRelease=0}function inMultiFingerRelease(){var withinThreshold=!1;if(previousTouchEndTime){var diff=getTimeStamp()-previousTouchEndTime;diff<=options.fingerReleaseThreshold&&(withinThreshold=!0)}return withinThreshold}function getTouchInProgress(){return!($element.data(PLUGIN_NS+"_intouch")!==!0)}function setTouchInProgress(val){$element&&(val===!0?($element.bind(MOVE_EV,touchMove),$element.bind(END_EV,touchEnd),LEAVE_EV&&$element.bind(LEAVE_EV,touchLeave)):($element.unbind(MOVE_EV,touchMove,!1),$element.unbind(END_EV,touchEnd,!1),LEAVE_EV&&$element.unbind(LEAVE_EV,touchLeave,!1)),$element.data(PLUGIN_NS+"_intouch",val===!0))}function createFingerData(id,evt){var f={start:{x:0,y:0},last:{x:0,y:0},end:{x:0,y:0}};return f.start.x=f.last.x=f.end.x=evt.pageX||evt.clientX,f.start.y=f.last.y=f.end.y=evt.pageY||evt.clientY,fingerData[id]=f,f}function updateFingerData(evt){var id=void 0!==evt.identifier?evt.identifier:0,f=getFingerData(id);return null===f&&(f=createFingerData(id,evt)),f.last.x=f.end.x,f.last.y=f.end.y,f.end.x=evt.pageX||evt.clientX,f.end.y=evt.pageY||evt.clientY,f}function getFingerData(id){return fingerData[id]||null}function setMaxDistance(direction,distance){direction!=NONE&&(distance=Math.max(distance,getMaxDistance(direction)),maximumsMap[direction].distance=distance)}function getMaxDistance(direction){return maximumsMap[direction]?maximumsMap[direction].distance:void 0}function createMaximumsData(){var maxData={};return maxData[LEFT]=createMaximumVO(LEFT),maxData[RIGHT]=createMaximumVO(RIGHT),maxData[UP]=createMaximumVO(UP),maxData[DOWN]=createMaximumVO(DOWN),maxData}function createMaximumVO(dir){return{direction:dir,distance:0}}function calculateDuration(){return endTime-startTime}function calculateTouchesDistance(startPoint,endPoint){var diffX=Math.abs(startPoint.x-endPoint.x),diffY=Math.abs(startPoint.y-endPoint.y);return Math.round(Math.sqrt(diffX*diffX+diffY*diffY))}function calculatePinchZoom(startDistance,endDistance){var percent=endDistance/startDistance*1;return percent.toFixed(2)}function calculatePinchDirection(){return 1>pinchZoom?OUT:IN}function calculateDistance(startPoint,endPoint){return Math.round(Math.sqrt(Math.pow(endPoint.x-startPoint.x,2)+Math.pow(endPoint.y-startPoint.y,2)))}function calculateAngle(startPoint,endPoint){var x=startPoint.x-endPoint.x,y=endPoint.y-startPoint.y,r=Math.atan2(y,x),angle=Math.round(180*r/Math.PI);return 0>angle&&(angle=360-Math.abs(angle)),angle}function calculateDirection(startPoint,endPoint){if(comparePoints(startPoint,endPoint))return NONE;var angle=calculateAngle(startPoint,endPoint);return 45>=angle&&angle>=0?LEFT:360>=angle&&angle>=315?LEFT:angle>=135&&225>=angle?RIGHT:angle>45&&135>angle?DOWN:UP}function getTimeStamp(){var now=new Date;return now.getTime()}function getbounds(el){el=$(el);var offset=el.offset(),bounds={left:offset.left,right:offset.left+el.outerWidth(),top:offset.top,bottom:offset.top+el.outerHeight()};return bounds}function isInBounds(point,bounds){return point.x>bounds.left&&point.xbounds.top&&point.y android-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/android-plugin/pom.xml b/components/mobile-plugins/android-plugin/pom.xml index 44333119ce..67a8a8d894 100644 --- a/components/mobile-plugins/android-plugin/pom.xml +++ b/components/mobile-plugins/android-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/pom.xml b/components/mobile-plugins/pom.xml index d066e7534f..993c87e411 100644 --- a/components/mobile-plugins/pom.xml +++ b/components/mobile-plugins/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml index 802aaf3f97..bdb54251a0 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.api/pom.xml @@ -21,7 +21,7 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml index 70b8cc790c..77a722ec67 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/pom.xml @@ -23,13 +23,13 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.windows.ui - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Mobile Windows UI pom diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js index ec7ae00035..1e756185b1 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.windows.policy-edit/public/js/windows-policy-edit.js @@ -107,7 +107,6 @@ var generatePolicyProfile = function () { return windowsOperationModule.generateProfile(configuredOperations); }; - /** * Checks if provided number is valid against a range. * @@ -387,7 +386,6 @@ var slideDownPaneAgainstValueSet = function (selectElement, paneID, valueSet) { }; // End of HTML embedded invoke methods - // Start of functions related to grid-input-view /** * Method to set count id to cloned elements. diff --git a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml index 91ed795a93..3110c8ae39 100644 --- a/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml +++ b/components/mobile-plugins/windows-plugin/org.wso2.carbon.device.mgt.mobile.windows/pom.xml @@ -22,7 +22,7 @@ windows-plugin org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/mobile-plugins/windows-plugin/pom.xml b/components/mobile-plugins/windows-plugin/pom.xml index 796a445d44..7ef3994ca5 100644 --- a/components/mobile-plugins/windows-plugin/pom.xml +++ b/components/mobile-plugins/windows-plugin/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/components/test-coverage/pom.xml b/components/test-coverage/pom.xml index 6d86d76d48..b1e943e43b 100644 --- a/components/test-coverage/pom.xml +++ b/components/test-coverage/pom.xml @@ -22,7 +22,7 @@ carbon-device-mgt-plugins-parent org.wso2.carbon.devicemgt-plugins - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 diff --git a/features/analytics-feature/org.wso2.carbon.device.mgt.cdmf.analytics.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.device.mgt.cdmf.analytics.feature/pom.xml index 9a469a3c18..571224692c 100644 --- a/features/analytics-feature/org.wso2.carbon.device.mgt.cdmf.analytics.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.device.mgt.cdmf.analytics.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml index 4a35d37c62..5ef9ceb516 100644 --- a/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.device.mgt.iot.analytics.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.analytics.feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - IoT Server Analytics Feature http://wso2.org diff --git a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml index c55e4baf3a..ccfce840c2 100644 --- a/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.iot.device.statistics.dashboard.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.iot.device.statistics.dashboard.feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - IoT Server Analytics Feature http://wso2.org diff --git a/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml b/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml index 48f5993b62..666a040802 100644 --- a/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml +++ b/features/analytics-feature/org.wso2.carbon.iot.geo.dashboard.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins analytics-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/analytics-feature/pom.xml b/features/analytics-feature/pom.xml index e0b634f869..97dcbc841f 100644 --- a/features/analytics-feature/pom.xml +++ b/features/analytics-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/pom.xml index bbb3167938..b9f4ec0de6 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins androidsense-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.androidsense.analytics.feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - IoT Server Android Sense Analytics Feature http://wso2.org diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/pom.xml index 527bad08c6..36ac5ef016 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.backend.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins androidsense-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.androidsense.backend.feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - IoT Server Android Sense Backend Feature http://wso2.org diff --git a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.ui.feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.ui.feature/pom.xml index 2d0d4ddfd8..47e552c8e9 100644 --- a/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.ui.feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/org.wso2.carbon.device.mgt.iot.androidsense.ui.feature/pom.xml @@ -23,13 +23,13 @@ org.wso2.carbon.devicemgt-plugins androidsense-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.iot.androidsense.ui.feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - IoT Server Android Sense UI Feature http://wso2.org diff --git a/features/device-types-feature/androidsense-plugin-feature/pom.xml b/features/device-types-feature/androidsense-plugin-feature/pom.xml index e02a189f77..32b7656769 100644 --- a/features/device-types-feature/androidsense-plugin-feature/pom.xml +++ b/features/device-types-feature/androidsense-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.analytics.feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.analytics.feature/pom.xml index 4bfcf66edf..69cf8c50c1 100644 --- a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.analytics.feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.analytics.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins arduino-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.backend.feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.backend.feature/pom.xml index f85401df58..b9d9496c77 100644 --- a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.backend.feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.backend.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins arduino-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.ui.feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.ui.feature/pom.xml index 736e9b530d..95c65035a5 100644 --- a/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.ui.feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/org.wso2.carbon.device.mgt.iot.arduino.ui.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins arduino-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/arduino-plugin-feature/pom.xml b/features/device-types-feature/arduino-plugin-feature/pom.xml index e28b80dd99..783fa1cd95 100644 --- a/features/device-types-feature/arduino-plugin-feature/pom.xml +++ b/features/device-types-feature/arduino-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/pom.xml b/features/device-types-feature/pom.xml index 87cb39f00f..e79a8967a5 100644 --- a/features/device-types-feature/pom.xml +++ b/features/device-types-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 device-types-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - Device Management IoT Plugins Feature http://wso2.org diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/pom.xml index 119f375f28..afdd56a5cf 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.analytics.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins raspberrypi-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/pom.xml index f72ad31f9f..9ba3873e35 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.backend.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins raspberrypi-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.ui.feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.ui.feature/pom.xml index bf65e37209..78be0faf17 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.ui.feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/org.wso2.carbon.device.mgt.iot.raspberrypi.ui.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins raspberrypi-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/raspberrypi-plugin-feature/pom.xml b/features/device-types-feature/raspberrypi-plugin-feature/pom.xml index 5ef2c45f55..1e01439a81 100644 --- a/features/device-types-feature/raspberrypi-plugin-feature/pom.xml +++ b/features/device-types-feature/raspberrypi-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/pom.xml index c5fcc5aabe..302097be87 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.analytics.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins virtual-fire-alarm-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/pom.xml index 695dec322f..dd0650e3b1 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.backend.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins virtual-fire-alarm-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui.feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui.feature/pom.xml index 554683d46c..6fcfd50632 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui.feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/org.wso2.carbon.device.mgt.iot.virtualfirealarm.ui.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins virtual-fire-alarm-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml b/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml index 389bd871ca..59a05b5a71 100644 --- a/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml +++ b/features/device-types-feature/virtual-fire-alarm-plugin-feature/pom.xml @@ -22,7 +22,7 @@ org.wso2.carbon.devicemgt-plugins device-types-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.api.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.api.feature/pom.xml index 709e0fa460..60311678b7 100644 --- a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.api.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.api.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml index 756e1b3ff7..cde126c349 100644 --- a/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml index 692f1e52ca..bf62c3c6ea 100644 --- a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.osgiconnector.feature/pom.xml @@ -20,13 +20,13 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml org.wso2.carbon.appmgt.mdm.osgiconnector.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - App management MDM OSGI Connector http://wso2.org This feature contains the core bundles required for APP management OSGI MDM connection @@ -36,7 +36,7 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.appmgt.mdm.osgiconnector - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT org.apache.ws.commons.axiom diff --git a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml index 93803e69f1..1e0a419ca2 100644 --- a/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.appmgt.mdm.restconnector.feature/pom.xml @@ -20,13 +20,13 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml org.wso2.carbon.appmgt.mdm.restconnector.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - App management MDM REST Connector http://wso2.org This feature contains the core bundles required for APP management MDM REST connection @@ -36,7 +36,7 @@ org.wso2.carbon.devicemgt-plugins org.wso2.carbon.appmgt.mdm.restconnector - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT org.apache.ws.commons.axiom diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml index 41cb7f41f1..876baf05a1 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.adapter.feature/pom.xml @@ -23,14 +23,14 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.adapter.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Device Management Adapters Feature http://wso2.org This feature contains the adapter bundles required for IoT Server diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.notification.listener.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.notification.listener.feature/pom.xml index 98ec9dcf87..ca98e950c1 100644 --- a/features/extensions-feature/org.wso2.carbon.device.mgt.notification.listener.feature/pom.xml +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.notification.listener.feature/pom.xml @@ -3,14 +3,14 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.notification.listener.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Notification Listener http://wso2.org This feature contains the core bundles required iot core listeners diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/pom.xml b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/pom.xml new file mode 100644 index 0000000000..1c86412613 --- /dev/null +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/pom.xml @@ -0,0 +1,151 @@ + + + + + + org.wso2.carbon.devicemgt-plugins + extensions-feature + 4.0.100-SNAPSHOT + ../pom.xml + + 4.0.0 + + org.wso2.carbon.device.mgt.remote.session.feature + pom + WSO2 Carbon - Remote Session Manager + http://wso2.org + This feature contains the core bundles required iot Remote Sessions + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.extensions.remote.session + + + io.github.openfeign + feign-jaxrs + ${io.github.openfeign.version} + + + io.github.openfeign + feign-gson + ${io.github.openfeign.version} + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy + package + + copy + + + + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.extensions.remote.session.endpoint + ${carbon.devicemgt.plugins.version} + war + true + + ${project.build.directory}/maven-shared-archive-resources/webapps/ + + remote#session.war + + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + build.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.device.mgt.remote.session + ../../../features/etc/feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:true + + + + + org.wso2.carbon.devicemgt-plugins:org.wso2.carbon.device.mgt.extensions.remote.session:${carbon.devicemgt.plugins.version} + + + + org.wso2.carbon.identity.inbound.auth.oauth2:org.wso2.carbon.identity.oauth.stub:${identity.inbound.auth.oauth.version} + + + io.github.openfeign:feign-core:${io.github.openfeign.version} + + + io.github.openfeign:feign-slf4j:${io.github.openfeign.version} + + + io.github.openfeign:feign-gson:${io.github.openfeign.version} + + + + + + + + + + \ No newline at end of file diff --git a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/resources/devicegroup.siddhiext b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/build.properties similarity index 81% rename from components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/resources/devicegroup.siddhiext rename to features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/build.properties index 41eed5053e..e0fe0c5134 100644 --- a/components/extensions/siddhi-extensions/org.wso2.extension.siddhi.devicegroup/src/main/resources/devicegroup.siddhiext +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/build.properties @@ -6,7 +6,7 @@ # in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# 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 @@ -16,4 +16,4 @@ # under the License. # -isDeviceInGroup=org.wso2.extension.siddhi.devicegroup.IsDeviceInGroupFunctionExecutor +custom = true diff --git a/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/p2.inf b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/p2.inf new file mode 100644 index 0000000000..9efb7a9948 --- /dev/null +++ b/features/extensions-feature/org.wso2.carbon.device.mgt.remote.session.feature/src/main/resources/p2.inf @@ -0,0 +1,3 @@ +instructions.configure = \ +org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.remote.session_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\ \ No newline at end of file diff --git a/features/extensions-feature/org.wso2.extension.siddhi.devicegroup.feature/pom.xml b/features/extensions-feature/org.wso2.extension.siddhi.device.feature/pom.xml similarity index 90% rename from features/extensions-feature/org.wso2.extension.siddhi.devicegroup.feature/pom.xml rename to features/extensions-feature/org.wso2.extension.siddhi.device.feature/pom.xml index 544c24075e..f28cc6dc32 100644 --- a/features/extensions-feature/org.wso2.extension.siddhi.devicegroup.feature/pom.xml +++ b/features/extensions-feature/org.wso2.extension.siddhi.device.feature/pom.xml @@ -20,11 +20,11 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml - org.wso2.extension.siddhi.devicegroup.feature + org.wso2.extension.siddhi.device.feature pom WSO2 Siddhi Execution Extension - Device Group Feature http://wso2.org @@ -33,7 +33,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.extension.siddhi.devicegroup + org.wso2.extension.siddhi.device @@ -51,7 +51,7 @@ p2-feature-gen - org.wso2.extension.siddhi.devicegroup + org.wso2.extension.siddhi.device ../../etc/feature.properties @@ -61,7 +61,7 @@ - org.wso2.carbon.devicemgt-plugins:org.wso2.extension.siddhi.devicegroup:${carbon.devicemgt.plugins.version} + org.wso2.carbon.devicemgt-plugins:org.wso2.extension.siddhi.device:${carbon.devicemgt.plugins.version} diff --git a/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml b/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml index 661993c1a7..b3471ef0b0 100644 --- a/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml +++ b/features/extensions-feature/org.wso2.extension.siddhi.execution.json.feature/pom.xml @@ -20,13 +20,13 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml org.wso2.extension.siddhi.execution.json.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Siddhi Execution Extension - Json Feature http://wso2.org This feature contains Siddhi extension feature for changing a json string to individual properties. diff --git a/features/extensions-feature/org.wso2.gpl.siddhi.extension.geo.script.feature/pom.xml b/features/extensions-feature/org.wso2.gpl.siddhi.extension.geo.script.feature/pom.xml index a68710bd6c..a810d88f0c 100644 --- a/features/extensions-feature/org.wso2.gpl.siddhi.extension.geo.script.feature/pom.xml +++ b/features/extensions-feature/org.wso2.gpl.siddhi.extension.geo.script.feature/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml diff --git a/features/extensions-feature/pom.xml b/features/extensions-feature/pom.xml index 931e29417c..05af882e8b 100644 --- a/features/extensions-feature/pom.xml +++ b/features/extensions-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 extensions-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - Device Management Extensions http://wso2.org @@ -39,10 +39,11 @@ org.wso2.carbon.device.mgt.adapter.feature org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature org.wso2.carbon.andes.extensions.device.mgt.api.feature - org.wso2.extension.siddhi.devicegroup.feature + org.wso2.extension.siddhi.device.feature org.wso2.extension.siddhi.execution.json.feature org.wso2.carbon.device.mgt.notification.listener.feature org.wso2.gpl.siddhi.extension.geo.script.feature + org.wso2.carbon.device.mgt.remote.session.feature diff --git a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml index 1c0a483bbd..eb5f999819 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/org.wso2.carbon.device.mgt.mobile.android.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt-plugins android-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.android.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Android Device Management Feature http://wso2.org This feature contains the core bundles required for Android Device Management diff --git a/features/mobile-plugins-feature/android-plugin-feature/pom.xml b/features/mobile-plugins-feature/android-plugin-feature/pom.xml index d094d337f5..748d9cbd5d 100644 --- a/features/mobile-plugins-feature/android-plugin-feature/pom.xml +++ b/features/mobile-plugins-feature/android-plugin-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 android-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - Device Management Android Plugin Feature http://wso2.org diff --git a/features/mobile-plugins-feature/pom.xml b/features/mobile-plugins-feature/pom.xml index 2c4bd1f0cb..01ca7fc4fd 100644 --- a/features/mobile-plugins-feature/pom.xml +++ b/features/mobile-plugins-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../../pom.xml 4.0.0 mobile-plugins-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - Device Management EMM Plugins Feature http://wso2.org diff --git a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml index f6266dbca9..1988b692cd 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/org.wso2.carbon.device.mgt.mobile.windows.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt-plugins windows-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.mgt.mobile.windows.feature pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Windows Device Management Feature http://wso2.org This feature contains the core bundles required for Windows Device Management diff --git a/features/mobile-plugins-feature/windows-plugin-feature/pom.xml b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml index 57cabe4f57..4c9c10ef49 100644 --- a/features/mobile-plugins-feature/windows-plugin-feature/pom.xml +++ b/features/mobile-plugins-feature/windows-plugin-feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt-plugins mobile-plugins-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT ../pom.xml 4.0.0 windows-plugin-feature - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT pom WSO2 Carbon - Device Management Windows Plugin Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 9b4b6b7293..79e87b8cd0 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ org.wso2.carbon.devicemgt-plugins carbon-device-mgt-plugins-parent pom - 4.0.91-SNAPSHOT + 4.0.100-SNAPSHOT WSO2 Carbon - Device Management Plugins Parent http://wso2.org WSO2 Carbon - Device Management Plugins Parent @@ -412,7 +412,7 @@ org.wso2.carbon.devicemgt-plugins - org.wso2.extension.siddhi.devicegroup + org.wso2.extension.siddhi.device ${carbon.devicemgt.plugins.version} @@ -483,6 +483,11 @@ ${carbon.devicemgt.plugins.version} war + + org.wso2.carbon.devicemgt-plugins + org.wso2.carbon.device.mgt.extensions.remote.session + ${carbon.devicemgt.plugins.version} + @@ -1210,14 +1215,14 @@ 1.1.1 - 3.0.170 + 3.0.182 [3.0.0, 4.0.0) 1.2.40 - ${project.version} + 4.0.100-SNAPSHOT 4.4.8