Merge branch 'release-3.0.x' of https://github.com/wso2/carbon-device-mgt-plugins into release-3.0.x

revert-dabc3590
Imesh Chandrasiri 8 years ago
commit 6464fcb615

@ -96,7 +96,7 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
synchronized(tokenInfo) {
synchronized(this) {
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());

@ -79,9 +79,11 @@ public class OAuthRequestInterceptor implements RequestInterceptor {
tokenInfo = tokenIssuerService.getToken(PASSWORD_GRANT_TYPE, username, password);
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
synchronized (this) {
if (System.currentTimeMillis() + refreshTimeOffset > tokenInfo.getExpires_in()) {
tokenInfo = tokenIssuerService.getToken(REFRESH_GRANT_TYPE, tokenInfo.getRefresh_token());
tokenInfo.setExpires_in(System.currentTimeMillis() + tokenInfo.getExpires_in());
}
}
String headerValue = "Bearer " + tokenInfo.getAccess_token();
template.header("Authorization", headerValue);

@ -15,7 +15,7 @@
specific language governing permissions and limitations
under the License.
}}
{{#if control_operations}}
{{#if controlOperations}}
<div class="wr-operations" style="height: 87px; display: block;"
xmlns="http://www.w3.org/1999/html">
<style>
@ -35,7 +35,7 @@
color: #B8B8B8;
}
</style>
{{#each control_operations}}
{{#each controlOperations}}
<a href="javascript:operationSelect('{{operation}}')">
{{#if iconFont}}
<i class="fw {{iconFont}}"></i>

@ -19,28 +19,37 @@
function onRequest(context) {
var log = new Log("operation.js");
var operationModule = require("/app/modules/business-controllers/operation.js")["operationModule"];
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var device = context.unit.params.device;
var autoCompleteParams = context.unit.params.autoCompleteParams;
var encodedFeaturePayloads=context.unit.params.encodedFeaturePayloads;
var controlOperations = operationModule.getControlOperations(device.type);
var encodedFeaturePayloads = context.unit.params.encodedFeaturePayloads;
var allControlOps = operationModule.getControlOperations(device.type);
var filteredControlOps = [];
var queryParams = [];
var formParams = [];
var pathParams = [];
for (var i = 0; i < controlOperations.length; i++) {
var currentParamList = controlOperations[i]["params"];
var uiParamList = controlOperations[i]["uiParams"];
for (var i = 0; i < allControlOps.length; i++) {
var controlOperation = {};
var uiPermission = allControlOps[i]["uiPermission"];
if (uiPermission && !userModule.isAuthorized("/permission/admin/" + uiPermission)) {
continue;
}
controlOperation = allControlOps[i];
var currentParamList = allControlOps[i]["params"];
for (var j = 0; j < currentParamList.length; j++) {
var currentParam = currentParamList[j];
currentParamList[j]["formParams"] = processParams(currentParam["formParams"], autoCompleteParams);
currentParamList[j]["queryParams"] = processParams(currentParam["queryParams"], autoCompleteParams);
currentParamList[j]["pathParams"] = processParams(currentParam["pathParams"], autoCompleteParams);
}
controlOperations[i]["uiParams"] = uiParamList;
controlOperation["params"] = currentParamList;
if (encodedFeaturePayloads) {
controlOperations[i]["payload"] = getPayload(encodedFeaturePayloads, controlOperations[i]["operation"]);
allControlOps[i]["payload"] = getPayload(encodedFeaturePayloads, allControlOps[i]["operation"]);
}
filteredControlOps.push(controlOperation);
}
return {"control_operations": controlOperations, "device": device};
return {"controlOperations": filteredControlOps, "device": device};
}
function processParams(paramsList, autoCompleteParams) {
@ -59,7 +68,7 @@ function processParams(paramsList, autoCompleteParams) {
return paramsList;
}
function getPayload(featuresPayload, featureCode){
function getPayload(featuresPayload, featureCode) {
var featuresJSONPayloads = JSON.parse(featuresPayload);
return featuresJSONPayloads[featureCode];
}

@ -6,7 +6,8 @@
"groupingEnabled": "false",
"features": {
"DEVICE_RING": {
"icon": "fw-dial-up"
"icon": "fw-dial-up",
"permission": "/device-mgt/devices/owning-device/operations/android/ring"
},
"DEVICE_LOCK": {
"icon": "fw-lock",
@ -22,16 +23,20 @@
"optional": true,
"label": "Hard lock enabled"
}
]
],
"permission": "/device-mgt/devices/owning-device/operations/android/lock"
},
"DEVICE_LOCATION": {
"icon": "fw-map-location"
"icon": "fw-map-location",
"permission": "/device-mgt/devices/owning-device/operations/android/location"
},
"CLEAR_PASSWORD": {
"icon": "fw-clear"
"icon": "fw-clear",
"permission": "/device-mgt/devices/owning-device/operations/android/clear-password"
},
"DEVICE_REBOOT": {
"icon": "fw-refresh"
"icon": "fw-refresh",
"permission": "/device-mgt/devices/owning-device/operations/android/reboot"
},
"UPGRADE_FIRMWARE": {
"icon": "fw-hardware",
@ -55,10 +60,12 @@
"optional": true,
"label": "Enter firmware upgrade server URL (ie. http://abc.com or http://abc.com/ota)"
}
]
],
"permission": "/device-mgt/devices/owning-device/operations/android/upgrade"
},
"DEVICE_MUTE": {
"icon": "fw-mute"
"icon": "fw-mute",
"permission": "/device-mgt/devices/owning-device/operations/android/mute"
},
"NOTIFICATION": {
"icon": "fw-message",
@ -75,7 +82,8 @@
"optional": false,
"label": "Message Here..."
}
]
],
"permission": "/device-mgt/devices/owning-device/operations/android/send-notification"
},
"CHANGE_LOCK_CODE": {
"icon": "fw-security",
@ -86,10 +94,12 @@
"optional": false,
"label": "Lock Code"
}
]
],
"permission": "/device-mgt/devices/owning-device/operations/android/change-lock-code"
},
"ENTERPRISE_WIPE": {
"icon": "fw-block"
"icon": "fw-block",
"permission": "/device-mgt/devices/owning-device/operations/android/enterprise-wipe"
},
"WIPE_DATA": {
"icon": "fw-delete",
@ -100,7 +110,8 @@
"optional": false,
"label": "Enter PIN code* of the device."
}
]
],
"permission": "/device-mgt/devices/owning-device/operations/android/wipe"
}
}
}

Loading…
Cancel
Save