Merge "Kafka now works in kube for calls outside its namespace"
[nonrtric.git] / enrichment-coordinator-service / src / main / java / org / oransc / enrichment / controllers / r1consumer / ConsumerController.java
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2020 Nordix Foundation
6  * %%
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20
21 package org.oransc.enrichment.controllers.r1consumer;
22
23 import com.fasterxml.jackson.databind.ObjectMapper;
24 import com.google.gson.Gson;
25 import com.google.gson.GsonBuilder;
26
27 import io.swagger.v3.oas.annotations.Operation;
28 import io.swagger.v3.oas.annotations.Parameter;
29 import io.swagger.v3.oas.annotations.media.ArraySchema;
30 import io.swagger.v3.oas.annotations.media.Content;
31 import io.swagger.v3.oas.annotations.media.Schema;
32 import io.swagger.v3.oas.annotations.responses.ApiResponse;
33 import io.swagger.v3.oas.annotations.responses.ApiResponses;
34 import io.swagger.v3.oas.annotations.tags.Tag;
35
36 import java.lang.invoke.MethodHandles;
37 import java.net.URI;
38 import java.net.URISyntaxException;
39 import java.util.ArrayList;
40 import java.util.Collection;
41 import java.util.List;
42
43 import org.json.JSONObject;
44 import org.oransc.enrichment.controllers.ErrorResponse;
45 import org.oransc.enrichment.controllers.VoidResponse;
46 import org.oransc.enrichment.controllers.r1producer.ProducerCallbacks;
47 import org.oransc.enrichment.exceptions.ServiceException;
48 import org.oransc.enrichment.repository.InfoJob;
49 import org.oransc.enrichment.repository.InfoJobs;
50 import org.oransc.enrichment.repository.InfoProducer;
51 import org.oransc.enrichment.repository.InfoProducers;
52 import org.oransc.enrichment.repository.InfoType;
53 import org.oransc.enrichment.repository.InfoTypeSubscriptions;
54 import org.oransc.enrichment.repository.InfoTypes;
55 import org.slf4j.Logger;
56 import org.slf4j.LoggerFactory;
57 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.http.HttpStatus;
59 import org.springframework.http.MediaType;
60 import org.springframework.http.ResponseEntity;
61 import org.springframework.web.bind.annotation.DeleteMapping;
62 import org.springframework.web.bind.annotation.GetMapping;
63 import org.springframework.web.bind.annotation.PathVariable;
64 import org.springframework.web.bind.annotation.PutMapping;
65 import org.springframework.web.bind.annotation.RequestBody;
66 import org.springframework.web.bind.annotation.RequestMapping;
67 import org.springframework.web.bind.annotation.RequestParam;
68 import org.springframework.web.bind.annotation.RestController;
69 import reactor.core.publisher.Mono;
70
71 @SuppressWarnings("java:S3457") // No need to call "toString()" method as formatting and string ..
72 @RestController("Consumer API")
73 @Tag(name = ConsumerConsts.CONSUMER_API_NAME)
74 @RequestMapping(path = ConsumerConsts.API_ROOT, produces = MediaType.APPLICATION_JSON_VALUE)
75 public class ConsumerController {
76
77     private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
78     private final InfoJobs infoJobs;
79     private final InfoTypes infoTypes;
80     private final InfoProducers infoProducers;
81     private final ProducerCallbacks producerCallbacks;
82     private final InfoTypeSubscriptions infoTypeSubscriptions;
83     private static Gson gson = new GsonBuilder().create();
84
85     public ConsumerController(@Autowired InfoJobs jobs, @Autowired InfoTypes infoTypes,
86         @Autowired InfoProducers infoProducers, @Autowired ProducerCallbacks producerCallbacks,
87         @Autowired InfoTypeSubscriptions infoTypeSubscriptions) {
88         this.infoProducers = infoProducers;
89         this.infoJobs = jobs;
90         this.infoTypeSubscriptions = infoTypeSubscriptions;
91         this.infoTypes = infoTypes;
92         this.producerCallbacks = producerCallbacks;
93     }
94
95     @GetMapping(path = "/info-types", produces = MediaType.APPLICATION_JSON_VALUE)
96     @Operation(summary = "Information type identifiers", description = "")
97     @ApiResponses(
98         value = { //
99             @ApiResponse(
100                 responseCode = "200",
101                 description = "Information type identifiers", //
102                 content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))), //
103         })
104     public ResponseEntity<Object> getinfoTypeIdentifiers( //
105     ) {
106         List<String> result = new ArrayList<>();
107         for (InfoType infoType : this.infoTypes.getAllInfoTypes()) {
108             result.add(infoType.getId());
109         }
110
111         return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
112     }
113
114     @GetMapping(path = "/info-types/{infoTypeId}", produces = MediaType.APPLICATION_JSON_VALUE)
115     @Operation(summary = "Individual information type", description = "")
116     @ApiResponses(
117         value = { //
118             @ApiResponse(
119                 responseCode = "200",
120                 description = "Information type", //
121                 content = @Content(schema = @Schema(implementation = ConsumerInfoTypeInfo.class))), //
122             @ApiResponse(
123                 responseCode = "404",
124                 description = "Information type is not found", //
125                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
126         })
127     public ResponseEntity<Object> getInfoType( //
128         @PathVariable("infoTypeId") String infoTypeId) {
129         try {
130             InfoType type = this.infoTypes.getType(infoTypeId);
131             ConsumerInfoTypeInfo info = toInfoTypeInfo(type);
132             return new ResponseEntity<>(gson.toJson(info), HttpStatus.OK);
133         } catch (Exception e) {
134             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
135         }
136     }
137
138     @GetMapping(path = "/info-jobs", produces = MediaType.APPLICATION_JSON_VALUE)
139     @Operation(summary = "Information Job identifiers", description = "query for information job identifiers")
140     @ApiResponses(
141         value = { //
142             @ApiResponse(
143                 responseCode = "200",
144                 description = "Information information job identifiers", //
145                 content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))),
146             @ApiResponse(
147                 responseCode = "404",
148                 description = "Information type is not found", //
149                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
150         })
151     public ResponseEntity<Object> getJobIds( //
152         @Parameter(
153             name = ConsumerConsts.INFO_TYPE_ID_PARAM,
154             required = false, //
155             description = ConsumerConsts.INFO_TYPE_ID_PARAM_DESCRIPTION) //
156         @RequestParam(name = ConsumerConsts.INFO_TYPE_ID_PARAM, required = false) String infoTypeId,
157         @Parameter(
158             name = ConsumerConsts.OWNER_PARAM,
159             required = false, //
160             description = ConsumerConsts.OWNER_PARAM_DESCRIPTION) //
161         @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = false) String owner) {
162         try {
163             List<String> result = new ArrayList<>();
164             if (owner != null) {
165                 for (InfoJob job : this.infoJobs.getJobsForOwner(owner)) {
166                     if (infoTypeId == null || job.getTypeId().equals(infoTypeId)) {
167                         result.add(job.getId());
168                     }
169                 }
170             } else if (infoTypeId != null) {
171                 this.infoJobs.getJobsForType(infoTypeId).forEach(job -> result.add(job.getId()));
172             } else {
173                 this.infoJobs.getJobs().forEach(job -> result.add(job.getId()));
174             }
175             return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
176         } catch (
177
178         Exception e) {
179             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
180         }
181     }
182
183     @GetMapping(path = "/info-jobs/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE) //
184     @Operation(summary = ConsumerConsts.INDIVIDUAL_JOB, description = "") //
185     @ApiResponses(
186         value = { //
187             @ApiResponse(
188                 responseCode = "200",
189                 description = "Information subscription job", //
190                 content = @Content(schema = @Schema(implementation = ConsumerJobInfo.class))), //
191             @ApiResponse(
192                 responseCode = "404",
193                 description = "Information subscription job is not found", //
194                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
195         })
196     public ResponseEntity<Object> getIndividualEiJob( //
197         @PathVariable("infoJobId") String infoJobId) {
198         try {
199             InfoJob job = this.infoJobs.getJob(infoJobId);
200             return new ResponseEntity<>(gson.toJson(toInfoJobInfo(job)), HttpStatus.OK);
201         } catch (Exception e) {
202             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
203         }
204     }
205
206     @GetMapping(path = "/info-jobs/{infoJobId}/status", produces = MediaType.APPLICATION_JSON_VALUE)
207     @Operation(summary = "Job status", description = "")
208     @ApiResponses(
209         value = { //
210             @ApiResponse(
211                 responseCode = "200",
212                 description = "Information subscription job status", //
213                 content = @Content(schema = @Schema(implementation = ConsumerJobStatus.class))), //
214             @ApiResponse(
215                 responseCode = "404",
216                 description = "Information subscription job is not found", //
217                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
218         })
219     public ResponseEntity<Object> getEiJobStatus( //
220         @PathVariable("infoJobId") String jobId) {
221         try {
222             InfoJob job = this.infoJobs.getJob(jobId);
223             return new ResponseEntity<>(gson.toJson(toInfoJobStatus(job)), HttpStatus.OK);
224         } catch (Exception e) {
225             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
226         }
227     }
228
229     private ConsumerJobStatus toInfoJobStatus(InfoJob job) {
230         Collection<String> producerIds = new ArrayList<>();
231         this.infoProducers.getProducersForType(job.getTypeId()).forEach(producer -> producerIds.add(producer.getId()));
232         return this.infoProducers.isJobEnabled(job)
233             ? new ConsumerJobStatus(ConsumerJobStatus.InfoJobStatusValues.ENABLED, producerIds)
234             : new ConsumerJobStatus(ConsumerJobStatus.InfoJobStatusValues.DISABLED, producerIds);
235
236     }
237
238     @DeleteMapping(path = "/info-jobs/{infoJobId}", produces = MediaType.APPLICATION_JSON_VALUE)
239     @Operation(summary = ConsumerConsts.INDIVIDUAL_JOB, description = "")
240     @ApiResponses(
241         value = { //
242             @ApiResponse(
243                 responseCode = "200",
244                 description = "Not used", //
245                 content = @Content(schema = @Schema(implementation = VoidResponse.class))),
246             @ApiResponse(
247                 responseCode = "204",
248                 description = "Job deleted", //
249                 content = @Content(schema = @Schema(implementation = VoidResponse.class))), // "Individual
250                                                                                             // Information Job"
251             @ApiResponse(
252                 responseCode = "404",
253                 description = "Information subscription job is not found", //
254                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
255         })
256     public ResponseEntity<Object> deleteIndividualEiJob( //
257         @PathVariable("infoJobId") String jobId) {
258         try {
259             InfoJob job = this.infoJobs.getJob(jobId);
260             this.infoJobs.remove(job, this.infoProducers);
261             return new ResponseEntity<>(HttpStatus.NO_CONTENT);
262         } catch (Exception e) {
263             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
264         }
265     }
266
267     @PutMapping(
268         path = "/info-jobs/{infoJobId}", //
269         produces = MediaType.APPLICATION_JSON_VALUE, //
270         consumes = MediaType.APPLICATION_JSON_VALUE)
271     @Operation(summary = ConsumerConsts.INDIVIDUAL_JOB, description = ConsumerConsts.PUT_INDIVIDUAL_JOB_DESCRIPTION)
272     @ApiResponses(
273         value = { //
274             @ApiResponse(
275                 responseCode = "201",
276                 description = "Job created", //
277                 content = @Content(schema = @Schema(implementation = VoidResponse.class))), //
278             @ApiResponse(
279                 responseCode = "200",
280                 description = "Job updated", //
281                 content = @Content(schema = @Schema(implementation = VoidResponse.class))), //
282             @ApiResponse(
283                 responseCode = "404",
284                 description = "Information type is not found", //
285                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), //
286             @ApiResponse(
287                 responseCode = "400",
288                 description = "Input validation failed", //
289                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))), //
290             @ApiResponse(
291                 responseCode = "409",
292                 description = "Cannot modify job type", //
293                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class)))})
294     public Mono<ResponseEntity<Object>> putIndividualInfoJob( //
295         @PathVariable("infoJobId") String jobId, //
296         @Parameter(
297             name = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM,
298             required = false, //
299             description = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM_DESCRIPTION) //
300         @RequestParam(
301             name = ConsumerConsts.PERFORM_TYPE_CHECK_PARAM,
302             required = false,
303             defaultValue = "false") boolean performTypeCheck,
304         @RequestBody ConsumerJobInfo informationJobObject) {
305
306         final boolean isNewJob = this.infoJobs.get(jobId) == null;
307
308         return validatePutInfoJob(jobId, informationJobObject, performTypeCheck) //
309             .flatMap(this::startInfoSubscriptionJob) //
310             .doOnNext(this.infoJobs::put) //
311             .map(newEiJob -> new ResponseEntity<>(isNewJob ? HttpStatus.CREATED : HttpStatus.OK)) //
312             .onErrorResume(throwable -> Mono.just(ErrorResponse.create(throwable, HttpStatus.NOT_FOUND)));
313     }
314
315     @GetMapping(path = "/info-type-subscription", produces = MediaType.APPLICATION_JSON_VALUE)
316     @Operation(
317         summary = "Information type subscription identifiers",
318         description = "query for information type subscription identifiers")
319     @ApiResponses(
320         value = { //
321             @ApiResponse(
322                 responseCode = "200",
323                 description = "Information type subscription identifiers", //
324                 content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))),})
325     public ResponseEntity<Object> getInfoTypeSubscriptions( //
326
327         @Parameter(
328             name = ConsumerConsts.OWNER_PARAM,
329             required = false, //
330             description = ConsumerConsts.OWNER_PARAM_DESCRIPTION) //
331         @RequestParam(name = ConsumerConsts.OWNER_PARAM, required = false) String owner) {
332         try {
333             List<String> result = new ArrayList<>();
334             if (owner != null) {
335                 this.infoTypeSubscriptions.getSubscriptionsForOwner(owner)
336                     .forEach(subscription -> result.add(subscription.getId()));
337             } else {
338                 this.infoTypeSubscriptions.getAllSubscriptions()
339                     .forEach(subscription -> result.add(subscription.getId()));
340             }
341             return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK);
342         } catch (Exception e) {
343             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
344         }
345     }
346
347     @GetMapping(path = "/info-type-subscription/{subscriptionId}", produces = MediaType.APPLICATION_JSON_VALUE) //
348     @Operation(summary = ConsumerConsts.INDIVIDUAL_TYPE_SUBSCRIPTION, description = "") //
349     @ApiResponses(
350         value = { //
351             @ApiResponse(
352                 responseCode = "200",
353                 description = "Type subscription", //
354                 content = @Content(schema = @Schema(implementation = ConsumerTypeSubscriptionInfo.class))), //
355             @ApiResponse(
356                 responseCode = "404",
357                 description = "Subscription is not found", //
358                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
359         })
360     public ResponseEntity<Object> getIndividualTypeSubscription( //
361         @PathVariable("subscriptionId") String subscriptionId) {
362         try {
363             InfoTypeSubscriptions.SubscriptionInfo subscription =
364                 this.infoTypeSubscriptions.getSubscription(subscriptionId);
365             return new ResponseEntity<>(gson.toJson(toTypeSuscriptionInfo(subscription)), HttpStatus.OK);
366         } catch (Exception e) {
367             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
368         }
369     }
370
371     @PutMapping(
372         path = "/info-type-subscription/{subscriptionId}", //
373         produces = MediaType.APPLICATION_JSON_VALUE, //
374         consumes = MediaType.APPLICATION_JSON_VALUE)
375     @Operation(
376         summary = ConsumerConsts.INDIVIDUAL_TYPE_SUBSCRIPTION,
377         description = ConsumerConsts.TYPE_SUBSCRIPTION_DESCRIPTION)
378     @ApiResponses(
379         value = { //
380             @ApiResponse(
381                 responseCode = "201",
382                 description = "Subscription created", //
383                 content = @Content(schema = @Schema(implementation = VoidResponse.class))), //
384             @ApiResponse(
385                 responseCode = "200",
386                 description = "Subscription updated", //
387                 content = @Content(schema = @Schema(implementation = VoidResponse.class))) //
388         })
389     public Mono<ResponseEntity<Object>> putIndividualTypeSubscription( //
390         @PathVariable("subscriptionId") String subscriptionId, //
391         @RequestBody ConsumerTypeSubscriptionInfo subscription) {
392
393         final boolean isNewSubscription = this.infoTypeSubscriptions.get(subscriptionId) == null;
394         this.infoTypeSubscriptions.put(toTypeSuscriptionInfo(subscription, subscriptionId));
395         return Mono.just(new ResponseEntity<>(isNewSubscription ? HttpStatus.CREATED : HttpStatus.OK));
396     }
397
398     @DeleteMapping(path = "/info-type-subscription/{subscriptionId}", produces = MediaType.APPLICATION_JSON_VALUE)
399     @Operation(summary = ConsumerConsts.INDIVIDUAL_TYPE_SUBSCRIPTION, description = "")
400     @ApiResponses(
401         value = { //
402             @ApiResponse(
403                 responseCode = "200",
404                 description = "Not used", //
405                 content = @Content(schema = @Schema(implementation = VoidResponse.class))),
406             @ApiResponse(
407                 responseCode = "204",
408                 description = "Subscription deleted", //
409                 content = @Content(schema = @Schema(implementation = VoidResponse.class))),
410             @ApiResponse(
411                 responseCode = "404",
412                 description = "Subscription is not found", //
413                 content = @Content(schema = @Schema(implementation = ErrorResponse.ErrorInfo.class))) //
414         })
415     public ResponseEntity<Object> deleteIndividualTypeSubscription( //
416         @PathVariable("subscriptionId") String subscriptionId) {
417         try {
418             InfoTypeSubscriptions.SubscriptionInfo subscription =
419                 this.infoTypeSubscriptions.getSubscription(subscriptionId);
420             this.infoTypeSubscriptions.remove(subscription);
421             return new ResponseEntity<>(HttpStatus.NO_CONTENT);
422         } catch (Exception e) {
423             return ErrorResponse.create(e, HttpStatus.NOT_FOUND);
424         }
425     }
426
427     private ConsumerTypeSubscriptionInfo toTypeSuscriptionInfo(InfoTypeSubscriptions.SubscriptionInfo s) {
428         return new ConsumerTypeSubscriptionInfo(s.getCallbackUrl(), s.getOwner());
429     }
430
431     private InfoTypeSubscriptions.SubscriptionInfo toTypeSuscriptionInfo(ConsumerTypeSubscriptionInfo s,
432         String subscriptionId) {
433         return InfoTypeSubscriptions.SubscriptionInfo.builder() //
434             .apiVersion(ConsumerCallbacks.API_VERSION) //
435             .owner(s.owner) //
436             .id(subscriptionId) //
437             .callbackUrl(s.statusResultUri).build();
438     }
439
440     private Mono<InfoJob> startInfoSubscriptionJob(InfoJob newInfoJob) {
441         return this.producerCallbacks.startInfoSubscriptionJob(newInfoJob, infoProducers) //
442             .doOnNext(noOfAcceptingProducers -> this.logger.debug("Started job {}, number of activated producers: {}",
443                 newInfoJob.getId(), noOfAcceptingProducers)) //
444             .map(noOfAcceptingProducers -> newInfoJob);
445     }
446
447     private Mono<InfoJob> validatePutInfoJob(String jobId, ConsumerJobInfo jobInfo, boolean performTypeCheck) {
448         try {
449             if (performTypeCheck) {
450                 InfoType infoType = this.infoTypes.getType(jobInfo.infoTypeId);
451                 validateJsonObjectAgainstSchema(infoType.getJobDataSchema(), jobInfo.jobDefinition);
452             }
453             InfoJob existingEiJob = this.infoJobs.get(jobId);
454             validateUri(jobInfo.statusNotificationUri);
455             validateUri(jobInfo.jobResultUri);
456
457             if (existingEiJob != null && !existingEiJob.getTypeId().equals(jobInfo.infoTypeId)) {
458                 throw new ServiceException("Not allowed to change type for existing job", HttpStatus.CONFLICT);
459             }
460             return Mono.just(toEiJob(jobInfo, jobId, jobInfo.infoTypeId));
461         } catch (Exception e) {
462             return Mono.error(e);
463         }
464     }
465
466     private void validateUri(String url) throws URISyntaxException, ServiceException {
467         if (url != null && !url.isEmpty()) {
468             URI uri = new URI(url);
469             if (!uri.isAbsolute()) {
470                 throw new ServiceException("URI: " + url + " is not absolute", HttpStatus.BAD_REQUEST);
471             }
472         }
473     }
474
475     private void validateJsonObjectAgainstSchema(Object schemaObj, Object object) throws ServiceException {
476         if (schemaObj != null) { // schema is optional for now
477             try {
478                 ObjectMapper mapper = new ObjectMapper();
479
480                 String schemaAsString = mapper.writeValueAsString(schemaObj);
481                 JSONObject schemaJSON = new JSONObject(schemaAsString);
482                 var schema = org.everit.json.schema.loader.SchemaLoader.load(schemaJSON);
483
484                 String objectAsString = mapper.writeValueAsString(object);
485                 JSONObject json = new JSONObject(objectAsString);
486                 schema.validate(json);
487             } catch (Exception e) {
488                 throw new ServiceException("Json validation failure " + e.toString(), HttpStatus.BAD_REQUEST);
489             }
490         }
491     }
492
493     private InfoJob toEiJob(ConsumerJobInfo info, String id, String typeId) {
494         return InfoJob.builder() //
495             .id(id) //
496             .typeId(typeId) //
497             .owner(info.owner) //
498             .jobData(info.jobDefinition) //
499             .targetUrl(info.jobResultUri) //
500             .jobStatusUrl(info.statusNotificationUri == null ? "" : info.statusNotificationUri) //
501             .build();
502     }
503
504     private ConsumerInfoTypeInfo toInfoTypeInfo(InfoType type) {
505         return new ConsumerInfoTypeInfo(type.getJobDataSchema(), typeStatus(type),
506             this.infoProducers.getProducerIdsForType(type.getId()).size());
507     }
508
509     private ConsumerInfoTypeInfo.ConsumerTypeStatusValues typeStatus(InfoType type) {
510         for (InfoProducer producer : this.infoProducers.getProducersForType(type)) {
511             if (producer.isAvailable()) {
512                 return ConsumerInfoTypeInfo.ConsumerTypeStatusValues.ENABLED;
513             }
514         }
515         return ConsumerInfoTypeInfo.ConsumerTypeStatusValues.DISABLED;
516     }
517
518     private ConsumerJobInfo toInfoJobInfo(InfoJob s) {
519         return new ConsumerJobInfo(s.getTypeId(), s.getJobData(), s.getOwner(), s.getTargetUrl(), s.getJobStatusUrl());
520     }
521 }