added profile check before publishing apis

revert-70aa11f8
ayyoob 8 years ago
parent 489fa46569
commit 52e84273d1

@ -0,0 +1,57 @@
package org.wso2.carbon.apimgt.webapp.publisher.config;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
/**
* <p>Java class for Profiles complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="Profiles">
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="Profile" maxOccurs="unbounded" minOccurs="0">
* &lt;simpleType>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}string">
* &lt;enumeration value="default"/>
* &lt;/restriction>
* &lt;/simpleType>
* &lt;/element>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Profiles", propOrder = {
"profile"
})
public class Profiles {
@XmlElement(name = "Profile")
protected List<String> profile;
/**
* Gets the value of the profile property.
*
*/
public List<String> getProfile() {
if (profile == null) {
profile = new ArrayList<String>();
}
return this.profile;
}
}

@ -40,6 +40,7 @@ public class WebappPublisherConfig {
private String host;
private boolean isPublished;
private Profiles profiles;
private static WebappPublisherConfig config;
@ -71,10 +72,19 @@ public class WebappPublisherConfig {
return isPublished;
}
@XmlElement(name = "Profiles", required = true)
public Profiles getProfiles() {
return profiles;
}
public void setPublished(boolean published) {
isPublished = published;
}
public void setProfiles(Profiles profiles) {
this.profiles = profiles;
}
public static void init() throws WebappPublisherConfigurationFailedException {
try {
File emailSenderConfig = new File(WEBAPP_PUBLISHER_CONFIG_PATH);

@ -29,6 +29,7 @@ import org.wso2.carbon.apimgt.webapp.publisher.APIConfig;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherService;
import org.wso2.carbon.apimgt.webapp.publisher.APIPublisherUtil;
import org.wso2.carbon.apimgt.webapp.publisher.config.APIResourceConfiguration;
import org.wso2.carbon.apimgt.webapp.publisher.config.WebappPublisherConfig;
import org.wso2.carbon.apimgt.webapp.publisher.internal.APIPublisherDataHolder;
import org.wso2.carbon.apimgt.webapp.publisher.lifecycle.util.AnnotationProcessor;
@ -56,8 +57,8 @@ public class APIPublisherLifecycleListener implements LifecycleListener {
String profile = System.getProperty(PROPERTY_PROFILE);
if ((profile.equalsIgnoreCase(PROFILE_DT_WORKER) ||
profile.equalsIgnoreCase(PROFILE_DEFAULT)) && isManagedApi) {
if (WebappPublisherConfig.getInstance().getProfiles().getProfile().contains(profile.toLowerCase())
&& isManagedApi) {
try {
AnnotationProcessor annotationProcessor = new AnnotationProcessor(context);
Set<String> annotatedAPIClasses = annotationProcessor.

@ -28,5 +28,8 @@
<!-- If it is true, the APIs of this instance will be published to the defined host -->
<PublishAPI>true</PublishAPI>
<!--Webapp will be published only when running below profiles-->
<Profiles>
<Profile>default</Profile>
</Profiles>
</WebappPublisherConfigs>

@ -36,14 +36,14 @@
</IdentityConfiguration>
<PolicyConfiguration>
<MonitoringClass>org.wso2.carbon.policy.mgt</MonitoringClass>
<MonitoringEnable>true</MonitoringEnable>
<MonitoringEnable>false</MonitoringEnable>
<MonitoringFrequency>60000</MonitoringFrequency>
<MaxRetries>5</MaxRetries>
<MinRetriesToMarkUnreachable>8</MinRetriesToMarkUnreachable>
<MinRetriesToMarkInactive>20</MinRetriesToMarkInactive>
</PolicyConfiguration>
<TaskConfiguration>
<Enable>true</Enable>
<Enable>false</Enable>
<Frequency>600000</Frequency>
<TaskClass>org.wso2.carbon.device.mgt.core.task.impl.DeviceDetailsRetrieverTask</TaskClass>
<Operations>

Loading…
Cancel
Save