/modules/dxp/apps/portal-workflow/portal-workflow-metrics-rest-client/src/main/java/com/liferay/portal/workflow/metrics/rest/client/resource/v1_0/SLAResource.java

http://github.com/liferay/liferay-portal · Java · 821 lines · 605 code · 199 blank · 17 comment · 69 complexity · c1aac337d159ac76569067e93d4d9438 MD5 · raw file

  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * The contents of this file are subject to the terms of the Liferay Enterprise
  5. * Subscription License ("License"). You may not use this file except in
  6. * compliance with the License. You can obtain a copy of the License by
  7. * contacting Liferay, Inc. See the License for the specific language governing
  8. * permissions and limitations under the License, including but not limited to
  9. * distribution rights of the Software.
  10. *
  11. *
  12. *
  13. */
  14. package com.liferay.portal.workflow.metrics.rest.client.resource.v1_0;
  15. import com.liferay.portal.workflow.metrics.rest.client.dto.v1_0.SLA;
  16. import com.liferay.portal.workflow.metrics.rest.client.http.HttpInvoker;
  17. import com.liferay.portal.workflow.metrics.rest.client.pagination.Page;
  18. import com.liferay.portal.workflow.metrics.rest.client.pagination.Pagination;
  19. import com.liferay.portal.workflow.metrics.rest.client.problem.Problem;
  20. import com.liferay.portal.workflow.metrics.rest.client.serdes.v1_0.SLASerDes;
  21. import java.util.LinkedHashMap;
  22. import java.util.Locale;
  23. import java.util.Map;
  24. import java.util.logging.Level;
  25. import java.util.logging.Logger;
  26. import javax.annotation.Generated;
  27. /**
  28. * @author Rafael Praxedes
  29. * @generated
  30. */
  31. @Generated("")
  32. public interface SLAResource {
  33. public static Builder builder() {
  34. return new Builder();
  35. }
  36. public Page<SLA> getProcessSLAsPage(
  37. Long processId, Integer status, Pagination pagination)
  38. throws Exception;
  39. public HttpInvoker.HttpResponse getProcessSLAsPageHttpResponse(
  40. Long processId, Integer status, Pagination pagination)
  41. throws Exception;
  42. public SLA postProcessSLA(Long processId, SLA sla) throws Exception;
  43. public HttpInvoker.HttpResponse postProcessSLAHttpResponse(
  44. Long processId, SLA sla)
  45. throws Exception;
  46. public void postProcessSLABatch(
  47. Long processId, SLA sla, String callbackURL, Object object)
  48. throws Exception;
  49. public HttpInvoker.HttpResponse postProcessSLABatchHttpResponse(
  50. Long processId, SLA sla, String callbackURL, Object object)
  51. throws Exception;
  52. public void deleteSLA(Long slaId) throws Exception;
  53. public HttpInvoker.HttpResponse deleteSLAHttpResponse(Long slaId)
  54. throws Exception;
  55. public void deleteSLABatch(Long slaId, String callbackURL, Object object)
  56. throws Exception;
  57. public HttpInvoker.HttpResponse deleteSLABatchHttpResponse(
  58. Long slaId, String callbackURL, Object object)
  59. throws Exception;
  60. public SLA getSLA(Long slaId) throws Exception;
  61. public HttpInvoker.HttpResponse getSLAHttpResponse(Long slaId)
  62. throws Exception;
  63. public SLA putSLA(Long slaId, SLA sla) throws Exception;
  64. public HttpInvoker.HttpResponse putSLAHttpResponse(Long slaId, SLA sla)
  65. throws Exception;
  66. public void putSLABatch(
  67. Long slaId, SLA sla, String callbackURL, Object object)
  68. throws Exception;
  69. public HttpInvoker.HttpResponse putSLABatchHttpResponse(
  70. Long slaId, SLA sla, String callbackURL, Object object)
  71. throws Exception;
  72. public static class Builder {
  73. public Builder authentication(String login, String password) {
  74. _login = login;
  75. _password = password;
  76. return this;
  77. }
  78. public SLAResource build() {
  79. return new SLAResourceImpl(this);
  80. }
  81. public Builder endpoint(String host, int port, String scheme) {
  82. _host = host;
  83. _port = port;
  84. _scheme = scheme;
  85. return this;
  86. }
  87. public Builder header(String key, String value) {
  88. _headers.put(key, value);
  89. return this;
  90. }
  91. public Builder locale(Locale locale) {
  92. _locale = locale;
  93. return this;
  94. }
  95. public Builder parameter(String key, String value) {
  96. _parameters.put(key, value);
  97. return this;
  98. }
  99. public Builder parameters(String... parameters) {
  100. if ((parameters.length % 2) != 0) {
  101. throw new IllegalArgumentException(
  102. "Parameters length is not an even number");
  103. }
  104. for (int i = 0; i < parameters.length; i += 2) {
  105. String parameterName = String.valueOf(parameters[i]);
  106. String parameterValue = String.valueOf(parameters[i + 1]);
  107. _parameters.put(parameterName, parameterValue);
  108. }
  109. return this;
  110. }
  111. private Builder() {
  112. }
  113. private Map<String, String> _headers = new LinkedHashMap<>();
  114. private String _host = "localhost";
  115. private Locale _locale;
  116. private String _login = "";
  117. private String _password = "";
  118. private Map<String, String> _parameters = new LinkedHashMap<>();
  119. private int _port = 8080;
  120. private String _scheme = "http";
  121. }
  122. public static class SLAResourceImpl implements SLAResource {
  123. public Page<SLA> getProcessSLAsPage(
  124. Long processId, Integer status, Pagination pagination)
  125. throws Exception {
  126. HttpInvoker.HttpResponse httpResponse =
  127. getProcessSLAsPageHttpResponse(processId, status, pagination);
  128. String content = httpResponse.getContent();
  129. if ((httpResponse.getStatusCode() / 100) != 2) {
  130. _logger.log(
  131. Level.WARNING,
  132. "Unable to process HTTP response content: " + content);
  133. _logger.log(
  134. Level.WARNING,
  135. "HTTP response message: " + httpResponse.getMessage());
  136. _logger.log(
  137. Level.WARNING,
  138. "HTTP response status code: " +
  139. httpResponse.getStatusCode());
  140. throw new Problem.ProblemException(Problem.toDTO(content));
  141. }
  142. else {
  143. _logger.fine("HTTP response content: " + content);
  144. _logger.fine(
  145. "HTTP response message: " + httpResponse.getMessage());
  146. _logger.fine(
  147. "HTTP response status code: " +
  148. httpResponse.getStatusCode());
  149. }
  150. try {
  151. return Page.of(content, SLASerDes::toDTO);
  152. }
  153. catch (Exception e) {
  154. _logger.log(
  155. Level.WARNING,
  156. "Unable to process HTTP response: " + content, e);
  157. throw new Problem.ProblemException(Problem.toDTO(content));
  158. }
  159. }
  160. public HttpInvoker.HttpResponse getProcessSLAsPageHttpResponse(
  161. Long processId, Integer status, Pagination pagination)
  162. throws Exception {
  163. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  164. if (_builder._locale != null) {
  165. httpInvoker.header(
  166. "Accept-Language", _builder._locale.toLanguageTag());
  167. }
  168. for (Map.Entry<String, String> entry :
  169. _builder._headers.entrySet()) {
  170. httpInvoker.header(entry.getKey(), entry.getValue());
  171. }
  172. for (Map.Entry<String, String> entry :
  173. _builder._parameters.entrySet()) {
  174. httpInvoker.parameter(entry.getKey(), entry.getValue());
  175. }
  176. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  177. if (status != null) {
  178. httpInvoker.parameter("status", String.valueOf(status));
  179. }
  180. if (pagination != null) {
  181. httpInvoker.parameter(
  182. "page", String.valueOf(pagination.getPage()));
  183. httpInvoker.parameter(
  184. "pageSize", String.valueOf(pagination.getPageSize()));
  185. }
  186. httpInvoker.path(
  187. _builder._scheme + "://" + _builder._host + ":" +
  188. _builder._port +
  189. "/o/portal-workflow-metrics/v1.0/processes/{processId}/slas");
  190. httpInvoker.path("processId", processId);
  191. httpInvoker.userNameAndPassword(
  192. _builder._login + ":" + _builder._password);
  193. return httpInvoker.invoke();
  194. }
  195. public SLA postProcessSLA(Long processId, SLA sla) throws Exception {
  196. HttpInvoker.HttpResponse httpResponse = postProcessSLAHttpResponse(
  197. processId, sla);
  198. String content = httpResponse.getContent();
  199. if ((httpResponse.getStatusCode() / 100) != 2) {
  200. _logger.log(
  201. Level.WARNING,
  202. "Unable to process HTTP response content: " + content);
  203. _logger.log(
  204. Level.WARNING,
  205. "HTTP response message: " + httpResponse.getMessage());
  206. _logger.log(
  207. Level.WARNING,
  208. "HTTP response status code: " +
  209. httpResponse.getStatusCode());
  210. throw new Problem.ProblemException(Problem.toDTO(content));
  211. }
  212. else {
  213. _logger.fine("HTTP response content: " + content);
  214. _logger.fine(
  215. "HTTP response message: " + httpResponse.getMessage());
  216. _logger.fine(
  217. "HTTP response status code: " +
  218. httpResponse.getStatusCode());
  219. }
  220. try {
  221. return SLASerDes.toDTO(content);
  222. }
  223. catch (Exception e) {
  224. _logger.log(
  225. Level.WARNING,
  226. "Unable to process HTTP response: " + content, e);
  227. throw new Problem.ProblemException(Problem.toDTO(content));
  228. }
  229. }
  230. public HttpInvoker.HttpResponse postProcessSLAHttpResponse(
  231. Long processId, SLA sla)
  232. throws Exception {
  233. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  234. httpInvoker.body(sla.toString(), "application/json");
  235. if (_builder._locale != null) {
  236. httpInvoker.header(
  237. "Accept-Language", _builder._locale.toLanguageTag());
  238. }
  239. for (Map.Entry<String, String> entry :
  240. _builder._headers.entrySet()) {
  241. httpInvoker.header(entry.getKey(), entry.getValue());
  242. }
  243. for (Map.Entry<String, String> entry :
  244. _builder._parameters.entrySet()) {
  245. httpInvoker.parameter(entry.getKey(), entry.getValue());
  246. }
  247. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  248. httpInvoker.path(
  249. _builder._scheme + "://" + _builder._host + ":" +
  250. _builder._port +
  251. "/o/portal-workflow-metrics/v1.0/processes/{processId}/slas");
  252. httpInvoker.path("processId", processId);
  253. httpInvoker.userNameAndPassword(
  254. _builder._login + ":" + _builder._password);
  255. return httpInvoker.invoke();
  256. }
  257. public void postProcessSLABatch(
  258. Long processId, SLA sla, String callbackURL, Object object)
  259. throws Exception {
  260. HttpInvoker.HttpResponse httpResponse =
  261. postProcessSLABatchHttpResponse(
  262. processId, sla, callbackURL, object);
  263. String content = httpResponse.getContent();
  264. if ((httpResponse.getStatusCode() / 100) != 2) {
  265. _logger.log(
  266. Level.WARNING,
  267. "Unable to process HTTP response content: " + content);
  268. _logger.log(
  269. Level.WARNING,
  270. "HTTP response message: " + httpResponse.getMessage());
  271. _logger.log(
  272. Level.WARNING,
  273. "HTTP response status code: " +
  274. httpResponse.getStatusCode());
  275. throw new Problem.ProblemException(Problem.toDTO(content));
  276. }
  277. else {
  278. _logger.fine("HTTP response content: " + content);
  279. _logger.fine(
  280. "HTTP response message: " + httpResponse.getMessage());
  281. _logger.fine(
  282. "HTTP response status code: " +
  283. httpResponse.getStatusCode());
  284. }
  285. }
  286. public HttpInvoker.HttpResponse postProcessSLABatchHttpResponse(
  287. Long processId, SLA sla, String callbackURL, Object object)
  288. throws Exception {
  289. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  290. httpInvoker.body(object.toString(), "application/json");
  291. if (_builder._locale != null) {
  292. httpInvoker.header(
  293. "Accept-Language", _builder._locale.toLanguageTag());
  294. }
  295. for (Map.Entry<String, String> entry :
  296. _builder._headers.entrySet()) {
  297. httpInvoker.header(entry.getKey(), entry.getValue());
  298. }
  299. for (Map.Entry<String, String> entry :
  300. _builder._parameters.entrySet()) {
  301. httpInvoker.parameter(entry.getKey(), entry.getValue());
  302. }
  303. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  304. if (callbackURL != null) {
  305. httpInvoker.parameter(
  306. "callbackURL", String.valueOf(callbackURL));
  307. }
  308. httpInvoker.path(
  309. _builder._scheme + "://" + _builder._host + ":" +
  310. _builder._port +
  311. "/o/portal-workflow-metrics/v1.0/processes/{processId}/slas/batch");
  312. httpInvoker.path("processId", processId);
  313. httpInvoker.userNameAndPassword(
  314. _builder._login + ":" + _builder._password);
  315. return httpInvoker.invoke();
  316. }
  317. public void deleteSLA(Long slaId) throws Exception {
  318. HttpInvoker.HttpResponse httpResponse = deleteSLAHttpResponse(
  319. slaId);
  320. String content = httpResponse.getContent();
  321. if ((httpResponse.getStatusCode() / 100) != 2) {
  322. _logger.log(
  323. Level.WARNING,
  324. "Unable to process HTTP response content: " + content);
  325. _logger.log(
  326. Level.WARNING,
  327. "HTTP response message: " + httpResponse.getMessage());
  328. _logger.log(
  329. Level.WARNING,
  330. "HTTP response status code: " +
  331. httpResponse.getStatusCode());
  332. throw new Problem.ProblemException(Problem.toDTO(content));
  333. }
  334. else {
  335. _logger.fine("HTTP response content: " + content);
  336. _logger.fine(
  337. "HTTP response message: " + httpResponse.getMessage());
  338. _logger.fine(
  339. "HTTP response status code: " +
  340. httpResponse.getStatusCode());
  341. }
  342. try {
  343. return;
  344. }
  345. catch (Exception e) {
  346. _logger.log(
  347. Level.WARNING,
  348. "Unable to process HTTP response: " + content, e);
  349. throw new Problem.ProblemException(Problem.toDTO(content));
  350. }
  351. }
  352. public HttpInvoker.HttpResponse deleteSLAHttpResponse(Long slaId)
  353. throws Exception {
  354. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  355. if (_builder._locale != null) {
  356. httpInvoker.header(
  357. "Accept-Language", _builder._locale.toLanguageTag());
  358. }
  359. for (Map.Entry<String, String> entry :
  360. _builder._headers.entrySet()) {
  361. httpInvoker.header(entry.getKey(), entry.getValue());
  362. }
  363. for (Map.Entry<String, String> entry :
  364. _builder._parameters.entrySet()) {
  365. httpInvoker.parameter(entry.getKey(), entry.getValue());
  366. }
  367. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  368. httpInvoker.path(
  369. _builder._scheme + "://" + _builder._host + ":" +
  370. _builder._port +
  371. "/o/portal-workflow-metrics/v1.0/slas/{slaId}");
  372. httpInvoker.path("slaId", slaId);
  373. httpInvoker.userNameAndPassword(
  374. _builder._login + ":" + _builder._password);
  375. return httpInvoker.invoke();
  376. }
  377. public void deleteSLABatch(
  378. Long slaId, String callbackURL, Object object)
  379. throws Exception {
  380. HttpInvoker.HttpResponse httpResponse = deleteSLABatchHttpResponse(
  381. slaId, callbackURL, object);
  382. String content = httpResponse.getContent();
  383. if ((httpResponse.getStatusCode() / 100) != 2) {
  384. _logger.log(
  385. Level.WARNING,
  386. "Unable to process HTTP response content: " + content);
  387. _logger.log(
  388. Level.WARNING,
  389. "HTTP response message: " + httpResponse.getMessage());
  390. _logger.log(
  391. Level.WARNING,
  392. "HTTP response status code: " +
  393. httpResponse.getStatusCode());
  394. throw new Problem.ProblemException(Problem.toDTO(content));
  395. }
  396. else {
  397. _logger.fine("HTTP response content: " + content);
  398. _logger.fine(
  399. "HTTP response message: " + httpResponse.getMessage());
  400. _logger.fine(
  401. "HTTP response status code: " +
  402. httpResponse.getStatusCode());
  403. }
  404. }
  405. public HttpInvoker.HttpResponse deleteSLABatchHttpResponse(
  406. Long slaId, String callbackURL, Object object)
  407. throws Exception {
  408. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  409. httpInvoker.body(object.toString(), "application/json");
  410. if (_builder._locale != null) {
  411. httpInvoker.header(
  412. "Accept-Language", _builder._locale.toLanguageTag());
  413. }
  414. for (Map.Entry<String, String> entry :
  415. _builder._headers.entrySet()) {
  416. httpInvoker.header(entry.getKey(), entry.getValue());
  417. }
  418. for (Map.Entry<String, String> entry :
  419. _builder._parameters.entrySet()) {
  420. httpInvoker.parameter(entry.getKey(), entry.getValue());
  421. }
  422. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  423. if (callbackURL != null) {
  424. httpInvoker.parameter(
  425. "callbackURL", String.valueOf(callbackURL));
  426. }
  427. httpInvoker.path(
  428. _builder._scheme + "://" + _builder._host + ":" +
  429. _builder._port +
  430. "/o/portal-workflow-metrics/v1.0/slas/{slaId}/batch");
  431. httpInvoker.path("slaId", slaId);
  432. httpInvoker.userNameAndPassword(
  433. _builder._login + ":" + _builder._password);
  434. return httpInvoker.invoke();
  435. }
  436. public SLA getSLA(Long slaId) throws Exception {
  437. HttpInvoker.HttpResponse httpResponse = getSLAHttpResponse(slaId);
  438. String content = httpResponse.getContent();
  439. if ((httpResponse.getStatusCode() / 100) != 2) {
  440. _logger.log(
  441. Level.WARNING,
  442. "Unable to process HTTP response content: " + content);
  443. _logger.log(
  444. Level.WARNING,
  445. "HTTP response message: " + httpResponse.getMessage());
  446. _logger.log(
  447. Level.WARNING,
  448. "HTTP response status code: " +
  449. httpResponse.getStatusCode());
  450. throw new Problem.ProblemException(Problem.toDTO(content));
  451. }
  452. else {
  453. _logger.fine("HTTP response content: " + content);
  454. _logger.fine(
  455. "HTTP response message: " + httpResponse.getMessage());
  456. _logger.fine(
  457. "HTTP response status code: " +
  458. httpResponse.getStatusCode());
  459. }
  460. try {
  461. return SLASerDes.toDTO(content);
  462. }
  463. catch (Exception e) {
  464. _logger.log(
  465. Level.WARNING,
  466. "Unable to process HTTP response: " + content, e);
  467. throw new Problem.ProblemException(Problem.toDTO(content));
  468. }
  469. }
  470. public HttpInvoker.HttpResponse getSLAHttpResponse(Long slaId)
  471. throws Exception {
  472. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  473. if (_builder._locale != null) {
  474. httpInvoker.header(
  475. "Accept-Language", _builder._locale.toLanguageTag());
  476. }
  477. for (Map.Entry<String, String> entry :
  478. _builder._headers.entrySet()) {
  479. httpInvoker.header(entry.getKey(), entry.getValue());
  480. }
  481. for (Map.Entry<String, String> entry :
  482. _builder._parameters.entrySet()) {
  483. httpInvoker.parameter(entry.getKey(), entry.getValue());
  484. }
  485. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  486. httpInvoker.path(
  487. _builder._scheme + "://" + _builder._host + ":" +
  488. _builder._port +
  489. "/o/portal-workflow-metrics/v1.0/slas/{slaId}");
  490. httpInvoker.path("slaId", slaId);
  491. httpInvoker.userNameAndPassword(
  492. _builder._login + ":" + _builder._password);
  493. return httpInvoker.invoke();
  494. }
  495. public SLA putSLA(Long slaId, SLA sla) throws Exception {
  496. HttpInvoker.HttpResponse httpResponse = putSLAHttpResponse(
  497. slaId, sla);
  498. String content = httpResponse.getContent();
  499. if ((httpResponse.getStatusCode() / 100) != 2) {
  500. _logger.log(
  501. Level.WARNING,
  502. "Unable to process HTTP response content: " + content);
  503. _logger.log(
  504. Level.WARNING,
  505. "HTTP response message: " + httpResponse.getMessage());
  506. _logger.log(
  507. Level.WARNING,
  508. "HTTP response status code: " +
  509. httpResponse.getStatusCode());
  510. throw new Problem.ProblemException(Problem.toDTO(content));
  511. }
  512. else {
  513. _logger.fine("HTTP response content: " + content);
  514. _logger.fine(
  515. "HTTP response message: " + httpResponse.getMessage());
  516. _logger.fine(
  517. "HTTP response status code: " +
  518. httpResponse.getStatusCode());
  519. }
  520. try {
  521. return SLASerDes.toDTO(content);
  522. }
  523. catch (Exception e) {
  524. _logger.log(
  525. Level.WARNING,
  526. "Unable to process HTTP response: " + content, e);
  527. throw new Problem.ProblemException(Problem.toDTO(content));
  528. }
  529. }
  530. public HttpInvoker.HttpResponse putSLAHttpResponse(Long slaId, SLA sla)
  531. throws Exception {
  532. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  533. httpInvoker.body(sla.toString(), "application/json");
  534. if (_builder._locale != null) {
  535. httpInvoker.header(
  536. "Accept-Language", _builder._locale.toLanguageTag());
  537. }
  538. for (Map.Entry<String, String> entry :
  539. _builder._headers.entrySet()) {
  540. httpInvoker.header(entry.getKey(), entry.getValue());
  541. }
  542. for (Map.Entry<String, String> entry :
  543. _builder._parameters.entrySet()) {
  544. httpInvoker.parameter(entry.getKey(), entry.getValue());
  545. }
  546. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  547. httpInvoker.path(
  548. _builder._scheme + "://" + _builder._host + ":" +
  549. _builder._port +
  550. "/o/portal-workflow-metrics/v1.0/slas/{slaId}");
  551. httpInvoker.path("slaId", slaId);
  552. httpInvoker.userNameAndPassword(
  553. _builder._login + ":" + _builder._password);
  554. return httpInvoker.invoke();
  555. }
  556. public void putSLABatch(
  557. Long slaId, SLA sla, String callbackURL, Object object)
  558. throws Exception {
  559. HttpInvoker.HttpResponse httpResponse = putSLABatchHttpResponse(
  560. slaId, sla, callbackURL, object);
  561. String content = httpResponse.getContent();
  562. if ((httpResponse.getStatusCode() / 100) != 2) {
  563. _logger.log(
  564. Level.WARNING,
  565. "Unable to process HTTP response content: " + content);
  566. _logger.log(
  567. Level.WARNING,
  568. "HTTP response message: " + httpResponse.getMessage());
  569. _logger.log(
  570. Level.WARNING,
  571. "HTTP response status code: " +
  572. httpResponse.getStatusCode());
  573. throw new Problem.ProblemException(Problem.toDTO(content));
  574. }
  575. else {
  576. _logger.fine("HTTP response content: " + content);
  577. _logger.fine(
  578. "HTTP response message: " + httpResponse.getMessage());
  579. _logger.fine(
  580. "HTTP response status code: " +
  581. httpResponse.getStatusCode());
  582. }
  583. }
  584. public HttpInvoker.HttpResponse putSLABatchHttpResponse(
  585. Long slaId, SLA sla, String callbackURL, Object object)
  586. throws Exception {
  587. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  588. httpInvoker.body(object.toString(), "application/json");
  589. if (_builder._locale != null) {
  590. httpInvoker.header(
  591. "Accept-Language", _builder._locale.toLanguageTag());
  592. }
  593. for (Map.Entry<String, String> entry :
  594. _builder._headers.entrySet()) {
  595. httpInvoker.header(entry.getKey(), entry.getValue());
  596. }
  597. for (Map.Entry<String, String> entry :
  598. _builder._parameters.entrySet()) {
  599. httpInvoker.parameter(entry.getKey(), entry.getValue());
  600. }
  601. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  602. if (callbackURL != null) {
  603. httpInvoker.parameter(
  604. "callbackURL", String.valueOf(callbackURL));
  605. }
  606. httpInvoker.path(
  607. _builder._scheme + "://" + _builder._host + ":" +
  608. _builder._port +
  609. "/o/portal-workflow-metrics/v1.0/slas/{slaId}/batch");
  610. httpInvoker.path("slaId", slaId);
  611. httpInvoker.userNameAndPassword(
  612. _builder._login + ":" + _builder._password);
  613. return httpInvoker.invoke();
  614. }
  615. private SLAResourceImpl(Builder builder) {
  616. _builder = builder;
  617. }
  618. private static final Logger _logger = Logger.getLogger(
  619. SLAResource.class.getName());
  620. private Builder _builder;
  621. }
  622. }