BrightSide Workbench Full Report + Source Code
org.turro.push.service.PushService Class Reference
Inheritance diagram for org.turro.push.service.PushService:
Collaboration diagram for org.turro.push.service.PushService:

Public Member Functions

 PushService ()
 
 PushService (String gcmApiKey)
 
 PushService (KeyPair keyPair)
 
 PushService (KeyPair keyPair, String subject)
 
 PushService (String publicKey, String privateKey) throws GeneralSecurityException
 
 PushService (String publicKey, String privateKey, String subject) throws GeneralSecurityException
 
HttpResponse send (Notification notification) throws GeneralSecurityException, IOException, JoseException, ExecutionException, InterruptedException
 
HttpResponse send (Notification notification, Encoding encoding) throws GeneralSecurityException, IOException, JoseException
 
HttpPost preparePost (Notification notification, Encoding encoding) throws GeneralSecurityException, IOException, JoseException
 
void sendAsync (Notification notification, Consumer< SimpleHttpResponse > completed, Consumer< Exception > failed, Runnable cancelled) throws GeneralSecurityException, IOException, JoseException, ExecutionException, InterruptedException
 
void sendAsync (Notification notification, Encoding encoding, Consumer< SimpleHttpResponse > completed, Consumer< Exception > failed, Runnable cancelled) throws GeneralSecurityException, IOException, JoseException
 
SimpleHttpRequest prepareAsyncPost (Notification notification, Encoding encoding) throws GeneralSecurityException, IOException, JoseException
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 45 of file PushService.java.

Constructor & Destructor Documentation

◆ PushService() [1/6]

org.turro.push.service.PushService.PushService ( )

Definition at line 47 of file PushService.java.

47  {
48  }

◆ PushService() [2/6]

org.turro.push.service.PushService.PushService ( String  gcmApiKey)

Definition at line 50 of file PushService.java.

50  {
51  super(gcmApiKey);
52  }

◆ PushService() [3/6]

org.turro.push.service.PushService.PushService ( KeyPair  keyPair)

Definition at line 54 of file PushService.java.

54  {
55  super(keyPair);
56  }

◆ PushService() [4/6]

org.turro.push.service.PushService.PushService ( KeyPair  keyPair,
String  subject 
)

Definition at line 58 of file PushService.java.

58  {
59  super(keyPair, subject);
60  }

◆ PushService() [5/6]

org.turro.push.service.PushService.PushService ( String  publicKey,
String  privateKey 
) throws GeneralSecurityException

Definition at line 62 of file PushService.java.

62  {
63  super(publicKey, privateKey);
64  }

◆ PushService() [6/6]

org.turro.push.service.PushService.PushService ( String  publicKey,
String  privateKey,
String  subject 
) throws GeneralSecurityException

Definition at line 66 of file PushService.java.

66  {
67  super(publicKey, privateKey, subject);
68  }

Member Function Documentation

◆ prepareAsyncPost()

SimpleHttpRequest org.turro.push.service.PushService.prepareAsyncPost ( Notification  notification,
Encoding  encoding 
) throws GeneralSecurityException, IOException, JoseException

Definition at line 122 of file PushService.java.

122  {
123  HttpRequest request = prepareRequest(notification, encoding);
124  SimpleHttpRequest httpPost = SimpleRequestBuilder.create(Method.POST).setUri(request.getUrl()).build();
125  request.getHeaders().forEach(httpPost::addHeader);
126  httpPost.setBody(request.getBody(), ContentType.APPLICATION_OCTET_STREAM);
127  return httpPost;
128  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ preparePost()

HttpPost org.turro.push.service.PushService.preparePost ( Notification  notification,
Encoding  encoding 
) throws GeneralSecurityException, IOException, JoseException

Definition at line 81 of file PushService.java.

81  {
82  HttpRequest request = prepareRequest(notification, encoding);
83  HttpPost httpPost = new HttpPost(request.getUrl());
84  request.getHeaders().forEach(httpPost::addHeader);
85  if (request.getBody() != null) {
86  httpPost.setEntity(new ByteArrayEntity(request.getBody(), ContentType.APPLICATION_OCTET_STREAM));
87  }
88  return httpPost;
89  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ send() [1/2]

HttpResponse org.turro.push.service.PushService.send ( Notification  notification) throws GeneralSecurityException, IOException, JoseException, ExecutionException, InterruptedException

Definition at line 70 of file PushService.java.

70  {
71  return send(notification, Encoding.AESGCM);
72  }
HttpResponse send(Notification notification)
Here is the caller graph for this function:

◆ send() [2/2]

HttpResponse org.turro.push.service.PushService.send ( Notification  notification,
Encoding  encoding 
) throws GeneralSecurityException, IOException, JoseException

Definition at line 74 of file PushService.java.

74  {
75  HttpPost httpPost = preparePost(notification, encoding);
76  try(CloseableHttpClient client = HttpClientBuilder.create().build()) {
77  return client.execute(httpPost);
78  }
79  }
HttpPost preparePost(Notification notification, Encoding encoding)
Here is the call graph for this function:

◆ sendAsync() [1/2]

void org.turro.push.service.PushService.sendAsync ( Notification  notification,
Consumer< SimpleHttpResponse >  completed,
Consumer< Exception >  failed,
Runnable  cancelled 
) throws GeneralSecurityException, IOException, JoseException, ExecutionException, InterruptedException

Definition at line 91 of file PushService.java.

92  {
93  sendAsync(notification, Encoding.AESGCM, completed, failed, cancelled);
94  }
void sendAsync(Notification notification, Consumer< SimpleHttpResponse > completed, Consumer< Exception > failed, Runnable cancelled)

◆ sendAsync() [2/2]

void org.turro.push.service.PushService.sendAsync ( Notification  notification,
Encoding  encoding,
Consumer< SimpleHttpResponse >  completed,
Consumer< Exception >  failed,
Runnable  cancelled 
) throws GeneralSecurityException, IOException, JoseException

Definition at line 96 of file PushService.java.

97  {
98  SimpleHttpRequest httpPost = prepareAsyncPost(notification, encoding);
99  final CloseableHttpAsyncClient httpClient = HttpAsyncClientBuilder.create().build();
100  httpClient.start();
101  httpClient.execute(httpPost, new FutureCallback<SimpleHttpResponse>() {
102  @Override
103  public void completed(SimpleHttpResponse result) {
104  if(completed != null) completed.accept(result);
105  httpClient.close(CloseMode.GRACEFUL);
106  }
107 
108  @Override
109  public void failed(Exception ex) {
110  if(failed != null) failed.accept(ex);
111  httpClient.close(CloseMode.GRACEFUL);
112  }
113 
114  @Override
115  public void cancelled() {
116  if(cancelled != null) cancelled.run();
117  httpClient.close(CloseMode.GRACEFUL);
118  }
119  });
120  }
SimpleHttpRequest prepareAsyncPost(Notification notification, Encoding encoding)
Here is the call graph for this function:

The documentation for this class was generated from the following file: