2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.models.sim.dmaap.rest;
24 import javax.ws.rs.Consumes;
25 import javax.ws.rs.DefaultValue;
26 import javax.ws.rs.GET;
27 import javax.ws.rs.POST;
28 import javax.ws.rs.Path;
29 import javax.ws.rs.PathParam;
30 import javax.ws.rs.Produces;
31 import javax.ws.rs.QueryParam;
32 import javax.ws.rs.core.Response;
33 import org.onap.policy.models.sim.dmaap.provider.DmaapSimProvider;
36 * Class to provide REST endpoints for DMaaP simulator component statistics.
39 @Produces(DmaapSimRestControllerV1.MEDIA_TYPE_APPLICATION_JSON)
40 public class DmaapSimRestControllerV1 extends BaseRestControllerV1 {
41 public static final String MEDIA_TYPE_APPLICATION_JSON = "application/json";
44 * Get a DMaaP message.
46 * @param topicName topic to get message from
47 * @param consumerGroup consumer group that is getting the message
48 * @param consumerId consumer ID that is getting the message
49 * @param timeoutMs timeout for the message
53 @Path("{topicName}/{consumerGroup}/{consumerId}")
54 public Response getDmaapMessage(@PathParam("topicName") final String topicName,
55 @PathParam("consumerGroup") final String consumerGroup,
56 @PathParam("consumerId") final String consumerId,
57 @QueryParam("limit") @DefaultValue("1") final int limit,
58 @QueryParam("timeout") @DefaultValue("15000") final long timeoutMs) {
60 return DmaapSimProvider.getInstance().processDmaapMessageGet(topicName, consumerGroup, consumerId, limit,
65 * Post a DMaaP message.
67 * @param topicName topic to get message from
68 * @return the response to the post
72 @Consumes(value = {CambriaMessageBodyHandler.MEDIA_TYPE_APPLICATION_CAMBRIA,
73 TextMessageBodyHandler.MEDIA_TYPE_TEXT_PLAIN, MEDIA_TYPE_APPLICATION_JSON})
74 public Response postDmaapMessage(@PathParam("topicName") final String topicName, final Object dmaapMessage) {
76 return DmaapSimProvider.getInstance().processDmaapMessagePut(topicName, dmaapMessage);