1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * See LICENSE.txt included in this distribution for the specific 9 * language governing permissions and limitations under the License. 10 * 11 * When distributing Covered Code, include this CDDL HEADER in each 12 * file and include the License file at LICENSE.txt. 13 * If applicable, add the following below this CDDL HEADER, with the 14 * fields enclosed by brackets "[]" replaced with your own identifying 15 * information: Portions Copyright [yyyy] [name of copyright owner] 16 * 17 * CDDL HEADER END 18 */ 19 20 /* 21 * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. 22 */ 23 package opengrok.auth.plugin.util; 24 25 import java.io.Serializable; 26 import java.util.concurrent.CompletableFuture; 27 import java.util.concurrent.Executors; 28 import java.util.concurrent.Future; 29 30 public class WebHook implements Serializable { 31 private static final long serialVersionUID = -1; 32 33 private String URI; 34 private String content; 35 WebHook()36 public WebHook() { 37 } 38 WebHook(String uri, String content)39 WebHook(String uri, String content) { 40 this.URI = uri; 41 this.content = content; 42 } 43 setURI(String uri)44 public void setURI(String uri) { 45 this.URI = uri; 46 } getURI()47 public String getURI() { 48 return URI; 49 } 50 setContent(String content)51 public void setContent(String content) { 52 this.content = content; 53 } getContent()54 public String getContent() { 55 return content; 56 } 57 post()58 public Future<String> post() { 59 CompletableFuture<String> completableFuture 60 = new CompletableFuture<>(); 61 62 Executors.newCachedThreadPool().submit(() -> { 63 int status = RestfulClient.postIt(getURI(), getContent()); 64 completableFuture.complete(String.valueOf(status)); 65 return null; 66 }); 67 68 return completableFuture; 69 } 70 } 71