@@ -75,12 +75,13 @@ public class NotificationController extends BaseController {
7575 public void notification (HttpServletResponse response , InputStream inputStream ) throws IOException {
7676
7777 BatchList batchList = (BatchList ) marshaller .unmarshal (new StreamSource (inputStream ));
78- batchListService . persist ( batchList );
79- Iterator < String > it = batchList . getResources (). iterator ( );
80- while ( it . hasNext ()) {
81- String resourceUri = ( String ) it . next ();
82- doImportAsynchronously (resourceUri );
78+
79+ batchListService . persist ( batchList );
80+
81+ for ( String resourceUri : batchList . getResources () ) {
82+ doImportAsynchronously (resourceUri );
8383 }
84+
8485 response .setStatus (HttpServletResponse .SC_OK );
8586 }
8687
@@ -93,6 +94,9 @@ private void doImportAsynchronously(String subscriptionUri) {
9394 System .out .printf ("Start Asynchronous Input: %s: %s\n " , threadName , subscriptionUri );
9495
9596 String resourceUri = subscriptionUri ;
97+ String accessToken = "" ;
98+ Authorization authorization = null ;
99+ RetailCustomer retailCustomer = null ;
96100
97101 if (subscriptionUri .indexOf ("?" ) > -1 ) { // Does message contain a query element
98102 resourceUri = subscriptionUri .substring (0 , subscriptionUri .indexOf ("?" )); // Yes, remove the query element
@@ -118,12 +122,31 @@ private void doImportAsynchronously(String subscriptionUri) {
118122
119123 } else {
120124 try {
121- Authorization authorization = resourceService .findByResourceUri (resourceUri , Authorization .class );
122-
123- RetailCustomer retailCustomer = authorization .getRetailCustomer ();
124-
125- String accessToken = authorization .getAccessToken ();
126-
125+ if ((resourceUri .contains ("/Batch/Bulk" )) || (resourceUri .contains ("/Authorization" ))) {
126+ // mutate the resourceUri to be of the form .../Batch/Bulk
127+ resourceUri = (resourceUri .substring (0 , resourceUri .indexOf ("/resource/" ) + "/resource/" .length ()).concat ("Batch/Bulk" ));
128+
129+ } else {
130+ if (resourceUri .contains ("/Subscription" )) {
131+ // mutate the resourceUri for the form /Subscription/{subscriptionId}/**
132+ String temp = resourceUri .substring (resourceUri .indexOf ("/Subscription/" ) + "/Subscription/" .length ());
133+ if (temp .contains ("/" )) {
134+ resourceUri = resourceUri .substring (0 , resourceUri .indexOf ("/Subscription" ) + "/Subscription" .length ()).concat (temp .substring (0 , temp .indexOf ("/" )));
135+ }
136+ }
137+ }
138+
139+ Authorization x = resourceService .findById (2L , Authorization .class );
140+
141+ if (x .getResourceURI ().equals (resourceUri )) {
142+ System .out .println ("ResourceURIs Equal:" + resourceUri );
143+ } else {
144+ System .out .println ("ResourceURIs Not - Equal:" + resourceUri );
145+ }
146+ authorization = resourceService .findByResourceUri (resourceUri , Authorization .class );
147+ retailCustomer = authorization .getRetailCustomer ();
148+ accessToken = authorization .getAccessToken ();
149+
127150 try {
128151
129152 HttpHeaders requestHeaders = new HttpHeaders ();
0 commit comments