@@ -88,7 +88,7 @@ public class APIManagerAPIAdapter {
8888
8989 ObjectMapper mapper = new ObjectMapper ();
9090
91- CoreParameters cmd = CoreParameters .getInstance ();
91+ static CoreParameters cmd = CoreParameters .getInstance ();
9292
9393 /**
9494 * Maps the provided status to the REST-API endpoint to change the status!
@@ -194,7 +194,7 @@ URI getAPIRequestUri(APIFilter filter) throws URISyntaxException {
194194 if (filter .getId ()!=null ) {
195195 requestedId = "/" +filter .getId ();
196196 }
197- URI uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION + "/" +filter .getApiType () + requestedId )
197+ URI uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () + "/" +filter .getApiType () + requestedId )
198198 .addParameters (filter .getFilters ())
199199 .build ();
200200 return uri ;
@@ -268,7 +268,7 @@ private void addImageFromAPIM(API api, boolean includeImage) throws AppException
268268 URI uri ;
269269 HttpResponse httpResponse = null ;
270270 try {
271- uri = new URIBuilder (CoreParameters . getInstance (). getAPIManagerURL ()).setPath (RestAPICall . API_VERSION + "/proxies/" +api .getId ()+"/image" ).build ();
271+ uri = new URIBuilder (cmd . getAPIManagerURL ()).setPath (cmd . getApiBasepath () + "/proxies/" +api .getId ()+"/image" ).build ();
272272 RestAPICall getRequest = new GETRequest (uri );
273273 httpResponse = getRequest .execute ();
274274 if (httpResponse == null || httpResponse .getEntity () == null || httpResponse .getStatusLine ().getStatusCode () == HttpStatus .SC_NOT_FOUND ) {
@@ -321,7 +321,7 @@ public void updateAPIImage(API api, Image image) throws AppException {
321321 HttpResponse httpResponse = null ;
322322
323323 try {
324- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/" +api .getId ()+"/image" ).build ();
324+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/" +api .getId ()+"/image" ).build ();
325325
326326 entity = MultipartEntityBuilder .create ()
327327 .addBinaryBody ("file" , api .getImage ().getInputStream (), ContentType .create ("image/jpeg" ), api .getImage ().getBaseFilename ())
@@ -470,11 +470,11 @@ private static void addOriginalAPIDefinitionFromAPIM(API api, APIFilter filter)
470470 HttpResponse httpResponse = null ;
471471 try {
472472 if (filter .isUseFEAPIDefinition ()) {
473- uri = new URIBuilder (CoreParameters . getInstance (). getAPIManagerURL ()).setPath (RestAPICall . API_VERSION + "/discovery/swagger/api/id/" +api .getId ())
473+ uri = new URIBuilder (cmd . getAPIManagerURL ()).setPath (cmd . getApiBasepath () + "/discovery/swagger/api/id/" +api .getId ())
474474 .setParameter ("swaggerVersion" , "2.0" ).build ();
475475 LOG .debug ("Loading API-Definition from FE-API: " );
476476 } else {
477- uri = new URIBuilder (CoreParameters . getInstance (). getAPIManagerURL ()).setPath (RestAPICall . API_VERSION + "/apirepo/" +api .getApiId ()+"/download" )
477+ uri = new URIBuilder (cmd . getAPIManagerURL ()).setPath (cmd . getApiBasepath () + "/apirepo/" +api .getApiId ()+"/download" )
478478 .setParameter ("original" , "true" ).build ();
479479 }
480480 RestAPICall getRequest = new GETRequest (uri , APIManagerAdapter .hasAdminAccount ());
@@ -502,7 +502,7 @@ public API createAPIProxy(API api) throws AppException {
502502 HttpEntity entity ;
503503 HttpResponse httpResponse = null ;
504504 try {
505- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/" ).build ();
505+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/" ).build ();
506506 entity = new StringEntity ("{\" apiId\" :\" " + api .getApiId () + "\" ,\" organizationId\" :\" " + api .getOrganization ().getId () + "\" }" );
507507
508508 RestAPICall request = new POSTRequest (entity , uri );
@@ -538,7 +538,7 @@ public API updateAPIProxy(API api) throws AppException {
538538 HttpResponse httpResponse = null ;
539539 translateMethodIds (api , api .getId (), METHOD_TRANSLATION .AS_ID );
540540 try {
541- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/" +api .getId ()).build ();
541+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/" +api .getId ()).build ();
542542 entity = new StringEntity (mapper .writeValueAsString (api ), ContentType .APPLICATION_JSON );
543543
544544 RestAPICall request = new PUTRequest (entity , uri );
@@ -572,7 +572,7 @@ public void deleteAPIProxy(API api) throws AppException {
572572 URI uri ;
573573 HttpResponse httpResponse = null ;
574574 try {
575- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/" +api .getId ()).build ();
575+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/" +api .getId ()).build ();
576576
577577 RestAPICall request = new DELRequest (uri );
578578 httpResponse = request .execute ();
@@ -597,7 +597,7 @@ public void deleteBackendAPI(API api) throws AppException {
597597 URI uri ;
598598 HttpResponse httpResponse = null ;
599599 try {
600- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/apirepo/" +api .getApiId ()).build ();
600+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/apirepo/" +api .getApiId ()).build ();
601601
602602 RestAPICall request = new DELRequest (uri );
603603 httpResponse = request .execute ();
@@ -631,7 +631,7 @@ public void updateAPIStatus(API api, String desiredState, String vhost) throws A
631631 RestAPICall request ;
632632 try {
633633 uri = new URIBuilder (cmd .getAPIManagerURL ())
634- .setPath (RestAPICall . API_VERSION +"/proxies/" +api .getId ()+"/" +StatusEndpoint .valueOf (desiredState ).endpoint )
634+ .setPath (cmd . getApiBasepath () +"/proxies/" +api .getId ()+"/" +StatusEndpoint .valueOf (desiredState ).endpoint )
635635 .build ();
636636 if (vhost !=null && desiredState .equals (API .STATE_PUBLISHED )) { // During publish, it might be required to also set the VHost (See issue: #98)
637637 HttpEntity entity = new StringEntity ("vhost=" +vhost , ContentType .APPLICATION_JSON );
@@ -687,7 +687,7 @@ public void updateRetirementDate(API api, Long retirementDate) throws AppExcepti
687687 return ;
688688 }
689689 URI uri = new URIBuilder (cmd .getAPIManagerURL ())
690- .setPath (RestAPICall . API_VERSION +"/proxies/" +api .getId ()+"/deprecate" ).build ();
690+ .setPath (cmd . getApiBasepath () +"/proxies/" +api .getId ()+"/deprecate" ).build ();
691691 RestAPICall apiCall = new POSTRequest (new StringEntity ("retirementDate=" +formatRetirementDate (retirementDate )), uri , true );
692692 apiCall .setContentType ("application/x-www-form-urlencoded" );
693693 httpResponse = apiCall .execute ();
@@ -745,7 +745,7 @@ private JsonNode importFromWSDL(API api) throws URISyntaxException, AppException
745745 pass =extractPassword (completeWsdlUrl );
746746
747747 try {
748- URIBuilder uriBuilder = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/apirepo/importFromUrl/" )
748+ URIBuilder uriBuilder = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/apirepo/importFromUrl/" )
749749 .setParameter ("organizationId" , api .getOrganization ().getId ())
750750 .setParameter ("type" , "wsdl" )
751751 .setParameter ("url" , wsdlUrl )
@@ -780,10 +780,10 @@ private JsonNode importFromSwagger(API api) throws URISyntaxException, AppExcept
780780 HttpEntity entity ;
781781 HttpResponse httpResponse = null ;
782782 if (APIManagerAdapter .hasAPIManagerVersion ("7.6.2" )) {
783- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/apirepo/import/" ).build ();
783+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/apirepo/import/" ).build ();
784784 } else {
785785 // Not sure, if 7.5.3 still needs it that way!
786- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/apirepo/import/" )
786+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/apirepo/import/" )
787787 .setParameter ("field" , "name" ).setParameter ("op" , "eq" ).setParameter ("value" , "API Development" ).build ();
788788 }
789789 try {
@@ -845,7 +845,7 @@ public void upgradeAccessToNewerAPI(API apiToUpgradeAccess, API referenceAPI) th
845845 if (updateAppQuota ) {
846846 LOG .info ("Taking over existing quota config for application: '" +app .getName ()+"' to newly created API." );
847847 try {
848- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/applications/" +app .getId ()+"/quota" ).build ();
848+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/applications/" +app .getId ()+"/quota" ).build ();
849849 entity = new StringEntity (mapper .writeValueAsString (app .getAppQuota ()), ContentType .APPLICATION_JSON );
850850
851851 request = new PUTRequest (entity , uri , true );
@@ -886,7 +886,7 @@ public boolean upgradeAccessToNewerAPI(API apiToUpgradeAccess, API referenceAPI,
886886 RestAPICall request ;
887887 HttpResponse httpResponse = null ;
888888 try {
889- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/upgrade/" +referenceAPI .getId ()).build ();
889+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/upgrade/" +referenceAPI .getId ()).build ();
890890
891891 List <NameValuePair > params = new Vector <NameValuePair >();
892892 params .add (new BasicNameValuePair ("upgradeApiId" , apiToUpgradeAccess .getId ()));
@@ -945,7 +945,7 @@ public void grantClientOrganization(List<Organization> grantAccessToOrgs, API ap
945945 }
946946 }
947947 try {
948- uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (RestAPICall . API_VERSION +"/proxies/grantaccess" ).build ();
948+ uri = new URIBuilder (cmd .getAPIManagerURL ()).setPath (cmd . getApiBasepath () +"/proxies/grantaccess" ).build ();
949949 entity = new StringEntity (formBody );
950950 apiCall = new POSTRequest (entity , uri , true );
951951 apiCall .setContentType ("application/x-www-form-urlencoded" );
0 commit comments