/modules/apps/commerce/headless/headless-commerce/headless-commerce-admin-inventory-client/src/main/java/com/liferay/headless/commerce/admin/inventory/client/resource/v1_0/WarehouseResource.java

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