|
|
@ -83,7 +83,10 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
DeviceGroup existingGroup = this.groupDAO.getGroup(deviceGroup.getName(), tenantId);
|
|
|
|
DeviceGroup existingGroup = this.groupDAO.getGroup(deviceGroup.getName(), tenantId);
|
|
|
|
if (existingGroup == null) {
|
|
|
|
if (existingGroup == null) {
|
|
|
|
this.groupDAO.addGroup(deviceGroup, tenantId);
|
|
|
|
int updatedGroupID = this.groupDAO.addGroup(deviceGroup, tenantId);
|
|
|
|
|
|
|
|
if (deviceGroup.getGroupProperties() != null && deviceGroup.getGroupProperties().size() > 0) {
|
|
|
|
|
|
|
|
this.groupDAO.addGroupProperties(deviceGroup, updatedGroupID, tenantId);
|
|
|
|
|
|
|
|
}
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new GroupAlreadyExistException("Group exist with name " + deviceGroup.getName());
|
|
|
|
throw new GroupAlreadyExistException("Group exist with name " + deviceGroup.getName());
|
|
|
@ -132,6 +135,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId);
|
|
|
|
DeviceGroup existingGroup = this.groupDAO.getGroup(groupId, tenantId);
|
|
|
|
if (existingGroup != null) {
|
|
|
|
if (existingGroup != null) {
|
|
|
|
this.groupDAO.updateGroup(deviceGroup, groupId, tenantId);
|
|
|
|
this.groupDAO.updateGroup(deviceGroup, groupId, tenantId);
|
|
|
|
|
|
|
|
if (deviceGroup.getGroupProperties() != null && deviceGroup.getGroupProperties().size() > 0) {
|
|
|
|
|
|
|
|
this.groupDAO.updateGroupProperties(deviceGroup, groupId, tenantId);
|
|
|
|
|
|
|
|
}
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
throw new GroupNotExistException("Group with ID - '" + groupId + "' doesn't exists!");
|
|
|
|
throw new GroupNotExistException("Group with ID - '" + groupId + "' doesn't exists!");
|
|
|
@ -171,6 +177,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
GroupManagementDAOFactory.beginTransaction();
|
|
|
|
this.groupDAO.deleteGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
this.groupDAO.deleteGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
this.groupDAO.deleteAllGroupProperties(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
GroupManagementDAOFactory.commitTransaction();
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("DeviceGroup " + deviceGroup.getName() + " removed.");
|
|
|
|
log.debug("DeviceGroup " + deviceGroup.getName() + " removed.");
|
|
|
@ -206,6 +213,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
deviceGroup = this.groupDAO.getGroup(groupId, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(),
|
|
|
|
|
|
|
|
CarbonContext.getThreadLocalCarbonContext().getTenantId()));
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
String msg = "Error occurred while obtaining group '" + groupId + "'";
|
|
|
|
String msg = "Error occurred while obtaining group '" + groupId + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -241,6 +250,8 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
deviceGroup = this.groupDAO.getGroup(groupName, CarbonContext.getThreadLocalCarbonContext().getTenantId());
|
|
|
|
|
|
|
|
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(),
|
|
|
|
|
|
|
|
CarbonContext.getThreadLocalCarbonContext().getTenantId()));
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
String msg = "Error occurred while obtaining group with name: '" + groupName + "'";
|
|
|
|
String msg = "Error occurred while obtaining group with name: '" + groupName + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -269,6 +280,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
deviceGroups = this.groupDAO.getGroups(tenantId);
|
|
|
|
deviceGroups = this.groupDAO.getGroups(tenantId);
|
|
|
|
|
|
|
|
for(DeviceGroup group : deviceGroups){
|
|
|
|
|
|
|
|
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -303,6 +317,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
deviceGroups = this.groupDAO.getGroups(request, tenantId);
|
|
|
|
deviceGroups = this.groupDAO.getGroups(request, tenantId);
|
|
|
|
|
|
|
|
for(DeviceGroup group : deviceGroups){
|
|
|
|
|
|
|
|
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
} catch (GroupManagementDAOException e) {
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
@ -348,6 +365,7 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deviceGroups = this.groupDAO.getGroups(roleList, tenantId);
|
|
|
|
deviceGroups = this.groupDAO.getGroups(roleList, tenantId);
|
|
|
|
for (DeviceGroup deviceGroup : deviceGroups) {
|
|
|
|
for (DeviceGroup deviceGroup : deviceGroups) {
|
|
|
|
|
|
|
|
deviceGroup.setGroupProperties(this.groupDAO.getAllGroupProperties(deviceGroup.getGroupId(), tenantId));
|
|
|
|
groups.put(deviceGroup.getGroupId(), deviceGroup);
|
|
|
|
groups.put(deviceGroup.getGroupId(), deviceGroup);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (UserStoreException | SQLException | GroupManagementDAOException e) {
|
|
|
|
} catch (UserStoreException | SQLException | GroupManagementDAOException e) {
|
|
|
@ -410,6 +428,9 @@ public class GroupManagementProviderServiceImpl implements GroupManagementProvid
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
GroupManagementDAOFactory.openConnection();
|
|
|
|
allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId);
|
|
|
|
allMatchingGroups = this.groupDAO.getGroups(request, allDeviceGroupIdsOfUser, tenantId);
|
|
|
|
|
|
|
|
for(DeviceGroup group : allMatchingGroups){
|
|
|
|
|
|
|
|
group.setGroupProperties(this.groupDAO.getAllGroupProperties(group.getGroupId(), tenantId));
|
|
|
|
|
|
|
|
}
|
|
|
|
} catch (GroupManagementDAOException | SQLException e) {
|
|
|
|
} catch (GroupManagementDAOException | SQLException e) {
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
String msg = "Error occurred while retrieving all groups in tenant";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|