Compare commits

..

6 Commits

Author SHA1 Message Date
Rahul Sharma
3a4561b323 Changing BE code to trim the name and inventoryId 2021-10-28 16:19:35 -04:00
norm-traxler
7abc4c8554 Merge pull request #167 from Telecominfraproject/WIFI-5112-bugfix-passpoint-ssid-association
[WIFI-5112] Changing associatedAccessSsidProfileIds to Set<Long>
2021-10-26 15:58:38 -04:00
ralphlee
34bec5009a [WIFI-5112] Changing associatedAccessSsidProfileIds to Set<Long> 2021-10-26 14:38:03 -04:00
Thomas-Leung2021
824568a128 Merge pull request #166 from Telecominfraproject/WIFI-3219
[WIFI-3219] throw exception when country code is being updated
2021-10-26 12:39:51 -04:00
Thomas Leung
5211ed7e68 Merged in NETEXP-3325 (pull request #25)
[NETEXP-3325] throw exception when country code is being updated

Approved-by: Norm Traxler
2021-10-26 12:07:06 -04:00
norm-traxler
1bffb4f96a Merge pull request #165 from Telecominfraproject/WIFI-4732-2
Wifi 4732 EquipmentPortalController resets to defaults channels for equipment country change
2021-10-20 16:20:24 -04:00
9 changed files with 66 additions and 87 deletions

View File

@@ -634,7 +634,7 @@ public class AllInOneStartListener implements ApplicationRunner {
((PasspointProfile) passpointHotspotConfig.getDetails()).setPasspointVenueProfileId(passpointVenueProfileId);
((PasspointProfile) passpointHotspotConfig.getDetails()).setOsuSsidProfileId(profileSsidOpenId);
((PasspointProfile) passpointHotspotConfig.getDetails())
.setAssociatedAccessSsidProfileIds(List.of(profileSsidPskId));
.setAssociatedAccessSsidProfileIds(Set.of(profileSsidPskId));
return profileServiceInterface.create(passpointHotspotConfig);
}

View File

@@ -263,7 +263,8 @@ public class EquipmentDAO extends BaseJdbcDao {
},
keyHolder);
}catch (DuplicateKeyException e) {
throw new DsDuplicateEntityException(e);
LOG.error("Duplicate equipment found", e);
throw new DsDuplicateEntityException("Equipment with the assetId " + equipment.getInventoryId() + " already exists!");
}
// keyHolder.getKey() now contains the generated key

View File

