33import java .io .IOException ;
44import java .net .MalformedURLException ;
55import java .net .URL ;
6- import java .util .ArrayList ;
76import java .util .List ;
87
98import com .sendsafely .Package ;
@@ -23,6 +22,7 @@ public class FinalizePackageHandler extends BaseHandler
2322{
2423
2524 private FinalizePackageRequest request ;
25+ private boolean notify = false ;
2626
2727 public FinalizePackageHandler (UploadManager uploadManager ) {
2828 super (uploadManager );
@@ -77,7 +77,18 @@ protected PackageURL makeRequest(String packageId, String packageCode, String ke
7777
7878 if (response .getResponse () == APIResponse .SUCCESS || response .getResponse () == APIResponse .PACKAGE_NEEDS_APPROVAL )
7979 {
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 ;
8192 }
8293 else if (response .getResponse () == APIResponse .LIMIT_EXCEEDED )
8394 {
@@ -154,5 +165,24 @@ protected Package convert(CreatePackageResponse obj)
154165 info .setServerSecret (obj .getServerSecret ());
155166 return info ;
156167 }
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+ }
157187
158188}
0 commit comments