2020
2121import java .io .File ;
2222import java .io .IOException ;
23- import java .util .*;
24-
25- import com .google .api .client .http .javanet .NetHttpTransport ;
26- import org .slf4j .Logger ;
27- import org .slf4j .LoggerFactory ;
23+ import java .util .ArrayList ;
24+ import java .util .Collections ;
25+ import java .util .Iterator ;
26+ import java .util .List ;
2827
2928import javax .net .ssl .HttpsURLConnection ;
3029
31- import com .google .api .client .http .apache .ApacheHttpTransport ;
32- import com .google .api .client .json .gson .GsonFactory ;
3330import org .apache .maven .plugin .MojoExecutionException ;
31+ import org .slf4j .Logger ;
32+ import org .slf4j .LoggerFactory ;
3433
3534import com .apigee .mgmtapi .sdk .client .MgmtAPIClient ;
3635import com .apigee .mgmtapi .sdk .model .AccessToken ;
4645import com .google .api .client .http .HttpResponseException ;
4746import com .google .api .client .http .HttpTransport ;
4847import com .google .api .client .http .UrlEncodedContent ;
48+ import com .google .api .client .http .apache .ApacheHttpTransport ;
49+ import com .google .api .client .http .javanet .NetHttpTransport ;
4950import com .google .api .client .json .JsonFactory ;
51+ import com .google .api .client .json .gson .GsonFactory ;
5052import com .google .api .client .util .GenericData ;
5153import com .google .api .client .util .Key ;
5254import com .google .gson .Gson ;
5355import com .google .gson .GsonBuilder ;
56+ import com .google .gson .JsonSyntaxException ;
5457
5558import io .apigee .buildTools .enterprise4g .utils .PrintUtil ;
5659import io .apigee .buildTools .enterprise4g .utils .ServerProfile ;
@@ -638,9 +641,26 @@ public String activateBundleRevision(Bundle bundle) throws IOException {
638641
639642 HttpResponse response = null ;
640643 response = executeAPI (profile , deployRestRequest );
644+ String responseString = response .parseAsString ();
645+ SeamLessDeploymentStatus deployment3 = null ;
646+ try {
647+ deployment3 = new Gson ().fromJson (responseString , SeamLessDeploymentStatus .class );
648+ }catch (JsonSyntaxException e ){
649+ // https://github.com/apigee/apigee-deploy-maven-plugin/issues/92
650+ // https://github.com/apigee/apigee-deploy-maven-plugin/issues/137
651+ // Whenever an existing API is deployed with option as override and in the new revision, the proxy basepath is changed,
652+ // the Mgmt API response is different. It does not return the usual response if the proxy has no changes to the basepath
653+ deployment2 = new Gson ().fromJson (responseString , BundleActivationConfig .class );
654+ if (log .isInfoEnabled ()) {
655+ log .info (PrintUtil .formatResponse (response , gson .toJson (deployment2 )));
656+ log .info ("Deployed revision is:{}" , deployment2 .revision );
657+ }
658+ applyDelay ();
659+ return deployment2 .state ;
660+ }
641661
642662 if (getProfile ().isOverride ()) {
643- SeamLessDeploymentStatus deployment3 = response .parseAs (SeamLessDeploymentStatus .class );
663+ // deployment3 = response.parseAs(SeamLessDeploymentStatus.class);
644664 Iterator <BundleActivationConfig > iter = deployment3 .environment .iterator ();
645665 while (iter .hasNext ()) {
646666 BundleActivationConfig config = iter .next ();
@@ -663,7 +683,7 @@ public String activateBundleRevision(Bundle bundle) throws IOException {
663683
664684 }
665685
666- deployment2 = response . parseAs ( BundleActivationConfig .class );
686+ deployment2 = new Gson (). fromJson ( responseString , BundleActivationConfig .class );
667687 if (log .isInfoEnabled ()) {
668688 log .info (PrintUtil .formatResponse (response , gson .toJson (deployment2 )));
669689 log .info ("Deployed revision is:{}" , deployment2 .revision );
0 commit comments