forked from community/device-mgt-core
Merge pull request #980 from sinthuja/origin-wso2-master
Adding first cut of operation management testcases.revert-70aa11f8
commit
26f72a10c7
@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.core;
|
||||
|
||||
import org.wso2.carbon.ntask.common.TaskException;
|
||||
import org.wso2.carbon.ntask.core.TaskInfo;
|
||||
import org.wso2.carbon.ntask.core.TaskManager;
|
||||
import org.wso2.carbon.ntask.core.service.TaskService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class TestTaskServiceImpl implements TaskService {
|
||||
@Override
|
||||
public TaskManager getTaskManager(String s) throws TaskException {
|
||||
return new TaskManager() {
|
||||
@Override
|
||||
public void initStartupTasks() throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleTask(String s) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rescheduleTask(String s) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteTask(String s) throws TaskException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pauseTask(String s) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resumeTask(String s) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTask(TaskInfo taskInfo) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskState getTaskState(String s) throws TaskException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskInfo getTask(String s) throws TaskException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskInfo> getAllTasks() throws TaskException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTaskScheduled(String s) throws TaskException {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskManager> getAllTenantTaskManagersForType(String s) throws TaskException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerTaskType(String s) throws TaskException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getRegisteredTaskTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverInitialized() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerInit() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskServiceConfiguration getServerConfiguration() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAfterRegistrationActions() throws TaskException {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 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.core.operation;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.InvalidDeviceException;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationRequest;
|
||||
import org.wso2.carbon.device.mgt.common.PaginationResult;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Activity;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.ActivityStatus;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
|
||||
import org.wso2.carbon.device.mgt.core.TestDeviceManagementService;
|
||||
import org.wso2.carbon.device.mgt.core.authorization.DeviceAccessAuthorizationServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.common.BaseDeviceManagementTest;
|
||||
import org.wso2.carbon.device.mgt.core.common.TestDataHolder;
|
||||
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
|
||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementServiceComponent;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.CommandOperation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ConfigOperation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.PolicyOperation;
|
||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderServiceImpl;
|
||||
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderServiceImpl;
|
||||
import org.wso2.carbon.registry.core.config.RegistryContext;
|
||||
import org.wso2.carbon.registry.core.exceptions.RegistryException;
|
||||
import org.wso2.carbon.registry.core.internal.RegistryDataHolder;
|
||||
import org.wso2.carbon.registry.core.jdbc.realm.InMemoryRealmService;
|
||||
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||
import org.wso2.carbon.user.core.service.RealmService;
|
||||
import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class OperationManagementTests{
|
||||
private static final Log log = LogFactory.getLog(OperationManagementTests.class);
|
||||
|
||||
private static final String DEVICE_TYPE = "OP_TEST_TYPE";
|
||||
private static final String DEVICE_ID_PREFIX = "OP-TEST-DEVICE-ID-";
|
||||
private static final String COMMAND_OPERATON_CODE = "COMMAND-TEST";
|
||||
private static final String POLICY_OPERATION_CODE = "POLICY-TEST";
|
||||
private static final String CONFIG_OPERATION_CODE = "CONFIG-TEST";
|
||||
private static final String PROFILE_OPERATION_CODE = "PROFILE-TEST";
|
||||
private static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
|
||||
private static final int NO_OF_DEVICES = 5;
|
||||
private static final String ADMIN_USER = "admin";
|
||||
private static final String NON_ADMIN_USER = "test";
|
||||
|
||||
private List<DeviceIdentifier> deviceIds = new ArrayList<>();
|
||||
private OperationManager operationMgtService;
|
||||
|
||||
@BeforeClass
|
||||
public void init() throws Exception {
|
||||
DeviceConfigurationManager.getInstance().initConfig();
|
||||
log.info("Initializing");
|
||||
for (int i = 0; i < NO_OF_DEVICES; i++) {
|
||||
deviceIds.add(new DeviceIdentifier(DEVICE_ID_PREFIX + i, DEVICE_TYPE));
|
||||
}
|
||||
List<Device> devices = TestDataHolder.generateDummyDeviceData(this.deviceIds);
|
||||
DeviceManagementProviderService deviceMgtService = new DeviceManagementProviderServiceImpl();
|
||||
DeviceManagementServiceComponent.notifyStartupListeners();
|
||||
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceMgtService);
|
||||
DeviceManagementDataHolder.getInstance().setRegistryService(getRegistryService());
|
||||
DeviceManagementDataHolder.getInstance().setDeviceAccessAuthorizationService(new DeviceAccessAuthorizationServiceImpl());
|
||||
DeviceManagementDataHolder.getInstance().setGroupManagementProviderService(new GroupManagementProviderServiceImpl());
|
||||
DeviceManagementDataHolder.getInstance().setDeviceTaskManagerService(null);
|
||||
deviceMgtService.registerDeviceType(new TestDeviceManagementService(DEVICE_TYPE,
|
||||
MultitenantConstants.SUPER_TENANT_DOMAIN_NAME));
|
||||
for (Device device : devices) {
|
||||
deviceMgtService.enrollDevice(device);
|
||||
}
|
||||
List<Device> returnedDevices = deviceMgtService.getAllDevices(DEVICE_TYPE);
|
||||
for (Device device : returnedDevices) {
|
||||
if (!device.getDeviceIdentifier().startsWith(DEVICE_ID_PREFIX)) {
|
||||
throw new Exception("Incorrect device with ID - " + device.getDeviceIdentifier() + " returned!");
|
||||
}
|
||||
}
|
||||
this.operationMgtService = new OperationManagerImpl(DEVICE_TYPE);
|
||||
}
|
||||
|
||||
private RegistryService getRegistryService() throws RegistryException {
|
||||
RealmService realmService = new InMemoryRealmService();
|
||||
RegistryDataHolder.getInstance().setRealmService(realmService);
|
||||
DeviceManagementDataHolder.getInstance().setRealmService(realmService);
|
||||
InputStream is = this.getClass().getClassLoader().getResourceAsStream("carbon-home/repository/conf/registry.xml");
|
||||
RegistryContext context = RegistryContext.getBaseInstance(is, realmService);
|
||||
context.setSetup(true);
|
||||
return context.getEmbeddedRegistryService();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCommandOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
Activity activity = this.operationMgtService.addOperation(getOperation(new CommandOperation(), Operation.Type.COMMAND, COMMAND_OPERATON_CODE),
|
||||
this.deviceIds);
|
||||
validateOperationResponse(activity);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "addCommandOperation")
|
||||
public void addPolicyOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
Activity activity = this.operationMgtService.addOperation(getOperation(new PolicyOperation(), Operation.Type.POLICY, POLICY_OPERATION_CODE),
|
||||
this.deviceIds);
|
||||
validateOperationResponse(activity);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "addPolicyOperation")
|
||||
public void addConfigOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
Activity activity = this.operationMgtService.addOperation(getOperation(new ConfigOperation(), Operation.Type.CONFIG, CONFIG_OPERATION_CODE),
|
||||
this.deviceIds);
|
||||
validateOperationResponse(activity);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "addConfigOperation")
|
||||
public void addProfileOperation() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
Activity activity = this.operationMgtService.addOperation(getOperation(new ProfileOperation(), Operation.Type.PROFILE, PROFILE_OPERATION_CODE),
|
||||
this.deviceIds);
|
||||
validateOperationResponse(activity);
|
||||
}
|
||||
|
||||
private Operation getOperation(Operation operation, Operation.Type type, String code) {
|
||||
String date = new SimpleDateFormat(DATE_FORMAT_NOW).format(new Date());
|
||||
operation.setCreatedTimeStamp(date);
|
||||
operation.setType(type);
|
||||
operation.setCode(code);
|
||||
return operation;
|
||||
}
|
||||
|
||||
private void validateOperationResponse(Activity activity) {
|
||||
Assert.assertEquals(activity.getActivityStatus().size(), NO_OF_DEVICES, "The operation reponse for add operation only have - " +
|
||||
activity.getActivityStatus().size());
|
||||
for (ActivityStatus status : activity.getActivityStatus()) {
|
||||
Assert.assertEquals(status.getStatus(), ActivityStatus.Status.PENDING);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "addProfileOperation")
|
||||
public void getOperations() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||
List operations = this.operationMgtService.getOperations(deviceIdentifier);
|
||||
Assert.assertEquals(operations.size(), 4, "The operations should be 4, but found only " + operations.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "getOperations")
|
||||
public void getPendingOperations() throws DeviceManagementException, OperationManagementException, InvalidDeviceException {
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||
List operations = this.operationMgtService.getPendingOperations(deviceIdentifier);
|
||||
Assert.assertEquals(operations.size(), 4, "The pending operations should be 4, but found only " + operations.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "getPendingOperations")
|
||||
public void getPaginatedRequestAsAdmin() throws OperationManagementException {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(ADMIN_USER);
|
||||
PaginationRequest request = new PaginationRequest(1, 2);
|
||||
request.setDeviceType(DEVICE_TYPE);
|
||||
request.setOwner(ADMIN_USER);
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||
PaginationResult result = this.operationMgtService.getOperations(deviceIdentifier, request);
|
||||
Assert.assertEquals(result.getRecordsFiltered(), 4);
|
||||
Assert.assertEquals(result.getData().size(), 2);
|
||||
Assert.assertEquals(result.getRecordsTotal(), 4);
|
||||
}
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "getPendingOperations")
|
||||
public void getPaginatedRequestAsNonAdmin() throws OperationManagementException {
|
||||
PrivilegedCarbonContext.startTenantFlow();
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID, true);
|
||||
PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(NON_ADMIN_USER);
|
||||
PaginationRequest request = new PaginationRequest(1, 2);
|
||||
request.setDeviceType(DEVICE_TYPE);
|
||||
request.setOwner(ADMIN_USER);
|
||||
for (DeviceIdentifier deviceIdentifier : deviceIds) {
|
||||
try {
|
||||
this.operationMgtService.getOperations(deviceIdentifier, request);
|
||||
} catch (OperationManagementException ex) {
|
||||
if (ex.getMessage() == null){
|
||||
Assert.assertTrue(ex.getMessage().contains("User '" + NON_ADMIN_USER + "' is not authorized"));
|
||||
}
|
||||
}
|
||||
}
|
||||
PrivilegedCarbonContext.endTenantFlow();
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "getPaginatedRequestAsAdmin")
|
||||
public void updateOperation() throws OperationManagementException {
|
||||
DeviceIdentifier deviceIdentifier = this.deviceIds.get(0);
|
||||
List operations = this.operationMgtService.getPendingOperations(deviceIdentifier);
|
||||
Assert.assertTrue(operations!= null && operations.size()==4);
|
||||
Operation operation = (Operation) operations.get(0);
|
||||
operation.setStatus(Operation.Status.COMPLETED);
|
||||
operation.setOperationResponse("The operation is successfully completed");
|
||||
this.operationMgtService.updateOperation(deviceIdentifier, operation);
|
||||
List pendingOperations = this.operationMgtService.getPendingOperations(deviceIdentifier);
|
||||
Assert.assertEquals(pendingOperations.size(), 3);
|
||||
}
|
||||
}
|
@ -0,0 +1,429 @@
|
||||
CREATE TABLE IF NOT EXISTS REG_CLUSTER_LOCK (
|
||||
REG_LOCK_NAME VARCHAR (20),
|
||||
REG_LOCK_STATUS VARCHAR (20),
|
||||
REG_LOCKED_TIME TIMESTAMP,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (REG_LOCK_NAME)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_LOG (
|
||||
REG_LOG_ID INTEGER AUTO_INCREMENT,
|
||||
REG_PATH VARCHAR (2000),
|
||||
REG_USER_ID VARCHAR (31) NOT NULL,
|
||||
REG_LOGGED_TIME TIMESTAMP NOT NULL,
|
||||
REG_ACTION INTEGER NOT NULL,
|
||||
REG_ACTION_DATA VARCHAR (500),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (REG_LOG_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS REG_LOG_IND_BY_REG_LOGTIME ON REG_LOG(REG_LOGGED_TIME, REG_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_PATH(
|
||||
REG_PATH_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_PATH_VALUE VARCHAR(2000) NOT NULL,
|
||||
REG_PATH_PARENT_ID INT,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_PATH PRIMARY KEY(REG_PATH_ID, REG_TENANT_ID)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_NAME ON REG_PATH(REG_PATH_VALUE, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_PATH_IND_BY_PARENT_ID ON REG_PATH(REG_PATH_PARENT_ID, REG_TENANT_ID);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_CONTENT (
|
||||
REG_CONTENT_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_CONTENT_DATA LONGBLOB,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_CONTENT PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_CONTENT_HISTORY (
|
||||
REG_CONTENT_ID INTEGER NOT NULL,
|
||||
REG_CONTENT_DATA LONGBLOB,
|
||||
REG_DELETED SMALLINT,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_CONTENT_HISTORY PRIMARY KEY(REG_CONTENT_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE (
|
||||
REG_PATH_ID INTEGER NOT NULL,
|
||||
REG_NAME VARCHAR(256),
|
||||
REG_VERSION INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_MEDIA_TYPE VARCHAR(500),
|
||||
REG_CREATOR VARCHAR(31) NOT NULL,
|
||||
REG_CREATED_TIME TIMESTAMP NOT NULL,
|
||||
REG_LAST_UPDATOR VARCHAR(31),
|
||||
REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL,
|
||||
REG_DESCRIPTION VARCHAR(1000),
|
||||
REG_CONTENT_ID INTEGER,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
REG_UUID VARCHAR(100) NOT NULL,
|
||||
CONSTRAINT PK_REG_RESOURCE PRIMARY KEY(REG_VERSION, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT (REG_CONTENT_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_NAME ON REG_RESOURCE(REG_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_UUID ON REG_RESOURCE(REG_UUID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TENANT ON REG_RESOURCE(REG_TENANT_ID, REG_UUID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_IND_BY_TYPE ON REG_RESOURCE(REG_TENANT_ID, REG_MEDIA_TYPE);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE_HISTORY (
|
||||
REG_PATH_ID INTEGER NOT NULL,
|
||||
REG_NAME VARCHAR(256),
|
||||
REG_VERSION INTEGER NOT NULL,
|
||||
REG_MEDIA_TYPE VARCHAR(500),
|
||||
REG_CREATOR VARCHAR(31) NOT NULL,
|
||||
REG_CREATED_TIME TIMESTAMP NOT NULL,
|
||||
REG_LAST_UPDATOR VARCHAR(31),
|
||||
REG_LAST_UPDATED_TIME TIMESTAMP NOT NULL,
|
||||
REG_DESCRIPTION VARCHAR(1000),
|
||||
REG_CONTENT_ID INTEGER,
|
||||
REG_DELETED SMALLINT,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
REG_UUID VARCHAR(100) NOT NULL,
|
||||
CONSTRAINT PK_REG_RESOURCE_HISTORY PRIMARY KEY(REG_VERSION, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_PATHID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE_HISTORY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_HIST_FK_BY_CONTENT_ID FOREIGN KEY (REG_CONTENT_ID, REG_TENANT_ID) REFERENCES REG_CONTENT_HISTORY (REG_CONTENT_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_NAME ON REG_RESOURCE_HISTORY(REG_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_HISTORY_IND_BY_PATH_ID_NAME ON REG_RESOURCE(REG_PATH_ID, REG_NAME, REG_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_COMMENT (
|
||||
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_COMMENT_TEXT VARCHAR(500) NOT NULL,
|
||||
REG_USER_ID VARCHAR(31) NOT NULL,
|
||||
REG_COMMENTED_TIME TIMESTAMP NOT NULL,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_COMMENT PRIMARY KEY(REG_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE_COMMENT (
|
||||
REG_COMMENT_ID INTEGER NOT NULL,
|
||||
REG_VERSION INTEGER,
|
||||
REG_PATH_ID INTEGER,
|
||||
REG_RESOURCE_NAME VARCHAR(256),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE_COMMENT ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_COMMENT_FK_BY_COMMENT_ID FOREIGN KEY (REG_COMMENT_ID, REG_TENANT_ID) REFERENCES REG_COMMENT (REG_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_COMMENT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_COMMENT_IND_BY_VERSION ON REG_RESOURCE_COMMENT(REG_VERSION, REG_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RATING (
|
||||
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_RATING INTEGER NOT NULL,
|
||||
REG_USER_ID VARCHAR(31) NOT NULL,
|
||||
REG_RATED_TIME TIMESTAMP NOT NULL,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_RATING PRIMARY KEY(REG_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE_RATING (
|
||||
REG_RATING_ID INTEGER NOT NULL,
|
||||
REG_VERSION INTEGER,
|
||||
REG_PATH_ID INTEGER,
|
||||
REG_RESOURCE_NAME VARCHAR(256),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE_RATING ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_RATING_FK_BY_RATING_ID FOREIGN KEY (REG_RATING_ID, REG_TENANT_ID) REFERENCES REG_RATING (REG_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_RATING(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_RATING_IND_BY_VERSION ON REG_RESOURCE_RATING(REG_VERSION, REG_TENANT_ID);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_TAG (
|
||||
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_TAG_NAME VARCHAR(500) NOT NULL,
|
||||
REG_USER_ID VARCHAR(31) NOT NULL,
|
||||
REG_TAGGED_TIME TIMESTAMP NOT NULL,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_TAG PRIMARY KEY(REG_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE_TAG (
|
||||
REG_TAG_ID INTEGER NOT NULL,
|
||||
REG_VERSION INTEGER,
|
||||
REG_PATH_ID INTEGER,
|
||||
REG_RESOURCE_NAME VARCHAR(256),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE_TAG ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_TAG_FK_BY_TAG_ID FOREIGN KEY (REG_TAG_ID, REG_TENANT_ID) REFERENCES REG_TAG (REG_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_TAG(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_TAG_IND_BY_VERSION ON REG_RESOURCE_TAG(REG_VERSION, REG_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_PROPERTY (
|
||||
REG_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_NAME VARCHAR(100) NOT NULL,
|
||||
REG_VALUE VARCHAR(1000),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_PROPERTY PRIMARY KEY(REG_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_RESOURCE_PROPERTY (
|
||||
REG_PROPERTY_ID INTEGER NOT NULL,
|
||||
REG_VERSION INTEGER,
|
||||
REG_PATH_ID INTEGER,
|
||||
REG_RESOURCE_NAME VARCHAR(256),
|
||||
REG_TENANT_ID INTEGER DEFAULT 0
|
||||
);
|
||||
|
||||
ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
ALTER TABLE REG_RESOURCE_PROPERTY ADD CONSTRAINT IF NOT EXISTS REG_RESOURCE_PROPERTY_FK_BY_TAG_ID FOREIGN KEY (REG_PROPERTY_ID, REG_TENANT_ID) REFERENCES REG_PROPERTY (REG_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_RESOURCE_PROPERTY(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_RESOURCE_PROPERTY_IND_BY_VERSION ON REG_RESOURCE_PROPERTY(REG_VERSION, REG_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_ASSOCIATION (
|
||||
REG_ASSOCIATION_ID INTEGER AUTO_INCREMENT,
|
||||
REG_SOURCEPATH VARCHAR (2000) NOT NULL,
|
||||
REG_TARGETPATH VARCHAR (2000) NOT NULL,
|
||||
REG_ASSOCIATION_TYPE VARCHAR (2000) NOT NULL,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (REG_ASSOCIATION_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS REG_SNAPSHOT (
|
||||
REG_SNAPSHOT_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
REG_PATH_ID INTEGER NOT NULL,
|
||||
REG_RESOURCE_NAME VARCHAR (256),
|
||||
REG_RESOURCE_VIDS LONGBLOB NOT NULL,
|
||||
REG_TENANT_ID INTEGER DEFAULT 0,
|
||||
CONSTRAINT PK_REG_SNAPSHOT PRIMARY KEY(REG_SNAPSHOT_ID, REG_TENANT_ID)
|
||||
);
|
||||
|
||||
ALTER TABLE REG_SNAPSHOT ADD CONSTRAINT IF NOT EXISTS REG_SNAPSHOT_FK_BY_PATH_ID FOREIGN KEY (REG_PATH_ID, REG_TENANT_ID) REFERENCES REG_PATH (REG_PATH_ID, REG_TENANT_ID);
|
||||
CREATE INDEX IF NOT EXISTS REG_SNAPSHOT_IND_BY_PATH_ID_AND_RESOURCE_NAME ON REG_SNAPSHOT(REG_PATH_ID, REG_RESOURCE_NAME, REG_TENANT_ID);
|
||||
|
||||
-- ################################
|
||||
-- USER MANAGER TABLES
|
||||
-- ################################
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_TENANT (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_DOMAIN_NAME VARCHAR(255) NOT NULL,
|
||||
UM_EMAIL VARCHAR(255),
|
||||
UM_ACTIVE BOOLEAN DEFAULT FALSE,
|
||||
UM_CREATED_DATE TIMESTAMP NOT NULL,
|
||||
UM_USER_CONFIG LONGBLOB NOT NULL,
|
||||
PRIMARY KEY (UM_ID),
|
||||
UNIQUE(UM_DOMAIN_NAME));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_DOMAIN(
|
||||
UM_DOMAIN_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_DOMAIN_NAME VARCHAR(255),
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_DOMAIN_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS INDEX_UM_TENANT_UM_DOMAIN_NAME ON UM_TENANT (UM_DOMAIN_NAME);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_USER (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255) NOT NULL,
|
||||
UM_USER_PASSWORD VARCHAR(255) NOT NULL,
|
||||
UM_SALT_VALUE VARCHAR(31),
|
||||
UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE,
|
||||
UM_CHANGED_TIME TIMESTAMP NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID),
|
||||
UNIQUE(UM_USER_NAME, UM_TENANT_ID));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255) NOT NULL,
|
||||
UM_USER_PASSWORD VARCHAR(255) NOT NULL,
|
||||
UM_SALT_VALUE VARCHAR(31),
|
||||
UM_REQUIRE_CHANGE BOOLEAN DEFAULT FALSE,
|
||||
UM_CHANGED_TIME TIMESTAMP NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID),
|
||||
UNIQUE(UM_USER_NAME, UM_TENANT_ID));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_USER_ATTRIBUTE (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_ATTR_NAME VARCHAR(255) NOT NULL,
|
||||
UM_ATTR_VALUE VARCHAR(1024),
|
||||
UM_PROFILE_ID VARCHAR(255),
|
||||
UM_USER_ID INTEGER,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID),
|
||||
FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID));
|
||||
|
||||
CREATE INDEX IF NOT EXISTS UM_USER_ID_INDEX ON UM_USER_ATTRIBUTE(UM_USER_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_ROLE (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_ROLE_NAME VARCHAR(255) NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UM_SHARED_ROLE BOOLEAN DEFAULT FALSE,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID),
|
||||
UNIQUE(UM_ROLE_NAME, UM_TENANT_ID));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_MODULE(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_MODULE_NAME VARCHAR(100),
|
||||
UNIQUE(UM_MODULE_NAME),
|
||||
PRIMARY KEY(UM_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_MODULE_ACTIONS(
|
||||
UM_ACTION VARCHAR(255) NOT NULL,
|
||||
UM_MODULE_ID INTEGER NOT NULL,
|
||||
PRIMARY KEY(UM_ACTION, UM_MODULE_ID),
|
||||
FOREIGN KEY (UM_MODULE_ID) REFERENCES UM_MODULE(UM_ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_PERMISSION (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_RESOURCE_ID VARCHAR(255) NOT NULL,
|
||||
UM_ACTION VARCHAR(255) NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UM_MODULE_ID INTEGER DEFAULT 0,
|
||||
UNIQUE(UM_RESOURCE_ID,UM_ACTION, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID));
|
||||
|
||||
CREATE INDEX IF NOT EXISTS INDEX_UM_PERMISSION_UM_RESOURCE_ID_UM_ACTION ON UM_PERMISSION (UM_RESOURCE_ID, UM_ACTION, UM_TENANT_ID);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_ROLE_PERMISSION (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_PERMISSION_ID INTEGER NOT NULL,
|
||||
UM_ROLE_NAME VARCHAR(255) NOT NULL,
|
||||
UM_IS_ALLOWED SMALLINT NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UM_DOMAIN_ID INTEGER,
|
||||
FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
|
||||
FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_USER_PERMISSION (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_PERMISSION_ID INTEGER NOT NULL,
|
||||
UM_USER_NAME VARCHAR(255) NOT NULL,
|
||||
UM_IS_ALLOWED SMALLINT NOT NULL,
|
||||
UNIQUE (UM_PERMISSION_ID, UM_USER_NAME, UM_TENANT_ID),
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
FOREIGN KEY (UM_PERMISSION_ID, UM_TENANT_ID) REFERENCES UM_PERMISSION(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID));
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_USER_ROLE (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_ROLE_ID INTEGER NOT NULL,
|
||||
UM_USER_ID INTEGER NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UNIQUE (UM_USER_ID, UM_ROLE_ID, UM_TENANT_ID),
|
||||
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_ROLE(UM_ID, UM_TENANT_ID),
|
||||
FOREIGN KEY (UM_USER_ID, UM_TENANT_ID) REFERENCES UM_USER(UM_ID, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID));
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_SHARED_USER_ROLE(
|
||||
UM_ROLE_ID INTEGER NOT NULL,
|
||||
UM_USER_ID INTEGER NOT NULL,
|
||||
UM_USER_TENANT_ID INTEGER NOT NULL,
|
||||
UM_ROLE_TENANT_ID INTEGER NOT NULL,
|
||||
UNIQUE(UM_USER_ID,UM_ROLE_ID,UM_USER_TENANT_ID, UM_ROLE_TENANT_ID),
|
||||
FOREIGN KEY(UM_ROLE_ID,UM_ROLE_TENANT_ID) REFERENCES UM_ROLE(UM_ID,UM_TENANT_ID) ON DELETE CASCADE ,
|
||||
FOREIGN KEY(UM_USER_ID,UM_USER_TENANT_ID) REFERENCES UM_USER(UM_ID,UM_TENANT_ID) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_ACCOUNT_MAPPING(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255) NOT NULL,
|
||||
UM_TENANT_ID INTEGER NOT NULL,
|
||||
UM_USER_STORE_DOMAIN VARCHAR(100),
|
||||
UM_ACC_LINK_ID INTEGER NOT NULL,
|
||||
UNIQUE(UM_USER_NAME, UM_TENANT_ID, UM_USER_STORE_DOMAIN, UM_ACC_LINK_ID),
|
||||
FOREIGN KEY (UM_TENANT_ID) REFERENCES UM_TENANT(UM_ID) ON DELETE CASCADE,
|
||||
PRIMARY KEY (UM_ID)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_DIALECT(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_DIALECT_URI VARCHAR(255) NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UNIQUE(UM_DIALECT_URI, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_CLAIM(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_DIALECT_ID INTEGER NOT NULL,
|
||||
UM_CLAIM_URI VARCHAR(255) NOT NULL,
|
||||
UM_DISPLAY_TAG VARCHAR(255),
|
||||
UM_DESCRIPTION VARCHAR(255),
|
||||
UM_MAPPED_ATTRIBUTE_DOMAIN VARCHAR(255),
|
||||
UM_MAPPED_ATTRIBUTE VARCHAR(255),
|
||||
UM_REG_EX VARCHAR(255),
|
||||
UM_SUPPORTED SMALLINT,
|
||||
UM_REQUIRED SMALLINT,
|
||||
UM_DISPLAY_ORDER INTEGER,
|
||||
UM_CHECKED_ATTRIBUTE SMALLINT,
|
||||
UM_READ_ONLY SMALLINT,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UNIQUE(UM_DIALECT_ID, UM_CLAIM_URI,UM_MAPPED_ATTRIBUTE_DOMAIN, UM_TENANT_ID),
|
||||
FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_PROFILE_CONFIG(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_DIALECT_ID INTEGER,
|
||||
UM_PROFILE_NAME VARCHAR(255),
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
FOREIGN KEY(UM_DIALECT_ID, UM_TENANT_ID) REFERENCES UM_DIALECT(UM_ID, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_HYBRID_ROLE(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_ROLE_NAME VARCHAR(255),
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_HYBRID_USER_ROLE(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255),
|
||||
UM_ROLE_ID INTEGER NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UM_DOMAIN_ID INTEGER,
|
||||
UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID,UM_DOMAIN_ID),
|
||||
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_HYBRID_ROLE(UM_ID, UM_TENANT_ID) ON DELETE CASCADE,
|
||||
FOREIGN KEY (UM_DOMAIN_ID, UM_TENANT_ID) REFERENCES UM_DOMAIN(UM_DOMAIN_ID, UM_TENANT_ID) ON DELETE CASCADE,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_HYBRID_REMEMBER_ME (
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255) NOT NULL,
|
||||
UM_COOKIE_VALUE VARCHAR(1024),
|
||||
UM_CREATED_TIME TIMESTAMP,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_SYSTEM_ROLE(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_ROLE_NAME VARCHAR(255),
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UM_SYSTEM_USER_ROLE(
|
||||
UM_ID INTEGER NOT NULL AUTO_INCREMENT,
|
||||
UM_USER_NAME VARCHAR(255),
|
||||
UM_ROLE_ID INTEGER NOT NULL,
|
||||
UM_TENANT_ID INTEGER DEFAULT 0,
|
||||
UNIQUE (UM_USER_NAME, UM_ROLE_ID, UM_TENANT_ID),
|
||||
FOREIGN KEY (UM_ROLE_ID, UM_TENANT_ID) REFERENCES UM_SYSTEM_ROLE(UM_ID, UM_TENANT_ID),
|
||||
PRIMARY KEY (UM_ID, UM_TENANT_ID)
|
||||
);
|
@ -0,0 +1,96 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<DeviceMgtConfiguration>
|
||||
<ManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/DM_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</ManagementRepository>
|
||||
<PushNotificationConfiguration>
|
||||
<SchedulerBatchSize>1000</SchedulerBatchSize>
|
||||
<SchedulerBatchDelayMills>60000</SchedulerBatchDelayMills>
|
||||
<SchedulerTaskInitialDelay>60000</SchedulerTaskInitialDelay>
|
||||
<SchedulerTaskEnabled>true</SchedulerTaskEnabled>
|
||||
<PushNotificationProviders>
|
||||
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.fcm.FCMBasedPushNotificationProvider</Provider>
|
||||
<!--<Provider>org.wso2.carbon.device.mgt.mobile.impl.ios.apns.APNSBasedPushNotificationProvider</Provider>-->
|
||||
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.mqtt.MQTTBasedPushNotificationProvider</Provider>
|
||||
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.http.HTTPBasedPushNotificationProvider</Provider>
|
||||
<Provider>org.wso2.carbon.device.mgt.extensions.push.notification.provider.xmpp.XMPPBasedPushNotificationProvider</Provider>
|
||||
</PushNotificationProviders>
|
||||
</PushNotificationConfiguration>
|
||||
<PullNotificationConfiguration>
|
||||
<Enabled>false</Enabled>
|
||||
</PullNotificationConfiguration>
|
||||
<IdentityConfiguration>
|
||||
<ServerUrl>https://localhost:9443</ServerUrl>
|
||||
<AdminUsername>admin</AdminUsername>
|
||||
<AdminPassword>admin</AdminPassword>
|
||||
</IdentityConfiguration>
|
||||
<PolicyConfiguration>
|
||||
<MonitoringClass>org.wso2.carbon.policy.mgt</MonitoringClass>
|
||||
<MonitoringEnable>true</MonitoringEnable>
|
||||
<MonitoringFrequency>60000</MonitoringFrequency>
|
||||
<MaxRetries>5</MaxRetries>
|
||||
<MinRetriesToMarkUnreachable>8</MinRetriesToMarkUnreachable>
|
||||
<MinRetriesToMarkInactive>20</MinRetriesToMarkInactive>
|
||||
<!--Set the policy evaluation point name-->
|
||||
<!--Simple -> Simple policy evaluation point-->
|
||||
<!--Merged -> Merged policy evaluation point -->
|
||||
<PolicyEvaluationPoint>Simple</PolicyEvaluationPoint>
|
||||
</PolicyConfiguration>
|
||||
<!-- Default Page size configuration for paginated DM APIs-->
|
||||
<PaginationConfiguration>
|
||||
<DeviceListPageSize>20</DeviceListPageSize>
|
||||
<GroupListPageSize>20</GroupListPageSize>
|
||||
<NotificationListPageSize>20</NotificationListPageSize>
|
||||
<ActivityListPageSize>20</ActivityListPageSize>
|
||||
<OperationListPageSize>20</OperationListPageSize>
|
||||
<TopicListPageSize>20</TopicListPageSize>
|
||||
</PaginationConfiguration>
|
||||
<!--This specifies whether to enable the DeviceStatus Task in this node. In clustered setup only master node
|
||||
should have to run this task.-->
|
||||
<DeviceStatusTaskConfig>
|
||||
<Enable>true</Enable>
|
||||
</DeviceStatusTaskConfig>
|
||||
<!--This controls the in-memory device cache which is local to this node. Setting it enable will activate the
|
||||
device caching for upto configured expiry-time in seconds. In clustered setup all worker nodes can enable the
|
||||
device-cache to improve performance. -->
|
||||
<DeviceCacheConfiguration>
|
||||
<Enable>true</Enable>
|
||||
<ExpiryTime>600</ExpiryTime>
|
||||
<!--This configuration specifies the number of cache entries in device cache. default capacity is 10000 entries.
|
||||
This can be configured to higher number if cache eviction happens due to large number of devices in the
|
||||
server environment-->
|
||||
<Capacity>10000</Capacity>
|
||||
</DeviceCacheConfiguration>
|
||||
<CertificateCacheConfiguration>
|
||||
<Enable>true</Enable>
|
||||
<ExpiryTime>86400</ExpiryTime>
|
||||
</CertificateCacheConfiguration>
|
||||
<GeoLocationConfiguration>
|
||||
<isEnabled>false</isEnabled>
|
||||
<PublishLocationOperationResponse>false</PublishLocationOperationResponse>
|
||||
</GeoLocationConfiguration>
|
||||
<DefaultGroupsConfiguration>BYOD,COPE</DefaultGroupsConfiguration>
|
||||
</DeviceMgtConfiguration>
|
||||
|
@ -0,0 +1,80 @@
|
||||
<!--
|
||||
~ Copyright (c) 2005-2011, 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.
|
||||
-->
|
||||
<UserManager>
|
||||
<Realm>
|
||||
<Configuration>
|
||||
<AddAdmin>true</AddAdmin>
|
||||
<AdminRole>admin</AdminRole>
|
||||
<AdminUser>
|
||||
<UserName>admin</UserName>
|
||||
<Password>admin</Password>
|
||||
</AdminUser>
|
||||
<EveryOneRoleName>everyone</EveryOneRoleName>
|
||||
<ReadOnly>false</ReadOnly>
|
||||
<MaxUserNameListLength>500</MaxUserNameListLength>
|
||||
<Property name="url">jdbc:h2:target/databasetest/CARBON_TEST</Property>
|
||||
<Property name="driverName">org.h2.Driver</Property>
|
||||
<Property name="maxActive">50</Property>
|
||||
<Property name="maxWait">60000</Property>
|
||||
<Property name="minIdle">5</Property>
|
||||
</Configuration>
|
||||
<UserStoreManager class="org.wso2.carbon.user.core.jdbc.JDBCUserStoreManager">
|
||||
<Property name="TenantManager">org.wso2.carbon.user.core.tenant.JDBCTenantManager</Property>
|
||||
<Property name="ReadOnly">false</Property>
|
||||
<Property name="MaxUserNameListLength">100</Property>
|
||||
<Property name="IsEmailUserName">false</Property>
|
||||
<Property name="DomainCalculation">default</Property>
|
||||
<Property name="PasswordDigest">SHA-256</Property>
|
||||
<Property name="StoreSaltedPassword">true</Property>
|
||||
<Property name="ReadGroups">true</Property>
|
||||
<Property name="WriteGroups">true</Property>
|
||||
<Property name="UserNameUniqueAcrossTenants">false</Property>
|
||||
<Property name="PasswordJavaRegEx">^[\S]{5,30}$</Property>
|
||||
<Property name="PasswordJavaRegExViolationErrorMsg">Password length should be between 5 to 30 characters
|
||||
</Property>
|
||||
<Property name="PasswordJavaScriptRegEx">^[\S]{5,30}$</Property>
|
||||
<Property name="UsernameJavaRegEx">[a-zA-Z0-9._-|//]{3,30}$</Property>
|
||||
<Property name="UsernameJavaScriptRegEx">^[\S]{3,30}$</Property>
|
||||
<Property name="RolenameJavaRegEx">^[^~!#$;%^*+={}\\|\\\\<>,\'\"]{3,30}$</Property>
|
||||
<Property name="RolenameJavaScriptRegEx">^[\S]{3,30}$</Property>
|
||||
<Property name="UserRolesCacheEnabled">true</Property>
|
||||
<Property name="MaxRoleNameListLength">100</Property>
|
||||
<Property name="MaxUserNameListLength">100</Property>
|
||||
<Property name="SharedGroupEnabled">false</Property>
|
||||
<Property name="SCIMEnabled">false</Property>
|
||||
<Property name="CaseSensitiveUsername">true</Property>
|
||||
<Property name="MultiAttributeSeparator">,</Property>
|
||||
<Property name="BulkImportSupported">true</Property>
|
||||
</UserStoreManager>
|
||||
<AuthorizationManager
|
||||
class="org.wso2.carbon.user.core.authorization.JDBCAuthorizationManager">
|
||||
<Property name="AuthorizationCacheEnabled">true</Property>
|
||||
</AuthorizationManager>
|
||||
</Realm>
|
||||
<SystemPermission>
|
||||
<Permission>login</Permission>
|
||||
<Permission>manage-configuration</Permission>
|
||||
<Permission>manage-security</Permission>
|
||||
<Permission>upload-services</Permission>
|
||||
<Permission>manage-services</Permission>
|
||||
<Permission>manage-lc-configuration</Permission>
|
||||
<Permission>manage-mediation</Permission>
|
||||
<Permission>monitor-system</Permission>
|
||||
<Permission>delegate-identity</Permission>
|
||||
</SystemPermission>
|
||||
</UserManager>
|
Loading…
Reference in new issue