diff --git a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java index a961f63693..e71c9290e7 100644 --- a/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java +++ b/components/iot-plugins/arduino-plugin/org.wso2.carbon.device.mgt.iot.arduino.api/src/main/java/org/wso2/carbon/device/mgt/iot/arduino/service/impl/ArduinoServiceImpl.java @@ -139,9 +139,7 @@ public class ArduinoServiceImpl implements ArduinoService { return Response.status(Response.Status.ACCEPTED.getStatusCode()).entity(result).build(); } catch (NoSuchElementException ex) { result = "There are no more controls for device " + deviceId + " of owner " + owner; - if (log.isDebugEnabled()) { - log.debug(result); - } + log.error(result, ex); return Response.status(Response.Status.NO_CONTENT.getStatusCode()).entity(result).build(); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java index 867783486c..2cad36be59 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/ContentTransformer.java @@ -1,3 +1,21 @@ +/* +* 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. +*/ + package org.wso2.carbon.device.mgt.iot.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java index d4b67e5885..c8c5ab1989 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentTransformer.java @@ -1,3 +1,21 @@ +/* +* 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. +*/ + package org.wso2.carbon.device.mgt.iot.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java index c84375f564..6a41bc270f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.input.adapter.extension/src/main/java/org/wso2/carbon/device/mgt/iot/input/adapter/extension/DefaultContentValidator.java @@ -1,3 +1,21 @@ +/* +* 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. +*/ + package org.wso2.carbon.device.mgt.iot.input.adapter.extension; import java.util.Map; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java index f2556ca95b..da26bb1d78 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/SuperTenantSubscriptionEndpoint.java @@ -78,7 +78,7 @@ public class SuperTenantSubscriptionEndpoint extends SubscriptionEndpoint { try { session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access")); } catch (IOException e) { - log.error("Failed to disconnect the unauthorized client."); + log.error("Failed to disconnect the unauthorized client.", e); } } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java index a4ca1da4b6..58a3e2d82f 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/TenantSubscriptionEndpoint.java @@ -77,7 +77,7 @@ public class TenantSubscriptionEndpoint extends SubscriptionEndpoint { try { session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access")); } catch (IOException e) { - log.error("Failed to disconnect the unauthorized client."); + log.error("Failed to disconnect the unauthorized client.", e); } } } @@ -92,7 +92,8 @@ public class TenantSubscriptionEndpoint extends SubscriptionEndpoint { @OnMessage public void onMessage (Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) { if (log.isDebugEnabled()) { - log.debug("Received and dropped message from client. Message: " + message+", for Session id: "+session.getId()+", for tenant domain"+tdomain+", for the Adaptor:"+streamName); + log.debug("Received and dropped message from client. Message: " + message + ", for Session id: " + + session.getId() + ", for tenant domain" + tdomain + ", for the Adaptor:" + streamName); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java index 0f6d81df56..755fcd7dff 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/ServiceHolder.java @@ -18,9 +18,9 @@ public class ServiceHolder { .getThreadLocalCarbonContext().getOSGiService(UIOutputCallbackControllerService.class, null); } - public synchronized static ServiceHolder getInstance(){ - if (instance==null){ - instance= new ServiceHolder(); + public synchronized static ServiceHolder getInstance() { + if (instance == null) { + instance = new ServiceHolder(); } return instance; } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java index 2db13ce816..162fc34ce4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui.endpoint/src/main/java/util/UIConstants.java @@ -1,34 +1,31 @@ /* - * - * * - * * Copyright (c) 2015, 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. - * * - * - */ +* 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. +*/ package util; /** * This class contains the constants related to ui client. */ -public class UIConstants { +public final class UIConstants { private UIConstants() { } + public static final String ADAPTER_UI_COLON = ":"; public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection"; public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost"; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java index d92bc406fb..807396aac4 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/UIEventAdapter.java @@ -1,5 +1,4 @@ /* - * * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, @@ -78,7 +77,6 @@ public class UIEventAdapter implements OutputEventAdapter { @Override public void init() throws OutputEventAdapterException { - tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); //ExecutorService will be assigned if it is null @@ -198,7 +196,6 @@ public class UIEventAdapter implements OutputEventAdapter { @Override public void publish(Object message, Map dynamicProperties) { - Event event = (Event) message; StringBuilder eventBuilder = new StringBuilder("["); @@ -275,7 +272,6 @@ public class UIEventAdapter implements OutputEventAdapter { @Override public void destroy() { - int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); ConcurrentHashMap tenantSpecificAdapterMap = UIEventAdaptorServiceDataHolder diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java index 9532f6dcd9..5587293fba 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValdiator.java @@ -72,7 +72,8 @@ public class OAuthTokenValdiator { Properties properties = getWebSocketConfig(); this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(properties)); } catch (IOException e) { - log.error("Failed to parse the web socket org.wso2.carbon.device.mgt.iot.output.adapter.ui.config file " + WEBSOCKET_CONFIG_LOCATION); + log.error("Failed to parse the web socket org.wso2.carbon.device.mgt.iot.output.adapter.ui.config file " + + WEBSOCKET_CONFIG_LOCATION, e); } } diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java index d791af42a5..10f056e4c7 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/authentication/oauth/OAuthTokenValidaterStubFactory.java @@ -30,6 +30,8 @@ import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory; import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.commons.pool.BasePoolableObjectFactory; import org.apache.log4j.Logger; import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.exception.OAuthTokenValidationException; @@ -46,7 +48,7 @@ import java.util.Properties; * This follows object pool pattern to manage the stub for oauth validation service. */ public class OAuthTokenValidaterStubFactory extends BasePoolableObjectFactory { - private static final Logger log = Logger.getLogger(OAuthTokenValidaterStubFactory.class); + private static final Log log = LogFactory.getLog(OAuthTokenValidaterStubFactory.class); private HttpClient httpClient; Properties tokenValidationProperties; diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java index 9242e28f70..31a9f1dd44 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/constants/WebsocketConstants.java @@ -1,5 +1,4 @@ /* - * * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java index dd08949851..024c0228ec 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UIEventAdaptorServiceDataHolder.java @@ -1,5 +1,4 @@ /* - * * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, @@ -31,10 +30,10 @@ import java.util.concurrent.LinkedBlockingDeque; public final class UIEventAdaptorServiceDataHolder { private static UIOutputCallbackControllerServiceImpl UIOutputCallbackRegisterServiceImpl; - private static ConcurrentHashMap> - tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap>(); + private static ConcurrentHashMap> + tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap>> - tenantSpecificStreamEventMap = new ConcurrentHashMap>>(); + tenantSpecificStreamEventMap = new ConcurrentHashMap<>(); private static EventStreamService eventStreamService; public static void registerEventStreamService(EventStreamService eventBuilderService) { diff --git a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java index 71897510e0..57d72b9caa 100644 --- a/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java +++ b/components/iot-plugins/iot-base-plugin/org.wso2.carbon.device.mgt.iot.output.adapter.ui/src/main/java/org/wso2/carbon/device/mgt/iot/output/adapter/ui/internal/UILocalEventAdapterServiceComponent.java @@ -88,10 +88,13 @@ public class UILocalEventAdapterServiceComponent { } catch (WebsocketValidationConfigurationFailedException e) { log.error("Failed to initialize configuration for websocket.", e); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) { - e.printStackTrace(); + log.error("Failed to initialize the class authentication and authorization given " + + "in the websocket validation configuration.", e); } } catch (RuntimeException e) { log.error("Can not create the output ui adapter service ", e); + } catch (Throwable e) { + log.error("Error occurred while activating UI Event Adapter Service Component", e); } }