use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class LocaleController method delete.
@PreAuthorize("hasRole('ALL') or hasRole('F_LOCALE_DELETE')")
@DeleteMapping(path = "/dbLocales/{uid}")
@ResponseStatus(value = HttpStatus.NO_CONTENT)
public void delete(@PathVariable String uid) throws Exception {
I18nLocale i18nLocale = localeService.getI18nLocaleByUid(uid);
if (i18nLocale == null) {
throw new WebMessageException(notFound("Cannot find Locale with uid " + uid));
}
localeService.deleteI18nLocale(i18nLocale);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class LocaleController method getObject.
@GetMapping(value = "/dbLocales/{uid}", produces = APPLICATION_JSON_VALUE)
@ResponseBody
public I18nLocale getObject(@PathVariable("uid") String uid, HttpServletResponse response) throws Exception {
response.setHeader(ContextUtils.HEADER_CACHE_CONTROL, CacheControl.noCache().cachePrivate().getHeaderValue());
I18nLocale locale = localeService.getI18nLocaleByUid(uid);
if (locale == null) {
throw new WebMessageException(notFound("Cannot find Locale with uid: " + uid));
}
return locale;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class MessageConversationController method addRecipientsToMessageConversation.
@PostMapping("/{uid}/recipients")
@ResponseStatus(HttpStatus.NO_CONTENT)
public void addRecipientsToMessageConversation(@PathVariable("uid") String uid, @RequestBody MessageConversation messageConversation) throws Exception {
org.hisp.dhis.message.MessageConversation conversation = messageService.getMessageConversation(uid);
if (conversation == null) {
throw new WebMessageException(notFound("Message conversation does not exist: " + uid));
}
Set<User> additionalUsers = getUsersToMessageConversation(messageConversation, messageConversation.getUsers());
additionalUsers.forEach(user -> {
if (!conversation.getUsers().contains(user)) {
conversation.addUserMessage(new UserMessage(user, false));
}
});
messageService.updateMessageConversation(conversation);
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class MessageConversationController method getMessage.
/**
* /* Returns the specified message after making sure the user has access to
* it.
*
* @param mcUid the message conversation UID.
* @param msgUid the message UID.
* @param user the user.
* @return a {@link Message}.
* @throws WebMessageException
*/
private Message getMessage(String mcUid, String msgUid, User user) throws WebMessageException {
org.hisp.dhis.message.MessageConversation conversation = messageService.getMessageConversation(mcUid);
if (conversation == null) {
throw new WebMessageException(notFound(String.format("No message conversation with uid '%s'", mcUid)));
}
if (!canReadMessageConversation(user, conversation)) {
throw new AccessDeniedException("Not authorized to access this conversation.");
}
List<Message> messages = conversation.getMessages().stream().filter(msg -> msg.getUid().equals(msgUid)).collect(Collectors.toList());
if (messages.size() < 1) {
throw new WebMessageException(notFound(String.format("No message with uid '%s' in messageConversation '%s", msgUid, mcUid)));
}
Message message = messages.get(0);
if (message.isInternal() && !configurationService.isUserInFeedbackRecipientUserGroup(user)) {
throw new WebMessageException(conflict("Not authorized to access this message"));
}
return message;
}
use of org.hisp.dhis.dxf2.events.trackedentity.store.query.EventQuery.COLUMNS.UID in project dhis2-core by dhis2.
the class ReportController method getReportDesign.
@GetMapping("/{uid}/design")
public void getReportDesign(@PathVariable("uid") String uid, HttpServletResponse response) throws Exception {
Report report = reportService.getReport(uid);
if (report == null) {
throw new WebMessageException(notFound("Report not found for identifier: " + uid));
}
if (report.getDesignContent() == null) {
throw new WebMessageException(conflict("Report has no design content: " + uid));
}
if (report.isTypeHtml()) {
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_HTML, CacheStrategy.NO_CACHE, filenameEncode(report.getName()) + ".html", true);
} else {
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.NO_CACHE, filenameEncode(report.getName()) + ".jrxml", true);
}
response.getWriter().write(report.getDesignContent());
}
Aggregations