diff --git a/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json b/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json
index 42eafe51..909b708d 100644
--- a/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json
+++ b/modules/samples/currentsensor/feature/feature/src/main/resources/configs/currentsensor.json
@@ -1,8 +1,7 @@
{
"deviceType": {
"label": "Smart Meeter",
- "category": "virtual"
-
+ "category": "iot"
},
"analyticStreams": [
{
diff --git a/modules/samples/doormanager/component/controller/pom.xml b/modules/samples/doormanager/component/controller/pom.xml
index cb8bb3c9..9d222daf 100644
--- a/modules/samples/doormanager/component/controller/pom.xml
+++ b/modules/samples/doormanager/component/controller/pom.xml
@@ -224,10 +224,5 @@
org.wso2.carbon.user.core
4.4.3
-
- org.wso2.carbon
- org.wso2.carbon.user.core
- 4.4.3
-
\ No newline at end of file
diff --git a/modules/samples/doormanager/component/controller/src/main/java/org.homeautomation/doormanager/controller/api/DoorManagerControllerService.java b/modules/samples/doormanager/component/controller/src/main/java/org.homeautomation/doormanager/controller/api/DoorManagerControllerService.java
index 2426b883..2924a442 100644
--- a/modules/samples/doormanager/component/controller/src/main/java/org.homeautomation/doormanager/controller/api/DoorManagerControllerService.java
+++ b/modules/samples/doormanager/component/controller/src/main/java/org.homeautomation/doormanager/controller/api/DoorManagerControllerService.java
@@ -58,16 +58,17 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.*;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
@API(name = "doormanager", version = "1.0.0", context = "/doormanager")
@DeviceType(value = "doormanager")
public class DoorManagerControllerService {
private static final DoorManagerDAO DOOR_MANAGER_DAO = new DoorManagerDAO();
- @Context //injected response proxy supporting multiple thread
private static Log log = LogFactory.getLog(DoorManagerControllerService.class);
private HttpServletResponse response;
@@ -76,6 +77,8 @@ public class DoorManagerControllerService {
private PrivilegedCarbonContext ctx;
+ @Context //injected response proxy supporting multiple thread
+
private UserStoreManager getUserStoreManager() throws UserStoreException {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
PrivilegedCarbonContext.startTenantFlow();
@@ -144,36 +147,36 @@ public class DoorManagerControllerService {
@FormParam("policy") String policy,
@FormParam("cardNumber") String cardNumber,
@FormParam("userName") String userName,
- @Context HttpServletResponse response){
+ @Context HttpServletResponse response) {
try {
- if (userName != null && cardNumber != null && deviceId != null) {
- try {
- UserStoreManager userStoreManager = this.getUserStoreManager();
- if (userStoreManager.isExistingUser(userName)) {
- TokenClient accessTokenClient = new TokenClient(DoorManagerConstants.DEVICE_TYPE);
- AccessTokenInfo accessTokenInfo = accessTokenClient.getAccessToken(deviceId, userName);
- String accessToken = accessTokenInfo.getAccess_token();
- if (accessToken == null) {
- response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
- return;
- }
- Map claims = new HashMap<>();
- claims.put("http://wso2.org/claims/lock/accesstoken", accessToken);
- claims.put("http://wso2.org/claims/lock/refreshtoken", accessTokenInfo.getRefresh_token());
- claims.put("http://wso2.org/claims/lock/cardnumber", cardNumber);
- userStoreManager.setUserClaimValues(userName, claims, null);
- //TODO: Add content to dto
- } else {
- response.setStatus(Response.Status.NOT_FOUND.getStatusCode());
+ if (userName != null && cardNumber != null && deviceId != null) {
+ try {
+ UserStoreManager userStoreManager = this.getUserStoreManager();
+ if (userStoreManager.isExistingUser(userName)) {
+ TokenClient accessTokenClient = new TokenClient(DoorManagerConstants.DEVICE_TYPE);
+ AccessTokenInfo accessTokenInfo = accessTokenClient.getAccessToken(deviceId, userName);
+ String accessToken = accessTokenInfo.getAccess_token();
+ if (accessToken == null) {
+ response.setStatus(Response.Status.UNAUTHORIZED.getStatusCode());
+ return;
}
- } catch (UserStoreException e) {
- response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
- log.error(e);
+ Map claims = new HashMap<>();
+ claims.put("http://wso2.org/claims/lock/accesstoken", accessToken);
+ claims.put("http://wso2.org/claims/lock/refreshtoken", accessTokenInfo.getRefresh_token());
+ claims.put("http://wso2.org/claims/lock/cardnumber", cardNumber);
+ userStoreManager.setUserClaimValues(userName, claims, null);
+ //TODO: Add content to dto
+ response.setStatus(Response.Status.OK.getStatusCode());
+ } else {
+ response.setStatus(Response.Status.NOT_FOUND.getStatusCode());
}
+ } catch (UserStoreException e) {
+ response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
+ log.error(e);
}
- else {
- response.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
- }
+ } else {
+ response.setStatus(Response.Status.BAD_REQUEST.getStatusCode());
+ }
} catch (AccessTokenException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
@@ -326,14 +329,14 @@ public class DoorManagerControllerService {
@Context HttpServletResponse response) {
try {
int lockerCurrentState;
- if(state.toUpperCase().equals("LOCK")){
+ if (state.toUpperCase().equals("LOCK")) {
lockerCurrentState = 0;
- }else{
+ } else {
lockerCurrentState = 1;
}
SensorDataManager.getInstance().setSensorRecord(deviceId, "door_locker_state",
- String.valueOf(lockerCurrentState), Calendar.getInstance().getTimeInMillis());
- doorManagerMQTTConnector.sendCommandViaMQTT(owner, deviceId,"DoorManager:", state.toUpperCase());
+ String.valueOf(lockerCurrentState), Calendar.getInstance().getTimeInMillis());
+ doorManagerMQTTConnector.sendCommandViaMQTT(owner, deviceId, "DoorManager:", state.toUpperCase());
response.setStatus(Response.Status.OK.getStatusCode());
} catch (DeviceManagementException e) {
log.error(e);
diff --git a/modules/samples/doormanager/component/plugin/src/main/java/org.homeautomation/doormanager/plugin/impl/dao/impl/DoorManagerDAOImpl.java b/modules/samples/doormanager/component/plugin/src/main/java/org.homeautomation/doormanager/plugin/impl/dao/impl/DoorManagerDAOImpl.java
index ccb5126e..7876773b 100644
--- a/modules/samples/doormanager/component/plugin/src/main/java/org.homeautomation/doormanager/plugin/impl/dao/impl/DoorManagerDAOImpl.java
+++ b/modules/samples/doormanager/component/plugin/src/main/java/org.homeautomation/doormanager/plugin/impl/dao/impl/DoorManagerDAOImpl.java
@@ -57,7 +57,6 @@ public class DoorManagerDAOImpl {
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceId);
resultSet = stmt.executeQuery();
-
if (resultSet.next()) {
automaticDoorLockerDevice = new Device();
automaticDoorLockerDevice.setName(resultSet.getString(
diff --git a/modules/samples/doormanager/feature/feature/src/main/resources/carbonapps/Sensor.car b/modules/samples/doormanager/feature/feature/src/main/resources/carbonapps/Sensor.car
deleted file mode 100644
index a0d543ea..00000000
Binary files a/modules/samples/doormanager/feature/feature/src/main/resources/carbonapps/Sensor.car and /dev/null differ
diff --git a/modules/samples/doormanager/feature/feature/src/main/resources/database/doormanagerDM_DB.h2.db b/modules/samples/doormanager/feature/feature/src/main/resources/database/doormanagerDM_DB.h2.db
deleted file mode 100644
index f10636ac..00000000
Binary files a/modules/samples/doormanager/feature/feature/src/main/resources/database/doormanagerDM_DB.h2.db and /dev/null differ