diff --git a/adoption-metrics-datastore-common-test/.gitignore b/adoption-metrics-datastore-common-test/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-datastore-common-test/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-datastore-inmemory/.gitignore b/adoption-metrics-datastore-inmemory/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-datastore-inmemory/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-datastore-interface/.gitignore b/adoption-metrics-datastore-interface/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-datastore-interface/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-datastore-rdbms/.gitignore b/adoption-metrics-datastore-rdbms/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-datastore-rdbms/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-models/.gitignore b/adoption-metrics-models/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-models/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-service-interface/.gitignore b/adoption-metrics-service-interface/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-service-interface/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-service-local/.gitignore b/adoption-metrics-service-local/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-service-local/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-service-remote/.gitignore b/adoption-metrics-service-remote/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-service-remote/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-service/.gitignore b/adoption-metrics-service/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-service/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/adoption-metrics-sp/.gitignore b/adoption-metrics-sp/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/adoption-metrics-sp/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-datastore-cassandra/.gitignore b/alarm-datastore-cassandra/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-datastore-cassandra/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-datastore-common-test/.gitignore b/alarm-datastore-common-test/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-datastore-common-test/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-datastore-inmemory/.gitignore b/alarm-datastore-inmemory/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-datastore-inmemory/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-datastore-interface/.gitignore b/alarm-datastore-interface/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-datastore-interface/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-datastore-rdbms/.gitignore b/alarm-datastore-rdbms/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-datastore-rdbms/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-models/.gitignore b/alarm-models/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-models/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-service-interface/.gitignore b/alarm-service-interface/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-service-interface/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-service-local/.gitignore b/alarm-service-local/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-service-local/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-service-remote/.gitignore b/alarm-service-remote/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-service-remote/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/alarm-service/.gitignore b/alarm-service/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/alarm-service/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/all-cloud-and-opensync-gw-in-one-process/.gitignore b/all-cloud-and-opensync-gw-in-one-process/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/all-cloud-and-opensync-gw-in-one-process/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/all-cloud-in-one-process-with-persistence/.gitignore b/all-cloud-in-one-process-with-persistence/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/all-cloud-in-one-process-with-persistence/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/all-cloud-in-one-process-with-persistence/pom.xml b/all-cloud-in-one-process-with-persistence/pom.xml
index 597c9b3c..70254bc0 100644
--- a/all-cloud-in-one-process-with-persistence/pom.xml
+++ b/all-cloud-in-one-process-with-persistence/pom.xml
@@ -278,18 +278,6 @@
com.telecominfraproject.wlan
1.1.0-SNAPSHOT
-
-
- client-service
- com.telecominfraproject.wlan
- 1.1.0-SNAPSHOT
-
-
-
- client-datastore-rdbms
- com.telecominfraproject.wlan
- 1.1.0-SNAPSHOT
-
routing-service
diff --git a/all-cloud-in-one-process/.gitignore b/all-cloud-in-one-process/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/all-cloud-in-one-process/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/client-datastore-cassandra/.gitignore b/client-datastore-cassandra/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/client-datastore-cassandra/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/client-datastore-cassandra/src/main/resources/schema-cassandra.cql b/client-datastore-cassandra/src/main/resources/schema-cassandra.cql
index ef125653..631ecd2a 100644
--- a/client-datastore-cassandra/src/main/resources/schema-cassandra.cql
+++ b/client-datastore-cassandra/src/main/resources/schema-cassandra.cql
@@ -42,8 +42,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session (
details blob,
PRIMARY KEY ((customerId, macAddress), equipmentId)
-) WITH comment='Wireless client sessions used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
- AND default_time_to_live = 2592000;
+) WITH comment='Wireless client sessions used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
+ AND default_time_to_live = 86400;
CREATE INDEX IF NOT EXISTS idx_client_session_customerId ON tip_wlan_keyspace.client_session (customerId);
@@ -53,8 +53,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_equipment (
macAddress bigint ,
PRIMARY KEY ((customerId, equipmentId), macAddress)
-) WITH comment='Index Table to look up wireless client sessions by equipmentId used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
- AND default_time_to_live = 2592000;
+) WITH comment='Index Table to look up wireless client sessions by equipmentId used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
+ AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_location (
customerId int,
@@ -63,8 +63,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_location (
macAddress bigint,
PRIMARY KEY ((locationId), equipmentId, macAddress)
-) WITH comment='Index Table to look up wireless client sessions by location and equipment used by TIP WLAN CloudSDK. Records automatically expire after 30 days'
- AND default_time_to_live = 2592000;
+) WITH comment='Index Table to look up wireless client sessions by location and equipment used by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
+ AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac (
customerId int,
@@ -74,8 +74,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac (
macAddressString text,
PRIMARY KEY ((macAddress), locationId, equipmentId, macAddressString)
-) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 30 days'
- AND default_time_to_live = 2592000;
+) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
+ AND default_time_to_live = 86400;
CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac_and_equipment (
customerId int,
@@ -85,8 +85,8 @@ CREATE TABLE IF NOT EXISTS tip_wlan_keyspace.client_session_by_mac_and_equipment
macAddressString text,
PRIMARY KEY ((macAddress), equipmentId, locationId, macAddressString)
-) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 30 days'
- AND default_time_to_live = 2592000;
+) WITH comment='Index Table to look up wireless client sessions by macAddressString, location, and equipment by TIP WLAN CloudSDK. Records automatically expire after 24 hours'
+ AND default_time_to_live = 86400;
DROP INDEX IF EXISTS tip_wlan_keyspace.idx_client_session_by_mac_macAddressString;
DROP INDEX IF EXISTS tip_wlan_keyspace.idx_client_session_by_mac_and_equipment_macAddressString;
diff --git a/client-datastore-common-test/.gitignore b/client-datastore-common-test/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/client-datastore-common-test/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/client-datastore-inmemory/.gitignore b/client-datastore-inmemory/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/client-datastore-inmemory/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/client-datastore-interface/.gitignore b/client-datastore-interface/.gitignore
new file mode 100644
index 00000000..b83d2226
--- /dev/null
+++ b/client-datastore-interface/.gitignore
@@ -0,0 +1 @@
+/target/
diff --git a/client-datastore-rdbms/pom.xml b/client-datastore-rdbms/pom.xml
deleted file mode 100644
index 9ab1df41..00000000
--- a/client-datastore-rdbms/pom.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-
- 4.0.0
-
- com.telecominfraproject.wlan
- tip-wlan-cloud-root-pom
- 1.1.0-SNAPSHOT
- ../../wlan-cloud-root
-
-
- client-datastore-rdbms
- client-datastore-rdbms
- SQL implementation of the data store
-
-
-
- com.telecominfraproject.wlan
- base-jdbc
- 1.1.0-SNAPSHOT
-
-
-
- com.telecominfraproject.wlan
- client-datastore-interface
- 1.1.0-SNAPSHOT
-
-
-
- com.telecominfraproject.wlan
- base-jdbc-tests
- 1.1.0-SNAPSHOT
- test
-
-
-
- com.telecominfraproject.wlan
- client-datastore-common-test
- 1.1.0-SNAPSHOT
- test
-
-
-
-
-
diff --git a/client-datastore-rdbms/src/main/java/com/telecominfraproject/wlan/client/datastore/rdbms/ClientDAO.java b/client-datastore-rdbms/src/main/java/com/telecominfraproject/wlan/client/datastore/rdbms/ClientDAO.java
deleted file mode 100644
index 6e7aab1f..00000000
--- a/client-datastore-rdbms/src/main/java/com/telecominfraproject/wlan/client/datastore/rdbms/ClientDAO.java
+++ /dev/null
@@ -1,493 +0,0 @@
-package com.telecominfraproject.wlan.client.datastore.rdbms;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.sql.DataSource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DuplicateKeyException;
-import org.springframework.dao.EmptyResultDataAccessException;
-import org.springframework.jdbc.core.PreparedStatementCreator;
-import org.springframework.jdbc.core.RowMapper;
-import org.springframework.stereotype.Repository;
-import org.springframework.transaction.annotation.Propagation;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.telecominfraproject.wlan.client.info.models.ClientInfoDetails;
-import com.telecominfraproject.wlan.client.models.Client;
-import com.telecominfraproject.wlan.core.model.equipment.MacAddress;
-import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
-import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
-import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
-import com.telecominfraproject.wlan.core.model.pagination.SortOrder;
-import com.telecominfraproject.wlan.core.server.jdbc.BaseJdbcDao;
-import com.telecominfraproject.wlan.datastore.exceptions.DsConcurrentModificationException;
-import com.telecominfraproject.wlan.datastore.exceptions.DsDuplicateEntityException;
-import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundException;
-
-/**
- * @author dtoptygin
- *
- */
-@Repository
-@Transactional(propagation = Propagation.MANDATORY)
-public class ClientDAO extends BaseJdbcDao {
-
- private static final Logger LOG = LoggerFactory.getLogger(ClientDatastoreRdbms.class);
-
- private static final String COL_ID = "macAddress";
-
- private static final String[] GENERATED_KEY_COLS = { };
-
- private static final String[] ALL_COLUMNS_LIST = {
- COL_ID,
- "macAddressString",
-
- //TODO: add colums from properties Client in here
- "customerId",
- "details",
- //make sure the order of properties matches this list and list in ClientRowMapper and list in create/update methods
-
- "createdTimestamp",
- "lastModifiedTimestamp"
- };
-
- private static final Set columnsToSkipForInsert = new HashSet<>(Arrays.asList());
- private static final Set columnsToSkipForUpdate = new HashSet<>(Arrays.asList(COL_ID, "macAddressString", "createdTimestamp", "customerId"));
-
- private static final String TABLE_NAME = "client";
- private static final String TABLE_PREFIX = "c.";
- private static final String ALL_COLUMNS;
-
- private static final Set ALL_COLUMNS_LOWERCASE = new HashSet<>();
-
- @SuppressWarnings("unused")
- //use this for queries where multiple tables are involved
- private static final String ALL_COLUMNS_WITH_PREFIX;
-
- private static final String ALL_COLUMNS_FOR_INSERT;
- private static final String BIND_VARS_FOR_INSERT;
- private static final String ALL_COLUMNS_UPDATE;
-
- static{
- StringBuilder strbAllColumns = new StringBuilder(1024);
- StringBuilder strbAllColumnsWithPrefix = new StringBuilder(1024);
- StringBuilder strbAllColumnsForInsert = new StringBuilder(1024);
- StringBuilder strbBindVarsForInsert = new StringBuilder(128);
- StringBuilder strbColumnsForUpdate = new StringBuilder(512);
- for(String colName: ALL_COLUMNS_LIST){
-
- ALL_COLUMNS_LOWERCASE.add(colName.toLowerCase());
-
- strbAllColumns.append(colName).append(",");
- strbAllColumnsWithPrefix.append(TABLE_PREFIX).append(colName).append(",");
-
- if(!columnsToSkipForInsert.contains(colName)){
- strbAllColumnsForInsert.append(colName).append(",");
- strbBindVarsForInsert.append("?,");
- }
-
- if(!columnsToSkipForUpdate.contains(colName)){
- strbColumnsForUpdate.append(colName).append("=?,");
- }
- }
-
- // remove trailing ','
- strbAllColumns.deleteCharAt(strbAllColumns.length() - 1);
- strbAllColumnsWithPrefix.deleteCharAt(strbAllColumnsWithPrefix.length() - 1);
- strbAllColumnsForInsert.deleteCharAt(strbAllColumnsForInsert.length() - 1);
- strbBindVarsForInsert.deleteCharAt(strbBindVarsForInsert.length() - 1);
- strbColumnsForUpdate.deleteCharAt(strbColumnsForUpdate.length() - 1);
-
- ALL_COLUMNS = strbAllColumns.toString();
- ALL_COLUMNS_WITH_PREFIX = strbAllColumnsWithPrefix.toString();
- ALL_COLUMNS_FOR_INSERT = strbAllColumnsForInsert.toString();
- BIND_VARS_FOR_INSERT = strbBindVarsForInsert.toString();
- ALL_COLUMNS_UPDATE = strbColumnsForUpdate.toString();
-
- }
-
-
- private static final String SQL_GET_BY_ID =
- "select " + ALL_COLUMNS +
- " from "+TABLE_NAME+" " +
- " where customerId = ? and " + COL_ID + " = ?";
-
- private static final String SQL_GET_BY_CUSTOMER_ID =
- "select " + ALL_COLUMNS +
- " from " + TABLE_NAME + " " +
- " where customerId = ? ";
-
- private static final String SQL_GET_BLOCKED_CLIENTS = "select " + ALL_COLUMNS_WITH_PREFIX +
- " from " + TABLE_NAME + " c , client_blocklist cb " +
- " where cb.customerId = ? and c.customerId = cb.customerId and c.macAddress = cb.macAddress ";
-
-
- private static final String SQL_GET_LASTMOD_BY_ID =
- "select lastModifiedTimestamp " +
- " from "+TABLE_NAME+" " +
- " where customerId = ? and " + COL_ID + " = ?";
-
- private static final String SQL_INSERT =
- "insert into "+TABLE_NAME+" ( "
- + ALL_COLUMNS_FOR_INSERT
- + " ) values ( "+BIND_VARS_FOR_INSERT+" ) ";
-
- private static final String SQL_DELETE =
- "delete from "+TABLE_NAME+" where customerId = ? and " + COL_ID + " = ? ";
-
- private static final String SQL_UPDATE =
- "update "+TABLE_NAME+" set "
- + ALL_COLUMNS_UPDATE +
- " where customerId = ? and " + COL_ID + " = ? "
- + " and ( lastModifiedTimestamp = ? or ? = true) " //last parameter will allow us to skip check for concurrent modification, if necessary
- ;
-
- private static final String SQL_GET_ALL_IN_SET = "select " + ALL_COLUMNS + " from "+TABLE_NAME + " where customerId = ? and "+ COL_ID +" in ";
-
- private static final String SQL_APPEND_SEARCH_MAC_SUBSTRING =
- "and macAddressString like ? ";
-
- private static final String SQL_PAGING_SUFFIX = " LIMIT ? OFFSET ? ";
- private static final String SORT_SUFFIX = "";
-
- private static final String SQL_INSERT_BLOCK_LIST = "insert into client_blocklist (customerId, macAddress) values (?, ?) ";
- private static final String SQL_DELETE_BLOCK_LIST = "delete from client_blocklist where customerId = ? and macAddress = ? ";
-
-
- private static final RowMapper clientRowMapper = new ClientRowMapper();
-
-
- @Autowired(required=false)
- public void setDataSource(ClientDataSourceInterface dataSource) {
- setDataSource((DataSource)dataSource);
- }
-
-
- public Client create(final Client client) {
-
- final long ts = System.currentTimeMillis();
-
- try{
- jdbcTemplate.update(
- new PreparedStatementCreator() {
- public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
- PreparedStatement ps = connection.prepareStatement(SQL_INSERT );
- int colIdx = 1;
-
- //TODO: add remaining properties from Client here
- ps.setLong(colIdx++, client.getMacAddress().getAddressAsLong());
- ps.setString(colIdx++, client.getMacAddress().getAddressAsString());
- ps.setInt(colIdx++, client.getCustomerId());
- ps.setBytes(colIdx++, (client.getDetails()!=null)?client.getDetails().toZippedBytes():null);
-
- ps.setLong(colIdx++, ts);
- ps.setLong(colIdx++, ts);
-
- return ps;
- }
- });
- }catch (DuplicateKeyException e) {
- throw new DsDuplicateEntityException(e);
- }
-
- //update blocked_client table, if needed
- if((client.getDetails() instanceof ClientInfoDetails)
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails()!=null
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails().isEnabled()
- ) {
-
- this.jdbcTemplate.update( SQL_INSERT_BLOCK_LIST,
- client.getCustomerId(), client.getMacAddress().getAddressAsLong());
-
- client.setNeedToUpdateBlocklist(true);
- }
-
-
- client.setCreatedTimestamp(ts);
- client.setLastModifiedTimestamp(ts);
-
-
- LOG.debug("Stored Client {}", client);
-
- return client.clone();
- }
-
-
- @Transactional(noRollbackFor = { EmptyResultDataAccessException.class })
- public Client getOrNull(int customerId, MacAddress clientMac) {
- LOG.debug("Looking up Client for id {} {}", customerId, clientMac);
-
- try{
- Client client = this.jdbcTemplate.queryForObject(
- SQL_GET_BY_ID,
- clientRowMapper, customerId, clientMac.getAddressAsLong());
-
- LOG.debug("Found Client {}", client);
-
- return client;
- }catch (EmptyResultDataAccessException e) {
- LOG.debug("Could not find Client for id {} {}", customerId, clientMac);
- return null;
- }
- }
-
- public Client update(Client client) {
-
- long newLastModifiedTs = System.currentTimeMillis();
- long incomingLastModifiedTs = client.getLastModifiedTimestamp();
-
- Client existingClient = getOrNull(client.getCustomerId(), client.getMacAddress());
-
- if(existingClient==null) {
- LOG.debug("Cannot find Client for {} {}", client.getCustomerId(), client.getMacAddress());
- throw new DsEntityNotFoundException("Client not found " + client.getCustomerId() + " " + client.getMacAddress());
- }
-
- int updateCount = this.jdbcTemplate.update(SQL_UPDATE, new Object[]{
- //TODO: add remaining properties from Client here
- (client.getDetails()!=null)?client.getDetails().toZippedBytes():null ,
-
- //client.getCreatedTimestamp(), - not updating this one
- newLastModifiedTs,
-
- // use id for update operation
- client.getCustomerId(),
- client.getMacAddress().getAddressAsLong(),
- // use lastModifiedTimestamp for data protection against concurrent modifications
- incomingLastModifiedTs,
- isSkipCheckForConcurrentUpdates()
- });
-
- if(updateCount==0){
-
- if(isSkipCheckForConcurrentUpdates()){
- //in this case we did not request protection against concurrent updates,
- //so the updateCount is 0 because record in db was not found
- throw new EmptyResultDataAccessException(1);
- }
-
- long recordTimestamp = existingClient.getLastModifiedTimestamp();
-
- LOG.debug("Concurrent modification detected for Client with id {} {} expected version is {} but version in db was {}",
- client.getCustomerId(),
- client.getMacAddress().getAddressAsLong(),
- incomingLastModifiedTs,
- recordTimestamp
- );
- throw new DsConcurrentModificationException("Concurrent modification detected for Client with id "
- + client.getCustomerId() + " " + client.getMacAddress()
- +" expected version is " + incomingLastModifiedTs
- +" but version in db was " + recordTimestamp
- );
-
- }
-
- //update client_blocklist table, if the blocking state of the client has changed
- boolean existingClientBlocked = (existingClient.getDetails() instanceof ClientInfoDetails)
- && ((ClientInfoDetails)existingClient.getDetails()).getBlocklistDetails()!=null
- && ((ClientInfoDetails)existingClient.getDetails()).getBlocklistDetails().isEnabled();
-
- boolean updatedClientBlocked = (client.getDetails() instanceof ClientInfoDetails)
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails()!=null
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails().isEnabled();
-
- if(existingClientBlocked != updatedClientBlocked) {
- if(updatedClientBlocked) {
- //insert record into client_blocklist table
- this.jdbcTemplate.update( SQL_INSERT_BLOCK_LIST,
- client.getCustomerId(), client.getMacAddress().getAddressAsLong());
- } else {
- //delete record from client_blocklist table
- this.jdbcTemplate.update( SQL_DELETE_BLOCK_LIST,
- client.getCustomerId(), client.getMacAddress().getAddressAsLong());
- }
-
- //notify the caller that block list needs to be updated
- client.setNeedToUpdateBlocklist(true);
-
- }
-
-
- //make a copy so that we don't accidentally update caller's version by reference
- Client clientCopy = client.clone();
- clientCopy.setLastModifiedTimestamp(newLastModifiedTs);
-
- LOG.debug("Updated Client {}", clientCopy);
-
- return clientCopy;
- }
-
-
- public Client delete(int customerId, MacAddress clientMac) {
- Client client = getOrNull(customerId, clientMac);
- if(client!=null) {
- this.jdbcTemplate.update(SQL_DELETE, customerId, clientMac.getAddressAsLong());
- } else {
- throw new DsEntityNotFoundException("Cannot find Client for id " + customerId + " " + clientMac);
- }
-
- //delete from client_blocklist table happens by foreign key cascade
- //but we still need to tell the caller if the blocklist need to be updated
- if((client.getDetails() instanceof ClientInfoDetails)
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails()!=null
- && ((ClientInfoDetails)client.getDetails()).getBlocklistDetails().isEnabled()
- ) {
- client.setNeedToUpdateBlocklist(true);
- }
-
- LOG.debug("Deleted Client {} {}", customerId, clientMac);
-
- return client;
- }
-
- public List getAllForCustomer(int customerId) {
- LOG.debug("Looking up Clients for customer {}", customerId);
-
- List ret = this.jdbcTemplate.query(SQL_GET_BY_CUSTOMER_ID,
- clientRowMapper, customerId);
-
- LOG.debug("Found Clients for customer {} : {}", customerId, ret);
-
- return ret;
- }
-
- public List get(int customerId, Set clientMacSet) {
- LOG.debug("calling get({}, {})", customerId, clientMacSet);
-
- if (clientMacSet == null || clientMacSet.isEmpty()) {
- return Collections.emptyList();
- }
-
- StringBuilder set = new StringBuilder(256);
- set.append("(");
- for(int i =0; i< clientMacSet.size(); i++) {
- set.append("?,");
- }
- //remove last comma
- set.deleteCharAt(set.length()-1);
- set.append(")");
-
- String query = SQL_GET_ALL_IN_SET + set;
- ArrayList