Compare commits

..

1 Commits

Author SHA1 Message Date
Kareem Dabbour
1018bafa0e WIFI-3201 Equipments cusId/locId/profIds can no longer be updated to 0 with REST API 2021-07-21 14:08:25 -04:00
11 changed files with 90 additions and 41 deletions

View File

@@ -555,7 +555,7 @@ components:
type: integer
format: int32
payload:
$ref: '#/components/schemas/PortalUserEventPayload'
$ref: '#/components/schemas/PortalUser'
PortalUserChangedEvent:
properties:
@@ -566,7 +566,7 @@ components:
type: integer
format: int32
payload:
$ref: '#/components/schemas/PortalUserEventPayload'
$ref: '#/components/schemas/PortalUser'
PortalUserRemovedEvent:
properties:
@@ -577,7 +577,7 @@ components:
type: integer
format: int32
payload:
$ref: '#/components/schemas/PortalUserEventPayload'
$ref: '#/components/schemas/PortalUser'
ProfileAddedEvent:
properties:
@@ -2382,7 +2382,7 @@ components:
# Portal User data models
#
PortalUserEventPayload:
PortalUser:
type: object
properties:
id:
@@ -2393,6 +2393,10 @@ components:
format: int32
username:
type: string
password:
type: string
role:
$ref: '#/components/schemas/PortalUserRole'
createdTimestamp:
type: integer
format: int64
@@ -2403,6 +2407,8 @@ components:
example:
customerId: 2
username: new_user
password: pwd
role: CustomerIT
PortalUserRole:
type: string

View File

