|
|
@ -30,14 +30,23 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
private static Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class);
|
|
|
|
private static Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int addDeviceApplicationMapping(String deviceIdentifier, String applicationUUID, boolean installed) throws ApplicationManagementException {
|
|
|
|
public int addDeviceApplicationMapping(String deviceIdentifier, String applicationUUID, boolean installed) throws
|
|
|
|
|
|
|
|
ApplicationManagementException {
|
|
|
|
Connection conn;
|
|
|
|
Connection conn;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
PreparedStatement stmt = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
ResultSet rs = null;
|
|
|
|
int mappingId = -1;
|
|
|
|
int mappingId = -1;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
conn = this.getDBConnection();
|
|
|
|
String sql = "INSERT INTO APPM_DEVICE_APPLICATION_MAPPING (DEVICE_IDENTIFIER, APPLICATION_UUID, " +
|
|
|
|
String sql = "SELECT ID FROM APPM_DEVICE_APPLICATION_MAPPING WHERE DEVICE_IDENTIFIER = ? AND " +
|
|
|
|
|
|
|
|
"APPLICATION_UUID = ?";
|
|
|
|
|
|
|
|
stmt = conn.prepareStatement(sql);
|
|
|
|
|
|
|
|
stmt.setString(1, deviceIdentifier);
|
|
|
|
|
|
|
|
stmt.setString(2, applicationUUID);
|
|
|
|
|
|
|
|
rs = stmt.executeQuery();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!rs.next()) {
|
|
|
|
|
|
|
|
sql = "INSERT INTO APPM_DEVICE_APPLICATION_MAPPING (DEVICE_IDENTIFIER, APPLICATION_UUID, " +
|
|
|
|
"INSTALLED) VALUES (?, ?, ?)";
|
|
|
|
"INSTALLED) VALUES (?, ?, ?)";
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"id"});
|
|
|
|
stmt = conn.prepareStatement(sql, new String[]{"id"});
|
|
|
|
stmt.setString(1, deviceIdentifier);
|
|
|
|
stmt.setString(1, deviceIdentifier);
|
|
|
@ -50,6 +59,11 @@ public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements Subsc
|
|
|
|
mappingId = rs.getInt(1);
|
|
|
|
mappingId = rs.getInt(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return mappingId;
|
|
|
|
return mappingId;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
log.warn("Device[" + deviceIdentifier + "] application[" + applicationUUID + "] mapping already " +
|
|
|
|
|
|
|
|
"exists in the DB");
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (SQLException e) {
|
|
|
|
} catch (SQLException e) {
|
|
|
|
throw new ApplicationManagementException("Error occurred while adding device application mapping to DB", e);
|
|
|
|
throw new ApplicationManagementException("Error occurred while adding device application mapping to DB", e);
|
|
|
|
} finally {
|
|
|
|
} finally {
|
|
|
|