mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge pull request #486 from Vishanth/release-2.0.x
Fixing some multi tenancy issues
This commit is contained in:
commit
c42260feb6
@ -20,6 +20,7 @@ package org.wso2.carbon.device.mgt.extensions.device.type.deployer.template;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
@ -41,6 +42,7 @@ import org.wso2.carbon.device.mgt.extensions.device.type.deployer.template.util.
|
|||||||
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
|
import org.wso2.carbon.device.mgt.extensions.license.mgt.registry.RegistryBasedLicenseManager;
|
||||||
import org.wso2.carbon.registry.api.RegistryException;
|
import org.wso2.carbon.registry.api.RegistryException;
|
||||||
import org.wso2.carbon.registry.api.Resource;
|
import org.wso2.carbon.registry.api.Resource;
|
||||||
|
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBContext;
|
import javax.xml.bind.JAXBContext;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
@ -118,25 +120,34 @@ public class DeviceTypeManager implements DeviceManager {
|
|||||||
throw new DeviceTypeDeployerFileException("Could not find definition for table: " + tableName);
|
throw new DeviceTypeDeployerFileException("Could not find definition for table: " + tableName);
|
||||||
}
|
}
|
||||||
propertiesExist = true;
|
propertiesExist = true;
|
||||||
DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
|
|
||||||
String datasourceName = deviceTypeConfiguration.getDataSource().getJndiConfig().getName();
|
try {
|
||||||
if (datasourceName != null && !datasourceName.isEmpty()) {
|
PrivilegedCarbonContext.startTenantFlow();
|
||||||
String setupOption = System.getProperty("setup");
|
PrivilegedCarbonContext.getThreadLocalCarbonContext()
|
||||||
if (setupOption != null) {
|
.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME, true);
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
|
DeviceDAODefinition deviceDAODefinition = new DeviceDAODefinition(deviceDefinitionTable);
|
||||||
"to begin");
|
String datasourceName = deviceTypeConfiguration.getDataSource().getJndiConfig().getName();
|
||||||
}
|
if (datasourceName != null && !datasourceName.isEmpty()) {
|
||||||
try {
|
String setupOption = System.getProperty("setup");
|
||||||
DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
|
if (setupOption != null) {
|
||||||
deviceDAODefinition.getDeviceTableName());
|
if (log.isDebugEnabled()) {
|
||||||
} catch (DeviceTypeMgtPluginException e) {
|
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
|
||||||
log.error("Exception occurred while initializing device management database schema", e);
|
"to begin");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
DeviceTypeUtils.setupDeviceManagementSchema(datasourceName, deviceType,
|
||||||
|
deviceDAODefinition.getDeviceTableName());
|
||||||
|
} catch (DeviceTypeMgtPluginException e) {
|
||||||
|
log.error("Exception occurred while initializing device management database schema", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(datasourceName, deviceDAODefinition);
|
||||||
|
} else {
|
||||||
|
throw new DeviceTypeDeployerFileException("Invalid datasource name.");
|
||||||
}
|
}
|
||||||
deviceTypePluginDAOManager = new DeviceTypePluginDAOManager(datasourceName, deviceDAODefinition);
|
} finally {
|
||||||
} else {
|
PrivilegedCarbonContext.endTenantFlow();
|
||||||
throw new DeviceTypeDeployerFileException("Invalid datasource name.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -147,8 +147,8 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE (
|
|||||||
UPDATED_TIME DATETIME NOT NULL ,
|
UPDATED_TIME DATETIME NOT NULL ,
|
||||||
PRIMARY KEY (ID) ,
|
PRIMARY KEY (ID) ,
|
||||||
CONSTRAINT DM_PROFILE_DEVICE_TYPE
|
CONSTRAINT DM_PROFILE_DEVICE_TYPE
|
||||||
FOREIGN KEY (DEVICE_TYPE )
|
FOREIGN KEY (DEVICE_TYPE, TENANT_ID)
|
||||||
REFERENCES DM_DEVICE_TYPE (NAME)
|
REFERENCES DM_DEVICE_TYPE (NAME, PROVIDER_TENANT_ID)
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
@ -200,11 +200,6 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE_POLICY (
|
|||||||
FOREIGN KEY (POLICY_ID )
|
FOREIGN KEY (POLICY_ID )
|
||||||
REFERENCES DM_POLICY (ID )
|
REFERENCES DM_POLICY (ID )
|
||||||
ON DELETE NO ACTION
|
ON DELETE NO ACTION
|
||||||
ON UPDATE NO ACTION,
|
|
||||||
CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE
|
|
||||||
FOREIGN KEY (DEVICE_TYPE )
|
|
||||||
REFERENCES DM_DEVICE_TYPE (NAME)
|
|
||||||
ON DELETE NO ACTION
|
|
||||||
ON UPDATE NO ACTION
|
ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user