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.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.core.report.mgt.Constants; 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.DeviceManagerUtil;
import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil; import org.wso2.carbon.device.mgt.core.util.HttpReportingUtil;
import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserRealm;
@ -90,6 +91,7 @@ public class DeviceInformationManagerImpl implements DeviceInformationManager {
@Override @Override
public void addDeviceInfo(Device device, DeviceInfo deviceInfo) throws DeviceDetailsMgtException { public void addDeviceInfo(Device device, DeviceInfo deviceInfo) throws DeviceDetailsMgtException {
try { try {
publishEvents(device, deviceInfo); publishEvents(device, deviceInfo);
DeviceManagementDAOFactory.beginTransaction(); DeviceManagementDAOFactory.beginTransaction();
DeviceInfo newDeviceInfo; 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 * 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;
}
} }

@ -103,7 +103,7 @@ import java.util.regex.Pattern;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public final class DeviceManagerUtil { public final class DeviceManagerUtil {
private static final Log log = LogFactory.getLog(DeviceManagerUtil.class); private static final Log log = LogFactory.getLog(DeviceManagerUtil.class);
public static final String GENERAL_CONFIG_RESOURCE_PATH = "general"; public static final String GENERAL_CONFIG_RESOURCE_PATH = "general";
@ -712,30 +712,6 @@ public final class DeviceManagerUtil {
return jwtClient.getAccessToken(clientId, clientSecret, deviceOwner, scopes); 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> * <h1>Generate a value for the passed os version</h1>
* *
@ -840,4 +816,28 @@ public final class DeviceManagerUtil {
} }
return joiner.toString(); 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