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.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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;
|
||||
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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;
|
||||
|
||||
@ -36,8 +38,7 @@ public class DeviceManagerImpl implements DeviceManager {
|
||||
private DeviceManagementConfig config;
|
||||
private DeviceManagementRepository pluginRepository;
|
||||
|
||||
public DeviceManagerImpl(DeviceManagementConfig config,
|
||||
DeviceManagementRepository pluginRepository) {
|
||||
public DeviceManagerImpl(DeviceManagementConfig config, DeviceManagementRepository pluginRepository) {
|
||||
this.config = config;
|
||||
this.pluginRepository = pluginRepository;
|
||||
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
||||
@ -46,58 +47,51 @@ public class DeviceManagerImpl implements DeviceManager {
|
||||
|
||||
@Override
|
||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
boolean status = dms.enrollDevice(device);
|
||||
|
||||
try {
|
||||
this.getDeviceTypeDAO().getDeviceType();
|
||||
org.wso2.carbon.device.mgt.core.dto.Device deviceDto =
|
||||
DeviceManagementDAOUtil.convertDevice(
|
||||
device);
|
||||
|
||||
Integer deviceTypeId =
|
||||
this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
||||
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
|
||||
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
||||
deviceDto.setDeviceType(deviceTypeId);
|
||||
this.getDeviceDAO().addDevice(deviceDto);
|
||||
|
||||
} catch (DeviceManagementDAOException e) {
|
||||
throw new DeviceManagementException("Error occurred while enrolling the device '" +
|
||||
device.getId() + "'", e);
|
||||
throw new DeviceManagementException("Error occurred while enrolling the device '" + device.getId() + "'",
|
||||
e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
boolean status = dms.modifyEnrollment(device);
|
||||
try {
|
||||
this.getDeviceDAO().updateDevice(DeviceManagementDAOUtil.convertDevice(device));
|
||||
} catch (DeviceManagementDAOException e) {
|
||||
throw new DeviceManagementException("Error occurred while modifying the device '" +
|
||||
device.getId() + "'", e);
|
||||
throw new DeviceManagementException("Error occurred while modifying the device '" + device.getId() + "'",
|
||||
e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
return dms.disenrollDevice(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
return dms.isEnrolled(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
return dms.isActive(deviceId);
|
||||
}
|
||||
|
||||
@ -118,29 +112,24 @@ public class DeviceManagerImpl implements DeviceManager {
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
return dms.getDevice(deviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(device.getType());
|
||||
return dms.updateDeviceInfo(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
||||
throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
|
||||
return dms.setOwnership(deviceId, ownershipType);
|
||||
}
|
||||
|
||||
public OperationManager getOperationManager(String type) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
this.getPluginRepository().getDeviceManagementProvider(type);
|
||||
DeviceManagerService dms = this.getPluginRepository().getDeviceManagementProvider(type);
|
||||
return dms.getOperationManager();
|
||||
}
|
||||
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
@ -27,14 +30,14 @@ import javax.xml.bind.Unmarshaller;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Class responsible for the rss manager configuration initialization
|
||||
* Class responsible for the cdm manager configuration initialization
|
||||
*/
|
||||
public class DeviceConfigurationManager {
|
||||
|
||||
private DeviceManagementConfig currentDeviceConfig;
|
||||
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;
|
||||
|
||||
public static DeviceConfigurationManager getInstance() {
|
||||
@ -49,6 +52,8 @@ public class DeviceConfigurationManager {
|
||||
}
|
||||
|
||||
public synchronized void initConfig() throws DeviceManagementException {
|
||||
|
||||
//catch generic exception.if any exception occurs wrap and throw DeviceManagementException
|
||||
try {
|
||||
File deviceMgtConfig = new File(deviceMgtConfigXMLPath);
|
||||
Document doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
@ -15,7 +18,6 @@
|
||||
package org.wso2.carbon.device.mgt.core.config;
|
||||
|
||||
import org.wso2.carbon.device.mgt.core.config.datasource.DataSourceConfig;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
@ -12,14 +15,13 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.core.config.datasource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
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")
|
||||
public class DataSourceConfig {
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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.dao;
|
||||
|
||||
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.DeviceTypeDAOImpl;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
@ -57,8 +59,8 @@ public class DeviceManagementDAOFactory {
|
||||
private static DataSource resolveDataSource(DataSourceConfig config) {
|
||||
DataSource dataSource = null;
|
||||
if (config == null) {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
throw new RuntimeException("Device Management Repository data source configuration " + "is null and " +
|
||||
"thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
if (jndiConfig != null) {
|
||||
@ -66,15 +68,13 @@ public class DeviceManagementDAOFactory {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
"Lookup Definition");
|
||||
}
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
|
||||
jndiConfig.getJndiProperties();
|
||||
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList = jndiConfig.getJndiProperties();
|
||||
if (jndiPropertyList != null) {
|
||||
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
dataSource =
|
||||
DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
} else {
|
||||
dataSource = DeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.core.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
|
||||
@ -1,26 +1,28 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.DeviceTypeDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@ -49,8 +51,7 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||
stmt.setString(1, deviceType.getName());
|
||||
stmt.execute();
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while registering the device type '" +
|
||||
deviceType.getName() + "'";
|
||||
String msg = "Error occurred while registering the device type '" + deviceType.getName() + "'";
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -69,9 +70,9 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||
PreparedStatement stmt = null;
|
||||
List<DeviceType> deviceTypes = new ArrayList<DeviceType>();
|
||||
try {
|
||||
stmt = conn.prepareStatement(
|
||||
"SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE");
|
||||
stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE");
|
||||
ResultSet results = stmt.executeQuery();
|
||||
|
||||
while (results.next()) {
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setId(results.getLong("DEVICE_TYPE_ID"));
|
||||
@ -90,22 +91,20 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||
|
||||
@Override
|
||||
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
|
||||
//TODO:
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getDeviceTypeIdByDeviceTypeName(String type)
|
||||
throws DeviceManagementDAOException {
|
||||
public Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException {
|
||||
|
||||
Connection conn = null;
|
||||
Connection conn = this.getConnection();
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet resultSet = null;
|
||||
Integer deviceTypeId = null;
|
||||
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?";
|
||||
String createDBQuery = "SELECT * From DM_DEVICE_TYPE DT WHERE DT.NAME=?";
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, type);
|
||||
resultSet = stmt.executeQuery();
|
||||
|
||||
@ -61,6 +61,9 @@ public final class DeviceManagementDAOUtil {
|
||||
log.warn("Error occurred while closing database connection", e);
|
||||
}
|
||||
}
|
||||
rs = null;
|
||||
stmt = null;
|
||||
conn = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -83,8 +86,7 @@ public final class DeviceManagementDAOUtil {
|
||||
try {
|
||||
tenantId = tenantManager.getTenantId(tenantDomain);
|
||||
} catch (UserStoreException e) {
|
||||
String msg = "Error occurred while retrieving id from the domain of tenant " +
|
||||
tenantDomain;
|
||||
String msg = "Error occurred while retrieving id from the domain of tenant " + tenantDomain;
|
||||
throw new DeviceManagementDAOException(msg);
|
||||
}
|
||||
return tenantId;
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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.internal;
|
||||
|
||||
@ -56,7 +58,6 @@ public class DeviceManagementServiceComponent {
|
||||
try {
|
||||
/* Initializing Device Management Configuration */
|
||||
DeviceConfigurationManager.getInstance().initConfig();
|
||||
|
||||
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||
|
||||
DataSourceConfig dsConfig = config.getDeviceMgtRepository().getDataSourceConfig();
|
||||
@ -88,6 +89,8 @@ public class DeviceManagementServiceComponent {
|
||||
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {
|
||||
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
||||
log.info("Initializing device management repository database schema");
|
||||
|
||||
// catch generic exception. If any error occurs wrap and throw DeviceManagementException
|
||||
try {
|
||||
initializer.createRegistryDatabase();
|
||||
} catch (Exception e) {
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2014, 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.
|
||||
*
|
||||
* 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
|
||||
@ -66,8 +69,8 @@ public class DeviceMgtDAOTestSuite {
|
||||
}
|
||||
}
|
||||
|
||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType)
|
||||
throws DeviceManagementDAOException, DeviceManagementException {
|
||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException,
|
||||
DeviceManagementException {
|
||||
|
||||
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
||||
Document doc = null;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user