Merge pull request #217 from charithag/master

Fix module locations & Enable IoT base plugin component
revert-dabc3590
Ruwan 9 years ago
commit 7423584c25

@ -1,173 +0,0 @@
<?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>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.impl</artifactId>
<version>2.1.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Mobile Device Management Impl</name>
<description>WSO2 Carbon - Mobile Device Management Impl</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.mobile.device.mgt.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.bind.*,
javax.naming,
javax.sql,
javax.xml.parsers,
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>

@ -1,41 +0,0 @@
/*
* 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;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import java.util.List;
public abstract class AbstractMobileOperationManager implements OperationManager {
@Override
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
return null;
}
@Override
public int addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException {
return 1;
}
}

@ -1,52 +0,0 @@
/*
* *
* * Copyright (c) 2015, 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.
*
*/
package org.wso2.carbon.device.mgt.mobile;
public class DataSourceNotAvailableException extends RuntimeException {
private String message;
private static final long serialVersionUID = 2021891706072918866L;
public DataSourceNotAvailableException(String message, Exception nestedException) {
super(message, nestedException);
setErrorMessage(message);
}
public DataSourceNotAvailableException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public DataSourceNotAvailableException(String message) {
super(message);
setErrorMessage(message);
}
public DataSourceNotAvailableException(Throwable cause) {
super(cause);
}
public String getMessage() {
return message;
}
public void setErrorMessage(String errorMessage) {
this.message = errorMessage;
}
}

@ -1,57 +0,0 @@
/*
* 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.common;
public class MobileDeviceMgtPluginException extends Exception{
private static final long serialVersionUID = -2297311387874900305L;
private String errorMessage;
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public MobileDeviceMgtPluginException(String msg, Exception nestedEx) {
super(msg, nestedEx);
setErrorMessage(msg);
}
public MobileDeviceMgtPluginException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
public MobileDeviceMgtPluginException(String msg) {
super(msg);
setErrorMessage(msg);
}
public MobileDeviceMgtPluginException() {
super();
}
public MobileDeviceMgtPluginException(Throwable cause) {
super(cause);
}
}

@ -1,29 +0,0 @@
/*
* 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.common;
public class MobilePluginConstants {
public static final String MOBILE_DB_SCRIPTS_FOLDER = "cdm";
public static final String MOBILE_CONFIG_REGISTRY_ROOT = "/_system/config";
public static final String MEDIA_TYPE_XML = "application/xml";
public static final String CHARSET_UTF8 = "UTF8";
public static final String LANGUAGE_CODE_ENGLISH_US = "en_US";
public static final String LANGUAGE_CODE_ENGLISH_UK = "en_UK";
}

@ -1,79 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.config;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.utils.CarbonUtils;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.File;
/**
* Class responsible for the mobile device manager configuration initialization.
*/
public class MobileDeviceConfigurationManager {
private static final String MOBILE_DEVICE_CONFIG_XML_NAME = "mobile-config.xml";
private static final String MOBILE_DEVICE_PLUGIN_DIRECTORY = "mobile";
private static final String DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY = "device-mgt-plugin-configs";
private MobileDeviceManagementConfig currentMobileDeviceConfig;
private static MobileDeviceConfigurationManager mobileDeviceConfigManager;
private final String mobileDeviceMgtConfigXMLPath =
CarbonUtils.getEtcCarbonConfigDirPath() + File.separator +
DEVICE_MGT_PLUGIN_CONFIGS_DIRECTORY +
File.separator +
MOBILE_DEVICE_PLUGIN_DIRECTORY + File.separator + MOBILE_DEVICE_CONFIG_XML_NAME;
public static MobileDeviceConfigurationManager getInstance() {
if (mobileDeviceConfigManager == null) {
synchronized (MobileDeviceConfigurationManager.class) {
if (mobileDeviceConfigManager == null) {
mobileDeviceConfigManager = new MobileDeviceConfigurationManager();
}
}
}
return mobileDeviceConfigManager;
}
public synchronized void initConfig() throws DeviceManagementException {
try {
File mobileDeviceMgtConfig = new File(mobileDeviceMgtConfigXMLPath);
Document doc = MobileDeviceManagementUtil.convertToDocument(mobileDeviceMgtConfig);
JAXBContext mobileDeviceMgmtContext =
JAXBContext.newInstance(MobileDeviceManagementConfig.class);
Unmarshaller unmarshaller = mobileDeviceMgmtContext.createUnmarshaller();
this.currentMobileDeviceConfig =
(MobileDeviceManagementConfig) unmarshaller.unmarshal(doc);
} catch (Exception e) {
throw new DeviceManagementException(
"Error occurred while initializing Mobile Device Management config", e);
}
}
public MobileDeviceManagementConfig getMobileDeviceManagementConfig() {
return currentMobileDeviceConfig;
}
}

@ -1,42 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.config;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Represents Mobile Device Mgt configuration.
*/
@XmlRootElement(name = "MobileDeviceMgtConfiguration")
public final class MobileDeviceManagementConfig {
private MobileDeviceManagementRepository mobileDeviceMgtRepository;
@XmlElement(name = "ManagementRepository", nillable = false)
public MobileDeviceManagementRepository getMobileDeviceMgtRepository() {
return mobileDeviceMgtRepository;
}
public void setMobileDeviceMgtRepository(
MobileDeviceManagementRepository mobileDeviceMgtRepository) {
this.mobileDeviceMgtRepository = mobileDeviceMgtRepository;
}
}

@ -1,57 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.config;
import org.wso2.carbon.device.mgt.mobile.config.datasource.DataSourceConfigAdapter;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import java.util.List;
import java.util.Map;
/**
* Class for holding management repository data.
*/
@XmlRootElement(name = "ManagementRepository")
public class MobileDeviceManagementRepository {
private Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap;
private List<MobileDataSourceConfig> mobileDataSourceConfigs;
public MobileDataSourceConfig getMobileDataSourceConfig(String provider) {
return mobileDataSourceConfigMap.get(provider);
}
@XmlElement(name = "DataSourceConfigurations")
@XmlJavaTypeAdapter(DataSourceConfigAdapter.class)
public Map<String, MobileDataSourceConfig> getMobileDataSourceConfigMap() {
return mobileDataSourceConfigMap;
}
public void setMobileDataSourceConfigMap(Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap) {
this.mobileDataSourceConfigMap = mobileDataSourceConfigMap;
}
public List<MobileDataSourceConfig> getMobileDataSourceConfigs() {
return (List<MobileDataSourceConfig>) mobileDataSourceConfigMap.values();
}
}

@ -1,51 +0,0 @@
/*
* 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.config.datasource;
import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class DataSourceConfigAdapter
extends XmlAdapter<MobileDataSourceConfigurations, Map<String, MobileDataSourceConfig>> {
@Override
public Map<String, MobileDataSourceConfig> unmarshal(MobileDataSourceConfigurations mobileDataSourceConfigurations)
throws Exception {
Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap = new HashMap<String, MobileDataSourceConfig>();
for (MobileDataSourceConfig mobileDataSourceConfig : mobileDataSourceConfigurations
.getMobileDataSourceConfigs()) {
mobileDataSourceConfigMap.put(mobileDataSourceConfig.getType(), mobileDataSourceConfig);
}
return mobileDataSourceConfigMap;
}
@Override
public MobileDataSourceConfigurations marshal(Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap)
throws Exception {
MobileDataSourceConfigurations mobileDataSourceConfigurations = new MobileDataSourceConfigurations();
mobileDataSourceConfigurations.setMobileDataSourceConfigs(
(List<MobileDataSourceConfig>) mobileDataSourceConfigMap.values());
return mobileDataSourceConfigurations;
}
}

@ -1,79 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.config.datasource;
import javax.xml.bind.annotation.*;
import java.util.List;
/**
* Class for hold JndiLookupDefinition of mobile-config.xml at parsing with JAXB.
*/
@XmlRootElement(name = "JndiLookupDefinition")
public class JNDILookupDefinition {
private String jndiName;
private List<JNDIProperty> jndiProperties;
@XmlElement(name = "Name", nillable = false)
public String getJndiName() {
return jndiName;
}
public void setJndiName(String jndiName) {
this.jndiName = jndiName;
}
@XmlElementWrapper(name = "Environment", nillable = false)
@XmlElement(name = "Property", nillable = false)
public List<JNDIProperty> getJndiProperties() {
return jndiProperties;
}
public void setJndiProperties(List<JNDIProperty> jndiProperties) {
this.jndiProperties = jndiProperties;
}
@XmlRootElement(name = "Property")
public static class JNDIProperty {
private String name;
private String value;
@XmlAttribute(name = "Name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@XmlValue
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}

@ -1,51 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.config.datasource;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
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 {
private JNDILookupDefinition jndiLookupDefinition;
private String type;
@XmlElement(name = "JndiLookupDefinition", nillable = true)
public JNDILookupDefinition getJndiLookupDefinition() {
return jndiLookupDefinition;
}
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
this.jndiLookupDefinition = jndiLookupDefinition;
}
@XmlAttribute(name = "type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}

@ -1,41 +0,0 @@
/*
* 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.config.datasource;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "DataSourceConfigurations")
@XmlAccessorType(XmlAccessType.FIELD)
public class MobileDataSourceConfigurations {
@XmlElement(name = "DataSourceConfiguration", nillable = true)
private List<MobileDataSourceConfig> mobileDataSourceConfigs;
public List<MobileDataSourceConfig> getMobileDataSourceConfigs() {
return mobileDataSourceConfigs;
}
public void setMobileDataSourceConfigs(List<MobileDataSourceConfig> mobileDataSourceConfigs) {
this.mobileDataSourceConfigs = mobileDataSourceConfigs;
}
}

@ -1,102 +0,0 @@
/*
* 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.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
/**
* Factory class used to create MobileDeviceManagement related DAO objects.
*/
public abstract class AbstractMobileDeviceManagementDAOFactory implements MobileDeviceManagementDAOFactory {
private static final Log log = LogFactory.getLog(AbstractMobileDeviceManagementDAOFactory.class);
private static Map<String, DataSource> dataSourceMap = new HashMap<>();
private static boolean isInitialized;
public static void init(Map<String, MobileDataSourceConfig> mobileDataSourceConfigMap)
throws MobileDeviceMgtPluginException {
DataSource dataSource;
for (String pluginType : mobileDataSourceConfigMap.keySet()) {
if (dataSourceMap.get(pluginType) == null) {
dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfigMap.get
(pluginType));
dataSourceMap.put(pluginType, dataSource);
}
}
isInitialized = true;
}
public static void init(String key, MobileDataSourceConfig mobileDataSourceConfig) throws
MobileDeviceMgtPluginException {
DataSource dataSource = AbstractMobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfig);
dataSourceMap.put(key, dataSource);
}
/**
* Resolve data source from the data source definition.
*
* @param config Mobile data source configuration
* @return data source resolved from the data source definition
*/
public static DataSource resolveDataSource(MobileDataSourceConfig config) {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException("Device Management Repository data source configuration " +
"is null and thus, is not initialized");
}
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
if (jndiConfig != null) {
if (log.isDebugEnabled()) {
log.debug("Initializing Device Management Repository data source using the JNDI " +
"Lookup Definition");
}
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
jndiConfig.getJndiProperties();
if (jndiPropertyList != null) {
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
jndiProperties.put(prop.getName(), prop.getValue());
}
dataSource =
MobileDeviceManagementDAOUtil
.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
} else {
dataSource = MobileDeviceManagementDAOUtil
.lookupDataSource(jndiConfig.getJndiName(), null);
}
}
return dataSource;
}
public static Map<String, DataSource> getDataSourceMap() {
return dataSourceMap;
}
}

