@@ -93,6 +93,9 @@ private void doImportAsynchronously(String subscriptionUri) {
9393 System .out .printf ("Start Asynchronous Input: %s: %s\n " , threadName , subscriptionUri );
9494
9595 String resourceUri = subscriptionUri ;
96+ String accessToken = "" ;
97+ Authorization authorization = null ;
98+ RetailCustomer retailCustomer = null ;
9699
97100 if (subscriptionUri .indexOf ("?" ) > -1 ) { // Does message contain a query element
98101 resourceUri = subscriptionUri .substring (0 , subscriptionUri .indexOf ("?" )); // Yes, remove the query element
@@ -118,12 +121,22 @@ private void doImportAsynchronously(String subscriptionUri) {
118121
119122 } else {
120123 try {
121- Authorization authorization = resourceService .findByResourceUri (resourceUri , Authorization .class );
122-
123- RetailCustomer retailCustomer = authorization .getRetailCustomer ();
124-
125- String accessToken = authorization .getAccessToken ();
126-
124+ if ((resourceUri .contains ("/Batch/Bulk" )) || (resourceUri .contains ("/Authorization" ))) {
125+ // mutate the resourceUri to be of the form .../Batch/Bulk
126+ resourceUri = (resourceUri .substring (0 , resourceUri .indexOf ("/resource/" ) + "/resource/" .length ()).concat ("Batch/Bulk" ));
127+
128+ } else {
129+ // mutate the resourceUri for the form /Subscription/{subscriptionId}/**
130+ String temp = resourceUri .substring (resourceUri .indexOf ("/Subscription/" ) + "/Subscription/" .length ());
131+ if (temp .contains ("/" )) {
132+ resourceUri = resourceUri .substring (0 , resourceUri .indexOf ("/Subscription" ) + "/Subscription" .length ()).concat (temp .substring (0 , temp .indexOf ("/" )));
133+ }
134+ }
135+
136+ authorization = resourceService .findByResourceUri (resourceUri , Authorization .class );
137+ retailCustomer = authorization .getRetailCustomer ();
138+ accessToken = authorization .getAccessToken ();
139+
127140 try {
128141
129142 HttpHeaders requestHeaders = new HttpHeaders ();
0 commit comments