mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Correct copy right text and refactor
This commit is contained in:
parent
acf33bdbe4
commit
0ba84713cd
@ -1,17 +1,19 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* you may not use this file except 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
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* software distributed under the License is distributed on an
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* See the License for the specific language governing permissions and
|
* KIND, either express or implied. See the License for the
|
||||||
* limitations under the License.
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core;
|
package org.wso2.carbon.device.mgt.core;
|
||||||
|
|
||||||
|
|||||||
@ -1,17 +1,19 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* you may not use this file except 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
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* software distributed under the License is distributed on an
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* See the License for the specific language governing permissions and
|
* KIND, either express or implied. See the License for the
|
||||||
* limitations under the License.
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core;
|
package org.wso2.carbon.device.mgt.core;
|
||||||
|
|
||||||
@ -31,129 +33,116 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DeviceManagerImpl implements DeviceManager {
|
public class DeviceManagerImpl implements DeviceManager {
|
||||||
|
|
||||||
private DeviceDAO deviceDAO;
|
private DeviceDAO deviceDAO;
|
||||||
private DeviceTypeDAO deviceTypeDAO;
|
private DeviceTypeDAO deviceTypeDAO;
|
||||||
private DeviceManagementConfig config;
|
private DeviceManagementConfig config;
|
||||||
private DeviceManagementRepository pluginRepository;
|
private DeviceManagementRepository pluginRepository;
|
||||||
|
|
||||||
public DeviceManagerImpl(DeviceManagementConfig config,
|
public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) {
|
||||||
DeviceManagementRepository pluginRepository) {
|
this.config = config;
|
||||||
this.config = config;
|
this.pluginRepository = pluginRepository;
|
||||||
this.pluginRepository = pluginRepository;
|
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
||||||
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||||
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
boolean status = dms.enrollDevice(device);
|
||||||
boolean status = dms.enrollDevice(device);
|
|
||||||
try {
|
|
||||||
this.getDeviceTypeDAO().getDeviceType();
|
|
||||||
org.wso2.carbon.device.mgt.core.dto.Device deviceDto =
|
|
||||||
DeviceManagementDAOUtil.convertDevice(
|
|
||||||
device);
|
|
||||||
|
|
||||||
Integer deviceTypeId =
|
try {
|
||||||
this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
this.getDeviceTypeDAO().getDeviceType();
|
||||||
deviceDto.setDeviceType(deviceTypeId);
|
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
|
||||||
this.getDeviceDAO().addDevice(deviceDto);
|
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
||||||
} catch (DeviceManagementDAOException e) {
|
deviceDto.setDeviceType(deviceTypeId);
|
||||||
throw new DeviceManagementException("Error occurred while enrolling the device '" +
|
this.getDeviceDAO().addDevice(deviceDto);
|
||||||
device.getId() + "'", e);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
} catch (DeviceManagementDAOException e) {
|
||||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'",
|
||||||
DeviceManagerService dms =
|
e);
|
||||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
}
|
||||||
boolean status = dms.modifyEnrollment(device);
|
return status;
|
||||||
try {
|
}
|
||||||
this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
|
|
||||||
} catch (DeviceManagementDAOException e) {
|
|
||||||
throw new DeviceManagementException("Error occurred while modifying the device '" +
|
|
||||||
device.getId() + "'", e);
|
|
||||||
}
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
boolean status = dms.modifyEnrollment(device);
|
||||||
return dms.disenrollDevice(deviceId);
|
try {
|
||||||
}
|
this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
return dms.disenrollDevice(deviceId);
|
||||||
return dms.isEnrolled(deviceId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
return dms.isEnrolled(deviceId);
|
||||||
return dms.isActive(deviceId);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
throws DeviceManagementException {
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
DeviceManagerService dms =
|
return dms.isActive(deviceId);
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
}
|
||||||
return dms.setActive(deviceId, status);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Device> getAllDevices(String type) throws DeviceManagementException {
|
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
||||||
DeviceManagerService dms =
|
throws DeviceManagementException {
|
||||||
this.getPluginRepository().getDeviceManagementProvider(type);
|
DeviceManagerService dms =
|
||||||
return dms.getAllDevices();
|
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
}
|
return dms.setActive(deviceId, status);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public List<Device> getAllDevices(String type) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms =
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
this.getPluginRepository().getDeviceManagementProvider(type);
|
||||||
return dms.getDevice(deviceId);
|
return dms.getAllDevices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
return dms.getDevice(deviceId);
|
||||||
return dms.updateDeviceInfo(device);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||||
throws DeviceManagementException {
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||||
DeviceManagerService dms =
|
return dms.updateDeviceInfo(device);
|
||||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
}
|
||||||
return dms.setOwnership(deviceId, ownershipType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationManager getOperationManager(String type) throws DeviceManagementException {
|
@Override
|
||||||
DeviceManagerService dms =
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
||||||
this.getPluginRepository().getDeviceManagementProvider(type);
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||||
return dms.getOperationManager();
|
return dms.setOwnership(deviceId, ownershipType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceDAO getDeviceDAO() {
|
public OperationManager getOperationManager(String type) throws DeviceManagementException {
|
||||||
return deviceDAO;
|
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
|
||||||
}
|
return dms.getOperationManager();
|
||||||
|
}
|
||||||
|
|
||||||
public DeviceTypeDAO getDeviceTypeDAO() {
|
public DeviceDAO getDeviceDAO() {
|
||||||
return deviceTypeDAO;
|
return deviceDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceManagementRepository getPluginRepository() {
|
public DeviceTypeDAO getDeviceTypeDAO() {
|
||||||
return pluginRepository;
|
return deviceTypeDAO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DeviceManagementRepository getPluginRepository() {
|
||||||
|
return pluginRepository;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -27,14 +30,14 @@ import javax.xml.bind.Unmarshaller;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class responsible for the rss manager configuration initialization
|
* Class responsible for the cdm manager configuration initialization
|
||||||
*/
|
*/
|
||||||
public class DeviceConfigurationManager {
|
public class DeviceConfigurationManager {
|
||||||
|
|
||||||
private DeviceManagementConfig currentDeviceConfig;
|
private DeviceManagementConfig currentDeviceConfig;
|
||||||
private static DeviceConfigurationManager deviceConfigManager;
|
private static DeviceConfigurationManager deviceConfigManager;
|
||||||
|
|
||||||
private final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
private static final String deviceMgtConfigXMLPath = CarbonUtils.getCarbonConfigDirPath() + File.separator +
|
||||||
DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME;
|
DeviceManagementConstants.DataSourceProperties.DEVICE_CONFIG_XML_NAME;
|
||||||
|
|
||||||
public static DeviceConfigurationManager getInstance() {
|
public static DeviceConfigurationManager getInstance() {
|
||||||
@ -49,6 +52,8 @@ public class DeviceConfigurationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void initConfig() throws DeviceManagementException {
|
public synchronized void initConfig() throws DeviceManagementException {
|
||||||
|
|
||||||
|
//catch generic exception.if any exception occurs wrap and throw DeviceManagementException
|
||||||
try {
|
try {
|
||||||
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
||||||
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,21 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core.config;
|
package org.wso2.carbon.device.mgt.core.config;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
|||||||
@ -1,25 +1,27 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.config.datasource;
|
package org.wso2.carbon.device.mgt.core.config.datasource;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for holding data source configuration in rss-config.xml at parsing with JAXB
|
* Class for holding data source configuration in cdm-config.xml at parsing with JAXB
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "DataSourceConfiguration")
|
@XmlRootElement(name = "DataSourceConfiguration")
|
||||||
public class DataSourceConfig {
|
public class DataSourceConfig {
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,18 +1,21 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* you may not use this file except 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
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* software distributed under the License is distributed on an
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* See the License for the specific language governing permissions and
|
* KIND, either express or implied. See the License for the
|
||||||
* limitations under the License.
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.dao;
|
package org.wso2.carbon.device.mgt.core.dao;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@ -22,7 +25,6 @@ import org.wso2.carbon.device.mgt.core.config.datasource.JNDILookupDefinition;
|
|||||||
import org.wso2.carbon.device.mgt.core.dao.impl.DeviceDAOImpl;
|
import org.wso2.carbon.device.mgt.core.dao.impl.DeviceDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl;
|
import org.wso2.carbon.device.mgt.core.dao.impl.DeviceTypeDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -57,8 +59,8 @@ public class DeviceManagementDAOFactory {
|
|||||||
private static DataSource resolveDataSource(DataSourceConfig config) {
|
private static DataSource resolveDataSource(DataSourceConfig config) {
|
||||||
DataSource dataSource = null;
|
DataSource dataSource = null;
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
throw new RuntimeException("Device Management Repository data source configuration " + "is null and " +
|
||||||
"is null and thus, is not initialized");
|
"thus, is not initialized");
|
||||||
}
|
}
|
||||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||||
if (jndiConfig != null) {
|
if (jndiConfig != null) {
|
||||||
@ -66,15 +68,13 @@ public class DeviceManagementDAOFactory {
|
|||||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||||
"Lookup Definition");
|
"Lookup Definition");
|
||||||
}
|
}
|
||||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
|
||||||
jndiConfig.getJndiProperties();
|
|
||||||
if (jndiPropertyList != null) {
|
if (jndiPropertyList != null) {
|
||||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||||
jndiProperties.put(prop.getName(), prop.getValue());
|
jndiProperties.put(prop.getName(), prop.getValue());
|
||||||
}
|
}
|
||||||
dataSource =
|
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||||
DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
|
||||||
} else {
|
} else {
|
||||||
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,11 +11,10 @@
|
|||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core.dao;
|
package org.wso2.carbon.device.mgt.core.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,26 +1,28 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* you may not use this file except 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
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* software distributed under the License is distributed on an
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* See the License for the specific language governing permissions and
|
* KIND, either express or implied. See the License for the
|
||||||
* limitations under the License.
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core.dao.impl;
|
package org.wso2.carbon.device.mgt.core.dao.impl;
|
||||||
|
|
||||||
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.device.mgt.common.DeviceIdentifier;
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
@ -33,106 +35,103 @@ import java.util.List;
|
|||||||
|
|
||||||
public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class);
|
private static final Log log = LogFactory.getLog(DeviceTypeDAOImpl.class);
|
||||||
|
|
||||||
public DeviceTypeDAOImpl(DataSource dataSource) {
|
public DeviceTypeDAOImpl(DataSource dataSource) {
|
||||||
this.dataSource = dataSource;
|
this.dataSource = dataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
public void addDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)");
|
stmt = conn.prepareStatement("INSERT INTO DM_DEVICE_TYPE (NAME) VALUES (?)");
|
||||||
stmt.setString(1, deviceType.getName());
|
stmt.setString(1, deviceType.getName());
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while registering the device type '" +
|
String msg = "Error occurred while registering the device type '" + deviceType.getName() + "'";
|
||||||
deviceType.getName() + "'";
|
log.error(msg, e);
|
||||||
log.error(msg, e);
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
throw new DeviceManagementDAOException(msg, e);
|
} finally {
|
||||||
} finally {
|
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
public void updateDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException {
|
public List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException {
|
||||||
Connection conn = this.getConnection();
|
Connection conn = this.getConnection();
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
List<DeviceType> deviceTypes = new ArrayList<DeviceType>();
|
List<DeviceType> deviceTypes = new ArrayList<DeviceType>();
|
||||||
try {
|
try {
|
||||||
stmt = conn.prepareStatement(
|
stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE");
|
||||||
"SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE");
|
ResultSet results = stmt.executeQuery();
|
||||||
ResultSet results = stmt.executeQuery();
|
|
||||||
while (results.next()) {
|
|
||||||
DeviceType deviceType = new DeviceType();
|
|
||||||
deviceType.setId(results.getLong("DEVICE_TYPE_ID"));
|
|
||||||
deviceType.setName(results.getString("DEVICE_TYPE"));
|
|
||||||
deviceTypes.add(deviceType);
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
String msg = "Error occurred while fetching the registered device types";
|
|
||||||
log.error(msg, e);
|
|
||||||
throw new DeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
return deviceTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
while (results.next()) {
|
||||||
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
|
DeviceType deviceType = new DeviceType();
|
||||||
return null;
|
deviceType.setId(results.getLong("DEVICE_TYPE_ID"));
|
||||||
}
|
deviceType.setName(results.getString("DEVICE_TYPE"));
|
||||||
|
deviceTypes.add(deviceType);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while fetching the registered device types";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return deviceTypes;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer getDeviceTypeIdByDeviceTypeName(String type)
|
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
|
||||||
throws DeviceManagementDAOException {
|
//TODO:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Connection conn = null;
|
@Override
|
||||||
PreparedStatement stmt = null;
|
public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException {
|
||||||
ResultSet resultSet = null;
|
|
||||||
Integer deviceTypeId = null;
|
|
||||||
|
|
||||||
try {
|
Connection conn = this.getConnection();
|
||||||
conn = this.getConnection();
|
PreparedStatement stmt = null;
|
||||||
String createDBQuery =
|
ResultSet resultSet = null;
|
||||||
"SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?";
|
Integer deviceTypeId = null;
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
|
||||||
stmt.setString(1, type);
|
|
||||||
resultSet = stmt.executeQuery();
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
try {
|
||||||
deviceTypeId = resultSet.getInt(1);
|
String createDBQuery = "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?";
|
||||||
}
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
|
stmt.setString(1, type);
|
||||||
|
resultSet = stmt.executeQuery();
|
||||||
|
|
||||||
} catch (SQLException e) {
|
while (resultSet.next()) {
|
||||||
String msg = "Error occurred while fetch device type id for device type '" + type + "'";
|
deviceTypeId = resultSet.getInt(1);
|
||||||
log.error(msg, e);
|
}
|
||||||
throw new DeviceManagementDAOException(msg, e);
|
|
||||||
} finally {
|
|
||||||
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return deviceTypeId;
|
} catch (SQLException e) {
|
||||||
}
|
String msg = "Error occurred while fetch device type id for device type '" + type + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
|
||||||
private Connection getConnection() throws DeviceManagementDAOException {
|
return deviceTypeId;
|
||||||
try {
|
}
|
||||||
return dataSource.getConnection();
|
|
||||||
} catch (SQLException e) {
|
private Connection getConnection() throws DeviceManagementDAOException {
|
||||||
String msg = "Error occurred while obtaining a connection from the device " +
|
try {
|
||||||
"management metadata repository datasource";
|
return dataSource.getConnection();
|
||||||
log.error(msg, e);
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException(msg, e);
|
String msg = "Error occurred while obtaining a connection from the device " +
|
||||||
}
|
"management metadata repository datasource";
|
||||||
}
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,9 @@ public final class DeviceManagementDAOUtil {
|
|||||||
log.warn("Error occurred while closing database connection", e);
|
log.warn("Error occurred while closing database connection", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rs = null;
|
||||||
|
stmt = null;
|
||||||
|
conn = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,8 +86,7 @@ public final class DeviceManagementDAOUtil {
|
|||||||
try {
|
try {
|
||||||
tenantId = tenantManager.getTenantId(tenantDomain);
|
tenantId = tenantManager.getTenantId(tenantDomain);
|
||||||
} catch (UserStoreException e) {
|
} catch (UserStoreException e) {
|
||||||
String msg = "Error occurred while retrieving id from the domain of tenant " +
|
String msg = "Error occurred while retrieving id from the domain of tenant " + tenantDomain;
|
||||||
tenantDomain;
|
|
||||||
throw new DeviceManagementDAOException(msg);
|
throw new DeviceManagementDAOException(msg);
|
||||||
}
|
}
|
||||||
return tenantId;
|
return tenantId;
|
||||||
|
|||||||
@ -1,17 +1,19 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
* you may not use this file except 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
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* software distributed under the License is distributed on an
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* See the License for the specific language governing permissions and
|
* KIND, either express or implied. See the License for the
|
||||||
* limitations under the License.
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core.internal;
|
package org.wso2.carbon.device.mgt.core.internal;
|
||||||
|
|
||||||
@ -56,7 +58,6 @@ public class DeviceManagementServiceComponent {
|
|||||||
try {
|
try {
|
||||||
/* Initializing Device Management Configuration */
|
/* Initializing Device Management Configuration */
|
||||||
DeviceConfigurationManager.getInstance().initConfig();
|
DeviceConfigurationManager.getInstance().initConfig();
|
||||||
|
|
||||||
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||||
|
|
||||||
DataSourceConfig dsConfig = config.getDeviceMgtRepository().getDataSourceConfig();
|
DataSourceConfig dsConfig = config.getDeviceMgtRepository().getDataSourceConfig();
|
||||||
@ -88,6 +89,8 @@ public class DeviceManagementServiceComponent {
|
|||||||
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {
|
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {
|
||||||
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
||||||
log.info("Initializing device management repository database schema");
|
log.info("Initializing device management repository database schema");
|
||||||
|
|
||||||
|
// catch generic exception. If any error occurs wrap and throw DeviceManagementException
|
||||||
try {
|
try {
|
||||||
initializer.createRegistryDatabase();
|
initializer.createRegistryDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* 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,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.core;
|
package org.wso2.carbon.device.mgt.core;
|
||||||
|
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, 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,
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* in compliance with the License.
|
* in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
* http://www.apache.org/licenses/LICENSE-2.
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Unless required by applicable law or agreed to in writing,
|
||||||
* software distributed under the License is distributed on an
|
* software distributed under the License is distributed on an
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
* KIND, either express or implied. See the License for the
|
* KIND, either express or implied. See the License for the
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
@ -66,8 +69,8 @@ public class DeviceMgtDAOTestSuite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType)
|
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException,
|
||||||
throws DeviceManagementDAOException, DeviceManagementException {
|
DeviceManagementException {
|
||||||
|
|
||||||
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
||||||
Document doc = null;
|
Document doc = null;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user