/modules/apps/object/object-admin-rest-client/src/main/java/com/liferay/object/admin/rest/client/resource/v1_0/ObjectValidationRuleResource.java
https://github.com/danielreuther/liferay-portal · Java · 973 lines · 731 code · 225 blank · 17 comment · 76 complexity · 1ab7812a840d854e466e6f169a495c15 MD5 · raw file
- /**
- * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by the Free
- * Software Foundation; either version 2.1 of the License, or (at your option)
- * any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- * details.
- */
- package com.liferay.object.admin.rest.client.resource.v1_0;
- import com.liferay.object.admin.rest.client.dto.v1_0.ObjectValidationRule;
- import com.liferay.object.admin.rest.client.http.HttpInvoker;
- import com.liferay.object.admin.rest.client.pagination.Page;
- import com.liferay.object.admin.rest.client.pagination.Pagination;
- import com.liferay.object.admin.rest.client.problem.Problem;
- import com.liferay.object.admin.rest.client.serdes.v1_0.ObjectValidationRuleSerDes;
- import java.util.LinkedHashMap;
- import java.util.Locale;
- import java.util.Map;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import javax.annotation.Generated;
- /**
- * @author Javier Gamarra
- * @generated
- */
- @Generated("")
- public interface ObjectValidationRuleResource {
- public static Builder builder() {
- return new Builder();
- }
- public Page<ObjectValidationRule>
- getObjectDefinitionObjectValidationRulesPage(
- Long objectDefinitionId, String search, Pagination pagination)
- throws Exception;
- public HttpInvoker.HttpResponse
- getObjectDefinitionObjectValidationRulesPageHttpResponse(
- Long objectDefinitionId, String search, Pagination pagination)
- throws Exception;
- public ObjectValidationRule postObjectDefinitionObjectValidationRule(
- Long objectDefinitionId, ObjectValidationRule objectValidationRule)
- throws Exception;
- public HttpInvoker.HttpResponse
- postObjectDefinitionObjectValidationRuleHttpResponse(
- Long objectDefinitionId,
- ObjectValidationRule objectValidationRule)
- throws Exception;
- public void postObjectDefinitionObjectValidationRuleBatch(
- Long objectDefinitionId, String callbackURL, Object object)
- throws Exception;
- public HttpInvoker.HttpResponse
- postObjectDefinitionObjectValidationRuleBatchHttpResponse(
- Long objectDefinitionId, String callbackURL, Object object)
- throws Exception;
- public void deleteObjectValidationRule(Long objectValidationRuleId)
- throws Exception;
- public HttpInvoker.HttpResponse deleteObjectValidationRuleHttpResponse(
- Long objectValidationRuleId)
- throws Exception;
- public void deleteObjectValidationRuleBatch(
- String callbackURL, Object object)
- throws Exception;
- public HttpInvoker.HttpResponse deleteObjectValidationRuleBatchHttpResponse(
- String callbackURL, Object object)
- throws Exception;
- public ObjectValidationRule getObjectValidationRule(
- Long objectValidationRuleId)
- throws Exception;
- public HttpInvoker.HttpResponse getObjectValidationRuleHttpResponse(
- Long objectValidationRuleId)
- throws Exception;
- public ObjectValidationRule patchObjectValidationRule(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception;
- public HttpInvoker.HttpResponse patchObjectValidationRuleHttpResponse(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception;
- public ObjectValidationRule putObjectValidationRule(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception;
- public HttpInvoker.HttpResponse putObjectValidationRuleHttpResponse(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception;
- public void putObjectValidationRuleBatch(String callbackURL, Object object)
- throws Exception;
- public HttpInvoker.HttpResponse putObjectValidationRuleBatchHttpResponse(
- String callbackURL, Object object)
- throws Exception;
- public static class Builder {
- public Builder authentication(String login, String password) {
- _login = login;
- _password = password;
- return this;
- }
- public ObjectValidationRuleResource build() {
- return new ObjectValidationRuleResourceImpl(this);
- }
- public Builder contextPath(String contextPath) {
- _contextPath = contextPath;
- return this;
- }
- public Builder endpoint(String host, int port, String scheme) {
- _host = host;
- _port = port;
- _scheme = scheme;
- return this;
- }
- public Builder header(String key, String value) {
- _headers.put(key, value);
- return this;
- }
- public Builder locale(Locale locale) {
- _locale = locale;
- return this;
- }
- public Builder parameter(String key, String value) {
- _parameters.put(key, value);
- return this;
- }
- public Builder parameters(String... parameters) {
- if ((parameters.length % 2) != 0) {
- throw new IllegalArgumentException(
- "Parameters length is not an even number");
- }
- for (int i = 0; i < parameters.length; i += 2) {
- String parameterName = String.valueOf(parameters[i]);
- String parameterValue = String.valueOf(parameters[i + 1]);
- _parameters.put(parameterName, parameterValue);
- }
- return this;
- }
- private Builder() {
- }
- private String _contextPath = "";
- private Map<String, String> _headers = new LinkedHashMap<>();
- private String _host = "localhost";
- private Locale _locale;
- private String _login = "";
- private String _password = "";
- private Map<String, String> _parameters = new LinkedHashMap<>();
- private int _port = 8080;
- private String _scheme = "http";
- }
- public static class ObjectValidationRuleResourceImpl
- implements ObjectValidationRuleResource {
- public Page<ObjectValidationRule>
- getObjectDefinitionObjectValidationRulesPage(
- Long objectDefinitionId, String search,
- Pagination pagination)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- getObjectDefinitionObjectValidationRulesPageHttpResponse(
- objectDefinitionId, search, pagination);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return Page.of(content, ObjectValidationRuleSerDes::toDTO);
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse
- getObjectDefinitionObjectValidationRulesPageHttpResponse(
- Long objectDefinitionId, String search,
- Pagination pagination)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
- if (search != null) {
- httpInvoker.parameter("search", String.valueOf(search));
- }
- if (pagination != null) {
- httpInvoker.parameter(
- "page", String.valueOf(pagination.getPage()));
- httpInvoker.parameter(
- "pageSize", String.valueOf(pagination.getPageSize()));
- }
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-definitions/{objectDefinitionId}/object-validation-rules");
- httpInvoker.path("objectDefinitionId", objectDefinitionId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public ObjectValidationRule postObjectDefinitionObjectValidationRule(
- Long objectDefinitionId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- postObjectDefinitionObjectValidationRuleHttpResponse(
- objectDefinitionId, objectValidationRule);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return ObjectValidationRuleSerDes.toDTO(content);
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse
- postObjectDefinitionObjectValidationRuleHttpResponse(
- Long objectDefinitionId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(
- objectValidationRule.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-definitions/{objectDefinitionId}/object-validation-rules");
- httpInvoker.path("objectDefinitionId", objectDefinitionId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public void postObjectDefinitionObjectValidationRuleBatch(
- Long objectDefinitionId, String callbackURL, Object object)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- postObjectDefinitionObjectValidationRuleBatchHttpResponse(
- objectDefinitionId, callbackURL, object);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- }
- public HttpInvoker.HttpResponse
- postObjectDefinitionObjectValidationRuleBatchHttpResponse(
- Long objectDefinitionId, String callbackURL, Object object)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(object.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.POST);
- if (callbackURL != null) {
- httpInvoker.parameter(
- "callbackURL", String.valueOf(callbackURL));
- }
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-definitions/{objectDefinitionId}/object-validation-rules/batch");
- httpInvoker.path("objectDefinitionId", objectDefinitionId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public void deleteObjectValidationRule(Long objectValidationRuleId)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- deleteObjectValidationRuleHttpResponse(objectValidationRuleId);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return;
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse deleteObjectValidationRuleHttpResponse(
- Long objectValidationRuleId)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/{objectValidationRuleId}");
- httpInvoker.path("objectValidationRuleId", objectValidationRuleId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public void deleteObjectValidationRuleBatch(
- String callbackURL, Object object)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- deleteObjectValidationRuleBatchHttpResponse(
- callbackURL, object);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- }
- public HttpInvoker.HttpResponse
- deleteObjectValidationRuleBatchHttpResponse(
- String callbackURL, Object object)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(object.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.DELETE);
- if (callbackURL != null) {
- httpInvoker.parameter(
- "callbackURL", String.valueOf(callbackURL));
- }
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/batch");
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public ObjectValidationRule getObjectValidationRule(
- Long objectValidationRuleId)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- getObjectValidationRuleHttpResponse(objectValidationRuleId);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return ObjectValidationRuleSerDes.toDTO(content);
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse getObjectValidationRuleHttpResponse(
- Long objectValidationRuleId)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.GET);
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/{objectValidationRuleId}");
- httpInvoker.path("objectValidationRuleId", objectValidationRuleId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public ObjectValidationRule patchObjectValidationRule(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- patchObjectValidationRuleHttpResponse(
- objectValidationRuleId, objectValidationRule);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return ObjectValidationRuleSerDes.toDTO(content);
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse patchObjectValidationRuleHttpResponse(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(
- objectValidationRule.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.PATCH);
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/{objectValidationRuleId}");
- httpInvoker.path("objectValidationRuleId", objectValidationRuleId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public ObjectValidationRule putObjectValidationRule(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- putObjectValidationRuleHttpResponse(
- objectValidationRuleId, objectValidationRule);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- try {
- return ObjectValidationRuleSerDes.toDTO(content);
- }
- catch (Exception e) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response: " + content, e);
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- }
- public HttpInvoker.HttpResponse putObjectValidationRuleHttpResponse(
- Long objectValidationRuleId,
- ObjectValidationRule objectValidationRule)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(
- objectValidationRule.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/{objectValidationRuleId}");
- httpInvoker.path("objectValidationRuleId", objectValidationRuleId);
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- public void putObjectValidationRuleBatch(
- String callbackURL, Object object)
- throws Exception {
- HttpInvoker.HttpResponse httpResponse =
- putObjectValidationRuleBatchHttpResponse(callbackURL, object);
- String content = httpResponse.getContent();
- if ((httpResponse.getStatusCode() / 100) != 2) {
- _logger.log(
- Level.WARNING,
- "Unable to process HTTP response content: " + content);
- _logger.log(
- Level.WARNING,
- "HTTP response message: " + httpResponse.getMessage());
- _logger.log(
- Level.WARNING,
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- throw new Problem.ProblemException(Problem.toDTO(content));
- }
- else {
- _logger.fine("HTTP response content: " + content);
- _logger.fine(
- "HTTP response message: " + httpResponse.getMessage());
- _logger.fine(
- "HTTP response status code: " +
- httpResponse.getStatusCode());
- }
- }
- public HttpInvoker.HttpResponse
- putObjectValidationRuleBatchHttpResponse(
- String callbackURL, Object object)
- throws Exception {
- HttpInvoker httpInvoker = HttpInvoker.newHttpInvoker();
- httpInvoker.body(object.toString(), "application/json");
- if (_builder._locale != null) {
- httpInvoker.header(
- "Accept-Language", _builder._locale.toLanguageTag());
- }
- for (Map.Entry<String, String> entry :
- _builder._headers.entrySet()) {
- httpInvoker.header(entry.getKey(), entry.getValue());
- }
- for (Map.Entry<String, String> entry :
- _builder._parameters.entrySet()) {
- httpInvoker.parameter(entry.getKey(), entry.getValue());
- }
- httpInvoker.httpMethod(HttpInvoker.HttpMethod.PUT);
- if (callbackURL != null) {
- httpInvoker.parameter(
- "callbackURL", String.valueOf(callbackURL));
- }
- httpInvoker.path(
- _builder._scheme + "://" + _builder._host + ":" +
- _builder._port + _builder._contextPath +
- "/o/object-admin/v1.0/object-validation-rules/batch");
- httpInvoker.userNameAndPassword(
- _builder._login + ":" + _builder._password);
- return httpInvoker.invoke();
- }
- private ObjectValidationRuleResourceImpl(Builder builder) {
- _builder = builder;
- }
- private static final Logger _logger = Logger.getLogger(
- ObjectValidationRuleResource.class.getName());
- private Builder _builder;
- }
- }