diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java index 16c9ac703..324d7beae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/config/datasource/MobileDataSourceConfig.java @@ -22,8 +22,7 @@ import javax.xml.bind.annotation.XmlRootElement; /** * Class for holding data source configuration in mobile-config.xml at parsing with JAXB. */ -@XmlRootElement(name = "DataSourceConfiguration") -public class MobileDataSourceConfig { +@XmlRootElement(name = "DataSourceConfiguration") public class MobileDataSourceConfig { private JNDILookupDefinition jndiLookupDefinition; diff --git a/pom.xml b/pom.xml index 322c9df85..114eda3ab 100644 --- a/pom.xml +++ b/pom.xml @@ -227,6 +227,7 @@ 1.1.0 1.0.0 1.0.0 + 1.1.0-SNAPSHOT 1.1.0 4.3.1 diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag new file mode 100644 index 000000000..783176d28 --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/api/mobile/device-api.jag @@ -0,0 +1,39 @@ +<% +/* + * 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 verb = request.getMethod(); +var uri = request.getRequestURI(); +var callPath=uri.replace("/cdm/api/",""); +var log = new Log(); +var deviceModule = require("/modules/device.js"); +if (uri != null) { + var uriMatcher = new URIMatcher(callPath); + log.info(callPath); + if (uriMatcher.match("devices/mobile/{type}/{deviceid}/")) { + var deviceId = uriMatcher.elements().deviceid; + var type = uriMatcher.elements().type; + var result = deviceModule.viewDevice(type, deviceId); + print(result); + } + if (uriMatcher.match("devices/mobile/")) { + var result = deviceModule.listDevices(); + print(result); + } +} +%> \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js index 7c3d5d979..0fa9dd49d 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/client/javascript/main.js @@ -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) { return [ - '', - value, - '' - ].join('');} \ No newline at end of file + '', + value, + '' + ].join(''); +} \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js index 27d9cf25c..859dd1037 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/init.js @@ -1 +1,32 @@ -//Init js to execute \ No newline at end of file +/* + * 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. + */ +//Init js to execute +var logger = new Log(); +logger.debug("running debug"); +var app_TENANT_CONFIGS = 'tenant.configs'; +var app_carbon = require('carbon'); +var app_configs = { + "HTTPS_URL": "https://localhost:9443" +}; + +var app_server = new app_carbon.server.Server({ + tenanted: app_configs.tenanted, + url: app_configs.HTTPS_URL + '/admin' +}); +application.put("SERVER", app_server); +application.put(app_TENANT_CONFIGS, {}); diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf index 3012d6082..efc8b1257 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/jaggery.conf @@ -1,6 +1,6 @@ { "welcomeFiles": ["pages/dashboard.jag"], - "initScripts": ["init.js"], + "initScripts": ["/init.js"], "urlMappings": [ { "url": "/devices/*", @@ -9,12 +9,16 @@ { "url": "/dashboard", "path": "/pages/dashboard.jag" + }, + { + "url": "/api/devices/mobile/*", + "path": "/api/mobile/device-api.jag" } ], "errorPages": { "500": "/error500.jag", "404": "/error404.jag", - "403": "/error403.jag" + "403": "/error403.jag " }, - "logLevel": "info" + "logLevel": "debug" } \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js new file mode 100644 index 000000000..c208c91a4 --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/device.js @@ -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 + }; +} \ No newline at end of file diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js new file mode 100644 index 000000000..47b8862bf --- /dev/null +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/modules/utility.js @@ -0,0 +1,32 @@ +/* + * 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. + */ + +//temporary + +var PrivilegedCarbonContext = Packages.org.wso2.carbon.context.PrivilegedCarbonContext, + Class = java.lang.Class; + +osgiService = function (clazz) { + return PrivilegedCarbonContext.getThreadLocalCarbonContext().getOSGiService(Class.forName(clazz)); +}; +var getDeviceManagementService= function(){ + //server.authenticate("admin", "admin"); + var realmService = osgiService('org.wso2.carbon.device.mgt.core.service.DeviceManagementService'); + //var realmService = null; + return realmService; +} diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag index 35d2f255b..46c5cd3da 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/dashboard.jag @@ -1,5 +1,22 @@ -<% +<% +/* + * 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 title="WSO2 CDM"; %> @@ -14,25 +31,43 @@ var title="WSO2 CDM";

Devices list

+ +
+ + + + + +
+
+
+ + + + + + + + + + + + + + +
IdentifierNameOwnerOwnershipDevice TypeVendorModelOS Version
+
+
+
sdfweroiweuroi
+
+
diff --git a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag index e4930c190..91977bdad 100644 --- a/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag +++ b/product/modules/distribution/src/repository/jaggeryapps/cdm/pages/device.jag @@ -1,5 +1,22 @@ -<% +<% +/* + * 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 title="WSO2 CDM"; %> @@ -9,11 +26,20 @@ var title="WSO2 CDM"; <% 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); %>
-

Dulitha's iPhone

+

<%=device.name%>

@@ -33,36 +59,44 @@ var title="WSO2 CDM";
-

Model: GT-I9500

-

IMSI : GT-I9500

-

IMEI : GT-I9500

-
-
-
-
-

Model: GT-I9500

-

IMSI : GT-I9500

-

IMEI : GT-I9500

-
-
-
-
- - - - - - - -
App namePackage name
-
-
-
-
-
+ + <% + for (var property in device.properties) { + if (device.properties.hasOwnProperty(property)) { + var value = device.properties[property]; + %> +

<%=property %>: <%=value %>

+ <% + } + } + %> +
+
+
+
+

Model: GT-I9500

+

IMSI : GT-I9500

+

IMEI : GT-I9500

+
+
+
+
+ + + + + + + +
App namePackage name
+
+
+ - <% + + +<% include("/includes/layout-footer.jag"); %> diff --git a/product/modules/p2-profile-gen/pom.xml b/product/modules/p2-profile-gen/pom.xml index 0ebd1840f..1697bf450 100644 --- a/product/modules/p2-profile-gen/pom.xml +++ b/product/modules/p2-profile-gen/pom.xml @@ -127,6 +127,9 @@ org.jaggeryjs.modules:uuid.feature:${uuid.feature.version} + + org.jaggeryjs.modules:sso.feature:${sso.feature.version} + org.jaggeryjs.modules:jaggery-test.feature:${jaggery-test.feature.version} @@ -284,6 +287,10 @@ org.jaggeryjs.modules.uuid.feature.group ${uuid.feature.version} + + org.jaggeryjs.modules.sso.feature.group + ${sso.feature.version} + org.jaggeryjs.modules.jaggery-test.feature.group ${jaggery-test.feature.version}