diff --git a/components/jaggery-apps/publisher/src/main/publisher/modules/api/add.jag b/components/jaggery-apps/publisher/src/main/publisher/modules/api/add.jag index 252142af4..4c76f47be 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/modules/api/add.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/modules/api/add.jag @@ -792,7 +792,7 @@ var isScopeExist = function (scope, username, roleName) { } catch (e) { log.error(e.message); return { - error:e + error:true }; } }; diff --git a/components/jaggery-apps/publisher/src/main/publisher/modules/search/search.jag b/components/jaggery-apps/publisher/src/main/publisher/modules/search/search.jag index 2775eea86..51c805719 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/modules/search/search.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/modules/search/search.jag @@ -1,9 +1,9 @@ <% -var searchAPIs = function (username,apiName, start, end) { +var searchAPIs = function (username,query, start, end) { var i,api,apis,length, result, log = new Log(), provider = jagg.module("manager").getAPIProviderObj(); try { - result = provider.searchPaginatedAPIs(username, apiName, start, end); + result = provider.searchPaginatedAPIs(username, query, start, end); if (log.isDebugEnabled()) { log.debug("searchAPI : " + stringify(apis)); } @@ -56,4 +56,4 @@ var searchAccessTokens = function (query) { }; } }; -%> \ No newline at end of file +%> diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/api-doc/ajax/get.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/api-doc/ajax/get.jag index 292e62730..a24367338 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/api-doc/ajax/get.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/api-doc/ajax/get.jag @@ -78,12 +78,20 @@ var log = new Log(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true); } - var APIUtil = Packages.org.wso2.carbon.apimgt.impl.utils.APIUtil; - var apiUtil = new APIUtil(); - var swaggerPath = apiUtil.getOpenAPIDefinitionFilePath(apiNameVal, apiVersionVal, providerVal); - var registry = carbon.server.osgiService('org.wso2.carbon.registry.core.service.RegistryService').getGovernanceUserRegistry(jagg.getUser(), tenantID); - url = swaggerPath + "swagger.json"; - data = registry.get(url); + var APIUtil = Packages.org.wso2.carbon.apimgt.impl.utils.APIUtil; + var apiUtil = new APIUtil(); + var swaggerPath = apiUtil.getOpenAPIDefinitionFilePath(apiNameVal, apiVersionVal, providerVal); + var user = jagg.getUser(); + if (user && user.username) { + var MultitenantUtils = Packages.org.wso2.carbon.utils.multitenancy.MultitenantUtils; + username = MultitenantUtils.getTenantAwareUsername(user.username); + } else { + username = "wso2.anonymous.user"; + } + var registry = carbon.server.osgiService('org.wso2.carbon.registry.core.service.RegistryService') + .getGovernanceUserRegistry(username, tenantID); + url = swaggerPath + "swagger.json"; + data = registry.get(url); } finally { if (isTenantFlowStarted) { PrivilegedCarbonContext.endTenantFlow(); diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/item-design/ajax/add.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/item-design/ajax/add.jag index 175c04db5..e1c96fe9c 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/item-design/ajax/add.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/item-design/ajax/add.jag @@ -50,6 +50,11 @@ var parseSwaggerDefinition = function (swagger) { return swaggerJson; } +var isSupportedOpenAPIVersion = function (version) { + // support for 3.0.x versions + return /^3\.0\.\d{1,}$/.test(version); +} + if(jagg.isCSRFTokenValid()) (function () { response.contentType = "text/plain; charset=UTF-8"; @@ -61,6 +66,8 @@ if(jagg.isCSRFTokenValid()) site = require("/site/conf/site.json"), msg = require("/site/conf/ui-messages.jag"), parser = new SwaggerParser(), + supportedSwaggerVersion = "2.0", + supportedOpenAPIVersion = "3.0.x", supportedHTTPMethods = ["get", "put", "post", "delete", "patch", "head", "options"]; if(jagg.getUser() == null){ @@ -74,8 +81,7 @@ if(jagg.isCSRFTokenValid()) var type = request.getParameter("type"); var swagger = null; var wsdl = null; - var supportedSwaggerVersion = "2.0"; - var supportedOpenAPIVersion = "3.0.0"; + var wsdlFile = null; var apiDefinitionVersion = request.getParameter("apiDefinitionVersion"); if(type == "rest"){ @@ -92,7 +98,7 @@ if(jagg.isCSRFTokenValid()) //released yet. var apiDefinition = parseSwaggerDefinition(swagger); if (apiDefinition.openapi) { - if (apiDefinition.openapi != supportedOpenAPIVersion) { + if (!isSupportedOpenAPIVersion(apiDefinition.openapi.trim())) { print({ error: true, message: "Unsupported OpenAPI version provided. Please re-import with OpenAPI " + @@ -150,7 +156,7 @@ if(jagg.isCSRFTokenValid()) if (apiDefinition.openapi) { //Supported Open API Version check - if (apiDefinition.openapi != supportedOpenAPIVersion) { + if (!isSupportedOpenAPIVersion(apiDefinition.openapi.trim())) { print({ error: true, message: "Unsupported OpenAPI version provided. Please re-import with OpenAPI " + @@ -204,11 +210,14 @@ if(jagg.isCSRFTokenValid()) } else if(type == "soap"){ var url = request.getParameter("wsdl-url"); - var file = request.getFile("wsdl-file"); + wsdlFile = request.getFile("wsdl-file"); var import_type = request.getParameter("import-definition"); var passThrough = request.getParameter("soap-options-pass-thru"); var rest = request.getParameter("soap-options-rest"); wsdl = "soap"; + if(wsdlFile) { + wsdl = wsdlFile.getName(); + } if(url){ wsdl = url.trim(); } @@ -222,191 +231,8 @@ if(jagg.isCSRFTokenValid()) if(resp) { mappingJson = JSON.parse(resp); session.put("mappingJson", mappingJson); - var names={},parameters=[]; - var definitions = {}; - for(var i = 0; i < mappingJson.length; i++) { - var responses = {},verb={},status={},description={},definition={}; - var httpverb = mappingJson[i].httpVerb.toLowerCase(); - var path = "/" + mappingJson[i].name; - description["description"] = ""; - status["200"] = description; - responses.tags = []; - responses.parameters = []; - responses["responses"]=status; - responses.tags.push(mappingJson[i].name); - var count = 0; - var properties = {}; - for(var j = 0; j < mappingJson[i].parameters.length; j++) { - var parameter = {}; - parameter.description = ""; - var type = mappingJson[i].parameters[j].dataType; - var isArray = mappingJson[i].parameters[j].isArray; - if(mappingJson[i].parameters[j].isComplexType) { - if(count == 0) { - parameter.in = "body"; - parameter.name = "Payload"; - var def = "#/definitions/" + mappingJson[i].name; - var ref = {}, typeObj = {}; - ref["$ref"] = def; - typeObj["type"] = "object"; - parameter.schema = ref; - - var defN = "#/definitions/" + mappingJson[i].parameters[j].name; - var refN = {}, typeNObj = {}; - refN["$ref"] = defN; - typeNObj["type"] = "object"; - - if(!definitions[mappingJson[i].name]) - definitions[mappingJson[i].name] = {}; - if(!definitions[mappingJson[i].parameters[j].name]) - definitions[mappingJson[i].parameters[j].name] = {}; - definitions[mappingJson[i].name] = typeObj; - definitions[mappingJson[i].parameters[j].name] = typeNObj; - var bodyParam = {}; - bodyParam[mappingJson[i].parameters[j].name] = refN; - definitions[mappingJson[i].name].properties = bodyParam; - } - var property = {}; - property.type = type; - if(isArray) { - property.type = "array"; - var itemType = {}; - itemType["type"] = type; - property.items = itemType; - properties[mappingJson[i].parameters[j].name] = property; - } else { - var root; - var buildTree = function(obj, parent) { - for(var k in obj) { - if(obj[k].wsdlComplexType && obj[k].wsdlComplexType.paramList) { - root = parent; - buildTree(obj[k].wsdlComplexType.paramList,obj[k]); - } else { - if(!definitions[mappingJson[i].parameters[j].name]) - definitions[mappingJson[i].parameters[j].name] = {}; - - if(root && root.name && parent.name) { - var rootDef = "#/definitions/" + root.name; - var parentDef = "#/definitions/" + parent.name; - if(!definitions[mappingJson[i].parameters[j].name].properties) { - definitions[mappingJson[i].parameters[j].name].properties = {}; - definitions[mappingJson[i].parameters[j].name].properties[root.name] = {}; - definitions[mappingJson[i].parameters[j].name].properties[root.name]["$ref"] = rootDef; - } - if(!definitions[root.name]) { - definitions[root.name] = {}; - definitions[root.name].type = "object"; - definitions[root.name].properties = {} - } - if(!definitions[parent.name]) { - definitions[parent.name] = {}; - definitions[parent.name].type = "object"; - definitions[parent.name].properties = {}; - } - if(parent.name != root.name) { - if(!definitions[root.name].properties[parent.name]) { - definitions[root.name].properties[parent.name] = {}; - } - if(!definitions[root.name].properties[parent.name]["$ref"]) { - definitions[root.name].properties[parent.name]["$ref"] = {}; - definitions[root.name].properties[parent.name]["$ref"] = parentDef; - } - } - if(!definitions[parent.name].properties[obj[k].name]) { - if(obj[k].isArray) { - definitions[parent.name].type = 'array'; - definitions[parent.name].items = {}; - definitions[parent.name].items.type = obj[k].dataType; - } else { - definitions[parent.name].properties[obj[k].name] = {}; - if(obj[k].dataType == 'int') { - definitions[parent.name].properties[obj[k].name].type = 'integer'; - } else { - definitions[parent.name].properties[obj[k].name].type = obj[k].dataType; - } - if(parent.name != root.name) { - definitions[parent.name].properties[obj[k].name]["x-path"] = root.name + "/" + parent.name + "/" + obj[k].name; - } else { - definitions[parent.name].properties[obj[k].name]["x-path"] = parent.name + "/" + obj[k].name; - } - } - } - - } else if(parent.name) { - var parentDef = "#/definitions/" + parent.name; - if(!definitions[parent.name]) { - definitions[parent.name] = {}; - definitions[parent.name].type = "object"; - definitions[parent.name].properties = {}; - } - if(!definitions[parent.name].properties[obj[k].name]) { - if(obj[k].isArray) { - definitions[parent.name].type = 'array'; - definitions[parent.name].items = {}; - definitions[parent.name].items.type = obj[k].dataType; - } else { - definitions[parent.name].properties[obj[k].name] = {}; - if(obj[k].dataType == 'int') { - definitions[parent.name].properties[obj[k].name].type = 'integer'; - } else { - definitions[parent.name].properties[obj[k].name].type = obj[k].dataType; - } - definitions[parent.name].properties[obj[k].name]["x-path"] = mappingJson[i].parameters[j].name + "/" + parent.name + "/" + obj[k].name; - } - } - if(!definitions[mappingJson[i].parameters[j].name].properties) { - definitions[mappingJson[i].parameters[j].name].properties = {}; - } - if(!definitions[mappingJson[i].parameters[j].name].properties[parent.name]) { - definitions[mappingJson[i].parameters[j].name].properties[parent.name] = {}; - definitions[mappingJson[i].parameters[j].name].properties[parent.name]["$ref"] = {}; - } - definitions[mappingJson[i].parameters[j].name].properties[parent.name]["$ref"] = parentDef; - - } else { - if(obj[k].isArray) { - definitions[mappingJson[i].parameters[j].name].type = 'array'; - definitions[mappingJson[i].parameters[j].name].items = {}; - definitions[mappingJson[i].parameters[j].name].items.type = obj[k].dataType; - } else { - if(!definitions[mappingJson[i].parameters[j].name].properties) { - definitions[mappingJson[i].parameters[j].name].properties = {}; - } - if(!definitions[mappingJson[i].parameters[j].name].properties[obj[k].name]) { - definitions[mappingJson[i].parameters[j].name].properties[obj[k].name] = {}; - } - if(obj[k].dataType == 'int') { - definitions[mappingJson[i].parameters[j].name].properties[obj[k].name].type = 'integer'; - } else { - definitions[mappingJson[i].parameters[j].name].properties[obj[k].name].type = obj[k].dataType; - } - definitions[mappingJson[i].parameters[j].name].properties[obj[k].name]["x-path"] = mappingJson[i].parameters[j].name + "/" + obj[k].name; - } - } - } - } - }; - buildTree(mappingJson[i].parameters[j].wsdlComplexType.paramList, - mappingJson[i].parameters[j].wsdlComplexType.paramList); - } - //definitions[mappingJson[i].parameters[j].name].properties = properties; - count++; - } else { - parameter.in = "query"; - parameter.name = mappingJson[i].parameters[j].name; - parameter.type = type; - } - - if(parameter.in) { - parameters.push(parameter); - responses.parameters.push(parameter); - } - } - verb[httpverb]=responses; - names[path]=verb; - } - session.put("paths", names); - session.put("definitions", definitions); + session.put("paths", mappingJson.paths); + session.put("definitions", mappingJson.definitions); } else { log.error("error occurred while soap to rest conversion.") } @@ -435,6 +261,13 @@ if(jagg.isCSRFTokenValid()) session.put("swagger",swagger); session.put("wsdl", wsdl); } + if(wsdlFile) { + session.put("ws",null); + session.put("swagger",swagger); + session.put("wsdl-file", wsdlFile); + } else { + session.remove("wsdl-file"); + } print({ error: false, @@ -471,9 +304,14 @@ if(jagg.isCSRFTokenValid()) return; } + var wsdlFile = request.getFile("wsdl-file"); + if(wsdlFile == null) { + wsdlFile = session.get("wsdl-file"); + } + //try to read the wsdl content from the url var wsdlUrl = request.getParameter("wsdl"); - if (wsdlUrl != null) { + if (wsdlFile == null && wsdlUrl != null) { if (!wsdlUrl.match(org.wso2.carbon.apimgt.impl.APIConstants.API_WSDL_RESOURCE_LOCATION)) { try { org.wso2.carbon.apimgt.impl.utils.APIUtil.isWSDL2Document(wsdlUrl); @@ -491,6 +329,15 @@ if(jagg.isCSRFTokenValid()) //If API not exist create result = mod.checkIfResourceExists(apiData); if(!result){ + // Check logged in user try to create api with different user name. + if(jagg.getUser().username != apiData.provider) { + obj = { + error:true, + message:"Not allowed to add APIs with different provider name other than logged in user." + }; + print(obj); + return; + } result = mod.createAPI(apiData); if (result.error==true) { obj = { @@ -511,6 +358,7 @@ if(jagg.isCSRFTokenValid()) apiData.visibility = request.getParameter("visibility"); apiData.visibleRoles = request.getParameter("roles","UTF-8"); apiData.wsdl = request.getParameter("wsdl"); + apiData.wsdlFile = wsdlFile; apiData.accessControl = request.getParameter("accessControl"); apiData.accessControlRoles = request.getParameter("accessControlRoles", "UTF-8"); apiData.additionalProperties = request.getParameter("additionalProperties", "UTF-8"); @@ -526,8 +374,10 @@ if(jagg.isCSRFTokenValid()) } if(isSoapToRestApi) { mappingJson = session.get("mappingJson"); - var sequenceGenerator = Packages.org.wso2.carbon.apimgt.impl.soaptorest.SequenceGenerator; - sequenceGenerator.generateSequences(stringify(apiData), stringify(mappingJson)); + if (mappingJson) { + var sequenceGenerator = Packages.org.wso2.carbon.apimgt.impl.soaptorest.SequenceGenerator; + sequenceGenerator.generateSequencesFromSwagger(apiData.swagger,stringify(apiData)); + } } } if (result.error == true) { @@ -609,8 +459,19 @@ if(jagg.isCSRFTokenValid()) } apiData.endpointUTPassword = decodedPassword.toString(); } else { - apiData.endpointUTPassword = session.get(request.getParameter("name", "UTF-8") + "-" + - request.getParameter("version") + "-epPassword"); + var encryptedPasswordFromSession = session.get(request.getParameter("name", "UTF-8") + "-" + + request.getParameter("version") + "-epPassword"); + if (encryptedPasswordFromSession) { + + var byteArray = CryptoUtil.getDefaultCryptoUtil().base64DecodeAndDecrypt(encryptedPasswordFromSession); + var decodedPassword = ""; + for(var index = 0; index < byteArray.length; index += 1) { + decodedPassword += String.fromCharCode(byteArray[index]); + } + apiData.endpointUTPassword = decodedPassword.toString(); + } else { + apiData.endpointUTPassword = encryptedPasswordFromSession; + } } apiData.endpoint_config= request.getParameter("endpoint_config","UTF-8"); apiData.destinationStats= request.getParameter("destinationStats","UTF-8"); @@ -920,23 +781,52 @@ if(jagg.isCSRFTokenValid()) print(apiDefinitionVersion); } else if (request.getMethod() === 'POST' && action === 'validateSwagger') { var swagger = request.getParameter("swaggerDefinition"); - var swaggerDeserializationResult = parser.readWithInfo(swagger); - var swaggerObj = swaggerDeserializationResult.getSwagger(); - var swaggerErrors = swaggerDeserializationResult.getMessages(); - if (swaggerErrors.size() > 0) { - print({ - error: true, - message: "API swagger definition is invalid. Please fix the suggested validation issues" - }); - return; - } else { - var swaggerJSON = JSON.parse(swagger); - if (swaggerJSON.paths) { - var swaggerPaths = swaggerJSON.paths; - for (var pathKey in swaggerPaths) { - var path = swaggerPaths[pathKey]; - for(var httpMethod in path){ - if(supportedHTTPMethods.indexOf(httpMethod.toLowerCase()) === -1){ + var apiDefinition = parseSwaggerDefinition(swagger); + + if (apiDefinition.swagger) { + var swaggerDeserializationResult = parser.readWithInfo(swagger); + var swaggerObj = swaggerDeserializationResult.getSwagger(); + var swaggerErrors = swaggerDeserializationResult.getMessages(); + + //Supported swagger version check + if (swaggerObj.swagger != supportedSwaggerVersion) { + print({ + error: true, + message: "Unsupported swagger version provided. Please re-import with swagger " + supportedSwaggerVersion + }); + return; + } + + if (swaggerErrors.size() > 0) { + print({ + error: true, + message: "API swagger definition is invalid. Please fix the suggested validation issues" + }); + return; + } else { + var swaggerJSON = JSON.parse(swagger); + if (swaggerJSON.paths) { + var swaggerPaths = swaggerJSON.paths; + for (var pathKey in swaggerPaths) { + var path = swaggerPaths[pathKey]; + var globalParametersDefined = false; + var httpMethodsDefined = false; + for (var httpMethod in path) { + if (httpMethod == "parameters") { + globalParametersDefined = true; + continue; + } else if (supportedHTTPMethods.indexOf(httpMethod.toLowerCase()) === -1) { + print({ + error: true, + message: "The HTTP method '" + httpMethod + "' provided for resource '" + pathKey + "' is invalid" + + }); + return; + } else { + httpMethodsDefined = true; + } + } + if (globalParametersDefined && !httpMethodsDefined) { print({ error: true, message: "The HTTP method '" + httpMethod + "' provided for resource '" + pathKey + "' is invalid" @@ -946,11 +836,36 @@ if(jagg.isCSRFTokenValid()) } } } + print({ + error: false + }) + } + } else if (apiDefinition.openapi){ + //Supported Open API Version check + if (!isSupportedOpenAPIVersion(apiDefinition.openapi.trim())) { + print({ + error: true, + message: "Unsupported OpenAPI version provided. Please re-import with OpenAPI " + + supportedOpenAPIVersion + }); + return; + } + + if (apiDefinition.info == null || apiDefinition.paths == null) { + print({ + error: true, + message: "Required property 'info' or 'paths' are not provided" + }); + return; } print({ error: false }) + } else { + print({error: true, message: "Invalid Open API definition provided"}); + return; } + } else { print({ error:true, diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/listing/block.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/listing/block.jag index e0eb87008..46143b9a1 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/listing/block.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/listing/block.jag @@ -33,6 +33,9 @@ jagg.block("listing", { var currentPage = page; var start = itemsPerPage*(page-1); if (query) { + if (query.indexOf(':') == -1) { + query = "content:" + query; + } mod = jagg.module("search"); result = mod.searchAPIs(null,query,String(start),String(itemsPerPage)); apis = null; @@ -51,7 +54,11 @@ jagg.block("listing", { if (result.response != null) { apis = result.response.apis; length = result.response.totalLength; - error = result.error; + if (!result.error) { + error = result.error; + } else { + error = true; + } message = result.message; mode = "listing"; } diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tag/ajax/tag.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tag/ajax/tag.jag index 33607767e..3990aafee 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tag/ajax/tag.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tag/ajax/tag.jag @@ -13,7 +13,7 @@ include("/jagg/jagg.jag"); result = mod.getAllTags(); if (result.error) { obj = { - error:result.error, + error:true, message:msg.error.backendError(action) }; } else { @@ -31,4 +31,4 @@ include("/jagg/jagg.jag"); }); } }()); -%> \ No newline at end of file +%> diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tiers/ajax/tiers.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tiers/ajax/tiers.jag index 51bf00d2a..28e5e4a42 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tiers/ajax/tiers.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/tiers/ajax/tiers.jag @@ -28,7 +28,7 @@ if(jagg.isCSRFTokenValid()) result = mod.updateTierPermissions(tierPermission); if (result.error) { obj = { - error:result.error, + error:true, message:result.message }; } else { @@ -48,4 +48,4 @@ if(jagg.isCSRFTokenValid()) } }()); %> -%> \ No newline at end of file +%> diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/usage/ajax/usage.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/usage/ajax/usage.jag index c3e6bc660..a08b2e0d4 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/usage/ajax/usage.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/usage/ajax/usage.jag @@ -21,7 +21,7 @@ include("/jagg/jagg.jag"); result = mod.getProviderAPIVersionUsage(provider, apiName); if (result.error) { obj = { - error:result.error, + error:true, message:msg.error.backendError(action) }; } else { @@ -94,4 +94,4 @@ include("/jagg/jagg.jag"); } } }()); -%> \ No newline at end of file +%> diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/users-api/ajax/subscriptions.jag b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/users-api/ajax/subscriptions.jag index 04893d922..f88d033ff 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/blocks/users-api/ajax/subscriptions.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/blocks/users-api/ajax/subscriptions.jag @@ -27,7 +27,7 @@ if(jagg.isCSRFTokenValid()) result = mod.updateSubscription(api, appId,newStatus); if (result.error) { obj = { - error:result.error, + error:true, message:result.message }; } else { @@ -44,4 +44,4 @@ if(jagg.isCSRFTokenValid()) } } }()); -%> \ No newline at end of file +%> diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_default.json b/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_default.json index 4b2fe1d31..ee1f0d57c 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_default.json +++ b/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_default.json @@ -549,7 +549,9 @@ "Visible to my Domain": "Visible to my Domain", "WADL": "WADL", "WSDL": "WSDL", + "WSDL Archive/File": "WSDL Archive/File", "WSDL Endpoint": "WSDL Endpoint", + "WSDL Url" : "WSDL Url", "WSO2 API Manager uses HTTP Head to check the validity of the endpoint.": "WSO2 API Manager uses HTTP Head to check the validity of the endpoint.", "WSO2 API Publisher Home": "WSO2 API Publisher Home", "WSO2 copyright": "WSO2 copyright", @@ -645,5 +647,7 @@ "Delete Task" : "Delete Task", "Authorization Header": "Authorization Header", "Here a custom authorization header can be defined as a replacement to the default Authorization header used to send a request. If a value is specified here, that will be used as the header field to send the access token in a request to consume the API": "A custom authorization header can be defined here as a replacement to the default Authorization header used to send a request. If a value is specified here, it will be used as the header field to send the access token in a request to consume the API", - "You have selected Microgateways for this API. The mediation policies selected here will not be applied in Microgateway environments.":"You have selected Microgateways for this API. The mediation policies selected here will not be applied in Microgateway environments." + "You have selected Microgateways for this API. The mediation policies selected here will not be applied in Microgateway environments.":"You have selected Microgateways for this API. The mediation policies selected here will not be applied in Microgateway environments.", + "Deprecate old versions after publish the API": "Deprecate old versions after publish the API", + "Requires re-subscription when publish the API": "Requires re-subscription when publish the API" } diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_en.json b/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_en.json index bcc5627aa..823cc121c 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_en.json +++ b/components/jaggery-apps/publisher/src/main/publisher/site/conf/locales/jaggery/locale_en.json @@ -545,7 +545,9 @@ "Visible to my Domain": "Visible to my Domain", "WADL": "WADL", "WSDL": "WSDL", + "WSDL Archive/File": "WSDL Archive/File", "WSDL Endpoint": "WSDL Endpoint", + "WSDL Url" : "WSDL Url", "WSO2 API Manager uses HTTP Head to check the validity of the endpoint.": "WSO2 API Manager uses HTTP Head to check the validity of the endpoint.", "WSO2 API Publisher Home": "WSO2 API Publisher Home", "WSO2 copyright": "WSO2 copyright", @@ -616,5 +618,8 @@ "You must select a mediation policy to download": "You must select a mediation policy to download.", "Error while retrieving the selected mediation policy": "Error while retrieving the selected mediation policy.", "API swagger definition is invalid" : "API swagger definition is invalid", - "Error while updating API swagger definition" : "Error while updating API swagger definition" + "Error while updating API swagger definition" : "Error while updating API swagger definition", + "Download Document" : "Download Document", + "View Document" : "View Document", + "Document" : "Document" } diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/css/custom.css b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/css/custom.css index 1da5498d3..884648b10 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/css/custom.css +++ b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/css/custom.css @@ -160,6 +160,53 @@ input.ep-field{ min-width:155px; } +.document-match-icon { + position:center; + opacity:1; +} + +.square-element .document-match-icon{ + display:block; + background:rgba(0, 0, 0, 0.3); + width:100%; + height:100%; + position:absolute; +} + +.square-element .document-match-icon i{ + padding:2px; + font-size:6vw; + position:absolute; + top:30%; + left:30%; + width:40%; + height:40%; +} + +.thumbnail .square-element{ + background-color:white; +} + +.app-data #document-match{ + margin-bottom: 0px +} + +.app-data #doc-name a{ + color:#ce8c2f; +} + +.app-data #document-type-label{ + text-transform: capitalize; +} + +.app-data #document-type-label{ + text-transform: capitalize; +} + + + + + /* ============================================================================= * Wso2.telco styles diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/js/item-add.js b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/js/item-add.js index 9bfa9da76..29490dfb0 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/js/item-add.js +++ b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/js/item-add.js @@ -147,7 +147,8 @@ $( document ).ready(function() { $("#startFromExistingSOAPEndpoint").click(function(){ var wsdlURL = $('#wsdl-url').val(); - if (wsdlURL.trim() == "" || wsdlURL.toLowerCase().indexOf("wsdl") < 0) { + var wsdlFile = $('#wsdl-file').val(); + if ( wsdlFile.trim() == "" && (wsdlURL.trim() == "" || wsdlURL.toLowerCase().indexOf("wsdl") < 0)) { $('#wsdl-url').addClass('error'); $('.wsdlError').show(); console.log("Wrong endpoint."); @@ -231,6 +232,18 @@ $( document ).ready(function() { }); }); + $('input[type=radio][name=wsdl-options-select]').change(function() { + if(this.value === 'url') { + $('#wsdl-url-section').show(); + $('#wsdl-file-section').hide(); + $('input[name=soap-options-rest]').attr("disabled",false); + } else if(this.value === 'archive') { + $('#wsdl-url-section').hide(); + $('#wsdl-file-section').show(); + $('input[name=soap-options-rest]').attr("disabled",true); + } + }); + $('.toggleContainers .controls').hide(); $('.toggleRadios input[type=radio]').prop('checked', false); $('.toggleRadios input[type=radio]').click(function(){ diff --git a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/template.jag b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/template.jag index 11a0b8a6b..f4c7cdb05 100644 --- a/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/template.jag +++ b/components/jaggery-apps/publisher/src/main/publisher/site/themes/wso2/templates/item-add/template.jag @@ -95,11 +95,36 @@