Search in sources :

Example 36 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-apimgt by wso2.

the class WSDL11SOAPOperationExtractor method getSoapOutputParameterModel.

/**
 * Gets swagger output parameter model for a given soap operation
 *
 * @param bindingOperation soap operation
 * @return list of swagger models for the parameters
 * @throws APIMgtWSDLException
 */
private List<ModelImpl> getSoapOutputParameterModel(BindingOperation bindingOperation) throws APIMgtWSDLException {
    List<ModelImpl> outputParameterModelList = new ArrayList<>();
    Operation operation = bindingOperation.getOperation();
    if (operation != null) {
        Output output = operation.getOutput();
        if (output != null) {
            Message message = output.getMessage();
            if (message != null) {
                Map map = message.getParts();
                for (Object obj : map.entrySet()) {
                    Map.Entry entry = (Map.Entry) obj;
                    Part part = (Part) entry.getValue();
                    if (part != null) {
                        if (part.getElementName() != null) {
                            outputParameterModelList.add(parameterModelMap.get(part.getElementName().getLocalPart()));
                        } else {
                            if (part.getTypeName() != null && parameterModelMap.containsKey(part.getTypeName().getLocalPart())) {
                                outputParameterModelList.add(parameterModelMap.get(part.getTypeName().getLocalPart()));
                            } else {
                                ModelImpl model = new ModelImpl();
                                model.setType(ObjectProperty.TYPE);
                                model.setName(message.getQName().getLocalPart());
                                if (getPropertyFromDataType(part.getTypeName().getLocalPart()) instanceof RefProperty) {
                                    RefProperty property = (RefProperty) getPropertyFromDataType(part.getTypeName().getLocalPart());
                                    property.set$ref(SOAPToRESTConstants.Swagger.DEFINITIONS_ROOT + part.getTypeName().getLocalPart());
                                    model.addProperty(part.getName(), property);
                                } else {
                                    model.addProperty(part.getName(), getPropertyFromDataType(part.getTypeName().getLocalPart()));
                                }
                                parameterModelMap.put(model.getName(), model);
                                outputParameterModelList.add(model);
                            }
                        }
                    }
                }
            }
        }
    }
    return outputParameterModelList;
}
Also used : Message(javax.wsdl.Message) Part(javax.wsdl.Part) Output(javax.wsdl.Output) ArrayList(java.util.ArrayList) Operation(javax.wsdl.Operation) SOAP12Operation(javax.wsdl.extensions.soap12.SOAP12Operation) WSDLSOAPOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLSOAPOperation) BindingOperation(javax.wsdl.BindingOperation) SOAPOperation(javax.wsdl.extensions.soap.SOAPOperation) WSDLOperation(org.wso2.carbon.apimgt.impl.wsdl.model.WSDLOperation) ModelImpl(io.swagger.models.ModelImpl) Map(java.util.Map) HashMap(java.util.HashMap) NamedNodeMap(org.w3c.dom.NamedNodeMap) RefProperty(io.swagger.models.properties.RefProperty)

Example 37 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-apimgt by wso2.

the class APIProviderImplTest method getLCBean.

