Merge pull request #838 from menakaj/master

Fixing code formatting issues.
revert-dabc3590
Charitha Goonetilleke 7 years ago committed by GitHub
commit c79836fc11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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; import agent.sense.android.iot.carbon.wso2.org.wso2_senseagent.R;
/** /**
* A login screen that offers to register the device. * A login screen that offers to register the device.
*/ */
@ -159,7 +158,6 @@ public class RegisterActivity extends Activity {
startActivity(intent); startActivity(intent);
} }
}); });
} }
mUiHandler.post(new Runnable() { mUiHandler.post(new Runnable() {
@Override @Override
@ -167,11 +165,9 @@ public class RegisterActivity extends Activity {
showProgress(false); showProgress(false);
} }
}); });
} }
}); });
myThread.start(); myThread.start();
} }
} }
@ -208,6 +204,4 @@ public class RegisterActivity extends Activity {
deviceRegisterButton.setVisibility(show? View.VISIBLE : View.GONE); deviceRegisterButton.setVisibility(show? View.VISIBLE : View.GONE);
} }
} }
} }

@ -34,5 +34,4 @@ public class DataPublisherReceiver extends BroadcastReceiver {
PendingIntent pending = PendingIntent.getService(context, 0, i, 0); PendingIntent pending = PendingIntent.getService(context, 0, i, 0);
service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), ALARM_INTERVAL, pending); service.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), ALARM_INTERVAL, pending);
} }
} }

@ -20,7 +20,6 @@ import android.hardware.Sensor;
import android.os.IBinder; import android.os.IBinder;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.util.Log; import android.util.Log;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; 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.AndroidSenseMQTTHandler;
import org.wso2.carbon.iot.android.sense.data.publisher.mqtt.transport.MQTTTransportHandler; 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.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.activity.ActivityData;
import org.wso2.carbon.iot.android.sense.event.streams.application.ApplicationData; 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.audio.AudioData;
import org.wso2.carbon.iot.android.sense.event.streams.battery.BatteryData; 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.call.CallData;
import org.wso2.carbon.iot.android.sense.event.streams.data.NetworkData; 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.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.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.ProcessWords;
import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData; import org.wso2.carbon.iot.android.sense.speech.detector.util.WordData;
import org.wso2.carbon.iot.android.sense.util.LocalRegistry; import org.wso2.carbon.iot.android.sense.util.LocalRegistry;
@ -65,9 +64,6 @@ public class DataPublisherService extends Service {
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
context = this; context = this;
Log.d(TAG, "service started"); Log.d(TAG, "service started");
// Runnable runnable = new Runnable() {
// @Override
// public void run() {
try { try {
List<Event> events = new ArrayList<>(); List<Event> events = new ArrayList<>();
//retrieve sensor data. //retrieve sensor data.
@ -312,10 +308,6 @@ public class DataPublisherService extends Service {
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
Log.e(TAG, "Data Publish Failed", e); Log.e(TAG, "Data Publish Failed", e);
} }
// }
// };
// Thread dataUploaderThread = new Thread(runnable);
// dataUploaderThread.start();
return Service.START_NOT_STICKY; return Service.START_NOT_STICKY;
} }
} }

@ -236,6 +236,5 @@ public class AndroidSenseMQTTHandler extends MQTTTransportHandler {
public void processIncomingMessage(MqttMessage message) throws TransportHandlerException { public void processIncomingMessage(MqttMessage message) throws TransportHandlerException {
} }
} }

@ -38,5 +38,4 @@ public class SenseScheduleReceiver extends BroadcastReceiver {
cal.add(Calendar.SECOND, 10); cal.add(Calendar.SECOND, 10);
service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), ALARM_INTERVAL, pending); service.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), ALARM_INTERVAL, pending);
} }
} }

@ -59,7 +59,6 @@ public class SenseService extends Service {
SenseDataReceiverManager.registerNetworkDataReader(this); SenseDataReceiverManager.registerNetworkDataReader(this);
//service will not be stopped until we manually stop the service //service will not be stopped until we manually stop the service
return Service.START_NOT_STICKY; return Service.START_NOT_STICKY;
} }
@Override @Override

@ -25,7 +25,6 @@ import android.net.TrafficStats;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import org.wso2.carbon.iot.android.sense.util.SenseDataHolder; import org.wso2.carbon.iot.android.sense.util.SenseDataHolder;
import java.util.Date; import java.util.Date;

