Merge pull request #688 from amalhub/master

Cherry-pick from Cloud 3.1.0
revert-70aa11f8
Kamidu Sachith Punchihewa 8 years ago committed by GitHub
commit b766925fc5

@ -46,7 +46,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
private static final int MAX_API_PER_TAG = 200; private static final int MAX_API_PER_TAG = 200;
private static final String APP_TIER_TYPE = "application"; private static final String APP_TIER_TYPE = "application";
private static final Map<String, String> tiersMap = new HashMap<>(); private static final Map<String, String> tiersMap = new HashMap<>();
private static final int MAX_ATTEMPTS = 10; private static final int MAX_ATTEMPTS = 20;
@Override @Override
public void removeAPIApplication(String applicationName, String username) throws APIManagerException { public void removeAPIApplication(String applicationName, String username) throws APIManagerException {
@ -76,18 +76,18 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext() String tenantDomain = PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain(); .getTenantDomain();
String tiersLoadedForTenant = tiersMap.get(tenantDomain); String tiersLoadedForTenant = tiersMap.get(tenantDomain);
if (tiersLoadedForTenant == null) { if (tiersLoadedForTenant == null) {
int tierStatus = 0; boolean tierLoaded = false;
int attempts = 0; int attempts = 0;
do { do {
try { try {
storeClient.getIndividualTier() storeClient.getIndividualTier()
.tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APP_TIER_TYPE, .tiersTierLevelTierNameGet(ApiApplicationConstants.DEFAULT_TIER, APP_TIER_TYPE,
tenantDomain, CONTENT_TYPE, null, null); tenantDomain, CONTENT_TYPE, null, null);
tiersMap.put(tenantDomain, "exist"); tiersMap.put(tenantDomain, "exist");
tierStatus = 200; tierLoaded = true;
} catch (FeignException e) { } catch (FeignException e) {
tierStatus = e.status();
attempts++; attempts++;
try { try {
Thread.sleep(500); Thread.sleep(500);
@ -95,7 +95,7 @@ public class APIManagementProviderServiceImpl implements APIManagementProviderSe
log.warn("Interrupted the waiting for tier availability."); log.warn("Interrupted the waiting for tier availability.");
} }
} }
} while (tierStatus == 500 && attempts < MAX_ATTEMPTS); } while ((!tierLoaded) && attempts < MAX_ATTEMPTS);
} }
ApplicationList applicationList = storeClient.getApplications() ApplicationList applicationList = storeClient.getApplications()

@ -65,8 +65,7 @@ public class DeviceTypeManagerService implements DeviceManagementService {
this.operationMonitoringConfigs = new OperationMonitoringTaskConfig(); this.operationMonitoringConfigs = new OperationMonitoringTaskConfig();
this.setOperationMonitoringConfig(deviceTypeConfiguration); this.setOperationMonitoringConfig(deviceTypeConfiguration);
this.setInitialOperationConfig(deviceTypeConfiguration); this.setInitialOperationConfig(deviceTypeConfiguration);
if (deviceTypeConfiguration.getPolicyMonitoring() != null && deviceTypeConfiguration.getPolicyMonitoring() if (deviceTypeConfiguration.getPolicyMonitoring() != null ) {
.isEnabled()) {
this.policyMonitoringManager = new DefaultPolicyMonitoringManager(); this.policyMonitoringManager = new DefaultPolicyMonitoringManager();
} }
} }

