/modules/apps/headless/headless-delivery/headless-delivery-client/src/main/java/com/liferay/headless/delivery/client/resource/v1_0/CommentResource.java

https://github.com/danielreuther/liferay-portal · Java · 1684 lines · 1287 code · 380 blank · 17 comment · 140 complexity · b7165542662b37c4726f438ab6ee05f2 MD5 · raw file

  1. /**
  2. * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under
  5. * the terms of the GNU Lesser General Public License as published by the Free
  6. * Software Foundation; either version 2.1 of the License, or (at your option)
  7. * any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  11. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  12. * details.
  13. */
  14. package com.liferay.headless.delivery.client.resource.v1_0;
  15. import com.liferay.headless.delivery.client.dto.v1_0.Comment;
  16. import com.liferay.headless.delivery.client.http.HttpInvoker;
  17. import com.liferay.headless.delivery.client.pagination.Page;
  18. import com.liferay.headless.delivery.client.pagination.Pagination;
  19. import com.liferay.headless.delivery.client.problem.Problem;
  20. import com.liferay.headless.delivery.client.serdes.v1_0.CommentSerDes;
  21. import java.util.LinkedHashMap;
  22. import java.util.List;
  23. import java.util.Locale;
  24. import java.util.Map;
  25. import java.util.logging.Level;
  26. import java.util.logging.Logger;
  27. import javax.annotation.Generated;
  28. /**
  29. * @author Javier Gamarra
  30. * @generated
  31. */
  32. @Generated("")
  33. public interface CommentResource {
  34. public static Builder builder() {
  35. return new Builder();
  36. }
  37. public Page<Comment> getBlogPostingCommentsPage(
  38. Long blogPostingId, String search, List<String> aggregations,
  39. String filterString, Pagination pagination, String sortString)
  40. throws Exception;
  41. public HttpInvoker.HttpResponse getBlogPostingCommentsPageHttpResponse(
  42. Long blogPostingId, String search, List<String> aggregations,
  43. String filterString, Pagination pagination, String sortString)
  44. throws Exception;
  45. public Comment postBlogPostingComment(Long blogPostingId, Comment comment)
  46. throws Exception;
  47. public HttpInvoker.HttpResponse postBlogPostingCommentHttpResponse(
  48. Long blogPostingId, Comment comment)
  49. throws Exception;
  50. public void postBlogPostingCommentBatch(
  51. Long blogPostingId, String callbackURL, Object object)
  52. throws Exception;
  53. public HttpInvoker.HttpResponse postBlogPostingCommentBatchHttpResponse(
  54. Long blogPostingId, String callbackURL, Object object)
  55. throws Exception;
  56. public void deleteComment(Long commentId) throws Exception;
  57. public HttpInvoker.HttpResponse deleteCommentHttpResponse(Long commentId)
  58. throws Exception;
  59. public void deleteCommentBatch(String callbackURL, Object object)
  60. throws Exception;
  61. public HttpInvoker.HttpResponse deleteCommentBatchHttpResponse(
  62. String callbackURL, Object object)
  63. throws Exception;
  64. public Comment getComment(Long commentId) throws Exception;
  65. public HttpInvoker.HttpResponse getCommentHttpResponse(Long commentId)
  66. throws Exception;
  67. public Comment putComment(Long commentId, Comment comment) throws Exception;
  68. public HttpInvoker.HttpResponse putCommentHttpResponse(
  69. Long commentId, Comment comment)
  70. throws Exception;
  71. public void putCommentBatch(String callbackURL, Object object)
  72. throws Exception;
  73. public HttpInvoker.HttpResponse putCommentBatchHttpResponse(
  74. String callbackURL, Object object)
  75. throws Exception;
  76. public Page<Comment> getCommentCommentsPage(
  77. Long parentCommentId, String search, List<String> aggregations,
  78. String filterString, Pagination pagination, String sortString)
  79. throws Exception;
  80. public HttpInvoker.HttpResponse getCommentCommentsPageHttpResponse(
  81. Long parentCommentId, String search, List<String> aggregations,
  82. String filterString, Pagination pagination, String sortString)
  83. throws Exception;
  84. public Comment postCommentComment(Long parentCommentId, Comment comment)
  85. throws Exception;
  86. public HttpInvoker.HttpResponse postCommentCommentHttpResponse(
  87. Long parentCommentId, Comment comment)
  88. throws Exception;
  89. public Page<Comment> getDocumentCommentsPage(
  90. Long documentId, String search, List<String> aggregations,
  91. String filterString, Pagination pagination, String sortString)
  92. throws Exception;
  93. public HttpInvoker.HttpResponse getDocumentCommentsPageHttpResponse(
  94. Long documentId, String search, List<String> aggregations,
  95. String filterString, Pagination pagination, String sortString)
  96. throws Exception;
  97. public Comment postDocumentComment(Long documentId, Comment comment)
  98. throws Exception;
  99. public HttpInvoker.HttpResponse postDocumentCommentHttpResponse(
  100. Long documentId, Comment comment)
  101. throws Exception;
  102. public void postDocumentCommentBatch(
  103. Long documentId, String callbackURL, Object object)
  104. throws Exception;
  105. public HttpInvoker.HttpResponse postDocumentCommentBatchHttpResponse(
  106. Long documentId, String callbackURL, Object object)
  107. throws Exception;
  108. public void
  109. deleteSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCode(
  110. Long siteId, String blogPostingExternalReferenceCode,
  111. String externalReferenceCode)
  112. throws Exception;
  113. public HttpInvoker.HttpResponse
  114. deleteSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  115. Long siteId, String blogPostingExternalReferenceCode,
  116. String externalReferenceCode)
  117. throws Exception;
  118. public Comment
  119. getSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCode(
  120. Long siteId, String blogPostingExternalReferenceCode,
  121. String externalReferenceCode)
  122. throws Exception;
  123. public HttpInvoker.HttpResponse
  124. getSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  125. Long siteId, String blogPostingExternalReferenceCode,
  126. String externalReferenceCode)
  127. throws Exception;
  128. public Comment
  129. putSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCode(
  130. Long siteId, String blogPostingExternalReferenceCode,
  131. String externalReferenceCode, Comment comment)
  132. throws Exception;
  133. public HttpInvoker.HttpResponse
  134. putSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  135. Long siteId, String blogPostingExternalReferenceCode,
  136. String externalReferenceCode, Comment comment)
  137. throws Exception;
  138. public void
  139. deleteSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCode(
  140. Long siteId, String parentCommentExternalReferenceCode,
  141. String externalReferenceCode)
  142. throws Exception;
  143. public HttpInvoker.HttpResponse
  144. deleteSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  145. Long siteId, String parentCommentExternalReferenceCode,
  146. String externalReferenceCode)
  147. throws Exception;
  148. public Comment
  149. getSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCode(
  150. Long siteId, String parentCommentExternalReferenceCode,
  151. String externalReferenceCode)
  152. throws Exception;
  153. public HttpInvoker.HttpResponse
  154. getSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  155. Long siteId, String parentCommentExternalReferenceCode,
  156. String externalReferenceCode)
  157. throws Exception;
  158. public Comment
  159. putSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCode(
  160. Long siteId, String parentCommentExternalReferenceCode,
  161. String externalReferenceCode, Comment comment)
  162. throws Exception;
  163. public HttpInvoker.HttpResponse
  164. putSiteCommentByExternalReferenceCodeParentCommentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  165. Long siteId, String parentCommentExternalReferenceCode,
  166. String externalReferenceCode, Comment comment)
  167. throws Exception;
  168. public void
  169. deleteSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCode(
  170. Long siteId, String documentExternalReferenceCode,
  171. String externalReferenceCode)
  172. throws Exception;
  173. public HttpInvoker.HttpResponse
  174. deleteSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  175. Long siteId, String documentExternalReferenceCode,
  176. String externalReferenceCode)
  177. throws Exception;
  178. public Comment
  179. getSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCode(
  180. Long siteId, String documentExternalReferenceCode,
  181. String externalReferenceCode)
  182. throws Exception;
  183. public HttpInvoker.HttpResponse
  184. getSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  185. Long siteId, String documentExternalReferenceCode,
  186. String externalReferenceCode)
  187. throws Exception;
  188. public Comment
  189. putSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCode(
  190. Long siteId, String documentExternalReferenceCode,
  191. String externalReferenceCode, Comment comment)
  192. throws Exception;
  193. public HttpInvoker.HttpResponse
  194. putSiteDocumentByExternalReferenceCodeDocumentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  195. Long siteId, String documentExternalReferenceCode,
  196. String externalReferenceCode, Comment comment)
  197. throws Exception;
  198. public void
  199. deleteSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCode(
  200. Long siteId, String structuredContentExternalReferenceCode,
  201. String externalReferenceCode)
  202. throws Exception;
  203. public HttpInvoker.HttpResponse
  204. deleteSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  205. Long siteId, String structuredContentExternalReferenceCode,
  206. String externalReferenceCode)
  207. throws Exception;
  208. public Comment
  209. getSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCode(
  210. Long siteId, String structuredContentExternalReferenceCode,
  211. String externalReferenceCode)
  212. throws Exception;
  213. public HttpInvoker.HttpResponse
  214. getSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  215. Long siteId, String structuredContentExternalReferenceCode,
  216. String externalReferenceCode)
  217. throws Exception;
  218. public Comment
  219. putSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCode(
  220. Long siteId, String structuredContentExternalReferenceCode,
  221. String externalReferenceCode, Comment comment)
  222. throws Exception;
  223. public HttpInvoker.HttpResponse
  224. putSiteStructuredContentByExternalReferenceCodeStructuredContentExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  225. Long siteId, String structuredContentExternalReferenceCode,
  226. String externalReferenceCode, Comment comment)
  227. throws Exception;
  228. public Page<Comment> getStructuredContentCommentsPage(
  229. Long structuredContentId, String search, List<String> aggregations,
  230. String filterString, Pagination pagination, String sortString)
  231. throws Exception;
  232. public HttpInvoker.HttpResponse
  233. getStructuredContentCommentsPageHttpResponse(
  234. Long structuredContentId, String search,
  235. List<String> aggregations, String filterString,
  236. Pagination pagination, String sortString)
  237. throws Exception;
  238. public Comment postStructuredContentComment(
  239. Long structuredContentId, Comment comment)
  240. throws Exception;
  241. public HttpInvoker.HttpResponse postStructuredContentCommentHttpResponse(
  242. Long structuredContentId, Comment comment)
  243. throws Exception;
  244. public void postStructuredContentCommentBatch(
  245. Long structuredContentId, String callbackURL, Object object)
  246. throws Exception;
  247. public HttpInvoker.HttpResponse
  248. postStructuredContentCommentBatchHttpResponse(
  249. Long structuredContentId, String callbackURL, Object object)
  250. throws Exception;
  251. public static class Builder {
  252. public Builder authentication(String login, String password) {
  253. _login = login;
  254. _password = password;
  255. return this;
  256. }
  257. public CommentResource build() {
  258. return new CommentResourceImpl(this);
  259. }
  260. public Builder contextPath(String contextPath) {
  261. _contextPath = contextPath;
  262. return this;
  263. }
  264. public Builder endpoint(String host, int port, String scheme) {
  265. _host = host;
  266. _port = port;
  267. _scheme = scheme;
  268. return this;
  269. }
  270. public Builder header(String key, String value) {
  271. _headers.put(key, value);
  272. return this;
  273. }
  274. public Builder locale(Locale locale) {
  275. _locale = locale;
  276. return this;
  277. }
  278. public Builder parameter(String key, String value) {
  279. _parameters.put(key, value);
  280. return this;
  281. }
  282. public Builder parameters(String... parameters) {
  283. if ((parameters.length % 2) != 0) {
  284. throw new IllegalArgumentException(
  285. "Parameters length is not an even number");
  286. }
  287. for (int i = 0; i < parameters.length; i += 2) {
  288. String parameterName = String.valueOf(parameters[i]);
  289. String parameterValue = String.valueOf(parameters[i + 1]);
  290. _parameters.put(parameterName, parameterValue);
  291. }
  292. return this;
  293. }
  294. private Builder() {
  295. }
  296. private String _contextPath = "";
  297. private Map<String, String> _headers = new LinkedHashMap<>();
  298. private String _host = "localhost";
  299. private Locale _locale;
  300. private String _login = "";
  301. private String _password = "";
  302. private Map<String, String> _parameters = new LinkedHashMap<>();
  303. private int _port = 8080;
  304. private String _scheme = "http";
  305. }
  306. public static class CommentResourceImpl implements CommentResource {
  307. public Page<Comment> getBlogPostingCommentsPage(
  308. Long blogPostingId, String search, List<String> aggregations,
  309. String filterString, Pagination pagination, String sortString)
  310. throws Exception {
  311. HttpInvoker.HttpResponse httpResponse =
  312. getBlogPostingCommentsPageHttpResponse(
  313. blogPostingId, search, aggregations, filterString,
  314. pagination, sortString);
  315. String content = httpResponse.getContent();
  316. if ((httpResponse.getStatusCode() / 100) != 2) {
  317. _logger.log(
  318. Level.WARNING,
  319. "Unable to process HTTP response content: " + content);
  320. _logger.log(
  321. Level.WARNING,
  322. "HTTP response message: " + httpResponse.getMessage());
  323. _logger.log(
  324. Level.WARNING,
  325. "HTTP response status code: " +
  326. httpResponse.getStatusCode());
  327. throw new Problem.ProblemException(Problem.toDTO(content));
  328. }
  329. else {
  330. _logger.fine("HTTP response content: " + content);
  331. _logger.fine(
  332. "HTTP response message: " + httpResponse.getMessage());
  333. _logger.fine(
  334. "HTTP response status code: " +
  335. httpResponse.getStatusCode());
  336. }
  337. try {
  338. return Page.of(content, CommentSerDes::toDTO);
  339. }
  340. catch (Exception e) {
  341. _logger.log(
  342. Level.WARNING,
  343. "Unable to process HTTP response: " + content, e);
  344. throw new Problem.ProblemException(Problem.toDTO(content));
  345. }
  346. }
  347. public HttpInvoker.HttpResponse getBlogPostingCommentsPageHttpResponse(
  348. Long blogPostingId, String search, List<String> aggregations,
  349. String filterString, Pagination pagination, String sortString)
  350. throws Exception {
  351. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  352. if (_builder._locale != null) {
  353. httpInvoker.header(
  354. "Accept-Language", _builder._locale.toLanguageTag());
  355. }
  356. for (Map.Entry<String, String> entry :
  357. _builder._headers.entrySet()) {
  358. httpInvoker.header(entry.getKey(), entry.getValue());
  359. }
  360. for (Map.Entry<String, String> entry :
  361. _builder._parameters.entrySet()) {
  362. httpInvoker.parameter(entry.getKey(), entry.getValue());
  363. }
  364. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  365. if (search != null) {
  366. httpInvoker.parameter("search", String.valueOf(search));
  367. }
  368. if (filterString != null) {
  369. httpInvoker.parameter("filter", filterString);
  370. }
  371. if (pagination != null) {
  372. httpInvoker.parameter(
  373. "page", String.valueOf(pagination.getPage()));
  374. httpInvoker.parameter(
  375. "pageSize", String.valueOf(pagination.getPageSize()));
  376. }
  377. if (sortString != null) {
  378. httpInvoker.parameter("sort", sortString);
  379. }
  380. httpInvoker.path(
  381. _builder._scheme + "://" + _builder._host + ":" +
  382. _builder._port + _builder._contextPath +
  383. "/o/headless-delivery/v1.0/blog-postings/{blogPostingId}/comments");
  384. httpInvoker.path("blogPostingId", blogPostingId);
  385. httpInvoker.userNameAndPassword(
  386. _builder._login + ":" + _builder._password);
  387. return httpInvoker.invoke();
  388. }
  389. public Comment postBlogPostingComment(
  390. Long blogPostingId, Comment comment)
  391. throws Exception {
  392. HttpInvoker.HttpResponse httpResponse =
  393. postBlogPostingCommentHttpResponse(blogPostingId, comment);
  394. String content = httpResponse.getContent();
  395. if ((httpResponse.getStatusCode() / 100) != 2) {
  396. _logger.log(
  397. Level.WARNING,
  398. "Unable to process HTTP response content: " + content);
  399. _logger.log(
  400. Level.WARNING,
  401. "HTTP response message: " + httpResponse.getMessage());
  402. _logger.log(
  403. Level.WARNING,
  404. "HTTP response status code: " +
  405. httpResponse.getStatusCode());
  406. throw new Problem.ProblemException(Problem.toDTO(content));
  407. }
  408. else {
  409. _logger.fine("HTTP response content: " + content);
  410. _logger.fine(
  411. "HTTP response message: " + httpResponse.getMessage());
  412. _logger.fine(
  413. "HTTP response status code: " +
  414. httpResponse.getStatusCode());
  415. }
  416. try {
  417. return CommentSerDes.toDTO(content);
  418. }
  419. catch (Exception e) {
  420. _logger.log(
  421. Level.WARNING,
  422. "Unable to process HTTP response: " + content, e);
  423. throw new Problem.ProblemException(Problem.toDTO(content));
  424. }
  425. }
  426. public HttpInvoker.HttpResponse postBlogPostingCommentHttpResponse(
  427. Long blogPostingId, Comment comment)
  428. throws Exception {
  429. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  430. httpInvoker.body(comment.toString(), "application/json");
  431. if (_builder._locale != null) {
  432. httpInvoker.header(
  433. "Accept-Language", _builder._locale.toLanguageTag());
  434. }
  435. for (Map.Entry<String, String> entry :
  436. _builder._headers.entrySet()) {
  437. httpInvoker.header(entry.getKey(), entry.getValue());
  438. }
  439. for (Map.Entry<String, String> entry :
  440. _builder._parameters.entrySet()) {
  441. httpInvoker.parameter(entry.getKey(), entry.getValue());
  442. }
  443. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  444. httpInvoker.path(
  445. _builder._scheme + "://" + _builder._host + ":" +
  446. _builder._port + _builder._contextPath +
  447. "/o/headless-delivery/v1.0/blog-postings/{blogPostingId}/comments");
  448. httpInvoker.path("blogPostingId", blogPostingId);
  449. httpInvoker.userNameAndPassword(
  450. _builder._login + ":" + _builder._password);
  451. return httpInvoker.invoke();
  452. }
  453. public void postBlogPostingCommentBatch(
  454. Long blogPostingId, String callbackURL, Object object)
  455. throws Exception {
  456. HttpInvoker.HttpResponse httpResponse =
  457. postBlogPostingCommentBatchHttpResponse(
  458. blogPostingId, callbackURL, object);
  459. String content = httpResponse.getContent();
  460. if ((httpResponse.getStatusCode() / 100) != 2) {
  461. _logger.log(
  462. Level.WARNING,
  463. "Unable to process HTTP response content: " + content);
  464. _logger.log(
  465. Level.WARNING,
  466. "HTTP response message: " + httpResponse.getMessage());
  467. _logger.log(
  468. Level.WARNING,
  469. "HTTP response status code: " +
  470. httpResponse.getStatusCode());
  471. throw new Problem.ProblemException(Problem.toDTO(content));
  472. }
  473. else {
  474. _logger.fine("HTTP response content: " + content);
  475. _logger.fine(
  476. "HTTP response message: " + httpResponse.getMessage());
  477. _logger.fine(
  478. "HTTP response status code: " +
  479. httpResponse.getStatusCode());
  480. }
  481. }
  482. public HttpInvoker.HttpResponse postBlogPostingCommentBatchHttpResponse(
  483. Long blogPostingId, String callbackURL, Object object)
  484. throws Exception {
  485. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  486. httpInvoker.body(object.toString(), "application/json");
  487. if (_builder._locale != null) {
  488. httpInvoker.header(
  489. "Accept-Language", _builder._locale.toLanguageTag());
  490. }
  491. for (Map.Entry<String, String> entry :
  492. _builder._headers.entrySet()) {
  493. httpInvoker.header(entry.getKey(), entry.getValue());
  494. }
  495. for (Map.Entry<String, String> entry :
  496. _builder._parameters.entrySet()) {
  497. httpInvoker.parameter(entry.getKey(), entry.getValue());
  498. }
  499. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  500. if (callbackURL != null) {
  501. httpInvoker.parameter(
  502. "callbackURL", String.valueOf(callbackURL));
  503. }
  504. httpInvoker.path(
  505. _builder._scheme + "://" + _builder._host + ":" +
  506. _builder._port + _builder._contextPath +
  507. "/o/headless-delivery/v1.0/blog-postings/{blogPostingId}/comments/batch");
  508. httpInvoker.path("blogPostingId", blogPostingId);
  509. httpInvoker.userNameAndPassword(
  510. _builder._login + ":" + _builder._password);
  511. return httpInvoker.invoke();
  512. }
  513. public void deleteComment(Long commentId) throws Exception {
  514. HttpInvoker.HttpResponse httpResponse = deleteCommentHttpResponse(
  515. commentId);
  516. String content = httpResponse.getContent();
  517. if ((httpResponse.getStatusCode() / 100) != 2) {
  518. _logger.log(
  519. Level.WARNING,
  520. "Unable to process HTTP response content: " + content);
  521. _logger.log(
  522. Level.WARNING,
  523. "HTTP response message: " + httpResponse.getMessage());
  524. _logger.log(
  525. Level.WARNING,
  526. "HTTP response status code: " +
  527. httpResponse.getStatusCode());
  528. throw new Problem.ProblemException(Problem.toDTO(content));
  529. }
  530. else {
  531. _logger.fine("HTTP response content: " + content);
  532. _logger.fine(
  533. "HTTP response message: " + httpResponse.getMessage());
  534. _logger.fine(
  535. "HTTP response status code: " +
  536. httpResponse.getStatusCode());
  537. }
  538. try {
  539. return;
  540. }
  541. catch (Exception e) {
  542. _logger.log(
  543. Level.WARNING,
  544. "Unable to process HTTP response: " + content, e);
  545. throw new Problem.ProblemException(Problem.toDTO(content));
  546. }
  547. }
  548. public HttpInvoker.HttpResponse deleteCommentHttpResponse(
  549. Long commentId)
  550. throws Exception {
  551. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  552. if (_builder._locale != null) {
  553. httpInvoker.header(
  554. "Accept-Language", _builder._locale.toLanguageTag());
  555. }
  556. for (Map.Entry<String, String> entry :
  557. _builder._headers.entrySet()) {
  558. httpInvoker.header(entry.getKey(), entry.getValue());
  559. }
  560. for (Map.Entry<String, String> entry :
  561. _builder._parameters.entrySet()) {
  562. httpInvoker.parameter(entry.getKey(), entry.getValue());
  563. }
  564. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  565. httpInvoker.path(
  566. _builder._scheme + "://" + _builder._host + ":" +
  567. _builder._port + _builder._contextPath +
  568. "/o/headless-delivery/v1.0/comments/{commentId}");
  569. httpInvoker.path("commentId", commentId);
  570. httpInvoker.userNameAndPassword(
  571. _builder._login + ":" + _builder._password);
  572. return httpInvoker.invoke();
  573. }
  574. public void deleteCommentBatch(String callbackURL, Object object)
  575. throws Exception {
  576. HttpInvoker.HttpResponse httpResponse =
  577. deleteCommentBatchHttpResponse(callbackURL, object);
  578. String content = httpResponse.getContent();
  579. if ((httpResponse.getStatusCode() / 100) != 2) {
  580. _logger.log(
  581. Level.WARNING,
  582. "Unable to process HTTP response content: " + content);
  583. _logger.log(
  584. Level.WARNING,
  585. "HTTP response message: " + httpResponse.getMessage());
  586. _logger.log(
  587. Level.WARNING,
  588. "HTTP response status code: " +
  589. httpResponse.getStatusCode());
  590. throw new Problem.ProblemException(Problem.toDTO(content));
  591. }
  592. else {
  593. _logger.fine("HTTP response content: " + content);
  594. _logger.fine(
  595. "HTTP response message: " + httpResponse.getMessage());
  596. _logger.fine(
  597. "HTTP response status code: " +
  598. httpResponse.getStatusCode());
  599. }
  600. }
  601. public HttpInvoker.HttpResponse deleteCommentBatchHttpResponse(
  602. String callbackURL, Object object)
  603. throws Exception {
  604. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  605. httpInvoker.body(object.toString(), "application/json");
  606. if (_builder._locale != null) {
  607. httpInvoker.header(
  608. "Accept-Language", _builder._locale.toLanguageTag());
  609. }
  610. for (Map.Entry<String, String> entry :
  611. _builder._headers.entrySet()) {
  612. httpInvoker.header(entry.getKey(), entry.getValue());
  613. }
  614. for (Map.Entry<String, String> entry :
  615. _builder._parameters.entrySet()) {
  616. httpInvoker.parameter(entry.getKey(), entry.getValue());
  617. }
  618. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  619. if (callbackURL != null) {
  620. httpInvoker.parameter(
  621. "callbackURL", String.valueOf(callbackURL));
  622. }
  623. httpInvoker.path(
  624. _builder._scheme + "://" + _builder._host + ":" +
  625. _builder._port + _builder._contextPath +
  626. "/o/headless-delivery/v1.0/comments/batch");
  627. httpInvoker.userNameAndPassword(
  628. _builder._login + ":" + _builder._password);
  629. return httpInvoker.invoke();
  630. }
  631. public Comment getComment(Long commentId) throws Exception {
  632. HttpInvoker.HttpResponse httpResponse = getCommentHttpResponse(
  633. commentId);
  634. String content = httpResponse.getContent();
  635. if ((httpResponse.getStatusCode() / 100) != 2) {
  636. _logger.log(
  637. Level.WARNING,
  638. "Unable to process HTTP response content: " + content);
  639. _logger.log(
  640. Level.WARNING,
  641. "HTTP response message: " + httpResponse.getMessage());
  642. _logger.log(
  643. Level.WARNING,
  644. "HTTP response status code: " +
  645. httpResponse.getStatusCode());
  646. throw new Problem.ProblemException(Problem.toDTO(content));
  647. }
  648. else {
  649. _logger.fine("HTTP response content: " + content);
  650. _logger.fine(
  651. "HTTP response message: " + httpResponse.getMessage());
  652. _logger.fine(
  653. "HTTP response status code: " +
  654. httpResponse.getStatusCode());
  655. }
  656. try {
  657. return CommentSerDes.toDTO(content);
  658. }
  659. catch (Exception e) {
  660. _logger.log(
  661. Level.WARNING,
  662. "Unable to process HTTP response: " + content, e);
  663. throw new Problem.ProblemException(Problem.toDTO(content));
  664. }
  665. }
  666. public HttpInvoker.HttpResponse getCommentHttpResponse(Long commentId)
  667. throws Exception {
  668. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  669. if (_builder._locale != null) {
  670. httpInvoker.header(
  671. "Accept-Language", _builder._locale.toLanguageTag());
  672. }
  673. for (Map.Entry<String, String> entry :
  674. _builder._headers.entrySet()) {
  675. httpInvoker.header(entry.getKey(), entry.getValue());
  676. }
  677. for (Map.Entry<String, String> entry :
  678. _builder._parameters.entrySet()) {
  679. httpInvoker.parameter(entry.getKey(), entry.getValue());
  680. }
  681. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  682. httpInvoker.path(
  683. _builder._scheme + "://" + _builder._host + ":" +
  684. _builder._port + _builder._contextPath +
  685. "/o/headless-delivery/v1.0/comments/{commentId}");
  686. httpInvoker.path("commentId", commentId);
  687. httpInvoker.userNameAndPassword(
  688. _builder._login + ":" + _builder._password);
  689. return httpInvoker.invoke();
  690. }
  691. public Comment putComment(Long commentId, Comment comment)
  692. throws Exception {
  693. HttpInvoker.HttpResponse httpResponse = putCommentHttpResponse(
  694. commentId, comment);
  695. String content = httpResponse.getContent();
  696. if ((httpResponse.getStatusCode() / 100) != 2) {
  697. _logger.log(
  698. Level.WARNING,
  699. "Unable to process HTTP response content: " + content);
  700. _logger.log(
  701. Level.WARNING,
  702. "HTTP response message: " + httpResponse.getMessage());
  703. _logger.log(
  704. Level.WARNING,
  705. "HTTP response status code: " +
  706. httpResponse.getStatusCode());
  707. throw new Problem.ProblemException(Problem.toDTO(content));
  708. }
  709. else {
  710. _logger.fine("HTTP response content: " + content);
  711. _logger.fine(
  712. "HTTP response message: " + httpResponse.getMessage());
  713. _logger.fine(
  714. "HTTP response status code: " +
  715. httpResponse.getStatusCode());
  716. }
  717. try {
  718. return CommentSerDes.toDTO(content);
  719. }
  720. catch (Exception e) {
  721. _logger.log(
  722. Level.WARNING,
  723. "Unable to process HTTP response: " + content, e);
  724. throw new Problem.ProblemException(Problem.toDTO(content));
  725. }
  726. }
  727. public HttpInvoker.HttpResponse putCommentHttpResponse(
  728. Long commentId, Comment comment)
  729. throws Exception {
  730. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  731. httpInvoker.body(comment.toString(), "application/json");
  732. if (_builder._locale != null) {
  733. httpInvoker.header(
  734. "Accept-Language", _builder._locale.toLanguageTag());
  735. }
  736. for (Map.Entry<String, String> entry :
  737. _builder._headers.entrySet()) {
  738. httpInvoker.header(entry.getKey(), entry.getValue());
  739. }
  740. for (Map.Entry<String, String> entry :
  741. _builder._parameters.entrySet()) {
  742. httpInvoker.parameter(entry.getKey(), entry.getValue());
  743. }
  744. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  745. httpInvoker.path(
  746. _builder._scheme + "://" + _builder._host + ":" +
  747. _builder._port + _builder._contextPath +
  748. "/o/headless-delivery/v1.0/comments/{commentId}");
  749. httpInvoker.path("commentId", commentId);
  750. httpInvoker.userNameAndPassword(
  751. _builder._login + ":" + _builder._password);
  752. return httpInvoker.invoke();
  753. }
  754. public void putCommentBatch(String callbackURL, Object object)
  755. throws Exception {
  756. HttpInvoker.HttpResponse httpResponse = putCommentBatchHttpResponse(
  757. callbackURL, object);
  758. String content = httpResponse.getContent();
  759. if ((httpResponse.getStatusCode() / 100) != 2) {
  760. _logger.log(
  761. Level.WARNING,
  762. "Unable to process HTTP response content: " + content);
  763. _logger.log(
  764. Level.WARNING,
  765. "HTTP response message: " + httpResponse.getMessage());
  766. _logger.log(
  767. Level.WARNING,
  768. "HTTP response status code: " +
  769. httpResponse.getStatusCode());
  770. throw new Problem.ProblemException(Problem.toDTO(content));
  771. }
  772. else {
  773. _logger.fine("HTTP response content: " + content);
  774. _logger.fine(
  775. "HTTP response message: " + httpResponse.getMessage());
  776. _logger.fine(
  777. "HTTP response status code: " +
  778. httpResponse.getStatusCode());
  779. }
  780. }
  781. public HttpInvoker.HttpResponse putCommentBatchHttpResponse(
  782. String callbackURL, Object object)
  783. throws Exception {
  784. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  785. httpInvoker.body(object.toString(), "application/json");
  786. if (_builder._locale != null) {
  787. httpInvoker.header(
  788. "Accept-Language", _builder._locale.toLanguageTag());
  789. }
  790. for (Map.Entry<String, String> entry :
  791. _builder._headers.entrySet()) {
  792. httpInvoker.header(entry.getKey(), entry.getValue());
  793. }
  794. for (Map.Entry<String, String> entry :
  795. _builder._parameters.entrySet()) {
  796. httpInvoker.parameter(entry.getKey(), entry.getValue());
  797. }
  798. httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
  799. if (callbackURL != null) {
  800. httpInvoker.parameter(
  801. "callbackURL", String.valueOf(callbackURL));
  802. }
  803. httpInvoker.path(
  804. _builder._scheme + "://" + _builder._host + ":" +
  805. _builder._port + _builder._contextPath +
  806. "/o/headless-delivery/v1.0/comments/batch");
  807. httpInvoker.userNameAndPassword(
  808. _builder._login + ":" + _builder._password);
  809. return httpInvoker.invoke();
  810. }
  811. public Page<Comment> getCommentCommentsPage(
  812. Long parentCommentId, String search, List<String> aggregations,
  813. String filterString, Pagination pagination, String sortString)
  814. throws Exception {
  815. HttpInvoker.HttpResponse httpResponse =
  816. getCommentCommentsPageHttpResponse(
  817. parentCommentId, search, aggregations, filterString,
  818. pagination, sortString);
  819. String content = httpResponse.getContent();
  820. if ((httpResponse.getStatusCode() / 100) != 2) {
  821. _logger.log(
  822. Level.WARNING,
  823. "Unable to process HTTP response content: " + content);
  824. _logger.log(
  825. Level.WARNING,
  826. "HTTP response message: " + httpResponse.getMessage());
  827. _logger.log(
  828. Level.WARNING,
  829. "HTTP response status code: " +
  830. httpResponse.getStatusCode());
  831. throw new Problem.ProblemException(Problem.toDTO(content));
  832. }
  833. else {
  834. _logger.fine("HTTP response content: " + content);
  835. _logger.fine(
  836. "HTTP response message: " + httpResponse.getMessage());
  837. _logger.fine(
  838. "HTTP response status code: " +
  839. httpResponse.getStatusCode());
  840. }
  841. try {
  842. return Page.of(content, CommentSerDes::toDTO);
  843. }
  844. catch (Exception e) {
  845. _logger.log(
  846. Level.WARNING,
  847. "Unable to process HTTP response: " + content, e);
  848. throw new Problem.ProblemException(Problem.toDTO(content));
  849. }
  850. }
  851. public HttpInvoker.HttpResponse getCommentCommentsPageHttpResponse(
  852. Long parentCommentId, String search, List<String> aggregations,
  853. String filterString, Pagination pagination, String sortString)
  854. throws Exception {
  855. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  856. if (_builder._locale != null) {
  857. httpInvoker.header(
  858. "Accept-Language", _builder._locale.toLanguageTag());
  859. }
  860. for (Map.Entry<String, String> entry :
  861. _builder._headers.entrySet()) {
  862. httpInvoker.header(entry.getKey(), entry.getValue());
  863. }
  864. for (Map.Entry<String, String> entry :
  865. _builder._parameters.entrySet()) {
  866. httpInvoker.parameter(entry.getKey(), entry.getValue());
  867. }
  868. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  869. if (search != null) {
  870. httpInvoker.parameter("search", String.valueOf(search));
  871. }
  872. if (filterString != null) {
  873. httpInvoker.parameter("filter", filterString);
  874. }
  875. if (pagination != null) {
  876. httpInvoker.parameter(
  877. "page", String.valueOf(pagination.getPage()));
  878. httpInvoker.parameter(
  879. "pageSize", String.valueOf(pagination.getPageSize()));
  880. }
  881. if (sortString != null) {
  882. httpInvoker.parameter("sort", sortString);
  883. }
  884. httpInvoker.path(
  885. _builder._scheme + "://" + _builder._host + ":" +
  886. _builder._port + _builder._contextPath +
  887. "/o/headless-delivery/v1.0/comments/{parentCommentId}/comments");
  888. httpInvoker.path("parentCommentId", parentCommentId);
  889. httpInvoker.userNameAndPassword(
  890. _builder._login + ":" + _builder._password);
  891. return httpInvoker.invoke();
  892. }
  893. public Comment postCommentComment(Long parentCommentId, Comment comment)
  894. throws Exception {
  895. HttpInvoker.HttpResponse httpResponse =
  896. postCommentCommentHttpResponse(parentCommentId, comment);
  897. String content = httpResponse.getContent();
  898. if ((httpResponse.getStatusCode() / 100) != 2) {
  899. _logger.log(
  900. Level.WARNING,
  901. "Unable to process HTTP response content: " + content);
  902. _logger.log(
  903. Level.WARNING,
  904. "HTTP response message: " + httpResponse.getMessage());
  905. _logger.log(
  906. Level.WARNING,
  907. "HTTP response status code: " +
  908. httpResponse.getStatusCode());
  909. throw new Problem.ProblemException(Problem.toDTO(content));
  910. }
  911. else {
  912. _logger.fine("HTTP response content: " + content);
  913. _logger.fine(
  914. "HTTP response message: " + httpResponse.getMessage());
  915. _logger.fine(
  916. "HTTP response status code: " +
  917. httpResponse.getStatusCode());
  918. }
  919. try {
  920. return CommentSerDes.toDTO(content);
  921. }
  922. catch (Exception e) {
  923. _logger.log(
  924. Level.WARNING,
  925. "Unable to process HTTP response: " + content, e);
  926. throw new Problem.ProblemException(Problem.toDTO(content));
  927. }
  928. }
  929. public HttpInvoker.HttpResponse postCommentCommentHttpResponse(
  930. Long parentCommentId, Comment comment)
  931. throws Exception {
  932. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  933. httpInvoker.body(comment.toString(), "application/json");
  934. if (_builder._locale != null) {
  935. httpInvoker.header(
  936. "Accept-Language", _builder._locale.toLanguageTag());
  937. }
  938. for (Map.Entry<String, String> entry :
  939. _builder._headers.entrySet()) {
  940. httpInvoker.header(entry.getKey(), entry.getValue());
  941. }
  942. for (Map.Entry<String, String> entry :
  943. _builder._parameters.entrySet()) {
  944. httpInvoker.parameter(entry.getKey(), entry.getValue());
  945. }
  946. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  947. httpInvoker.path(
  948. _builder._scheme + "://" + _builder._host + ":" +
  949. _builder._port + _builder._contextPath +
  950. "/o/headless-delivery/v1.0/comments/{parentCommentId}/comments");
  951. httpInvoker.path("parentCommentId", parentCommentId);
  952. httpInvoker.userNameAndPassword(
  953. _builder._login + ":" + _builder._password);
  954. return httpInvoker.invoke();
  955. }
  956. public Page<Comment> getDocumentCommentsPage(
  957. Long documentId, String search, List<String> aggregations,
  958. String filterString, Pagination pagination, String sortString)
  959. throws Exception {
  960. HttpInvoker.HttpResponse httpResponse =
  961. getDocumentCommentsPageHttpResponse(
  962. documentId, search, aggregations, filterString, pagination,
  963. sortString);
  964. String content = httpResponse.getContent();
  965. if ((httpResponse.getStatusCode() / 100) != 2) {
  966. _logger.log(
  967. Level.WARNING,
  968. "Unable to process HTTP response content: " + content);
  969. _logger.log(
  970. Level.WARNING,
  971. "HTTP response message: " + httpResponse.getMessage());
  972. _logger.log(
  973. Level.WARNING,
  974. "HTTP response status code: " +
  975. httpResponse.getStatusCode());
  976. throw new Problem.ProblemException(Problem.toDTO(content));
  977. }
  978. else {
  979. _logger.fine("HTTP response content: " + content);
  980. _logger.fine(
  981. "HTTP response message: " + httpResponse.getMessage());
  982. _logger.fine(
  983. "HTTP response status code: " +
  984. httpResponse.getStatusCode());
  985. }
  986. try {
  987. return Page.of(content, CommentSerDes::toDTO);
  988. }
  989. catch (Exception e) {
  990. _logger.log(
  991. Level.WARNING,
  992. "Unable to process HTTP response: " + content, e);
  993. throw new Problem.ProblemException(Problem.toDTO(content));
  994. }
  995. }
  996. public HttpInvoker.HttpResponse getDocumentCommentsPageHttpResponse(
  997. Long documentId, String search, List<String> aggregations,
  998. String filterString, Pagination pagination, String sortString)
  999. throws Exception {
  1000. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1001. if (_builder._locale != null) {
  1002. httpInvoker.header(
  1003. "Accept-Language", _builder._locale.toLanguageTag());
  1004. }
  1005. for (Map.Entry<String, String> entry :
  1006. _builder._headers.entrySet()) {
  1007. httpInvoker.header(entry.getKey(), entry.getValue());
  1008. }
  1009. for (Map.Entry<String, String> entry :
  1010. _builder._parameters.entrySet()) {
  1011. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1012. }
  1013. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  1014. if (search != null) {
  1015. httpInvoker.parameter("search", String.valueOf(search));
  1016. }
  1017. if (filterString != null) {
  1018. httpInvoker.parameter("filter", filterString);
  1019. }
  1020. if (pagination != null) {
  1021. httpInvoker.parameter(
  1022. "page", String.valueOf(pagination.getPage()));
  1023. httpInvoker.parameter(
  1024. "pageSize", String.valueOf(pagination.getPageSize()));
  1025. }
  1026. if (sortString != null) {
  1027. httpInvoker.parameter("sort", sortString);
  1028. }
  1029. httpInvoker.path(
  1030. _builder._scheme + "://" + _builder._host + ":" +
  1031. _builder._port + _builder._contextPath +
  1032. "/o/headless-delivery/v1.0/documents/{documentId}/comments");
  1033. httpInvoker.path("documentId", documentId);
  1034. httpInvoker.userNameAndPassword(
  1035. _builder._login + ":" + _builder._password);
  1036. return httpInvoker.invoke();
  1037. }
  1038. public Comment postDocumentComment(Long documentId, Comment comment)
  1039. throws Exception {
  1040. HttpInvoker.HttpResponse httpResponse =
  1041. postDocumentCommentHttpResponse(documentId, comment);
  1042. String content = httpResponse.getContent();
  1043. if ((httpResponse.getStatusCode() / 100) != 2) {
  1044. _logger.log(
  1045. Level.WARNING,
  1046. "Unable to process HTTP response content: " + content);
  1047. _logger.log(
  1048. Level.WARNING,
  1049. "HTTP response message: " + httpResponse.getMessage());
  1050. _logger.log(
  1051. Level.WARNING,
  1052. "HTTP response status code: " +
  1053. httpResponse.getStatusCode());
  1054. throw new Problem.ProblemException(Problem.toDTO(content));
  1055. }
  1056. else {
  1057. _logger.fine("HTTP response content: " + content);
  1058. _logger.fine(
  1059. "HTTP response message: " + httpResponse.getMessage());
  1060. _logger.fine(
  1061. "HTTP response status code: " +
  1062. httpResponse.getStatusCode());
  1063. }
  1064. try {
  1065. return CommentSerDes.toDTO(content);
  1066. }
  1067. catch (Exception e) {
  1068. _logger.log(
  1069. Level.WARNING,
  1070. "Unable to process HTTP response: " + content, e);
  1071. throw new Problem.ProblemException(Problem.toDTO(content));
  1072. }
  1073. }
  1074. public HttpInvoker.HttpResponse postDocumentCommentHttpResponse(
  1075. Long documentId, Comment comment)
  1076. throws Exception {
  1077. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1078. httpInvoker.body(comment.toString(), "application/json");
  1079. if (_builder._locale != null) {
  1080. httpInvoker.header(
  1081. "Accept-Language", _builder._locale.toLanguageTag());
  1082. }
  1083. for (Map.Entry<String, String> entry :
  1084. _builder._headers.entrySet()) {
  1085. httpInvoker.header(entry.getKey(), entry.getValue());
  1086. }
  1087. for (Map.Entry<String, String> entry :
  1088. _builder._parameters.entrySet()) {
  1089. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1090. }
  1091. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  1092. httpInvoker.path(
  1093. _builder._scheme + "://" + _builder._host + ":" +
  1094. _builder._port + _builder._contextPath +
  1095. "/o/headless-delivery/v1.0/documents/{documentId}/comments");
  1096. httpInvoker.path("documentId", documentId);
  1097. httpInvoker.userNameAndPassword(
  1098. _builder._login + ":" + _builder._password);
  1099. return httpInvoker.invoke();
  1100. }
  1101. public void postDocumentCommentBatch(
  1102. Long documentId, String callbackURL, Object object)
  1103. throws Exception {
  1104. HttpInvoker.HttpResponse httpResponse =
  1105. postDocumentCommentBatchHttpResponse(
  1106. documentId, callbackURL, object);
  1107. String content = httpResponse.getContent();
  1108. if ((httpResponse.getStatusCode() / 100) != 2) {
  1109. _logger.log(
  1110. Level.WARNING,
  1111. "Unable to process HTTP response content: " + content);
  1112. _logger.log(
  1113. Level.WARNING,
  1114. "HTTP response message: " + httpResponse.getMessage());
  1115. _logger.log(
  1116. Level.WARNING,
  1117. "HTTP response status code: " +
  1118. httpResponse.getStatusCode());
  1119. throw new Problem.ProblemException(Problem.toDTO(content));
  1120. }
  1121. else {
  1122. _logger.fine("HTTP response content: " + content);
  1123. _logger.fine(
  1124. "HTTP response message: " + httpResponse.getMessage());
  1125. _logger.fine(
  1126. "HTTP response status code: " +
  1127. httpResponse.getStatusCode());
  1128. }
  1129. }
  1130. public HttpInvoker.HttpResponse postDocumentCommentBatchHttpResponse(
  1131. Long documentId, String callbackURL, Object object)
  1132. throws Exception {
  1133. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1134. httpInvoker.body(object.toString(), "application/json");
  1135. if (_builder._locale != null) {
  1136. httpInvoker.header(
  1137. "Accept-Language", _builder._locale.toLanguageTag());
  1138. }
  1139. for (Map.Entry<String, String> entry :
  1140. _builder._headers.entrySet()) {
  1141. httpInvoker.header(entry.getKey(), entry.getValue());
  1142. }
  1143. for (Map.Entry<String, String> entry :
  1144. _builder._parameters.entrySet()) {
  1145. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1146. }
  1147. httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
  1148. if (callbackURL != null) {
  1149. httpInvoker.parameter(
  1150. "callbackURL", String.valueOf(callbackURL));
  1151. }
  1152. httpInvoker.path(
  1153. _builder._scheme + "://" + _builder._host + ":" +
  1154. _builder._port + _builder._contextPath +
  1155. "/o/headless-delivery/v1.0/documents/{documentId}/comments/batch");
  1156. httpInvoker.path("documentId", documentId);
  1157. httpInvoker.userNameAndPassword(
  1158. _builder._login + ":" + _builder._password);
  1159. return httpInvoker.invoke();
  1160. }
  1161. public void
  1162. deleteSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCode(
  1163. Long siteId, String blogPostingExternalReferenceCode,
  1164. String externalReferenceCode)
  1165. throws Exception {
  1166. HttpInvoker.HttpResponse httpResponse =
  1167. deleteSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  1168. siteId, blogPostingExternalReferenceCode,
  1169. externalReferenceCode);
  1170. String content = httpResponse.getContent();
  1171. if ((httpResponse.getStatusCode() / 100) != 2) {
  1172. _logger.log(
  1173. Level.WARNING,
  1174. "Unable to process HTTP response content: " + content);
  1175. _logger.log(
  1176. Level.WARNING,
  1177. "HTTP response message: " + httpResponse.getMessage());
  1178. _logger.log(
  1179. Level.WARNING,
  1180. "HTTP response status code: " +
  1181. httpResponse.getStatusCode());
  1182. throw new Problem.ProblemException(Problem.toDTO(content));
  1183. }
  1184. else {
  1185. _logger.fine("HTTP response content: " + content);
  1186. _logger.fine(
  1187. "HTTP response message: " + httpResponse.getMessage());
  1188. _logger.fine(
  1189. "HTTP response status code: " +
  1190. httpResponse.getStatusCode());
  1191. }
  1192. try {
  1193. return;
  1194. }
  1195. catch (Exception e) {
  1196. _logger.log(
  1197. Level.WARNING,
  1198. "Unable to process HTTP response: " + content, e);
  1199. throw new Problem.ProblemException(Problem.toDTO(content));
  1200. }
  1201. }
  1202. public HttpInvoker.HttpResponse
  1203. deleteSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  1204. Long siteId, String blogPostingExternalReferenceCode,
  1205. String externalReferenceCode)
  1206. throws Exception {
  1207. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1208. if (_builder._locale != null) {
  1209. httpInvoker.header(
  1210. "Accept-Language", _builder._locale.toLanguageTag());
  1211. }
  1212. for (Map.Entry<String, String> entry :
  1213. _builder._headers.entrySet()) {
  1214. httpInvoker.header(entry.getKey(), entry.getValue());
  1215. }
  1216. for (Map.Entry<String, String> entry :
  1217. _builder._parameters.entrySet()) {
  1218. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1219. }
  1220. httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
  1221. httpInvoker.path(
  1222. _builder._scheme + "://" + _builder._host + ":" +
  1223. _builder._port + _builder._contextPath +
  1224. "/o/headless-delivery/v1.0/sites/{siteId}/blog-postings/by-external-reference-code/{blogPostingExternalReferenceCode}/comments/by-external-reference-code/{externalReferenceCode}");
  1225. httpInvoker.path("siteId", siteId);
  1226. httpInvoker.path(
  1227. "blogPostingExternalReferenceCode",
  1228. blogPostingExternalReferenceCode);
  1229. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  1230. httpInvoker.userNameAndPassword(
  1231. _builder._login + ":" + _builder._password);
  1232. return httpInvoker.invoke();
  1233. }
  1234. public Comment
  1235. getSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCode(
  1236. Long siteId, String blogPostingExternalReferenceCode,
  1237. String externalReferenceCode)
  1238. throws Exception {
  1239. HttpInvoker.HttpResponse httpResponse =
  1240. getSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  1241. siteId, blogPostingExternalReferenceCode,
  1242. externalReferenceCode);
  1243. String content = httpResponse.getContent();
  1244. if ((httpResponse.getStatusCode() / 100) != 2) {
  1245. _logger.log(
  1246. Level.WARNING,
  1247. "Unable to process HTTP response content: " + content);
  1248. _logger.log(
  1249. Level.WARNING,
  1250. "HTTP response message: " + httpResponse.getMessage());
  1251. _logger.log(
  1252. Level.WARNING,
  1253. "HTTP response status code: " +
  1254. httpResponse.getStatusCode());
  1255. throw new Problem.ProblemException(Problem.toDTO(content));
  1256. }
  1257. else {
  1258. _logger.fine("HTTP response content: " + content);
  1259. _logger.fine(
  1260. "HTTP response message: " + httpResponse.getMessage());
  1261. _logger.fine(
  1262. "HTTP response status code: " +
  1263. httpResponse.getStatusCode());
  1264. }
  1265. try {
  1266. return CommentSerDes.toDTO(content);
  1267. }
  1268. catch (Exception e) {
  1269. _logger.log(
  1270. Level.WARNING,
  1271. "Unable to process HTTP response: " + content, e);
  1272. throw new Problem.ProblemException(Problem.toDTO(content));
  1273. }
  1274. }
  1275. public HttpInvoker.HttpResponse
  1276. getSiteBlogPostingByExternalReferenceCodeBlogPostingExternalReferenceCodeCommentByExternalReferenceCodeHttpResponse(
  1277. Long siteId, String blogPostingExternalReferenceCode,
  1278. String externalReferenceCode)
  1279. throws Exception {
  1280. HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
  1281. if (_builder._locale != null) {
  1282. httpInvoker.header(
  1283. "Accept-Language", _builder._locale.toLanguageTag());
  1284. }
  1285. for (Map.Entry<String, String> entry :
  1286. _builder._headers.entrySet()) {
  1287. httpInvoker.header(entry.getKey(), entry.getValue());
  1288. }
  1289. for (Map.Entry<String, String> entry :
  1290. _builder._parameters.entrySet()) {
  1291. httpInvoker.parameter(entry.getKey(), entry.getValue());
  1292. }
  1293. httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
  1294. httpInvoker.path(
  1295. _builder._scheme + "://" + _builder._host + ":" +
  1296. _builder._port + _builder._contextPath +
  1297. "/o/headless-delivery/v1.0/sites/{siteId}/blog-postings/by-external-reference-code/{blogPostingExternalReferenceCode}/comments/by-external-reference-code/{externalReferenceCode}");
  1298. httpInvoker.path("siteId", siteId);
  1299. httpInvoker.path(
  1300. "blogPostingExternalReferenceCode",
  1301. blogPostingExternalReferenceCode);
  1302. httpInvoker.path("externalReferenceCode", externalReferenceCode);
  1303. httpInvoker.userNameAndPassword(
  1304. _builder._login + ":" + _builder._pass