@ -1,74 +0,0 @@
/*
* 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.dao;
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
import java.util.List;
/**
* This class represents the key operations associated with persisting mobile-device related
* information.
*/
public interface MobileDeviceDAO {
/**
* Fetches a MobileDevice from MDM database.
*
* @param mblDeviceId Id of the Mobile-Device.
* @return MobileDevice corresponding to given device-id.
* @throws MobileDeviceManagementDAOException
*/
MobileDevice getMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException;
/**
* Adds a new MobileDevice to the MDM database.
*
* @param mobileDevice MobileDevice to be added.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
/**
* Updates MobileDevice information in MDM database.
*
* @param mobileDevice MobileDevice to be updated.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
/**
* Deletes a given MobileDevice from MDM database.
*
* @param mblDeviceId Id of MobileDevice to be deleted.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteMobileDevice(String mblDeviceId) throws MobileDeviceManagementDAOException;
/**
* Fetches all MobileDevices from MDM database.
*
* @return List of MobileDevices.
* @throws MobileDeviceManagementDAOException
*/
List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException;
}

@ -1,80 +0,0 @@
/*
* 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.dao;
/**
* Custom exception class for mobile device specific data access related exceptions.
*/
public class MobileDeviceManagementDAOException extends Exception {
private String message;
private static final long serialVersionUID = 2021891706072918865L;
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message and
* nested exception.
*
* @param message error message
* @param nestedException exception
*/
public MobileDeviceManagementDAOException(String message, Exception nestedException) {
super(message, nestedException);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message
* and cause.
*
* @param message the detail message.
* @param cause the cause of this exception.
*/
public MobileDeviceManagementDAOException(String message, Throwable cause) {
super(message, cause);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified detail message.
*
* @param message the detail message.
*/
public MobileDeviceManagementDAOException(String message) {
super(message);
setErrorMessage(message);
}
/**
* Constructs a new MobileDeviceManagementDAOException with the specified and cause.
*
* @param cause the cause of this exception.
*/
public MobileDeviceManagementDAOException(Throwable cause) {
super(cause);
}
public String getMessage() {
return message;
}
public void setErrorMessage(String errorMessage) {
this.message = errorMessage;
}
}

@ -1,110 +0,0 @@
/*
* 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.dao;
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
import java.util.List;
/**
* This class represents the key operations associated with persisting mobile feature related
* information.
*/
public interface MobileFeatureDAO {
/**
* Adds a new MobileFeature to Mobile-Feature table.
*
* @param mobileFeature MobileFeature object that holds data related to the feature to be inserted.
* @return boolean status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean addFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
/**
* Adda a list of MobileFeatures to Mobile-Feature table.
*
* @param mobileFeatures List of MobileFeature objects.
* @return boolean status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean addFeatures(List<MobileFeature> mobileFeatures) throws MobileDeviceManagementDAOException;
/**
* Updates a MobileFeature in Mobile-Feature table.
*
* @param mobileFeature MobileFeature object that holds data has to be updated.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean updateFeature(MobileFeature mobileFeature) throws MobileDeviceManagementDAOException;
/**
* Deletes a MobileFeature from Mobile-Feature table when the feature id is given.
*
* @param mblFeatureId MobileFeature id of the MobileFeature to be deleted.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
/**
* Deletes a MobileFeature from Mobile-Feature table when the feature code is given.
*
* @param mblFeatureCode MobileFeature code of the feature to be deleted.
* @return The status of the operation.
* @throws MobileDeviceManagementDAOException
*/
boolean deleteFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
/**
* Retrieves a given MobileFeature from Mobile-Feature table when the feature id is given.
*
* @param mblFeatureId Feature id of the feature to be retrieved.
* @return MobileFeature object that holds data of the feature represented by featureId.
* @throws MobileDeviceManagementDAOException
*/
MobileFeature getFeatureById(int mblFeatureId) throws MobileDeviceManagementDAOException;
/**
* Retrieves a given MobileFeature from Mobile-Feature table when the feature code is given.
*
* @param mblFeatureCode Feature code of the feature to be retrieved.
* @return MobileFeature object that holds data of the feature represented by featureCode.
* @throws MobileDeviceManagementDAOException
*/
MobileFeature getFeatureByCode(String mblFeatureCode) throws MobileDeviceManagementDAOException;
/**
* Retrieves all MobileFeatures of a MobileDevice type from Mobile-Feature table.
*
* @param deviceType MobileDevice type of the MobileFeatures to be retrieved
* @return MobileFeature object list.
* @throws MobileDeviceManagementDAOException
*/
List<MobileFeature> getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException;
/**
* Retrieve all the MobileFeatures from Mobile-Feature table.
*
* @return MobileFeature object list.
* @throws MobileDeviceManagementDAOException
*/
List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException;
}

@ -1,336 +0,0 @@
/*
* 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.
*/
package org.wso2.carbon.device.mgt.mobile.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileFeatureDAO;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.dto.MobileFeature;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
* Implementation of MobileFeatureDAO.
*/
public class MobileFeatureDAOImpl implements MobileFeatureDAO {
private DataSource dataSource;
private static final Log log = LogFactory.getLog(MobileFeatureDAOImpl.class);
public MobileFeatureDAOImpl(DataSource dataSource) {
this.dataSource = dataSource;
}
@Override
public boolean addFeature(MobileFeature mobileFeature)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String createDBQuery =
"INSERT INTO AD_FEATURE(CODE, NAME, DESCRIPTION, DEVICE_TYPE) VALUES (?, ?, ?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, mobileFeature.getCode());
stmt.setString(2, mobileFeature.getName());
stmt.setString(3, mobileFeature.getDescription());
stmt.setString(4, mobileFeature.getDeviceType());
int rows = stmt.executeUpdate();
if (rows > 0) {
if (log.isDebugEnabled()) {
log.debug("Added a new MobileFeature " + mobileFeature.getCode() + " to the MDM database.");
}
status = true;
}
} catch (SQLException e) {
String msg = "Error occurred while adding feature code - '" +
mobileFeature.getCode() + "' to feature table";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean addFeatures(List<MobileFeature> mobileFeatures) throws MobileDeviceManagementDAOException {
return false;
}
@Override
public boolean updateFeature(MobileFeature mobileFeature)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String updateDBQuery =
"UPDATE AD_FEATURE SET CODE = ?, NAME = ?, DESCRIPTION = ?, DEVICE_TYPE = ?" +
" WHERE ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
stmt.setString(1, mobileFeature.getCode());
stmt.setString(2, mobileFeature.getName());
stmt.setString(3, mobileFeature.getDescription());
stmt.setString(4, mobileFeature.getDeviceType());
stmt.setInt(5, mobileFeature.getId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Updated MobileFeature " + mobileFeature.getCode());
}
}
} catch (SQLException e) {
String msg = "Error occurred while updating the feature with feature code - '" +
mobileFeature.getId() + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM AD_FEATURE WHERE CODE = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, mblFeatureCode);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileFeature code " + mblFeatureCode + " from the MDM database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while deleting feature with code - " + mblFeatureCode;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public boolean deleteFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = this.getConnection();
String deleteDBQuery =
"DELETE FROM AD_FEATURE WHERE ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setInt(1, mblFeatureId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Deleted MobileFeature id " + mblFeatureId + " from the MDM database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while deleting feature with id - " + mblFeatureId;
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
}
return status;
}
@Override
public MobileFeature getFeatureByCode(String mblFeatureCode)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileFeature mobileFeature = null;
ResultSet resultSet = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE " +
"WHERE CODE = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, mblFeatureCode);
resultSet = stmt.executeQuery();
if (resultSet.next()) {
mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2));
mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileFeature " + mblFeatureCode + " from the MDM database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while fetching feature code - '" + mblFeatureCode + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
}
return mobileFeature;
}
@Override
public MobileFeature getFeatureById(int mblFeatureId)
throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileFeature mobileFeature = null;
ResultSet resultSet = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" +
" WHERE ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setInt(1, mblFeatureId);
resultSet = stmt.executeQuery();
if (resultSet.next()) {
mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2));
mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5));
if (log.isDebugEnabled()) {
log.debug("Fetched MobileFeatureId" + mblFeatureId + " from the MDM database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while fetching feature id - '" + mblFeatureId + "'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
}
return mobileFeature;
}
@Override
public List<MobileFeature> getAllFeatures() throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileFeature mobileFeature;
List<MobileFeature> mobileFeatures = new ArrayList<MobileFeature>();
ResultSet resultSet = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE";
stmt = conn.prepareStatement(selectDBQuery);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2));
mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5));
mobileFeatures.add(mobileFeature);
}
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileFeatures from the MDM database.");
}
return mobileFeatures;
} catch (SQLException e) {
String msg = "Error occurred while fetching all features.'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
}
}
@Override
public List<MobileFeature> getFeatureByDeviceType(String deviceType) throws MobileDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
MobileFeature mobileFeature;
List<MobileFeature> mobileFeatures = new ArrayList<>();
ResultSet resultSet = null;
try {
conn = this.getConnection();
String selectDBQuery =
"SELECT ID, CODE, NAME, DESCRIPTION, DEVICE_TYPE FROM AD_FEATURE" +
" WHERE DEVICE_TYPE = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, deviceType);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
mobileFeature = new MobileFeature();
mobileFeature.setId(resultSet.getInt(1));
mobileFeature.setCode(resultSet.getString(2));
mobileFeature.setName(resultSet.getString(3));
mobileFeature.setDescription(resultSet.getString(4));
mobileFeature.setDeviceType(resultSet.getString(5));
mobileFeatures.add(mobileFeature);
}
if (log.isDebugEnabled()) {
log.debug("Fetched all MobileFeatures of type " + deviceType + " from the MDM" +
" database.");
}
return mobileFeatures;
} catch (SQLException e) {
String msg = "Error occurred while fetching all features.'";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
} finally {
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
}
}
private Connection getConnection() throws MobileDeviceManagementDAOException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
String msg = "Error occurred while obtaining a connection from the mobile specific " +
"datasource.";
log.error(msg, e);
throw new MobileDeviceManagementDAOException(msg, e);
}
}
}

