Merge branch 'portal' of https://github.com/Megala21/carbon-device-mgt into release-2.0.x

# Conflicts:
#	components/device-mgt/org.wso2.carbon.device.mgt.ui/src/main/resources/jaggeryapps/devicemgt/app/units/cdmf.unit.ui.navbar.nav-menu/nav-menu.hbs
revert-70aa11f8
charitha 8 years ago
commit 1c8e4b8de7

@ -0,0 +1,68 @@
/*
* 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.extensions.device.type.deployer.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for Device type authorization requirement.
* <p/>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p/>
* <pre>
* &lt;complexType name="DeviceAuthorizationConfig">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="authorizationRequired" type="{http://www.w3.org/2001/XMLSchema}boolean"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "DeviceAuthorizationConfig", propOrder = {
"authorizationRequired"
})
public class DeviceAuthorizationConfig {
@XmlElement(name = "authorizationRequired")
protected boolean authorizationRequired;
/**
* Gets the value of the sharedWithAllTenants property.
*/
public boolean isAuthorizationRequired() {
return authorizationRequired;
}
/**
* Sets the value of the sharedWithAllTenants property.
*/
public void setAuthorizationRequired(boolean authorizationRequired) {
this.authorizationRequired = authorizationRequired;
}
}

@ -27,9 +27,9 @@ import javax.xml.bind.annotation.XmlRootElement;
/** /**
* <p>Java class for DeviceTypeConfiguration complex type. * <p>Java class for DeviceTypeConfiguration complex type.
* * <p/>
* <p>The following schema fragment specifies the expected content contained within this class. * <p>The following schema fragment specifies the expected content contained within this class.
* * <p/>
* <pre> * <pre>
* &lt;complexType name="DeviceTypeConfiguration"> * &lt;complexType name="DeviceTypeConfiguration">
* &lt;complexContent> * &lt;complexContent>
@ -41,14 +41,13 @@ import javax.xml.bind.annotation.XmlRootElement;
* &lt;element name="PushNotificationProvider" type="{}PushNotificationProvider"/> * &lt;element name="PushNotificationProvider" type="{}PushNotificationProvider"/>
* &lt;element name="License" type="{}License"/> * &lt;element name="License" type="{}License"/>
* &lt;element name="DataSource" type="{}DataSource"/> * &lt;element name="DataSource" type="{}DataSource"/>
* &lt;element name="DeviceAuthorizationConfig" type="{}DeviceAuthorizationConfig"/>
* &lt;/sequence> * &lt;/sequence>
* &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" /> * &lt;attribute name="name" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;/restriction> * &lt;/restriction>
* &lt;/complexContent> * &lt;/complexContent>
* &lt;/complexType> * &lt;/complexType>
* </pre> * </pre>
*
*
*/ */
@XmlAccessorType(XmlAccessType.FIELD) @XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "DeviceTypeConfiguration") @XmlRootElement(name = "DeviceTypeConfiguration")
@ -68,6 +67,8 @@ public class DeviceTypeConfiguration {
protected DataSource dataSource; protected DataSource dataSource;
@XmlElement(name = "TaskConfiguration", required = true) @XmlElement(name = "TaskConfiguration", required = true)
private TaskConfiguration taskConfiguration; private TaskConfiguration taskConfiguration;
@XmlElement(name = "DeviceAuthorizationConfig", required = true)
protected DeviceAuthorizationConfig deviceAuthorizationConfig;
@XmlAttribute(name = "name") @XmlAttribute(name = "name")
protected String name; protected String name;
@ -97,11 +98,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the deviceDetails property. * Gets the value of the deviceDetails property.
* *
* @return * @return possible object is
* possible object is * {@link DeviceDetails }
* {@link DeviceDetails }
*
*/ */
public DeviceDetails getDeviceDetails() { public DeviceDetails getDeviceDetails() {
return deviceDetails; return deviceDetails;
@ -109,11 +108,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the deviceDetails property. * Sets the value of the deviceDetails property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link DeviceDetails }
* {@link DeviceDetails }
*
*/ */
public void setDeviceDetails(DeviceDetails value) { public void setDeviceDetails(DeviceDetails value) {
this.deviceDetails = value; this.deviceDetails = value;
@ -121,11 +118,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the features property. * Gets the value of the features property.
* *
* @return * @return possible object is
* possible object is * {@link Features }
* {@link Features }
*
*/ */
public Features getFeatures() { public Features getFeatures() {
return features; return features;
@ -133,11 +128,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the features property. * Sets the value of the features property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link Features }
* {@link Features }
*
*/ */
public void setFeatures(Features value) { public void setFeatures(Features value) {
this.features = value; this.features = value;
@ -145,11 +138,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the provisioningConfig property. * Gets the value of the provisioningConfig property.
* *
* @return * @return possible object is
* possible object is * {@link ProvisioningConfig }
* {@link ProvisioningConfig }
*
*/ */
public ProvisioningConfig getProvisioningConfig() { public ProvisioningConfig getProvisioningConfig() {
return provisioningConfig; return provisioningConfig;
@ -157,11 +148,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the provisioningConfig property. * Sets the value of the provisioningConfig property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link ProvisioningConfig }
* {@link ProvisioningConfig }
*
*/ */
public void setProvisioningConfig(ProvisioningConfig value) { public void setProvisioningConfig(ProvisioningConfig value) {
this.provisioningConfig = value; this.provisioningConfig = value;
@ -169,11 +158,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the pushNotificationProvider property. * Gets the value of the pushNotificationProvider property.
* *
* @return * @return possible object is
* possible object is * {@link PushNotificationProvider }
* {@link PushNotificationProvider }
*
*/ */
public PushNotificationProvider getPushNotificationProvider() { public PushNotificationProvider getPushNotificationProvider() {
return pushNotificationProvider; return pushNotificationProvider;
@ -181,11 +168,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the pushNotificationProvider property. * Sets the value of the pushNotificationProvider property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link PushNotificationProvider }
* {@link PushNotificationProvider }
*
*/ */
public void setPushNotificationProvider(PushNotificationProvider value) { public void setPushNotificationProvider(PushNotificationProvider value) {
this.pushNotificationProvider = value; this.pushNotificationProvider = value;
@ -193,11 +178,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the license property. * Gets the value of the license property.
* *
* @return * @return possible object is
* possible object is * {@link License }
* {@link License }
*
*/ */
public License getLicense() { public License getLicense() {
return license; return license;
@ -205,11 +188,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the license property. * Sets the value of the license property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link License }
* {@link License }
*
*/ */
public void setLicense(License value) { public void setLicense(License value) {
this.license = value; this.license = value;
@ -217,11 +198,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the dataSource property. * Gets the value of the dataSource property.
* *
* @return * @return possible object is
* possible object is * {@link DataSource }
* {@link DataSource }
*
*/ */
public DataSource getDataSource() { public DataSource getDataSource() {
return dataSource; return dataSource;
@ -229,11 +208,9 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the dataSource property. * Sets the value of the dataSource property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link DataSource }
* {@link DataSource }
*
*/ */
public void setDataSource(DataSource value) { public void setDataSource(DataSource value) {
this.dataSource = value; this.dataSource = value;
@ -241,11 +218,9 @@ public class DeviceTypeConfiguration {
/** /**
* Gets the value of the name property. * Gets the value of the name property.
* *
* @return * @return possible object is
* possible object is * {@link String }
* {@link String }
*
*/ */
public String getName() { public String getName() {
return name; return name;
@ -253,14 +228,32 @@ public class DeviceTypeConfiguration {
/** /**
* Sets the value of the name property. * Sets the value of the name property.
* *
* @param value * @param value allowed object is
* allowed object is * {@link String }
* {@link String }
*
*/ */
public void setName(String value) { public void setName(String value) {
this.name = value; this.name = value;
} }
/**
* Gets the value of the authorizationRequired property.
*
* @return possible object is
* {@link DeviceAuthorizationConfig }
*/
public DeviceAuthorizationConfig getDeviceAuthorizationConfig() {
return deviceAuthorizationConfig;
}
/**
* Sets the value of the provisioningConfig property.
*
* @param value allowed object is
* {@link DeviceAuthorizationConfig }
*/
public void setDeviceAuthorizationConfig(DeviceAuthorizationConfig value) {
this.deviceAuthorizationConfig = value;
}
} }

@ -30,11 +30,8 @@ import org.wso2.carbon.device.mgt.common.configuration.mgt.PlatformConfiguration
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager; import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceDetails; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.*;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.DeviceTypeConfiguration;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Table;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.util.DeviceTypePluginConstants;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.config.Feature;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeDeployerFileException;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.exception.DeviceTypeMgtPluginException;
import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao.DeviceDAODefinition; import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.dao.DeviceDAODefinition;
@ -65,18 +62,26 @@ public class DeviceTypeManager implements DeviceManager {
private DeviceTypePluginDAOManager deviceTypePluginDAOManager; private DeviceTypePluginDAOManager deviceTypePluginDAOManager;
private LicenseManager licenseManager; private LicenseManager licenseManager;
private boolean propertiesExist; private boolean propertiesExist;
private boolean requiredDeviceTypeAuthorization;
private FeatureManager featureManager; private FeatureManager featureManager;
public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier, public DeviceTypeManager(DeviceTypeConfigIdentifier deviceTypeConfigIdentifier,
DeviceTypeConfiguration deviceTypeConfiguration) { DeviceTypeConfiguration deviceTypeConfiguration) {
deviceType = deviceTypeConfigIdentifier.getDeviceType(); deviceType = deviceTypeConfigIdentifier.getDeviceType();
if (deviceTypeConfiguration.getFeatures() != null && deviceTypeConfiguration.getFeatures().getFeature() != null ) { if (deviceTypeConfiguration.getFeatures() != null && deviceTypeConfiguration.getFeatures().
getFeature() != null) {
List<Feature> features = deviceTypeConfiguration.getFeatures().getFeature(); List<Feature> features = deviceTypeConfiguration.getFeatures().getFeature();
if (features != null) { if (features != null) {
featureManager = new ConfigurationBasedFeatureManager(features); featureManager = new ConfigurationBasedFeatureManager(features);
} }
} }
if (deviceTypeConfiguration.getDeviceAuthorizationConfig() != null) {
requiredDeviceTypeAuthorization = deviceTypeConfiguration.getDeviceAuthorizationConfig().
isAuthorizationRequired();
} else {
requiredDeviceTypeAuthorization = true;
}
//add license to registry. //add license to registry.
this.licenseManager = new RegistryBasedLicenseManager(); this.licenseManager = new RegistryBasedLicenseManager();
try { try {
@ -120,11 +125,11 @@ public class DeviceTypeManager implements DeviceManager {
if (setupOption != null) { if (setupOption != null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " + log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
"to begin"); "to begin");
} }
try { try {
DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType, DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
deviceDAODefinition.getDeviceTableName()); deviceDAODefinition.getDeviceTableName());
} catch (DeviceTypeMgtPluginException e) { } catch (DeviceTypeMgtPluginException e) {
log.error("Exception occurred while initializing device management database schema", e); log.error("Exception occurred while initializing device management database schema", e);
} }
@ -346,7 +351,7 @@ public class DeviceTypeManager implements DeviceManager {
@Override @Override
public boolean requireDeviceAuthorization() { public boolean requireDeviceAuthorization() {
return true; return requiredDeviceTypeAuthorization;
} }
@Override @Override
@ -370,7 +375,7 @@ public class DeviceTypeManager implements DeviceManager {
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction(); deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction();
} catch (DeviceTypeMgtPluginException e1) { } catch (DeviceTypeMgtPluginException e1) {
log.warn("Error occurred while roll back the update device info transaction : '" + log.warn("Error occurred while roll back the update device info transaction : '" +
device.toString() + "'", e1); device.toString() + "'", e1);
} }
throw new DeviceManagementException( throw new DeviceManagementException(
"Error occurred while updating the " + deviceType + " device: '" + "Error occurred while updating the " + deviceType + " device: '" +

@ -69,7 +69,7 @@ public class DeviceTypePluginDAO {
device = new Device(); device = new Device();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() + log.debug(deviceId + " data has been fetched from " + deviceDAODefinition.getDeviceTableName() +
" database."); " database.");
} }
List<Device.Property> properties = new ArrayList<>(); List<Device.Property> properties = new ArrayList<>();
for (String columnName : deviceDAODefinition.getColumnNames()) { for (String columnName : deviceDAODefinition.getColumnNames()) {
@ -112,7 +112,7 @@ public class DeviceTypePluginDAO {
status = true; status = true;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("device " + device.getDeviceIdentifier() + " data has been" + log.debug("device " + device.getDeviceIdentifier() + " data has been" +
" added to the " + deviceDAODefinition.getDeviceTableName() + " database."); " added to the " + deviceDAODefinition.getDeviceTableName() + " database.");
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -170,7 +170,7 @@ public class DeviceTypePluginDAO {
status = true; status = true;
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("device " + deviceId + " data has deleted from the " + log.debug("device " + deviceId + " data has deleted from the " +
deviceDAODefinition.getDeviceTableName() + " table."); deviceDAODefinition.getDeviceTableName() + " table.");
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
@ -241,7 +241,7 @@ public class DeviceTypePluginDAO {
private String getPropertString(List<Device.Property> properties, String propertyName) { private String getPropertString(List<Device.Property> properties, String propertyName) {
for (Device.Property property : properties) { for (Device.Property property : properties) {
if (property.getName().equals(propertyName)) { if (property.getName() != null && property.getName().equals(propertyName)) {
return property.getValue(); return property.getValue();
} }
} }
@ -257,7 +257,7 @@ public class DeviceTypePluginDAO {
+ getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")"; + getPreparedInputString(deviceDAODefinition.getColumnNames().size() + 1) + ")";
updateDBQueryForUpdateDevice = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET " updateDBQueryForUpdateDevice = "UPDATE " + deviceDAODefinition.getDeviceTableName() + " SET "
+ getDeviceTableColumnNamesForUpdateQuery()+ " WHERE " + deviceDAODefinition.getPrimaryKey() + getDeviceTableColumnNamesForUpdateQuery() + " WHERE " + deviceDAODefinition.getPrimaryKey()
+ " = ?"; + " = ?";
deleteDBQueryToRemoveDevicd = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() deleteDBQueryToRemoveDevicd = "DELETE FROM " + deviceDAODefinition.getDeviceTableName()

@ -63,6 +63,10 @@
<SharedWithAllTenants>false</SharedWithAllTenants> <SharedWithAllTenants>false</SharedWithAllTenants>
</ProvisioningConfig> </ProvisioningConfig>
<DeviceAuthorizationConfig>
<authorizationRequired>true</authorizationRequired>
</DeviceAuthorizationConfig>
<PushNotificationProvider type="MQTT"> <PushNotificationProvider type="MQTT">
<FileBasedProperties>true</FileBasedProperties> <FileBasedProperties>true</FileBasedProperties>
<!--if file based properties is set to false then the configuration will be picked from platform configuration--> <!--if file based properties is set to false then the configuration will be picked from platform configuration-->

Loading…
Cancel
Save