@ -56,7 +56,6 @@ public class SensorDataReader extends DataReader implements SensorEventListener
for (Sensor sensor : sensorList) { for (Sensor sensor : sensorList) {
mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL); mSensorManager.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
} }
} }
private void collectSensorData() { private void collectSensorData() {
@ -112,5 +111,4 @@ public class SensorDataReader extends DataReader implements SensorEventListener
} }
} }
} }
} }

@ -73,7 +73,6 @@ public class ActivitySelectSensor extends AppCompatActivity
private ListView listView; private ListView listView;
private SensorManager sensorManager; private SensorManager sensorManager;
private ArrayList<Sensor> sensors = new ArrayList<>(); private ArrayList<Sensor> sensors = new ArrayList<>();
// private EditText sessionIdText;
private RealTimeSensorReader sensorReader = null; private RealTimeSensorReader sensorReader = null;
private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver(); private RealTimeSensorChangeReceiver realTimeSensorChangeReceiver = new RealTimeSensorChangeReceiver();
private SupportedSensors supportedSensors = SupportedSensors.getInstance(); private SupportedSensors supportedSensors = SupportedSensors.getInstance();
@ -87,22 +86,10 @@ public class ActivitySelectSensor extends AppCompatActivity
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar); setSupportActionBar(toolbar);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
//sessionIdText = (EditText) findViewById(R.id.sessionId);
// sessionIdText.setCursorVisible(false);
listView = (ListView) findViewById(R.id.senseListContainer); listView = (ListView) findViewById(R.id.senseListContainer);
//verifyBluetooth();
registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap")); registerReceiver(realTimeSensorChangeReceiver, new IntentFilter("sensorDataMap"));
// sessionIdText.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// sessionIdText.setCursorVisible(true);
//
// }
// });
//Publish data //Publish data
FloatingActionButton fbtnPublishData = (FloatingActionButton) findViewById(R.id.publish); 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); sharedPreferences = getSharedPreferences(SupportedSensors.SELECTED_SENSORS, 0);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
@ -223,7 +181,6 @@ public class ActivitySelectSensor extends AppCompatActivity
finish(); finish();
return true; return true;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -272,7 +229,6 @@ public class ActivitySelectSensor extends AppCompatActivity
realTimeSensorChangeReceiver.updateOnChange(adaptor1); realTimeSensorChangeReceiver.updateOnChange(adaptor1);
listView.setAdapter(adaptor1); listView.setAdapter(adaptor1);
} }
public void update() { public void update() {
@ -305,51 +261,10 @@ public class ActivitySelectSensor extends AppCompatActivity
} }
} }
/** /**
* This method unregisters the real-time broadcast receiver. * This method unregisters the real-time broadcast receiver.
*/ */
public void unregisterReceivers() { public void unregisterReceivers() {
unregisterReceiver(realTimeSensorChangeReceiver); 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();
//
// }
//
// }
} }

@ -33,5 +33,4 @@ public class TempStore {
* Array List which is used to populate the List view. * Array List which is used to populate the List view.
*/ */
public static ArrayList<RealTimeSensor> sensorArrayList = new ArrayList<>(); public static ArrayList<RealTimeSensor> sensorArrayList = new ArrayList<>();
} }

@ -37,5 +37,4 @@ public class RealTimeSensorChangeReceiver extends BroadcastReceiver {
TempStore.sensorArrayList.clear(); TempStore.sensorArrayList.clear();
TempStore.sensorArrayList.addAll(TempStore.sensorDataMap.values()); TempStore.sensorArrayList.addAll(TempStore.sensorDataMap.values());
} }
} }

@ -58,5 +58,4 @@ public class RealTimeSensorReader implements SensorEventListener {
@Override @Override
public void onAccuracyChanged(Sensor sensor, int accuracy) { public void onAccuracyChanged(Sensor sensor, int accuracy) {
} }
} }

@ -60,6 +60,4 @@ public class AvailableSensorsInDevice {
editor.putStringSet(SupportedSensors.GET_AVAILABLE_SENSORS, sensorSet); editor.putStringSet(SupportedSensors.GET_AVAILABLE_SENSORS, sensorSet);
editor.apply(); editor.apply();
} }
} }

@ -119,5 +119,4 @@ public class SupportedSensors {
public String getType(int type) { public String getType(int type) {
return typeSensorMap.get(type); return typeSensorMap.get(type);
} }
} }