@ -1,139 +0,0 @@
/*
* 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.dao.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.config.datasource.JNDILookupDefinition;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementSchemaInitializer;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Hashtable;
import java.util.List;
/**
* Utility method required by MobileDeviceManagement DAO classes.
*/
public class MobileDeviceManagementDAOUtil {
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
public static DataSource lookupDataSource(String dataSourceName,
final Hashtable<Object, Object> jndiProperties){
try {
if (jndiProperties == null || jndiProperties.isEmpty()) {
return (DataSource) InitialContext.doLookup(dataSourceName);
}
final InitialContext context = new InitialContext(jndiProperties);
return (DataSource) context.lookup(dataSourceName);
} catch (Exception e) {
String msg = "Error in looking up data source: " + e.getMessage();
log.error(msg, e);
throw new RuntimeException(msg + e.getMessage(), e);
}
}
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
log.warn("Error occurred while closing result set", e);
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Error occurred while closing prepared statement", e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.warn("Error occurred while closing database connection", e);
}
}
}
public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
cleanupResources(null, stmt, rs);
}
/**
* Creates the mobile device management schema.
*
* @param dataSource Mobile data source
*/
public static void setupMobileDeviceManagementSchema(DataSource dataSource, String pluginType) throws MobileDeviceMgtPluginException {
MobileDeviceManagementSchemaInitializer initializer =
new MobileDeviceManagementSchemaInitializer(dataSource, pluginType);
log.info("Initializing mobile device management repository database schema for : " + pluginType);
try {
initializer.createRegistryDatabase();
} catch (Exception e) {
throw new MobileDeviceMgtPluginException("Error occurred while initializing Mobile Device " +
"Management database schema", e);
}
}
/**
* Resolve data source from the data source definition
*
* @param config data source configuration
* @return data source resolved from the data source definition
*/
private static DataSource resolveDataSource(MobileDataSourceConfig config) {
DataSource dataSource = null;
if (config == null) {
throw new RuntimeException(
"data source configuration " + "is null and " +
"thus, is not initialized");
}
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
if (jndiConfig != null) {
if (log.isDebugEnabled()) {
log.debug("Initializing data source using the JNDI " +
"Lookup Definition");
}
List<JNDILookupDefinition.JNDIProperty> jndiPropertyList =
jndiConfig.getJndiProperties();
if (jndiPropertyList != null) {
Hashtable<Object, Object> jndiProperties = new Hashtable<Object, Object>();
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
jndiProperties.put(prop.getName(), prop.getValue());
}
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
} else {
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
}
}
return dataSource;
}
}

@ -1,125 +0,0 @@
/*
* 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.dto;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
* DTO of MobileDevice.
*/
public class MobileDevice implements Serializable {
private String mobileDeviceId;
private String osVersion;
private String model;
private String vendor;
private String latitude;
private String longitude;
private String imei;
private String imsi;
private String serial;
private Map<String, String> deviceProperties;
public MobileDevice() {
this.deviceProperties = new HashMap<>();
}
public String getMobileDeviceId() {
return mobileDeviceId;
}
public void setMobileDeviceId(String mobileDeviceId) {
this.mobileDeviceId = mobileDeviceId;
}
public String getOsVersion() {
return osVersion;
}
public void setOsVersion(String osVersion) {
this.osVersion = osVersion;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public String getImsi() {
return imsi;
}
public void setImsi(String imsi) {
this.imsi = imsi;
}
public String getSerial() {
return serial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public Map<String, String> getDeviceProperties() {
return deviceProperties;
}
public void setDeviceProperties(Map<String, String> deviceProperties) {
this.deviceProperties = deviceProperties;
}
}

@ -1,86 +0,0 @@
/*
* 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.dto;
/**
* DTO of Mobile Device Operation Mappings.
*/
public class MobileDeviceOperationMapping {
private String deviceId;
private int operationId;
private long sentDate;
private long receivedDate;
private Status status;
public enum Status {
NEW, INPROGRESS, COMPLETED
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public void setStatus(String status) {
if(Status.NEW.name().equals(status)){
this.status = Status.NEW;
}else if(Status.INPROGRESS.name().equals(status)){
this.status = Status.INPROGRESS;
}else if(Status.COMPLETED.name().equals(status)){
this.status = Status.COMPLETED;
}
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public long getSentDate() {
return sentDate;
}
public void setSentDate(long sentDate) {
this.sentDate = sentDate;
}
public long getReceivedDate() {
return receivedDate;
}
public void setReceivedDate(long receivedDate) {
this.receivedDate = receivedDate;
}
}

@ -1,73 +0,0 @@
/*
* 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.dto;
import java.io.Serializable;
/**
* DTO of Mobile features.
*/
public class MobileFeature implements Serializable {
private int id;
private String deviceType;
private String code;
private String name;
private String description;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
}

@ -1,45 +0,0 @@
/*
* 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.dto;
/**
* DTO of Mobile feature property. Represents a property of a mobile feature.
*/
public class MobileFeatureProperty {
private String property;
private Integer featureID;
public Integer getFeatureID() {
return featureID;
}
public void setFeatureID(Integer featureID) {
this.featureID = featureID;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}

@ -1,64 +0,0 @@
/*
* 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.dto;
import java.util.List;
/**
* DTO of MobileOperation.
*/
public class MobileOperation {
private int operationId;
private String featureCode;
private long createdDate;
private List<MobileOperationProperty> properties;
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public List<MobileOperationProperty> getProperties() {
return properties;
}
public void setProperties(List<MobileOperationProperty> properties) {
this.properties = properties;
}
public String getFeatureCode() {
return featureCode;
}
public void setFeatureCode(String featureCode) {
this.featureCode = featureCode;
}
public long getCreatedDate() {
return createdDate;
}
public void setCreatedDate(long createdDate) {
this.createdDate = createdDate;
}
}

@ -1,54 +0,0 @@
/*
* 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.dto;
/**
* DTO of Mobile Operation property.
*/
public class MobileOperationProperty {
private int operationId;
private String property;
private String value;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public int getOperationId() {
return operationId;
}
public void setOperationId(int operationId) {
this.operationId = operationId;
}
public String getProperty() {
return property;
}
public void setProperty(String property) {
this.property = property;
}
}

@ -1,67 +0,0 @@
/*
* 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.internal;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService;
import org.wso2.carbon.registry.core.service.RegistryService;
/**
* DataHolder class of Mobile plugins component.
*/
public class MobileDeviceManagementDataHolder {
private RegistryService registryService;
private DeviceManagementService androidDeviceManagementService;
private GCMService gcmService;
private static MobileDeviceManagementDataHolder thisInstance = new MobileDeviceManagementDataHolder();
private MobileDeviceManagementDataHolder() {
}
public static MobileDeviceManagementDataHolder getInstance() {
return thisInstance;
}
public RegistryService getRegistryService() {
return registryService;
}
public void setRegistryService(RegistryService registryService) {
this.registryService = registryService;
}
public DeviceManagementService getAndroidDeviceManagementService() {
return androidDeviceManagementService;
}
public void setAndroidDeviceManagementService(
DeviceManagementService androidDeviceManagementService) {
this.androidDeviceManagementService = androidDeviceManagementService;
}
public GCMService getGCMService() {
return gcmService;
}
public void setGCMService(GCMService gcmService) {
this.gcmService = gcmService;
}
}

@ -1,181 +0,0 @@
/*
* 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.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.common.MobileDeviceMgtPluginException;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
import org.wso2.carbon.device.mgt.mobile.dao.AbstractMobileDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidPolicyMonitoringService;
import org.wso2.carbon.device.mgt.mobile.impl.android.gcm.GCMService;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagementService;
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsPolicyMonitoringService;
import org.wso2.carbon.ndatasource.core.DataSourceService;
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
import org.wso2.carbon.registry.core.service.RegistryService;
import java.util.Map;
/**
* @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent"
* immediate="true"
* @scr.reference name="org.wso2.carbon.ndatasource"
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDataSourceService"
* unbind="unsetDataSourceService"
* @scr.reference name="registry.service"
* interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1"
* policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
* <p/>
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
* to avoid as an ideal fix
*/
public class MobileDeviceManagementServiceComponent {
private ServiceRegistration androidServiceRegRef;
private ServiceRegistration windowsServiceRegRef;
private ServiceRegistration gcmServiceRegRef;
private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class);
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Mobile Device Management Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
/* Initialize the data source configuration */
MobileDeviceConfigurationManager.getInstance().initConfig();
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
.getMobileDeviceManagementConfig();
Map<String, MobileDataSourceConfig> dsConfigMap =
config.getMobileDeviceMgtRepository().getMobileDataSourceConfigMap();
AbstractMobileDeviceManagementDAOFactory.init(dsConfigMap);
String setupOption = System.getProperty("setup");
if (setupOption != null) {
if (log.isDebugEnabled()) {
log.debug(
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
"to begin");
}
try {
for (String pluginType : dsConfigMap.keySet()) {
MobileDeviceManagementDAOUtil
.setupMobileDeviceManagementSchema(AbstractMobileDeviceManagementDAOFactory.getDataSourceMap
().get(pluginType), pluginType);
}
} catch (MobileDeviceMgtPluginException e) {
log.error("Exception occurred while initializing mobile device management database schema", e);
}
}
DeviceManagementService androidDeviceManagementService = new AndroidDeviceManagementService();
GCMService gcmService = new GCMService();
androidServiceRegRef =
bundleContext.registerService(DeviceManagementService.class.getName(),
androidDeviceManagementService, null);
windowsServiceRegRef =
bundleContext.registerService(DeviceManagementService.class.getName(),
new WindowsDeviceManagementService(), null);
gcmServiceRegRef =
bundleContext.registerService(GCMService.class.getName(), gcmService, null);
// Policy management service
bundleContext.registerService(PolicyMonitoringService.class,
new AndroidPolicyMonitoringService(), null);
bundleContext.registerService(PolicyMonitoringService.class,
new WindowsPolicyMonitoringService(), null);
MobileDeviceManagementDataHolder.getInstance().setAndroidDeviceManagementService(
androidDeviceManagementService);
MobileDeviceManagementDataHolder.getInstance().setGCMService(gcmService);
if (log.isDebugEnabled()) {
log.debug("Mobile Device Management Service Component has been successfully activated");
}
} catch (Throwable e) {
log.error("Error occurred while activating Mobile Device Management Service Component", e);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("De-activating Mobile Device Management Service Component");
}
try {
if (androidServiceRegRef != null) {
androidServiceRegRef.unregister();
}
if (windowsServiceRegRef != null) {
windowsServiceRegRef.unregister();
}
if (gcmServiceRegRef != null) {
gcmServiceRegRef.unregister();
}
if (log.isDebugEnabled()) {
log.debug(
"Mobile Device Management Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
}
}
protected void setDataSourceService(DataSourceService dataSourceService) {
/* This is to avoid mobile device management component getting initialized before the underlying datasources
are registered */
if (log.isDebugEnabled()) {
log.debug("Data source service set to mobile service component");
}
}
protected void unsetDataSourceService(DataSourceService dataSourceService) {
//do nothing
}
protected void setRegistryService(RegistryService registryService) {
if (log.isDebugEnabled()) {
log.debug("RegistryService acquired");
}
MobileDeviceManagementDataHolder.getInstance().setRegistryService(registryService);
}
protected void unsetRegistryService(RegistryService registryService) {
MobileDeviceManagementDataHolder.getInstance().setRegistryService(null);
}
}

@ -1,62 +0,0 @@
/*
* 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.wso2.carbon.device.mgt.mobile.common.MobilePluginConstants;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
import javax.sql.DataSource;
import java.io.File;
/**
*
* Provides methods for initializing the database script.
*
*/
public final class MobileDeviceManagementSchemaInitializer extends DatabaseCreator {
private static final Log log = LogFactory.getLog(MobileDeviceManagementSchemaInitializer.class);
private static final String setupSQLScriptBaseLocation =
CarbonUtils.getCarbonHome() + File.separator + "dbscripts" + File.separator
+ MobilePluginConstants.MOBILE_DB_SCRIPTS_FOLDER +
File.separator + "plugins" + File.separator;
private String pluginType;
public String getPluginType() {
return pluginType;
}
public MobileDeviceManagementSchemaInitializer(DataSource dataSource, String pType) {
super(dataSource);
this.pluginType = pType;
}
protected String getDbScriptLocation(String databaseType) {
String scriptName = databaseType + ".sql";
String scriptLocation = setupSQLScriptBaseLocation + this.getPluginType() + File.separator + scriptName;
if (log.isDebugEnabled()) {
log.debug("Loading database script from :" + scriptLocation);
}
return scriptLocation;
}
}

@ -1,320 +0,0 @@
/*
* 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.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
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";
public static Document convertToDocument(File file) throws DeviceManagementException {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
try {
DocumentBuilder docBuilder = factory.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) {
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));
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_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;
}
}

@ -1,141 +0,0 @@
/*
* 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.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import java.io.File;
/**
* Class for holding unit-tests related to MobileDeviceManagementConfig class.
*/
public class MobileDeviceManagementConfigTests {
private static final Log log = LogFactory.getLog(MobileDeviceManagementConfigTests.class);
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY =
"./src/test/resources/config/malformed-mobile-config-no-mgt-repo.xml";
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG =
"./src/test/resources/config/malformed-mobile-config-no-ds-config.xml";
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG =
"./src/test/resources/config/malformed-mobile-config-no-jndi-config.xml";
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG =
"./src/test/resources/config/malformed-mobile-config-no-apis-config.xml";
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG =
"./src/test/resources/config/malformed-mobile-config-no-api-config.xml";
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG =
"./src/test/resources/config/malformed-mobile-config-no-api-publisher-config.xml";
private static final String TEST_CONFIG_SCHEMA_LOCATION =
"./src/test/resources/config/schema/MobileDeviceManagementConfigSchema.xsd";
private Schema schema;
@BeforeClass
private void initSchema() {
File deviceManagementSchemaConfig =
new File(MobileDeviceManagementConfigTests.TEST_CONFIG_SCHEMA_LOCATION);
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
try {
schema = factory.newSchema(deviceManagementSchemaConfig);
} catch (SAXException e) {
Assert.fail("Invalid schema found", e);
}
}
@Test
public void testMandateManagementRepositoryElement() {
File malformedConfig =
new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY);
this.validateMalformedConfig(malformedConfig);
}
@Test
public void testMandateDataSourceConfigurationElement() {
File malformedConfig = new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG);
this.validateMalformedConfig(malformedConfig);
}
@Test
public void testMandateJndiLookupDefinitionElement() {
File malformedConfig = new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG);
this.validateMalformedConfig(malformedConfig);
}
@Test
public void testMandateAPIPublisherElement() {
File malformedConfig = new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_PUBLISHER_CONFIG);
this.validateMalformedConfig(malformedConfig);
}
@Test
public void testMandateAPIsElement() {
File malformedConfig = new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_APIS_CONFIG);
this.validateMalformedConfig(malformedConfig);
}
@Test
public void testMandateAPIElement() {
File malformedConfig = new File(
MobileDeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_API_CONFIG);
this.validateMalformedConfig(malformedConfig);
}
/**
* Validates a given malformed-configuration file.
*/
private void validateMalformedConfig(File malformedConfig) {
try {
JAXBContext ctx = JAXBContext.newInstance(MobileDeviceManagementConfig.class);
Unmarshaller um = ctx.createUnmarshaller();
um.setSchema(this.getSchema());
um.unmarshal(malformedConfig);
Assert.assertTrue(false);
} catch (JAXBException e) {
Throwable linkedException = e.getLinkedException();
if (!(linkedException instanceof SAXParseException)) {
log.error("Unexpected error occurred while unmarshalling mobile device management config", e);
Assert.assertTrue(false);
}
Assert.assertTrue(true);
}
}
private Schema getSchema() {
return schema;
}
}

