--- /dev/null
+/*\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.holmes.common.dmaap;\r
+\r
+import java.util.Collections;\r
+import java.util.List;\r
+import javax.ws.rs.client.Client;\r
+import javax.ws.rs.client.ClientBuilder;\r
+import javax.ws.rs.client.WebTarget;\r
+import javax.ws.rs.core.Response;\r
+import lombok.Getter;\r
+import lombok.Setter;\r
+import org.glassfish.jersey.client.ClientConfig;\r
+import org.onap.holmes.common.dmaap.entity.VesAlarm;\r
+import org.onap.holmes.common.exception.CorrelationException;\r
+\r
+@Getter\r
+@Setter\r
+public class Subscriber {\r
+ /**\r
+ * The number of milliseconds to wait for messages if none are immediately\r
+ * available. This should normally be used, and set at 15000 or higher.\r
+ */\r
+ private int timeout = 15000;\r
+\r
+ /**\r
+ * The maximum number of messages to return\r
+ */\r
+ private int limit = 100;\r
+\r
+ private boolean secure;\r
+ private String topic;\r
+ private String url;\r
+ private String consumerGroup = "g0";\r
+ private String consumer = "u1";\r
+ private String authInfo;\r
+ private String authExpDate;\r
+\r
+ List<VesAlarm> subscribe() throws CorrelationException {\r
+ Client client = ClientBuilder.newClient(new ClientConfig());\r
+ WebTarget webTarget = client.target(url);\r
+ Response response = webTarget.path(topic).path(consumerGroup).path(consumer).request().get();\r
+\r
+ try {\r
+ return extractAlarms(response);\r
+ }\r
+ catch (Exception e) {\r
+ throw new CorrelationException("Failed to convert the response data to VES alarms.", e);\r
+ }\r
+ }\r
+\r
+ private List<VesAlarm> extractAlarms(Response response) {\r
+ return Collections.emptyList();\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2017 ZTE Corporation.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package org.onap.holmes.common.dmaap.entity;\r
+\r
+import lombok.Getter;\r
+import lombok.Setter;\r
+\r
+@Getter\r
+@Setter\r
+public class VesAlarm {\r
+ private String eventId;\r
+ private String sourceId;\r
+ private String specificProblem;\r
+ private long alarmRaisedTime;\r
+}\r