@ -1,7 +1,7 @@
{ {
"Logo": { "Logo": {
"name": "Cloud", "name": "Cloud",
"url": "https://<%= @cloudmgt_host %>/cloudmgt", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt",
"target": "_parent" "target": "_parent"
}, },
"Main": { "Main": {
@ -12,75 +12,21 @@
"target": "_parent", "target": "_parent",
"dropDown": { "dropDown": {
"Organization": { "Organization": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/organization.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization", "icon": "fw fw-organization",
"dropDown": "false", "dropDown": "false",
"target": "_self" "target": "_self"
}, },
"Members": { "Members": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users", "icon": "fa fa-users",
"dropDown": "false", "dropDown": "false",
"target": "_self" "target": "_self"
} }
} }
}, },
"Account": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/account-summary.jag",
"icon": "fw fw-resource",
"isAdminOnly": true,
"target": "_blank",
"dropDown": {
"Upgrade Now": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/payment-plans.jag?cloud-type=api_cloud",
"icon": "fw fw-export",
"target": "_self"
},
"Monetization": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/monetization-dashboard.jag",
"icon": "fa fa-money fa-lg",
"dropDown": "false",
"target": "_self"
},
"Request Extension": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/contact-us.jag?cloud-type=api_cloud&request-extension=true",
"icon": "fw fw-mail",
"target": "_blank"
},
"Usage data": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/tenant-usage.jag?cloud-type=api_cloud",
"icon": "fw fw-bar-chart",
"target": "_self"
}
}
},
"Configure": {
"url": "none",
"icon": "fw fw-settings",
"isAdminOnly": true,
"dropDown": {
"Admin Dashboard": {
"id": "admin-dashboard",
"url": "https://<%= @apimpublisher_host %>/admin-dashboard/",
"icon": "fw fw-user",
"target": "_self"
},
"Custom URL": {
"id": "custom-url",
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/custom_url.jag",
"icon": "fw fw-uri",
"target": "_self"
},
"API Store Access": {
"id": "custom-url",
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/selfSignup.jag",
"icon": "fw fw-store",
"target": "_self"
}
}
},
"Support": { "Support": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/contact-us.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/contact-us.jag",
"icon": "fw fw-mail", "icon": "fw fw-mail",
"isAdminOnly": false, "isAdminOnly": false,
"target": "_self", "target": "_self",
@ -91,29 +37,11 @@
"icon": "fw fw-document", "icon": "fw fw-document",
"isAdminOnly": false, "isAdminOnly": false,
"dropDown": { "dropDown": {
"API Cloud": {
"id": "api_cloud",
"url": "https://docs.wso2.com/display/APICloud/WSO2+API+Cloud+Documentation",
"icon": "fw fw-api",
"target": "_blank"
},
"Integration Cloud": {
"id": "integration_cloud",
"url": "https://docs.wso2.com/display/IntegrationCloud/WSO2+Integration+Cloud+Documentation",
"icon": "fw fw-application",
"target": "_blank"
},
"Device Cloud": { "Device Cloud": {
"id": "device_cloud", "id": "device_cloud",
"url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation", "url": "https://docs.wso2.com/display/DeviceCloud/WSO2+Device+Cloud+Documentation",
"icon": "fw fw-mobile", "icon": "fw fw-mobile",
"target": "_self" "target": "_self"
},
"API Cloud Walkthrough": {
"id": "api_cloud_walkthrough",
"url": "https://<%= @apimpublisher_host %>/publisher?interactiveTutorial=true",
"icon": "fw fw-document",
"target": "_self"
} }
} }
} }
@ -123,19 +51,19 @@
"icon": "fw fw-user", "icon": "fw fw-user",
"dropDown": { "dropDown": {
"Profile": { "Profile": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user-profile.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user-profile.jag",
"icon": "fw fw-user", "icon": "fw fw-user",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
}, },
"Change Password": { "Change Password": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/change-password.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/change-password.jag",
"icon": "fw fw-lock", "icon": "fw fw-lock",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
}, },
"Logout": { "Logout": {
"url": "https://<%= @apimpublisher_host %>/publisher/site/pages/logout.jag", "url": "https://api.cloud.wso2.com/publisher/site/pages/logout.jag",
"icon": "fw fw-sign-out", "icon": "fw fw-sign-out",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
@ -146,50 +74,36 @@
"Clouds": { "Clouds": {
"API Cloud": { "API Cloud": {
"id": "api_cloud", "id": "api_cloud",
"url": "https://<%= @apimpublisher_host %>/publisher", "url": "https://api.cloud.wso2.com/publisher",
"icon": "fw fw-api fw-3x", "icon": "fw fw-api fw-3x",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
}, },
"Integration Cloud": { "Integration Cloud": {
"id": "integration_cloud", "id": "integration_cloud",
"url": "https://milestones.appfactory.wso2.com:9443/appmgt", "url": "https://integration.cloud.wso2.com/appmgt",
"icon": "fa fa-cubes fw-3x", "icon": "fw fw-service fw-3x",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
}, },
"Identity Cloud": { "Identity Cloud": {
"id": "integration_cloud", "id": "integration_cloud",
"url": "https://identity.cloudlocal.wso2.com:9443/admin", "url": "https://identity.cloud.wso2.com/admin",
"icon": "fw fw-security fw-3x", "icon": "fw fw-security fw-3x",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
},
"App Cloud": {
"id": "app_cloud",
"url": "https://<%= @appcloud_host %>/appmgt",
"icon": "fw fw-application fw-3x",
"dropDown": "true",
"target": "_self"
},
"Device Cloud": {
"id": "device_cloud",
"url": "https://<%= @mgt_hostname %>/devicemgt",
"icon": "fw fw-mobile fw-3x",
"dropDown": "true",
"target": "_self"
} }
}, },
"Actions": { "Actions": {
"Organization": { "Organization": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/organization.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/organization.jag",
"icon": "fw fw-organization fw-3x", "icon": "fw fw-organization fw-3x",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
}, },
"Members": { "Members": {
"url": "https://<%= @cloudmgt_host %>/cloudmgt/site/pages/user.jag", "url": "https://cloudmgt.cloud.wso2.com/cloudmgt/site/pages/user.jag",
"icon": "fa fa-users fw-3x", "icon": "fa fa-users fa-3x",
"dropDown": "true", "dropDown": "true",
"target": "_self" "target": "_self"
} }

@ -40,52 +40,66 @@ var operationModule = function () {
privateMethods.getOperationsFromFeatures = function (deviceType, operationType) { privateMethods.getOperationsFromFeatures = function (deviceType, operationType) {
var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types/" + deviceType + "/features"; var url = devicemgtProps["httpsURL"] + devicemgtProps["backendRestEndpoints"]["deviceMgt"] + "/device-types/" + deviceType + "/features";
var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) { var featuresList = serviceInvokers.XMLHttp.get(url, function (responsePayload) {
var features = JSON.parse(responsePayload.responseText); var features = JSON.parse(responsePayload.responseText);
var featureList = []; var featureList = [];
var feature; var feature;
for (var i = 0; i < features.length; i++) { for (var i = 0; i < features.length; i++) {
feature = {}; feature = {};
feature["operation"] = features[i].code; feature["operation"] = features[i].code;
feature["name"] = features[i].name; feature["name"] = features[i].name;
feature["description"] = features[i].description; feature["description"] = features[i].description;
feature["contentType"] = features[i].contentType; feature["contentType"] = features[i].contentType;
feature["deviceType"] = deviceType; feature["deviceType"] = deviceType;
feature["params"] = []; feature["params"] = [];
var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"]; var featuresEntry = utility.getDeviceTypeConfig(deviceType)["deviceType"]["features"];
if (featuresEntry) { if (featuresEntry) {
var featureEntry = featuresEntry[features[i].code]; var featureEntry = featuresEntry[features[i].code];
if (featureEntry) { if (featureEntry) {
var permissionEntry = featureEntry["permission"]; var permissionEntry = featureEntry["permission"];
if (permissionEntry) { if (permissionEntry) {
feature["permission"] = permissionEntry feature["permission"] = permissionEntry
} }
} }
} }
var metaData = features[i].metadataEntries; var metaData = features[i].metadataEntries;
if (metaData) { if (metaData) {
for (var j = 0; j < metaData.length; j++) { for (var j = 0; j < metaData.length; j++) {
feature["params"].push(metaData[j].value); feature["params"].push(metaData[j].value);
} }
featureList.push(feature); featureList.push(feature);
} }
} }
return featureList; return featureList;
}, function (responsePayload) { }, function (responsePayload) {
var response = {}; var response = {};
response["status"] = "error"; response["status"] = "error";
return response; return response;
} }
); );
return featuresList; return featuresList;
}; };
publicMethods.getControlOperations = function (deviceType) { publicMethods.getControlOperations = function (deviceType) {
var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation"); var operations = privateMethods.getOperationsFromFeatures(deviceType, "operation");
var features = utility.getDeviceTypeConfig(deviceType).deviceType.features;
for (var op in operations) { for (var op in operations) {
var iconIdentifier = operations[op].operation; var iconIdentifier = operations[op].operation;
var icon = utility.getOperationIcon(deviceType, iconIdentifier); if (features && features[iconIdentifier]) {
if (icon) { var icon = features[iconIdentifier].icon;
operations[op]["icon"] = icon; if (icon) {
operations[op]["iconFont"] = icon;
} else if (iconPath) {
var iconPath = utility.getOperationIcon(deviceType, iconIdentifier);
operations[op]["icon"] = iconPath;
}
var formParams = features[iconIdentifier].formParams;
if (formParams) {
operations[op]["uiParams"] = formParams;
}
// var icon = utility.getOperationIcon(deviceType, iconIdentifier);
// if (icon) {
// log.error("icon found : " + icon );
// operations[op]["icon"] = icon;
} }
} }
return operations; return operations;
@ -99,9 +113,9 @@ var operationModule = function () {
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation;
var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId +
'","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' + '","protocol":"mqtt", "sessionId":"' + session.getId() + '", "' +
constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX + constants.AUTHORIZATION_HEADER + '":"' + constants.BEARER_PREFIX +
getAccessToken(deviceType, user.username, deviceId) + '"}'; getAccessToken(deviceType, user.username, deviceId) + '"}';
return post(endPoint, params, JSON.parse(header), "json"); return post(endPoint, params, JSON.parse(header), "json");
}; };
@ -109,9 +123,9 @@ var operationModule = function () {
var user = session.get(constants.USER_SESSION_KEY); var user = session.get(constants.USER_SESSION_KEY);
var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation; var endPoint = devicemgtProps["httpsURL"] + '/' + deviceType + "/controller/" + operation;
var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId + var header = '{"owner":"' + user.username + '","deviceId":"' + deviceId +
'","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' + '","protocol":"mqtt", "' + constants.AUTHORIZATION_HEADER + '":"' +
constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) + constants.BEARER_PREFIX + getAccessToken(deviceType, user.username, deviceId) +
'"}'; '"}';
var result = get(endPoint, {}, JSON.parse(header), "json"); var result = get(endPoint, {}, JSON.parse(header), "json");
if (result.data) { if (result.data) {
var values = result.data.sensorValue.split(','); var values = result.data.sensorValue.split(',');

@ -288,6 +288,9 @@ function loadDevices(searchType, searchParam) {
case 'REMOVED' : case 'REMOVED' :
html = '<span><i class="fw fw-delete icon-danger"></i> Removed</span>'; html = '<span><i class="fw fw-delete icon-danger"></i> Removed</span>';
break; break;
case 'UNREACHABLE' :
html = '<span><i class="fw fw-warning icon-warning"></i> Unreachable</span>';
break;
} }
return html; return html;
} }
@ -461,11 +464,11 @@ function loadDevices(searchType, searchParam) {
attachDeviceEvents(); attachDeviceEvents();
if ($('.advance-search').length < 1) { // if ($('.advance-search').length < 1) {
$(this).closest('.dataTables_wrapper').find('div[id$=_filter] input') // $(this).closest('.dataTables_wrapper').find('div[id$=_filter] input')
.after('<a href="' + context + '/devices/search"' + // .after('<a href="' + context + '/devices/search"' +
' class="advance-search add-padding-3x">Advance Search</a>'); // ' class="advance-search add-padding-3x">Advance Search</a>');
} // }
}, { }, {
"placeholder": "Search By Device Name", "placeholder": "Search By Device Name",

@ -1,7 +1,7 @@
{{#zone "content"}} {{#zone "content"}}
{{#if isAuthorized}} {{#if isAuthorized}}
<span id="logged-in-user" class="hidden" data-username="{{user.username}}" data-domain="{{user.domain}}" <span id="logged-in-user" class="hidden" data-username="{{user.username}}" data-domain="{{user.domain}}"
data-tenant-id="{{user.tenantId}}"></span> data-tenant-id="{{user.tenantId}}" data-iscloud="{{isCloud}}"></span>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
@ -284,8 +284,8 @@
<i class="icon fw fw-error"></i><span></span> <i class="icon fw fw-error"></i><span></span>
</div> </div>
{{#unless types}} {{#unless types}}
<h3><i class="icon fw fw-warning"></i> No compatible device types have been installed. <h3><i class="icon fw fw-warning"></i> No compatible device types have been installed.
Install device types to add policies.</h3> Install device types to add policies.</h3>
{{/unless}} {{/unless}}
<div class="row wr-tile-buttons-list"> <div class="row wr-tile-buttons-list">
<div class="wr-input-control"> <div class="wr-input-control">

@ -50,17 +50,17 @@ function onRequest(context) {
var policyOperationsTemplateSrc = policyWizardSrc + "/public/templates/" + deviceType + "-policy-operations.hbs"; var policyOperationsTemplateSrc = policyWizardSrc + "/public/templates/" + deviceType + "-policy-operations.hbs";
if (new File(policyOperationsTemplateSrc).isExists()) { if (new File(policyOperationsTemplateSrc).isExists()) {
content["template"] = "/public/cdmf.unit.device.type." + deviceType + content["template"] = "/public/cdmf.unit.device.type." + deviceType +
".policy-wizard/templates/" + deviceType + "-policy-operations.hbs"; ".policy-wizard/templates/" + deviceType + "-policy-operations.hbs";
} }
var policyOperationsScriptSrc = policyWizardSrc + "/public/js/" + deviceType + "-policy-operations.js"; var policyOperationsScriptSrc = policyWizardSrc + "/public/js/" + deviceType + "-policy-operations.js";
if (new File(policyOperationsScriptSrc).isExists()) { if (new File(policyOperationsScriptSrc).isExists()) {
content["script"] = "/public/cdmf.unit.device.type." + deviceType + content["script"] = "/public/cdmf.unit.device.type." + deviceType +
".policy-wizard/js/" + deviceType + "-policy-operations.js";; ".policy-wizard/js/" + deviceType + "-policy-operations.js";;
} }
var policyOperationsStylesSrc = policyWizardSrc + "/public/css/" + deviceType + "-policy-operations.css"; var policyOperationsStylesSrc = policyWizardSrc + "/public/css/" + deviceType + "-policy-operations.css";
if (new File(policyOperationsStylesSrc).isExists()) { if (new File(policyOperationsStylesSrc).isExists()) {
content["style"] = "/public/cdmf.unit.device.type." + deviceType + content["style"] = "/public/cdmf.unit.device.type." + deviceType +
".policy-wizard/css/" + deviceType + "-policy-operations.css";; ".policy-wizard/css/" + deviceType + "-policy-operations.css";;
} }
types["types"].push(content); types["types"].push(content);
} }
@ -74,6 +74,8 @@ function onRequest(context) {
types["roles"] = roles["content"]; types["roles"] = roles["content"];
} }
types["groups"] = groupModule.getGroups(); types["groups"] = groupModule.getGroups();
var devicemgtProps = require("/app/modules/conf-reader/main.js")["conf"];
types["isCloud"] = devicemgtProps.isCloud;
return types; return types;
} }

@ -146,7 +146,7 @@ stepForwardFrom["policy-platform"] = function (actionButton) {
if (policyOperationsTemplateSrc) { if (policyOperationsTemplateSrc) {
$.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) { $.template(policyOperationsTemplateCacheKey, context + policyOperationsTemplateSrc, function (template) {
var content = template(); var content = template({"iscloud" : $("#logged-in-user").data("iscloud")});
$("#device-type-policy-operations").html(content).removeClass("hidden"); $("#device-type-policy-operations").html(content).removeClass("hidden");
$(".policy-platform").addClass("hidden"); $(".policy-platform").addClass("hidden");
}); });

Loading…
Cancel
Save