@@ -88,12 +88,7 @@ public class EquipmentController {
throw new DsDataValidationException("Equipment contains unsupported value");
}
long ts = System.currentTimeMillis();
if (equipment.getCreatedTimestamp() == 0) {
equipment.setCreatedTimestamp(ts);
}
equipment.setLastModifiedTimestamp(ts);
updateValuesIfNeeded(equipment);
Equipment ret = equipmentDatastore.create(equipment);
LOG.debug("Created Equipment {}", ret);
@@ -104,7 +99,24 @@ public class EquipmentController {
return ret;
}
private void updateValuesIfNeeded(Equipment equipment) {
// strip out whitespaces from user entered inventoryId and name strings
if (equipment.getName() != null) {
equipment.setName(equipment.getName().strip());
}
if (equipment.getInventoryId() != null) {
equipment.setInventoryId(equipment.getInventoryId().strip());
}
// Update timestamp
long ts = System.currentTimeMillis();
if (equipment.getCreatedTimestamp() == 0) {
equipment.setCreatedTimestamp(ts);
}
equipment.setLastModifiedTimestamp(ts);
}
/**
* Retrieves Equipment by id
* @param equipmentId

View File

@@ -71,11 +71,33 @@ public class EquipmentControllerTest {
equipmentController.delete(ret.getId());
}
private void assertEqualEquipments(
Equipment expected,
Equipment actual) {
@Test
public void testEquipmentCRUD_ValidateSpaceInInputString() {
//Create new Equipment - success
Equipment equipment = new Equipment();
equipment.setName(" nameAndInventoryIdWithTrailingSpaces ");
equipment.setInventoryId(" C4411EAA31F5 ");
equipment.setEquipmentType(EquipmentType.AP);
Equipment ret = equipmentController.create(equipment);
assertNotNull(ret);
ret = equipmentController.get(ret.getId());
assertEqualEquipments(equipment, ret);
ret = equipmentController.getOrNull(ret.getId());
assertEqualEquipments(equipment, ret);
assertNull(equipmentController.getOrNull(-1));
//Delete - success
equipmentController.delete(ret.getId());
}
private void assertEqualEquipments(Equipment expected, Equipment actual) {
assertEquals(expected.getName(), actual.getName());
//TODO: add more fields to check here
}

View File

@@ -1,30 +0,0 @@
package com.telecominfraproject.wlan.location.models.events;
import com.telecominfraproject.wlan.core.model.json.interfaces.HasLocationId;
import com.telecominfraproject.wlan.location.models.Location;
import com.telecominfraproject.wlan.systemevent.models.CustomerEventWithPayload;
public class LocationChangedApImpactingEvent extends CustomerEventWithPayload<Location> implements HasLocationId {
private static final long serialVersionUID = -8369849230866347412L;
public LocationChangedApImpactingEvent(Location location){
super(location.getCustomerId(), location);
}
@Override
public long getLocationId() {
if (getPayload() != null) {
return getPayload().getId();
}
return 0;
}
/**
* Constructor used by JSON
*/
public LocationChangedApImpactingEvent() {
super(0, 0, null);
}
}

View File

@@ -80,7 +80,7 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
location.setLocationType(LocationType.FLOOR);
location.setCustomerId(getNextCustomerId());
location.setName("testName_updated");
location.setDetails(generateDetails(CountryCode.US));
location.setDetails(generateDetails(CountryCode.CA));
Location retFromUpdate = testInterface.update(location);
assertFieldEquals(location, retFromUpdate);
@@ -95,6 +95,14 @@ public class LocationServiceRemoteTest extends BaseRemoteTest {
// expected it
}
//UPDATE test - fail because country code cannot be modified once created
try {
location.setDetails(generateDetails(CountryCode.US));
testInterface.update(location);
fail("failed to detect country code update");
} catch (IllegalStateException e) {
// expected it
}
//DELETE Test
testInterface.delete(ret.getId());

View File

@@ -25,7 +25,6 @@ import com.telecominfraproject.wlan.datastore.exceptions.DsEntityNotFoundExcepti
import com.telecominfraproject.wlan.location.datastore.LocationDatastore;
import com.telecominfraproject.wlan.location.models.Location;
import com.telecominfraproject.wlan.location.models.events.LocationAddedEvent;
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
import com.telecominfraproject.wlan.location.models.events.LocationChangedEvent;
import com.telecominfraproject.wlan.location.models.events.LocationRemovedEvent;
import com.telecominfraproject.wlan.systemevent.models.SystemEvent;
@@ -97,14 +96,15 @@ public class LocationServiceController {
}
Location existingLocation = locationDatastore.get(location.getId());
if (location.needsToBeUpdatedOnDevice(existingLocation)) {
throw new IllegalStateException("Cannot update location. Country code is not allow to modify once created.");
}
Location ret = locationDatastore.update(location);
List<SystemEvent> events = new ArrayList<>();
if (ret.needsToBeUpdatedOnDevice(existingLocation)) {
events.add(new LocationChangedApImpactingEvent(ret));
}
events.add(new LocationChangedEvent(ret));
publishEvents(events);

View File

