* Fixed the JNDI bug

* Added a device module method and apis for a single device
* UI improvement to the device page
revert-dabc3590
Dulitha Wijewantha 10 years ago
parent 90402107f6
commit 9f71408001

@ -22,13 +22,11 @@ import javax.xml.bind.annotation.XmlRootElement;
/** /**
* Class for holding data source configuration in mobile-config.xml at parsing with JAXB. * Class for holding data source configuration in mobile-config.xml at parsing with JAXB.
*/ */
@XmlRootElement(name = "DataSourceConfiguration") @XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig {
public class MobileDataSourceConfig {
private JNDILookupDefinition jndiLookupDefinition; private JNDILookupDefinition jndiLookupDefinition;
@XmlElement(name = "JndiLookupDefinition", nillable = true) @XmlElement(name = "JndiLookupDefinition", nillable = true) public JNDILookupDefinition getJndiLookupDefinition() {
public JNDILookupDefinition getJndiLookupDefintion() {
return jndiLookupDefinition; return jndiLookupDefinition;
} }

@ -62,7 +62,7 @@ public class MobileDeviceManagementDAOFactory {
throw new RuntimeException("Device Management Repository data source configuration " + throw new RuntimeException("Device Management Repository data source configuration " +
"is null and thus, is not initialized"); "is null and thus, is not initialized");
} }
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
if (jndiConfig != null) { if (jndiConfig != null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Initializing Device Management Repository data source using the JNDI " + log.debug("Initializing Device Management Repository data source using the JNDI " +

@ -51,7 +51,7 @@ public class MobileDeviceManagementDAOUtil {
throw new RuntimeException("Device Management Repository data source configuration " + throw new RuntimeException("Device Management Repository data source configuration " +
"is null and thus, is not initialized"); "is null and thus, is not initialized");
} }
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion(); JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
if (jndiConfig != null) { if (jndiConfig != null) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Initializing Device Management Repository data source using the JNDI " + log.debug("Initializing Device Management Repository data source using the JNDI " +

@ -16,23 +16,24 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
var utility = require("/modules/utility.js");
var deviceManagementService = utility.getDeviceManagementService(); var verb = request.getMethod();
var devices = deviceManagementService.getAllDevices("android"); var uri = request.getRequestURI();
var logger = new Log(); var callPath=uri.replace("/cdm/api/","");
var deviceList = []; var log = new Log();
for (i = 0; i < devices.size(); i++) { var deviceModule = require("/modules/device.js");
var device = devices.get(i); if (uri != null) {
deviceList.push({ var uriMatcher = new URIMatcher(callPath);
"identifier": device.getDeviceIdentifier(), log.info(callPath);
"name": device.getName(), if (uriMatcher.match("devices/mobile/{type}/{deviceid}/")) {
"ownership": device.getOwnership(), var deviceId = uriMatcher.elements().deviceid;
"owner": device.getOwner(), var type = uriMatcher.elements().type;
"deviceType": device.getType(), var result = deviceModule.viewDevice(type, deviceId);
"vendor": device.getProperties().get("vendor"), print(result);
"model": device.getProperties().get("model"), }
"osVersion": device.getProperties().get("osVersion") if (uriMatcher.match("devices/mobile/")) {
}); var result = deviceModule.listDevices();
print(result);
}
} }
print(deviceList);
%> %>

@ -1,6 +1,24 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
function identifierFormatter(value, row, index) { function identifierFormatter(value, row, index) {
return [ return [
'<a class="like" href="/cdm/devices/'+value+'" title="Like">', '<a class="like" href="/cdm/devices/' + row["deviceType"] + '/' + value + '" title="Like">',
value, value,
'</a>' '</a>'
].join('');} ].join('');
}

@ -0,0 +1,75 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var utility = require("/modules/utility.js");
var DeviceIdentifier = Packages.org.wso2.carbon.device.mgt.common.DeviceIdentifier;
var log = new Log();
var deviceManagementService = utility.getDeviceManagementService();
var listDevices = function () {
var devices = deviceManagementService.getAllDevices("android");
var deviceList = [];
for (i = 0; i < devices.size(); i++) {
var device = devices.get(i);
deviceList.push({
"identifier": device.getDeviceIdentifier(),
"name": device.getName(),
"ownership": device.getOwnership(),
"owner": device.getOwner(),
"deviceType": device.getType(),
"vendor": device.getProperties().get("vendor"),
"model": device.getProperties().get("model"),
"osVersion": device.getProperties().get("osVersion")
});
}
return deviceList;
}
var getDevice = function(type, deviceId){
var deviceIdentifier = new DeviceIdentifier();
deviceIdentifier.setType(type);
deviceIdentifier.setId(deviceId);
var device = deviceManagementService.getDevice(deviceIdentifier);
return device;
}
var viewDevice = function(type, deviceId){
var device = this.getDevice(type, deviceId);
var entries = device.getProperties().entrySet();
var iterator = entries.iterator();
var properties = {};
while(iterator.hasNext()){
var entry = iterator.next();
var key = entry.getKey();
var value = entry.getValue();
properties[key]= value;
}
return {
"identifier": device.getDeviceIdentifier(),
"name": device.getName(),
"ownership": device.getOwnership(),
"owner": device.getOwner(),
"deviceType": device.getType(),
"vendor": device.getProperties().get("vendor"),
"model": device.getProperties().get("model"),
"osVersion": device.getProperties().get("osVersion"),
"properties": properties
};
}

@ -26,11 +26,20 @@ var title="WSO2 CDM";
<body> <body>
<% <%
include("/includes/header.jag"); include("/includes/header.jag");
var deviceModule = require("/modules/device.js");
var uri = request.getRequestURI();
var callPath=uri.replace("/cdm/","");
var uriMatcher = new URIMatcher(callPath);
uriMatcher.match("devices/{type}/{deviceid}/");
var deviceId = uriMatcher.elements().deviceid;
var type = uriMatcher.elements().type;
var device = deviceModule.viewDevice(type, deviceId);
%> %>
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-9 main col-centered"> <div class="col-sm-9 main col-centered">
<h2 class="sub-header">Dulitha's iPhone</h2> <h2 class="sub-header"><%=device.name%></h2>
<div class="row"> <div class="row">
</div> </div>
<div class="row"> <div class="row">
@ -50,9 +59,17 @@ var title="WSO2 CDM";
<div class="col-md-8"> <div class="col-md-8">
<div class="row"> <div class="row">
<div class="col-md-12 well well-lg device-static-data"> <div class="col-md-12 well well-lg device-static-data">
<p>Model: <span>GT-I9500</span> </p>
<p>IMSI : <span>GT-I9500</span> </p> <%
<p>IMEI : <span>GT-I9500</span> </p> for (var property in device.properties) {
if (device.properties.hasOwnProperty(property)) {
var value = device.properties[property];
%>
<p><%=property %>: <span><%=value %></span> </p>
<%
}
}
%>
</div> </div>
</div> </div>
<div class="row"> <div class="row">

Loading…
Cancel
Save