use of org.apache.synapse.rest.API in project wso2-synapse by wso2.
the class SynapseXMLConfigurationFactory method defineAPI.
public static API defineAPI(SynapseConfiguration config, OMElement elem, Properties properties) {
API api = null;
try {
api = APIFactory.createAPI(elem, properties);
config.addAPI(api.getName(), api);
} catch (Exception e) {
String msg = "API configuration cannot be built";
handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_API, msg, e);
}
return api;
}
use of org.apache.synapse.rest.API in project wso2-synapse by wso2.
the class SynapseXMLConfigurationFactory method defineAPI.
/**
* Add api with the option of re-ordering the api collection based on the context
*
* @param config SynapseConfiguration
* @param elem OMElement element
* @param properties Properties
* @param reOrder reorder the deployment order based on the context
* @return API api object
*/
public static API defineAPI(SynapseConfiguration config, OMElement elem, Properties properties, boolean reOrder) {
API api = null;
try {
api = APIFactory.createAPI(elem, properties);
config.addAPI(api.getName(), api, reOrder);
} catch (Exception e) {
String msg = "API configuration cannot be built";
handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_API, msg, e);
}
return api;
}
use of org.apache.synapse.rest.API in project wso2-synapse by wso2.
the class SynapseXMLConfigurationSerializer method serializeAPIs.
private static void serializeAPIs(OMElement definitions, Collection<API> apiSet) {
for (API api : apiSet) {
OMElement apiElt = APISerializer.serializeAPI(api);
definitions.addChild(apiElt);
}
}
use of org.apache.synapse.rest.API in project wso2-synapse by wso2.
the class SynapseConfigurationTest method testAPITableOrderWithAddAPI.
public void testAPITableOrderWithAddAPI() {
SynapseConfiguration config = new SynapseConfiguration();
API api1 = new API("API1", "/context/test");
API api2 = new API("API2", "/context");
API api3 = new API("API3", "/context/test/ctx");
config.addAPI("API1", api1);
config.addAPI("API2", api2);
config.addAPI("API3", api3);
// this should get the api table in descending order with longest at the first
Collection<API> apis = config.getAPIs();
API[] apisArray = apis.toArray(new API[apis.size()]);
// api3 with context /context/test/ctx should be first in the list
assertEquals("Order is not correct", api3, apisArray[0]);
}
use of org.apache.synapse.rest.API in project wso2-synapse by wso2.
the class APIDeployer method deploySynapseArtifact.
@Override
public String deploySynapseArtifact(OMElement artifactConfig, String fileName, Properties properties) {
CustomLogSetter.getInstance().setLogAppender(customLogContent);
if (log.isDebugEnabled()) {
log.debug("API deployment from file : " + fileName + " : Started");
}
try {
API api = APIFactory.createAPI(artifactConfig, properties);
api.setArtifactContainerName(customLogContent);
if (api != null) {
api.setFileName((new File(fileName)).getName());
if (log.isDebugEnabled()) {
log.debug("API named '" + api.getName() + "' has been built from the file " + fileName);
}
api.init(getSynapseEnvironment());
if (log.isDebugEnabled()) {
log.debug("Initialized the API: " + api.getName());
}
getSynapseConfiguration().addAPI(api.getName(), api);
if (log.isDebugEnabled()) {
log.debug("API deployment from file : " + fileName + " : Completed");
}
log.info("API named '" + api.getName() + "' has been deployed from file : " + fileName);
return api.getName();
} else {
handleSynapseArtifactDeploymentError("API deployment Failed. The artifact " + "described in the file " + fileName + " is not a valid API");
}
} catch (Exception e) {
handleSynapseArtifactDeploymentError("API deployment from the file : " + fileName + " : Failed.", e);
}
return null;
}
Aggregations