Merge pull request 'Fix certificate search by partial device identifiers' (#288) from prathabanKavin/device-mgt-core:certsearchfix into master

Reviewed-on: community/device-mgt-core#288
apim420Tcdlpds
commit 3735ab042f

@ -67,7 +67,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
sql += " AND DEVICE_IDENTIFIER = ?"; sql += " AND DEVICE_IDENTIFIER LIKE ?";
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {
@ -83,7 +83,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {
@ -129,7 +129,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
query += "AND DEVICE_IDENTIFIER = ? "; query += "AND DEVICE_IDENTIFIER LIKE ? ";
isCertificateDeviceIdentifierProvided = true; isCertificateDeviceIdentifierProvided = true;
} }
@ -147,7 +147,7 @@ public class GenericCertificateDAOImpl extends AbstractCertificateDAOImpl {
stmt.setString(paramIdx++, "%" + serialNumber + "%"); stmt.setString(paramIdx++, "%" + serialNumber + "%");
} }
if (isCertificateDeviceIdentifierProvided) { if (isCertificateDeviceIdentifierProvided) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (isCertificateUsernameProvided) { if (isCertificateUsernameProvided) {
stmt.setString(paramIdx++, "%" + username + "%"); stmt.setString(paramIdx++, "%" + username + "%");

@ -68,7 +68,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
query += "AND DEVICE_IDENTIFIER = ? "; query += "AND DEVICE_IDENTIFIER LIKE ? ";
isCertificateDeviceIdentifierProvided = true; isCertificateDeviceIdentifierProvided = true;
} }
@ -83,10 +83,10 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl {
int paramIdx = 1; int paramIdx = 1;
stmt.setInt(paramIdx++, tenantId); stmt.setInt(paramIdx++, tenantId);
if (isCertificateSerialNumberProvided) { if (isCertificateSerialNumberProvided) {
stmt.setString(paramIdx++, "%" + serialNumber+ "%"); stmt.setString(paramIdx++, "%" + serialNumber + "%");
} }
if (isCertificateDeviceIdentifierProvided) { if (isCertificateDeviceIdentifierProvided) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (isCertificateUsernameProvided) { if (isCertificateUsernameProvided) {
stmt.setString(paramIdx++, "%" + username + "%"); stmt.setString(paramIdx++, "%" + username + "%");
@ -140,7 +140,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
sql += " AND DEVICE_IDENTIFIER = ?"; sql += " AND DEVICE_IDENTIFIER LIKE ?";
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {
@ -156,7 +156,7 @@ public class OracleCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {

@ -68,7 +68,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
query += "AND DEVICE_IDENTIFIER = ? "; query += "AND DEVICE_IDENTIFIER LIKE ? ";
isCertificateDeviceIdentifierProvided = true; isCertificateDeviceIdentifierProvided = true;
} }
@ -86,7 +86,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl {
stmt.setString(paramIdx++, "%" + serialNumber + "%"); stmt.setString(paramIdx++, "%" + serialNumber + "%");
} }
if (isCertificateDeviceIdentifierProvided) { if (isCertificateDeviceIdentifierProvided) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (isCertificateUsernameProvided) { if (isCertificateUsernameProvided) {
stmt.setString(paramIdx++, "%" + username + "%"); stmt.setString(paramIdx++, "%" + username + "%");
@ -140,7 +140,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
sql += " AND DEVICE_IDENTIFIER = ?"; sql += " AND DEVICE_IDENTIFIER LIKE ?";
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {
@ -156,7 +156,7 @@ public class PostgreSQLCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {

@ -68,7 +68,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
query += "AND DEVICE_IDENTIFIER = ? "; query += "AND DEVICE_IDENTIFIER LIKE ? ";
isCertificateDeviceIdentifierProvided = true; isCertificateDeviceIdentifierProvided = true;
} }
@ -86,7 +86,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl {
stmt.setString(paramIdx++, "%" + serialNumber + "%"); stmt.setString(paramIdx++, "%" + serialNumber + "%");
} }
if (isCertificateDeviceIdentifierProvided) { if (isCertificateDeviceIdentifierProvided) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (isCertificateUsernameProvided) { if (isCertificateUsernameProvided) {
stmt.setString(paramIdx++, "%" + username + "%"); stmt.setString(paramIdx++, "%" + username + "%");
@ -140,7 +140,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
sql += " AND DEVICE_IDENTIFIER = ?"; sql += " AND DEVICE_IDENTIFIER LIKE ?";
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {
@ -156,7 +156,7 @@ public class SQLServerCertificateDAOImpl extends AbstractCertificateDAOImpl {
} }
if (StringUtils.isNotEmpty(deviceIdentifier)) { if (StringUtils.isNotEmpty(deviceIdentifier)) {
stmt.setString(paramIdx++, deviceIdentifier); stmt.setString(paramIdx++, "%" + deviceIdentifier + "%");
} }
if (StringUtils.isNotEmpty(username)) { if (StringUtils.isNotEmpty(username)) {

Loading…
Cancel
Save