@ -1,29 +0,0 @@
/*
* 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.impl.common;
public enum DBTypes {
Oracle("Oracle"),H2("H2"),MySql("MySql");
String dbName ;
DBTypes(String dbStrName) {
dbName = dbStrName;
}
}

@ -1,90 +0,0 @@
/*
* 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.impl.common;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "Type")
public class TestDBConfiguration {
private String connectionURL;
private String driverClassName;
private String username;
private String password;
@Override public String toString() {
return "TestDataSourceConfiguration{" +
"ConnectionURL='" + connectionURL + '\'' +
", DriverClassName='" + driverClassName + '\'' +
", Username='" + username + '\'' +
", Password='" + password + '\'' +
", Type='" + dbType + '\'' +
'}';
}
private String dbType;
@XmlElement(name = "ConnectionURL", nillable = false)
public String getConnectionURL() {
return connectionURL;
}
public void setConnectionURL(String connectionURL) {
this.connectionURL = connectionURL;
}
@XmlElement(name = "DriverClassName", nillable = false)
public String getDriverClassName() {
return driverClassName;
}
public void setDriverClassName(String driverClassName) {
this.driverClassName = driverClassName;
}
@XmlElement(name = "Username", nillable = false)
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
@XmlElement(name = "Password", nillable = false)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@XmlAttribute(name = "name")
public String getType() {
return dbType;
}
public void setType(String type) {
this.dbType = type;
}
}

@ -1,39 +0,0 @@
/*
* 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.impl.common;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
@XmlRootElement(name = "TestDataSourceConfigurations")
public class TestDBConfigurations {
private List<TestDBConfiguration> dbTypesList;
@XmlElement(name = "Type")
public List<TestDBConfiguration> getDbTypesList() {
return dbTypesList;
}
public void setDbTypesList(List<TestDBConfiguration> dbTypesList) {
this.dbTypesList = dbTypesList;
}
}

@ -1,111 +0,0 @@
/*
* 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.impl.dao.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.mobile.impl.common.DBTypes;
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfiguration;
import org.wso2.carbon.device.mgt.mobile.impl.common.TestDBConfigurations;
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.File;
import java.sql.*;
/**
* This class provides the utility methods needed for DAO related test executions.
*/
public class MobileDatabaseUtils {
private static final Log log = LogFactory.getLog(MobileDatabaseUtils.class);
public static final String TEST_RESOURCES_DB_CONFIG_FILE =
"src/test/resources/testdbconfig.xml";
public static void cleanupResources(Connection conn, Statement stmt, ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
log.warn("Error occurred while closing result set", e);
}
}
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Error occurred while closing prepared statement", e);
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.warn("Error occurred while closing database connection", e);
}
}
}
public static TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws
MobileDeviceManagementDAOException,
DeviceManagementException {
File deviceMgtConfig = new File(TEST_RESOURCES_DB_CONFIG_FILE);
Document doc;
TestDBConfiguration testDBConfiguration = null;
TestDBConfigurations testDBConfigurations;
doc = MobileDeviceManagementUtil.convertToDocument(deviceMgtConfig);
JAXBContext testDBContext;
try {
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
} catch (JAXBException e) {
throw new MobileDeviceManagementDAOException("Error parsing test db configurations", e);
}
for (TestDBConfiguration testDBConfiguration1 : testDBConfigurations.getDbTypesList()) {
testDBConfiguration = testDBConfiguration1;
if (testDBConfiguration.getType().equals(dbType.toString())) {
break;
}
}
return testDBConfiguration;
}
public static void createH2DB(TestDBConfiguration testDBConf) throws Exception {
Connection conn = null;
Statement stmt = null;
try {
Class.forName(testDBConf.getDriverClassName());
conn = DriverManager.getConnection(testDBConf.getConnectionURL());
stmt = conn.createStatement();
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/h2.sql'");
} finally {
cleanupResources(conn, stmt, null);
}
}
}

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<ManagementRepository>
<DataSourceConfigurations>
<DataSourceConfiguration type="ios">
<JndiLookupDefinition>
<Name>jdbc/MobileIOSDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
<DataSourceConfiguration type="android">
<JndiLookupDefinition>
<Name>jdbc/MobileAndroidDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
<DataSourceConfiguration type="windows">
<JndiLookupDefinition>
<Name>jdbc/MobileWindowsDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
</DataSourceConfigurations>
</ManagementRepository>
</MobileDeviceMgtConfiguration>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<ManagementRepository>
<DataSourceConfiguration>
<JndiLookupDefinition>
<Name>jdbc/MobileDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
</ManagementRepository>
<MalformedAPIPublisher>
<APIs>
<API>
<Name>enrollment</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs>
</MalformedAPIPublisher>
</MobileDeviceMgtConfiguration>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<ManagementRepository>
<DataSourceConfiguration>
<JndiLookupDefinition>
<Name>jdbc/MobileDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
</ManagementRepository>
<APIPublisher>
<MalformedAPIs>
<API>
<Name>enrollment</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</MalformedAPIs>
</APIPublisher>
</MobileDeviceMgtConfiguration>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<ManagementRepository>
<MalformedDataSourceConfiguration>
<JndiLookupDefinition>
<Name>jdbc/MobileDM_DS</Name>
</JndiLookupDefinition>
</MalformedDataSourceConfiguration>
</ManagementRepository>
<APIPublisher>
<APIs>
<API>
<Name>enrollment</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs>
</APIPublisher>
</MobileDeviceMgtConfiguration>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<ManagementRepository>
<DataSourceConfiguration>
<MalformedJndiLookupDefinition>
<Name>jdbc/MobileDM_DS</Name>
</MalformedJndiLookupDefinition>
</DataSourceConfiguration>
</ManagementRepository>
<APIPublisher>
<APIs>
<API>
<Name>enrollment</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs>
</APIPublisher>
</MobileDeviceMgtConfiguration>

@ -1,42 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
~ 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.
-->
<MobileDeviceMgtConfiguration>
<MalformedManagementRepository>
<DataSourceConfiguration>
<JndiLookupDefinition>
<Name>jdbc/MobileDM_DS</Name>
</JndiLookupDefinition>
</DataSourceConfiguration>
</MalformedManagementRepository>
<APIPublisher>
<APIs>
<API>
<Name>enrollment</Name>
<Owner>admin</Owner>
<Context>enrollment</Context>
<Version>1.0.0</Version>
<Endpoint>http://localhost:9763/</Endpoint>
<Transports>http,https</Transports>
</API>
</APIs>
</APIPublisher>
</MobileDeviceMgtConfiguration>

