mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Merge branch 'master' of https://gitlab.com/entgra/carbon-device-mgt
This commit is contained in:
commit
3369438f2d
@ -49,6 +49,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Path("/admin/certificates")
|
@Path("/admin/certificates")
|
||||||
public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService {
|
public class CertificateManagementAdminServiceImpl implements CertificateManagementAdminService {
|
||||||
@ -242,6 +244,11 @@ public class CertificateManagementAdminServiceImpl implements CertificateManagem
|
|||||||
String challengeToken = certMgtService.extractChallengeToken(cert);
|
String challengeToken = certMgtService.extractChallengeToken(cert);
|
||||||
|
|
||||||
if (challengeToken != null) {
|
if (challengeToken != null) {
|
||||||
|
Pattern regexPattern = Pattern.compile("[a-zA-Z0-9][a-zA-Z0-9-]+$");
|
||||||
|
Matcher regexMatcher = regexPattern.matcher(challengeToken);
|
||||||
|
if (regexMatcher.find()) {
|
||||||
|
challengeToken = regexMatcher.group();
|
||||||
|
}
|
||||||
challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim();
|
challengeToken = challengeToken.substring(challengeToken.indexOf("(") + 1).trim();
|
||||||
|
|
||||||
SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();
|
SCEPManager scepManager = CertificateMgtAPIUtils.getSCEPManagerService();
|
||||||
|
|||||||
@ -32,6 +32,10 @@ public class BasicUserInfo {
|
|||||||
private String lastname;
|
private String lastname;
|
||||||
@ApiModelProperty(name = "emailAddress", value = "The email address of the user.", required = true )
|
@ApiModelProperty(name = "emailAddress", value = "The email address of the user.", required = true )
|
||||||
private String emailAddress;
|
private String emailAddress;
|
||||||
|
@ApiModelProperty(name = "createdDate", value = "User creation date." )
|
||||||
|
private String createdDate;
|
||||||
|
@ApiModelProperty(name = "modifiedDate", value = "User modifiedDate date." )
|
||||||
|
private String modifiedDate;
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
@ -65,4 +69,20 @@ public class BasicUserInfo {
|
|||||||
this.emailAddress = emailAddress;
|
this.emailAddress = emailAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getCreatedDate() {
|
||||||
|
return createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreatedDate(String createdDate) {
|
||||||
|
this.createdDate = createdDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModifiedDate() {
|
||||||
|
return modifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModifiedDate(String modifiedDate) {
|
||||||
|
this.modifiedDate = modifiedDate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -94,6 +94,7 @@ import java.net.URISyntaxException;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@ -152,7 +153,7 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
|
|
||||||
Map<String, String> defaultUserClaims =
|
Map<String, String> defaultUserClaims =
|
||||||
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
||||||
userInfo.getEmailAddress());
|
userInfo.getEmailAddress(), true);
|
||||||
// calling addUser method of carbon user api
|
// calling addUser method of carbon user api
|
||||||
List<String> tmpRoles = new ArrayList<>();
|
List<String> tmpRoles = new ArrayList<>();
|
||||||
String[] userInfoRoles = userInfo.getRoles();
|
String[] userInfoRoles = userInfo.getRoles();
|
||||||
@ -279,7 +280,7 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
|
|
||||||
Map<String, String> defaultUserClaims =
|
Map<String, String> defaultUserClaims =
|
||||||
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
this.buildDefaultUserClaims(userInfo.getFirstname(), userInfo.getLastname(),
|
||||||
userInfo.getEmailAddress());
|
userInfo.getEmailAddress(), false);
|
||||||
if (StringUtils.isNotEmpty(userInfo.getPassword())) {
|
if (StringUtils.isNotEmpty(userInfo.getPassword())) {
|
||||||
// Decoding Base64 encoded password
|
// Decoding Base64 encoded password
|
||||||
userStoreManager.updateCredentialByAdmin(username,
|
userStoreManager.updateCredentialByAdmin(username,
|
||||||
@ -427,11 +428,7 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
userList = new ArrayList<>(users.length);
|
userList = new ArrayList<>(users.length);
|
||||||
BasicUserInfo user;
|
BasicUserInfo user;
|
||||||
for (String username : users) {
|
for (String username : users) {
|
||||||
user = new BasicUserInfo();
|
user = getBasicUserInfo(username);
|
||||||
user.setUsername(username);
|
|
||||||
user.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
|
|
||||||
user.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
|
|
||||||
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
|
||||||
userList.add(user);
|
userList.add(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -899,11 +896,17 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, String> buildDefaultUserClaims(String firstName, String lastName, String emailAddress) {
|
private Map<String, String> buildDefaultUserClaims(String firstName, String lastName, String emailAddress,
|
||||||
|
boolean isFresh) {
|
||||||
Map<String, String> defaultUserClaims = new HashMap<>();
|
Map<String, String> defaultUserClaims = new HashMap<>();
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_FIRST_NAME, firstName);
|
defaultUserClaims.put(Constants.USER_CLAIM_FIRST_NAME, firstName);
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_LAST_NAME, lastName);
|
defaultUserClaims.put(Constants.USER_CLAIM_LAST_NAME, lastName);
|
||||||
defaultUserClaims.put(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress);
|
defaultUserClaims.put(Constants.USER_CLAIM_EMAIL_ADDRESS, emailAddress);
|
||||||
|
if (isFresh) {
|
||||||
|
defaultUserClaims.put(Constants.USER_CLAIM_CREATED, String.valueOf(Instant.now().getEpochSecond()));
|
||||||
|
} else {
|
||||||
|
defaultUserClaims.put(Constants.USER_CLAIM_MODIFIED, String.valueOf(Instant.now().getEpochSecond()));
|
||||||
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Default claim map is created for new user: " + defaultUserClaims.toString());
|
log.debug("Default claim map is created for new user: " + defaultUserClaims.toString());
|
||||||
}
|
}
|
||||||
@ -936,6 +939,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|||||||
userInfo.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
|
userInfo.setEmailAddress(getClaimValue(username, Constants.USER_CLAIM_EMAIL_ADDRESS));
|
||||||
userInfo.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
|
userInfo.setFirstname(getClaimValue(username, Constants.USER_CLAIM_FIRST_NAME));
|
||||||
userInfo.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
userInfo.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
||||||
|
userInfo.setCreatedDate(getClaimValue(username, Constants.USER_CLAIM_CREATED));
|
||||||
|
userInfo.setModifiedDate(getClaimValue(username, Constants.USER_CLAIM_MODIFIED));
|
||||||
return userInfo;
|
return userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,8 @@ public class Constants {
|
|||||||
public static final String USER_CLAIM_EMAIL_ADDRESS = "http://wso2.org/claims/emailaddress";
|
public static final String USER_CLAIM_EMAIL_ADDRESS = "http://wso2.org/claims/emailaddress";
|
||||||
public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname";
|
public static final String USER_CLAIM_FIRST_NAME = "http://wso2.org/claims/givenname";
|
||||||
public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname";
|
public static final String USER_CLAIM_LAST_NAME = "http://wso2.org/claims/lastname";
|
||||||
|
public static final String USER_CLAIM_CREATED = "http://wso2.org/claims/created";
|
||||||
|
public static final String USER_CLAIM_MODIFIED = "http://wso2.org/claims/modified";
|
||||||
public static final String PRIMARY_USER_STORE = "PRIMARY";
|
public static final String PRIMARY_USER_STORE = "PRIMARY";
|
||||||
public static final String DEFAULT_STREAM_VERSION = "1.0.0";
|
public static final String DEFAULT_STREAM_VERSION = "1.0.0";
|
||||||
public static final String SCOPE = "scope";
|
public static final String SCOPE = "scope";
|
||||||
|
|||||||
@ -14,6 +14,23 @@
|
|||||||
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.common;
|
package org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
@ -79,6 +96,15 @@ public interface DeviceManager {
|
|||||||
*/
|
*/
|
||||||
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
|
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to delete a particular device from CDM.
|
||||||
|
*
|
||||||
|
* @param deviceId Fully qualified device identifier
|
||||||
|
* @return A boolean indicating the status of the operation.
|
||||||
|
* @throws DeviceManagementException If some unusual behaviour is observed while deleting a device
|
||||||
|
*/
|
||||||
|
boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to retrieve the status of the registration process of a particular device.
|
* Method to retrieve the status of the registration process of a particular device.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1513,91 +1513,97 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deleteDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException {
|
public void deleteDevice(DeviceIdentifier deviceIdentifier, int tenantId) throws DeviceManagementDAOException {
|
||||||
|
String deviceIdentifierId = deviceIdentifier.getId();
|
||||||
|
String deviceType = deviceIdentifier.getType();
|
||||||
Connection conn;
|
Connection conn;
|
||||||
try {
|
try {
|
||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
int deviceId = getDeviceId(conn, deviceIdentifier, tenantId);
|
int deviceId = getDeviceId(conn, deviceIdentifier, tenantId);
|
||||||
if (deviceId == -1) {
|
if (deviceId == -1) {
|
||||||
String msg = "Device " + deviceIdentifier.getId() + " of type " + deviceIdentifier.getType() +
|
String msg = "Device " + deviceIdentifierId + " of type " + deviceType + " is not found";
|
||||||
" is not found";
|
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new DeviceManagementDAOException(msg);
|
throw new DeviceManagementDAOException(msg);
|
||||||
} else {
|
} else {
|
||||||
int enrollmentId = getEnrollmentId(conn, deviceId, tenantId);
|
List<Integer> enrollmentIds = getEnrollmentIds(conn, deviceId, tenantId);
|
||||||
if (enrollmentId == -1) {
|
if (enrollmentIds == null || enrollmentIds.isEmpty()) {
|
||||||
String msg = "Enrollment not found for the device " + deviceIdentifier.getId() + " of type " +
|
String msg = "Enrollments not found for the device " + deviceIdentifierId + " of type "
|
||||||
deviceIdentifier.getType();
|
+ deviceType;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new DeviceManagementDAOException(msg);
|
throw new DeviceManagementDAOException(msg);
|
||||||
} else {
|
} else {
|
||||||
removeDeviceDetail(conn, deviceId);
|
removeDeviceDetail(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device detail data");
|
log.debug("Successfully removed device detail data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDeviceLocation(conn, deviceId);
|
removeDeviceLocation(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device location data");
|
log.debug("Successfully removed device location data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDeviceInfo(conn, deviceId);
|
removeDeviceInfo(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device info data");
|
log.debug("Successfully removed device info data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDeviceNotification(conn, deviceId);
|
removeDeviceNotification(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device notification data");
|
log.debug("Successfully removed device notification data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDeviceApplicationMapping(conn, deviceId);
|
removeDeviceApplicationMapping(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device application mapping data");
|
log.debug("Successfully removed device application mapping data of device "
|
||||||
|
+ deviceIdentifierId + " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDevicePolicyApplied(conn, deviceId);
|
removeDevicePolicyApplied(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device applied policy data");
|
log.debug("Successfully removed device applied policy data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDevicePolicy(conn, deviceId);
|
removeDevicePolicy(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device policy data");
|
log.debug("Successfully removed device policy data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeEnrollmentDeviceDetail(conn, enrollmentId);
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed enrollment device detail data");
|
log.debug("Starting to remove " + enrollmentIds.size() + " enrollment data of device "
|
||||||
|
+ deviceIdentifierId + " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeEnrollmentDeviceLocation(conn, enrollmentId);
|
for (Integer enrollmentId : enrollmentIds) {
|
||||||
if (log.isDebugEnabled()) {
|
removeEnrollmentDeviceDetail(conn, enrollmentId);
|
||||||
log.debug("Successfully removed enrollment device location data");
|
removeEnrollmentDeviceLocation(conn, enrollmentId);
|
||||||
|
removeEnrollmentDeviceInfo(conn, enrollmentId);
|
||||||
|
removeEnrollmentDeviceApplicationMapping(conn, enrollmentId);
|
||||||
|
removeDeviceOperationResponse(conn, enrollmentId);
|
||||||
|
removeEnrollmentOperationMapping(conn, enrollmentId);
|
||||||
}
|
}
|
||||||
removeEnrollmentDeviceInfo(conn, enrollmentId);
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed enrollment device info data");
|
log.debug("Successfully removed enrollment device details, enrollment device location, " +
|
||||||
}
|
"enrollment device info, enrollment device application mapping, " +
|
||||||
removeEnrollmentDeviceApplicationMapping(conn, enrollmentId);
|
"enrollment device operation response, enrollment operation mapping data of device "
|
||||||
if (log.isDebugEnabled()) {
|
+ deviceIdentifierId + " of type " + deviceType);
|
||||||
log.debug("Successfully removed enrollment device application mapping data");
|
|
||||||
}
|
|
||||||
removeDeviceOperationResponse(conn, enrollmentId);
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Successfully removed device operation response data");
|
|
||||||
}
|
|
||||||
removeEnrollmentOperationMapping(conn, enrollmentId);
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Successfully removed enrollment operation mapping data");
|
|
||||||
}
|
}
|
||||||
removeDeviceEnrollment(conn, deviceId);
|
removeDeviceEnrollment(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device enrollment data");
|
log.debug("Successfully removed device enrollment data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDeviceGroupMapping(conn, deviceId);
|
removeDeviceGroupMapping(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully removed device group mapping data");
|
log.debug("Successfully removed device group mapping data of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
removeDevice(conn, deviceId);
|
removeDevice(conn, deviceId);
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Successfully permanently deleted the device");
|
log.debug("Successfully permanently deleted the device of device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while deleting the device", e);
|
throw new DeviceManagementDAOException("Error occurred while deleting the device " + deviceIdentifierId
|
||||||
|
+ " of type " + deviceType, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1623,30 +1629,29 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
return deviceId;
|
return deviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getEnrollmentId(Connection conn, int deviceId, int tenantId) throws DeviceManagementDAOException {
|
private List<Integer> getEnrollmentIds(Connection conn, int deviceId, int tenantId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
int enrollmentId = -1;
|
List<Integer> enrollmentIds = new ArrayList<>();
|
||||||
try {
|
try {
|
||||||
String sql = "SELECT ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
|
String sql = "SELECT ID FROM DM_ENROLMENT WHERE DEVICE_ID = ? AND TENANT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
stmt.setInt(1, deviceId);
|
stmt.setInt(1, deviceId);
|
||||||
stmt.setInt(2, tenantId);
|
stmt.setInt(2, tenantId);
|
||||||
rs = stmt.executeQuery();
|
rs = stmt.executeQuery();
|
||||||
if (rs.next()) {
|
while (rs.next()) {
|
||||||
enrollmentId = rs.getInt("ID");
|
enrollmentIds.add(rs.getInt("ID"));
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while retrieving enrollment id of the device", e);
|
throw new DeviceManagementDAOException("Error occurred while retrieving enrollment id of the device", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
||||||
}
|
}
|
||||||
return enrollmentId;
|
return enrollmentIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceDetail(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceDetail(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1655,13 +1660,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device detail", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device detail", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceLocation(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceLocation(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1670,13 +1674,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device location", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device location", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceInfo(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceInfo(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_INFO WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1685,13 +1688,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device info", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device info", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceNotification(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceNotification(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_NOTIFICATION WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_NOTIFICATION WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1700,13 +1702,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device notification", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device notification", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceApplicationMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceApplicationMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1715,13 +1716,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device application mapping", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device application mapping", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDevicePolicyApplied(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDevicePolicyApplied(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_POLICY_APPLIED WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1730,13 +1730,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device policy applied", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device policy applied", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDevicePolicy(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDevicePolicy(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_POLICY WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_POLICY WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1745,13 +1744,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device policy", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device policy", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnrollmentDeviceDetail(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
private void removeEnrollmentDeviceDetail(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_DETAIL WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1760,13 +1758,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing enrollment device detail", e);
|
throw new DeviceManagementDAOException("Error occurred while removing enrollment device detail", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnrollmentDeviceLocation(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
private void removeEnrollmentDeviceLocation(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_LOCATION WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1775,13 +1772,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing enrollment device location", e);
|
throw new DeviceManagementDAOException("Error occurred while removing enrollment device location", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnrollmentDeviceInfo(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
private void removeEnrollmentDeviceInfo(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_INFO WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_INFO WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1790,14 +1786,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing enrollment device info", e);
|
throw new DeviceManagementDAOException("Error occurred while removing enrollment device info", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnrollmentDeviceApplicationMapping(Connection conn, int enrollmentId)
|
private void removeEnrollmentDeviceApplicationMapping(Connection conn, int enrollmentId)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_APPLICATION_MAPPING WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1807,13 +1802,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
throw new DeviceManagementDAOException("Error occurred while removing enrollment device application " +
|
throw new DeviceManagementDAOException("Error occurred while removing enrollment device application " +
|
||||||
"mapping", e);
|
"mapping", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceOperationResponse(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
private void removeDeviceOperationResponse(Connection conn, int enrollmentId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_OPERATION_RESPONSE WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1822,14 +1816,13 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device operation response", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device operation response", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEnrollmentOperationMapping(Connection conn, int enrollmentId)
|
private void removeEnrollmentOperationMapping(Connection conn, int enrollmentId)
|
||||||
throws DeviceManagementDAOException {
|
throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
|
String sql = "DELETE FROM DM_ENROLMENT_OP_MAPPING WHERE ENROLMENT_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1838,13 +1831,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing enrollment operation mapping", e);
|
throw new DeviceManagementDAOException("Error occurred while removing enrollment operation mapping", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceEnrollment(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceEnrollment(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_ENROLMENT WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1853,13 +1845,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device enrollment", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device enrollment", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDeviceGroupMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDeviceGroupMapping(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE_GROUP_MAP WHERE DEVICE_ID = ?";
|
String sql = "DELETE FROM DM_DEVICE_GROUP_MAP WHERE DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1868,13 +1859,12 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device group mapping", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device group mapping", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDevice(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
private void removeDevice(Connection conn, int deviceId) throws DeviceManagementDAOException {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
|
||||||
try {
|
try {
|
||||||
String sql = "DELETE FROM DM_DEVICE WHERE ID = ?";
|
String sql = "DELETE FROM DM_DEVICE WHERE ID = ?";
|
||||||
stmt = conn.prepareStatement(sql);
|
stmt = conn.prepareStatement(sql);
|
||||||
@ -1883,7 +1873,7 @@ public abstract class AbstractDeviceDAOImpl implements DeviceDAO {
|
|||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new DeviceManagementDAOException("Error occurred while removing device", e);
|
throw new DeviceManagementDAOException("Error occurred while removing device", e);
|
||||||
} finally {
|
} finally {
|
||||||
DeviceManagementDAOUtil.cleanupResources(stmt, rs);
|
DeviceManagementDAOUtil.cleanupResources(stmt, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,23 +14,23 @@
|
|||||||
* 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.
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
|
||||||
*
|
*
|
||||||
* Entgra (pvt) Ltd. 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
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
* software distributed under the License is distributed on an
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* in compliance with the License.
|
||||||
* KIND, either express or implied. See the License for the
|
* You may obtain a copy of the License at
|
||||||
* specific language governing permissions and limitations
|
*
|
||||||
* under the License.
|
* 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.service;
|
package org.wso2.carbon.device.mgt.core.service;
|
||||||
|
|
||||||
@ -550,6 +550,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
|
|||||||
try {
|
try {
|
||||||
DeviceManagementDAOFactory.beginTransaction();
|
DeviceManagementDAOFactory.beginTransaction();
|
||||||
deviceDAO.deleteDevice(deviceId, tenantId);
|
deviceDAO.deleteDevice(deviceId, tenantId);
|
||||||
|
try {
|
||||||
|
deviceManager.deleteDevice(deviceId, device);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
String msg = "Error occurred while permanently deleting '" + deviceId.getType() +
|
||||||
|
"' device with the identifier '" + deviceId.getId() + "' in plugin.";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
}
|
||||||
DeviceManagementDAOFactory.commitTransaction();
|
DeviceManagementDAOFactory.commitTransaction();
|
||||||
this.removeDeviceFromCache(deviceId);
|
this.removeDeviceFromCache(deviceId);
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
|||||||
@ -59,6 +59,11 @@ public class TestDeviceManager implements DeviceManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -416,7 +416,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
ENROLMENT_ID INT NOT NULL,
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
|||||||
@ -15,6 +15,22 @@
|
|||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.extensions.device.type.template;
|
package org.wso2.carbon.device.mgt.extensions.device.type.template;
|
||||||
|
|
||||||
@ -568,4 +584,35 @@ public class DeviceTypeManager implements DeviceManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDevice(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
||||||
|
if (propertiesExist) {
|
||||||
|
boolean status;
|
||||||
|
Device existingDevice = this.getDevice(deviceIdentifier);
|
||||||
|
if (existingDevice == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Deleting the details of " + deviceType + " device : " + device.getDeviceIdentifier());
|
||||||
|
}
|
||||||
|
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().beginTransaction();
|
||||||
|
status = deviceTypePluginDAOManager.getDeviceDAO().deleteDevice(existingDevice);
|
||||||
|
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().commitTransaction();
|
||||||
|
} catch (DeviceTypeMgtPluginException e) {
|
||||||
|
try {
|
||||||
|
deviceTypePluginDAOManager.getDeviceTypeDAOHandler().rollbackTransaction();
|
||||||
|
} catch (DeviceTypeMgtPluginException e1) {
|
||||||
|
log.warn("Error occurred while roll back the delete device info transaction : '" +
|
||||||
|
device.toString() + "'", e1);
|
||||||
|
}
|
||||||
|
throw new DeviceManagementException(
|
||||||
|
"Error occurred while deleting the " + deviceType + " device: '" +
|
||||||
|
device.getDeviceIdentifier() + "'", e);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,23 @@
|
|||||||
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
||||||
@ -45,6 +62,7 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
|
|||||||
private String createDBqueryForAddDevice;
|
private String createDBqueryForAddDevice;
|
||||||
private String updateDBQueryForUpdateDevice;
|
private String updateDBQueryForUpdateDevice;
|
||||||
private String selectDBQueryToGetAllDevice;
|
private String selectDBQueryToGetAllDevice;
|
||||||
|
private String deleteDBQueryForDeleteDevice;
|
||||||
|
|
||||||
public DeviceTypePluginDAOImpl(DeviceDAODefinition deviceDAODefinition,
|
public DeviceTypePluginDAOImpl(DeviceDAODefinition deviceDAODefinition,
|
||||||
DeviceTypeDAOHandler deviceTypeDAOHandler) {
|
DeviceTypeDAOHandler deviceTypeDAOHandler) {
|
||||||
@ -196,6 +214,33 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException {
|
||||||
|
boolean status = false;
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = deviceTypeDAOHandler.getConnection();
|
||||||
|
stmt = conn.prepareStatement(deleteDBQueryForDeleteDevice);
|
||||||
|
stmt.setString(1, device.getDeviceIdentifier());
|
||||||
|
int rows = stmt.executeUpdate();
|
||||||
|
if (rows > 0) {
|
||||||
|
status = true;
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Device " + device.getDeviceIdentifier() + " data has been deleted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while deleting the device '" + device.getDeviceIdentifier() + "' data in "
|
||||||
|
+ deviceDAODefinition.getDeviceTableName();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceTypeMgtPluginException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceTypeUtils.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
private String getDeviceTableColumnNames() {
|
private String getDeviceTableColumnNames() {
|
||||||
return StringUtils.join(deviceDAODefinition.getColumnNames(), ", ");
|
return StringUtils.join(deviceDAODefinition.getColumnNames(), ", ");
|
||||||
}
|
}
|
||||||
@ -239,5 +284,8 @@ public class DeviceTypePluginDAOImpl implements PluginDAO {
|
|||||||
selectDBQueryToGetAllDevice =
|
selectDBQueryToGetAllDevice =
|
||||||
"SELECT " + getDeviceTableColumnNames() + "," + deviceDAODefinition.getPrimaryKey() + " FROM "
|
"SELECT " + getDeviceTableColumnNames() + "," + deviceDAODefinition.getPrimaryKey() + " FROM "
|
||||||
+ deviceDAODefinition.getDeviceTableName();
|
+ deviceDAODefinition.getDeviceTableName();
|
||||||
|
|
||||||
|
deleteDBQueryForDeleteDevice = "DELETE FROM " + deviceDAODefinition.getDeviceTableName() + " WHERE "
|
||||||
|
+ deviceDAODefinition.getPrimaryKey() + " = ?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,23 @@
|
|||||||
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
||||||
@ -32,4 +49,6 @@ public interface PluginDAO {
|
|||||||
boolean updateDevice(Device device) throws DeviceTypeMgtPluginException;
|
boolean updateDevice(Device device) throws DeviceTypeMgtPluginException;
|
||||||
|
|
||||||
List<Device> getAllDevices() throws DeviceTypeMgtPluginException;
|
List<Device> getAllDevices() throws DeviceTypeMgtPluginException;
|
||||||
|
|
||||||
|
boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,23 @@
|
|||||||
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
package org.wso2.carbon.device.mgt.extensions.device.type.template.dao;
|
||||||
@ -200,6 +217,27 @@ public class PropertyBasedPluginDAOImpl implements PluginDAO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDevice(Device device) throws DeviceTypeMgtPluginException {
|
||||||
|
Connection conn;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
try {
|
||||||
|
conn = deviceTypeDAOHandler.getConnection();
|
||||||
|
stmt = conn.prepareStatement("DELETE FROM DM_DEVICE_PROPERTIES WHERE DEVICE_IDENTIFICATION = ?");
|
||||||
|
stmt.setString(1, device.getDeviceIdentifier());
|
||||||
|
stmt.executeUpdate();
|
||||||
|
return true;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while deleting the device '" + device.getDeviceIdentifier() + "' data on"
|
||||||
|
+ deviceType;
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceTypeMgtPluginException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceTypeUtils.cleanupResources(stmt, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getPropertyValue(List<Device.Property> properties, String propertyName) {
|
private String getPropertyValue(List<Device.Property> properties, String propertyName) {
|
||||||
for (Device.Property property : properties) {
|
for (Device.Property property : properties) {
|
||||||
if (property.getName() != null && property.getName().equals(propertyName)) {
|
if (property.getName() != null && property.getName().equals(propertyName)) {
|
||||||
|
|||||||
@ -400,7 +400,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(100) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
|||||||
@ -14,6 +14,23 @@
|
|||||||
* 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.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.policy.mgt.core.mock;
|
package org.wso2.carbon.policy.mgt.core.mock;
|
||||||
|
|
||||||
@ -61,6 +78,11 @@ public class TypeXDeviceManager implements DeviceManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean deleteDevice(DeviceIdentifier deviceId, Device device) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -467,7 +467,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
ENROLMENT_ID INT NOT NULL,
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(500) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
|
|||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
||||||
DESCRIPTION TEXT DEFAULT NULL,
|
DESCRIPTION TEXT DEFAULT NULL,
|
||||||
OWNER VARCHAR(45) DEFAULT NULL,
|
OWNER VARCHAR(255) DEFAULT NULL,
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
TENANT_ID INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -110,7 +110,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
OWNER VARCHAR(50) NOT NULL,
|
OWNER VARCHAR(255) NOT NULL,
|
||||||
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
DATE_OF_ENROLMENT TIMESTAMP DEFAULT NULL,
|
DATE_OF_ENROLMENT TIMESTAMP DEFAULT NULL,
|
||||||
@ -413,7 +413,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
ENROLMENT_ID INT NOT NULL,
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(500) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
|||||||
@ -20,7 +20,7 @@ IF NOT EXISTS(SELECT *
|
|||||||
ID INTEGER IDENTITY (1, 1) NOT NULL,
|
ID INTEGER IDENTITY (1, 1) NOT NULL,
|
||||||
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
||||||
DESCRIPTION VARCHAR(MAX) DEFAULT NULL,
|
DESCRIPTION VARCHAR(MAX) DEFAULT NULL,
|
||||||
OWNER VARCHAR(45) DEFAULT NULL,
|
OWNER VARCHAR(255) DEFAULT NULL,
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
TENANT_ID INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
);
|
);
|
||||||
@ -140,7 +140,7 @@ IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[D
|
|||||||
CREATE TABLE DM_ENROLMENT (
|
CREATE TABLE DM_ENROLMENT (
|
||||||
ID INTEGER IDENTITY(1,1) NOT NULL,
|
ID INTEGER IDENTITY(1,1) NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
OWNER VARCHAR(50) NOT NULL,
|
OWNER VARCHAR(255) NOT NULL,
|
||||||
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
DATE_OF_ENROLMENT DATETIME2 DEFAULT NULL,
|
DATE_OF_ENROLMENT DATETIME2 DEFAULT NULL,
|
||||||
@ -457,7 +457,7 @@ CREATE TABLE DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INTEGER NULL,
|
DEVICE_ID INTEGER NULL,
|
||||||
ENROLMENT_ID INTEGER NOT NULL,
|
ENROLMENT_ID INTEGER NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(500) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC)
|
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC)
|
||||||
|
|||||||
@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
|
|||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
||||||
DESCRIPTION TEXT DEFAULT NULL,
|
DESCRIPTION TEXT DEFAULT NULL,
|
||||||
OWNER VARCHAR(45) DEFAULT NULL,
|
OWNER VARCHAR(255) DEFAULT NULL,
|
||||||
TENANT_ID INTEGER DEFAULT 0,
|
TENANT_ID INTEGER DEFAULT 0,
|
||||||
PRIMARY KEY (ID)
|
PRIMARY KEY (ID)
|
||||||
)
|
)
|
||||||
@ -125,7 +125,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
||||||
ID INTEGER AUTO_INCREMENT NOT NULL,
|
ID INTEGER AUTO_INCREMENT NOT NULL,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
OWNER VARCHAR(50) NOT NULL,
|
OWNER VARCHAR(255) NOT NULL,
|
||||||
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL,
|
DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL,
|
||||||
@ -472,7 +472,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INT NULL,
|
DEVICE_ID INT NULL,
|
||||||
ENROLMENT_ID INT NOT NULL,
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(500) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
INDEX DM_DEVICE_INFO_DEVICE_idx (DEVICE_ID ASC),
|
||||||
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC),
|
INDEX DM_DEVICE_INFO_DEVICE_ENROLLMENT_idx (ENROLMENT_ID ASC),
|
||||||
|
|||||||
@ -27,7 +27,7 @@ CREATE TABLE DM_GROUP (
|
|||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DESCRIPTION CLOB DEFAULT NULL,
|
DESCRIPTION CLOB DEFAULT NULL,
|
||||||
GROUP_NAME VARCHAR2(100) DEFAULT NULL,
|
GROUP_NAME VARCHAR2(100) DEFAULT NULL,
|
||||||
OWNER VARCHAR2(45) DEFAULT NULL,
|
OWNER VARCHAR2(255) DEFAULT NULL,
|
||||||
TENANT_ID NUMBER(10) DEFAULT 0,
|
TENANT_ID NUMBER(10) DEFAULT 0,
|
||||||
CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID)
|
CONSTRAINT PK_DM_GROUP PRIMARY KEY (ID)
|
||||||
)
|
)
|
||||||
@ -201,7 +201,7 @@ CREATE TABLE DM_PROFILE_OPERATION (
|
|||||||
CREATE TABLE DM_ENROLMENT (
|
CREATE TABLE DM_ENROLMENT (
|
||||||
ID NUMBER(10) NOT NULL,
|
ID NUMBER(10) NOT NULL,
|
||||||
DEVICE_ID NUMBER(10) NOT NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
OWNER VARCHAR2(50) NOT NULL,
|
OWNER VARCHAR2(255) NOT NULL,
|
||||||
OWNERSHIP VARCHAR2(45) DEFAULT NULL,
|
OWNERSHIP VARCHAR2(45) DEFAULT NULL,
|
||||||
STATUS VARCHAR2(50) NULL,
|
STATUS VARCHAR2(50) NULL,
|
||||||
DATE_OF_ENROLMENT TIMESTAMP(0) DEFAULT NULL,
|
DATE_OF_ENROLMENT TIMESTAMP(0) DEFAULT NULL,
|
||||||
@ -791,7 +791,7 @@ CREATE TABLE DM_DEVICE_INFO (
|
|||||||
DEVICE_ID NUMBER(10) NOT NULL,
|
DEVICE_ID NUMBER(10) NOT NULL,
|
||||||
ENROLMENT_ID NUMBER(10) NOT NULL,
|
ENROLMENT_ID NUMBER(10) NOT NULL,
|
||||||
KEY_FIELD VARCHAR2(45) NULL,
|
KEY_FIELD VARCHAR2(45) NULL,
|
||||||
VALUE_FIELD VARCHAR2(500) NULL,
|
VALUE_FIELD VARCHAR2(1000) NULL,
|
||||||
PRIMARY KEY (ID),
|
PRIMARY KEY (ID),
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
|
|||||||
@ -12,7 +12,7 @@ CREATE TABLE IF NOT EXISTS DM_GROUP (
|
|||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
GROUP_NAME VARCHAR(100) DEFAULT NULL,
|
||||||
DESCRIPTION TEXT DEFAULT NULL,
|
DESCRIPTION TEXT DEFAULT NULL,
|
||||||
OWNER VARCHAR(45) DEFAULT NULL,
|
OWNER VARCHAR(255) DEFAULT NULL,
|
||||||
TENANT_ID INTEGER DEFAULT 0
|
TENANT_ID INTEGER DEFAULT 0
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ CREATE TABLE IF NOT EXISTS DM_PROFILE_OPERATION (
|
|||||||
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
CREATE TABLE IF NOT EXISTS DM_ENROLMENT (
|
||||||
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
ID BIGSERIAL NOT NULL PRIMARY KEY,
|
||||||
DEVICE_ID INTEGER NOT NULL,
|
DEVICE_ID INTEGER NOT NULL,
|
||||||
OWNER VARCHAR(50) NOT NULL,
|
OWNER VARCHAR(255) NOT NULL,
|
||||||
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
OWNERSHIP VARCHAR(45) DEFAULT NULL,
|
||||||
STATUS VARCHAR(50) NULL,
|
STATUS VARCHAR(50) NULL,
|
||||||
DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL,
|
DATE_OF_ENROLMENT TIMESTAMP NULL DEFAULT NULL,
|
||||||
@ -417,7 +417,7 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE_INFO (
|
|||||||
DEVICE_ID INT NOT NULL,
|
DEVICE_ID INT NOT NULL,
|
||||||
ENROLMENT_ID INT NOT NULL,
|
ENROLMENT_ID INT NOT NULL,
|
||||||
KEY_FIELD VARCHAR(45) NULL,
|
KEY_FIELD VARCHAR(45) NULL,
|
||||||
VALUE_FIELD VARCHAR(500) NULL,
|
VALUE_FIELD VARCHAR(1000) NULL,
|
||||||
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
CONSTRAINT DM_DEVICE_INFO_DEVICE
|
||||||
FOREIGN KEY (DEVICE_ID)
|
FOREIGN KEY (DEVICE_ID)
|
||||||
REFERENCES DM_DEVICE (ID)
|
REFERENCES DM_DEVICE (ID)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user