@Bean public NotifyObjectMapper notifyObjectMapper() { return new NotifyObjectMapper(); }
public NotifyObjectMapper() { super(Arrays.asList(new TiogaJacksonModule(), new NotifyJacksonModule()), Collections.<TiogaJacksonInjectable>emptyList()); configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } }
@SuppressWarnings("unchecked") public QueryResult<Task> getTasks(TaskStatus taskStatus) throws IOException { Response response = client.target(apiPath + "/v2/admin/domains").path(domainName).path("tasks") .queryParam("taskStatus", taskStatus) .request(MediaType.APPLICATION_JSON_TYPE) .get(); HttpStatusCode statusCode = HttpStatusCode.findByCode(response.getStatus()); if (statusCode != HttpStatusCode.OK) { throw ApiException.fromCode(statusCode, "Get of tasks FAILED: " + response.getStatusInfo()); } String json = response.readEntity(String.class); NotifyObjectMapper objectMapper = new NotifyObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return objectMapper.readValue(json, QueryResult.class); }
this.notificationDatabasePrefix = serversConfig.getNotificationDatabasePrefix(); this.notificationDatabaseSuffix = serversConfig.getNotificationDatabaseSuffix(); this.requestDatabasePrefix = serversConfig.getRequestDatabasePrefix(); this.requestDatabaseSuffix = serversConfig.getRequestDatabaseSuffix(); new JSR310Module(), new NotifyJacksonModule()); CouchSetup masterConfig = new CouchSetup(serversConfig.getMasterUrl()) .setHttpClient(JerseyCouchHttpClient.class) .setJsonStrategy(jsonStrategy) .setUserName(serversConfig.getMasterUsername()) .setPassword(serversConfig.getMasterPassword()); masterServer = new CouchServer(masterConfig); masterDatabase = initMasterDatabase(serversConfig, masterServer); CouchSetup notificationConfig = new CouchSetup(serversConfig.getNotificationUrl()) .setHttpClient(JerseyCouchHttpClient.class) .setJsonStrategy(jsonStrategy) .setUserName(serversConfig.getNotificationUsername()) .setPassword(serversConfig.getNotificationPassword()); notificationServer = new CouchServer(notificationConfig); CouchSetup requestConfig = new CouchSetup(serversConfig.getRequestUrl()) .setHttpClient(JerseyCouchHttpClient.class) .setJsonStrategy(jsonStrategy) .setUserName(serversConfig.getRequestUsername()) .setPassword(serversConfig.getRequestPassword()); requestServer = new CouchServer(requestConfig);
@SuppressWarnings("unchecked") public QueryResult<Notification> getNotifications(String domainName) throws IOException { Response response = client.target(apiPath + "/v2/admin/domains").path(domainName).path("notifications") .request(MediaType.APPLICATION_JSON_TYPE) .get(); HttpStatusCode statusCode = HttpStatusCode.findByCode(response.getStatus()); if (statusCode != HttpStatusCode.OK) { throw ApiException.fromCode(statusCode, "Get of tasks FAILED: " + response.getStatusInfo()); } String json = response.readEntity(String.class); NotifyObjectMapper objectMapper = new NotifyObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return objectMapper.readValue(json, QueryResult.class); }
@SuppressWarnings("unchecked") public QueryResult<NotificationRequest> getRequests(String domainName, NotificationRequestStatus requestStatus) throws IOException { Response response = client.target(apiPath + "/v2/admin/domains").path(domainName).path("requests") .queryParam("requestStatus", requestStatus) .request(MediaType.APPLICATION_JSON_TYPE) .get(); HttpStatusCode statusCode = HttpStatusCode.findByCode(response.getStatus()); if (statusCode != HttpStatusCode.OK) { throw ApiException.fromCode(statusCode, "Get of tasks FAILED: " + response.getStatusInfo()); } String json = response.readEntity(String.class); NotifyObjectMapper objectMapper = new NotifyObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return objectMapper.readValue(json, QueryResult.class); }
public DomainProfile getOrCreateDomainProfile(Client client, String domainName) throws IOException { Response response = client.target(apiPath + "/v2/admin/domains").path(domainName) .request(MediaType.APPLICATION_JSON_TYPE) .put(Entity.entity("", MediaType.WILDCARD_TYPE)); HttpStatusCode statusCode = HttpStatusCode.findByCode(response.getStatus()); if (statusCode != HttpStatusCode.OK) { String msg = String.format("Put of domain \"%s\" FAILED: %s", domainName, response.getStatusInfo()); throw ApiException.fromCode(statusCode, msg); } String json = response.readEntity(String.class); NotifyObjectMapper objectMapper = new NotifyObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); return objectMapper.readValue(json, DomainProfile.class); }