|
35 | 35 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.EXP_UUID; |
36 | 36 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.FILTER_QUERY_PARAMETERS; |
37 | 37 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.FILTER_QUERY_PARAMETERS_EX; |
| 38 | +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.RPT; |
38 | 39 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.INDEX; |
39 | 40 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.INDEX_EX; |
40 | 41 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.INVALID_PARAMETERS; |
|
50 | 51 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MARKER_SET_ID; |
51 | 52 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MISSING_OUTPUTID; |
52 | 53 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MISSING_PARAMETERS; |
| 54 | +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.MISSING_SUBTYPE; |
53 | 55 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_PROVIDER; |
| 56 | +import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_CONFIGURATION; |
54 | 57 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_CONFIGURATION_TYPE; |
55 | 58 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_DERIVED_PROVIDER; |
56 | 59 | import static org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.services.EndpointConstants.NO_SUCH_PROVIDER; |
|
133 | 136 | import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.TreeModelWrapper; |
134 | 137 | import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.VirtualTableModelWrapper; |
135 | 138 | import org.eclipse.tracecompass.internal.analysis.timing.core.event.matching.EventMatchingLatencyAnalysis; |
| 139 | +import org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider.ITmfDataProviderConfigurationDataFetcher; |
| 140 | +import org.eclipse.tracecompass.internal.provisional.tmf.core.dataprovider.TmfDataProviderConfigurationDataModel; |
136 | 141 | import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.ITmfVirtualTableDataProvider; |
137 | 142 | import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.ITmfVirtualTableModel; |
138 | 143 | import org.eclipse.tracecompass.internal.provisional.tmf.core.model.table.IVirtualTableLine; |
@@ -1101,6 +1106,87 @@ private Response getTree(UUID expUUID, String outputId, QueryParameters queryPar |
1101 | 1106 | } |
1102 | 1107 | } |
1103 | 1108 |
|
| 1109 | + /** |
| 1110 | + * Query the provider for a MIME report. Based on the given output, this |
| 1111 | + * endpoint will return a specific report, which can be an image, a |
| 1112 | + * textual data, a HTML, etc. |
| 1113 | + * |
| 1114 | + * @param expUUID |
| 1115 | + * desired experiment UUID |
| 1116 | + * @param outputId |
| 1117 | + * Output ID for the data provider to query |
| 1118 | + * @return {@link Response} with the corresponding report data |
| 1119 | + */ |
| 1120 | + @GET |
| 1121 | + @Path("/report/{outputId}") |
| 1122 | + @Tag(name = RPT) |
| 1123 | + @Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN }) |
| 1124 | + @Operation(summary = "API to get a MIME report", responses = { |
| 1125 | + @ApiResponse(responseCode = "200", description = "Returns the report data"), |
| 1126 | + @ApiResponse(responseCode = "400", description = MISSING_PARAMETERS, content = @Content(schema = @Schema(implementation = String.class))), |
| 1127 | + @ApiResponse(responseCode = "404", description = "Provider not found, missing subtype, or requested resource not found", content = @Content(schema = @Schema(implementation = String.class))), |
| 1128 | + @ApiResponse(responseCode = "500", description = "Error retrieving the report data", content = @Content(schema = @Schema(implementation = String.class))), |
| 1129 | + }) |
| 1130 | + public Response getReport( |
| 1131 | + @Parameter(description = EXP_UUID) @PathParam("expUUID") UUID expUUID, |
| 1132 | + @Parameter(description = OUTPUT_ID) @PathParam("outputId") String outputId) { |
| 1133 | + |
| 1134 | + if (outputId == null) { |
| 1135 | + return Response.status(Status.BAD_REQUEST).entity(MISSING_OUTPUTID).build(); |
| 1136 | + } |
| 1137 | + |
| 1138 | + TmfExperiment experiment = ExperimentManagerService.getExperimentByUUID(expUUID); |
| 1139 | + if (experiment == null) { |
| 1140 | + return Response.status(Status.NOT_FOUND).entity(NO_SUCH_TRACE).build(); |
| 1141 | + } |
| 1142 | + |
| 1143 | + IDataProviderDescriptor descriptor = getDescriptor(experiment, outputId); |
| 1144 | + if (descriptor == null) { |
| 1145 | + return Response.status(Status.NOT_FOUND).entity(NO_SUCH_PROVIDER).build(); |
| 1146 | + } |
| 1147 | + |
| 1148 | + if (descriptor.getType() != ProviderType.MIME) { |
| 1149 | + return Response.status(Status.NOT_FOUND).entity("The requested output is not a MIME report").build(); //$NON-NLS-1$" |
| 1150 | + } |
| 1151 | + |
| 1152 | + ITmfConfiguration config = descriptor.getConfiguration(); |
| 1153 | + if (config == null) { |
| 1154 | + return Response.status(Status.NOT_FOUND).entity(NO_SUCH_CONFIGURATION).build(); |
| 1155 | + } |
| 1156 | + |
| 1157 | + IDataProviderFactory factory = manager.getFactory(REPORTS_FACTORY_ID); |
| 1158 | + if (factory == null) { |
| 1159 | + return Response.status(Status.NOT_FOUND).entity("Report factory not found").build(); //$NON-NLS-1$" |
| 1160 | + } |
| 1161 | + |
| 1162 | + ITmfDataProviderConfigurationDataFetcher dataFetcher = factory.getAdapter(ITmfDataProviderConfigurationDataFetcher.class); |
| 1163 | + if (dataFetcher == null) { |
| 1164 | + return Response.status(Status.NOT_FOUND).entity("Report data fetcher not found").build(); //$NON-NLS-1$ " |
| 1165 | + } |
| 1166 | + |
| 1167 | + try { |
| 1168 | + TmfModelResponse<TmfDataProviderConfigurationDataModel> reportResponse = dataFetcher.getData(experiment, config); |
| 1169 | + if (reportResponse == null) { |
| 1170 | + return Response.status(Status.NOT_FOUND).entity("Report data not found").build(); //$NON-NLS-1$ |
| 1171 | + } |
| 1172 | + |
| 1173 | + if (reportResponse.getStatus() != ITmfResponse.Status.COMPLETED) { |
| 1174 | + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(reportResponse.getStatusMessage()).build(); |
| 1175 | + } |
| 1176 | + |
| 1177 | + TmfDataProviderConfigurationDataModel responseModel = reportResponse.getModel(); |
| 1178 | + if (responseModel == null) { |
| 1179 | + return Response.status(Status.NOT_FOUND).entity("Report data model not found").build(); //$NON-NLS-1$ |
| 1180 | + } |
| 1181 | + |
| 1182 | + return Response.ok(responseModel.getContent(), responseModel.getContentType()).build(); |
| 1183 | + } catch (TmfConfigurationException e) { |
| 1184 | + return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); |
| 1185 | + } catch (Exception e) { |
| 1186 | + return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build(); |
| 1187 | + } |
| 1188 | + } |
| 1189 | + |
1104 | 1190 | /** |
1105 | 1191 | * Query the provider for styles |
1106 | 1192 | * |
|
0 commit comments