Adding siddhi extension and analytics for android-agent

merge-requests/1/head
Megala 8 years ago
parent 59fd3a6fc7
commit 4bfd9a72b6

@ -116,6 +116,10 @@ SpatialObject.prototype.update = function (geoJSON) {
// Update the spatial object leaflet marker
this.marker.setLatLng([this.latitude, this.longitude]);
if (this.latitude, this.longitude) {
map.setView([this.latitude, this.longitude]);
}
this.marker.setIconAngle(this.heading);
this.marker.setIcon(this.stateIcon());
@ -134,7 +138,6 @@ SpatialObject.prototype.update = function (geoJSON) {
if (selectedSpatialObject == this.id) {
this.updatePath([geoJSON.geometry.coordinates[1], geoJSON.geometry.coordinates[0]]);
chart.load({columns: [this.speedHistory.getArray()]});
map.setView([this.latitude, this.longitude]);
}
// TODO: use general popup DOM
@ -707,7 +710,7 @@ intializeWebsocketUrls();
SpatialObject.prototype.stateIcon = function () {
//TODO : Need to add separate icons for each device type
var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/default_icons";
var iconUrl = "/portal/store/carbon.super/fs/gadget/geo-dashboard/img/markers/object-types/default";
if (0 < this.speed && (-360 <= this.heading && 360 >= this.heading)) {
iconUrl = iconUrl + "/moving/" + this.state.toLowerCase();
} else {

@ -36,6 +36,7 @@
<module>appm-connector</module>
<module>cdmf-transport-adapters</module>
<module>mb-extensions</module>
<module>siddhi-extensions</module>
</modules>
<build>
@ -44,7 +45,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<version>${maven.scr.version}</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ Licensed 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>siddhi-extensions</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Siddhi Execution Extension - Json</name>
<url>http://wso2.org</url>
<dependencies>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-api</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.json.wso2</groupId>
<artifactId>json</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${wso2.maven.compiler.source}</source>
<target>${wso2.maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>
org.wso2.extension.siddhi.execution.json,
org.wso2.extension.siddhi.execution.json.*
</Export-Package>
<Import-Package>
org.json,
org.wso2.siddhi.core.*,
org.wso2.siddhi.query.api.*,
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,108 @@
/*
* Copyright (c) 2016, 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.
*/
package org.wso2.extension.siddhi.execution.json;
import org.json.JSONObject;
import org.wso2.siddhi.core.config.ExecutionPlanContext;
import org.wso2.siddhi.core.exception.ExecutionPlanRuntimeException;
import org.wso2.siddhi.core.executor.ExpressionExecutor;
import org.wso2.siddhi.core.executor.function.FunctionExecutor;
import org.wso2.siddhi.query.api.definition.Attribute;
import org.wso2.siddhi.query.api.exception.ExecutionPlanValidationException;
/**
* getProperty(json , propertyName)
* Returns the vale of the property from the given json json
* Accept Type(s): (STRING, STRING)
* Return Type(s): (STRING|INT|DOUBLE|FLOAT|OBJECT)
*/
public class getPropertyFunctionExtension extends FunctionExecutor {
Attribute.Type returnType = Attribute.Type.STRING;
@Override
protected void init(ExpressionExecutor[] attributeExpressionExecutors,
ExecutionPlanContext executionPlanContext) {
if (attributeExpressionExecutors.length != 2) {
throw new ExecutionPlanValidationException(
"Invalid no of arguments passed to json:getProperty() function," + " required 2, but found "
+ attributeExpressionExecutors.length);
}
if (attributeExpressionExecutors[0].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException(
"Invalid parameter type found for the first argument of json:getProperty() function, " + "required "
+ Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[0].getReturnType()
.toString());
}
if (attributeExpressionExecutors[1].getReturnType() != Attribute.Type.STRING) {
throw new ExecutionPlanValidationException(
"Invalid parameter type found for the second argument of json:getProperty() function, " + "required "
+ Attribute.Type.STRING + ", but found " + attributeExpressionExecutors[1].getReturnType()
.toString());
}
}
@Override
protected Object execute(Object[] data) {
if (data[0] == null) {
throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. First argument cannot be null");
}
if (data[1] == null) {
throw new ExecutionPlanRuntimeException("Invalid input given to json:getProperty() function. Second argument cannot be null");
}
String jsonString = (String) data[0];
String property = (String) data[1];
JSONObject jsonObject = new JSONObject(jsonString);
Object value = jsonObject.get(property).toString();
return value;
}
@Override
protected Object execute(Object data) {
return null; //Since the getProperty function takes in 2 parameters, this method does not get called. Hence,not implemented.
}
@Override
public void start() {
//Nothing to start
}
@Override
public void stop() {
//Nothing to stop
}
@Override
public Attribute.Type getReturnType() {
return returnType;
}
@Override
public Object[] currentState() {
return null; //No need to maintain a state.
}
@Override
public void restoreState(Object[] state) {
//Since there's no need to maintain a state, nothing needs to be done here.
}
}

@ -0,0 +1,19 @@
#
# Copyright (c) 2016, 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.
#
getProperty=org.wso2.extension.siddhi.execution.json.getPropertyFunctionExtension

@ -0,0 +1,88 @@
/*
* Copyright (c) 2016, 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.
*/
package org.wso2.extension.siddhi.execution.json;
import junit.framework.Assert;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
import org.wso2.siddhi.core.ExecutionPlanRuntime;
import org.wso2.siddhi.core.SiddhiManager;
import org.wso2.siddhi.core.event.Event;
import org.wso2.siddhi.core.query.output.callback.QueryCallback;
import org.wso2.siddhi.core.stream.input.InputHandler;
import org.wso2.siddhi.core.util.EventPrinter;
import org.wso2.extension.siddhi.execution.json.test.util.SiddhiTestHelper;
import java.util.concurrent.atomic.AtomicInteger;
public class getPropertyFunctionTestCase {
static final Logger log = Logger.getLogger(getPropertyFunctionTestCase.class);
private AtomicInteger count = new AtomicInteger(0);
private volatile boolean eventArrived;
@Before
public void init() {
count.set(0);
eventArrived = false;
}
@Test
public void testGetPropertyFunctionExtension() throws InterruptedException {
log.info("getPropertyFunctionExtension TestCase");
SiddhiManager siddhiManager = new SiddhiManager();
String inStreamDefinition = "define stream inputStream (payload string, id string, volume long);";
String query = ("@info(name = 'query1') from inputStream select id, json:getProperty(payload, 'latitude') "
+ "as latitude insert into outputStream;");
ExecutionPlanRuntime executionPlanRuntime = siddhiManager.createExecutionPlanRuntime(inStreamDefinition + query);
executionPlanRuntime.addCallback("query1", new QueryCallback() {
@Override
public void receive(long timeStamp, Event[] inEvents, Event[] removeEvents) {
EventPrinter.print(timeStamp, inEvents, removeEvents);
for (Event event : inEvents) {
count.incrementAndGet();
if (count.get() == 1) {
Assert.assertEquals("1.5", event.getData(1));
eventArrived = true;
}
if (count.get() == 2) {
Assert.assertEquals("67.5", event.getData(1));
eventArrived = true;
}
if (count.get() == 3) {
Assert.assertEquals("7.5", event.getData(1));
eventArrived = true;
}
}
}
});
InputHandler inputHandler = executionPlanRuntime.getInputHandler("inputStream");
executionPlanRuntime.start();
inputHandler.send(new Object[]{"{'latitude' : 1.5, 'longitude' : 78.5}","IBM",100l});
inputHandler.send(new Object[]{"{'latitude' : 67.5, 'longitude' : 34.9}","WSO2", 200l});
inputHandler.send(new Object[]{"{'latitude' : 7.5, 'longitude' : 44.9}", "XYZ", 200l});
SiddhiTestHelper.waitForEvents(100, 3, count, 60000);
Assert.assertEquals(3, count.get());
Assert.assertTrue(eventArrived);
executionPlanRuntime.shutdown();
}
}

@ -0,0 +1,32 @@
/*
* Copyright (c) 2016, 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.
*/
package org.wso2.extension.siddhi.execution.json.test.util;
import java.util.concurrent.atomic.AtomicInteger;
public class SiddhiTestHelper {
public static void waitForEvents(long sleepTime, int expectedCount, AtomicInteger actualCount, long timeout) throws InterruptedException {
long currentWaitTime = 0;
long startTime = System.currentTimeMillis();
while ((actualCount.get() < expectedCount) && (currentWaitTime <= timeout)) {
Thread.sleep(sleepTime);
currentWaitTime = System.currentTimeMillis() - startTime;
}
}
}

@ -0,0 +1,36 @@
#
# 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.
#
# For the general syntax of property based configuration files see the
# documenation of org.apache.log4j.PropertyConfigurator.
# The root category uses the appender called A1. Since no priority is
# specified, the root category assumes the default priority for root
# which is DEBUG in log4j. The root category is the only category that
# has a default priority. All other categories need not be assigned a
# priority in which case they inherit their priority from the
# hierarchy.
#log4j.rootLogger=DEBUG, stdout
log4j.rootLogger=INFO, stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n
#log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %x - %m%n

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2014, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>siddhi-extensions</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - Siddhi Extension</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.extension.siddhi.execution.json</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>${maven.scr.version}</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project name="create-geo-fence-capps" default="zip" basedir=".">
<property name="project-name" value="${ant.project.name}"/>
<property name="target-dir" value="target/carbonapps"/>
<property name="src-dir" value="src/main/resources/carbonapps"/>
<property name="androidAgent" value="android_agent_analytics-1.0.0"/>
<target name="clean">
<delete dir="${target-dir}" />
</target>
<target name="zip" depends="clean">
<zip destfile="${target-dir}/${androidAgent}.car">
<zipfileset dir="${src-dir}"/>
</zip>
</target>
</project>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-analytics</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.analytics</artifactId>
<name>WSO2 Carbon - IoT Android Stream C-APP</name>
<url>http://wso2.org</url>
<description>This feature contains the android streams</description>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
<executions>
<execution>
<phase>process-resources</phase>
<configuration>
<target>
<ant antfile="build.xml" target="zip" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.assembly.plugin.version}</version>
<configuration>
<finalName>${project.artifactId}-${carbon.devicemgt.plugins.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/src.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,36 @@
<!--
~ Copyright (c) 2016, 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.
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>src</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<baseDirectory>${basedir}/src</baseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/target/carbonapps</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
</fileSet>
</fileSets>
</assembly>

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<eventReceiver name="Android-Agent-Event-Receiver" statistics="disable" trace="disable" xmlns="http://wso2.org/carbon/eventreceiver">
<from eventAdapterType="wso2event">
<property name="events.duplicated.in.cluster">false</property>
</from>
<mapping customMapping="disable" type="wso2event"/>
<to streamName="org.wso2.android.agent.Stream" version="1.0.0"/>
</eventReceiver>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<artifact name="Android-Agent-Event-Receiver" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>android_agent_event_receiver.xml</file>
</artifact>

@ -0,0 +1,20 @@
/* Enter a unique ExecutionPlan */
@Plan:name('Android-Agent-ExecutionPlan')
/* Enter a unique description for ExecutionPlan */
@Plan:description('To convert the android agent incoming stream to relvant streams')
/* define streams/tables and write queries here ... */
@Plan:trace('false')
@Import('org.wso2.android.agent.Stream:1.0.0')
define stream dataIn (deviceId string, payload string, type string);
@Export('org.wso2.geo.LocationStream:1.0.0')
define stream dataOut (id string, timeStamp long, latitude double, longitude double, type string, speed float, heading float );
from dataIn[type == 'location']
select deviceId as id, convert(json:getProperty(payload, 'timeStamp'), 'long') as timeStamp, convert(json:getProperty(payload,
'latitude'), 'double') as latitude, convert(json:getProperty(payload, 'longitude'), 'double') as longitude,
'android' as type, 0.0f as speed, 0.0f as heading insert into dataOut

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<artifact name= "Android-Agent-ExecutionPlan" version="1.0.0" type="event/execution-plan" serverRole="DataAnalyticsServer">
<file>Android-Agent-ExecutionPlan.siddhiql</file>
</artifact>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<artifacts>
<artifact name="android_agent_analytics" version="1.0.0" type="carbon/application">
<dependency artifact="org.wso2.android.agent.Stream" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
<dependency artifact="Android-Agent-Event-Receiver" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
<dependency artifact="Android-Agent-ExecutionPlan" version="1.0.0" include="true"
serverRole="DataAnalyticsServer"/>
</artifact>
</artifacts>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<artifact name="org.wso2.android.agent.Stream" version="1.0.0" type="event/stream" serverRole="DataAnalyticsServer">
<file>org.wso2.android.agent.Stream_1.0.0.json</file>
</artifact>

@ -0,0 +1,20 @@
{
"name": "org.wso2.android.agent.Stream",
"version": "1.0.0",
"nickName": "",
"description": "Stream that receives various types of events from android agent",
"payloadData": [
{
"name": "deviceId",
"type": "STRING"
},
{
"name": "payload",
"type": "STRING"
},
{
"name": "type",
"type": "STRING"
}
]
}

@ -40,8 +40,7 @@ import java.util.List;
@Path("/events")
public class EventReceiverServiceImpl implements EventReceiverService {
private static final String EVENT_STREAM_DEFINITION = "android_agent";
private static final String EVENT_STREAM_DEFINITION = "org.wso2.android.agent.Stream";
private static final Log log = LogFactory.getLog(EventReceiverServiceImpl.class);
@POST

@ -36,6 +36,7 @@
<module>org.wso2.carbon.device.mgt.mobile.android</module>
<module>org.wso2.carbon.device.mgt.mobile.android.api</module>
<module>org.wso2.carbon.device.mgt.mobile.android.ui</module>
<module>org.wso2.carbon.device.mgt.mobile.android.analytics</module>
</modules>
<build>

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>mobile-base-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.ui</artifactId>
<name>WSO2 Carbon - EMM Server UI</name>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>${project.artifactId}-${carbon.devicemgt.plugins.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/src.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,53 @@
{
"appName": "WSO2 Enterprise Mobility Manager",
"cachingEnabled": true,
"debuggingEnabled": false,
"permissionRoot": "/",
"loginPage": "cdmf.page.sign-in",
"adminServicesUrl": "https://${server.ip}:${server.https_port}/admin/services/",
"authModule": {
"enabled": true,
"login": {
"onSuccess": {
"script": "/app/modules/login.js",
"page": "mdm.page.dashboard"
},
"onFail": {
"script": "/app/modules/login.js",
"page": "cdmf.page.sign-in"
}
},
"logout": {
"onSuccess": {
"page": "cdmf.page.sign-in"
},
"onFail": {
"page": "mdm.page.dashboard"
}
},
"sso": {
"enabled": false,
"issuer" : "emm",
"appName" : "emm",
"identityProviderUrl" : "https://localhost:9443/samlsso",
"acs": "https://localhost:9443/emm/uuf/sso/acs",
"identityAlias": "wso2carbon",
"responseSigningEnabled" : true,
"validateAssertionValidityPeriod": true,
"validateAudienceRestriction": true,
"assertionSigningEnabled": true
}
},
"generalConfig" : {
"host" : "https://localhost:9443",
"companyName" : "WSO2 Enterprise Mobility Manager",
"browserTitle" : "WSO2 EMM",
"copyrightPrefix" : "\u00A9 %date-year%, ",
"copyrightOwner" : "WSO2 Inc.",
"copyrightOwnersSite" : "http://www.wso2.org",
"copyrightSuffix" : ""
},
"errorPages": {
"default": "uuf.page.error"
}
}

@ -0,0 +1,124 @@
{
"appContext": "/emm/",
"webAgentContext" : "/emm-web-agent/",
"apiContext": "api",
"httpsURL" : "%https.ip%",
"httpURL" : "%http.ip%",
"httpsWebURL" : "%https.ip%",
"wssURL" : "%https.ip%",
"wsURL" : "%http.ip%",
"enrollmentDir": "/emm-web-agent/enrollment",
"iOSConfigRoot" : "%https.ip%/ios-enrollment/",
"iOSAPIRoot" : "%https.ip%/ios/",
"adminService": "%https.ip%",
"oauthProvider": {
"appRegistration": {
"appType": "webapp",
"clientName": "emm",
"owner": "admin@carbon.super",
"dynamicClientAppRegistrationServiceURL": "%https.ip%/dynamic-client-web/register",
"apiManagerClientAppRegistrationServiceURL": "%https.ip%/api-application-registration/register/tenants",
"grantType": "password refresh_token urn:ietf:params:oauth:grant-type:saml2-bearer urn:ietf:params:oauth:grant-type:jwt-bearer",
"tokenScope": "admin",
"callbackUrl": "%https.ip%/api/device-mgt/v1.0"
},
"tokenServiceURL": "%https.ip%/oauth2/token"
},
"adminUser": "admin@carbon.super",
"adminRole": "admin",
"usernameLength": 30,
"pageSize":10,
"ssoConfiguration" : {
"enabled" : false,
"issuer" : "devicemgt",
"appName" : "devicemgt",
"identityProviderURL" : "%https.ip%/sso/samlsso.jag",
"responseSigningEnabled" : "true",
"keyStorePassword" : "wso2carbon",
"identityAlias" : "wso2carbon",
"keyStoreName" : "/repository/resources/security/wso2carbon.jks"
},
"userValidationConfig" : {
"usernameJSRegEx" : "^[\\S]{3,30}$",
"usernameRegExViolationErrorMsg" : "Provided username is invalid.",
"usernameHelpMsg" : "Should be in minimum 3 characters long and do not include any whitespaces.",
"firstnameJSRegEx" : "^[\\S]{3,30}$",
"firstnameRegExViolationErrorMsg" : "Provided first name is invalid.",
"lastnameJSRegEx" : "^[\\S]{3,30}$",
"lastnameRegExViolationErrorMsg" : "Provided last name is invalid.",
"emailJSRegEx" : "/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/",
"emailRegExViolationErrorMsg" : "Provided email is invalid."
},
"groupValidationConfig": {
"groupNameJSRegEx": "^[\\S]{3,30}$",
"groupNameRegExViolationErrorMsg": "Provided group name is invalid.",
"groupNameHelpMsg": "Should be in minimum 3 characters long and should not include any whitespaces."
},
"roleValidationConfig" : {
"roleNameJSRegEx" : "^[\\S]{3,30}$",
"roleNameRegExViolationErrorMsg" : "Provided role name is invalid.",
"roleNameHelpMsg" : "should be in minimum 3 characters long and do not include any whitespaces."
},
"generalConfig" : {
"host" : "%https.ip%",
"companyName" : "WSO2 Carbon Device Manager",
"browserTitle" : "WSO2 Device Manager",
"copyrightPrefix" : "\u00A9 %date-year%, ",
"copyrightOwner" : "WSO2 Inc.",
"copyrightOwnersSite" : "http://www.wso2.org",
"copyrightSuffix" : " All Rights Reserved."
},
"scopes" : [
"user:manage",
"user:view",
"device-type:admin:view",
"device:view",
"notification:view",
"device:admin:view",
"application:manage",
"activity:view",
"user:admin:reset-password",
"policy:manage",
"policy:view",
"role:manage",
"role:view",
"configuration:view",
"configuration:modify",
"device:android:operation:reboot",
"device:android:operation:camera",
"device:android:operation:vpn",
"device:android:operation:lock",
"device:android:operation:ring",
"device:android:operation:update-app",
"device:android:operation:wipe",
"device:android:operation:encrypt",
"device:android:operation:blacklist-app",
"device:android:operation:applications",
"device:android:operation:enterprise-wipe",
"device:android:operation:info",
"device:android:operation:wifi",
"device:android:operation:uninstall-app",
"device:android:operation:change-lock",
"device:android:operation:notification",
"device:android:operation:upgrade",
"device:android:operation:unlock",
"device:android:operation:mute",
"device:android:operation:location",
"device:android:operation:webclip",
"device:android:operation:clear-password",
"device:android:operation:password-policy",
"device:android:operation:install-app",
"device:android:event:write",
"device:android:event:read",
"device:android:enroll",
"configuration:manage",
"configuration:view",
"device:android:enroll",
"certificate:view",
"certificate:manage"
],
"isOAuthEnabled" : true,
"backendRestEndpoints" : {
"deviceMgt" : "/api/device-mgt/v1.0"
}
}

@ -0,0 +1,106 @@
/*
* Copyright (c) 2016, 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 onRequest(context) {
var log = new Log("mdm.unit.device.operation-bar");
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var viewModel = {};
var permissions = {};
// adding android operations related permission checks
permissions["android"] = [];
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/ring")) {
permissions["android"].push("DEVICE_RING");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/lock")) {
permissions["android"].push("DEVICE_LOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/unlock")) {
permissions["android"].push("DEVICE_UNLOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/location")) {
permissions["android"].push("DEVICE_LOCATION");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/clear-password")) {
permissions["android"].push("CLEAR_PASSWORD");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/reboot")) {
permissions["android"].push("DEVICE_REBOOT");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/upgrade-firmware")) {
permissions["android"].push("UPGRADE_FIRMWARE");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/mute")) {
permissions["android"].push("DEVICE_MUTE");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/send-notification")) {
permissions["android"].push("NOTIFICATION");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/change-lock-code")) {
permissions["android"].push("CHANGE_LOCK_CODE");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/enterprise-wipe")) {
permissions["android"].push("ENTERPRISE_WIPE");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/android/wipe")) {
permissions["android"].push("WIPE_DATA");
}
// adding ios operations related permission checks
permissions["ios"] = [];
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/lock")) {
permissions["ios"].push("DEVICE_LOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/location")) {
permissions["ios"].push("LOCATION");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/enterprise-wipe")) {
permissions["ios"].push("ENTERPRISE_WIPE");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/notification")) {
permissions["ios"].push("NOTIFICATION");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/ios/ring")) {
permissions["ios"].push("RING");
}
// adding windows operations related permission checks
permissions["windows"] = [];
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/lock")) {
permissions["windows"].push("DEVICE_LOCK");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/disenroll/windows")) {
permissions["windows"].push("DISENROLL");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/wipe")) {
permissions["windows"].push("WIPE_DATA");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/ring")) {
permissions["windows"].push("DEVICE_RING");
}
if (userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/operations/windows/lock-reset")) {
permissions["windows"].push("LOCK_RESET");
}
viewModel["permissions"] = stringify(permissions);
viewModel["deviceType"] = context.unit.params.deviceType;
viewModel["ownership"] = context.unit.params.ownership;
return viewModel;
}

@ -0,0 +1,119 @@
{{!
Copyright (c) 2016, 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.
}}
{{#zone "navMenu-icon"}}
<span class="icon fw-stack">
<i class="fw fw-menu fw-stack-1x toggle-icon-down"></i>
</span>
{{/zone}}
{{#zone "navMenu-items"}}
{{#if permissions.LIST_DEVICES}}
<li>
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/devices">
<i class="fw fw-mobile"></i>
Device Management
</a>
</li>
{{/if}}
{{#if permissions.VIEW_DASHBOARD}}
<li>
<a href="/portal/t/{{currentUser.domain}}/dashboards/device-statistics-dashboard/">
<i class="fw fw-statistics"></i>Device Statistics
</a>
</li>
{{/if}}
{{#if permissions.LIST_POLICIES}}
<li><!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/policies"><i class="fw fw-policy"></i>Policy Management</a></li>
{{/if}}
{{#if permissions.USER_MGT_PERMITTED}}
<li><a><i class="fw fw-user"></i>User Management</a>
<ul>
{{#if permissions.LIST_USERS}}
<li><!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/users"><i class="fw fw-user"></i>Users</a></li>
{{/if}}
{{#if permissions.LIST_ROLES}}
<li><!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/roles"><i class="fw fw-bookmark"></i>Roles</a></li>
{{/if}}
</ul>
</li>
{{/if}}
{{#if permissions.CONFIG_MGT_PERMITTED}}
<li><a><i class="fw fw-settings"></i>Configuration Management</a>
<ul>
{{#if permissions.LIST_PLATFORM_CONFIGURATIONS}}
<li><!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/platform-configuration"><i class="fw fw-service"></i>Platform Configurations</a>
</li>
{{/if}}
<!-- todo change the permission and get the related permission -->
{{#if permissions.LIST_CERTIFICATES}}
<li><!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/certificates"><i class="fw fw-security-policy"></i>Certificate Configurations</a>
</li>
{{/if}}
</ul>
</li>
{{/if}}
{{/zone}}
{{#zone "navbarCollapsableRightItems"}}
<ul id="notification-bubble-wrapper" class="nav navbar-nav navbar-right">
<li>
<!--<a href="{{@app.context}}notification-listing" title="Failures of operations on the device side will be listed here">-->
<a data-toggle="sidebar" data-target="#right-sidebar" data-container=".page-content"
aria-expanded="false" rel="notifications-sidebar">
<span id="notification-bubble" class="badge notifications hidden"></span>
<span id="notifications-icon" class="icon fw-stack hidden">
<i class="fw fw-notification fw-stack-1x"></i>
</span>
<span id="notifications-spacer" class="hidden"> </span>
<span class="text-capitalize">Notifications</span>
</a>
</li>
</ul>
{{/zone}}
{{#zone "sidePanes"}}
<!--suppress HtmlUnknownAttribute -->
<div class="sidebar-wrapper" id="right-sidebar" is-authorized="{{permissions.LIST_NOTIFICATIONS}}"
data-side="right" data-width="300" data-sidebar-fixed="true" data-fixed-offset="60" data-spy="affix"
data-offset-top="80">
<ul class="sidebar-messages"></ul>
<br>
<div class="text-center">
<!--suppress HtmlUnknownTarget -->
<a href="{{@app.context}}/notification-listing" class="btn-operations btn-default">
<span class="fw-stack">
<i class="fw fw-ring fw-stroke fw-stack-2x"></i>
<i class="fw fw-notification fw-stack-1x"></i>
</span>
View All Notifications
</a>
</div>
</div>
{{/zone}}
{{#zone "bottomJs"}}
<!--suppress HtmlUnknownTarget -->
<script id="notifications" data-current-user="{{@user.username}}"
data-image-resource="{{@unit.publicUri}}/images/" src="{{@unit.publicUri}}/templates/notifications.hbs"
type="text/x-handlebars-template"></script>
{{js "js/nav-menu.js"}}
{{/zone}}

@ -0,0 +1,67 @@
/*
* 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 onRequest(context) {
var userModule = require("/app/modules/business-controllers/user.js")["userModule"];
var mdmProps = require("/app/modules/conf-reader/main.js")["conf"];
var constants = require("/app/modules/constants.js");
context.handlebars.registerHelper('equal', function (lvalue, rvalue, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (lvalue != rvalue) {
return options.inverse(this);
} else {
return options.fn(this);
}
});
var links = {
"user-mgt": [],
"role-mgt": [],
"policy-mgt": [],
"device-mgt": []
};
var viewModel = {};
// following viewModel.link value comes here based on the value passed at the point
// where units are attached to a page zone.
// eg: {{unit "app-bar" pageLink="users" title="User Management"}}
viewModel["currentActions"] = links[viewModel["pageLink"]];
viewModel["enrollmentURL"] = mdmProps["generalConfig"]["host"] + mdmProps["enrollmentDir"];
viewModel["currentUser"] = session.get(constants["USER_SESSION_KEY"]);
var permissions = {};
permissions["LIST_DEVICES"] = userModule.isAuthorized("/permission/admin/device-mgt/devices/owning-device/view");
permissions["LIST_POLICIES"] = userModule.isAuthorized("/permission/admin/device-mgt/policies/view");
permissions["LIST_USERS"] = userModule.isAuthorized("/permission/admin/device-mgt/users/view");
permissions["LIST_ROLES"] = userModule.isAuthorized("/permission/admin/device-mgt/roles/view");
permissions["USER_MGT_PERMITTED"] = (permissions["LIST_USERS"] || permissions["LIST_ROLES"]);
permissions["LIST_PLATFORM_CONFIGURATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/platform-configurations/view");
permissions["LIST_CERTIFICATES"] = userModule.isAuthorized("/permission/admin/device-mgt/certificates/view");
permissions["CONFIG_MGT_PERMITTED"] = (permissions["LIST_PLATFORM_CONFIGURATIONS"] || permissions["LIST_CERTIFICATES"]);
permissions["LIST_NOTIFICATIONS"] = userModule.isAuthorized("/permission/admin/device-mgt/notifications/view");
permissions["VIEW_DASHBOARD"] = userModule.isAuthorized("/permission/admin/device-mgt/dashboard/view");
viewModel["permissions"] = permissions;
viewModel["appContext"] = mdmProps["appContext"];
viewModel["serverURL"] = mdmProps["httpsWebURL"];
return viewModel;
}

@ -0,0 +1,148 @@
{
"displayName": "EMM Web Agent",
"logLevel": "error",
"initScripts": ["/app/modules/init.js"],
"urlMappings": [
{
"url": "/enrollment",
"path": "/lib/pages.jag"
},
{
"url": "/enrollment/windows/login",
"path": "/app/modules/enrollments/windows/agent-controller.jag"
},
{
"url": "/enrollment/windows/enroll",
"path": "/app/modules/enrollments/windows/agent-enroll.jag"
},
{
"url": "/enrollment/ios/download-certificate",
"path": "/app/modules/enrollments/ios/certificate.jag"
},
{
"url": "/enrollment/ios/download-agent",
"path": "/app/modules/enrollments/ios/agent.jag"
},
{
"url": "/enrollment/ios/login",
"path": "/app/modules/enrollments/ios/agent-controller.jag"
},
{
"url": "/enrollment/ios/enroll",
"path": "/app/modules/enrollments/ios/agent-enroll.jag"
},
{
"url": "/enrollment/ios/check",
"path": "/app/modules/enrollments/ios/agent-check.jag"
},
{
"url": "/api/invoker/*",
"path": "/api/invoker-api.jag"
},
{
"url": "/uuf/login",
"path": "/lib/modules/auth/login.jag"
},
{
"url": "/uuf/logout",
"path": "/lib/modules/auth/logout.jag"
},
{
"url": "/uuf/sso/acs",
"path": "/lib/modules/auth/acs.jag"
},
{
"url": "/public/*",
"path": "/lib/static-files.jag"
},
{
"url": "/unit/*",
"path": "/lib/units.jag"
},
{
"url": "/*",
"path": "/lib/pages.jag"
}
],
"securityConstraints": [
{
"securityConstraint": {
"webResourceCollection": {
"name": "EMM-WEB-AGENT",
"urlPatterns": [
"/*"
]
},
"userDataConstraint": {
"transportGuarantee": "CONFIDENTIAL"
}
}
},
{
"securityConstraint": {
"webResourceCollection": {
"name": "EMM-WEB-AGENT-http",
"urlPatterns": [
"/public/*",
"/enrollments/windows/*",
"/enrollment/windows/*"
]
},
"userDataConstraint": {
"transportGuarantee": "NONE"
}
}
}
],
"filters": [
{
"name": "URLBasedCachePreventionFilter",
"class": "org.wso2.carbon.ui.filters.cache.URLBasedCachePreventionFilter"
},
{
"name":"HttpHeaderSecurityFilter",
"class":"org.apache.catalina.filters.HttpHeaderSecurityFilter",
"params" : [{"name" : "hstsEnabled", "value" : "false"}]
}
],
"filterMappings": [
{
"name": "URLBasedCachePreventionFilter",
"url": "/api/*"
},
{
"name": "URLBasedCachePreventionFilter",
"url": "/enrollment/*"
},
{
"name":"HttpHeaderSecurityFilter",
"url":"*"
}
],
"listeners" : [
{
"class" : "org.owasp.csrfguard.CsrfGuardServletContextListener"
},
{
"class" : "org.owasp.csrfguard.CsrfGuardHttpSessionListener"
}
],
"servlets" : [
{
"name" : "JavaScriptServlet",
"class" : "org.owasp.csrfguard.servlet.JavaScriptServlet"
}
],
"servletMappings" : [
{
"name" : "JavaScriptServlet",
"url" : "/csrf.js"
}
],
"contextParams" : [
{
"name" : "Owasp.CsrfGuard.Config",
"value" : "/repository/conf/security/Owasp.CsrfGuard.dashboard.properties"
}
]
}

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mobile-base-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</name>
<description>WSO2 Carbon - Startup Handler That Prints MDM End-User Web-App URL</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
<Bundle-Description>Bundle Containing The Startup Handler That Prints MDM End-User Web-App URL</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.mobile.url.printer.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
org.apache.axis2.*;version="${axis2.osgi.version.range}",
org.wso2.carbon.core,
org.wso2.carbon.utils.*,
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.url.printer.internal,
org.wso2.carbon.device.mgt.mobile.url.printer,
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>mobile-base-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Mobile Device Management Impl</name>
<description>WSO2 Carbon - Mobile Device Management Implementation</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.0</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.devicemgt.plugins.version}</Bundle-Version>
<Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
javax.xml.*; !javax.xml.parsers,
javax.xml.parsers; version="${javax.xml.parsers.import.pkg.version}",
javax.naming,
javax.sql,
org.w3c.dom,
org.wso2.carbon.context,
org.wso2.carbon.utils.*,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.ndatasource.core,
org.wso2.carbon.policy.mgt.common.*,
org.wso2.carbon.registry.core,
org.wso2.carbon.registry.core.service,
org.wso2.carbon.registry.core.session,
org.wso2.carbon.registry.api,
org.wso2.carbon.device.mgt.extensions.license.mgt.registry,
com.google.gson.*
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.mobile.internal,
!org.wso2.carbon.device.mgt.mobile.impl,
org.wso2.carbon.device.mgt.mobile.*,
</Export-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<systemPropertyVariables>
<log4j.configuration>file:src/test/resources/log4j.properties
</log4j.configuration>
</systemPropertyVariables>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.policy.mgt.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.core</artifactId>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.wso2</groupId>
<artifactId>jdbc-pool</artifactId>
</dependency>
<dependency>
<groupId>com.h2database.wso2</groupId>
<artifactId>h2-database-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.android.gcm</groupId>
<artifactId>gcm-server</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,332 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.Feature;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants;
import org.wso2.carbon.device.mgt.mobile.dto.*;
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementDataHolder;
import org.wso2.carbon.registry.api.RegistryException;
import org.wso2.carbon.registry.api.Resource;
import org.wso2.carbon.registry.core.Registry;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Provides utility methods required by the mobile device management bundle.
*/
public class MobileDeviceManagementUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagementUtil.class);
private static final String MOBILE_DEVICE_IMEI = "IMEI";
private static final String MOBILE_DEVICE_IMSI = "IMSI";
private static final String MOBILE_DEVICE_VENDOR = "VENDOR";
private static final String MOBILE_DEVICE_OS_VERSION = "OS_VERSION";
private static final String MOBILE_DEVICE_MODEL = "DEVICE_MODEL";
private static final String MOBILE_DEVICE_LATITUDE = "LATITUDE";
private static final String MOBILE_DEVICE_LONGITUDE = "LONGITUDE";
private static final String MOBILE_DEVICE_SERIAL = "SERIAL";
private static final String MOBILE_DEVICE_OS_BUILD_DATE = "OS_BUILD_DATE";
public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
return docBuilder.parse(file);
} catch (Exception e) {
throw new DeviceManagementException(
"Error occurred while parsing file, while converting " +
"to a org.w3c.dom.Document : " + e.getMessage(), e);
}
}
private static String getPropertyValue(Device device, String property) {
if (device != null && device.getProperties() != null) {
for (Device.Property prop : device.getProperties()) {
if (property.equals(prop.getName())) {
return prop.getValue();
}
}
}
return null;
}
private static Device.Property getProperty(String property, String value) {
if (property != null) {
Device.Property prop = new Device.Property();
prop.setName(property);
prop.setValue(value);
return prop;
}
return null;
}
public static MobileDevice convertToMobileDevice(Device device) {
MobileDevice mobileDevice = null;
if (device != null) {
mobileDevice = new MobileDevice();
mobileDevice.setMobileDeviceId(device.getDeviceIdentifier());
mobileDevice.setImei(getPropertyValue(device, MOBILE_DEVICE_IMEI));
mobileDevice.setImsi(getPropertyValue(device, MOBILE_DEVICE_IMSI));
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
mobileDevice.setLatitude(getPropertyValue(device, MOBILE_DEVICE_LATITUDE));
mobileDevice.setLongitude(getPropertyValue(device, MOBILE_DEVICE_LONGITUDE));
mobileDevice.setSerial(getPropertyValue(device, MOBILE_DEVICE_SERIAL));
mobileDevice.setOsBuildDate(getPropertyValue(device, MOBILE_DEVICE_OS_BUILD_DATE));
if (device.getProperties() != null) {
Map<String, String> deviceProperties = new HashMap<String, String>();
for (Device.Property deviceProperty : device.getProperties()) {
deviceProperties.put(deviceProperty.getName(), deviceProperty.getValue());
}
mobileDevice.setDeviceProperties(deviceProperties);
} else {
mobileDevice.setDeviceProperties(new HashMap<String, String>());
}
}
return mobileDevice;
}
public static Device convertToDevice(MobileDevice mobileDevice) {
Device device = null;
if (mobileDevice != null) {
device = new Device();
List<Device.Property> propertyList = new ArrayList<Device.Property>();
propertyList.add(getProperty(MOBILE_DEVICE_IMEI, mobileDevice.getImei()));
propertyList.add(getProperty(MOBILE_DEVICE_IMSI, mobileDevice.getImsi()));
propertyList.add(getProperty(MOBILE_DEVICE_MODEL, mobileDevice.getModel()));
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION, mobileDevice.getOsVersion()));
propertyList.add(getProperty(MOBILE_DEVICE_OS_BUILD_DATE, mobileDevice.getOsBuildDate()));
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR, mobileDevice.getVendor()));
if(mobileDevice.getLatitude() != null) {
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE, mobileDevice.getLatitude()));
}
if(mobileDevice.getLongitude() != null) {
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE, mobileDevice.getLongitude()));
}
propertyList.add(getProperty(MOBILE_DEVICE_SERIAL, mobileDevice.getSerial()));
if (mobileDevice.getDeviceProperties() != null) {
for (Map.Entry<String, String> deviceProperty : mobileDevice.getDeviceProperties()
.entrySet()) {
propertyList
.add(getProperty(deviceProperty.getKey(), deviceProperty.getValue()));
}
}
device.setProperties(propertyList);
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
}
return device;
}
public static MobileOperation convertToMobileOperation(Operation operation) {
MobileOperation mobileOperation = new MobileOperation();
MobileOperationProperty operationProperty;
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
mobileOperation.setFeatureCode(operation.getCode());
mobileOperation.setCreatedDate(new Date().getTime());
Properties operationProperties = operation.getProperties();
for (String key : operationProperties.stringPropertyNames()) {
operationProperty = new MobileOperationProperty();
operationProperty.setProperty(key);
operationProperty.setValue(operationProperties.getProperty(key));
properties.add(operationProperty);
}
mobileOperation.setProperties(properties);
return mobileOperation;
}
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
List<MobileDeviceOperationMapping> mobileDeviceOperationMappings) {
List<Integer> mobileOperationIds = new ArrayList<Integer>(mobileDeviceOperationMappings.size());
for (MobileDeviceOperationMapping mobileDeviceOperationMapping : mobileDeviceOperationMappings) {
mobileOperationIds.add(mobileDeviceOperationMapping.getOperationId());
}
return mobileOperationIds;
}
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation) {
Operation operation = new Operation();
Properties properties = new Properties();
operation.setCode(mobileOperation.getFeatureCode());
for (MobileOperationProperty mobileOperationProperty : mobileOperation.getProperties()) {
properties
.put(mobileOperationProperty.getProperty(), mobileOperationProperty.getValue());
}
operation.setProperties(properties);
return operation;
}
public static MobileFeature convertToMobileFeature(Feature feature) {
MobileFeature mobileFeature = new MobileFeature();
mobileFeature.setName(feature.getName());
mobileFeature.setCode(feature.getCode());
mobileFeature.setDescription(feature.getDescription());
mobileFeature.setDeviceType(feature.getDeviceType());
return mobileFeature;
}
public static Feature convertToFeature(MobileFeature mobileFeature) {
Feature feature = new Feature();
feature.setDescription(mobileFeature.getDescription());
feature.setDeviceType(mobileFeature.getDeviceType());
feature.setCode(mobileFeature.getCode());
feature.setName(mobileFeature.getName());
return feature;
}
public static Registry getConfigurationRegistry() throws MobileDeviceMgtPluginException {
try {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
return MobileDeviceManagementDataHolder.getInstance().getRegistryService()
.getConfigSystemRegistry(
tenantId);
} catch (RegistryException e) {
throw new MobileDeviceMgtPluginException(
"Error in retrieving conf registry instance: " +
e.getMessage(), e);
}
}
public static Resource getRegistryResource(String path) throws MobileDeviceMgtPluginException {
try {
if(MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)){
return MobileDeviceManagementUtil.getConfigurationRegistry().get(path);
}
return null;
} catch (RegistryException e) {
throw new MobileDeviceMgtPluginException("Error in retrieving registry resource : " +
e.getMessage(), e);
}
}
public static boolean putRegistryResource(String path,
Resource resource)
throws MobileDeviceMgtPluginException {
boolean status;
try {
MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
status = true;
} catch (RegistryException e) {
throw new MobileDeviceMgtPluginException(
"Error occurred while persisting registry resource : " +
e.getMessage(), e);
}
return status;
}
public static String getResourcePath(String resourceName, String platform) {
String regPath = "";
switch (platform) {
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID +
"/" + resourceName;
break;
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS +
"/" + resourceName;
break;
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS:
regPath = MobilePluginConstants.MOBILE_CONFIG_REGISTRY_ROOT + "/" +
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS +
"/" + resourceName;
break;
}
return regPath;
}
public static String getPlatformConfigPath(String platform) {
String regPath = "";
switch (platform) {
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID:
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID;
break;
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS:
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_WINDOWS;
break;
case DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS:
regPath = DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_IOS;
break;
}
return regPath;
}
public static boolean createRegistryCollection(String path)
throws MobileDeviceMgtPluginException {
try {
if (! MobileDeviceManagementUtil.getConfigurationRegistry().resourceExists(path)) {
Resource resource = MobileDeviceManagementUtil.getConfigurationRegistry().newCollection();
MobileDeviceManagementUtil.getConfigurationRegistry().beginTransaction();
MobileDeviceManagementUtil.getConfigurationRegistry().put(path, resource);
MobileDeviceManagementUtil.getConfigurationRegistry().commitTransaction();
}
return true;
} catch (MobileDeviceMgtPluginException e) {
throw new MobileDeviceMgtPluginException(
"Error occurred while creating a registry collection : " +
e.getMessage(), e);
} catch (RegistryException e) {
throw new MobileDeviceMgtPluginException(
"Error occurred while creating a registry collection : " +
e.getMessage(), e);
}
}
public static List<Feature> getMissingFeatures(List<Feature> supportedFeatures, List<Feature> existingFeatures) {
HashMap<String,Feature> featureHashMap = new HashMap();
for (Feature feature: existingFeatures) {
featureHashMap.put(feature.getCode(),feature);
}
List<Feature> missingFeatures = new ArrayList<Feature>();
for (Feature supportedFeature : supportedFeatures) {
if (featureHashMap.get(supportedFeature.getCode()) != null) {
continue;
}
missingFeatures.add(supportedFeature);
}
return missingFeatures;
}
}

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>mobile-plugins</artifactId>
<version>2.2.8-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>mobile-base-plugin</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - Mobile Plugins</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.device.mgt.mobile</module>
<module>org.wso2.carbon.device.mgt.mobile.ui</module>
<module>org.wso2.carbon.device.mgt.mobile.url.printer</module>
</modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~
~ Licensed 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.
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>extensions-feature</artifactId>
<version>3.0.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.extension.siddhi.execution.json.feature</artifactId>
<packaging>pom</packaging>
<version>3.0.3-SNAPSHOT</version>
<name>WSO2 Siddhi Execution Extension - Json Feature</name>
<url>http://wso2.org</url>
<description>This feature contains Siddhi extension feature for changing a json string to individual properties.</description>
<dependencies>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.wso2.maven</groupId>
<artifactId>carbon-p2-plugin</artifactId>
<version>${carbon.p2.plugin.version}</version>
<executions>
<execution>
<id>p2-feature-generation</id>
<phase>package</phase>
<goals>
<goal>p2-feature-gen</goal>
</goals>
<configuration>
<id>org.wso2.extension.siddhi.execution.json</id>
<propertiesFile>../../etc/feature.properties</propertiesFile>
<adviceFile>
<properties>
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
</properties>
</adviceFile>
<bundles>
<bundleDef>
org.wso2.carbon.devicemgt-plugins:org.wso2.extension.siddhi.execution.json:${carbon.devicemgt.plugins.version}
</bundleDef>
<bundleDef>org.json.wso2:json:${commons-json.version}</bundleDef>
</bundles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -37,6 +37,7 @@
<module>org.wso2.carbon.appmgt.mdm.osgiconnector.feature</module>
<module>org.wso2.carbon.device.mgt.adapter.feature</module>
<module>org.wso2.carbon.andes.extensions.device.mgt.mqtt.authorization.feature</module>
<module>org.wso2.extension.siddhi.execution.json.feature</module>
</modules>
</project>