private LifecycleBean getLCBean() {
    LifecycleBean bean = new LifecycleBean();
    List<Property> lifecycleProps = new ArrayList<Property>();
    Property property1 = new Property();
    property1.setKey("registry.custom_lifecycle.checklist.option.APILifeCycle.1.item");
    String[] values1 = { "status:Created", "name:Requires re-subscription when publishing the API", "value:false", "order:1" };
    property1.setValues(values1);
    Property property2 = new Property();
    property2.setKey("registry.lifecycle.APILifeCycle.state");
    String[] values2 = { "Created" };
    property2.setValues(values2);
    Property property3 = new Property();
    property3.setKey("registry.custom_lifecycle.checklist.option.APILifeCycle.0.item.permission");
    String[] values3 = { "registry.custom_lifecycle.checklist.option.APILifeCycle.0.item.permission" };
    property3.setValues(values3);
    Property property4 = new Property();
    property4.setKey("registry.lifecycle.APILifeCycle.lastStateUpdatedTime");
    String[] values4 = { "2017-08-31 13:36:54.501" };
    property4.setValues(values4);
    Property property5 = new Property();
    property5.setKey("registry.custom_lifecycle.checklist.option.APILifeCycle.1.item.permission");
    String[] values5 = { "registry.custom_lifecycle.checklist.option.APILifeCycle.1.item.permission" };
    property5.setValues(values5);
    Property property6 = new Property();
    property6.setKey("registry.custom_lifecycle.checklist.option.APILifeCycle.0.item");
    String[] values6 = { "status:Created", "name:Deprecate old versions after publishing the API", "value:false", "order:0" };
    property6.setValues(values6);
    Property property7 = new Property();
    property7.setKey("registry.LC.name");
    String[] values7 = { "APILifeCycle" };
    property7.setValues(values7);
    lifecycleProps.add(property1);
    lifecycleProps.add(property2);
    lifecycleProps.add(property3);
    lifecycleProps.add(property4);
    lifecycleProps.add(property5);
    lifecycleProps.add(property6);
    Property[] propertyArr = new Property[lifecycleProps.size()];
    bean.setLifecycleProperties(lifecycleProps.toArray(propertyArr));
    String[] userRoles = { "publisher" };
    bean.setRolesOfUser(userRoles);
    return bean;
}
Also used : ArrayList(java.util.ArrayList) LifecycleBean(org.wso2.carbon.governance.custom.lifecycles.checklist.beans.LifecycleBean) Property(org.wso2.carbon.governance.custom.lifecycles.checklist.util.Property)

Example 38 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-apimgt by wso2.

the class JMSTaskManagerFactory method createTaskManagerForService.

/**
 * Create a ServiceTaskManager for the service passed in and its corresponding JMSConnectionFactory
 *
 * @param jcf        JMS Connection factory definition
 * @param name       JMS consumer name
 * @param workerPool Shared thread pool from the Listener
 * @param svc        JNDI context properties and other general properties
 * @return JMSTaskManager instance
 */
