Fixed Issues raised in the comments

revert-dabc3590
ayyoob 8 years ago
parent 95ca419d17
commit 20cf418394

@ -139,9 +139,7 @@ public class ArduinoServiceImpl implements ArduinoService {
return Response.status(Response.Status.ACCEPTED.getStatusCode()).entity(result).build(); return Response.status(Response.Status.ACCEPTED.getStatusCode()).entity(result).build();
} catch (NoSuchElementException ex) { } catch (NoSuchElementException ex) {
result = "There are no more controls for device " + deviceId + " of owner " + owner; result = "There are no more controls for device " + deviceId + " of owner " + owner;
if (log.isDebugEnabled()) { log.error(result, ex);
log.debug(result);
}
return Response.status(Response.Status.NO_CONTENT.getStatusCode()).entity(result).build(); return Response.status(Response.Status.NO_CONTENT.getStatusCode()).entity(result).build();
} }
} }

@ -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; package org.wso2.carbon.device.mgt.iot.input.adapter.extension;
import java.util.Map; import java.util.Map;

@ -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; package org.wso2.carbon.device.mgt.iot.input.adapter.extension;
import java.util.Map; import java.util.Map;

@ -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; package org.wso2.carbon.device.mgt.iot.input.adapter.extension;
import java.util.Map; import java.util.Map;

@ -78,7 +78,7 @@ public class SuperTenantSubscriptionEndpoint extends SubscriptionEndpoint {
try { try {
session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access")); session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access"));
} catch (IOException e) { } catch (IOException e) {
log.error("Failed to disconnect the unauthorized client."); log.error("Failed to disconnect the unauthorized client.", e);
} }
} }
} }

@ -77,7 +77,7 @@ public class TenantSubscriptionEndpoint extends SubscriptionEndpoint {
try { try {
session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access")); session.close(new CloseReason(CloseReason.CloseCodes.CANNOT_ACCEPT, "Unauthorized Access"));
} catch (IOException e) { } 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 @OnMessage
public void onMessage (Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) { public void onMessage (Session session, String message, @PathParam("streamname") String streamName, @PathParam("tdomain") String tdomain) {
if (log.isDebugEnabled()) { 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);
} }
} }

@ -1,23 +1,19 @@
/* /*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* * * WSO2 Inc. licenses this file to you under the Apache License,
* * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Version 2.0 (the "License"); you may not use this file except
* * * in compliance with the License.
* * WSO2 Inc. licenses this file to you under the Apache License, * You may obtain a copy of the License at
* * 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.
* *
* *
* 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; package util;
@ -25,10 +21,11 @@ package util;
/** /**
* This class contains the constants related to ui client. * This class contains the constants related to ui client.
*/ */
public class UIConstants { public final class UIConstants {
private UIConstants() { private UIConstants() {
} }
public static final String ADAPTER_UI_COLON = ":"; public static final String ADAPTER_UI_COLON = ":";
public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection"; public static final String MAXIMUM_TOTAL_HTTP_CONNECTION = "maximumTotalHttpConnection";
public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost"; public static final String MAXIMUM_HTTP_CONNECTION_PER_HOST = "maximumHttpConnectionPerHost";

@ -1,5 +1,4 @@
/* /*
*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
@ -78,7 +77,6 @@ public class UIEventAdapter implements OutputEventAdapter {
@Override @Override
public void init() throws OutputEventAdapterException { public void init() throws OutputEventAdapterException {
tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(); tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
//ExecutorService will be assigned if it is null //ExecutorService will be assigned if it is null
@ -198,7 +196,6 @@ public class UIEventAdapter implements OutputEventAdapter {
@Override @Override
public void publish(Object message, Map<String, String> dynamicProperties) { public void publish(Object message, Map<String, String> dynamicProperties) {
Event event = (Event) message; Event event = (Event) message;
StringBuilder eventBuilder = new StringBuilder("["); StringBuilder eventBuilder = new StringBuilder("[");
@ -275,7 +272,6 @@ public class UIEventAdapter implements OutputEventAdapter {
@Override @Override
public void destroy() { public void destroy() {
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId(); int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
ConcurrentHashMap<String, String> tenantSpecificAdapterMap = UIEventAdaptorServiceDataHolder ConcurrentHashMap<String, String> tenantSpecificAdapterMap = UIEventAdaptorServiceDataHolder

@ -72,7 +72,8 @@ public class OAuthTokenValdiator {
Properties properties = getWebSocketConfig(); Properties properties = getWebSocketConfig();
this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(properties)); this.stubs = new GenericObjectPool(new OAuthTokenValidaterStubFactory(properties));
} catch (IOException e) { } 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);
} }
} }

@ -30,6 +30,8 @@ import org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory;
import org.apache.commons.httpclient.params.HttpConnectionManagerParams; import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
import org.apache.commons.httpclient.protocol.Protocol; import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; 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.commons.pool.BasePoolableObjectFactory;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.wso2.carbon.device.mgt.iot.output.adapter.ui.authentication.oauth.exception.OAuthTokenValidationException; 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. * This follows object pool pattern to manage the stub for oauth validation service.
*/ */
public class OAuthTokenValidaterStubFactory extends BasePoolableObjectFactory { 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; private HttpClient httpClient;
Properties tokenValidationProperties; Properties tokenValidationProperties;

@ -1,5 +1,4 @@
/* /*
*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,

@ -1,5 +1,4 @@
/* /*
*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* *
* WSO2 Inc. licenses this file to you under the Apache License, * WSO2 Inc. licenses this file to you under the Apache License,
@ -32,9 +31,9 @@ public final class UIEventAdaptorServiceDataHolder {
private static UIOutputCallbackControllerServiceImpl UIOutputCallbackRegisterServiceImpl; private static UIOutputCallbackControllerServiceImpl UIOutputCallbackRegisterServiceImpl;
private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>> private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>>
tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<Integer,ConcurrentHashMap<String, String>>(); tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<>();
private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, LinkedBlockingDeque<Object>>> private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, LinkedBlockingDeque<Object>>>
tenantSpecificStreamEventMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String, LinkedBlockingDeque<Object>>>(); tenantSpecificStreamEventMap = new ConcurrentHashMap<>();
private static EventStreamService eventStreamService; private static EventStreamService eventStreamService;
public static void registerEventStreamService(EventStreamService eventBuilderService) { public static void registerEventStreamService(EventStreamService eventBuilderService) {

@ -88,10 +88,13 @@ public class UILocalEventAdapterServiceComponent {
} catch (WebsocketValidationConfigurationFailedException e) { } catch (WebsocketValidationConfigurationFailedException e) {
log.error("Failed to initialize configuration for websocket.", e); log.error("Failed to initialize configuration for websocket.", e);
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException 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) { } catch (RuntimeException e) {
log.error("Can not create the output ui adapter service ", 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);
} }
} }

Loading…
Cancel
Save