public static API createAPI(OMElement apiElt) { return createAPI(apiElt, new Properties()); }
private static void defineHandler(API api, OMElement handlerElt) { String handlerClass = handlerElt.getAttributeValue(new QName("class")); if (handlerClass == null || "".equals(handlerClass)) { handleException("A handler element must have a class attribute"); } try { Class clazz = APIFactory.class.getClassLoader().loadClass(handlerClass); Handler handler = (Handler) clazz.newInstance(); api.addHandler(handler); } catch (Exception e) { handleException("Error initializing API handler: " + handlerClass, e); } }
public static API createAPI(OMElement apiElt) { OMAttribute nameAtt = apiElt.getAttribute(new QName("name")); if (nameAtt == null || "".equals(nameAtt.getAttributeValue())) { handleException("Attribute 'name' is required for an API definition"); return null; handleException("Attribute 'context' is required for an API definition"); return null; handleException("An API must contain at least one resource definition"); while (handlers.hasNext()) { OMElement handlerElt = (OMElement) handlers.next(); defineHandler(api, handlerElt); api.setProtocol(RESTConstants.PROTOCOL_HTTPS_ONLY); } else { handleException("Invalid protocol name: " + transports);
public static API createAPI(OMElement apiElt, Properties properties) { OMAttribute nameAtt = apiElt.getAttribute(new QName("name")); if (nameAtt == null || "".equals(nameAtt.getAttributeValue())) { handleException("Attribute 'name' is required for an API definition"); handleException("Attribute 'context' is required for an API definition"); handleException("An API must contain at least one resource definition"); while (handlers.hasNext()) { OMElement handlerElt = (OMElement) handlers.next(); defineHandler(api, handlerElt); api.setProtocol(RESTConstants.PROTOCOL_HTTPS_ONLY); } else { handleException("Invalid protocol name: " + transports);
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; }
private static void defineHandler(API api, OMElement handlerElt) { String handlerClass = handlerElt.getAttributeValue(new QName("class")); if (handlerClass == null || "".equals(handlerClass)) { handleException("A handler element must have a class attribute"); handleException( "A Class mediator property must specify the name attribute"); } else { PropertyHelper.setInstanceProperty(propName, omElt, handler); } else { handleException("A Class mediator property must specify " + "name and value attributes, or a name and a child XML fragment"); handleException("Error initializing API handler: " + handlerClass, e);
public static API defineAPI(SynapseConfiguration config, OMElement elem) { API api = null; try { api = APIFactory.createAPI(elem); config.addAPI(api.getName(), api); } catch (Exception e) { String msg = "API configuration cannot be built"; handleConfigurationError(SynapseConstants.FAIL_SAFE_MODE_APIS, msg, e); } return api; }
/** * 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; }
API api = APIFactory.createAPI(artifactConfig); if (api != null) { api.setFileName((new File(fileName)).getName());
API api = APIFactory.createAPI(artifactConfig, properties); api.setArtifactContainerName(customLogContent); if (api != null) {
API api = APIFactory.createAPI(artifactConfig); if (api == null) { handleSynapseArtifactDeploymentError("API update failed. The artifact " +
@Override public String updateSynapseArtifact(OMElement artifactConfig, String fileName, String existingArtifactName, Properties properties) { API api = APIFactory.createAPI(artifactConfig, properties);
public void testAPISerialization3() throws Exception { String xml = "<api name=\"test\" context=\"/dictionary\" transports=\"https\" hostname=\"apache.org\" port=\"8243\"" + " xmlns=\"http://ws.apache.org/ns/synapse\"><resource url-mapping=\"/admin/view\" " + "inSequence=\"in\"><outSequence><log/><send/></outSequence></resource></api>"; OMElement om = AXIOMUtil.stringToOM(xml); API api = APIFactory.createAPI(om); OMElement out = APISerializer.serializeAPI(api); assertXMLEqual(xml, out.toString()); }
public void testAPISerialization1() throws Exception { String xml = "<api name=\"test\" context=\"/dictionary\" transports=\"https\" xmlns=\"http://ws.apache.org/ns/synapse\">" + "<resource url-mapping=\"/admin/view\" inSequence=\"in\" outSequence=\"out\"/></api>"; OMElement om = AXIOMUtil.stringToOM(xml); API api = APIFactory.createAPI(om); OMElement out = APISerializer.serializeAPI(api); assertXMLEqual(xml, out.toString()); }
public void testAPISerialization4() throws Exception { String xml = "<api name=\"test\" context=\"/dictionary\" transports=\"https\" hostname=\"apache.org\" port=\"8243\"" + " xmlns=\"http://ws.apache.org/ns/synapse\"><resource url-mapping=\"/admin/view\" " + "outSequence=\"out\"><inSequence><log/><send/></inSequence></resource></api>"; OMElement om = AXIOMUtil.stringToOM(xml); API api = APIFactory.createAPI(om); OMElement out = APISerializer.serializeAPI(api); assertXMLEqual(xml, out.toString()); }
public void testAPISerialization2() throws Exception { String xml = "<api name=\"test\" context=\"/dictionary\" transports=\"https\" hostname=\"apache.org\" port=\"8243\"" + " xmlns=\"http://ws.apache.org/ns/synapse\"><resource url-mapping=\"/admin/view\" " + "inSequence=\"in\" outSequence=\"out\"/></api>"; OMElement om = AXIOMUtil.stringToOM(xml); API api = APIFactory.createAPI(om); OMElement out = APISerializer.serializeAPI(api); assertXMLEqual(xml, out.toString()); }
public void testAPISerialization5() throws Exception { String xml = "<api name=\"test\" context=\"/dictionary\" transports=\"https\" hostname=\"apache.org\" port=\"8243\"" + " xmlns=\"http://ws.apache.org/ns/synapse\"><resource url-mapping=\"/admin/view/*\" " + "><inSequence><log/><send/></inSequence><outSequence><log/><send/></outSequence></resource>" + "<resource url-mapping=\"/admin/*\"><inSequence><log/><send/></inSequence><outSequence>" + "<log/><send/></outSequence></resource><resource uri-template=\"/{char}/{word}\">" + "<inSequence><send/></inSequence><faultSequence><log level=\"full\"/></faultSequence>" + "</resource></api>"; OMElement om = AXIOMUtil.stringToOM(xml); API api = APIFactory.createAPI(om); OMElement out = APISerializer.serializeAPI(api); assertXMLEqual(xml, out.toString()); } }