@ -1,69 +0,0 @@
<?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.
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:element name="MobileDeviceMgtConfiguration">
<xs:complexType>
<xs:sequence>
<xs:element name="ManagementRepository" minOccurs="1" maxOccurs="1"
type="DataSourceConfigurationType"/>
<xs:element name="APIPublisher" minOccurs="1" maxOccurs="1"
type="APIsConfigurationType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="JndiLookupDefinitionType">
<xs:sequence>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DataSourceConfigurationType">
<xs:sequence>
<xs:element name="JndiLookupDefinition" minOccurs="1" maxOccurs="1"
type="JndiLookupDefinitionType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ManagementRepositoryType">
<xs:sequence>
<xs:element name="DataSourceConfiguration" minOccurs="1" maxOccurs="1"
type="DataSourceConfigurationType"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="APIConfigurationType">
<xs:all>
<xs:element name="Name" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Owner" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Context" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Version" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Endpoint" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="Transports" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
<xs:complexType name="APIsConfigurationType">
<xs:sequence>
<xs:element name="API" maxOccurs="unbounded"
type="APIConfigurationType"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

@ -1,33 +0,0 @@
#
# Copyright 2015 WSO2, Inc. (http://wso2.com)
#
# 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.
#
#
# This is the log4j configuration file used by WSO2 Carbon
#
# IMPORTANT : Please do not remove or change the names of any
# of the Appenders defined here. The layout pattern & log file
# can be changed using the WSO2 Carbon Management Console, and those
# settings will override the settings in this file.
#
log4j.rootLogger=DEBUG, STD_OUT
# Redirect log messages to console
log4j.appender.STD_OUT=org.apache.log4j.ConsoleAppender
log4j.appender.STD_OUT.Target=System.out
log4j.appender.STD_OUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STD_OUT.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

