2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.monitoring.configuration.camunda;
23 import org.springframework.stereotype.Service;
24 import org.springframework.web.util.UriComponentsBuilder;
27 * @author waqas.ikram@ericsson.com
30 public class CamundaRestUrlProvider {
32 private static final String HISTORY_PATH = "history";
33 private final URI baseUri;
35 public CamundaRestUrlProvider(final String httpUrl, final String engineName) {
36 this.baseUri = UriComponentsBuilder.fromHttpUrl(httpUrl).path(engineName).build().toUri();
41 * "https://docs.camunda.org/manual/7.5/reference/rest/history/process-instance/get-process-instance-query/">Get
42 * Process Instances</a>}.
44 * @param requestId the request ID
47 public String getHistoryProcessInstanceUrl(final String requestId) {
48 return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance")
49 .query("variables=requestId_eq_{requestID}").buildAndExpand(requestId).toString();
54 * "https://docs.camunda.org/manual/7.5/reference/rest/history/process-instance/get-process-instance/">Get Single
55 * Process Instance</a>}.
57 * @param processInstanceId the process instance id.
60 public String getSingleProcessInstanceUrl(final String processInstanceId) {
61 return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("process-instance")
62 .pathSegment(processInstanceId).build().toString();
66 * see {@link <a href= "https://docs.camunda.org/manual/7.5/reference/rest/process-definition/get-xml/">Get BPMN 2.0
69 * @param processDefinitionId the process definition id.
72 public String getProcessDefinitionUrl(final String processDefinitionId) {
73 return UriComponentsBuilder.fromUri(baseUri).pathSegment("process-definition").pathSegment(processDefinitionId)
74 .pathSegment("xml").build().toString();
79 * "https://docs.camunda.org/manual/7.5/reference/rest/history/activity-instance/get-activity-instance/">Get Single
80 * Activity Instance (Historic)</a>}.
82 * @param processInstanceId the process instance id.
85 public String getActivityInstanceUrl(final String processInstanceId) {
86 return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("activity-instance")
87 .query("processInstanceId={processInstanceId}").queryParam("sortBy", "startTime")
88 .queryParam("sortOrder", "asc").buildAndExpand(processInstanceId).toString();
93 * "https://docs.camunda.org/manual/7.5/reference/rest/history/variable-instance/get-variable-instance/">Get Single
94 * Variable Instance</a>}.
96 * @param processInstanceId the process instance id.
99 public String getProcessInstanceVariablesUrl(final String processInstanceId) {
100 return UriComponentsBuilder.fromUri(baseUri).pathSegment(HISTORY_PATH).pathSegment("variable-instance")
101 .query("processInstanceId={processInstanceId}").buildAndExpand(processInstanceId).toString();