|
|
@ -181,8 +181,6 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE);
|
|
|
|
group.setStatus(DeviceGroupConstants.GroupStatus.ACTIVE);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(group.getGroupId());
|
|
|
|
|
|
|
|
String stringDevices = new Gson().toJson(DeviceMgtAPIUtils.getGroupManagementProviderService().getAllDevicesOfGroup(group.getName(), false));
|
|
|
|
|
|
|
|
log.info(
|
|
|
|
log.info(
|
|
|
|
"Group " + group.getName() + " created",
|
|
|
|
"Group " + group.getName() + " created",
|
|
|
|
groupMgtContextBuilder
|
|
|
|
groupMgtContextBuilder
|
|
|
@ -190,8 +188,6 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
.setGroupId(String.valueOf(group.getGroupId()))
|
|
|
|
.setGroupId(String.valueOf(group.getGroupId()))
|
|
|
|
.setName(group.getName())
|
|
|
|
.setName(group.getName())
|
|
|
|
.setOwner(group.getOwner())
|
|
|
|
.setOwner(group.getOwner())
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
|
|
|
|
.setDevices(stringDevices)
|
|
|
|
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setUserName(owner)
|
|
|
|
.setUserName(owner)
|
|
|
@ -255,7 +251,12 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().updateGroup(deviceGroup, groupId);
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().updateGroup(deviceGroup, groupId);
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
|
|
|
String stringDevices = new Gson().toJson(DeviceMgtAPIUtils.getGroupManagementProviderService().getAllDevicesOfGroup(deviceGroup.getName(), false));
|
|
|
|
List<Device> devices = DeviceMgtAPIUtils.getGroupManagementProviderService().getAllDevicesOfGroup(deviceGroup.getName(), false);
|
|
|
|
|
|
|
|
List<String> deviceIdentifiers = new ArrayList<>();
|
|
|
|
|
|
|
|
for(Device device : devices) {
|
|
|
|
|
|
|
|
deviceIdentifiers.add(device.getDeviceIdentifier());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String stringDeviceIdentifiers = new Gson().toJson(deviceIdentifiers);
|
|
|
|
log.info(
|
|
|
|
log.info(
|
|
|
|
"Group " + deviceGroup.getName() + " updated",
|
|
|
|
"Group " + deviceGroup.getName() + " updated",
|
|
|
|
groupMgtContextBuilder
|
|
|
|
groupMgtContextBuilder
|
|
|
@ -264,7 +265,7 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
.setName(deviceGroup.getName())
|
|
|
|
.setName(deviceGroup.getName())
|
|
|
|
.setOwner(deviceGroup.getOwner())
|
|
|
|
.setOwner(deviceGroup.getOwner())
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
.setDevices(stringDevices)
|
|
|
|
.setDeviceIdentifiers(stringDeviceIdentifiers)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setUserName(username)
|
|
|
|
.setUserName(username)
|
|
|
@ -293,11 +294,13 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
String tenantDomain = String.valueOf(CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
|
|
|
String tenantDomain = String.valueOf(CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
|
|
|
|
String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
|
|
|
|
if (DeviceMgtAPIUtils.getGroupManagementProviderService().deleteGroup(groupId, isDeleteChildren)) {
|
|
|
|
if (DeviceMgtAPIUtils.getGroupManagementProviderService().deleteGroup(groupId, isDeleteChildren)) {
|
|
|
|
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
|
|
|
log.info(
|
|
|
|
log.info(
|
|
|
|
"Group with group id " + groupId + " deleted",
|
|
|
|
"Group with group id " + groupId + " deleted",
|
|
|
|
groupMgtContextBuilder
|
|
|
|
groupMgtContextBuilder
|
|
|
|
.setActionTag("DELETE_GROUP")
|
|
|
|
.setActionTag("DELETE_GROUP")
|
|
|
|
.setGroupId(String.valueOf(groupId))
|
|
|
|
.setGroupId(String.valueOf(groupId))
|
|
|
|
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setUserName(username)
|
|
|
|
.setUserName(username)
|
|
|
@ -394,10 +397,8 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().addDevices(groupId, deviceIdentifiers);
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().addDevices(groupId, deviceIdentifiers);
|
|
|
|
PolicyAdministratorPoint pap = DeviceMgtAPIUtils.getPolicyManagementService().getPAP();
|
|
|
|
PolicyAdministratorPoint pap = DeviceMgtAPIUtils.getPolicyManagementService().getPAP();
|
|
|
|
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
|
|
|
DeviceManagementProviderService dms = DeviceMgtAPIUtils.getDeviceManagementService();
|
|
|
|
List<Device> devices = new ArrayList<>();
|
|
|
|
|
|
|
|
for(DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
|
|
|
for(DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
|
|
|
Device device = dms.getDevice(deviceIdentifier, false);
|
|
|
|
Device device = dms.getDevice(deviceIdentifier, false);
|
|
|
|
devices.add(device);
|
|
|
|
|
|
|
|
if(!device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) {
|
|
|
|
if(!device.getEnrolmentInfo().getStatus().equals(EnrolmentInfo.Status.REMOVED)) {
|
|
|
|
pap.removePolicyUsed(deviceIdentifier);
|
|
|
|
pap.removePolicyUsed(deviceIdentifier);
|
|
|
|
DeviceMgtAPIUtils.getPolicyManagementService().getEffectivePolicy(deviceIdentifier);
|
|
|
|
DeviceMgtAPIUtils.getPolicyManagementService().getEffectivePolicy(deviceIdentifier);
|
|
|
@ -405,14 +406,18 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pap.publishChanges();
|
|
|
|
pap.publishChanges();
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(groupId);
|
|
|
|
String stringDevices = new Gson().toJson(devices);
|
|
|
|
List<String> deviceIdentifiersList = new ArrayList<>();
|
|
|
|
|
|
|
|
for(DeviceIdentifier deviceIdentifier : deviceIdentifiers) {
|
|
|
|
|
|
|
|
deviceIdentifiersList.add(deviceIdentifier.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String stringDeviceIdentifiers = new Gson().toJson(deviceIdentifiersList);
|
|
|
|
log.info(
|
|
|
|
log.info(
|
|
|
|
"Devices added for group id " + groupId,
|
|
|
|
"Devices added for group id " + groupId,
|
|
|
|
groupMgtContextBuilder
|
|
|
|
groupMgtContextBuilder
|
|
|
|
.setActionTag("ADD_DEVICES")
|
|
|
|
.setActionTag("ADD_DEVICES")
|
|
|
|
.setGroupId(String.valueOf(groupId))
|
|
|
|
.setGroupId(String.valueOf(groupId))
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
.setDevices(stringDevices)
|
|
|
|
.setDeviceIdentifiers(stringDeviceIdentifiers)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setUserName(username)
|
|
|
|
.setUserName(username)
|
|
|
@ -553,8 +558,6 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty());
|
|
|
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername().isEmpty());
|
|
|
|
if (group != null) {
|
|
|
|
if (group != null) {
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles());
|
|
|
|
DeviceMgtAPIUtils.getGroupManagementProviderService().manageGroupSharing(group.getGroupId(), groups.getUserRoles());
|
|
|
|
int deviceCount = DeviceMgtAPIUtils.getGroupManagementProviderService().getDeviceCount(group.getGroupId());
|
|
|
|
|
|
|
|
String stringDevices = new Gson().toJson(DeviceMgtAPIUtils.getGroupManagementProviderService().getAllDevicesOfGroup(group.getName(), false));
|
|
|
|
|
|
|
|
log.info(
|
|
|
|
log.info(
|
|
|
|
"Group " + group.getName() + " created",
|
|
|
|
"Group " + group.getName() + " created",
|
|
|
|
groupMgtContextBuilder
|
|
|
|
groupMgtContextBuilder
|
|
|
@ -562,8 +565,6 @@ public class GroupManagementServiceImpl implements GroupManagementService {
|
|
|
|
.setGroupId(String.valueOf(group.getGroupId()))
|
|
|
|
.setGroupId(String.valueOf(group.getGroupId()))
|
|
|
|
.setName(group.getName())
|
|
|
|
.setName(group.getName())
|
|
|
|
.setOwner(group.getOwner())
|
|
|
|
.setOwner(group.getOwner())
|
|
|
|
.setDeviceCount(String.valueOf(deviceCount))
|
|
|
|
|
|
|
|
.setDevices(stringDevices)
|
|
|
|
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantID(tenantId)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setTenantDomain(tenantDomain)
|
|
|
|
.setUserName(username)
|
|
|
|
.setUserName(username)
|
|
|
|