Merge pull request #309 from ayyoob/com

Fix issues raised in the comments
revert-dabc3590
Milan Perera 9 years ago committed by GitHub
commit 2998c1e4ac

@ -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;

@ -42,7 +42,7 @@ public class PropertyUtils {
ServerConfiguration carbonConfig = ServerConfiguration.getInstance(); ServerConfiguration carbonConfig = ServerConfiguration.getInstance();
String portOffset = System.getProperty("portOffset", carbonConfig.getFirstProperty(CARBON_CONFIG_PORT_OFFSET)); String portOffset = System.getProperty("portOffset", carbonConfig.getFirstProperty(CARBON_CONFIG_PORT_OFFSET));
try { try {
if ((portOffset != null)) { if (portOffset != null) {
return Integer.parseInt(portOffset.trim()); return Integer.parseInt(portOffset.trim());
} else { } else {
return CARBON_DEFAULT_PORT_OFFSET; return CARBON_DEFAULT_PORT_OFFSET;

@ -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);
} }
} }

@ -18,9 +18,9 @@ public class ServiceHolder {
.getThreadLocalCarbonContext().getOSGiService(UIOutputCallbackControllerService.class, null); .getThreadLocalCarbonContext().getOSGiService(UIOutputCallbackControllerService.class, null);
} }
public synchronized static ServiceHolder getInstance(){ public synchronized static ServiceHolder getInstance() {
if (instance==null){ if (instance == null) {
instance= new ServiceHolder(); instance = new ServiceHolder();
} }
return instance; return instance;
} }

@ -1,34 +1,31 @@
/* /*
* * Copyright (c) 2016, 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,
* * * Version 2.0 (the "License"); you may not use this file except
* * WSO2 Inc. licenses this file to you under the Apache License, * in compliance with the License.
* * Version 2.0 (the "License"); you may not use this file except * You may obtain a copy of the License at
* * in compliance with the License. *
* * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0
* * *
* * 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
* * Unless required by applicable law or agreed to in writing, * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* * software distributed under the License is distributed on an * KIND, either express or implied. See the License for the
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * specific language governing permissions and limitations
* * KIND, either express or implied. See the License for the * under the License.
* * specific language governing permissions and limitations */
* * under the License.
* *
*
*/
package util; 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,
@ -31,10 +30,10 @@ import java.util.concurrent.LinkedBlockingDeque;
public final class UIEventAdaptorServiceDataHolder { 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);
} }
} }

@ -34,7 +34,7 @@ public class DeviceTypeConfigServiceImpl implements DeviceTypeConfigService {
String deviceType = deviceManagementConfiguration.getDeviceType(); String deviceType = deviceManagementConfiguration.getDeviceType();
String tenantDomain = deviceManagementConfiguration.getDeviceManagementConfigRepository() String tenantDomain = deviceManagementConfiguration.getDeviceManagementConfigRepository()
.getProvisioningConfig().getTenantDomain(); .getProvisioningConfig().getTenantDomain();
if ( deviceType != null && !deviceType.isEmpty() && tenantDomain != null if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
&& !tenantDomain.isEmpty()) { && !tenantDomain.isEmpty()) {
deviceTypeConfigurationMap.put(new DeviceTypeConfigIdentifier(deviceType, tenantDomain), deviceTypeConfigurationMap.put(new DeviceTypeConfigIdentifier(deviceType, tenantDomain),
deviceManagementConfiguration); deviceManagementConfiguration);

@ -45,7 +45,7 @@ public class XmppConfig {
List<PushNotificationConfig.Property> properties = deviceManagementConfiguration.getPushNotificationConfig() List<PushNotificationConfig.Property> properties = deviceManagementConfiguration.getPushNotificationConfig()
.getProperties(); .getProperties();
String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider(); String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
if (provider.equals("XMPP")) { if ("XMPP".equals(provider)) {
enabled = true; enabled = true;
} }
if (enabled) { if (enabled) {

Loading…
Cancel
Save