From 81117d00c4da77a13f4641d800c775128e82040d Mon Sep 17 00:00:00 2001 From: charithag Date: Tue, 16 Feb 2016 19:21:43 +0530 Subject: [PATCH 1/2] Change water dispensor category --- .../feature/src/main/resources/configs/currentsensor.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 60844dc9..a2ca2cec 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,7 +1,7 @@ { "deviceType": { "label": "Water Dispensor", - "category": "virtual" + "category": "iot" }, "analyticStreams": [ { From ae08246052180a7511c187d373e1c546dbcea3df Mon Sep 17 00:00:00 2001 From: charithag Date: Tue, 16 Feb 2016 23:07:20 +0530 Subject: [PATCH 2/2] fix issues --- .../doormanager/component/controller/pom.xml | 5 -- .../api/DoorManagerControllerService.java | 69 +++++++++--------- .../impl/dao/impl/DoorManagerDAOImpl.java | 1 - .../src/main/resources/carbonapps/Sensor.car | Bin 6981 -> 0 bytes .../resources/database/doormanagerDM_DB.h2.db | Bin 18432 -> 0 bytes 5 files changed, 36 insertions(+), 39 deletions(-) delete mode 100644 modules/samples/doormanager/feature/feature/src/main/resources/carbonapps/Sensor.car delete mode 100644 modules/samples/doormanager/feature/feature/src/main/resources/database/doormanagerDM_DB.h2.db 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 a0d543eabf82094e0da19f13c0440585bd761aac..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6981 zcma)BbzGBO*q*@1k{1Qk?5x*L>6K#)%9aD;@k zAgF}jc;nO8m)Gw*|Lp9y-?{GdoL%R-?)!f9Ah>wM001EX;CWM96Y$eu!p_xvVD4T> zm>ta72Zppk!Q4>@q|GG}Q4!ILdjGpn&sOgr3+ew}i1I=pVgI%2*KiC!Rv}?fxBu_5 z^VnsE9#EtU$`0x5;f4BTcZ7gjQ4r0oBf%>O900%#4*(GVJI>jU^~Vz%{PT%LZo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^Td8MNTt%^2g*VBK@? zJV84Pwx*EikQ5IRl2(yt3Y7V>xoA~D)XF7j!CM{U8b$V+t-!1xE{7obJ~R{!UW4DVjuuOisjPZ#6g`( zaf8vIJ2or2C1T^boMVDB^hwm1Ne}i2J}8h&Xf=}4C6iz)T&6I^v0aXM9~1H@xn5Sm1G5mRtC^hjPgjOC<|^<5rJqNdQ?6>79)S6BEmN)}Ms= zHqwwc-^4J5v=iXxDXk1q#|eh$L7Iqf1U$pgupV6XpOc-FHKsQge(>=1G0H|mYumQA zlT&VweugJwhl|CxV-MBYATS_X`lTX{R@~GzgbB(0CG?249^WlwnRfMF90y(1;}ra= z?&j63k{Y#+%v}=^0p03^6*AVm?{)y-TjN|uPhzbu3?zw%|C;2}pyb*9IgXUx`OeD> zIiktUPI5ImOPyXS1x$B%AEfPBh}F2`8hCI;GTA*>>?m|q$#PbW{?hfvfWT1xJ${5G zSeYfiejb}0t*QvXL7+*4T8H}kt`1%r;ME$$Xxjd@fZkHMWN5+2@@O|V-7Kjy3C52! zIzh&kKdtH(W1Fw<`p7Y&5zr)wM>#E08NDy=bakTC8#&ZJz`iP=ygLz3Hhwdv%doJc zo0qQo{ScTtTHt~MLeQQ<5hy^}!MtLOP6KmyiSeiPttjX0HvpFz*+di?+dd8QYti^4$PJSJ4f5|l{dfERwN&^4*@P9^zxMra z$p2sA@bmu9O0<6j+ax=aZU0KUe?~k#kzbRHABb0}&P4pLvpCCTet^YN|Kd4%5FoZ# SI5i_u04w%w5+&W~xBme|e}04j 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 f10636ac5326291f4076f1083040d790b00005ca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18432 zcmeI&J#W)M7zgl_v~}yMLJ`PFwQv@+z&|1|JF|T69~lY`0|ih31yBG5P~e;br6*qp$sgjnI$M~YlD^DK?`7%D zg7o5?Jzxw4Pyhu`00mHBd;+Vmy3z?+Esbc}eWK}_p_!Vc)wH?_YWeU^XLzRq73E|b z08~!4m9F;(CCk$I3df#N00mG01yBG5CQP7oGe7_5rzfl~EC&Tp00mG01yEpo0;L=I z`9Fu}|M-ltXB0pI6hHwKm^6XXx6gS=(*=1-`dE}+&qyyN>G{0$Y(aXwIJ+(Ak z6&%*0v3EQiyG|0cl34s`RCFs4weF5eu`YGJggOpqVK^#GZCj+0DCjW%C~N$>QqEeU z%l4?Stg3?h!_*nvp>P`~_30`3i^{TE5##%G*7!~@m_J)c!^P&)E<2i>-z=lCOr!!! zi%*C1m@m+sFfeS&n}H7@70Xyjb)(72E!s1Sq@NwmAgfZT#|@A$p^X%M+x7Q_*Vy+M8gaxF?L