use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.
the class ConfigurationController method removeOfflineOrganisationUnitLevel.
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@RequestMapping(value = "/offlineOrganisationUnitLevel", method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void removeOfflineOrganisationUnitLevel() {
Configuration config = configurationService.getConfiguration();
config.setOfflineOrganisationUnitLevel(null);
configurationService.setConfiguration(config);
}
use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.
the class ConfigurationServiceTest method testConfiguration.
@Test
public void testConfiguration() {
User userA = createUser('A');
User userB = createUser('B');
UserGroup group = new UserGroup("UserGroupA");
group.getMembers().add(userA);
group.getMembers().add(userB);
userService.addUser(userA);
userService.addUser(userB);
userGroupService.addUserGroup(group);
Configuration config = configurationService.getConfiguration();
assertNull(config.getFeedbackRecipients());
config.setFeedbackRecipients(group);
configurationService.setConfiguration(config);
config = configurationService.getConfiguration();
assertNotNull(config.getFeedbackRecipients());
assertEquals(group, config.getFeedbackRecipients());
}
use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.
the class DefaultSystemService method getSystemInfo.
// -------------------------------------------------------------------------
// SystemService implementation
// -------------------------------------------------------------------------
@Override
public SystemInfo getSystemInfo() {
SystemInfo info = systemInfo.instance();
if (info == null) {
return null;
}
Date lastAnalyticsTableSuccess = (Date) systemSettingManager.getSystemSetting(SettingKey.LAST_SUCCESSFUL_ANALYTICS_TABLES_UPDATE);
String lastAnalyticsTableRuntime = (String) systemSettingManager.getSystemSetting(SettingKey.LAST_SUCCESSFUL_ANALYTICS_TABLES_RUNTIME);
String systemName = (String) systemSettingManager.getSystemSetting(SettingKey.APPLICATION_TITLE);
Configuration config = configurationService.getConfiguration();
Date now = new Date();
info.setCalendar(calendarService.getSystemCalendar().name());
info.setDateFormat(calendarService.getSystemDateFormat().getJs());
info.setServerDate(new Date());
info.setLastAnalyticsTableSuccess(lastAnalyticsTableSuccess);
info.setIntervalSinceLastAnalyticsTableSuccess(DateUtils.getPrettyInterval(lastAnalyticsTableSuccess, now));
info.setSystemId(config.getSystemId());
info.setLastAnalyticsTableRuntime(lastAnalyticsTableRuntime);
info.setSystemName(systemName);
setSystemMetadataVersionInfo(info);
return info;
}
use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.
the class DefaultSynchronizationManager method isRemoteServerAvailable.
// -------------------------------------------------------------------------
// SynchronizatonManager implementation
// -------------------------------------------------------------------------
@Override
public AvailabilityStatus isRemoteServerAvailable() {
Configuration config = configurationService.getConfiguration();
if (!isRemoteServerConfigured(config)) {
return new AvailabilityStatus(false, "Remote server is not configured", HttpStatus.BAD_GATEWAY);
}
String url = systemSettingManager.getSystemSetting(SettingKey.REMOTE_INSTANCE_URL) + PING_PATH;
String username = (String) systemSettingManager.getSystemSetting(SettingKey.REMOTE_INSTANCE_USERNAME);
String password = (String) systemSettingManager.getSystemSetting(SettingKey.REMOTE_INSTANCE_PASSWORD);
log.debug(String.format("Remote server ping URL: %s, username: %s", url, username));
HttpEntity<String> request = getBasicAuthRequestEntity(username, password);
ResponseEntity<String> response = null;
HttpStatus sc = null;
String st = null;
AvailabilityStatus status = null;
try {
response = restTemplate.exchange(url, HttpMethod.GET, request, String.class);
sc = response.getStatusCode();
} catch (HttpClientErrorException ex) {
sc = ex.getStatusCode();
st = ex.getStatusText();
} catch (HttpServerErrorException ex) {
sc = ex.getStatusCode();
st = ex.getStatusText();
} catch (ResourceAccessException ex) {
return new AvailabilityStatus(false, "Network is unreachable", HttpStatus.BAD_GATEWAY);
}
log.debug("Response status code: " + sc);
if (HttpStatus.FOUND.equals(sc)) {
status = new AvailabilityStatus(false, "No authentication was provided", sc);
} else if (HttpStatus.UNAUTHORIZED.equals(sc)) {
status = new AvailabilityStatus(false, "Authentication failed", sc);
} else if (HttpStatus.INTERNAL_SERVER_ERROR.equals(sc)) {
status = new AvailabilityStatus(false, "Remote server experienced an internal error", sc);
} else if (HttpStatus.OK.equals(sc)) {
status = new AvailabilityStatus(true, "Authentication was successful", sc);
} else {
status = new AvailabilityStatus(false, "Server is not available: " + st, sc);
}
log.info("Status: " + status);
return status;
}
use of org.hisp.dhis.configuration.Configuration in project dhis2-core by dhis2.
the class ConfigurationPopulator method executeInTransaction.
@Override
public void executeInTransaction() {
checkSecurityConfiguration();
Configuration config = configurationService.getConfiguration();
if (config != null && config.getSystemId() == null) {
config.setSystemId(UUID.randomUUID().toString());
configurationService.setConfiguration(config);
}
}
Aggregations