Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added server/lib/jackson/jackson-jaxrs-base-2.14.3.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.mirth.connect.client.core.api;

/**
* This class contains custom MIME types used by the Mirth API.
*/
public class ApiContentTypes {
/** Custom MIME type for Mirth API JSON responses */
public static final String APPLICATION_MIRTHAPI_JSON = "application/mirthapi+json";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.mirth.connect.client.core.api.providers;

import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

@Provider
public class JacksonJsonObjectMapperConfig implements ContextResolver<ObjectMapper> {

private final ObjectMapper objectMapper;

public JacksonJsonObjectMapperConfig() {
objectMapper = new ObjectMapper();
// Be forward compatible with unknown properties
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// Match the Swagger documented format for dates and null handling
objectMapper.registerModule(new JavaTimeModule());
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}

@Override
public ObjectMapper getContext(Class<?> aClass) {
return objectMapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.mirth.connect.client.core.Permissions;
import com.mirth.connect.client.core.api.BaseServletInterface;
import com.mirth.connect.client.core.api.MirthOperation;
import com.mirth.connect.client.core.api.ApiContentTypes;
import com.mirth.connect.client.core.api.Param;
import com.mirth.connect.model.ChannelHeader;
import com.mirth.connect.model.alert.AlertInfo;
Expand All @@ -45,8 +46,8 @@

@Path("/alerts")
@Tag(name = "Alerts")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, ApiContentTypes.APPLICATION_MIRTHAPI_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, ApiContentTypes.APPLICATION_MIRTHAPI_JSON })
public interface AlertServletInterface extends BaseServletInterface {

@POST
Expand All @@ -58,7 +59,8 @@ public void createAlert(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }) }) AlertModel alertModel)
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON) }) AlertModel alertModel)
throws ClientException;