@ -83,7 +83,6 @@ public class SensorViewAdaptor extends BaseAdapter {
holder.valuesZ.setText(data.getValueZ()); holder.valuesZ.setText(data.getValueZ());
return view; return view;
} }
private class ViewHolder { private class ViewHolder {

@ -36,7 +36,6 @@ import java.util.Set;
* Get the user selections * Get the user selections
* Put them in to shared preferences * Put them in to shared preferences
*/ */
public class SelectSensorDialog extends DialogFragment { public class SelectSensorDialog extends DialogFragment {
protected boolean[] selections = new boolean[SupportedSensors.SUPPORTED_SENSOR_COUNT]; protected boolean[] selections = new boolean[SupportedSensors.SUPPORTED_SENSOR_COUNT];
@ -79,7 +78,6 @@ public class SelectSensorDialog extends DialogFragment {
Log.d("Click", "Ok"); Log.d("Click", "Ok");
//call sensorDataMap reading class //call sensorDataMap reading class
sensorListListener.onDialogPositiveClick(SelectSensorDialog.this); sensorListListener.onDialogPositiveClick(SelectSensorDialog.this);
} }
}); });
@ -96,7 +94,6 @@ public class SelectSensorDialog extends DialogFragment {
} }
} }
}); });
return builder.create(); return builder.create();
} }
@ -143,5 +140,4 @@ public class SelectSensorDialog extends DialogFragment {
public interface SensorListListener { public interface SensorListListener {
void onDialogPositiveClick(SelectSensorDialog dialog); void onDialogPositiveClick(SelectSensorDialog dialog);
} }
} }

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidActivityScript</Name> <Name>AndroidActivityScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidAudioScript</Name> <Name>AndroidAudioScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidBatteryScript</Name> <Name>AndroidBatteryScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidCallScript</Name> <Name>AndroidCallScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidDataScript</Name> <Name>AndroidDataScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>AndroidFrequentContactsScript</Name> <Name>AndroidFrequentContactsScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<Analytics> <Analytics>
<Editable>true</Editable> <Editable>true</Editable>
<Name>HeadsetScript</Name> <Name>HeadsetScript</Name>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -1,4 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<EventStoreConfiguration> <EventStoreConfiguration>
<TableSchema> <TableSchema>
<ColumnDefinition> <ColumnDefinition>