@@ -63,7 +63,7 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
private boolean enable2pt4GHz;
private boolean enable5GHz;
private List<Long> associatedAccessSsidProfileIds;
private Set<Long> associatedAccessSsidProfileIds;
private Long osuSsidProfileId;
@@ -321,11 +321,11 @@ public class PasspointProfile extends ProfileDetails implements PushableConfigur
this.passpointNetworkAuthenticationType = passpointNetworkAuthenticationType;
}
public List<Long> getAssociatedAccessSsidProfileIds() {
public Set<Long> getAssociatedAccessSsidProfileIds() {
return associatedAccessSsidProfileIds;
}
public void setAssociatedAccessSsidProfileIds(List<Long> associatedAccessSsidProfileIds) {
public void setAssociatedAccessSsidProfileIds(Set<Long> associatedAccessSsidProfileIds) {
this.associatedAccessSsidProfileIds = associatedAccessSsidProfileIds;
}

View File

@@ -39,7 +39,6 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWConfigChangeNoti
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWNewChannelRequest;
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCellSizeAttributesRequest;
import com.telecominfraproject.wlan.equipmentgateway.service.EquipmentGatewayServiceInterface;
import com.telecominfraproject.wlan.location.models.events.LocationChangedApImpactingEvent;
import com.telecominfraproject.wlan.profile.ProfileServiceInterface;
import com.telecominfraproject.wlan.profile.models.Profile;
import com.telecominfraproject.wlan.profile.models.events.ProfileAddedEvent;
@@ -92,7 +91,7 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
|| ser.getDetails() instanceof EquipmentChannelsChangedEvent || ser.getDetails() instanceof EquipmentCellSizeAttributesChangedEvent
|| ser.getDetails() instanceof EquipmentRemovedEvent || ser.getDetails() instanceof ProfileAddedEvent
|| ser.getDetails() instanceof ProfileChangedEvent || ser.getDetails() instanceof ProfileRemovedEvent
|| ser.getDetails() instanceof LocationChangedApImpactingEvent || ser.getDetails() instanceof EquipmentCustomerChangedEvent);
|| ser.getDetails() instanceof EquipmentCustomerChangedEvent);
} else {
ret = false;
}
@@ -133,9 +132,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
case "ProfileRemovedEvent":
process((ProfileRemovedEvent) se);
break;
case "LocationChangedApImpactingEvent":
process((LocationChangedApImpactingEvent) se);
break;
case "EquipmentCustomerChangedEvent":
process((EquipmentCustomerChangedEvent) se);
default:
@@ -222,36 +218,6 @@ public class EquipmentConfigPushTrigger extends StreamProcessor {
LOG.debug("Finished processing profile {}", profile.getId());
}
private void process(LocationChangedApImpactingEvent model) {
LOG.debug("Processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
Set<Long> locationIds = new HashSet<>(Arrays.asList(model.getPayload().getId()));
// go through all equipmentIds that reside in the specified location and trigger change config notification on
// them
PaginationContext<PairLongLong> context = new PaginationContext<>(100);
while (!context.isLastPage()) {
PaginationResponse<PairLongLong> page = equipmentServiceInterface.getEquipmentIdsByLocationIds(locationIds, context);
context = page.getContext();
Set<Long> equipmentIds = new HashSet<>();
page.getItems().forEach(p -> equipmentIds.add(p.getValue2()));
// retrieve full equipment objects to get the inventory id
List<Equipment> equipmentForPage = equipmentServiceInterface.get(equipmentIds);
List<CEGWBaseCommand> commands = new ArrayList<>(equipmentForPage.size());
equipmentForPage.forEach(eq -> commands.add(new CEGWConfigChangeNotification(eq.getInventoryId(), eq.getId())));
equipmentGatewayInterface.sendCommands(commands);
LOG.debug("Page {} - sent {} commands to equipment gateway", context.getLastReturnedPageNumber(), commands.size());
}
LOG.debug("Finished processing LocationChangedApImpactingEvent {}", model.getPayload().getId());
}
private void process(EquipmentCustomerChangedEvent model) {
LOG.info("Processing EquipmentCustomerChangedEvent {}", model.getPayload().getId());