@GET
Expand All @@ -68,7 +70,8 @@ public void createAlert(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }), })
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlert", display = "Get alerts", permission = Permissions.ALERTS_VIEW)
public AlertModel getAlert(
@Param("alertId") @Parameter(description = "The ID of the alert.", required = true) @PathParam("alertId") String alertId)
Expand All @@ -81,7 +84,8 @@ public AlertModel getAlert(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_json") }), })
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlert", display = "Get alerts", permission = Permissions.ALERTS_VIEW)
public List<AlertModel> getAlerts(
@Param("alertIds") @Parameter(description = "The ID of the alert(s). If absent, all alerts will be returned.") @QueryParam("alertId") Set<String> alertIds)
Expand All @@ -94,14 +98,17 @@ public List<AlertModel> getAlerts(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_json") }) })
@ExampleObject(name = "alert_list", ref = "../apiexamples/alert_list_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlert", display = "Get alerts", permission = Permissions.ALERTS_VIEW)
public List<AlertModel> getAlertsPost(
@Param("alertIds") @RequestBody(description = "The ID of the alert(s). If absent, all alerts will be returned.", content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_set", ref = "../apiexamples/guid_set_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_set", ref = "../apiexamples/guid_set_json") }) }) Set<String> alertIds)
@ExampleObject(name = "alert_set", ref = "../apiexamples/guid_set_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
Set<String> alertIds)
throws ClientException;

@GET
Expand All @@ -111,7 +118,8 @@ public List<AlertModel> getAlertsPost(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_status_list", ref = "../apiexamples/alert_status_list_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_status_list", ref = "../apiexamples/alert_status_list_json") }) })
@ExampleObject(name = "alert_status_list", ref = "../apiexamples/alert_status_list_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlertStatusList", display = "Get alert status list", permission = Permissions.ALERTS_VIEW, type = ExecuteType.ASYNC, auditable = false)
public List<AlertStatus> getAlertStatusList() throws ClientException;

Expand All @@ -122,15 +130,18 @@ public List<AlertModel> getAlertsPost(
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_json") }) })
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlertInfo", display = "Get alert info", permission = Permissions.ALERTS_VIEW, auditable = false)
public AlertInfo getAlertInfo(// @formatter:off
@Param("alertId") @Parameter(description = "The ID of the alert.", required = true) @PathParam("alertId") String alertId,
@Param("cachedChannels") @RequestBody(description = "A map of ChannelHeader objects telling the server the state of the client-side channel cache.", required = true, content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_json") }) }) Map<String, ChannelHeader> cachedChannels)
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
Map<String, ChannelHeader> cachedChannels)
throws ClientException;
// @formatter:on

Expand All @@ -141,23 +152,28 @@ public AlertInfo getAlertInfo(// @formatter:off
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_json") }) })
@ExampleObject(name = "alert_info", ref = "../apiexamples/alert_info_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlertInfo", display = "Get alert info", permission = Permissions.ALERTS_VIEW)
public AlertInfo getAlertInfo(
@Param("cachedChannels") @RequestBody(description = "A map of ChannelHeader objects telling the server the state of the client-side channel cache.", required = true, content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_json") }) }) Map<String, ChannelHeader> cachedChannels)
@ExampleObject(name = "channel_header_map", ref = "../apiexamples/channel_header_map_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
Map<String, ChannelHeader> cachedChannels)
throws ClientException;

@GET
@Path("/options")
@Operation(summary = "Returns all alert protocol options.")
@ApiResponse(content = { @Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_protocol_options", ref = "../apiexamples/alert_protocol_options_xml") }),
@ApiResponse(content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert_protocol_options", ref = "../apiexamples/alert_protocol_options_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert_protocol_options", ref = "../apiexamples/alert_protocol_options_json") }) })
@ExampleObject(name = "alert_protocol_options", ref = "../apiexamples/alert_protocol_options_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getAlertProtocolOptions", display = "Get alert protocol options", permission = Permissions.ALERTS_VIEW, auditable = false)
public Map<String, Map<String, String>> getAlertProtocolOptions() throws ClientException;

Expand All @@ -171,7 +187,9 @@ public void updateAlert(// @formatter:off
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }) }) AlertModel alertModel)
@ExampleObject(name = "alert", ref = "../apiexamples/alert_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
AlertModel alertModel)
throws ClientException;
// @formatter:on

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,45 +34,51 @@
import com.mirth.connect.client.core.ClientException;
import com.mirth.connect.client.core.Operation.ExecuteType;
import com.mirth.connect.client.core.Permissions;
import com.mirth.connect.client.core.api.ApiContentTypes;
import com.mirth.connect.client.core.api.BaseServletInterface;
import com.mirth.connect.client.core.api.MirthOperation;
import com.mirth.connect.client.core.api.Param;
import com.mirth.connect.model.ChannelGroup;

@Path("/channelgroups")
@Tag(name = "Channel Groups")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, ApiContentTypes.APPLICATION_MIRTHAPI_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, ApiContentTypes.APPLICATION_MIRTHAPI_JSON })
public interface ChannelGroupServletInterface extends BaseServletInterface {

@GET
@Path("/")
@Operation(summary = "Retrieve a list of all channel groups, or multiple channel groups by ID.")
@ApiResponse(content = { @Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_xml") }),
@ApiResponse(content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_json") }) })
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getChannelGroups", display = "Get channel groups", permission = Permissions.CHANNEL_GROUPS_VIEW, type = ExecuteType.ASYNC, auditable = false)
public List<ChannelGroup> getChannelGroups(@Param("channelGroupIds") @Parameter(description = "The IDs of the channel groups to retrieve. If absent, all groups will be retrieved.") @QueryParam("channelGroupId") Set<String> channelGroupIds) throws ClientException;

@POST
@Path("/_getChannelGroups")
@Operation(summary = "Retrieve a list of all channel groups, or multiple channel groups by ID. This is a POST request alternative to GET /channelgroups that may be used when there are too many channel group IDs to include in the query parameters.")
@ApiResponse(content = { @Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_xml") }),
@ApiResponse(content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_json") }) })
@ExampleObject(name = "channel_group_list", ref = "../apiexamples/channel_group_list_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), })
@MirthOperation(name = "getChannelGroups", display = "Get channel groups", permission = Permissions.CHANNEL_GROUPS_VIEW, type = ExecuteType.ASYNC, auditable = false)
public List<ChannelGroup> getChannelGroupsPost(@Param("channelGroupIds") @RequestBody(description = "The IDs of the channel groups to retrieve. If absent, all groups will be retrieved.", content = {
@Content(mediaType = MediaType.APPLICATION_XML, examples = {
@ExampleObject(name = "group_set", ref = "../apiexamples/guid_set_xml") }),
@Content(mediaType = MediaType.APPLICATION_JSON, examples = {
@ExampleObject(name = "group_set", ref = "../apiexamples/guid_set_json") }) }) Set<String> channelGroupIds) throws ClientException;
@ExampleObject(name = "group_set", ref = "../apiexamples/guid_set_json") }),
@Content(mediaType = ApiContentTypes.APPLICATION_MIRTHAPI_JSON), }) Set<String> channelGroupIds) throws ClientException;

@POST
@Path("/_bulkUpdate")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN })
@Produces({ MediaType.APPLICATION_JSON, ApiContentTypes.APPLICATION_MIRTHAPI_JSON, MediaType.TEXT_PLAIN })
@Operation(summary = "Updates all channel groups in one request. " + SWAGGER_TRY_IT_OUT_DISCLAIMER)
@MirthOperation(name = "updateChannelGroups", display = "Update channel groups", permission = Permissions.CHANNELS_MANAGE)
public boolean updateChannelGroups(// @formatter:off
Expand Down
Loading