Merge branch 'reporting2' into 'master'

Reporting conflict fixes

See merge request entgra/carbon-device-mgt!486
feature/appm-store/pbac
Inosh Perara 5 years ago
commit 670174e25d

@ -48,6 +48,7 @@ import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.report.mgt.Constants;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil;
import org.wso2.carbon.user.api.UserRealm;
@ -90,6 +91,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
@Override
public void addDeviceInfo(Device device, DeviceInfo deviceInfo) throws DeviceDetailsMgtException {
try {
publishEvents(device, deviceInfo);
DeviceManagementDAOFactory.beginTransaction();
DeviceInfo newDeviceInfo;
@ -471,21 +473,6 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
}
private String[] getRolesOfUser(String userName) throws UserStoreException {
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
String[] roleList;
if (userRealm != null) {
userRealm.getUserStoreManager().getRoleNames();
roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName);
} else {
String msg = "User realm is not initiated. Logged in user: " + userName;
log.error(msg);
throw new UserStoreException(msg);
}
return roleList;
}
/**
* Generate and add a value depending on the device's OS version included in device info
*
@ -520,5 +507,20 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
}
}
}
private String[] getRolesOfUser(String userName) throws UserStoreException {
UserRealm userRealm = CarbonContext.getThreadLocalCarbonContext().getUserRealm();
String[] roleList;
if (userRealm != null) {
userRealm.getUserStoreManager().getRoleNames();
roleList = userRealm.getUserStoreManager().getRoleListOfUser(userName);
} else {
String msg = "User realm is not initiated. Logged in user: " + userName;
log.error(msg);
throw new UserStoreException(msg);
}
return roleList;
}
}

@ -712,30 +712,6 @@ public final class DeviceManagerUtil {
return jwtClient.getAccessToken(clientId, clientSecret, deviceOwner, scopes);
}
public static Object getConfiguration(String key) {
PlatformConfigurationManagementService configMgtService =
new PlatformConfigurationManagementServiceImpl();
try {
PlatformConfiguration tenantConfiguration = configMgtService.getConfiguration
(GENERAL_CONFIG_RESOURCE_PATH);
List<ConfigurationEntry> configuration = tenantConfiguration.getConfiguration();
if (configuration != null && !configuration.isEmpty()) {
for (ConfigurationEntry cEntry : configuration) {
if (key.equalsIgnoreCase(cEntry.getName())) {
return cEntry.getValue();
}
}
}
} catch (ConfigurationManagementException e) {
log.error("Error while getting the configurations from registry.", e);
return null;
}
return null;
}
/**
* <h1>Generate a value for the passed os version</h1>
*
@ -840,4 +816,28 @@ public final class DeviceManagerUtil {
}
return joiner.toString();
}
public static Object getConfiguration(String key) {
PlatformConfigurationManagementService configMgtService =
new PlatformConfigurationManagementServiceImpl();
try {
PlatformConfiguration tenantConfiguration = configMgtService.getConfiguration
(GENERAL_CONFIG_RESOURCE_PATH);
List<ConfigurationEntry> configuration = tenantConfiguration.getConfiguration();
if (configuration != null && !configuration.isEmpty()) {
for (ConfigurationEntry cEntry : configuration) {
if (key.equalsIgnoreCase(cEntry.getName())) {
return cEntry.getValue();
}
}
}
} catch (ConfigurationManagementException e) {
log.error("Error while getting the configurations from registry.", e);
return null;
}
return null;
}
}

Loading…
Cancel
Save