From 11310a9145512524ec2f038091167157e26831a9 Mon Sep 17 00:00:00 2001 From: lasantha Date: Fri, 15 Dec 2017 10:21:15 +0530 Subject: [PATCH] default API set to newly added API and fixed it by using context parameters --- .../wso2/carbon/apimgt/webapp/publisher/APIConfig.java | 10 ++++++++++ .../webapp/publisher/APIPublisherServiceImpl.java | 2 +- .../apimgt/webapp/publisher/APIPublisherUtil.java | 8 ++++++++ .../src/main/webapp/WEB-INF/web.xml | 4 ++++ .../src/main/webapp/WEB-INF/web.xml | 4 ++++ .../src/main/webapp/WEB-INF/web.xml | 4 ++++ 6 files changed, 31 insertions(+), 1 deletion(-) diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java index ca020bd83a..0c2334ae20 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIConfig.java @@ -57,6 +57,7 @@ public class APIConfig { private String tenantDomain; private String[] tags; private Set scopes; + private boolean isDefault = true; @XmlElement(name = "Policy", required = true) public String getPolicy() { @@ -184,4 +185,13 @@ public class APIConfig { public void setScopes(Set scopes) { this.scopes = scopes; } + + @XmlElement(name = "isDefault") + public boolean isDefault() { + return isDefault; + } + + public void setDefault(boolean aDefault) { + isDefault = aDefault; + } } diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java index bc02e33e5a..4bb54d5ac1 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherServiceImpl.java @@ -108,7 +108,7 @@ public class APIPublisherServiceImpl implements APIPublisherService { api.setStatus(PUBLISHED_STATUS); api.setResponseCaching("DISABLED"); api.setDestinationStatsEnabled("false"); - api.isDefaultVersion(true); + api.isDefaultVersion(config.isDefault()); List transport = new ArrayList<>(); transport.add("https"); transport.add("http"); diff --git a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java index e1f2195282..cbb27d9f2a 100644 --- a/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java +++ b/components/apimgt-extensions/org.wso2.carbon.apimgt.webapp.publisher/src/main/java/org/wso2/carbon/apimgt/webapp/publisher/APIPublisherUtil.java @@ -55,6 +55,7 @@ public class APIPublisherUtil { private static final String NON_SECURED_RESOURCES = "nonSecuredEndPoints"; private static final String AUTH_TYPE_NON_SECURED = "None"; + private static final String PARAM_IS_DEFAULT = "isDefault"; public static String getServerBaseUrl() { WebappPublisherConfig webappPublisherConfig = WebappPublisherConfig.getInstance(); @@ -143,6 +144,13 @@ public class APIPublisherUtil { apiConfig.setSecured(false); + boolean isDefault = true; + String isDefaultParam = servletContext.getInitParameter(PARAM_IS_DEFAULT); + if (isDefaultParam != null && !isDefaultParam.isEmpty()) { + isDefault = Boolean.parseBoolean(isDefaultParam); + } + apiConfig.setDefault(isDefault); + String transports = servletContext.getInitParameter(PARAM_MANAGED_API_TRANSPORTS); if (transports == null || transports.isEmpty()) { if (log.isDebugEnabled()) { diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/src/main/webapp/WEB-INF/web.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/src/main/webapp/WEB-INF/web.xml index ca08169c8c..e919cb9235 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/src/main/webapp/WEB-INF/web.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.cert.admin.v09.api/src/main/webapp/WEB-INF/web.xml @@ -44,6 +44,10 @@ doAuthentication true + + isDefault + false + diff --git a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/src/main/webapp/WEB-INF/web.xml b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/src/main/webapp/WEB-INF/web.xml index 6fd45f33b3..6cef7eee36 100644 --- a/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/src/main/webapp/WEB-INF/web.xml +++ b/components/certificate-mgt/org.wso2.carbon.certificate.mgt.v09.api/src/main/webapp/WEB-INF/web.xml @@ -37,6 +37,10 @@ doAuthentication true + + isDefault + false + diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/webapp/WEB-INF/web.xml b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/webapp/WEB-INF/web.xml index b23f60be4c..bc6b3d8907 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/webapp/WEB-INF/web.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.v09.api/src/main/webapp/WEB-INF/web.xml @@ -44,6 +44,10 @@ doAuthentication true + + isDefault + false +