mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge pull request #309 from ayyoob/com
Fix issues raised in the comments
This commit is contained in:
commit
2998c1e4ac
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -42,7 +42,7 @@ public class PropertyUtils {
|
||||
ServerConfiguration carbonConfig = ServerConfiguration.getInstance();
|
||||
String portOffset = System.getProperty("portOffset", carbonConfig.getFirstProperty(CARBON_CONFIG_PORT_OFFSET));
|
||||
try {
|
||||
if ((portOffset != null)) {
|
||||
if (portOffset != null) {
|
||||
return Integer.parseInt(portOffset.trim());
|
||||
} else {
|
||||
return CARBON_DEFAULT_PORT_OFFSET;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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";
|
||||
|
||||
@ -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<String, String> 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<String, String> tenantSpecificAdapterMap = UIEventAdaptorServiceDataHolder
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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<Integer,ConcurrentHashMap<String, String>>
|
||||
tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<Integer,ConcurrentHashMap<String, String>>();
|
||||
private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, String>>
|
||||
tenantSpecificOutputEventStreamAdapterMap = new ConcurrentHashMap<>();
|
||||
private static ConcurrentHashMap<Integer, ConcurrentHashMap<String, LinkedBlockingDeque<Object>>>
|
||||
tenantSpecificStreamEventMap = new ConcurrentHashMap<Integer, ConcurrentHashMap<String, LinkedBlockingDeque<Object>>>();
|
||||
tenantSpecificStreamEventMap = new ConcurrentHashMap<>();
|
||||
private static EventStreamService eventStreamService;
|
||||
|
||||
public static void registerEventStreamService(EventStreamService eventBuilderService) {
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ public class DeviceTypeConfigServiceImpl implements DeviceTypeConfigService {
|
||||
String deviceType = deviceManagementConfiguration.getDeviceType();
|
||||
String tenantDomain = deviceManagementConfiguration.getDeviceManagementConfigRepository()
|
||||
.getProvisioningConfig().getTenantDomain();
|
||||
if ( deviceType != null && !deviceType.isEmpty() && tenantDomain != null
|
||||
if (deviceType != null && !deviceType.isEmpty() && tenantDomain != null
|
||||
&& !tenantDomain.isEmpty()) {
|
||||
deviceTypeConfigurationMap.put(new DeviceTypeConfigIdentifier(deviceType, tenantDomain),
|
||||
deviceManagementConfiguration);
|
||||
|
||||
@ -45,7 +45,7 @@ public class XmppConfig {
|
||||
List<PushNotificationConfig.Property> properties = deviceManagementConfiguration.getPushNotificationConfig()
|
||||
.getProperties();
|
||||
String provider = deviceManagementConfiguration.getPushNotificationConfig().getPushNotificationProvider();
|
||||
if (provider.equals("XMPP")) {
|
||||
if ("XMPP".equals(provider)) {
|
||||
enabled = true;
|
||||
}
|
||||
if (enabled) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user