mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge branch 'master' of https://github.com/geethkokila/product-cdm
Conflicts: components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/DeviceManagementRepository.java components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/internal/DeviceManagementServiceComponent.java product/modules/mobileservices/agents/android/jax-rs/src/main/java/org/wso2/cdmserver/mobileservices/android/util/AndroidAPIUtils.java product/pom.xml
This commit is contained in:
commit
72a3df080b
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -13,21 +13,48 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.common;
|
package org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
/**
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
* This class needs to be implemented by all
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
*/
|
import java.util.Properties;
|
||||||
public interface Operation {
|
|
||||||
|
|
||||||
/**
|
@XmlRootElement
|
||||||
* Initializes any start-up resources required to execute a particular operation
|
public class Operation {
|
||||||
*/
|
|
||||||
void init();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes the functionality configured within the method implementation
|
|
||||||
*/
|
|
||||||
void execute();
|
|
||||||
|
|
||||||
|
public enum Type {
|
||||||
|
CONFIG, MESSAGE, INFO
|
||||||
|
}
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private Properties properties;
|
||||||
|
private Type type;
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public Properties getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(Properties properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
@XmlElement
|
||||||
|
public Type getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(Type type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -1,75 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2014, 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.common;
|
|
||||||
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
public class OperationData {
|
|
||||||
|
|
||||||
public enum Type {
|
|
||||||
CONFIG, MESSAGE, STATE
|
|
||||||
}
|
|
||||||
|
|
||||||
private String name;
|
|
||||||
private boolean state;
|
|
||||||
private Properties properties;
|
|
||||||
private String text;
|
|
||||||
private Type type;
|
|
||||||
|
|
||||||
public OperationData(String name, Type type) {
|
|
||||||
this.type = type;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationData(String name, boolean state) {
|
|
||||||
this.name = name;
|
|
||||||
this.type = Type.STATE;
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationData(String name, Properties properties) {
|
|
||||||
this.name = name;
|
|
||||||
this.type = Type.CONFIG;
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OperationData(String name, String text) {
|
|
||||||
this.name = name;
|
|
||||||
this.type = Type.MESSAGE;
|
|
||||||
this.text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getText() {
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2012, 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.common;
|
|
||||||
|
|
||||||
public class OperationFactory {
|
|
||||||
|
|
||||||
public static Operation getOperation(String type) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -15,8 +15,33 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.common;
|
package org.wso2.carbon.device.mgt.common;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents the Device Operation management functionality which should be implemented by
|
||||||
|
* the device type plugins.
|
||||||
|
*/
|
||||||
public interface OperationManager {
|
public interface OperationManager {
|
||||||
|
|
||||||
boolean executeOperation();
|
/**
|
||||||
|
* Method to add a operation to a device or a set of devices.
|
||||||
|
*
|
||||||
|
* @param operation Operation to be added
|
||||||
|
* @param devices List of DeviceIdentifiers to execute the operation
|
||||||
|
* @throws OperationManagementException If some unusual behaviour is observed while adding the
|
||||||
|
* operation
|
||||||
|
*/
|
||||||
|
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices)
|
||||||
|
throws OperationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to retrieve the list of available operations to a device.
|
||||||
|
*
|
||||||
|
* @param deviceId DeviceIdentifier of the device
|
||||||
|
* @throws OperationManagementException If some unusual behaviour is observed while fetching the
|
||||||
|
* operation list.
|
||||||
|
*/
|
||||||
|
public List<Operation> getOperations(DeviceIdentifier deviceId)
|
||||||
|
throws OperationManagementException;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -13,18 +13,15 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.common;
|
package org.wso2.carbon.device.mgt.core;
|
||||||
|
|
||||||
public class DefaultOperation implements Operation {
|
public final class DeviceManagementConstants {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() {
|
|
||||||
|
|
||||||
|
public static final class Common {
|
||||||
|
private Common() {
|
||||||
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
|
public static final String PROPERTY_SETUP = "setup";
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -35,25 +35,26 @@ public class DeviceManagementRepository {
|
|||||||
|
|
||||||
public void addDeviceManagementProvider(DeviceManagerService provider) {
|
public void addDeviceManagementProvider(DeviceManagerService provider) {
|
||||||
String deviceType = provider.getProviderType();
|
String deviceType = provider.getProviderType();
|
||||||
providers.put(deviceType, provider);
|
|
||||||
try {
|
try {
|
||||||
DeviceManagerUtil.registerDeviceType(deviceType);
|
DeviceManagerUtil.registerDeviceType(deviceType);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
log.error("Exception occured while registering the device type.",e);
|
log.error("Exception occurred while registering the device type.", e);
|
||||||
}
|
}
|
||||||
|
providers.put(deviceType, provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeDeviceManagementProvider(DeviceManagerService provider) {
|
public void removeDeviceManagementProvider(DeviceManagerService provider) {
|
||||||
String deviceType = provider.getProviderType();
|
String deviceType = provider.getProviderType();
|
||||||
|
|
||||||
|
try {
|
||||||
|
DeviceManagerUtil.unregisterDeviceType(deviceType);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
log.error("Exception occurred while registering the device type.", e);
|
||||||
|
}
|
||||||
providers.remove(deviceType);
|
providers.remove(deviceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeviceManagerService getDeviceManagementProvider(String type) {
|
public DeviceManagerService getDeviceManagementProvider(String type) {
|
||||||
return providers.get(type);
|
return providers.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, DeviceManagerService> getProviders() {
|
|
||||||
return providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
|
|||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DeviceManagerImpl implements DeviceManager {
|
public class DeviceManagerImpl implements DeviceManager {
|
||||||
@ -51,10 +52,9 @@ public class DeviceManagerImpl implements DeviceManager {
|
|||||||
boolean status = dms.enrollDevice(device);
|
boolean status = dms.enrollDevice(device);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.getDeviceTypeDAO().getDeviceType();
|
|
||||||
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
|
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
|
||||||
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
||||||
deviceDto.setDeviceType(deviceTypeId);
|
deviceDto.setDeviceTypeId(deviceTypeId);
|
||||||
this.getDeviceDAO().addDevice(deviceDto);
|
this.getDeviceDAO().addDevice(deviceDto);
|
||||||
|
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
@ -106,7 +106,27 @@ public class DeviceManagerImpl implements DeviceManager {
|
|||||||
public List<Device> getAllDevices(String type) throws DeviceManagementException {
|
public List<Device> getAllDevices(String type) throws DeviceManagementException {
|
||||||
DeviceManagerService dms =
|
DeviceManagerService dms =
|
||||||
this.getPluginRepository().getDeviceManagementProvider(type);
|
this.getPluginRepository().getDeviceManagementProvider(type);
|
||||||
return dms.getAllDevices();
|
List<Device> devicesList = new ArrayList<Device>();
|
||||||
|
try {
|
||||||
|
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(type);
|
||||||
|
List<org.wso2.carbon.device.mgt.core.dto.Device> devices =
|
||||||
|
this.getDeviceDAO().getDevices(deviceTypeId);
|
||||||
|
|
||||||
|
for (org.wso2.carbon.device.mgt.core.dto.Device device : devices) {
|
||||||
|
Device convertedDevice = DeviceManagementDAOUtil.convertDevice(device);
|
||||||
|
DeviceIdentifier deviceIdentifier = DeviceManagementDAOUtil
|
||||||
|
.createDeviceIdentifier(device, this.deviceTypeDAO
|
||||||
|
.getDeviceType(device.getDeviceTypeId()));
|
||||||
|
Device dmsDevice = dms.getDevice(deviceIdentifier);
|
||||||
|
convertedDevice.setProperties(dmsDevice.getProperties());
|
||||||
|
convertedDevice.setFeatures(dmsDevice.getFeatures());
|
||||||
|
devicesList.add(convertedDevice);
|
||||||
|
}
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
throw new DeviceManagementException("Error occurred while obtaining the device for type '" + type + "'",
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
return devicesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -28,7 +28,7 @@ public final class DeviceManagementConfig {
|
|||||||
|
|
||||||
private DeviceManagementRepository deviceMgtRepository;
|
private DeviceManagementRepository deviceMgtRepository;
|
||||||
|
|
||||||
@XmlElement(name = "ManagementRepository", nillable = false)
|
@XmlElement(name = "ManagementRepository", required = true)
|
||||||
public DeviceManagementRepository getDeviceMgtRepository() {
|
public DeviceManagementRepository getDeviceMgtRepository() {
|
||||||
return deviceMgtRepository;
|
return deviceMgtRepository;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class DeviceManagementRepository {
|
|||||||
|
|
||||||
private DataSourceConfig dataSourceConfig;
|
private DataSourceConfig dataSourceConfig;
|
||||||
|
|
||||||
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
@XmlElement(name = "DataSourceConfiguration", required = false)
|
||||||
public DataSourceConfig getDataSourceConfig() {
|
public DataSourceConfig getDataSourceConfig() {
|
||||||
return dataSourceConfig;
|
return dataSourceConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,14 +21,14 @@ import javax.xml.bind.annotation.XmlElement;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for holding data source configuration in cdm-config.xml at parsing with JAXB
|
* Class for holding data source configuration in malformed-cdm-config-no-mgt-repo.xml at parsing with JAXB
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "DataSourceConfiguration")
|
@XmlRootElement(name = "DataSourceConfiguration")
|
||||||
public class DataSourceConfig {
|
public class DataSourceConfig {
|
||||||
|
|
||||||
private JNDILookupDefinition jndiLookupDefintion;
|
private JNDILookupDefinition jndiLookupDefintion;
|
||||||
|
|
||||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
@XmlElement(name = "JndiLookupDefinition", required = true)
|
||||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
public JNDILookupDefinition getJndiLookupDefintion() {
|
||||||
return jndiLookupDefintion;
|
return jndiLookupDefintion;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class JNDILookupDefinition {
|
|||||||
private String jndiName;
|
private String jndiName;
|
||||||
private List<JNDIProperty> jndiProperties;
|
private List<JNDIProperty> jndiProperties;
|
||||||
|
|
||||||
@XmlElement(name = "Name", nillable = false)
|
@XmlElement(name = "Name", required = false)
|
||||||
public String getJndiName() {
|
public String getJndiName() {
|
||||||
return jndiName;
|
return jndiName;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ public class JNDILookupDefinition {
|
|||||||
this.jndiName = jndiName;
|
this.jndiName = jndiName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@XmlElementWrapper(name = "Environment", nillable = false)
|
@XmlElementWrapper(name = "Environment", required = false)
|
||||||
@XmlElement(name = "Property", nillable = false)
|
@XmlElement(name = "Property", nillable = false)
|
||||||
public List<JNDIProperty> getJndiProperties() {
|
public List<JNDIProperty> getJndiProperties() {
|
||||||
return jndiProperties;
|
return jndiProperties;
|
||||||
|
|||||||
@ -39,4 +39,11 @@ public interface DeviceDAO {
|
|||||||
Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException;
|
Device getDeviceByDeviceId(Long deviceId) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
List<Device> getDevices() throws DeviceManagementDAOException;
|
List<Device> getDevices() throws DeviceManagementDAOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param type - The device type id.
|
||||||
|
* @return a list of devices based on the type id.
|
||||||
|
* @throws DeviceManagementDAOException
|
||||||
|
*/
|
||||||
|
List<Device> getDevices(Integer type) throws DeviceManagementDAOException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.core.dao;
|
package org.wso2.carbon.device.mgt.core.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -33,8 +32,10 @@ public interface DeviceTypeDAO {
|
|||||||
|
|
||||||
List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException;
|
List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException;
|
||||||
|
|
||||||
DeviceIdentifier getDeviceType() throws DeviceManagementDAOException;
|
DeviceType getDeviceType(Integer id) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException;
|
Integer getDeviceTypeIdByDeviceTypeName(String type) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
|
void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -62,7 +63,7 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|||||||
stmt.setLong(4, new Date().getTime());
|
stmt.setLong(4, new Date().getTime());
|
||||||
stmt.setString(5, device.getOwnerShip());
|
stmt.setString(5, device.getOwnerShip());
|
||||||
stmt.setString(6, device.getStatus().toString());
|
stmt.setString(6, device.getStatus().toString());
|
||||||
stmt.setInt(7, device.getDeviceType());
|
stmt.setInt(7, device.getDeviceTypeId());
|
||||||
stmt.setString(8, device.getDeviceIdentificationId());
|
stmt.setString(8, device.getDeviceIdentificationId());
|
||||||
stmt.setString(9, device.getOwnerId());
|
stmt.setString(9, device.getOwnerId());
|
||||||
stmt.setInt(10, device.getTenantId());
|
stmt.setInt(10, device.getTenantId());
|
||||||
@ -102,6 +103,47 @@ public class DeviceDAOImpl implements DeviceDAO {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public List<Device> getDevices(Integer type) throws DeviceManagementDAOException {
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
List<Device> devicesList = null;
|
||||||
|
try {
|
||||||
|
conn = this.getConnection();
|
||||||
|
String selectDBQueryForType = "SELECT ID, DESCRIPTION, NAME, DATE_OF_ENROLLMENT, " +
|
||||||
|
"DATE_OF_LAST_UPDATE, OWNERSHIP, STATUS, DEVICE_TYPE_ID, " +
|
||||||
|
"DEVICE_IDENTIFICATION, OWNER, TENANT_ID FROM DM_DEVICE " +
|
||||||
|
"WHERE DM_DEVICE.DEVICE_TYPE_ID=?";
|
||||||
|
stmt = conn.prepareStatement(selectDBQueryForType);
|
||||||
|
stmt.setInt(1, type);
|
||||||
|
resultSet = stmt.executeQuery();
|
||||||
|
devicesList = new ArrayList<Device>();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
Device device = new Device();
|
||||||
|
device.setId(resultSet.getInt(1));
|
||||||
|
device.setDescription(resultSet.getString(2));
|
||||||
|
device.setName(resultSet.getString(3));
|
||||||
|
device.setDateOfEnrollment(resultSet.getLong(4));
|
||||||
|
device.setDateOfLastUpdate(resultSet.getLong(5));
|
||||||
|
//TODO:- Ownership is not a enum in DeviceDAO
|
||||||
|
device.setOwnerShip(resultSet.getString(6));
|
||||||
|
device.setStatus(Status.valueOf(resultSet.getString(7)));
|
||||||
|
device.setDeviceTypeId(resultSet.getInt(8));
|
||||||
|
device.setDeviceIdentificationId(resultSet.getString(9));
|
||||||
|
device.setOwnerId(resultSet.getString(10));
|
||||||
|
device.setTenantId(resultSet.getInt(11));
|
||||||
|
devicesList.add(device);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while listing devices for type '" + type + "'";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(conn, stmt, resultSet);
|
||||||
|
}
|
||||||
|
return devicesList;
|
||||||
|
}
|
||||||
|
|
||||||
private Connection getConnection() throws DeviceManagementDAOException {
|
private Connection getConnection() throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
return dataSource.getConnection();
|
return dataSource.getConnection();
|
||||||
|
|||||||
@ -19,7 +19,6 @@ package org.wso2.carbon.device.mgt.core.dao.impl;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceTypeDAO;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||||
@ -90,9 +89,28 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
|
public DeviceType getDeviceType(Integer id) throws DeviceManagementDAOException {
|
||||||
//TODO:
|
Connection conn = this.getConnection();
|
||||||
return null;
|
PreparedStatement stmt = null;
|
||||||
|
DeviceType deviceType = null;
|
||||||
|
try {
|
||||||
|
stmt = conn.prepareStatement("SELECT ID AS DEVICE_TYPE_ID, NAME AS DEVICE_TYPE FROM DM_DEVICE_TYPE WHERE ID=?");
|
||||||
|
stmt.setInt(1, id);
|
||||||
|
ResultSet results = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (results.next()) {
|
||||||
|
deviceType = new DeviceType();
|
||||||
|
deviceType.setId(results.getLong("DEVICE_TYPE_ID"));
|
||||||
|
deviceType.setName(results.getString("DEVICE_TYPE"));
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
String msg = "Error occurred while fetching the registered device type";
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementDAOException(msg, e);
|
||||||
|
} finally {
|
||||||
|
DeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
|
return deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,6 +142,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
|||||||
return deviceTypeId;
|
return deviceTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Connection getConnection() throws DeviceManagementDAOException {
|
private Connection getConnection() throws DeviceManagementDAOException {
|
||||||
try {
|
try {
|
||||||
return dataSource.getConnection();
|
return dataSource.getConnection();
|
||||||
|
|||||||
@ -18,8 +18,10 @@ package org.wso2.carbon.device.mgt.core.dao.util;
|
|||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.context.CarbonContext;
|
import org.wso2.carbon.context.CarbonContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.Device;
|
import org.wso2.carbon.device.mgt.core.dto.Device;
|
||||||
|
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||||
import org.wso2.carbon.device.mgt.core.dto.Status;
|
import org.wso2.carbon.device.mgt.core.dto.Status;
|
||||||
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
|
||||||
import org.wso2.carbon.user.api.UserStoreException;
|
import org.wso2.carbon.user.api.UserStoreException;
|
||||||
@ -32,7 +34,9 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public final class DeviceManagementDAOUtil {
|
public final class DeviceManagementDAOUtil {
|
||||||
|
|
||||||
@ -63,7 +67,8 @@ public final class DeviceManagementDAOUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get id of the current tenant
|
* Get id of the current tenant.
|
||||||
|
*
|
||||||
* @return tenant id
|
* @return tenant id
|
||||||
* @throws DeviceManagementDAOException if an error is observed when getting tenant id
|
* @throws DeviceManagementDAOException if an error is observed when getting tenant id
|
||||||
*/
|
*/
|
||||||
@ -94,12 +99,50 @@ public final class DeviceManagementDAOUtil {
|
|||||||
return (DataSource) InitialContext.doLookup(dataSourceName);
|
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||||
}
|
}
|
||||||
final InitialContext context = new InitialContext(jndiProperties);
|
final InitialContext context = new InitialContext(jndiProperties);
|
||||||
return (DataSource) context.doLookup(dataSourceName);
|
return (DataSource) context.lookup(dataSourceName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
|
throw new RuntimeException("Error in looking up data source: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param device - The DTO device object.
|
||||||
|
* @return A Business Object.
|
||||||
|
*/
|
||||||
|
public static org.wso2.carbon.device.mgt.common.Device convertDevice(Device device){
|
||||||
|
org.wso2.carbon.device.mgt.common.Device deviceBO =
|
||||||
|
new org.wso2.carbon.device.mgt.common.Device();
|
||||||
|
deviceBO.setDateOfEnrolment(device.getDateOfEnrollment());
|
||||||
|
deviceBO.setDateOfLastUpdate(device.getDateOfLastUpdate());
|
||||||
|
deviceBO.setDescription(device.getDescription());
|
||||||
|
deviceBO.setDeviceIdentifier(device.getDeviceIdentificationId());
|
||||||
|
deviceBO.setDeviceTypeId(device.getDeviceTypeId());
|
||||||
|
deviceBO.setName(device.getName());
|
||||||
|
deviceBO.setId(device.getId());
|
||||||
|
deviceBO.setOwner(device.getOwnerId());
|
||||||
|
deviceBO.setOwnership(device.getOwnerShip());
|
||||||
|
if (device.getStatus() == Status.ACTIVE) {
|
||||||
|
deviceBO.setStatus(true);
|
||||||
|
} else if (device.getStatus() == Status.INACTIVE) {
|
||||||
|
deviceBO.setStatus(false);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param devices - DTO Device Object list.
|
||||||
|
* @return converted Business Object list.
|
||||||
|
*/
|
||||||
|
public static List<org.wso2.carbon.device.mgt.common.Device> convertDevices(
|
||||||
|
List<Device> devices) {
|
||||||
|
List<org.wso2.carbon.device.mgt.common.Device> deviceBOList =
|
||||||
|
new ArrayList<org.wso2.carbon.device.mgt.common.Device>();
|
||||||
|
for (Device device : devices) {
|
||||||
|
deviceBOList.add(convertDevice(device));
|
||||||
|
}
|
||||||
|
return deviceBOList;
|
||||||
|
}
|
||||||
|
|
||||||
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
|
public static Device convertDevice(org.wso2.carbon.device.mgt.common.Device
|
||||||
device) throws DeviceManagementDAOException {
|
device) throws DeviceManagementDAOException {
|
||||||
Device deviceBO = new Device();
|
Device deviceBO = new Device();
|
||||||
@ -120,4 +163,10 @@ public final class DeviceManagementDAOUtil {
|
|||||||
return deviceBO;
|
return deviceBO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DeviceIdentifier createDeviceIdentifier(Device device, DeviceType deviceType) {
|
||||||
|
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||||
|
deviceIdentifier.setType(deviceType.getName());
|
||||||
|
deviceIdentifier.setId(device.getDeviceIdentificationId());
|
||||||
|
return deviceIdentifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import java.io.Serializable;
|
|||||||
public class Device implements Serializable {
|
public class Device implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -8101106997837486245L;
|
private static final long serialVersionUID = -8101106997837486245L;
|
||||||
private String id;
|
private Integer id;
|
||||||
private String description;
|
private String description;
|
||||||
private String name;
|
private String name;
|
||||||
private Long dateOfEnrollment;
|
private Long dateOfEnrollment;
|
||||||
@ -33,21 +33,21 @@ public class Device implements Serializable {
|
|||||||
private String ownerId;
|
private String ownerId;
|
||||||
private String ownerShip;
|
private String ownerShip;
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
private Integer deviceType;
|
private Integer deviceTypeId;
|
||||||
|
|
||||||
public Integer getDeviceType() {
|
public Integer getDeviceTypeId() {
|
||||||
return deviceType;
|
return deviceTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDeviceType(Integer deviceType) {
|
public void setDeviceTypeId(Integer deviceTypeId) {
|
||||||
this.deviceType = deviceType;
|
this.deviceTypeId = deviceTypeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public Integer getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(Integer id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ import org.osgi.framework.BundleContext;
|
|||||||
import org.osgi.service.component.ComponentContext;
|
import org.osgi.service.component.ComponentContext;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagementRepository;
|
import org.wso2.carbon.device.mgt.core.DeviceManagementRepository;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManager;
|
import org.wso2.carbon.device.mgt.core.DeviceManager;
|
||||||
import org.wso2.carbon.device.mgt.core.DeviceManagerImpl;
|
import org.wso2.carbon.device.mgt.core.DeviceManagerImpl;
|
||||||
@ -49,6 +50,7 @@ import org.wso2.carbon.user.core.service.RealmService;
|
|||||||
* bind="setDeviceManagerService"
|
* bind="setDeviceManagerService"
|
||||||
* unbind="unsetDeviceManagerService"
|
* unbind="unsetDeviceManagerService"
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public class DeviceManagementServiceComponent {
|
public class DeviceManagementServiceComponent {
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class);
|
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class);
|
||||||
@ -56,6 +58,9 @@ public class DeviceManagementServiceComponent {
|
|||||||
|
|
||||||
protected void activate(ComponentContext componentContext) {
|
protected void activate(ComponentContext componentContext) {
|
||||||
try {
|
try {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Initializing device management core bundle");
|
||||||
|
}
|
||||||
/* Initializing Device Management Configuration */
|
/* Initializing Device Management Configuration */
|
||||||
DeviceConfigurationManager.getInstance().initConfig();
|
DeviceConfigurationManager.getInstance().initConfig();
|
||||||
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||||
@ -67,16 +72,24 @@ public class DeviceManagementServiceComponent {
|
|||||||
DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager);
|
DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager);
|
||||||
|
|
||||||
/* If -Dsetup option enabled then create device management database schema */
|
/* If -Dsetup option enabled then create device management database schema */
|
||||||
String setupOption = System.getProperty("setup");
|
String setupOption = System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP);
|
||||||
if (setupOption != null) {
|
if (setupOption != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
|
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
|
||||||
"to begin");
|
"to begin");
|
||||||
}
|
}
|
||||||
setupDeviceManagementSchema(dsConfig);
|
this.setupDeviceManagementSchema(dsConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Registering OSGi service DeviceManagementService");
|
||||||
}
|
}
|
||||||
BundleContext bundleContext = componentContext.getBundleContext();
|
BundleContext bundleContext = componentContext.getBundleContext();
|
||||||
bundleContext.registerService(DeviceManagementService.class.getName(), new DeviceManagementService(), null);
|
bundleContext.registerService(DeviceManagementService.class.getName(),
|
||||||
|
new DeviceManagementService(), null);
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Device management core bundle has been successfully initialized");
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
String msg = "Error occurred while initializing device management core bundle";
|
String msg = "Error occurred while initializing device management core bundle";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
@ -87,39 +100,43 @@ public class DeviceManagementServiceComponent {
|
|||||||
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
||||||
log.info("Initializing device management repository database schema");
|
log.info("Initializing device management repository database schema");
|
||||||
|
|
||||||
// catch generic exception. If any error occurs wrap and throw DeviceManagementException
|
|
||||||
try {
|
try {
|
||||||
initializer.createRegistryDatabase();
|
initializer.createRegistryDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeviceManagementException("Error occurred while initializing Device Management " +
|
throw new DeviceManagementException("Error occurred while initializing Device Management " +
|
||||||
"database schema", e);
|
"database schema", e);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets Device Manager services
|
|
||||||
* @param deviceManager An instance of DeviceManagerService
|
|
||||||
*/
|
|
||||||
protected void setDeviceManagerService(DeviceManagerService deviceManager) {
|
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Setting Device Management Service");
|
log.debug("Device management metadata repository schema has been successfully initialized");
|
||||||
}
|
}
|
||||||
this.getPluginRepository().addDeviceManagementProvider(deviceManager);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets Device Management services
|
* Sets Device Manager service.
|
||||||
* @param deviceManager An instance of DeviceManagerService
|
* @param deviceManagerService An instance of DeviceManagerService
|
||||||
*/
|
*/
|
||||||
protected void unsetDeviceManagerService(DeviceManagerService deviceManager) {
|
protected void setDeviceManagerService(DeviceManagerService deviceManagerService) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Unsetting Device Management Service");
|
log.debug("Setting Device Management Service Provider : '" +
|
||||||
|
deviceManagerService.getProviderType() + "'");
|
||||||
}
|
}
|
||||||
this.getPluginRepository().removeDeviceManagementProvider(deviceManager);
|
this.getPluginRepository().addDeviceManagementProvider(deviceManagerService);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets Realm Service
|
* Unsets Device Management service.
|
||||||
|
* @param deviceManagerService An Instance of DeviceManagerService
|
||||||
|
*/
|
||||||
|
protected void unsetDeviceManagerService(DeviceManagerService deviceManagerService) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Unsetting Device Management Service Provider : '" +
|
||||||
|
deviceManagerService.getProviderType() + "'");
|
||||||
|
}
|
||||||
|
this.getPluginRepository().removeDeviceManagementProvider(deviceManagerService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets Realm Service.
|
||||||
* @param realmService An instance of RealmService
|
* @param realmService An instance of RealmService
|
||||||
*/
|
*/
|
||||||
protected void setRealmService(RealmService realmService) {
|
protected void setRealmService(RealmService realmService) {
|
||||||
@ -130,7 +147,7 @@ public class DeviceManagementServiceComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsets Realm Service
|
* Unsets Realm Service.
|
||||||
* @param realmService An instance of RealmService
|
* @param realmService An instance of RealmService
|
||||||
*/
|
*/
|
||||||
protected void unsetRealmService(RealmService realmService) {
|
protected void unsetRealmService(RealmService realmService) {
|
||||||
|
|||||||
@ -87,24 +87,47 @@ public final class DeviceManagerUtil {
|
|||||||
/**
|
/**
|
||||||
* Adds a new device type to the database if it does not exists.
|
* Adds a new device type to the database if it does not exists.
|
||||||
*
|
*
|
||||||
* @param deviceTypeName device type
|
* @param deviceType device type
|
||||||
* @return status of the operation
|
* @return status of the operation
|
||||||
*/
|
*/
|
||||||
public static boolean registerDeviceType(String deviceTypeName) throws DeviceManagementException{
|
public static boolean registerDeviceType(String deviceType) throws DeviceManagementException {
|
||||||
boolean status = false;
|
boolean status;
|
||||||
try {
|
try {
|
||||||
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||||
Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceTypeName);
|
Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType);
|
||||||
if (deviceTypeId == null) {
|
if (deviceTypeId == null) {
|
||||||
DeviceType deviceType = new DeviceType();
|
DeviceType dt = new DeviceType();
|
||||||
deviceType.setName(deviceTypeName);
|
dt.setName(deviceType);
|
||||||
deviceTypeDAO.addDeviceType(deviceType);
|
deviceTypeDAO.addDeviceType(dt);
|
||||||
}
|
}
|
||||||
status = true;
|
status = true;
|
||||||
} catch (DeviceManagementDAOException e) {
|
} catch (DeviceManagementDAOException e) {
|
||||||
String msg = "Error occurred while registering the device type " + deviceTypeName;
|
String msg = "Error occurred while registering the device type " + deviceType;
|
||||||
throw new DeviceManagementException(msg, e);
|
throw new DeviceManagementException(msg, e);
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregisters an existing device type from the device management metadata repository.
|
||||||
|
*
|
||||||
|
* @param deviceType device type
|
||||||
|
* @return status of the operation
|
||||||
|
*/
|
||||||
|
public static boolean unregisterDeviceType(String deviceType) throws DeviceManagementException {
|
||||||
|
try {
|
||||||
|
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||||
|
Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType);
|
||||||
|
if (deviceTypeId == null) {
|
||||||
|
DeviceType dt = new DeviceType();
|
||||||
|
dt.setName(deviceType);
|
||||||
|
deviceTypeDAO.removeDeviceType(dt);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (DeviceManagementDAOException e) {
|
||||||
|
String msg = "Error occurred while registering the device type " + deviceType;
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* 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.core;
|
||||||
|
|
||||||
|
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.core.config.DeviceManagementConfig;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class DeviceManagementConfigTests {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(DeviceManagementConfigTests.class);
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY =
|
||||||
|
"./src/test/resources/config/malformed-cdm-config-no-mgt-repo.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-cdm-config-no-ds-config.xml";
|
||||||
|
private static final String MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG =
|
||||||
|
"./src/test/resources/config/malformed-cdm-config-no-jndi-config.xml";
|
||||||
|
private static final String TEST_CONFIG_SCHEMA_LOCATION =
|
||||||
|
"./src/test/resources/config/schema/DeviceManagementConfigSchema.xsd";
|
||||||
|
|
||||||
|
private Schema schema;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
private void initSchema() {
|
||||||
|
File deviceManagementSchemaConfig = new File(DeviceManagementConfigTests.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(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_MGT_REPOSITORY);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateDataSourceConfigurationElement() {
|
||||||
|
File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_DS_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMandateJndiLookupDefinitionElement() {
|
||||||
|
File malformedConfig = new File(DeviceManagementConfigTests.MALFORMED_TEST_CONFIG_LOCATION_NO_JNDI_CONFIG);
|
||||||
|
this.validateMalformedConfig(malformedConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMalformedConfig(File malformedConfig) {
|
||||||
|
try {
|
||||||
|
JAXBContext ctx = JAXBContext.newInstance(DeviceManagementConfig.class);
|
||||||
|
Unmarshaller um = ctx.createUnmarshaller();
|
||||||
|
um.setSchema(this.getSchema());
|
||||||
|
um.unmarshal(malformedConfig);
|
||||||
|
Assert.assertTrue(false);
|
||||||
|
} catch (JAXBException e) {
|
||||||
|
log.error("Error occurred while unmarsharlling device management config", e);
|
||||||
|
Assert.assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Schema getSchema() {
|
||||||
|
return schema;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* 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.core;
|
||||||
|
|
||||||
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.BeforeClass;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
|
|
||||||
|
public class DeviceManagementRepositoryTests {
|
||||||
|
|
||||||
|
private DeviceManagementRepository repository;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public void initRepository() {
|
||||||
|
this.repository = new DeviceManagementRepository();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAddDeviceManagementService() {
|
||||||
|
DeviceManagerService sourceProvider = new TestDeviceManagerService();
|
||||||
|
this.getRepository().addDeviceManagementProvider(sourceProvider);
|
||||||
|
|
||||||
|
DeviceManagerService targetProvider =
|
||||||
|
this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST);
|
||||||
|
|
||||||
|
Assert.assertEquals(targetProvider.getProviderType(), sourceProvider.getProviderType());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(dependsOnMethods = "testAddDeviceManagementService")
|
||||||
|
public void testRemoveDeviceManagementService() {
|
||||||
|
DeviceManagerService sourceProvider = new TestDeviceManagerService();
|
||||||
|
this.getRepository().removeDeviceManagementProvider(sourceProvider);
|
||||||
|
|
||||||
|
DeviceManagerService targetProvider =
|
||||||
|
this.getRepository().getDeviceManagementProvider(TestDeviceManagerService.DEVICE_TYPE_TEST);
|
||||||
|
|
||||||
|
Assert.assertNull(targetProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DeviceManagementRepository getRepository() {
|
||||||
|
return repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2012, 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.core;
|
||||||
|
|
||||||
|
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.OperationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TestDeviceManagerService implements DeviceManagerService {
|
||||||
|
|
||||||
|
public static final String DEVICE_TYPE_TEST = "Test";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getProviderType() {
|
||||||
|
return TestDeviceManagerService.DEVICE_TYPE_TEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Device> getAllDevices() throws DeviceManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OperationManager getOperationManager() throws DeviceManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2012, 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.core;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
|
||||||
|
public class TestUtils {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(TestUtils.class);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -25,6 +25,7 @@ import org.testng.annotations.Parameters;
|
|||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.core.TestUtils;
|
||||||
import org.wso2.carbon.device.mgt.core.common.DBTypes;
|
import org.wso2.carbon.device.mgt.core.common.DBTypes;
|
||||||
import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration;
|
import org.wso2.carbon.device.mgt.core.common.TestDBConfiguration;
|
||||||
import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations;
|
import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations;
|
||||||
@ -40,30 +41,23 @@ import javax.xml.bind.Unmarshaller;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class DeviceMgtDAOTestSuite {
|
public class DeviceManagementDAOTests {
|
||||||
|
|
||||||
private TestDBConfiguration testDBConfiguration;
|
|
||||||
private DeviceType devType = new DeviceType();
|
|
||||||
private Connection conn = null;
|
|
||||||
private Statement stmt = null;
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Parameters("dbType")
|
@Parameters("dbType")
|
||||||
public void setUpDB(String dbTypeStr) throws Exception {
|
public void setUpDB(String dbTypeStr) throws Exception {
|
||||||
|
|
||||||
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
|
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
|
||||||
testDBConfiguration = getTestDBConfiguration(dbType);
|
TestDBConfiguration dbConfig = getTestDBConfiguration(dbType);
|
||||||
|
|
||||||
switch (dbType) {
|
switch (dbType) {
|
||||||
case H2:
|
case H2:
|
||||||
createH2DB(testDBConfiguration);
|
createH2DB(dbConfig);
|
||||||
BasicDataSource testDataSource = new BasicDataSource();
|
BasicDataSource testDataSource = new BasicDataSource();
|
||||||
testDataSource.setDriverClassName(testDBConfiguration.getDriverClass());
|
testDataSource.setDriverClassName(dbConfig.getDriverClass());
|
||||||
testDataSource.setUrl(testDBConfiguration.getConnectionUrl());
|
testDataSource.setUrl(dbConfig.getConnectionUrl());
|
||||||
testDataSource.setUsername(testDBConfiguration.getUserName());
|
testDataSource.setUsername(dbConfig.getUserName());
|
||||||
testDataSource.setPassword(testDBConfiguration.getPwd());
|
testDataSource.setPassword(dbConfig.getPwd());
|
||||||
DeviceManagementDAOFactory.init(testDataSource);
|
DeviceManagementDAOFactory.init(testDataSource);
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
@ -71,11 +65,9 @@ public class DeviceMgtDAOTestSuite {
|
|||||||
|
|
||||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException,
|
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException,
|
||||||
DeviceManagementException {
|
DeviceManagementException {
|
||||||
|
|
||||||
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
||||||
Document doc = null;
|
Document doc;
|
||||||
testDBConfiguration = null;
|
TestDBConfigurations dbConfigs;
|
||||||
TestDBConfigurations testDBConfigurations = null;
|
|
||||||
|
|
||||||
doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
||||||
JAXBContext testDBContext = null;
|
JAXBContext testDBContext = null;
|
||||||
@ -83,92 +75,100 @@ public class DeviceMgtDAOTestSuite {
|
|||||||
try {
|
try {
|
||||||
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
|
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
|
||||||
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
|
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
|
||||||
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
dbConfigs = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
||||||
} catch (JAXBException e) {
|
} catch (JAXBException e) {
|
||||||
throw new DeviceManagementDAOException("Error parsing test db configurations", e);
|
throw new DeviceManagementDAOException("Error parsing test db configurations", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator<TestDBConfiguration> itrDBConfigs = testDBConfigurations.getDbTypesList().iterator();
|
for (TestDBConfiguration config : dbConfigs.getDbTypesList()) {
|
||||||
while (itrDBConfigs.hasNext()) {
|
if (config.getDbType().equals(dbType.toString())) {
|
||||||
testDBConfiguration = itrDBConfigs.next();
|
return config;
|
||||||
if (testDBConfiguration.getDbType().equals(dbType.toString())) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
return testDBConfiguration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
|
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
|
||||||
|
Connection conn = null;
|
||||||
|
Statement stmt = null;
|
||||||
|
try {
|
||||||
Class.forName(testDBConf.getDriverClass());
|
Class.forName(testDBConf.getDriverClass());
|
||||||
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
|
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
|
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
|
||||||
stmt.close();
|
} finally {
|
||||||
conn.close();
|
TestUtils.cleanupResources(conn, stmt, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException {
|
public void addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException {
|
||||||
|
|
||||||
DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||||
|
|
||||||
devType.setName("IOS");
|
DeviceType deviceType = new DeviceType();
|
||||||
|
deviceType.setName("IOS");
|
||||||
|
|
||||||
deviceTypeMgtDAO.addDeviceType(devType);
|
deviceTypeMgtDAO.addDeviceType(deviceType);
|
||||||
Long deviceTypeId = null;
|
Long deviceTypeId = null;
|
||||||
|
|
||||||
|
Connection conn = null;
|
||||||
|
Statement stmt = null;
|
||||||
try {
|
try {
|
||||||
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
ResultSet resultSet = stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'");
|
ResultSet resultSet =
|
||||||
|
stmt.executeQuery("SELECT ID,NAME from DM_DEVICE_TYPE DType where DType.NAME='IOS'");
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
deviceTypeId = resultSet.getLong(1);
|
deviceTypeId = resultSet.getLong(1);
|
||||||
}
|
}
|
||||||
conn.close();
|
|
||||||
} catch (SQLException sqlEx) {
|
} catch (SQLException sqlEx) {
|
||||||
throw new DeviceManagementDAOException("error in fetch device type by name IOS", sqlEx);
|
throw new DeviceManagementDAOException("error in fetch device type by name IOS", sqlEx);
|
||||||
|
} finally {
|
||||||
|
TestUtils.cleanupResources(conn, stmt, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertNotNull(deviceTypeId, "Device Type Id is null");
|
Assert.assertNotNull(deviceTypeId, "Device Type Id is null");
|
||||||
devType.setId(deviceTypeId);
|
deviceType.setId(deviceTypeId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dependsOnMethods = {"addDeviceTypeTest"})
|
@Test(dependsOnMethods = {"addDeviceTypeTest"})
|
||||||
public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException {
|
public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException {
|
||||||
|
|
||||||
DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
||||||
|
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
|
|
||||||
device.setDateOfEnrollment(new Date().getTime());
|
device.setDateOfEnrollment(new Date().getTime());
|
||||||
device.setDateOfLastUpdate(new Date().getTime());
|
device.setDateOfLastUpdate(new Date().getTime());
|
||||||
device.setDescription("test description");
|
device.setDescription("test description");
|
||||||
device.setStatus(Status.ACTIVE);
|
device.setStatus(Status.ACTIVE);
|
||||||
device.setDeviceIdentificationId("111");
|
device.setDeviceIdentificationId("111");
|
||||||
device.setDeviceType(devType.getId().intValue());
|
|
||||||
|
DeviceType deviceType = new DeviceType();
|
||||||
|
deviceType.setId(Long.parseLong("1"));
|
||||||
|
|
||||||
|
device.setDeviceType(deviceType.getId().intValue());
|
||||||
device.setOwnerShip(OwnerShip.BYOD.toString());
|
device.setOwnerShip(OwnerShip.BYOD.toString());
|
||||||
device.setOwnerId("111");
|
device.setOwnerId("111");
|
||||||
device.setTenantId(-1234);
|
device.setTenantId(-1234);
|
||||||
deviceMgtDAO.addDevice(device);
|
deviceMgtDAO.addDevice(device);
|
||||||
|
|
||||||
Long deviceId = null;
|
Long deviceId = null;
|
||||||
|
Connection conn = null;
|
||||||
|
PreparedStatement stmt = null;
|
||||||
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
||||||
stmt = conn.createStatement();
|
stmt = conn.prepareStatement("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
||||||
ResultSet resultSet = stmt
|
rs = stmt.executeQuery();
|
||||||
.executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
|
||||||
|
|
||||||
while (resultSet.next()) {
|
while (rs.next()) {
|
||||||
deviceId = resultSet.getLong(1);
|
deviceId = rs.getLong(1);
|
||||||
}
|
}
|
||||||
conn.close();
|
} catch (SQLException e) {
|
||||||
} catch (SQLException sqlEx) {
|
throw new DeviceManagementDAOException("error in fetch device by device identification id", e);
|
||||||
throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx);
|
} finally {
|
||||||
|
TestUtils.cleanupResources(conn, stmt, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.assertNotNull(deviceId, "Device Id is null");
|
Assert.assertNotNull(deviceId, "Device Id is null");
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<DeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<MalformedDataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</MalformedDataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
</DeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<DeviceMgtConfiguration>
|
||||||
|
<ManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<MalformedJndiLookupDefinition>
|
||||||
|
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||||
|
</MalformedJndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</ManagementRepository>
|
||||||
|
</DeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
<!--
|
||||||
|
~ 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<DeviceMgtConfiguration>
|
||||||
|
<MalformedManagementRepository>
|
||||||
|
<DataSourceConfiguration>
|
||||||
|
<JndiLookupDefinition>
|
||||||
|
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||||
|
</JndiLookupDefinition>
|
||||||
|
</DataSourceConfiguration>
|
||||||
|
</MalformedManagementRepository>
|
||||||
|
</DeviceMgtConfiguration>
|
||||||
|
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
<?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.
|
||||||
|
~ 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="DeviceMgtConfiguration">
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element name="ManagementRepository" minOccurs="1" maxOccurs="1" type="DataSourceConfigurationType"/>
|
||||||
|
</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:schema>
|
||||||
@ -21,8 +21,9 @@
|
|||||||
<test name="DAO Unit Tests" preserve-order="true">
|
<test name="DAO Unit Tests" preserve-order="true">
|
||||||
<parameter name="dbType" value="H2"/>
|
<parameter name="dbType" value="H2"/>
|
||||||
<classes>
|
<classes>
|
||||||
|
<class name="org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOTests"/>
|
||||||
<class name="org.wso2.carbon.device.mgt.core.dao.DeviceMgtDAOTestSuite"/>
|
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementRepositoryTests"/>
|
||||||
|
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementConfigTests"/>
|
||||||
</classes>
|
</classes>
|
||||||
</test>
|
</test>
|
||||||
</suite>
|
</suite>
|
||||||
@ -52,7 +52,7 @@
|
|||||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||||
<Bundle-Version>${project.version}</Bundle-Version>
|
<Bundle-Version>${project.version}</Bundle-Version>
|
||||||
<Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description>
|
<Bundle-Description>Device Management Mobile Impl Bundle</Bundle-Description>
|
||||||
<Bundle-Activator>org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator</Bundle-Activator>
|
<!--<Bundle-Activator>org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator</Bundle-Activator>-->
|
||||||
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package>
|
<Private-Package>org.wso2.carbon.device.mgt.mobile.internal</Private-Package>
|
||||||
<Import-Package>
|
<Import-Package>
|
||||||
org.osgi.framework,
|
org.osgi.framework,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014 - 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -13,12 +13,24 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile;
|
package org.wso2.carbon.device.mgt.mobile;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.common.OperationManager;
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public abstract class AbstractMobileOperationManager implements OperationManager {
|
public abstract class AbstractMobileOperationManager implements OperationManager {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addOperation(Operation operation,
|
||||||
|
List<DeviceIdentifier> devices) throws OperationManagementException {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.Feature;
|
import org.wso2.carbon.device.mgt.mobile.dto.Feature;
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
|
||||||
|
|||||||
@ -18,9 +18,10 @@ package org.wso2.carbon.device.mgt.mobile.dao;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.DataSourceListener;
|
import org.wso2.carbon.device.mgt.mobile.DataSourceListener;
|
||||||
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.impl.MobileDeviceDAOImpl;
|
import org.wso2.carbon.device.mgt.mobile.dao.impl.*;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator;
|
import org.wso2.carbon.device.mgt.mobile.internal.MobileDeviceManagementBundleActivator;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(){
|
public void init() throws DeviceManagementException {
|
||||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
||||||
if (dataSource != null) {
|
if (dataSource != null) {
|
||||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
||||||
@ -52,6 +53,26 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
|||||||
return new MobileDeviceDAOImpl(dataSource);
|
return new MobileDeviceDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static OperationDAO getOperationDAO() {
|
||||||
|
return new OperationDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static OperationPropertyDAO geOperationPropertyDAO() {
|
||||||
|
return new OperationPropertyDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeviceOperationDAO getDeviceOperationDAO() {
|
||||||
|
return new DeviceOperationDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FeatureDAO getFeatureDAO() {
|
||||||
|
return new FeatureDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FeaturePropertyDAO getFeaturePropertyDAO() {
|
||||||
|
return new FeaturePropertyDAOImpl(dataSource);
|
||||||
|
}
|
||||||
|
|
||||||
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
|
public static MobileDataSourceConfig getMobileDeviceManagementConfig() {
|
||||||
return mobileDataSourceConfig;
|
return mobileDataSourceConfig;
|
||||||
}
|
}
|
||||||
@ -68,9 +89,11 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyObserver() {
|
public void notifyObserver() {
|
||||||
|
try {
|
||||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
||||||
if(dataSource!=null){
|
|
||||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
log.error("Error occurred while resolving mobile device management metadata repository data source", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||||
@ -13,10 +29,10 @@ public interface OperationDAO {
|
|||||||
/**
|
/**
|
||||||
* Add a new operation to plugin operation table.
|
* Add a new operation to plugin operation table.
|
||||||
* @param operation Operation object that holds data related to the operation to be inserted.
|
* @param operation Operation object that holds data related to the operation to be inserted.
|
||||||
* @return The status of the operation. If the insert was successful or not.
|
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned.
|
||||||
* @throws MobileDeviceManagementDAOException
|
* @throws MobileDeviceManagementDAOException
|
||||||
*/
|
*/
|
||||||
boolean addOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
int addOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update a operation in the operation table.
|
* Update a operation in the operation table.
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao;
|
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@ -40,16 +56,18 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
stmt.setString(1, deviceOperation.getDeviceId());
|
stmt.setString(1, deviceOperation.getDeviceId());
|
||||||
stmt.setInt(2, deviceOperation.getOperationId());
|
stmt.setLong(2, deviceOperation.getOperationId());
|
||||||
stmt.setInt(3, deviceOperation.getSentDate());
|
stmt.setLong(3, deviceOperation.getSentDate());
|
||||||
stmt.setInt(4, deviceOperation.getReceivedDate());
|
stmt.setLong(4, deviceOperation.getReceivedDate());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while adding device id - '" +
|
String msg = "Error occurred while adding device id - '" +
|
||||||
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";;
|
deviceOperation.getDeviceId() + " and operation id - " +
|
||||||
|
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||||
|
;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -69,8 +87,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
String updateDBQuery =
|
String updateDBQuery =
|
||||||
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
"UPDATE MBL_DEVICE_OPERATION SET SENT_DATE = ?, RECEIVED_DATE = ? WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setInt(1, deviceOperation.getSentDate());
|
stmt.setLong(1, deviceOperation.getSentDate());
|
||||||
stmt.setInt(2, deviceOperation.getReceivedDate());
|
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||||
stmt.setString(3, deviceOperation.getDeviceId());
|
stmt.setString(3, deviceOperation.getDeviceId());
|
||||||
stmt.setInt(4, deviceOperation.getOperationId());
|
stmt.setInt(4, deviceOperation.getOperationId());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
@ -79,7 +97,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while updating device id - '" +
|
String msg = "Error occurred while updating device id - '" +
|
||||||
deviceOperation.getDeviceId() + " and operation id - " + deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
deviceOperation.getDeviceId() + " and operation id - " +
|
||||||
|
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
} finally {
|
} finally {
|
||||||
@ -106,7 +125,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" +
|
String msg =
|
||||||
|
"Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" +
|
||||||
deviceId + " and operation id - " + operationId;
|
deviceId + " and operation id - " + operationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
@ -139,7 +159,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
String msg =
|
||||||
|
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||||
deviceId + " and operation id - " + operationId;
|
deviceId + " and operation id - " + operationId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
@ -173,7 +194,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
String msg =
|
||||||
|
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||||
deviceId;
|
deviceId;
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new MobileDeviceManagementDAOException(msg, e);
|
throw new MobileDeviceManagementDAOException(msg, e);
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|||||||
@ -64,6 +64,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
mobileDevice.setOsVersion(resultSet.getString(5));
|
mobileDevice.setOsVersion(resultSet.getString(5));
|
||||||
mobileDevice.setModel(resultSet.getString(6));
|
mobileDevice.setModel(resultSet.getString(6));
|
||||||
mobileDevice.setVendor(resultSet.getString(7));
|
mobileDevice.setVendor(resultSet.getString(7));
|
||||||
|
mobileDevice.setLatitude(resultSet.getString(8));
|
||||||
|
mobileDevice.setLongitude(resultSet.getString(9));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -87,7 +89,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String createDBQuery =
|
String createDBQuery =
|
||||||
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," +
|
"INSERT INTO MBL_DEVICE(MOBILE_DEVICE_ID, REG_ID, IMEI, IMSI, OS_VERSION," +
|
||||||
"DEVICE_MODEL, VENDOR) VALUES (?, ?, ?, ?, ?, ?, ?)";
|
"DEVICE_MODEL, VENDOR, LATITUDE, LONGITUDE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery);
|
||||||
stmt.setString(1, mobileDevice.getMobileDeviceId());
|
stmt.setString(1, mobileDevice.getMobileDeviceId());
|
||||||
@ -97,6 +99,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
stmt.setString(5, mobileDevice.getOsVersion());
|
stmt.setString(5, mobileDevice.getOsVersion());
|
||||||
stmt.setString(6, mobileDevice.getModel());
|
stmt.setString(6, mobileDevice.getModel());
|
||||||
stmt.setString(7, mobileDevice.getVendor());
|
stmt.setString(7, mobileDevice.getVendor());
|
||||||
|
stmt.setString(8, mobileDevice.getLatitude());
|
||||||
|
stmt.setString(8, mobileDevice.getLongitude());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if(rows>0){
|
if(rows>0){
|
||||||
status = true;
|
status = true;
|
||||||
@ -122,7 +126,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
conn = this.getConnection();
|
conn = this.getConnection();
|
||||||
String updateDBQuery =
|
String updateDBQuery =
|
||||||
"UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
|
"UPDATE MBL_DEVICE SET REG_ID = ?, IMEI = ?, IMSI = ?, OS_VERSION = ?," +
|
||||||
"DEVICE_MODEL = ?, VENDOR = ? WHERE MOBILE_DEVICE_ID = ?";
|
"DEVICE_MODEL = ?, VENDOR = ? , LATITUDE = ?, LONGITUDE = ? WHERE MOBILE_DEVICE_ID = ?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setString(1, mobileDevice.getRegId());
|
stmt.setString(1, mobileDevice.getRegId());
|
||||||
stmt.setString(2, mobileDevice.getImei());
|
stmt.setString(2, mobileDevice.getImei());
|
||||||
@ -130,7 +134,9 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
stmt.setString(4, mobileDevice.getOsVersion());
|
stmt.setString(4, mobileDevice.getOsVersion());
|
||||||
stmt.setString(5, mobileDevice.getModel());
|
stmt.setString(5, mobileDevice.getModel());
|
||||||
stmt.setString(6, mobileDevice.getVendor());
|
stmt.setString(6, mobileDevice.getVendor());
|
||||||
stmt.setString(7, mobileDevice.getMobileDeviceId());
|
stmt.setString(7, mobileDevice.getLatitude());
|
||||||
|
stmt.setString(8, mobileDevice.getLongitude());
|
||||||
|
stmt.setString(9, mobileDevice.getMobileDeviceId());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if(rows>0){
|
if(rows>0){
|
||||||
status = true;
|
status = true;
|
||||||
@ -192,6 +198,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
|||||||
mobileDevice.setOsVersion(resultSet.getString(5));
|
mobileDevice.setOsVersion(resultSet.getString(5));
|
||||||
mobileDevice.setModel(resultSet.getString(6));
|
mobileDevice.setModel(resultSet.getString(6));
|
||||||
mobileDevice.setVendor(resultSet.getString(7));
|
mobileDevice.setVendor(resultSet.getString(7));
|
||||||
|
mobileDevice.setLatitude(resultSet.getString(8));
|
||||||
|
mobileDevice.setLongitude(resultSet.getString(9));
|
||||||
mobileDevices.add(mobileDevice);
|
mobileDevices.add(mobileDevice);
|
||||||
}
|
}
|
||||||
return mobileDevices;
|
return mobileDevices;
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@ -26,9 +42,9 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addOperation(Operation operation)
|
public int addOperation(Operation operation)
|
||||||
throws MobileDeviceManagementDAOException {
|
throws MobileDeviceManagementDAOException {
|
||||||
boolean status = false;
|
int status = -1;
|
||||||
Connection conn = null;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
try {
|
try {
|
||||||
@ -36,12 +52,15 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
String createDBQuery =
|
String createDBQuery =
|
||||||
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
|
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
|
||||||
|
|
||||||
stmt = conn.prepareStatement(createDBQuery);
|
stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" });
|
||||||
stmt.setString(1, operation.getFeatureCode());
|
stmt.setString(1, operation.getFeatureCode());
|
||||||
stmt.setInt(2, operation.getCreatedDate());
|
stmt.setLong(2, operation.getCreatedDate());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
status = true;
|
ResultSet rs = stmt.getGeneratedKeys();
|
||||||
|
if (rs != null && rs.next()) {
|
||||||
|
status = rs.getInt(1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
String msg = "Error occurred while adding feature code - '" +
|
String msg = "Error occurred while adding feature code - '" +
|
||||||
@ -66,7 +85,7 @@ public class OperationDAOImpl implements OperationDAO {
|
|||||||
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?";
|
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?";
|
||||||
stmt = conn.prepareStatement(updateDBQuery);
|
stmt = conn.prepareStatement(updateDBQuery);
|
||||||
stmt.setString(1, operation.getFeatureCode());
|
stmt.setString(1, operation.getFeatureCode());
|
||||||
stmt.setInt(2, operation.getCreatedDate());
|
stmt.setLong(2, operation.getCreatedDate());
|
||||||
stmt.setInt(3, operation.getOperationId());
|
stmt.setInt(3, operation.getOperationId());
|
||||||
int rows = stmt.executeUpdate();
|
int rows = stmt.executeUpdate();
|
||||||
if (rows > 0) {
|
if (rows > 0) {
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dao.impl;
|
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|||||||
@ -45,7 +45,7 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
* @param config Mobile data source configuration
|
* @param config Mobile data source configuration
|
||||||
* @return data source resolved from the data source definition
|
* @return data source resolved from the data source definition
|
||||||
*/
|
*/
|
||||||
public static DataSource resolveDataSource(MobileDataSourceConfig config) {
|
public static DataSource resolveDataSource(MobileDataSourceConfig config) throws DeviceManagementException {
|
||||||
DataSource dataSource = null;
|
DataSource dataSource = null;
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||||
@ -64,25 +64,10 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||||
jndiProperties.put(prop.getName(), prop.getValue());
|
jndiProperties.put(prop.getName(), prop.getValue());
|
||||||
}
|
}
|
||||||
try {
|
dataSource =
|
||||||
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(
|
MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||||
jndiConfig.getJndiName(), jndiProperties);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Error in looking up data source: " + e.getMessage());
|
|
||||||
}
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||||
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(
|
|
||||||
jndiConfig.getJndiName(), null);
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Error in looking up data source: " + e.getMessage());
|
|
||||||
}
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dataSource;
|
return dataSource;
|
||||||
@ -96,10 +81,11 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
return (DataSource) InitialContext.doLookup(dataSourceName);
|
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||||
}
|
}
|
||||||
final InitialContext context = new InitialContext(jndiProperties);
|
final InitialContext context = new InitialContext(jndiProperties);
|
||||||
return (DataSource) context.doLookup(dataSourceName);
|
return (DataSource) context.lookup(dataSourceName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeviceManagementException(
|
String msg = "Error in looking up data source: " + e.getMessage();
|
||||||
"Error in looking up data source: " + e.getMessage(), e);
|
log.error(msg, e);
|
||||||
|
throw new DeviceManagementException(msg, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,9 +129,7 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
try {
|
try {
|
||||||
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource);
|
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource);
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
log.error(
|
log.error("Exception occurred while initializing mobile device management database schema", e);
|
||||||
"Exception occurred while initializing mobile device management database schema",
|
|
||||||
e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,8 +147,7 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
try {
|
try {
|
||||||
initializer.createRegistryDatabase();
|
initializer.createRegistryDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeviceManagementException(
|
throw new DeviceManagementException("Error occurred while initializing Mobile Device Management " +
|
||||||
"Error occurred while initializing Mobile Device Management " +
|
|
||||||
"database schema", e);
|
"database schema", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of Operations.
|
* DTO of Operations.
|
||||||
*/
|
*/
|
||||||
public class DeviceOperation {
|
public class DeviceOperation {
|
||||||
String deviceId;
|
|
||||||
int operationId;
|
private String deviceId;
|
||||||
int sentDate;
|
private int operationId;
|
||||||
int receivedDate;
|
private long sentDate;
|
||||||
|
private long receivedDate;
|
||||||
|
|
||||||
public String getDeviceId() {
|
public String getDeviceId() {
|
||||||
return deviceId;
|
return deviceId;
|
||||||
@ -25,19 +42,19 @@ public class DeviceOperation {
|
|||||||
this.operationId = operationId;
|
this.operationId = operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSentDate() {
|
public long getSentDate() {
|
||||||
return sentDate;
|
return sentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSentDate(int sentDate) {
|
public void setSentDate(long sentDate) {
|
||||||
this.sentDate = sentDate;
|
this.sentDate = sentDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getReceivedDate() {
|
public long getReceivedDate() {
|
||||||
return receivedDate;
|
return receivedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReceivedDate(int receivedDate) {
|
public void setReceivedDate(long receivedDate) {
|
||||||
this.receivedDate = receivedDate;
|
this.receivedDate = receivedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* 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.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -6,10 +22,11 @@ import java.io.Serializable;
|
|||||||
* DTO of features.
|
* DTO of features.
|
||||||
*/
|
*/
|
||||||
public class Feature implements Serializable {
|
public class Feature implements Serializable {
|
||||||
int id;
|
|
||||||
String code;
|
private int id;
|
||||||
String name;
|
private String code;
|
||||||
String description;
|
private String name;
|
||||||
|
private String description;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|||||||
@ -1,12 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 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.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of feature property. Represents a property of a feature.
|
* DTO of feature property. Represents a property of a feature.
|
||||||
*/
|
*/
|
||||||
public class FeatureProperty {
|
public class FeatureProperty {
|
||||||
int propertyId;
|
|
||||||
String property;
|
private int propertyId;
|
||||||
String featureID;
|
private String property;
|
||||||
|
private String featureID;
|
||||||
|
|
||||||
public String getFeatureID() {
|
public String getFeatureID() {
|
||||||
return featureID;
|
return featureID;
|
||||||
|
|||||||
@ -30,6 +30,8 @@ public class MobileDevice implements Serializable {
|
|||||||
private String osVersion;
|
private String osVersion;
|
||||||
private String model;
|
private String model;
|
||||||
private String vendor;
|
private String vendor;
|
||||||
|
private String latitude;
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
public String getMobileDeviceId() {
|
public String getMobileDeviceId() {
|
||||||
return mobileDeviceId;
|
return mobileDeviceId;
|
||||||
@ -86,4 +88,20 @@ public class MobileDevice implements Serializable {
|
|||||||
public void setVendor(String vendor) {
|
public void setVendor(String vendor) {
|
||||||
this.vendor = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,12 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 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.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of operation.
|
* DTO of operation.
|
||||||
*/
|
*/
|
||||||
public class Operation {
|
public class Operation {
|
||||||
int operationId;
|
|
||||||
String featureCode;
|
private int operationId;
|
||||||
int createdDate;
|
private String featureCode;
|
||||||
|
private long createdDate;
|
||||||
|
private List<OperationProperty> properties;
|
||||||
|
|
||||||
public int getOperationId() {
|
public int getOperationId() {
|
||||||
return operationId;
|
return operationId;
|
||||||
@ -16,6 +36,14 @@ public class Operation {
|
|||||||
this.operationId = operationId;
|
this.operationId = operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<OperationProperty> getProperties() {
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProperties(List<OperationProperty> properties) {
|
||||||
|
this.properties = properties;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFeatureCode() {
|
public String getFeatureCode() {
|
||||||
return featureCode;
|
return featureCode;
|
||||||
}
|
}
|
||||||
@ -24,13 +52,11 @@ public class Operation {
|
|||||||
this.featureCode = featureCode;
|
this.featureCode = featureCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCreatedDate() {
|
public long getCreatedDate() {
|
||||||
return createdDate;
|
return createdDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedDate(int createdDate) {
|
public void setCreatedDate(long createdDate) {
|
||||||
this.createdDate = createdDate;
|
this.createdDate = createdDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,13 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2014 - 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.dto;
|
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DTO of operation property.
|
* DTO of operation property.
|
||||||
*/
|
*/
|
||||||
public class OperationProperty {
|
public class OperationProperty {
|
||||||
int operationPropertyId;
|
|
||||||
int getOperationId;
|
private int operationPropertyId;
|
||||||
int propertyId;
|
private int operationId;
|
||||||
String value;
|
private int propertyId;
|
||||||
|
private String value;
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return value;
|
return value;
|
||||||
@ -26,11 +43,11 @@ public class OperationProperty {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getOperationId() {
|
public int getOperationId() {
|
||||||
return getOperationId;
|
return operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOperationId(int getOperationId) {
|
public void setOperationId(int operationId) {
|
||||||
this.getOperationId = getOperationId;
|
this.operationId = operationId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPropertyId() {
|
public int getPropertyId() {
|
||||||
|
|||||||
@ -47,7 +47,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||||
boolean status = false;
|
boolean status;
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
try {
|
try {
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice);
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice);
|
||||||
@ -62,7 +62,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||||
boolean status = false;
|
boolean status;
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
try {
|
try {
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
@ -78,7 +78,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
boolean status = false;
|
boolean status;
|
||||||
try {
|
try {
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
.deleteDevice(deviceId.getId());
|
.deleteDevice(deviceId.getId());
|
||||||
@ -122,7 +122,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||||
Device device = null;
|
Device device;
|
||||||
try {
|
try {
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||||
getDevice(deviceId.getId());
|
getDevice(deviceId.getId());
|
||||||
@ -143,14 +143,13 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||||
boolean status = false;
|
boolean status;
|
||||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||||
try {
|
try {
|
||||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||||
.updateDevice(mobileDevice);
|
.updateDevice(mobileDevice);
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
String msg =
|
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
|
||||||
"Error while updating the Android device : " + device.getDeviceIdentifier();
|
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
throw new DeviceManagementException(msg, e);
|
throw new DeviceManagementException(msg, e);
|
||||||
}
|
}
|
||||||
@ -166,8 +165,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
|||||||
getAllDevices();
|
getAllDevices();
|
||||||
if (mobileDevices != null) {
|
if (mobileDevices != null) {
|
||||||
devices = new ArrayList<Device>();
|
devices = new ArrayList<Device>();
|
||||||
for (int x = 0; x < mobileDevices.size(); x++) {
|
for (MobileDevice mobileDevice : mobileDevices) {
|
||||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevices.get(x)));
|
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MobileDeviceManagementDAOException e) {
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2012, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -15,13 +15,47 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.android;
|
package org.wso2.carbon.device.mgt.mobile.impl.android;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.common.OperationManagementException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
|
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(AndroidMobileOperationManager.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean executeOperation() {
|
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
||||||
|
OperationManagementException {
|
||||||
|
try {
|
||||||
|
MobileDeviceManagementDAOFactory.getOperationDAO().addOperation(
|
||||||
|
new org.wso2.carbon.device.mgt.mobile.dto.Operation());
|
||||||
|
MobileDeviceManagementDAOFactory.geOperationPropertyDAO()
|
||||||
|
.addOperationProperty(new OperationProperty());
|
||||||
|
MobileDeviceManagementDAOFactory.getDeviceOperationDAO()
|
||||||
|
.addDeviceOperation(new DeviceOperation());
|
||||||
|
} catch (MobileDeviceManagementDAOException e) {
|
||||||
|
String msg = "Error while updating the enrollment of the Android device : " +
|
||||||
|
devices.get(0).getId();
|
||||||
|
log.error(msg, e);
|
||||||
|
throw new OperationManagementException(msg, e);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||||
|
throws OperationManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -88,5 +88,4 @@ public class IOSDeviceManagerService implements DeviceManagerService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,7 +105,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
services */
|
services */
|
||||||
this.removeAPIs();
|
this.removeAPIs();
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
log.error("Error occurred while de-activating Mobile Device Management bundle");
|
log.error("Error occurred while de-activating Mobile Device Management bundle", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,165 @@
|
|||||||
|
/**
|
||||||
|
* 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.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.apimgt.api.APIManagementException;
|
||||||
|
import org.wso2.carbon.apimgt.api.APIProvider;
|
||||||
|
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
|
||||||
|
import org.wso2.carbon.apimgt.impl.APIManagerFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.config.APIConfig;
|
||||||
|
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.MobileDeviceManagementDAOFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.util.DeviceManagementAPIPublisherUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @scr.component name="org.wso2.carbon.device.mgt.mobile.impl.internal.MobileDeviceManagementServiceComponent"
|
||||||
|
* immediate="true"
|
||||||
|
* @scr.reference name="api.manager.config.service"
|
||||||
|
* interface="org.wso2.carbon.apimgt.impl.APIManagerConfigurationService"
|
||||||
|
* cardinality="1..1"
|
||||||
|
* policy="dynamic"
|
||||||
|
* bind="setAPIManagerConfigurationService"
|
||||||
|
* unbind="unsetAPIManagerConfigurationService"
|
||||||
|
* <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 iOSServiceRegRef;
|
||||||
|
private ServiceRegistration windowsServiceRegRef;
|
||||||
|
|
||||||
|
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 datasource configuration */
|
||||||
|
MobileDeviceConfigurationManager.getInstance().initConfig();
|
||||||
|
MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
||||||
|
.getMobileDeviceManagementConfig();
|
||||||
|
MobileDataSourceConfig dsConfig =
|
||||||
|
config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
||||||
|
|
||||||
|
MobileDeviceManagementDAOFactory.setMobileDataSourceConfig(dsConfig);
|
||||||
|
|
||||||
|
androidServiceRegRef =
|
||||||
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
|
new AndroidDeviceManagerService(), null);
|
||||||
|
iOSServiceRegRef =
|
||||||
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
|
new IOSDeviceManagerService(), null);
|
||||||
|
windowsServiceRegRef =
|
||||||
|
bundleContext.registerService(DeviceManagerService.class.getName(),
|
||||||
|
new WindowsDeviceManagerService(), null);
|
||||||
|
|
||||||
|
/* Initialize all API configurations with corresponding API Providers */
|
||||||
|
this.initAPIConfigs();
|
||||||
|
/* Publish all mobile device management related JAX-RS services as APIs */
|
||||||
|
this.publishAPIs();
|
||||||
|
|
||||||
|
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 {
|
||||||
|
BundleContext bundleContext = ctx.getBundleContext();
|
||||||
|
|
||||||
|
androidServiceRegRef.unregister();
|
||||||
|
iOSServiceRegRef.unregister();
|
||||||
|
windowsServiceRegRef.unregister();
|
||||||
|
|
||||||
|
/* Removing all APIs published upon start-up for mobile device management related JAX-RS
|
||||||
|
services */
|
||||||
|
this.removeAPIs();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAPIConfigs() throws DeviceManagementException {
|
||||||
|
List<APIConfig> apiConfigs =
|
||||||
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
|
getApiPublisherConfig().getAPIs();
|
||||||
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
|
try {
|
||||||
|
APIProvider provider = APIManagerFactory.getInstance().getAPIProvider(apiConfig.getOwner());
|
||||||
|
apiConfig.init(provider);
|
||||||
|
} catch (APIManagementException e) {
|
||||||
|
throw new DeviceManagementException("Error occurred while initializing API Config '" +
|
||||||
|
apiConfig.getName() + "'", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void publishAPIs() throws DeviceManagementException {
|
||||||
|
List<APIConfig> apiConfigs =
|
||||||
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
|
getApiPublisherConfig().getAPIs();
|
||||||
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
|
DeviceManagementAPIPublisherUtil.publishAPI(apiConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeAPIs() throws DeviceManagementException {
|
||||||
|
List<APIConfig> apiConfigs =
|
||||||
|
MobileDeviceConfigurationManager.getInstance().getMobileDeviceManagementConfig().
|
||||||
|
getApiPublisherConfig().getAPIs();
|
||||||
|
for (APIConfig apiConfig : apiConfigs) {
|
||||||
|
DeviceManagementAPIPublisherUtil.removeAPI(apiConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetAPIManagerConfigurationService(APIManagerConfigurationService service) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -22,12 +22,13 @@ import org.w3c.dom.Document;
|
|||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides utility methods required by the mobile device management bundle.
|
* Provides utility methods required by the mobile device management bundle.
|
||||||
@ -41,6 +42,8 @@ public class MobileDeviceManagementUtil {
|
|||||||
private static final String MOBILE_DEVICE_VENDOR = "vendor";
|
private static final String MOBILE_DEVICE_VENDOR = "vendor";
|
||||||
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
|
private static final String MOBILE_DEVICE_OS_VERSION = "osVersion";
|
||||||
private static final String MOBILE_DEVICE_MODEL = "model";
|
private static final String MOBILE_DEVICE_MODEL = "model";
|
||||||
|
private static final String MOBILE_DEVICE_LATITUDE = "latitude";
|
||||||
|
private static final String MOBILE_DEVICE_LONGITUDE = "longitude";
|
||||||
|
|
||||||
public static Document convertToDocument(File file) throws DeviceManagementException {
|
public static Document convertToDocument(File file) throws DeviceManagementException {
|
||||||
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||||
@ -86,6 +89,8 @@ public class MobileDeviceManagementUtil {
|
|||||||
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
mobileDevice.setModel(getPropertyValue(device, MOBILE_DEVICE_MODEL));
|
||||||
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
mobileDevice.setOsVersion(getPropertyValue(device, MOBILE_DEVICE_OS_VERSION));
|
||||||
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
mobileDevice.setVendor(getPropertyValue(device, MOBILE_DEVICE_VENDOR));
|
||||||
|
mobileDevice.setLatitude(getPropertyValue(device,MOBILE_DEVICE_LATITUDE));
|
||||||
|
mobileDevice.setLongitude(getPropertyValue(device,MOBILE_DEVICE_LONGITUDE));
|
||||||
}
|
}
|
||||||
return mobileDevice;
|
return mobileDevice;
|
||||||
}
|
}
|
||||||
@ -101,9 +106,23 @@ public class MobileDeviceManagementUtil {
|
|||||||
propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel()));
|
propertyList.add(getProperty(MOBILE_DEVICE_MODEL,mobileDevice.getModel()));
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion()));
|
propertyList.add(getProperty(MOBILE_DEVICE_OS_VERSION,mobileDevice.getOsVersion()));
|
||||||
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor()));
|
propertyList.add(getProperty(MOBILE_DEVICE_VENDOR,mobileDevice.getVendor()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_LATITUDE,mobileDevice.getLatitude()));
|
||||||
|
propertyList.add(getProperty(MOBILE_DEVICE_LONGITUDE,mobileDevice.getLongitude()));
|
||||||
device.setProperties(propertyList);
|
device.setProperties(propertyList);
|
||||||
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
device.setDeviceIdentifier(mobileDevice.getMobileDeviceId());
|
||||||
}
|
}
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Operation convertToOperation(org.wso2.carbon.device.mgt.common.Operation operation){
|
||||||
|
Operation mobileOperation = new Operation();
|
||||||
|
List<OperationProperty> properties = new LinkedList<OperationProperty>();
|
||||||
|
mobileOperation.setFeatureCode(operation.getCode());
|
||||||
|
mobileOperation.setCreatedDate(new Date().getTime());
|
||||||
|
Properties operationProperties = operation.getProperties();
|
||||||
|
for(String key : operationProperties.stringPropertyNames()) {
|
||||||
|
String value = operationProperties.getProperty(key);
|
||||||
|
}
|
||||||
|
return mobileOperation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ Version 2.0 (the "License"); you may not use this file except
|
~ you may not use this file except in compliance with the License.
|
||||||
~ 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,
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ software distributed under the License is distributed on an
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ KIND, either express or implied. See the License for the
|
~ See the License for the specific language governing permissions and
|
||||||
~ specific language governing permissions and limitations
|
~ limitations under the License.
|
||||||
~ under the License.
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.evaluator;
|
package org.wso2.carbon.policy.evaluator;
|
||||||
|
|||||||
@ -1,25 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.evaluator.spi;
|
package org.wso2.carbon.policy.evaluator.spi;
|
||||||
|
|
||||||
|
|
||||||
public interface PDPService {
|
public interface PDPService {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ Version 2.0 (the "License"); you may not use this file except
|
~ you may not use this file except in compliance with the License.
|
||||||
~ 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,
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ software distributed under the License is distributed on an
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ KIND, either express or implied. See the License for the
|
~ See the License for the specific language governing permissions and
|
||||||
~ specific language governing permissions and limitations
|
~ limitations under the License.
|
||||||
~ under the License.
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|||||||
@ -1,27 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface FeatureManagerService {
|
public interface FeatureManagerService {
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|||||||
@ -1,27 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common;
|
package org.wso2.carbon.policy.mgt.common;
|
||||||
|
|
||||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
|
||||||
import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines the policy management which should be implemented by the plugins
|
* This interface defines the policy management which should be implemented by the plugins
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.common.impl;
|
package org.wso2.carbon.policy.mgt.common.impl;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005-2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wos2.carbon.policy.mgt.common;
|
package org.wos2.carbon.policy.mgt.common;
|
||||||
@ -36,7 +34,6 @@ public class PolicyManagementTestCase {
|
|||||||
|
|
||||||
private PolicyManagement policyManagement = new PolicyManagement();
|
private PolicyManagement policyManagement = new PolicyManagement();
|
||||||
|
|
||||||
|
|
||||||
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device")
|
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device")
|
||||||
public void testAddPolicy() throws FeatureManagementException, PolicyManagementException {
|
public void testAddPolicy() throws FeatureManagementException, PolicyManagementException {
|
||||||
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
|
Assert.assertEquals(policyManagement.addPolicyToDevice("1212-ESDD-12ER-7890", "MD", policy), 0);
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wos2.carbon.policy.mgt.common.utils;
|
package org.wos2.carbon.policy.mgt.common.utils;
|
||||||
|
|||||||
@ -1,21 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ Version 2.0 (the "License"); you may not use this file except
|
~ you may not use this file except in compliance with the License.
|
||||||
~ 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,
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ software distributed under the License is distributed on an
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ KIND, either express or implied. See the License for the
|
~ See the License for the specific language governing permissions and
|
||||||
~ specific language governing permissions and limitations
|
~ limitations under the License.
|
||||||
~ under the License.
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with 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.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.config;
|
package org.wso2.carbon.policy.mgt.core.config;
|
||||||
|
|||||||
@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with 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.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.config;
|
package org.wso2.carbon.policy.mgt.core.config;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
|
|||||||
@ -1,17 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with 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.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.config;
|
package org.wso2.carbon.policy.mgt.core.config;
|
||||||
|
|
||||||
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
import org.wso2.carbon.policy.mgt.core.config.datasource.DataSourceConfig;
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with 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.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.config.datasource;
|
package org.wso2.carbon.policy.mgt.core.config.datasource;
|
||||||
@ -24,15 +25,14 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||||||
@XmlRootElement(name = "DataSourceConfiguration")
|
@XmlRootElement(name = "DataSourceConfiguration")
|
||||||
public class DataSourceConfig {
|
public class DataSourceConfig {
|
||||||
|
|
||||||
private JNDILookupDefinition jndiLookupDefintion;
|
private JNDILookupDefinition jndiLookupDefinition;
|
||||||
|
|
||||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
public JNDILookupDefinition getJndiLookupDefinition() {
|
||||||
return jndiLookupDefintion;
|
return jndiLookupDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) {
|
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
|
||||||
this.jndiLookupDefintion = jndiLookupDefintion;
|
this.jndiLookupDefinition = jndiLookupDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* 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
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* in compliance with 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.
|
*
|
||||||
* Unless required by applicable law or agreed to in writing,
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
* software distributed under the License is distributed on an
|
*
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* KIND, either express or implied. See the License for the
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* specific language governing permissions and limitations
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* under the License.
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.config.datasource;
|
package org.wso2.carbon.policy.mgt.core.config.datasource;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
@ -28,7 +26,7 @@ public interface PolicyDAO {
|
|||||||
|
|
||||||
int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException;
|
int addPolicy(String deviceID, String deviceType, Policy policy) throws PolicyManagerDAOException;
|
||||||
|
|
||||||
void updatePolicy(int id) throws PolicyManagerDAOException;
|
void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException;
|
||||||
|
|
||||||
Policy getPolicy() throws PolicyManagerDAOException;
|
Policy getPolicy() throws PolicyManagerDAOException;
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
@ -55,7 +53,7 @@ public class PolicyManagementDAOFactory {
|
|||||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||||
"is null and thus, is not initialized");
|
"is null and thus, is not initialized");
|
||||||
}
|
}
|
||||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||||
if (jndiConfig != null) {
|
if (jndiConfig != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao;
|
package org.wso2.carbon.policy.mgt.core.dao;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao.impl;
|
package org.wso2.carbon.policy.mgt.core.dao.impl;
|
||||||
@ -39,7 +37,6 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int addPolicy(Policy policy) throws PolicyManagerDAOException {
|
public int addPolicy(Policy policy) throws PolicyManagerDAOException {
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +51,7 @@ public class PolicyDAOImpl implements PolicyDAO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePolicy(int id) throws PolicyManagerDAOException {
|
public void updatePolicy(int id, Policy policy) throws PolicyManagerDAOException {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.dao.util;
|
package org.wso2.carbon.policy.mgt.core.dao.util;
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.internal;
|
package org.wso2.carbon.policy.mgt.core.internal;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/**
|
/*
|
||||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -13,6 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.internal;
|
package org.wso2.carbon.policy.mgt.core.internal;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|||||||
@ -1,24 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.util;
|
package org.wso2.carbon.policy.mgt.core.util;
|
||||||
|
|
||||||
public final class PolicyManagementConstants {
|
public final class PolicyManagementConstants {
|
||||||
|
|
||||||
public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml";
|
public static final String DEVICE_CONFIG_XML_NAME = "cdm-config.xml";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
*
|
*
|
||||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* Version 2.0 (the "License"); you may not use this file except
|
* you may not use this file except in compliance with the License.
|
||||||
* 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,
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* software distributed under the License is distributed on an
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* KIND, either express or implied. See the License for the
|
* See the License for the specific language governing permissions and
|
||||||
* specific language governing permissions and limitations
|
* limitations under the License.
|
||||||
* under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.policy.mgt.core.util;
|
package org.wso2.carbon.policy.mgt.core.util;
|
||||||
@ -61,7 +59,7 @@ public class PolicyManagerUtil {
|
|||||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||||
"is null and thus, is not initialized");
|
"is null and thus, is not initialized");
|
||||||
}
|
}
|
||||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||||
if (jndiConfig != null) {
|
if (jndiConfig != null) {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ Version 2.0 (the "License"); you may not use this file except
|
~ you may not use this file except in compliance with the License.
|
||||||
~ 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,
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ software distributed under the License is distributed on an
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ KIND, either express or implied. See the License for the
|
~ See the License for the specific language governing permissions and
|
||||||
~ specific language governing permissions and limitations
|
~ limitations under the License.
|
||||||
~ under the License.
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
<ManagementRepository>
|
<ManagementRepository>
|
||||||
<DataSourceConfiguration>
|
<DataSourceConfiguration>
|
||||||
<JndiLookupDefinition>
|
<JndiLookupDefinition>
|
||||||
<Name>jdbc/MOBILE_MGT_DS</Name>
|
<Name>jdbc/MobileDM_DS</Name>
|
||||||
</JndiLookupDefinition>
|
</JndiLookupDefinition>
|
||||||
</DataSourceConfiguration>
|
</DataSourceConfiguration>
|
||||||
</ManagementRepository>
|
</ManagementRepository>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
<APIs>
|
<APIs>
|
||||||
<API>
|
<API>
|
||||||
<Name>enrollment</Name>
|
<Name>enrollment</Name>
|
||||||
<Provider>admin</Provider>
|
<Owner>admin</Owner>
|
||||||
<Context>enrollment</Context>
|
<Context>enrollment</Context>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Endpoint>http://localhost:9763/</Endpoint>
|
<Endpoint>http://localhost:9763/</Endpoint>
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
<ManagementRepository>
|
<ManagementRepository>
|
||||||
<DataSourceConfiguration>
|
<DataSourceConfiguration>
|
||||||
<JndiLookupDefinition>
|
<JndiLookupDefinition>
|
||||||
<Name>jdbc/DEVICE_MGT_DS</Name>
|
<Name>jdbc/DM_DS</Name>
|
||||||
</JndiLookupDefinition>
|
</JndiLookupDefinition>
|
||||||
</DataSourceConfiguration>
|
</DataSourceConfiguration>
|
||||||
</ManagementRepository>
|
</ManagementRepository>
|
||||||
|
|||||||
@ -0,0 +1,26 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS DM_DEVICE_TYPE
|
||||||
|
(
|
||||||
|
ID INT(11) auto_increment NOT NULL,
|
||||||
|
NAME VARCHAR(300) NULL DEFAULT NULL,
|
||||||
|
PRIMARY KEY (ID)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS DM_DEVICE
|
||||||
|
(
|
||||||
|
ID INT auto_increment NOT NULL,
|
||||||
|
DESCRIPTION TEXT NULL DEFAULT NULL,
|
||||||
|
NAME VARCHAR(100) NULL DEFAULT NULL,
|
||||||
|
DATE_OF_ENROLLMENT BIGINT NULL DEFAULT NULL,
|
||||||
|
DATE_OF_LAST_UPDATE BIGINT NULL DEFAULT NULL,
|
||||||
|
OWNERSHIP VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
STATUS VARCHAR(15) NULL DEFAULT NULL,
|
||||||
|
DEVICE_TYPE_ID INT(11) NULL DEFAULT NULL,
|
||||||
|
DEVICE_IDENTIFICATION VARCHAR(300) NULL DEFAULT NULL,
|
||||||
|
OWNER VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
TENANT_ID INTEGER DEFAULT 0,
|
||||||
|
PRIMARY KEY (ID),
|
||||||
|
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
||||||
|
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
|
);
|
||||||
|
-- TO:DO - Remove this INSERT sql statement.
|
||||||
|
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `DM_DEVICE_TYPE`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `DM_DEVICE_TYPE` (
|
||||||
|
`ID` INT(11) NOT NULL ,
|
||||||
|
`NAME` VARCHAR(300) NULL DEFAULT NULL ,
|
||||||
|
PRIMARY KEY (`ID`) )
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = latin1;
|
||||||
|
|
||||||
|
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
-- Table `DM_DEVICE`
|
||||||
|
-- -----------------------------------------------------
|
||||||
|
CREATE TABLE IF NOT EXISTS `DM_DEVICE` (
|
||||||
|
`ID` VARCHAR(20) NOT NULL ,
|
||||||
|
`DESCRIPTION` TEXT NULL DEFAULT NULL ,
|
||||||
|
`NAME` VARCHAR(100) NULL DEFAULT NULL ,
|
||||||
|
`DATE_OF_ENROLLMENT` DATETIME NULL DEFAULT NULL ,
|
||||||
|
`DATE_OF_LAST_UPDATE` DATETIME NULL DEFAULT NULL ,
|
||||||
|
`OWNERSHIP` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
|
`STATUS` VARCHAR(15) NULL DEFAULT NULL ,
|
||||||
|
`DEVICE_TYPE_ID` INT(11) NULL DEFAULT NULL ,
|
||||||
|
`DEVICE_IDENTIFICATION` VARCHAR(300) NULL DEFAULT NULL ,
|
||||||
|
`OWNER` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
|
TENANT_ID INTEGER DEFAULT 0,
|
||||||
|
PRIMARY KEY (`ID`) ,
|
||||||
|
INDEX `fk_DM_DEVICE_DM_DEVICE_TYPE2_idx` (`DEVICE_TYPE_ID` ASC) ,
|
||||||
|
CONSTRAINT `fk_DM_DEVICE_DM_DEVICE_TYPE2`
|
||||||
|
FOREIGN KEY (`DEVICE_TYPE_ID` )
|
||||||
|
REFERENCES `DM_DEVICE_TYPE` (`ID` )
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION)
|
||||||
|
ENGINE = InnoDB
|
||||||
|
DEFAULT CHARACTER SET = latin1;
|
||||||
@ -1,3 +1,3 @@
|
|||||||
instructions.configure = \
|
instructions.configure = \
|
||||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/conf/cdm-config.xml,target:${installFolder}/../../conf/cdm-config.xml,overwrite:true);\
|
||||||
|
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.mgt.server_${feature.version}/dbscripts/cdm,target:${installFolder}/../../../dbscripts/cdm,overwrite:true);\
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ you may not use this file except in compliance with the License.
|
~ you may not use this file except in compliance with the License.
|
||||||
|
|||||||
@ -1,20 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
~
|
~
|
||||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
~ Version 2.0 (the "License"); you may not use this file except
|
~ you may not use this file except in compliance with the License.
|
||||||
~ 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,
|
~ Unless required by applicable law or agreed to in writing, software
|
||||||
~ software distributed under the License is distributed on an
|
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
~ KIND, either express or implied. See the License for the
|
~ See the License for the specific language governing permissions and
|
||||||
~ specific language governing permissions and limitations
|
~ limitations under the License.
|
||||||
~ under the License.
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
|||||||
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* 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 cdm.api.android;
|
||||||
|
|
||||||
|
import cdm.api.android.common.AndroidAgentException;
|
||||||
|
import cdm.api.android.util.AndroidAPIUtils;
|
||||||
|
import cdm.api.android.util.Message;
|
||||||
|
import org.apache.commons.httpclient.HttpStatus;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.wso2.carbon.device.mgt.common.*;
|
||||||
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
|
||||||
|
|
||||||
|
import javax.ws.rs.*;
|
||||||
|
import javax.ws.rs.core.Response;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Android Device Operation REST-API implementation.
|
||||||
|
*/
|
||||||
|
@Produces({ "application/json", "application/xml" })
|
||||||
|
@Consumes({ "application/json", "application/xml" })
|
||||||
|
public class Operation {
|
||||||
|
|
||||||
|
private static Log log = LogFactory.getLog(Operation.class);
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{id}")
|
||||||
|
public List<org.wso2.carbon.device.mgt.common.Operation> getAllOperations(
|
||||||
|
@PathParam("id") String id) throws
|
||||||
|
AndroidAgentException {
|
||||||
|
List<org.wso2.carbon.device.mgt.common.Operation> operations;
|
||||||
|
String msg;
|
||||||
|
DeviceManagementService dmService;
|
||||||
|
|
||||||
|
try {
|
||||||
|
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||||
|
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||||
|
msg = "Device management service error";
|
||||||
|
log.error(msg, deviceMgtServiceEx);
|
||||||
|
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
|
||||||
|
operations = dmService.getOperationManager(
|
||||||
|
DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID)
|
||||||
|
.getOperations(deviceIdentifier);
|
||||||
|
Response.status(HttpStatus.SC_OK);
|
||||||
|
return operations;
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||||
|
log.error(msg, e);
|
||||||
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
throw new AndroidAgentException(msg, e);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
msg = "Error occurred while fetching the operation list for the device.";
|
||||||
|
log.error(msg, e);
|
||||||
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
throw new AndroidAgentException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PUT
|
||||||
|
public Message updateOperation() throws
|
||||||
|
AndroidAgentException {
|
||||||
|
String msg;
|
||||||
|
DeviceManagementService dmService;
|
||||||
|
Message responseMsg = new Message();
|
||||||
|
|
||||||
|
try {
|
||||||
|
dmService = AndroidAPIUtils.getDeviceManagementService();
|
||||||
|
|
||||||
|
} catch (DeviceManagementServiceException deviceMgtServiceEx) {
|
||||||
|
msg = "Device management service error";
|
||||||
|
log.error(msg, deviceMgtServiceEx);
|
||||||
|
throw new AndroidAgentException(msg, deviceMgtServiceEx);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean result = dmService.getOperationManager("").addOperation(null, null);
|
||||||
|
if (result) {
|
||||||
|
Response.status(HttpStatus.SC_OK);
|
||||||
|
responseMsg.setResponseMessage("Device has already enrolled");
|
||||||
|
} else {
|
||||||
|
Response.status(HttpStatus.SC_NOT_FOUND);
|
||||||
|
responseMsg.setResponseMessage("Operation not found");
|
||||||
|
}
|
||||||
|
return responseMsg;
|
||||||
|
} catch (DeviceManagementException e) {
|
||||||
|
msg = "Error occurred while fetching the operation manager for the device type.";
|
||||||
|
log.error(msg, e);
|
||||||
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
throw new AndroidAgentException(msg, e);
|
||||||
|
} catch (OperationManagementException e) {
|
||||||
|
msg = "Error occurred while updating the operation status for the device.";
|
||||||
|
log.error(msg, e);
|
||||||
|
Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR);
|
||||||
|
throw new AndroidAgentException(msg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -98,6 +98,40 @@
|
|||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<!--<version>${maven-antrun-plugin.version}</version>-->
|
<!--<version>${maven-antrun-plugin.version}</version>-->
|
||||||
<executions>
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<!-- Creating Device Management schema -->
|
||||||
|
<id>create-device-mgt-schema</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<tasks>
|
||||||
|
<echo
|
||||||
|
message="########### Create Device Management H2 Schema ###########"/>
|
||||||
|
|
||||||
|
<property name="db.dir"
|
||||||
|
value="target/wso2carbon-core-${carbon.kernel.version}/repository/database"/>
|
||||||
|
<property name="userid" value="wso2carbon"/>
|
||||||
|
<property name="password" value="wso2carbon"/>
|
||||||
|
<property name="dbURL"
|
||||||
|
value="jdbc:h2:file:${basedir}/${db.dir}/WSO2DM_DB;DB_CLOSE_ON_EXIT=FALSE"/>
|
||||||
|
|
||||||
|
<sql driver="org.h2.Driver"
|
||||||
|
url="${dbURL}"
|
||||||
|
userid="${userid}" password="${password}"
|
||||||
|
autocommit="true" onerror="continue">
|
||||||
|
<classpath refid="maven.dependency.classpath"/>
|
||||||
|
<classpath refid="maven.compile.classpath"/>
|
||||||
|
<classpath refid="maven.runtime.classpath"/>
|
||||||
|
|
||||||
|
<fileset file="${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm/h2.sql"/>
|
||||||
|
</sql>
|
||||||
|
<echo
|
||||||
|
message="##################### END ####################"/>
|
||||||
|
</tasks>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<!-- Creating IDP Management schema -->
|
<!-- Creating IDP Management schema -->
|
||||||
<id>create-idp-mgt-schema</id>
|
<id>create-idp-mgt-schema</id>
|
||||||
@ -132,6 +166,40 @@
|
|||||||
</tasks>
|
</tasks>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<!-- Creating API Management schema -->
|
||||||
|
<id>create-api-mgt-schema</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<tasks>
|
||||||
|
<echo
|
||||||
|
message="########### Create API Management H2 Schema ###########"/>
|
||||||
|
|
||||||
|
<property name="db.dir"
|
||||||
|
value="target/wso2carbon-core-${carbon.kernel.version}/repository/database"/>
|
||||||
|
<property name="userid" value="wso2carbon"/>
|
||||||
|
<property name="password" value="wso2carbon"/>
|
||||||
|
<property name="dbURL"
|
||||||
|
value="jdbc:h2:file:${basedir}/${db.dir}/WSO2AM_DB;DB_CLOSE_ON_EXIT=FALSE"/>
|
||||||
|
|
||||||
|
<sql driver="org.h2.Driver"
|
||||||
|
url="${dbURL}"
|
||||||
|
userid="${userid}" password="${password}"
|
||||||
|
autocommit="true" onerror="continue">
|
||||||
|
<classpath refid="maven.dependency.classpath"/>
|
||||||
|
<classpath refid="maven.compile.classpath"/>
|
||||||
|
<classpath refid="maven.runtime.classpath"/>
|
||||||
|
|
||||||
|
<fileset file="${basedir}/../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt/h2.sql"/>
|
||||||
|
</sql>
|
||||||
|
<echo
|
||||||
|
message="##################### END ####################"/>
|
||||||
|
</tasks>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>3-extract-docs-from-components</id>
|
<id>3-extract-docs-from-components</id>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
|||||||
@ -128,7 +128,8 @@
|
|||||||
</fileSet>
|
</fileSet>
|
||||||
|
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
|
<directory>
|
||||||
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources/rxts/
|
||||||
</directory>
|
</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/repository/resources/rxts/</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/repository/resources/rxts/</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
@ -186,6 +187,17 @@
|
|||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
|
||||||
|
<!-- Copying API management related dbscripts -->
|
||||||
|
<fileSet>
|
||||||
|
<directory>
|
||||||
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/apimgt
|
||||||
|
</directory>
|
||||||
|
<outputDirectory>wso2cdm-${project.version}/dbscripts/apimgt</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>*/**</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
|
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>
|
<directory>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/modules
|
||||||
@ -196,17 +208,20 @@
|
|||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
|
||||||
<!-- Script -->
|
<!-- Copying Device Management related dbscripts -->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>src/repository/dbscripts/</directory>
|
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/dbscripts/cdm</directory>
|
||||||
<outputDirectory>wso2cdm-${project.version}/dbscripts</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/dbscripts/cdm</outputDirectory>
|
||||||
<includes>
|
<includes>
|
||||||
<include>*/**</include>
|
<include>*/**</include>
|
||||||
</includes>
|
</includes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources</directory>
|
<directory>
|
||||||
<outputDirectory>${project.artifactId}-${project.version}/repository/resources</outputDirectory>
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/resources
|
||||||
|
</directory>
|
||||||
|
<outputDirectory>${project.artifactId}-${project.version}/repository/resources
|
||||||
|
</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
<!-- copy cdm jaggery app -->
|
<!-- copy cdm jaggery app -->
|
||||||
<fileSet>
|
<fileSet>
|
||||||
@ -216,6 +231,7 @@
|
|||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
|
|
||||||
<dependencySets>
|
<dependencySets>
|
||||||
<dependencySet>
|
<dependencySet>
|
||||||
<outputDirectory>wso2cdm-${project.version}/lib/endorsed</outputDirectory>
|
<outputDirectory>wso2cdm-${project.version}/lib/endorsed</outputDirectory>
|
||||||
@ -234,13 +250,18 @@
|
|||||||
</dependencySets>
|
</dependencySets>
|
||||||
|
|
||||||
<files>
|
<files>
|
||||||
|
|
||||||
<file>
|
<file>
|
||||||
<source>../agents/android/jax-rs/target/cdm-android-api.war</source>
|
<source>../agents/android/jax-rs/target/cdm-android-api.war</source>
|
||||||
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
||||||
</outputDirectory>
|
</outputDirectory>
|
||||||
<fileMode>755</fileMode>
|
<fileMode>755</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
<file>
|
||||||
|
<source>../rest-api/target/wso2cdm-api.war</source>
|
||||||
|
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
||||||
|
</outputDirectory>
|
||||||
|
<fileMode>755</fileMode>
|
||||||
|
</file>
|
||||||
<!-- <file>
|
<!-- <file>
|
||||||
<source>
|
<source>
|
||||||
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml
|
../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/tomcat/webapp-classloading.xml
|
||||||
@ -419,6 +440,25 @@
|
|||||||
<fileMode>644</fileMode>
|
<fileMode>644</fileMode>
|
||||||
</file>
|
</file>
|
||||||
|
|
||||||
|
<!-- Copying H2 database related files corresponding to default API management repository schema -->
|
||||||
|
<file>
|
||||||
|
<source>
|
||||||
|
target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2AM_DB.h2.db
|
||||||
|
</source>
|
||||||
|
<outputDirectory>${pom.artifactId}-${pom.version}/repository/database</outputDirectory>
|
||||||
|
<destName>WSO2AM_DB.h2.db</destName>
|
||||||
|
<fileMode>644</fileMode>
|
||||||
|
</file>
|
||||||
|
|
||||||
|
<!-- Copying H2 database related files corresponding to default Device management repository schema -->
|
||||||
|
<file>
|
||||||
|
<source>
|
||||||
|
target/wso2carbon-core-${carbon.kernel.version}/repository/database/WSO2DM_DB.h2.db
|
||||||
|
</source>
|
||||||
|
<outputDirectory>${pom.artifactId}-${pom.version}/repository/database</outputDirectory>
|
||||||
|
<destName>WSO2DM_DB.h2.db</destName>
|
||||||
|
<fileMode>644</fileMode>
|
||||||
|
</file>
|
||||||
|
|
||||||
</files>
|
</files>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
|||||||
@ -5,14 +5,14 @@
|
|||||||
|
|
||||||
<datasources>
|
<datasources>
|
||||||
<datasource>
|
<datasource>
|
||||||
<name>DEVICE_MGT_DS</name>
|
<name>DM_DS</name>
|
||||||
<description>The datasource used for CDM</description>
|
<description>The datasource used for CDM</description>
|
||||||
<jndiConfig>
|
<jndiConfig>
|
||||||
<name>jdbc/DEVICE_MGT_DS</name>
|
<name>jdbc/DM_DS</name>
|
||||||
</jndiConfig>
|
</jndiConfig>
|
||||||
<definition type="RDBMS">
|
<definition type="RDBMS">
|
||||||
<configuration>
|
<configuration>
|
||||||
<url>jdbc:h2:repository/database/WSO2DEVICEMGT_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
<url>jdbc:h2:repository/database/WSO2DM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
||||||
<username>wso2carbon</username>
|
<username>wso2carbon</username>
|
||||||
<password>wso2carbon</password>
|
<password>wso2carbon</password>
|
||||||
<driverClassName>org.h2.Driver</driverClassName>
|
<driverClassName>org.h2.Driver</driverClassName>
|
||||||
@ -25,14 +25,14 @@
|
|||||||
</definition>
|
</definition>
|
||||||
</datasource>
|
</datasource>
|
||||||
<datasource>
|
<datasource>
|
||||||
<name>MOBILE_MGT_DS</name>
|
<name>MobileDM_DS</name>
|
||||||
<description>The datasource used for CDM Mobile Device Management</description>
|
<description>The datasource used for CDM Mobile Device Management</description>
|
||||||
<jndiConfig>
|
<jndiConfig>
|
||||||
<name>jdbc/MOBILE_MGT_DS</name>
|
<name>jdbc/MobileDM_DS</name>
|
||||||
</jndiConfig>
|
</jndiConfig>
|
||||||
<definition type="RDBMS">
|
<definition type="RDBMS">
|
||||||
<configuration>
|
<configuration>
|
||||||
<url>jdbc:h2:repository/database/WSO2MOBILE_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
<url>jdbc:h2:repository/database/WSO2MobileDM_DB;DB_CLOSE_ON_EXIT=FALSE</url>
|
||||||
<username>wso2carbon</username>
|
<username>wso2carbon</username>
|
||||||
<password>wso2carbon</password>
|
<password>wso2carbon</password>
|
||||||
<driverClassName>org.h2.Driver</driverClassName>
|
<driverClassName>org.h2.Driver</driverClassName>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
</definition>
|
</definition>
|
||||||
</datasource>
|
</datasource>
|
||||||
<datasource>
|
<datasource>
|
||||||
<name>WSO2DEVICE_DB</name>
|
<name>WSO2AM_DS</name>
|
||||||
<description>The datasource used for CDM</description>
|
<description>The datasource used for CDM</description>
|
||||||
<jndiConfig>
|
<jndiConfig>
|
||||||
<name>jdbc/WSO2AM_DB</name>
|
<name>jdbc/WSO2AM_DB</name>
|
||||||
|
|||||||
@ -22,3 +22,5 @@ CREATE TABLE IF NOT EXISTS DM_DEVICE
|
|||||||
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID )
|
||||||
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
REFERENCES DM_DEVICE_TYPE (ID ) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||||
);
|
);
|
||||||
|
-- TO:DO - Remove this INSERT sql statement.
|
||||||
|
Insert into DM_DEVICE_TYPE (ID,NAME) VALUES (1, 'android');
|
||||||
|
|||||||
@ -10,6 +10,8 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
|||||||
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
|
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
|
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
|
`VENDOR` VARCHAR(45) NULL DEFAULT NULL ,
|
||||||
|
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
|
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
|
PRIMARY KEY (`MOBILE_DEVICE_ID`) );
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -35,11 +35,48 @@
|
|||||||
<name>WSO2 CDM - Integration Test Ui Pages</name>
|
<name>WSO2 CDM - Integration Test Ui Pages</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon</groupId>
|
<groupId>org.wso2.carbon</groupId>
|
||||||
<artifactId>org.wso2.carbon.integration.common.admin.client</artifactId>
|
<artifactId>org.wso2.carbon.integration.common.admin.client</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.user.mgt.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.logging.view.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.ndatasource.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.server.admin.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.throttle.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.tenant.mgt.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.application.mgt.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.security.mgt.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.wso2.carbon</groupId>
|
||||||
|
<artifactId>org.wso2.carbon.identity.user.profile.stub</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wso2.carbon.automation</groupId>
|
<groupId>org.wso2.carbon.automation</groupId>
|
||||||
|
|||||||
@ -86,6 +86,7 @@ public class ServerDetails extends Activity {
|
|||||||
getResources().getString(R.string.shared_pref_ip));
|
getResources().getString(R.string.shared_pref_ip));
|
||||||
regId = Preference.get(context.getApplicationContext().getApplicationContext(), getResources().getString(R.string.shared_pref_regId));
|
regId = Preference.get(context.getApplicationContext().getApplicationContext(), getResources().getString(R.string.shared_pref_regId));
|
||||||
|
|
||||||
|
//heck if we have the IP saved previously.
|
||||||
if (ipSaved != null) {
|
if (ipSaved != null) {
|
||||||
serverIP.setText(ipSaved);
|
serverIP.setText(ipSaved);
|
||||||
CommonUtilities.setServerURL(ipSaved);
|
CommonUtilities.setServerURL(ipSaved);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user