use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class PdfFormController method sendFormPdfDataSet.
@PostMapping("/dataSet")
@PreAuthorize("hasRole('ALL') or hasRole('F_DATAVALUE_ADD')")
@ResponseBody
public WebMessage sendFormPdfDataSet(HttpServletRequest request) throws Exception {
JobConfiguration jobId = new JobConfiguration("inMemoryDataValueImport", JobType.DATAVALUE_IMPORT, currentUserService.getCurrentUser().getUid(), true);
notifier.clear(jobId);
InputStream in = request.getInputStream();
in = StreamUtils.wrapAndCheckCompressionFormat(in);
ImportSummary summary = dataValueSetService.importDataValueSetPdf(in, ImportOptions.getDefaultImportOptions(), jobId);
return importSummary(summary);
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class SystemSettingController method setSystemSettingV29.
@PostMapping(consumes = ContextUtils.CONTENT_TYPE_JSON)
@PreAuthorize("hasRole('ALL') or hasRole('F_SYSTEM_SETTING')")
@ResponseBody
public WebMessage setSystemSettingV29(@RequestBody Map<String, Object> settings) {
List<String> invalidKeys = settings.keySet().stream().filter((key) -> !SettingKey.getByName(key).isPresent()).collect(Collectors.toList());
if (!invalidKeys.isEmpty()) {
return conflict("Key(s) is not supported: " + StringUtils.join(invalidKeys, ", "));
}
for (Entry<String, Object> entry : settings.entrySet()) {
String key = entry.getKey();
Serializable valueObject = SettingKey.getAsRealClass(key, entry.getValue().toString());
systemSettingManager.saveSystemSetting(SettingKey.getByName(key).get(), valueObject);
}
return ok("System settings imported");
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class UserSettingController method setUserSettingByKey.
@PostMapping(value = "/{key}")
public WebMessage setUserSettingByKey(@PathVariable(value = "key") String key, @RequestParam(value = "user", required = false) String username, @RequestParam(value = "userId", required = false) String userId, @RequestParam(required = false) String value, @RequestBody(required = false) String valuePayload) throws WebMessageException {
UserSettingKey userSettingKey = getUserSettingKey(key);
User user = getUser(userId, username);
String newValue = ObjectUtils.firstNonNull(value, valuePayload);
if (StringUtils.isEmpty(newValue)) {
throw new WebMessageException(conflict("You need to specify a new value"));
}
userSettingService.saveUserSetting(userSettingKey, UserSettingKey.getAsRealClass(key, newValue), user);
return ok("User setting saved");
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class FileResourceController method saveFileResource.
@PostMapping
public WebMessage saveFileResource(@RequestParam MultipartFile file, @RequestParam(defaultValue = "DATA_VALUE") FileResourceDomain domain) throws WebMessageException, IOException {
FileResource fileResource = fileResourceUtils.saveFileResource(file, domain);
WebMessage webMessage = new WebMessage(Status.OK, HttpStatus.ACCEPTED);
webMessage.setResponse(new FileResourceWebMessageResponse(fileResource));
return webMessage;
}
use of org.hisp.dhis.dxf2.webmessage.WebMessage in project dhis2-core by dhis2.
the class EnrollmentController method updateEnrollmentJson.
@PutMapping(value = "/{id}", consumes = APPLICATION_JSON_VALUE, produces = APPLICATION_JSON_VALUE)
@ResponseBody
public WebMessage updateEnrollmentJson(@PathVariable String id, ImportOptions importOptions, HttpServletRequest request) throws IOException {
InputStream inputStream = StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream());
ImportSummary importSummary = enrollmentService.updateEnrollmentJson(id, inputStream, importOptions);
importSummary.setImportOptions(importOptions);
return importSummary(importSummary);
}
Aggregations