@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener;
public class AndroidSensePermissionUpdateListener implements ServletContextListener { public class AndroidSensePermissionUpdateListener implements ServletContextListener {
private static Log log = LogFactory.getLog(AndroidSensePermissionUpdateListener.class); private static Log log = LogFactory.getLog(AndroidSensePermissionUpdateListener.class);
private static PrivilegedCarbonContext threadLocalCarbonContext;
private static RealmService realmService;
@Override @Override
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null);
UserStoreManager userStoreManager = getUserStoreManager(); UserStoreManager userStoreManager = getUserStoreManager();
try { try {
if (userStoreManager != null) { if (userStoreManager != null) {
@ -47,7 +50,8 @@ public class AndroidSensePermissionUpdateListener implements ServletContextListe
getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME, getAuthorizationManager().authorizeRole(AndroidSenseConstants.ROLE_NAME,
AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); 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); 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() { private UserStoreManager getUserStoreManager() {
RealmService realmService;
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return userStoreManager; return userStoreManager;
} }
public static AuthorizationManager getAuthorizationManager() { private AuthorizationManager getAuthorizationManager() {
RealmService realmService;
AuthorizationManager authorizationManager; AuthorizationManager authorizationManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return authorizationManager; return authorizationManager;
} }
private Permission[] getPermissions() { private Permission[] getPermissions() {
Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE, Permission androidSense = new Permission(AndroidSenseConstants.PERM_ENROLL_ANDROID_SENSE,
CarbonConstants.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants Permission view = new Permission(AndroidSenseConstants.PERM_OWNING_DEVICE_VIEW,
.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
return new Permission[]{androidSense, view}; return new Permission[]{androidSense, view};
} }
} }

@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener;
public class ArduinoPermissionUpdateListener implements ServletContextListener { public class ArduinoPermissionUpdateListener implements ServletContextListener {
private static Log log = LogFactory.getLog(ArduinoPermissionUpdateListener.class); private static Log log = LogFactory.getLog(ArduinoPermissionUpdateListener.class);
private static PrivilegedCarbonContext threadLocalCarbonContext;
private static RealmService realmService;
@Override @Override
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null);
UserStoreManager userStoreManager = getUserStoreManager(); UserStoreManager userStoreManager = getUserStoreManager();
try { try {
if (userStoreManager != null) { if (userStoreManager != null) {
@ -47,7 +50,8 @@ public class ArduinoPermissionUpdateListener implements ServletContextListener {
getAuthorizationManager().authorizeRole(ArduinoConstants.ROLE_NAME, getAuthorizationManager().authorizeRole(ArduinoConstants.ROLE_NAME,
ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); 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); 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() { private UserStoreManager getUserStoreManager() {
RealmService realmService;
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return userStoreManager; return userStoreManager;
} }
public static AuthorizationManager getAuthorizationManager() { private AuthorizationManager getAuthorizationManager() {
RealmService realmService;
AuthorizationManager authorizationManager; AuthorizationManager authorizationManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return authorizationManager; return authorizationManager;
} }
private Permission[] getPermissions() { private Permission[] getPermissions() {
Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO, Permission androidSense = new Permission(ArduinoConstants.PERM_ENROLL_ARDUINO,
CarbonConstants.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants Permission view = new Permission(ArduinoConstants.PERM_OWNING_DEVICE_VIEW,
.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
return new Permission[]{androidSense, view}; return new Permission[]{androidSense, view};
} }
} }

@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener;
public class RaspberryPIPermissionUpdateListener implements ServletContextListener { public class RaspberryPIPermissionUpdateListener implements ServletContextListener {
private static Log log = LogFactory.getLog(RaspberryPIPermissionUpdateListener.class); private static Log log = LogFactory.getLog(RaspberryPIPermissionUpdateListener.class);
private static PrivilegedCarbonContext threadLocalCarbonContext;
private static RealmService realmService;
@Override @Override
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null);
UserStoreManager userStoreManager = getUserStoreManager(); UserStoreManager userStoreManager = getUserStoreManager();
try { try {
if (userStoreManager != null) { if (userStoreManager != null) {
@ -47,7 +50,8 @@ public class RaspberryPIPermissionUpdateListener implements ServletContextListen
getAuthorizationManager().authorizeRole(RaspberrypiConstants.ROLE_NAME, getAuthorizationManager().authorizeRole(RaspberrypiConstants.ROLE_NAME,
RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); 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); 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() { private UserStoreManager getUserStoreManager() {
RealmService realmService;
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return userStoreManager; return userStoreManager;
} }
public static AuthorizationManager getAuthorizationManager() { private AuthorizationManager getAuthorizationManager() {
RealmService realmService;
AuthorizationManager authorizationManager; AuthorizationManager authorizationManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return authorizationManager; return authorizationManager;
} }
private Permission[] getPermissions() { private Permission[] getPermissions() {
Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI, Permission androidSense = new Permission(RaspberrypiConstants.PERM_ENROLL_RASPBERRYPI,
CarbonConstants.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants Permission view = new Permission(RaspberrypiConstants.PERM_OWNING_DEVICE_VIEW,
.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
return new Permission[]{androidSense, view}; return new Permission[]{androidSense, view};
} }
} }

@ -32,10 +32,13 @@ import javax.servlet.ServletContextListener;
public class VirtualFireAlarmPermissionUpdateListener implements ServletContextListener { public class VirtualFireAlarmPermissionUpdateListener implements ServletContextListener {
private static Log log = LogFactory.getLog(VirtualFireAlarmPermissionUpdateListener.class); private static Log log = LogFactory.getLog(VirtualFireAlarmPermissionUpdateListener.class);
private static PrivilegedCarbonContext threadLocalCarbonContext;
private static RealmService realmService;
@Override @Override
public void contextInitialized(ServletContextEvent servletContextEvent) { public void contextInitialized(ServletContextEvent servletContextEvent) {
threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) threadLocalCarbonContext.getOSGiService(RealmService.class, null);
UserStoreManager userStoreManager = getUserStoreManager(); UserStoreManager userStoreManager = getUserStoreManager();
try { try {
if (userStoreManager != null) { if (userStoreManager != null) {
@ -47,7 +50,8 @@ public class VirtualFireAlarmPermissionUpdateListener implements ServletContextL
getAuthorizationManager().authorizeRole(VirtualFireAlarmConstants.ROLE_NAME, getAuthorizationManager().authorizeRole(VirtualFireAlarmConstants.ROLE_NAME,
VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants.UI_PERMISSION_ACTION); 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); 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() { private UserStoreManager getUserStoreManager() {
RealmService realmService;
UserStoreManager userStoreManager; UserStoreManager userStoreManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager(); userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();
realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return userStoreManager; return userStoreManager;
} }
public static AuthorizationManager getAuthorizationManager() { private AuthorizationManager getAuthorizationManager() {
RealmService realmService;
AuthorizationManager authorizationManager; AuthorizationManager authorizationManager;
try { try {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
realmService = (RealmService) ctx.getOSGiService(RealmService.class, null);
if (realmService == null) { if (realmService == null) {
String msg = "Realm service has not initialized."; String msg = "Realm service has not initialized.";
log.error(msg);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
int tenantId = ctx.getTenantId(); int tenantId = threadLocalCarbonContext.getTenantId();
authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager(); authorizationManager = realmService.getTenantUserRealm(tenantId).getAuthorizationManager();
} catch (UserStoreException e) { } catch (UserStoreException e) {
String msg = "Error occurred while retrieving current user store manager"; String msg = "Error occurred while retrieving current user store manager";
log.error(msg, e);
throw new IllegalStateException(msg); throw new IllegalStateException(msg);
} }
return authorizationManager; return authorizationManager;
} }
private Permission[] getPermissions() { private Permission[] getPermissions() {
Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM, Permission androidSense = new Permission(VirtualFireAlarmConstants.PERM_ENROLL_FIRE_ALARM,
CarbonConstants.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW, CarbonConstants Permission view = new Permission(VirtualFireAlarmConstants.PERM_OWNING_DEVICE_VIEW,
.UI_PERMISSION_ACTION); CarbonConstants.UI_PERMISSION_ACTION);
return new Permission[]{androidSense, view}; return new Permission[]{androidSense, view};
} }
} }

@ -33,9 +33,9 @@ import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException;
* Accept Type(s): (STRING, STRING) * Accept Type(s): (STRING, STRING)
* Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT) * 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 @Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors, protected void init(ExpressionExecutor[] attributeExpressionExecutors,
@ -47,32 +47,34 @@ public class getPropertyFunctionExtension extends FunctionExecutor {
} }
if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) { if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException( 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() + Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType()
.toString()); .toString());
} }
if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) { if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException( throw new ExecutionPlanValidationException(
"Invalid parameter type found for the second argument of json:getProperty() function, " + "required " "Invalid parameter type found for the second argument of json:getProperty() function, required "
+ Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType() + Attribute.Type.STRING + ", but found "
.toString()); + attributeExpressionExecutors[1].getReturnType().toString());
} }
} }
@Override @Override
protected Object execute(Object[] data) { protected Object execute(Object[] data) {
if (data[0] == null) { 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) { 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 jsonString = (String) data[0];
String property = (String) data[1]; String property = (String) data[1];
JSONObject jsonObject = null; Object jsonObject;
try { try {
jsonObject = new JSONObject(jsonString); jsonObject = new JSONObject(jsonString).get(property);
return jsonObject.get(property).toString(); return jsonObject == null ? null : jsonObject.toString();
} catch (JSONException e) { } catch (JSONException e) {
throw new ExecutionPlanRuntimeException("Cannot parse JSON String in json:getPeroperty() function. " + e); throw new ExecutionPlanRuntimeException("Cannot parse JSON String in json:getPeroperty() function. " + e);
} }
@ -80,7 +82,8 @@ public class getPropertyFunctionExtension extends FunctionExecutor {
@Override @Override
protected Object execute(Object data) { 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 @Override

@ -16,4 +16,4 @@
# under the License. # under the License.
# #
getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension getProperty=org.wso2.extension.siddhi.execution.json.GetPropertyFunctionExtension

@ -45,7 +45,7 @@ public class getPropertyFunctionTestCase {
@Test @Test
public void testGetPropertyFunctionExtension() throws InterruptedException { public void testGetPropertyFunctionExtension() throws InterruptedException {
log.info("getPropertyFunctionExtension TestCase"); log.info("GetPropertyFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager(); SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);"; String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);";

@ -107,7 +107,6 @@ var generatePolicyProfile = function () {
return windowsOperationModule.generateProfile(configuredOperations); return windowsOperationModule.generateProfile(configuredOperations);
}; };
/** /**
* Checks if provided number is valid against a range. * 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 // End of HTML embedded invoke methods
// Start of functions related to grid-input-view // Start of functions related to grid-input-view
/** /**
* Method to set count id to cloned elements. * Method to set count id to cloned elements.

Loading…
Cancel
Save