From e3a11b0a446f6981acc2b432d7239d3aa7c790e3 Mon Sep 17 00:00:00 2001 From: ayyoob Date: Tue, 24 Jan 2017 19:57:25 +0530 Subject: [PATCH] resolved merge issues --- .../impl/VirtualFireAlarmServiceImpl.java | 34 ------------------- .../service/impl/util/APIUtil.java | 13 ------- 2 files changed, 47 deletions(-) diff --git a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java index f5bb1d84b1..b283bcb3db 100644 --- a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java +++ b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/VirtualFireAlarmServiceImpl.java @@ -134,40 +134,6 @@ public class VirtualFireAlarmServiceImpl implements VirtualFireAlarmService { } } - @PUT - @Path("device/{deviceId}/policy") - public Response updatePolicy(@PathParam("deviceId") String deviceId, @QueryParam("protocol") String protocol, - @FormParam("policy") String policy) { - String protocolString = protocol.toUpperCase(); - if (log.isDebugEnabled()) { - log.debug("Sending request to update-policy of device [" + deviceId + "] via " + protocolString); - } - try { - if (!APIUtil.getDeviceAccessAuthorizationService().isUserAuthorized( - new DeviceIdentifier(deviceId, VirtualFireAlarmConstants.DEVICE_TYPE), - DeviceGroupConstants.Permissions.DEFAULT_MANAGE_POLICIES_PERMISSIONS)) { - return Response.status(Response.Status.UNAUTHORIZED.getStatusCode()).build(); - } - String actualMessage = VirtualFireAlarmConstants.POLICY_CONTEXT + ":" + policy; - Map dynamicProperties = new HashMap<>(); - String publishTopic = APIUtil.getTenantDomainOftheUser() + "/" - + VirtualFireAlarmConstants.DEVICE_TYPE + "/" + deviceId; - dynamicProperties.put(VirtualFireAlarmConstants.ADAPTER_TOPIC_PROPERTY, publishTopic); - dynamicProperties.put(VirtualFireAlarmConstants.JID_PROPERTY_KEY, - deviceId + "@" + XmppConfig.getInstance().getServerName()); - dynamicProperties.put(VirtualFireAlarmConstants.SUBJECT_PROPERTY_KEY, "POLICTY-REQUEST"); - dynamicProperties.put(VirtualFireAlarmConstants.MESSAGE_TYPE_PROPERTY_KEY, - VirtualFireAlarmConstants.CHAT_PROPERTY_KEY); - APIUtil.getOutputEventAdapterService().publish(VirtualFireAlarmConstants.XMPP_ADAPTER_NAME, - dynamicProperties, actualMessage); - return Response.ok().build(); - } catch (DeviceAccessAuthorizationException e) { - log.error(e.getErrorMessage(), e); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); - } - } - - @Path("device/stats/{deviceId}") @GET @Consumes("application/json") diff --git a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java index d302e72811..bbcf1acef0 100644 --- a/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java +++ b/src/main/java/org/wso2/carbon/device/mgt/iot/virtualfirealarm/service/impl/util/APIUtil.java @@ -16,7 +16,6 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfigurationManagementService; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.device.mgt.iot.virtualfirealarm.service.impl.dto.SensorRecord; -import org.wso2.carbon.event.output.adapter.core.OutputEventAdapterService; import org.wso2.carbon.identity.jwt.client.extension.service.JWTClientManagerService; import java.util.ArrayList; @@ -169,18 +168,6 @@ public class APIUtil { return deviceAccessAuthorizationService; } - public static OutputEventAdapterService getOutputEventAdapterService() { - PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); - OutputEventAdapterService outputEventAdapterService = - (OutputEventAdapterService) ctx.getOSGiService(OutputEventAdapterService.class, null); - if (outputEventAdapterService == null) { - String msg = "Device Authorization service has not initialized."; - log.error(msg); - throw new IllegalStateException(msg); - } - return outputEventAdapterService; - } - public static PlatformConfigurationManagementService getTenantConfigurationManagementService() { PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext(); PlatformConfigurationManagementService tenantConfigurationManagementService =