@@ -59,6 +59,11 @@ public enum CEGWCommandType {
WdsRequest,
ClientBlocklistChangeNotification,
/**
* Most recent timestamp for receipt of stats data from this AP.
*/
MostRecentStatsTimestamp,
UNSUPPORTED;

View File

@@ -62,7 +62,7 @@ public class ElementRadioConfiguration extends BaseJsonModel
if (radioType == RadioType.is5GHz) {
returnValue.setChannelNumber(36);
returnValue.setBackupChannelNumber(149);
returnValue.setBackupChannelNumber(153);
} else if (radioType == RadioType.is5GHzL) {
returnValue.setChannelNumber(36);
returnValue.setBackupChannelNumber(44);

View File

@@ -118,40 +118,33 @@ public class EquipmentRrmBulkUpdateItem extends BaseJsonModel {
finalDetails.getRadioMap().put(rt, erc);
}
if(erc.getManualChannelNumber() == null
|| erc.getManualChannelNumber().intValue() != updateDetails.getChannelNumber()) {
if(erc.getManualChannelNumber()== null || erc.getManualChannelNumber().intValue() != updateDetails.getChannelNumber()) {
erc.setManualChannelNumber(updateDetails.getChannelNumber());
modelChanged.set(true);
}
if(erc.getManualBackupChannelNumber() == null
|| erc.getManualBackupChannelNumber().intValue() != updateDetails.getBackupChannelNumber()) {
if(erc.getManualBackupChannelNumber()== null ||
erc.getManualBackupChannelNumber().intValue() != updateDetails.getBackupChannelNumber()) {
erc.setManualBackupChannelNumber(updateDetails.getBackupChannelNumber());
modelChanged.set(true);
}
if (updateDetails.getClientDisconnectThresholdDb() != null) {
if ((erc.getClientDisconnectThresholdDb() == null && updateDetails.getClientDisconnectThresholdDb() != null)
|| !erc.getClientDisconnectThresholdDb().equals(updateDetails.getClientDisconnectThresholdDb())) {
erc.setClientDisconnectThresholdDb(updateDetails.getClientDisconnectThresholdDb());
modelChanged.set(true);
}
if ((erc.getClientDisconnectThresholdDb() == null && updateDetails.getClientDisconnectThresholdDb() != null)
|| !erc.getClientDisconnectThresholdDb().equals(updateDetails.getClientDisconnectThresholdDb())) {
erc.setClientDisconnectThresholdDb(updateDetails.getClientDisconnectThresholdDb());
modelChanged.set(true);
}
if (updateDetails.getProbeResponseThresholdDb() != null) {
if ((erc.getProbeResponseThresholdDb() == null && updateDetails.getProbeResponseThresholdDb() != null)
|| !erc.getProbeResponseThresholdDb().equals(updateDetails.getProbeResponseThresholdDb())) {
erc.setProbeResponseThresholdDb(updateDetails.getProbeResponseThresholdDb());
modelChanged.set(true);
}
if ((erc.getProbeResponseThresholdDb() == null && updateDetails.getProbeResponseThresholdDb() != null)
|| !erc.getProbeResponseThresholdDb().equals(updateDetails.getProbeResponseThresholdDb())) {
erc.setProbeResponseThresholdDb(updateDetails.getProbeResponseThresholdDb());
modelChanged.set(true);
}
if (updateDetails.getRxCellSizeDb() != null) {
if ((erc.getRxCellSizeDb() == null && updateDetails.getRxCellSizeDb() != null)
|| !erc.getRxCellSizeDb().equals(updateDetails.getRxCellSizeDb())) {
erc.setRxCellSizeDb(updateDetails.getRxCellSizeDb());
modelChanged.set(true);
}
if ((erc.getRxCellSizeDb() == null && updateDetails.getRxCellSizeDb() != null)
|| !erc.getRxCellSizeDb().equals(updateDetails.getRxCellSizeDb())) {
erc.setRxCellSizeDb(updateDetails.getRxCellSizeDb());
modelChanged.set(true);
}

View File

@@ -83,7 +83,10 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
equipment.setName("testName-"+getNextEquipmentId());
equipment.setInventoryId("test-inv-"+getNextEquipmentId());
equipment.setEquipmentType(EquipmentType.AP);
equipment.setLocationId(1);
equipment.setProfileId(1);
equipment.setCustomerId(1);
Equipment ret = remoteInterface.create(equipment);
assertNotNull(ret);
@@ -631,6 +634,9 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
equipment.setName("testName-"+getNextEquipmentId());
equipment.setInventoryId("test-inv-"+getNextEquipmentId());
equipment.setEquipmentType(EquipmentType.AP);
equipment.setCustomerId(1);
equipment.setLocationId(1);
equipment.setProfileId(1);
equipment.setDetails(ApElementConfiguration.createWithDefaults());
ElementRadioConfiguration element2dot4RadioConfig = ((ApElementConfiguration)equipment.getDetails()).getRadioMap().get(RadioType.is2dot4GHz);
@@ -932,9 +938,9 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
assertEquals(11, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
assertEquals(36, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
assertEquals(149, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
assertEquals(153, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
assertEquals(36, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
assertEquals(149, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
assertEquals(153, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());
Map<RadioType, Integer> primaryChannels = new EnumMap<>(RadioType.class);
Map<RadioType, Integer> backupChannels = new EnumMap<>(RadioType.class);
@@ -970,7 +976,7 @@ public class EquipmentServiceRemoteTest extends BaseRemoteTest {
assertEquals(6, radioMap.get(RadioType.is2dot4GHz).getManualBackupChannelNumber().intValue());
assertEquals(36, radioMap.get(RadioType.is5GHz).getChannelNumber().intValue());
assertEquals(149, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
assertEquals(153, radioMap.get(RadioType.is5GHz).getBackupChannelNumber().intValue());
assertEquals(40, radioMap.get(RadioType.is5GHz).getManualChannelNumber().intValue());
assertEquals(48, radioMap.get(RadioType.is5GHz).getManualBackupChannelNumber().intValue());

View File

@@ -258,7 +258,10 @@ public class EquipmentController {
LOG.debug("Updating Equipment {}", equipment);
if (BaseJsonModel.hasUnsupportedValue(equipment)) {
if (BaseJsonModel.hasUnsupportedValue(equipment)
|| equipment.getCustomerId() == 0
|| equipment.getLocationId() == 0
|| equipment.getProfileId() == 0) {
LOG.error("Failed to update Equipment, request contains unsupported value: {}", equipment);
throw new DsDataValidationException("Equipment contains unsupported value");
}

View File

@@ -16,9 +16,12 @@ import com.telecominfraproject.wlan.equipment.models.Equipment;
import com.telecominfraproject.wlan.equipment.models.RadioChannelChangeSettings;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCode;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandType;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareDownloadRequest;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWMostRecentStatsTimestamp;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRebootRequest;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGatewayCommand;
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommandResponse;
import com.telecominfraproject.wlan.equipmentgateway.service.EquipmentGatewayServiceInterface;
import com.telecominfraproject.wlan.firmware.FirmwareServiceInterface;
@@ -160,4 +163,17 @@ public class EquipmentGatewayPortalController {
}
}
@RequestMapping(value = "/equipmentGateway/lastReceivedStatsTimestamp", method = RequestMethod.GET)
public GenericResponse lastReceivedStatsTimestamp(@RequestParam long equipmentId) {
Equipment equipment = equipmentServiceInterface.get(equipmentId);
String apId = equipment.getInventoryId();
CEGWMostRecentStatsTimestamp mostRecentStatsTimestamp = new CEGWMostRecentStatsTimestamp(CEGWCommandType.MostRecentStatsTimestamp, apId, equipmentId);
EquipmentCommandResponse response = equipmentGatewayServiceInterface.sendCommand(mostRecentStatsTimestamp);
LOG.debug("lastReceivedStatsTimestamp response {}", response);
if (response.getResultCode() == CEGWCommandResultCode.Success) {
return new GenericResponse(true, response.getResultDetail());
} else {
return new GenericResponse(false, response.getResultCode() + " - Failed to get last received stats timestamp for " + apId);
}
}
}

View File

@@ -14268,6 +14268,31 @@ paths:
$ref: '#/components/schemas/GenericResponse'
500:
$ref: '#/components/responses/GenericApiError'
/portal/equipmentGateway/lastReceivedStatsTimestamp:
get:
tags:
- Equipment Gateway
summary: Request to get the last received (most recent) stats received timestamp for the APs session with the gateway controller
operationId: lastReceivedStatsTimestamp
parameters:
- name: equipmentId
in: query
description: Equipment id for AP for which last received stats timestamp is being requested.
required: true
schema:
type: integer
format: int64
responses:
200:
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/GenericResponse'
500:
$ref: '#/components/responses/GenericApiError'
/portal/equipmentGateway/requestChannelChange:
post:

View File

@@ -20,8 +20,6 @@ public class PortalUserEventPayload extends BaseJsonModel implements HasCustomer
private long createdTimestamp;
private long lastModifiedTimestamp;
public PortalUserEventPayload() {}
public PortalUserEventPayload(PortalUser portalUser) {
this.setId(portalUser.getId());
this.setCustomerId(portalUser.getCustomerId());

View File

@@ -56,7 +56,8 @@ public class StatusDatastoreCassandra implements StatusDatastore {
private static final Set<String> columnsToSkipForUpdate = new HashSet<>(Arrays.asList(
"customerId",
"equipmentId",
"statusDataType"));
"statusDataType",
"createdTimestamp"));
private static final String TABLE_NAME = "status";
private static final String ALL_COLUMNS;
@@ -229,14 +230,11 @@ public class StatusDatastoreCassandra implements StatusDatastore {
//This DAO does not enforce check for concurrent updates. Last one always wins.
long newLastModifiedTs = System.currentTimeMillis();
boolean isCreateNotSet = status.getCreatedTimestamp() == 0;
cqlSession.execute(preparedStmt_update.bind(
//TODO: add remaining properties from Status here
(status.getDetails()!=null) ? ByteBuffer.wrap(status.getDetails().toZippedBytes()) : null ,
isCreateNotSet ? newLastModifiedTs : status.getCreatedTimestamp(),
newLastModifiedTs,
@@ -255,9 +253,6 @@ public class StatusDatastoreCassandra implements StatusDatastore {
//make a copy so that we don't accidentally update caller's version by reference
Status statusCopy = status.clone();
if(isCreateNotSet) {
statusCopy.setCreatedTimestamp(newLastModifiedTs);
}
statusCopy.setLastModifiedTimestamp(newLastModifiedTs);
LOG.debug("Updated Status {}", statusCopy);

View File

@@ -2415,6 +2415,8 @@ components:
example:
customerId: 2
username: new_user
password: pwd
role: CustomerIT
PortalUserRole:
type: string