Merge remote-tracking branch 'origin/master'

Conflicts:
	modules/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/transport/ConnectedCupMQTTConnector.java
	modules/samples/connectedcup/component/api/src/main/java/org/coffeeking/api/util/ConnectedCupServiceUtils.java
	modules/samples/connectedcup/component/controller/src/main/java/org/coffeeking/controller/service/ConnectedCupControllerService.java
	modules/samples/connectedcup/component/manager/src/main/java/org/coffeeking/manager/service/ConnectedCupManagerService.java
	modules/samples/connectedcup/component/manager/src/main/webapp/WEB-INF/cxf-servlet.xml
	modules/samples/currentsensor/component/api/src/main/java/org/homeautomation/currentsensor/api/util/CurrentSensorServiceUtils.java
	modules/samples/currentsensor/component/controller/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorControllerService.java
	modules/samples/currentsensor/component/manager/src/main/java/org/homeautomation/currentsensor/manager/api/CurrentSensorManagerService.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/constants/CurrentSensorConstants.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManager.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/CurrentSensorManagerService.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/CurrentSensorDAOUtil.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/dao/impl/CurrentSensorDeviceDAOImpl.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/impl/util/CurrentSensorUtils.java
	modules/samples/currentsensor/component/plugin/src/main/java/org/homeautomation/currentsensor/plugin/internal/ServiceComponent.java
	modules/samples/firealarm/component/controller/src/main/java/org.homeautomation/firealarm/controller/api/ControllerService.java
application-manager-new
NuwanSameera 9 years ago
commit ab7ee2dbb8