public static JMSTaskManager createTaskManagerForService(JMSConnectionFactory jcf, String name, WorkerPool workerPool, Map<String, String> svc) {
    Map<String, String> cf = jcf.getParameters();
    JMSTaskManager stm = new JMSTaskManager();
    stm.setJmsConsumerName(name);
    stm.addJmsProperties(cf);
    stm.addJmsProperties(svc);
    stm.setConnFactoryJNDIName(getRqdStringProperty(JMSConstants.PARAM_CONFAC_JNDI_NAME, svc, cf));
    String destName = getOptionalStringProperty(JMSConstants.PARAM_DESTINATION, svc, cf);
    if (destName == null) {
        destName = name;
    }
    stm.setDestinationJNDIName(destName);
    stm.setDestinationType(getDestinationType(svc, cf));
    if (getOptionalBooleanProperty(JMSConstants.PARAM_SUB_DURABLE, svc, cf) != null && getOptionalBooleanProperty(JMSConstants.PARAM_SUB_DURABLE, svc, cf)) {
        stm.setDurableSubscriberClientId(getRqdStringProperty(JMSConstants.PARAM_DURABLE_SUB_CLIENT_ID, svc, cf));
    }
    stm.setJmsSpec11(getJMSSpecVersion(svc, cf));
    stm.setTransactionality(getTransactionality(svc, cf));
    stm.setCacheUserTransaction(getOptionalBooleanProperty(BaseConstants.PARAM_CACHE_USER_TXN, svc, cf));
    stm.setUserTransactionJNDIName(getOptionalStringProperty(BaseConstants.PARAM_USER_TXN_JNDI_NAME, svc, cf));
    stm.setSessionTransacted(getOptionalBooleanProperty(JMSConstants.PARAM_SESSION_TRANSACTED, svc, cf));
    stm.setSessionAckMode(getSessionAck(svc, cf));
    stm.setMessageSelector(getOptionalStringProperty(JMSConstants.PARAM_MSG_SELECTOR, svc, cf));
    stm.setSubscriptionDurable(getOptionalBooleanProperty(JMSConstants.PARAM_SUB_DURABLE, svc, cf));
    stm.setDurableSubscriberName(getOptionalStringProperty(JMSConstants.PARAM_DURABLE_SUB_NAME, svc, cf));
    stm.setCacheLevel(getCacheLevel(svc, cf));
    stm.setPubSubNoLocal(getOptionalBooleanProperty(JMSConstants.PARAM_PUBSUB_NO_LOCAL, svc, cf));
    Integer value = getOptionalIntProperty(JMSConstants.PARAM_RCV_TIMEOUT, svc, cf);
    if (value != null) {
        stm.setReceiveTimeout(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_CONCURRENT_CONSUMERS, svc, cf);
    if (value != null) {
        stm.setConcurrentConsumers(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_MAX_CONSUMERS, svc, cf);
    if (value != null) {
        stm.setMaxConcurrentConsumers(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_IDLE_TASK_LIMIT, svc, cf);
    if (value != null) {
        stm.setIdleTaskExecutionLimit(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_MAX_MSGS_PER_TASK, svc, cf);
    if (value != null) {
        stm.setMaxMessagesPerTask(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_RECON_INIT_DURATION, svc, cf);
    if (value != null) {
        stm.setInitialReconnectDuration(value);
    }
    value = getOptionalIntProperty(JMSConstants.PARAM_RECON_MAX_DURATION, svc, cf);
    if (value != null) {
        stm.setMaxReconnectDuration(value);
    }
    Double dValue = getOptionalDoubleProperty(JMSConstants.PARAM_RECON_FACTOR, svc, cf);
    if (dValue != null) {
        stm.setReconnectionProgressionFactor(dValue);
    }
    stm.setWorkerPool(workerPool);
    // remove processed properties from property bag
    stm.removeJmsProperties(JMSConstants.PARAM_CONFAC_JNDI_NAME);
    stm.removeJmsProperties(JMSConstants.PARAM_DESTINATION);
    stm.removeJmsProperties(JMSConstants.PARAM_JMS_SPEC_VER);
    stm.removeJmsProperties(BaseConstants.PARAM_TRANSACTIONALITY);
    stm.removeJmsProperties(BaseConstants.PARAM_CACHE_USER_TXN);
    stm.removeJmsProperties(BaseConstants.PARAM_USER_TXN_JNDI_NAME);
    stm.removeJmsProperties(JMSConstants.PARAM_SESSION_TRANSACTED);
    stm.removeJmsProperties(JMSConstants.PARAM_MSG_SELECTOR);
    stm.removeJmsProperties(JMSConstants.PARAM_SUB_DURABLE);
    stm.removeJmsProperties(JMSConstants.PARAM_DURABLE_SUB_NAME);
    stm.removeJmsProperties(JMSConstants.PARAM_CACHE_LEVEL);
    stm.removeJmsProperties(JMSConstants.PARAM_PUBSUB_NO_LOCAL);
    stm.removeJmsProperties(JMSConstants.PARAM_RCV_TIMEOUT);
    stm.removeJmsProperties(JMSConstants.PARAM_CONCURRENT_CONSUMERS);
    stm.removeJmsProperties(JMSConstants.PARAM_MAX_CONSUMERS);
    stm.removeJmsProperties(JMSConstants.PARAM_IDLE_TASK_LIMIT);
    stm.removeJmsProperties(JMSConstants.PARAM_MAX_MSGS_PER_TASK);
    stm.removeJmsProperties(JMSConstants.PARAM_RECON_INIT_DURATION);
    stm.removeJmsProperties(JMSConstants.PARAM_RECON_MAX_DURATION);
    stm.removeJmsProperties(JMSConstants.PARAM_RECON_FACTOR);
    stm.removeJmsProperties(JMSConstants.PARAM_DURABLE_SUB_CLIENT_ID);
    return stm;
}
Also used : JMSTaskManager(org.wso2.carbon.apimgt.common.jms.JMSTaskManager)

Example 39 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-apimgt by wso2.

the class JMSTaskManagerFactory method getTransactionality.

/**
 * @param svcMap JNDI context properties and other general property map
 * @param cfMap  properties defined on the JMS CF
 * @return value for the specific transactionality type
 */
private static int getTransactionality(Map<String, String> svcMap, Map<String, String> cfMap) {
    String key = BaseConstants.PARAM_TRANSACTIONALITY;
    String val = svcMap.get(key);
    if (val == null) {
        val = cfMap.get(key);
    }
    if (val == null) {
        return BaseConstants.TRANSACTION_NONE;
    } else {
        if (BaseConstants.STR_TRANSACTION_JTA.equalsIgnoreCase(val)) {
            return BaseConstants.TRANSACTION_JTA;
        } else if (BaseConstants.STR_TRANSACTION_LOCAL.equalsIgnoreCase(val)) {
            return BaseConstants.TRANSACTION_LOCAL;
        } else {
            throw new JmsRunTimeException("Invalid option : " + val + " for parameter : " + BaseConstants.STR_TRANSACTION_JTA);
        // TODO fix it
        // return 0;
        }
    }
}
Also used : JmsRunTimeException(org.wso2.carbon.apimgt.common.jms.JmsRunTimeException)

Example 40 with Property

use of org.wso2.carbon.event.output.adapter.core.Property in project carbon-apimgt by wso2.

the class APIManagerConfigurationTest method testEnvironmentsConfigWithAdditionalProperties.

@Test
public void testEnvironmentsConfigWithAdditionalProperties() throws XMLStreamException, APIManagementException {
    String envConfig = "<Environment type=\"hybrid\" api-console=\"true\" isDefault=\"true\">\n" + "                <Name>Default</Name>\n" + "                <DisplayName></DisplayName>\n" + "                <Description>This is a hybrid gateway that handles both production and sandbox token traffic.</Description>\n" + "                <!-- Server URL of the API gateway -->\n" + "                <ServerURL>https://localhost:9440/services/</ServerURL>\n" + "                <!-- Admin username for the API gateway. -->\n" + "                <Username>${admin.username}</Username>\n" + "                <!-- Admin password for the API gateway.-->\n" + "                <Password>${admin.password}</Password>\n" + "                <!-- Provider Vendor of the API gateway.-->\n" + "                <Provider>wso2</Provider>\n" + "                <!-- Endpoint URLs for the APIs hosted in this API gateway.-->\n" + "                <GatewayEndpoint>https://localhost:9440,http://localhost:9440</GatewayEndpoint>\n" + "                <!-- Additional properties for External Gateways -->\n" + "                <!-- Endpoint URLs of the WebSocket APIs hosted in this API Gateway -->\n" + "                <GatewayWSEndpoint>ws://localhost:9099,wss://localhost:8099</GatewayWSEndpoint>\n" + "                <!-- Endpoint URLs of the WebSub APIs hosted in this API Gateway -->\n" + "                <GatewayWebSubEndpoint>http://localhost:9021,https://localhost:8021</GatewayWebSubEndpoint>\n" + "                <Properties>\n" + "                    <Property name=\"Organization\">WSO2</Property>\n" + "                    <Property name=\"DisplayName\">Development Environment</Property>\n" + "                    <Property name=\"DevAccountName\">dev-1</Property>\n" + "                </Properties>\n" + "                <VirtualHosts>\n" + "                </VirtualHosts>\n" + "            </Environment>";
    OMElement element = AXIOMUtil.stringToOM(envConfig);
    APIManagerConfiguration config = new APIManagerConfiguration();
    config.setEnvironmentConfig(element);
    Map<String, Environment> environmentsList = config.getGatewayEnvironments();
    Assert.assertFalse(environmentsList.isEmpty());
    Environment defaultEnv = environmentsList.get("Default");
    Assert.assertFalse(defaultEnv.getAdditionalProperties().isEmpty());
}
Also used : Environment(org.wso2.carbon.apimgt.api.model.Environment) OMElement(org.apache.axiom.om.OMElement) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)42 ArrayList (java.util.ArrayList)32 APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)32 Resource (org.wso2.carbon.registry.core.Resource)23 Map (java.util.Map)21 Test (org.junit.Test)21 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)21 DataResponse (org.wso2.carbon.bpmn.rest.model.common.DataResponse)17 API (org.wso2.carbon.apimgt.api.model.API)16 UserStoreException (org.wso2.carbon.user.api.UserStoreException)16 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 JSONObject (org.json.simple.JSONObject)14 APIIdentifier (org.wso2.carbon.apimgt.api.model.APIIdentifier)14 List (java.util.List)13 IOException (java.io.IOException)11 QName (javax.xml.namespace.QName)11 APIProductResource (org.wso2.carbon.apimgt.api.model.APIProductResource)11 Properties (java.util.Properties)10 GovernanceException (org.wso2.carbon.governance.api.exception.GovernanceException)10