@ -117,6 +117,18 @@
</outputDirectory>
<includes>**/*</includes>
</artifactItem>
<artifactItem>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.analytics
</artifactId>
<version>${project.version}</version>
<type>zip</type>
<overWrite>true</overWrite>
<outputDirectory>
${project.build.directory}/maven-shared-archive-resources/carbonapps
</outputDirectory>
<includes>**/*</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>

@ -1,5 +1,7 @@
instructions.configure = \
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/webapps/api#device-mgt#android#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#device-mgt#android#v1.0.war,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/carbonapps/);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/carbonapps/,target:${installFolder}/../../deployment/server/carbonapps/,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/devicemgt,target:${installFolder}/../../deployment/server/jaggeryapps/devicemgt,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/jaggeryapps/android-web-agent,target:${installFolder}/../../deployment/server/jaggeryapps/android-web-agent,overwrite:true);\
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.mobile.android_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
@ -28,4 +30,5 @@ org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../dep
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/android);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/WSO2MobileAndroid_DB.h2.db);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/carbonapps/android_agent_analytics-1.0.0.car);\
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/devicetypes/android.xml);\

@ -382,6 +382,11 @@
<!--<artifactId>org.wso2.carbon.device.mgt.iot.url.printer</artifactId>-->
<!--<version>${carbon.devicemgt.plugins.version}</version>-->
<!--</dependency>-->
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.extension.siddhi.execution.json</artifactId>
<version>${carbon.devicemgt.plugins.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.output.adapter.mqtt</artifactId>
@ -1185,6 +1190,24 @@
<artifactId>feign-gson</artifactId>
<version>${io.github.openfeign.version}</version>
</dependency>
<!-- dependencies for siddhi extension -->
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-core</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.siddhi</groupId>
<artifactId>siddhi-query-api</artifactId>
<version>${siddhi.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
@ -1352,6 +1375,9 @@
<io.github.openfeign.version>9.3.1</io.github.openfeign.version>
<javax.ws.rs.jsr311-api.version>[1.1.0, 2.0.0)</javax.ws.rs.jsr311-api.version>
<maven-antrun-plugin.version>1.7</maven-antrun-plugin.version>
<siddhi.version>3.1.2</siddhi.version>
<maven.scr.version>1.7.2</maven.scr.version>
<maven.assembly.plugin.version>2.5.5</maven.assembly.plugin.version>
</properties>
<scm>

Loading…
Cancel
Save