@ -1,54 +0,0 @@
-- -----------------------------------------------------
-- Table `AD_DEVICE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_DEVICE` (
`DEVICE_ID` VARCHAR(45) NOT NULL ,
`PUSH_TOKEN` VARCHAR(45) NULL DEFAULT NULL ,
`IMEI` VARCHAR(45) NULL DEFAULT NULL ,
`IMSI` VARCHAR(45) NULL DEFAULT NULL ,
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
`CHALLENGE` VARCHAR(45) NULL DEFAULT NULL,
`TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`UNLOCK_TOKEN` VARCHAR(500) NULL DEFAULT NULL,
`SERIAL` VARCHAR(45) NULL DEFAULT NULL,
PRIMARY KEY (`DEVICE_ID`) );
-- -----------------------------------------------------
-- Table `AD_FEATURE`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_FEATURE` (
`ID` INT NOT NULL AUTO_INCREMENT ,
`CODE` VARCHAR(45) NOT NULL,
`NAME` VARCHAR(100) NULL ,
`DESCRIPTION` VARCHAR(200) NULL ,
`DEVICE_TYPE` VARCHAR(50) NULL ,
PRIMARY KEY (`ID`) );
-- -----------------------------------------------------
-- Table `AD_OPERATION`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_OPERATION` (
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
`CREATED_DATE` BIGINT NULL ,
PRIMARY KEY (`OPERATION_ID`));
-- -----------------------------------------------------
-- Table `AD_FEATURE_PROPERTY`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `AD_FEATURE_PROPERTY` (
`PROPERTY` VARCHAR(45) NOT NULL ,
`FEATURE_ID` INT NOT NULL ,
PRIMARY KEY (`PROPERTY`) ,
CONSTRAINT `fk_AD_FEATURE_PROPERTY_AD_FEATURE1`
FOREIGN KEY (`FEATURE_ID` )
REFERENCES `AD_FEATURE` (`ID` )
ON DELETE NO ACTION
ON UPDATE NO ACTION);

@ -1,27 +0,0 @@
<!--
~ 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.
~ 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.
-->
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="CDM-Mobile-Tests">
<parameter name="useDefaultListeners" value="false"/>
<test name="Config Unit Tests" preserve-order="true">
<parameter name="dbType" value="H2"/>
<classes>
<class name="org.wso2.carbon.device.mgt.mobile.impl.MobileDeviceManagementConfigTests"/>
</classes>
</test>
</suite>

@ -1,82 +0,0 @@
<?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>device-mgt</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.mobile.url.printer</artifactId>
<version>2.1.0-SNAPSHOT</version>
<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.mobile.device.mgt.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>

@ -1,64 +0,0 @@
/*
* 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.url.printer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.mobile.url.printer.internal.URLPrinterDataHolder;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
public class URLPrinterStartupHandler implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(URLPrinterStartupHandler.class);
@Override
public void completingServerStartup() {
}
@Override
public void completedServerStartup() {
log.info("EMM Console URL : " + this.getEmmUrl());
}
private String getEmmUrl() {
// Hostname
String hostName = "localhost";
try {
hostName = NetworkUtils.getMgtHostName();
} catch (Exception ignored) {
}
// HTTPS port
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
ConfigurationContextService configContextService =
URLPrinterDataHolder.getInstance().getConfigurationContextService();
int port = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
int httpsProxyPort =
CarbonUtils.getTransportProxyPort(configContextService.getServerConfigContext(),
mgtConsoleTransport);
if (httpsProxyPort > 0) {
port = httpsProxyPort;
}
return "https://" + hostName + ":" + port + "/emm";
}
}

@ -1,42 +0,0 @@
/*
* 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.url.printer.internal;
import org.wso2.carbon.utils.ConfigurationContextService;
public class URLPrinterDataHolder {
private ConfigurationContextService configurationContextService;
private static URLPrinterDataHolder thisInstance = new URLPrinterDataHolder();
private URLPrinterDataHolder() {}
public static URLPrinterDataHolder getInstance() {
return thisInstance;
}
public ConfigurationContextService getConfigurationContextService() {
return configurationContextService;
}
public void setConfigurationContextService(ConfigurationContextService configurationContextService) {
this.configurationContextService = configurationContextService;
}
}

@ -1,73 +0,0 @@
/*
* 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.url.printer.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandler;
import org.wso2.carbon.utils.ConfigurationContextService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.mobile.url.printer.URLPrinterStartupHandlerServiceComponent"
* immediate="true"
* @scr.reference name="config.context.service"
* interface="org.wso2.carbon.utils.ConfigurationContextService"
* cardinality="0..1"
* policy="dynamic"
* bind="setConfigurationContextService"
* unbind="unsetConfigurationContextService"
*/
public class URLPrinterStartupHandlerServiceComponent {
private static final Log log = LogFactory.getLog(URLPrinterStartupHandlerServiceComponent.class);
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {
try {
BundleContext bundleContext = componentContext.getBundleContext();
/* Registering URL printer start-up handler */
bundleContext.registerService(ServerStartupObserver.class, new URLPrinterStartupHandler(), null);
} catch (Throwable e) {
log.error("Error occurred while activating URL printer server start-up handler service component", e);
}
}
@SuppressWarnings("unused")
protected void deactivate(ComponentContext componentContext) {
//do nothing
}
protected void setConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Setting ConfigurationContextService");
}
URLPrinterDataHolder.getInstance().setConfigurationContextService(configurationContextService);
}
protected void unsetConfigurationContextService(ConfigurationContextService configurationContextService) {
if (log.isDebugEnabled()) {
log.debug("Un-setting ConfigurationContextService");
}
URLPrinterDataHolder.getInstance().setConfigurationContextService(null);
}
}

@ -1,61 +0,0 @@
<?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>carbon-device-mgt-plugins-parent</artifactId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>device-mgt</artifactId>
<version>2.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon - Mobile Device Management Component</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.device.mgt.mobile.impl</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>

@ -1,261 +0,0 @@
<?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>camera-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.controller.service.impl</artifactId>
<packaging>war</packaging>
<name>WSO2 Carbon - IoT Server Camera API</name>
<description>WSO2 Carbon - Camera Service Controller API Implementation</description>
<url>http://wso2.org</url>
<dependencies>
<!-- CDM -->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope>
</dependency>
<!--MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>provided</scope>
</dependency>
<!--IOT -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.plugin.impl</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.queuing</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.base</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</exclusion>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload.wso2</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>${wso2.maven.compiler.source}</source>
<target>${wso2.maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>camera</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -1,261 +0,0 @@
<?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>camera-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.manager.service.impl</artifactId>
<packaging>war</packaging>
<name>WSO2 Carbon - IoT Server Camera API</name>
<description>WSO2 Carbon - Camera Service Management API Implementation</description>
<url>http://wso2.org</url>
<dependencies>
<!-- CDM -->
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.analytics</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--CXF -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<scope>provided</scope>
</dependency>
<!--MQTT -->
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<scope>provided</scope>
</dependency>
<!--IOT -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpasyncclient</artifactId>
<version>4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.plugin.impl</artifactId>
<scope>provided</scope>
</dependency>
<!--JAX-RS -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.bouncycastle.wso2</groupId>
<artifactId>bcprov-jdk15on</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.api</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.queuing</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.base</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.axis2.wso2</groupId>
<artifactId>axis2</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
</exclusion>
<exclusion>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
</exclusion>
<exclusion>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
</exclusion>
<exclusion>
<groupId>commons-fileupload.wso2</groupId>
<artifactId>commons-fileupload</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.ant.wso2</groupId>
<artifactId>ant</artifactId>
</exclusion>
<exclusion>
<groupId>commons-httpclient.wso2</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>javax.servlet</artifactId>
</exclusion>
<exclusion>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.registry.api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-codec.wso2</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smack</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack.wso2</groupId>
<artifactId>smackx</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>${wso2.maven.compiler.source}</source>
<target>${wso2.maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>camera_mgt</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -1,123 +0,0 @@
<?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>camera-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.plugin.impl</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - IoT Server Camera Management Plugin</name>
<description>WSO2 Carbon - Camera Management/Control Plugin Implementation</description>
<url>http://wso2.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>2.3.2</version>
</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>IoT Server Camera Impl Bundle</Bundle-Description>
<Private-Package>org.wso2.carbon.device.mgt.iot.camera.plugin.internal</Private-Package>
<Import-Package>
org.osgi.framework,
org.osgi.service.component,
org.apache.commons.logging,
javax.xml.bind.*,
javax.naming,
javax.sql,
javax.xml.bind.annotation.*,
javax.xml.parsers,
javax.net,
javax.net.ssl,
org.w3c.dom,
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.common,
org.wso2.carbon.context.*,
org.wso2.carbon.ndatasource.core,
org.wso2.carbon.device.mgt.iot.*,
</Import-Package>
<Export-Package>
!org.wso2.carbon.device.mgt.iot.camera.plugin.internal,
org.wso2.carbon.device.mgt.iot.camera.plugin.*
</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.logging</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
</dependency>
</dependencies>
</project>

@ -1,281 +0,0 @@
/*
* 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.iot.camera.plugin.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.util.IotDeviceManagementUtil;
import java.util.ArrayList;
import java.util.List;
/**
* This represents the FireAlarm implementation of DeviceManagerService.
*/
public class CameraManager implements DeviceManager {
private static final IotDeviceManagementDAOFactory iotDeviceManagementDAOFactory = new CameraDAO();
private static final Log log = LogFactory.getLog(CameraManager.class);
@Override
public FeatureManager getFeatureManager() {
return null;
}
@Override
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
throws DeviceManagementException {
//TODO implement this
return false;
}
@Override
public TenantConfiguration getConfiguration() throws DeviceManagementException {
//TODO implement this
return null;
}
@Override
public boolean enrollDevice(Device device) throws DeviceManagementException {
boolean status;
IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device);
try {
if (log.isDebugEnabled()) {
log.debug("Enrolling a new Camera device : " + device.getDeviceIdentifier());
}
CameraDAO.beginTransaction();
status = iotDeviceManagementDAOFactory.getIotDeviceDAO().addIotDevice(
iotDevice);
CameraDAO.commitTransaction();
} catch (IotDeviceManagementDAOException e) {
try {
CameraDAO.rollbackTransaction();
} catch (IotDeviceManagementDAOException iotDAOEx) {
String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while enrolling the Camera device : " + device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
boolean status;
IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device);
try {
if (log.isDebugEnabled()) {
log.debug("Modifying the Camera device enrollment data");
}
CameraDAO.beginTransaction();
status = iotDeviceManagementDAOFactory.getIotDeviceDAO()
.updateIotDevice(iotDevice);
CameraDAO.commitTransaction();
} catch (IotDeviceManagementDAOException e) {
try {
CameraDAO.rollbackTransaction();
} catch (IotDeviceManagementDAOException iotDAOEx) {
String msg = "Error occurred while roll back the update device transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while updating the enrollment of the Camera device : " +
device.getDeviceIdentifier();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean status;
try {
if (log.isDebugEnabled()) {
log.debug("Dis-enrolling Camera device : " + deviceId);
}
CameraDAO.beginTransaction();
status = iotDeviceManagementDAOFactory.getIotDeviceDAO()
.deleteIotDevice(deviceId.getId());
CameraDAO.commitTransaction();
} catch (IotDeviceManagementDAOException e) {
try {
CameraDAO.rollbackTransaction();
} catch (IotDeviceManagementDAOException iotDAOEx) {
String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
log.warn(msg, iotDAOEx);
}
String msg = "Error while removing the Camera device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
boolean isEnrolled = false;
try {
if (log.isDebugEnabled()) {
log.debug("Checking the enrollment of Camera device : " + deviceId.getId());
}
IotDevice iotDevice =
iotDeviceManagementDAOFactory.getIotDeviceDAO().getIotDevice(
deviceId.getId());
if (iotDevice != null) {
isEnrolled = true;
}
} catch (IotDeviceManagementDAOException e) {
String msg = "Error while checking the enrollment status of Camera device : " +
deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return isEnrolled;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
return true;
}
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
Device device;
try {
if (log.isDebugEnabled()) {
log.debug("Getting the details of Camera device : " + deviceId.getId());
}
IotDevice iotDevice = iotDeviceManagementDAOFactory.getIotDeviceDAO().
getIotDevice(deviceId.getId());
device = IotDeviceManagementUtil.convertToDevice(iotDevice);
} catch (IotDeviceManagementDAOException e) {
String msg = "Error while fetching the Camera device : " + deviceId.getId();
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return device;
}
@Override
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return true;
}
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
return false;
}
@Override
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
EnrolmentInfo.Status status) throws DeviceManagementException {
return false;
}
@Override
public License getLicense(String s) throws LicenseManagementException {
return null;
}
@Override
public void addLicense(License license) throws LicenseManagementException {
}
@Override
public boolean requireDeviceAuthorization() {
return false;
}
@Override
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
boolean status;
IotDevice iotDevice = IotDeviceManagementUtil.convertToIotDevice(device);
try {
if (log.isDebugEnabled()) {
log.debug(
"updating the details of Camera device : " + deviceIdentifier);
}
CameraDAO.beginTransaction();
status = iotDeviceManagementDAOFactory.getIotDeviceDAO()
.updateIotDevice(iotDevice);
CameraDAO.commitTransaction();
} catch (IotDeviceManagementDAOException e) {
try {
CameraDAO.rollbackTransaction();
} catch (IotDeviceManagementDAOException iotDAOEx) {
String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
log.warn(msg, iotDAOEx);
}
String msg =
"Error while updating the Camera device : " + deviceIdentifier;
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return status;
}
@Override
public List<Device> getAllDevices() throws DeviceManagementException {
List<Device> devices = null;
try {
if (log.isDebugEnabled()) {
log.debug("Fetching the details of all Camera devices");
}
List<IotDevice> iotDevices =
iotDeviceManagementDAOFactory.getIotDeviceDAO().getAllIotDevices();
if (iotDevices != null) {
devices = new ArrayList<Device>();
for (IotDevice iotDevice : iotDevices) {
devices.add(IotDeviceManagementUtil.convertToDevice(iotDevice));
}
}
} catch (IotDeviceManagementDAOException e) {
String msg = "Error while fetching all Camera devices.";
log.error(msg, e);
throw new DeviceManagementException(msg, e);
}
return devices;
}
}

@ -1,112 +0,0 @@
/*
* 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.iot.camera.plugin.impl;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants;
import java.util.List;
public class CameraManagerService implements DeviceManagementService{
private DeviceManager deviceManager;
@Override
public String getType() {
return CameraConstants.DEVICE_TYPE;
}
@Override
public String getProviderTenantDomain() {
return "carbon.super";
}
@Override
public boolean isSharedWithAllTenants() {
return true;
}
@Override
public String[] getSharedTenantsDomain() {
return new String[0];
}
@Override
public void init() throws DeviceManagementException {
this.deviceManager=new CameraManager();
}
@Override
public DeviceManager getDeviceManager() {
return deviceManager;
}
@Override
public ApplicationManager getApplicationManager() {
return null;
}
@Override
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
throws DeviceManagementException {
}
@Override
public Application[] getApplications(String domain, int pageNumber, int size)
throws ApplicationManagementException {
return new Application[0];
}
@Override
public void updateApplicationStatus(DeviceIdentifier deviceId, Application application,
String status) throws ApplicationManagementException {
}
@Override
public String getApplicationStatus(DeviceIdentifier deviceId, Application application)
throws ApplicationManagementException {
return null;
}
@Override
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws ApplicationManagementException {
}
@Override
public void installApplicationForUsers(Operation operation, List<String> userNameList)
throws ApplicationManagementException {
}
@Override
public void installApplicationForUserRoles(Operation operation, List<String> userRoleList)
throws ApplicationManagementException {
}
}

@ -1,121 +0,0 @@
/*
* 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.iot.camera.plugin.impl.dao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants;
import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.impl.CameraDeviceDAOImpl;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactoryInterface;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
public class CameraDAO extends IotDeviceManagementDAOFactory implements IotDeviceManagementDAOFactoryInterface {
private static final Log log = LogFactory.getLog(CameraDAO.class);
static DataSource dataSource;
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
public CameraDAO() {
initFireAlarmDAO();
}
public static void initFireAlarmDAO() {
dataSource = getDataSourceMap().get(CameraConstants.DEVICE_TYPE);
}
@Override public IotDeviceDAO getIotDeviceDAO() {
return new CameraDeviceDAOImpl();
}
public static void beginTransaction() throws IotDeviceManagementDAOException {
try {
Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);
currentConnection.set(conn);
} catch (SQLException e) {
throw new IotDeviceManagementDAOException("Error occurred while retrieving datasource connection", e);
}
}
public static Connection getConnection() throws IotDeviceManagementDAOException {
if (currentConnection.get() == null) {
try {
currentConnection.set(dataSource.getConnection());
} catch (SQLException e) {
throw new IotDeviceManagementDAOException("Error occurred while retrieving data source connection", e);
}
}
return currentConnection.get();
}
public static void commitTransaction() throws IotDeviceManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.commit();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence commit "
+ "has not been attempted");
}
}
} catch (SQLException e) {
throw new IotDeviceManagementDAOException("Error occurred while committing the transaction", e);
} finally {
closeConnection();
}
}
public static void closeConnection() throws IotDeviceManagementDAOException {
Connection con = currentConnection.get();
if (con != null) {
try {
con.close();
} catch (SQLException e) {
log.error("Error occurred while close the connection");
}
}
currentConnection.remove();
}
public static void rollbackTransaction() throws IotDeviceManagementDAOException {
try {
Connection conn = currentConnection.get();
if (conn != null) {
conn.rollback();
} else {
if (log.isDebugEnabled()) {
log.debug("Datasource connection associated with the current thread is null, hence rollback "
+ "has not been attempted");
}
}
} catch (SQLException e) {
throw new IotDeviceManagementDAOException("Error occurred while rollback the transaction", e);
} finally {
closeConnection();
}
}
}

@ -1,237 +0,0 @@
/*
* 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.iot.camera.plugin.impl.dao.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.iot.camera.plugin.constants.CameraConstants;
import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.dao.CameraDAO;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceDAO;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOException;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dto.IotDevice;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Implements IotDeviceDAO for camera Devices.
*/
public class CameraDeviceDAOImpl implements IotDeviceDAO{
private static final Log log = LogFactory.getLog(CameraDeviceDAOImpl.class);
@Override
public IotDevice getIotDevice(String iotDeviceId)
throws IotDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
IotDevice iotDevice = null;
ResultSet resultSet = null;
try {
conn = CameraDAO.getConnection();
String selectDBQuery =
"SELECT CAMERA_DEVICE_ID, DEVICE_NAME" +
" FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?";
stmt = conn.prepareStatement(selectDBQuery);
stmt.setString(1, iotDeviceId);
resultSet = stmt.executeQuery();
if (resultSet.next()) {
iotDevice = new IotDevice();
iotDevice.setIotDeviceName(resultSet.getString(
CameraConstants.DEVICE_PLUGIN_DEVICE_NAME));
Map<String, String> propertyMap = new HashMap<String, String>();
iotDevice.setDeviceProperties(propertyMap);
if (log.isDebugEnabled()) {
log.debug("Camera device " + iotDeviceId + " data has been fetched from " +
"Camera database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while fetching Camera device : '" + iotDeviceId + "'";
log.error(msg, e);
throw new IotDeviceManagementDAOException(msg, e);
} finally {
IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
CameraDAO.closeConnection();
}
return iotDevice;
}
@Override
public boolean addIotDevice(IotDevice iotDevice)
throws IotDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = CameraDAO.getConnection();
String createDBQuery =
"INSERT INTO CAMERA_DEVICE(CAMERA_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)";
stmt = conn.prepareStatement(createDBQuery);
stmt.setString(1, iotDevice.getIotDeviceId());
stmt.setString(2,iotDevice.getIotDeviceName());
if (iotDevice.getDeviceProperties() == null) {
iotDevice.setDeviceProperties(new HashMap<String, String>());
}
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" +
" added to the Camere database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while adding the Camera device '" +
iotDevice.getIotDeviceId() + "' to the Camera db.";
log.error(msg, e);
throw new IotDeviceManagementDAOException(msg, e);
} finally {
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
return status;
}
@Override
public boolean updateIotDevice(IotDevice iotDevice)
throws IotDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = CameraDAO.getConnection();
String updateDBQuery =
"UPDATE CAMERA_DEVICE SET DEVICE_NAME = ? WHERE CAMERA_DEVICE_ID = ?";
stmt = conn.prepareStatement(updateDBQuery);
if (iotDevice.getDeviceProperties() == null) {
iotDevice.setDeviceProperties(new HashMap<String, String>());
}
stmt.setString(1, iotDevice.getIotDeviceName());
stmt.setString(2, iotDevice.getIotDeviceId());
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Camera device " + iotDevice.getIotDeviceId() + " data has been" +
" modified.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while modifying the Camera device '" +
iotDevice.getIotDeviceId() + "' data.";
log.error(msg, e);
throw new IotDeviceManagementDAOException(msg, e);
} finally {
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
return status;
}
@Override
public boolean deleteIotDevice(String iotDeviceId)
throws IotDeviceManagementDAOException {
boolean status = false;
Connection conn = null;
PreparedStatement stmt = null;
try {
conn = CameraDAO.getConnection();
String deleteDBQuery =
"DELETE FROM CAMERA_DEVICE WHERE CAMERA_DEVICE_ID = ?";
stmt = conn.prepareStatement(deleteDBQuery);
stmt.setString(1, iotDeviceId);
int rows = stmt.executeUpdate();
if (rows > 0) {
status = true;
if (log.isDebugEnabled()) {
log.debug("Camera device " + iotDeviceId + " data has deleted from the Camera database.");
}
}
} catch (SQLException e) {
String msg = "Error occurred while deleting Camera device " + iotDeviceId;
log.error(msg, e);
throw new IotDeviceManagementDAOException(msg, e);
} finally {
IotDeviceManagementDAOUtil.cleanupResources(stmt, null);
}
return status;
}
@Override
public List<IotDevice> getAllIotDevices()
throws IotDeviceManagementDAOException {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet resultSet = null;
IotDevice iotDevice;
List<IotDevice> iotDevices = new ArrayList<IotDevice>();
try {
conn = CameraDAO.getConnection();
String selectDBQuery =
"SELECT CAMERA_DEVICE_ID, DEVICE_NAME " +
"FROM CAMERA_DEVICE";
stmt = conn.prepareStatement(selectDBQuery);
resultSet = stmt.executeQuery();
while (resultSet.next()) {
iotDevice = new IotDevice();
iotDevice.setIotDeviceId(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_ID));
iotDevice.setIotDeviceName(resultSet.getString(CameraConstants.DEVICE_PLUGIN_DEVICE_NAME));
Map<String, String> propertyMap = new HashMap<String, String>();
iotDevice.setDeviceProperties(propertyMap);
iotDevices.add(iotDevice);
}
if (log.isDebugEnabled()) {
log.debug("All Camera device details have fetched from Firealarm database.");
}
return iotDevices;
} catch (SQLException e) {
String msg = "Error occurred while fetching all Camera device data'";
log.error(msg, e);
throw new IotDeviceManagementDAOException(msg, e);
} finally {
IotDeviceManagementDAOUtil.cleanupResources(stmt, resultSet);
CameraDAO.closeConnection();
}
}
}

@ -1,45 +0,0 @@
/*
* 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.iot.camera.plugin.impl.util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.Map;
/**
* Contains utility methods used by FireAlarm plugin.
*/
public class VirtualFireAlarmUtils {
private static Log log = LogFactory.getLog(VirtualFireAlarmUtils.class);
public static String getDeviceProperty(Map<String, String> deviceProperties, String property) {
String deviceProperty = deviceProperties.get(property);
if (deviceProperty == null) {
return "";
}
return deviceProperty;
}
}

@ -1,98 +0,0 @@
/*
* 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.iot.camera.plugin.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.iot.camera.plugin.impl.CameraManagerService;
import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService;
/**
* @scr.component name="org.wso2.carbon.device.mgt.iot.camera.plugin.internal
* .CameraManagementServiceComponent"
* immediate="true"
* @scr.reference name="org.wso2.carbon.device.mgt.iot.service.DeviceTypeServiceImpl"
* interface="org.wso2.carbon.device.mgt.iot.service.DeviceTypeService"
* cardinality="1..1"
* policy="dynamic"
* bind="setDeviceTypeService"
* unbind="unsetDeviceTypeService"
*/
public class CameraManagementServiceComponent {
private static final Log log = LogFactory.getLog(CameraManagementServiceComponent.class);
private ServiceRegistration firealarmServiceRegRef;
protected void activate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("Activating Camera Device Management Service Component");
}
try {
BundleContext bundleContext = ctx.getBundleContext();
firealarmServiceRegRef =
bundleContext.registerService(DeviceManagementService.class.getName(),
new CameraManagerService(), null);
if (log.isDebugEnabled()) {
log.debug(
"Camera Device Management Service Component has been successfully activated");
}
} catch (Throwable e) {
log.error(
"Error occurred while activating Camera Device Management Service Component", e);
}
}
protected void deactivate(ComponentContext ctx) {
if (log.isDebugEnabled()) {
log.debug("De-activating Camera Device Management Service Component");
}
try {
if (firealarmServiceRegRef != null) {
firealarmServiceRegRef.unregister();
}
if (log.isDebugEnabled()) {
log.debug(
"Camera Device Management Service Component has been successfully de-activated");
}
} catch (Throwable e) {
log.error(
"Error occurred while de-activating Camera Device Management bundle", e);
}
}
protected void setDeviceTypeService(DeviceTypeService deviceTypeService) {
/* This is to avoid this component getting initialized before the common registered */
if (log.isDebugEnabled()) {
log.debug("Data source service set to mobile service component");
}
}
protected void unsetDeviceTypeService(DeviceTypeService deviceTypeService) {
//do nothing
}
}

@ -1,62 +0,0 @@
<?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>camera-plugin</artifactId>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.iot.camera.ui</artifactId>
<name>WSO2 Carbon - IoT Server Camera UI</name>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<finalName>${project.artifactId}-${carbon.device.mgt.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>

@ -1,63 +0,0 @@
<?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>iot-plugins</artifactId>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>camera-plugin</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - Arduino Plugin</name>
<url>http://wso2.org</url>
<modules>
<module>org.wso2.carbon.device.mgt.iot.camera.controller.service.impl</module>
<module>org.wso2.carbon.device.mgt.iot.camera.manager.service.impl</module>
<module>org.wso2.carbon.device.mgt.iot.camera.plugin.impl</module>
<module>org.wso2.carbon.device.mgt.iot.camera.ui</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>

@ -22,7 +22,10 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@ -33,7 +36,17 @@ import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord;
import javax.jws.WebService;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
@ -97,22 +110,6 @@ import java.util.List;
}
}
@Path("/device/user/{username}/ungrouped")
@GET
@Consumes("application/json")
@Produces("application/json")
public Device[] getUnGroupedDevices(@PathParam("username") String username){
try{
List<Device> devices = this.getServiceProvider().getUnGroupedDevices(username);
return this.getActiveDevices(devices);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
return null;
} finally {
this.endTenantFlow();
}
}
@Path("/device/user/{username}/all/count")
@GET
@Consumes("application/json")
@ -205,66 +202,6 @@ import java.util.List;
}
}
@Path("/device/enrollment/invitation")
@POST
@Consumes("application/json")
@Produces("application/json")
public void sendEnrolmentInvitation(@FormParam("messageBody") String messageBody,
@FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList,
@FormParam("bccList") String[] bccList, @FormParam("subject") String subject,
@FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl,
@FormParam("title") String title, @FormParam("password") String password,
@FormParam("userName") String userName){
EmailMessageProperties config = new EmailMessageProperties();
config.setMessageBody(messageBody);
config.setMailTo(mailTo);
config.setCcList(ccList);
config.setBccList(bccList);
config.setSubject(subject);
config.setFirstName(firstName);
config.setEnrolmentUrl(enrolmentUrl);
config.setTitle(title);
config.setUserName(userName);
config.setPassword(password);
try {
this.getServiceProvider().sendEnrolmentInvitation(config);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
} finally {
this.endTenantFlow();
}
}
@Path("/device/registration/invitation")
@POST
@Consumes("application/json")
@Produces("application/json")
public void sendRegistrationEmail(@FormParam("messageBody") String messageBody,
@FormParam("mailTo") String[] mailTo, @FormParam("ccList") String[] ccList,
@FormParam("bccList") String[] bccList, @FormParam("subject") String subject,
@FormParam("firstName") String firstName, @FormParam("enrolmentUrl") String enrolmentUrl,
@FormParam("title") String title, @FormParam("password") String password,
@FormParam("userName") String userName){
EmailMessageProperties config = new EmailMessageProperties();
config.setMessageBody(messageBody);
config.setMailTo(mailTo);
config.setCcList(ccList);
config.setBccList(bccList);
config.setSubject(subject);
config.setFirstName(firstName);
config.setEnrolmentUrl(enrolmentUrl);
config.setTitle(title);
config.setUserName(userName);
config.setPassword(password);
try {
this.getServiceProvider().sendRegistrationEmail(config);
} catch (DeviceManagementException e) {
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
} finally {
this.endTenantFlow();
}
}
@Path("/device/type/{type}/config")
@GET
@Consumes("application/json")
@ -394,10 +331,12 @@ import java.util.List;
@Produces("application/json")
boolean modifyEnrollment(@PathParam("type") String type, @PathParam("identifier") String identifier,
@FormParam("name") String name, @FormParam("description") String description,
@FormParam("groupId") int groupId, @FormParam("enrollmentId") int enrollmentId,
@FormParam("dateOfEnrolment") long dateOfEnrolment, @FormParam("dateOfLastUpdate") long dateOfLastUpdate,
@FormParam("ownership") EnrolmentInfo.OwnerShip ownership, @FormParam("status") EnrolmentInfo.Status status,
@FormParam("owner") String owner){
@FormParam("enrollmentId") int enrollmentId,
@FormParam("dateOfEnrolment") long dateOfEnrolment,
@FormParam("dateOfLastUpdate") long dateOfLastUpdate,
@FormParam("ownership") EnrolmentInfo.OwnerShip ownership,
@FormParam("status") EnrolmentInfo.Status status,
@FormParam("owner") String owner) {
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setId(enrollmentId);
@ -412,7 +351,6 @@ import java.util.List;
device.setDeviceIdentifier(identifier);
device.setName(name);
device.setDescription(description);
device.setGroupId(groupId);
device.setEnrolmentInfo(enrolmentInfo);
try {
return this.getServiceProvider().modifyEnrollment(device);
@ -430,10 +368,12 @@ import java.util.List;
@Produces("application/json")
boolean enrollDevice(@FormParam("type") String type, @FormParam("identifier") String identifier,
@FormParam("name") String name, @FormParam("description") String description,
@FormParam("groupId") int groupId, @FormParam("enrollmentId") int enrollmentId,
@FormParam("dateOfEnrolment") long dateOfEnrolment, @FormParam("dateOfLastUpdate") long dateOfLastUpdate,
@FormParam("ownership") EnrolmentInfo.OwnerShip ownership, @FormParam("status") EnrolmentInfo.Status status,
@FormParam("owner") String owner){
@FormParam("enrollmentId") int enrollmentId,
@FormParam("dateOfEnrolment") long dateOfEnrolment,
@FormParam("dateOfLastUpdate") long dateOfLastUpdate,
@FormParam("ownership") EnrolmentInfo.OwnerShip ownership,
@FormParam("status") EnrolmentInfo.Status status,
@FormParam("owner") String owner) {
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
enrolmentInfo.setId(enrollmentId);
@ -448,7 +388,6 @@ import java.util.List;
device.setDeviceIdentifier(identifier);
device.setName(name);
device.setDescription(description);
device.setGroupId(groupId);
device.setEnrolmentInfo(enrolmentInfo);
try {
return this.getServiceProvider().enrollDevice(device);

@ -27,10 +27,10 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.PaginationRequest;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.group.common.DeviceGroup;
import org.wso2.carbon.device.mgt.group.common.GroupManagementException;
import org.wso2.carbon.device.mgt.group.common.GroupUser;
import org.wso2.carbon.device.mgt.group.core.providers.GroupManagementServiceProvider;
import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupManagementException;
import org.wso2.carbon.device.mgt.common.group.mgt.GroupUser;
import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
import org.wso2.carbon.device.mgt.iot.util.ResponsePayload;
import javax.jws.WebService;
@ -73,7 +73,7 @@ public class GroupManagerService {
private HttpServletResponse response;
private PrivilegedCarbonContext ctx;
private GroupManagementServiceProvider getServiceProvider() {
private GroupManagementProviderService getServiceProvider() {
String tenantDomain = CarbonContext.getThreadLocalCarbonContext().getTenantDomain();
String username = CarbonContext.getThreadLocalCarbonContext().getUsername();
PrivilegedCarbonContext.startTenantFlow();
@ -82,7 +82,7 @@ public class GroupManagerService {
if (log.isDebugEnabled()) {
log.debug("Getting thread local carbon context for tenant domain: " + tenantDomain);
}
return (GroupManagementServiceProvider) ctx.getOSGiService(GroupManagementServiceProvider.class, null);
return (GroupManagementProviderService) ctx.getOSGiService(GroupManagementProviderService.class, null);
}
private void endTenantFlow() {
@ -108,7 +108,7 @@ public class GroupManagerService {
group.setDateOfLastUpdate(new Date().getTime());
boolean isAdded = false;
try {
GroupManagementServiceProvider groupManagementService = this.getServiceProvider();
GroupManagementProviderService groupManagementService = this.getServiceProvider();
int groupId = groupManagementService.createGroup(group, DEFAULT_ADMIN_ROLE, DEFAULT_ADMIN_PERMISSIONS);
if (groupId == -2) {
ResponsePayload responsePayload = new ResponsePayload();
@ -151,7 +151,7 @@ public class GroupManagerService {
return false;
}
try {
GroupManagementServiceProvider groupManagementService = this.getServiceProvider();
GroupManagementProviderService groupManagementService = this.getServiceProvider();
DeviceGroup group = groupManagementService.getGroup(groupId);
group.setName(name);
group.setDescription(description);
@ -219,7 +219,7 @@ public class GroupManagerService {
@FormParam("username") String username) {
DeviceGroup[] deviceGroups = null;
try {
List<DeviceGroup> groups = this.getServiceProvider().findGroups(groupName, username);
List<DeviceGroup> groups = this.getServiceProvider().findInGroups(groupName, username);
deviceGroups = new DeviceGroup[groups.size()];
response.setStatus(Response.Status.OK.getStatusCode());
groups.toArray(deviceGroups);
@ -240,7 +240,7 @@ public class GroupManagerService {
@QueryParam("permission") String permission) {
DeviceGroup[] deviceGroups = null;
try {
GroupManagementServiceProvider groupManagementService = this.getServiceProvider();
GroupManagementProviderService groupManagementService = this.getServiceProvider();
List<DeviceGroup> groups;
if (permission != null) {
groups = groupManagementService.getGroups(username, permission);
@ -475,7 +475,7 @@ public class GroupManagerService {
@GET
@Consumes("application/json")
@Produces("application/json")
public PaginationResult getDevices(@PathParam("groupId") int groupId,
public List<Device> getDevices(@PathParam("groupId") int groupId,
@QueryParam("index") int index,
@QueryParam("limit") int limit) {
try {

@ -1,103 +0,0 @@
/*
* 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.iot.api;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.common.AnalyticsDataRecord;
import org.wso2.carbon.device.mgt.analytics.exception.DeviceManagementAnalyticsException;
import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService;
import javax.jws.WebService;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@WebService public class StatsManagerService {
private static Log log = LogFactory.getLog(StatsManagerService.class);
@Context //injected response proxy supporting multiple thread
private HttpServletResponse response;
//TODO THIS NEEDS TO BE REMOVED.
@Path("/stats/device/type/{type}/identifier/{identifier}")
@GET
@Consumes("application/json")
@Produces("application/json")
public DeviceUsageDTO[] getDeviceStats(@PathParam("type") String type, @PathParam("identifier") String identifier,
@QueryParam("table") String table, @QueryParam("column") String column, @QueryParam("username") String user,
@QueryParam("from") long from, @QueryParam("to") long to) {
String fromDate = String.valueOf(from);
String toDate = String.valueOf(to);
List<DeviceUsageDTO> deviceUsageDTOs = new ArrayList<>();
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain("carbon.super", true);
DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx
.getOSGiService(DeviceAnalyticsService.class, null);
String query = "owner:" + user + " AND deviceId:" + identifier + " AND deviceType:" + type +
" AND time : [" + fromDate + " TO " + toDate + "]";
try {
List<AnalyticsDataRecord> records = deviceAnalyticsService.getAllEventsForDevice(table, query);
Collections.sort(records, new Comparator<AnalyticsDataRecord>() {
@Override
public int compare(AnalyticsDataRecord o1, AnalyticsDataRecord o2) {
long t1 = (Long) o1.getValue("time");
long t2 = (Long) o2.getValue("time");
if (t1 < t2) {
return -1;
} else if (t1 > t2) {
return 1;
} else {
return 0;
}
}
});
for (AnalyticsDataRecord record : records) {
DeviceUsageDTO deviceUsageDTO = new DeviceUsageDTO();
deviceUsageDTO.setTime("" + (long)record.getValue("time"));
deviceUsageDTO.setValue("" + (float) record.getValue(column.toLowerCase()));
deviceUsageDTOs.add(deviceUsageDTO);
}
return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]);
} catch (DeviceManagementAnalyticsException e) {
String errorMsg= "Error on retrieving stats on table " + table + " with query " + query;
log.error(errorMsg);
response.setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode());
return deviceUsageDTOs.toArray(new DeviceUsageDTO[deviceUsageDTOs.size()]);
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
}
}

@ -45,16 +45,6 @@
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="StatsManager" address="/stats_manager">
<jaxrs:serviceBeans>
<bean id="StatsManagerService"
class="org.wso2.carbon.device.mgt.iot.api.StatsManagerService"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="PolicyManager" address="/policy_manager">
<jaxrs:serviceBeans>
<bean id="PolicyManagerService"
@ -65,15 +55,5 @@
</jaxrs:providers>
</jaxrs:server>
<!--<jaxrs:server id="TokenManager" address="/token_manager">-->
<!--<jaxrs:serviceBeans>-->
<!--<bean id="TokenManagerService"-->
<!--class="org.wso2.carbon.device.mgt.iot.common.api.TokenManagerService"/>-->
<!--</jaxrs:serviceBeans>-->
<!--<jaxrs:providers>-->
<!--<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />-->
<!--</jaxrs:providers>-->
<!--</jaxrs:server>-->
</beans>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ 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
@ -13,10 +13,11 @@
~ 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
~ 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">
@ -66,24 +67,17 @@
javax.xml.namespace;resolution:=optional,
javax.xml.validation;resolution:=optional,
org.apache.commons.codec.binary,
org.apache.commons.collections.map,
org.apache.http.*,
org.apache.commons.io.*,
org.apache.commons.logging.*,
org.json;version="${commons-json.version}",
org.wso2.carbon.base.*,
org.wso2.carbon.databridge.*,
org.wso2.carbon.user.api,
org.wso2.carbon.user.core.service,
org.osgi.framework,
org.osgi.service.component,
javax.xml.bind.*;resolution:=optional,
javax.naming;resolution:=optional,
javax.sql;resolution:=optional,
javax.xml.bind.annotation.*;resolution:=optional,
javax.xml.parsers.*;resolution:=optional,
javax.net;resolution:=optional,
javax.net.ssl;resolution:=optional,
javax.crypto,
org.apache.tomcat.util.codec.binary,
org.w3c.dom;resolution:=optional,
@ -92,7 +86,6 @@
org.wso2.carbon.device.mgt.common.*,
org.wso2.carbon.device.mgt.core.*,
org.wso2.carbon.context.*;version="${carbon.kernel.version.range}",
org.wso2.carbon.ndatasource.core;version="${carbon.kernel.version.range}",
org.eclipse.paho.client.mqttv3.*;version="${eclipse.paho.version}"
</Import-Package>
<Export-Package>
@ -144,6 +137,12 @@
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
<exclusions>
<exclusion>
<groupId>org.apache.httpcomponents.wso2</groupId>
<artifactId>httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>

@ -27,20 +27,18 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
<artifactId>iot-plugins</artifactId>
<packaging>pom</packaging>
<name>WSO2 Carbon - IoT Plugins</name>
<url>http://wso2.org</url>
<modules>
<module>androidsense-plugin</module>
<module>arduino-plugin</module>
<module>camera-plugin</module>
<module>digital-display-plugin</module>
<module>drone-analyzer-plugin</module>
<module>raspberrypi-plugin</module>
<module>virtual-fire-alarm-plugin</module>
<!--<module>androidsense-plugin</module>-->
<!--<module>arduino-plugin</module>-->
<!--<module>digital-display-plugin</module>-->
<!--<module>drone-analyzer-plugin</module>-->
<!--<module>raspberrypi-plugin</module>-->
<!--<module>virtual-fire-alarm-plugin</module>-->
<module>iot-base-plugin</module>
</modules>

@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
~ 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
@ -28,7 +28,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.agent</artifactId>
<artifactId>org.wso2.carbon.device.mgt.mobile.android.api</artifactId>
<name>WSO2 Carbon - Android JAX-RS API</name>
<description>Android JAX-RS API</description>
<packaging>war</packaging>

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,17 +1,17 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http:www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* 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
@ -11,7 +11,7 @@
* 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
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save