3
3
import java .io .IOException ;
4
4
import java .net .MalformedURLException ;
5
5
import java .net .URL ;
6
- import java .util .ArrayList ;
7
6
import java .util .List ;
8
7
9
8
import com .sendsafely .Package ;
@@ -23,6 +22,7 @@ public class FinalizePackageHandler extends BaseHandler
23
22
{
24
23
25
24
private FinalizePackageRequest request ;
25
+ private boolean notify = false ;
26
26
27
27
public FinalizePackageHandler (UploadManager uploadManager ) {
28
28
super (uploadManager );
@@ -77,7 +77,18 @@ protected PackageURL makeRequest(String packageId, String packageCode, String ke
77
77
78
78
if (response .getResponse () == APIResponse .SUCCESS || response .getResponse () == APIResponse .PACKAGE_NEEDS_APPROVAL )
79
79
{
80
- return convert (response , keyCode );
80
+ PackageURL packageUrl = convert (response , keyCode );
81
+
82
+ if (notify ) {
83
+ try {
84
+ notifyPackageRecipients (packageId ,keyCode );
85
+ packageUrl .setNotificationStatus (APIResponse .SUCCESS .toString ());
86
+ } catch (NotifyPackageRecipientsException e ) {
87
+ packageUrl .setNotificationStatus (e .getMessage ());
88
+ }
89
+ }
90
+
91
+ return packageUrl ;
81
92
}
82
93
else if (response .getResponse () == APIResponse .LIMIT_EXCEEDED )
83
94
{
@@ -154,5 +165,24 @@ protected Package convert(CreatePackageResponse obj)
154
165
info .setServerSecret (obj .getServerSecret ());
155
166
return info ;
156
167
}
168
+
169
+ protected void notifyPackageRecipients (String packageId , String keycode ) throws NotifyPackageRecipientsException {
170
+
171
+ NotifyPackageRecipientsHandler handler = new NotifyPackageRecipientsHandler (uploadManager ,keycode );
172
+
173
+ try {
174
+ handler .makeRequest (packageId );
175
+ } catch (NotifyPackageRecipientsException e ) {
176
+ throw new NotifyPackageRecipientsException (e );
177
+ }
178
+ }
179
+
180
+ public boolean isNotify () {
181
+ return notify ;
182
+ }
183
+
184
+ public void setNotify (boolean notify ) {
185
+ this .notify = notify ;
186
+ }
157
187
158
188
}
0 commit comments