@ -100,8 +100,7 @@
var deviceId = '<%=request.getSession().getAttribute("deviceId")%>'; var deviceId = '<%=request.getSession().getAttribute("deviceId")%>';
var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>'; var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>';
var token = '<%=request.getSession().getAttribute("token")%>'; var token = '<%=request.getSession().getAttribute("token")%>';
var url = "/connectedcup/controller/ordercoffee?deviceId=" + deviceId +"&deviceOwner=" + var url = "/connectedcup/controller/ordercoffee?deviceId=" + deviceId + "&deviceOwner=" + deviceOwner;
deviceOwner;
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
@ -114,8 +113,7 @@
}); });
function sendData() function sendData() {
{
var deviceId = '<%=request.getSession().getAttribute("deviceId")%>'; var deviceId = '<%=request.getSession().getAttribute("deviceId")%>';
var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>'; var deviceOwner = '<%=request.getSession().getAttribute("deviceOwner")%>';
var tempPayload = "temperature:" + temperature; var tempPayload = "temperature:" + temperature;

@ -26,10 +26,18 @@ import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement @XmlRootElement
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DeviceJSON { public class DeviceJSON {
@XmlElement(required = true) public String owner;
@XmlElement(required = true) public String deviceId; @XmlElement(required = true)
@XmlElement(required = true) public String reply; public String owner;
@XmlElement public Long time; @XmlElement(required = true)
@XmlElement public String key; public String deviceId;
@XmlElement public float value; @XmlElement(required = true)
public String reply;
@XmlElement
public Long time;
@XmlElement
public String key;
@XmlElement
public float value;
} }

@ -19,6 +19,7 @@
package org.coffeeking.api.exception; package org.coffeeking.api.exception;
public class ConnectedCupException extends Exception { public class ConnectedCupException extends Exception {
private static final long serialVersionUID = 118512086957330189L; private static final long serialVersionUID = 118512086957330189L;
public ConnectedCupException(String errorMessage) { public ConnectedCupException(String errorMessage) {
@ -28,4 +29,5 @@ public class ConnectedCupException extends Exception {
public ConnectedCupException(String errorMessage, Throwable throwable) { public ConnectedCupException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable); super(errorMessage, throwable);
} }
} }

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!-- This file contains the list of permissions that are associated with URL end points
of the web app. Each permission should contain the name, permission path ,API path
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
NOTE: All the endpoints of the web app should be available in this file. Otherwise
it will result 403 error at the runtime.
-->
<PermissionConfiguration>
<APIVersion></APIVersion>
<!-- Device related APIs -->
<Permission>
<name>Request coffee level</name>
<path>/device-mgt/devices/connectedcup/coffeelevel</path>
<url>/controller/coffeelevel</url>
<method>GET</method>
<scope>connectedcup_user</scope>
</Permission>
<Permission>
<name>Request temperature</name>
<path>/device-mgt/devices/connectedcup/temperature</path>
<url>/controller/temperature</url>
<method>GET</method>
<scope>connectedcup_user</scope>
</Permission>
<Permission>
<name>Order coffee cup</name>
<path>/device-mgt/devices/connectedcup/ordercoffee</path>
<url>/controller/ordercoffee</url>
<method>POST</method>
<scope>connectedcup_user</scope>
</Permission>
</PermissionConfiguration>

@ -0,0 +1,36 @@
package org.coffeeking.manager.service.util;
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;
/**
* This class provides utility functions used by REST-API.
*/
public class APIUtil {
private static Log log = LogFactory.getLog(APIUtil.class);
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
public static DeviceManagementProviderService getDeviceManagementService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceManagementProviderService 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;
}
}

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!-- This file contains the list of permissions that are associated with URL end points
of the web app. Each permission should contain the name, permission path ,API path
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
NOTE: All the endpoints of the web app should be available in this file. Otherwise
it will result 403 error at the runtime.
-->
<PermissionConfiguration>
<APIVersion></APIVersion>
<!-- Device related APIs -->
<Permission>
<name>Get device</name>
<path>/device-mgt/user/devices/list</path>
<url>/manager/device/{device_id}</url>
<method>GET</method>
<scope></scope>
</Permission>
<Permission>
<name>Add device</name>
<path>/device-mgt/user/devices/add</path>
<url>/manager/device</url>
<method>POST</method>
<scope></scope>
</Permission>
<Permission>
<name>Remove device</name>
<path>/device-mgt/user/devices/remove</path>
<url>/manager/device/{device_id}</url>
<method>DELETE</method>
<scope></scope>
</Permission>
<Permission>
<name>Update device</name>
<path>/device-mgt/user/devices/update</path>
<url>/manager/device/{device_id}</url>
<method>POST</method>
<scope></scope>
</Permission>
</PermissionConfiguration>

@ -145,8 +145,7 @@ function downloadAgent() {
payload.name = $inputs[0].value; payload.name = $inputs[0].value;
payload.owner = $inputs[1].value; payload.owner = $inputs[1].value;
var connectedCupRegisterURL = "/connectedcup_mgt/connectedcup/cup/register?" + var connectedCupRegisterURL = "/connectedcup_mgt/manager/device?name=" + encodeURI(payload.name);
"name=" + encodeURI(payload.name) + "&owner=" + payload.owner;
invokerUtil.post( invokerUtil.post(
connectedCupRegisterURL, connectedCupRegisterURL,

@ -27,11 +27,20 @@ import javax.xml.bind.annotation.XmlRootElement;
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
public class DeviceJSON { public class DeviceJSON {
@XmlElement(required = true) public String owner;
@XmlElement(required = true) public String deviceId; @XmlElement(required = true)
@XmlElement(required = true) public String reply; public String owner;
@XmlElement public Long time; @XmlElement(required = true)
@XmlElement public String key; public String deviceId;
@XmlElement public float current; @XmlElement(required = true)
@XmlElement public float flow_rate; public String reply;
@XmlElement
public Long time;
@XmlElement
public String key;
@XmlElement
public float current;
@XmlElement
public float flow_rate;
} }

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!-- This file contains the list of permissions that are associated with URL end points
of the web app. Each permission should contain the name, permission path ,API path
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
NOTE: All the endpoints of the web app should be available in this file. Otherwise
it will result 403 error at the runtime.
-->
<PermissionConfiguration>
<APIVersion></APIVersion>
<!-- Device related APIs -->
<Permission>
<name></name>
<path>/device-mgt/devices/currentsensor/register</path>
<url>/controller/register/{owner}/{deviceId}/{ip}/{port}</url>
<method>POST</method>
<scope>currentsensor_device</scope>
</Permission>
<Permission>
<name></name>
<path>/device-mgt/devices/currentsensor/read-current</path>
<url>/controller/read-current</url>
<method>GET</method>
<scope>currentsensor_user</scope>
</Permission>
<Permission>
<name></name>
<path>/device-mgt/devices/currentsensor/read-power</path>
<url>/controller/read-power</url>
<method>GET</method>
<scope>currentsensor_user</scope>
</Permission>
<Permission>
<name></name>
<path>/device-mgt/devices/currentsensor/read-flowrate</path>
<url>/controller/read-flowrate</url>
<method>GET</method>
<scope>currentsensor_user</scope>
</Permission>
<Permission>
<name></name>
<path>/device-mgt/devices/currentsensor/push-data</path>
<url>/controller/push-data</url>
<method>POST</method>
<scope>currentsensor_device</scope>
</Permission>
</PermissionConfiguration>

@ -0,0 +1,36 @@
package org.homeautomation.currentsensor.manager.api.util;
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;
/**
* This class provides utility functions used by REST-API.
*/
public class APIUtil {
private static Log log = LogFactory.getLog(APIUtil.class);
public static String getAuthenticatedUser() {
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
String username = threadLocalCarbonContext.getUsername();
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
if (username.endsWith(tenantDomain)) {
return username.substring(0, username.lastIndexOf("@"));
}
return username;
}
public static DeviceManagementProviderService getDeviceManagementService() {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
DeviceManagementProviderService 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;
}
}

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ WSO2 Inc. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<!-- This file contains the list of permissions that are associated with URL end points
of the web app. Each permission should contain the name, permission path ,API path
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
NOTE: All the endpoints of the web app should be available in this file. Otherwise
it will result 403 error at the runtime.
-->
<PermissionConfiguration>
<APIVersion></APIVersion>
<!-- Device related APIs -->
<Permission>
<name>Get device</name>
<path>/device-mgt/user/devices/list</path>
<url>/manager/device/{device_id}</url>
<method>GET</method>
<scope></scope>
</Permission>
<Permission>
<name>Add device</name>
<path>/device-mgt/user/devices/add</path>
<url>/manager/device</url>
<method>POST</method>
<scope></scope>
</Permission>
<Permission>
<name>Remove device</name>
<path>/device-mgt/user/devices/remove</path>
<url>/manager/device/{device_id}</url>
<method>DELETE</method>
<scope></scope>
</Permission>
<Permission>
<name>Download device</name>
<path>/device-mgt/user/devices/add</path>
<url>/manager/device/{sketch_type}/download</url>
<method>GET</method>
<scope></scope>
</Permission>
<Permission>
<name>Update device</name>
<path>/device-mgt/user/devices/update</path>
<url>/manager/device/{device_id}</url>
<method>POST</method>
<scope></scope>
</Permission>
</PermissionConfiguration>

@ -1,5 +1,5 @@
<div class="col-lg-12 margin-top-double"> <div class="col-lg-12 margin-top-double">
<h1 class="grey ">Smart Meeter</h1> <h1 class="grey ">Smart Meter</h1>
<hr> <hr>
</div> </div>

@ -16,7 +16,7 @@
} }
}, },
{ {
"name": "Power x100", "name": "Power",
"table": "DEVICE_POWER_SUMMARY", "table": "DEVICE_POWER_SUMMARY",
"ui_unit": { "ui_unit": {
"name": "cdmf.unit.analytics.line-chart", "name": "cdmf.unit.analytics.line-chart",
@ -27,7 +27,7 @@
} }
}, },
{ {
"name": "Flow Rate x100", "name": "Flow Rate",
"table": "DEVICE_FLOWRATE_SUMMARY", "table": "DEVICE_FLOWRATE_SUMMARY",
"ui_unit": { "ui_unit": {
"name": "cdmf.unit.analytics.line-chart", "name": "cdmf.unit.analytics.line-chart",

Loading…
Cancel
Save