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
This commit is contained in:
commit
1f489c8d62
@ -23,29 +23,17 @@ import java.util.List;
|
||||
public class Device {
|
||||
|
||||
private int id;
|
||||
|
||||
private String type;
|
||||
|
||||
private String description;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long dateOfEnrolment;
|
||||
|
||||
private Long dateOfLastUpdate;
|
||||
|
||||
private String ownership;
|
||||
|
||||
private boolean status;
|
||||
|
||||
private int deviceTypeId;
|
||||
|
||||
private String deviceIdentifier;
|
||||
|
||||
private String owner;
|
||||
|
||||
private List<Feature> features;
|
||||
|
||||
private List<Device.Property> properties;
|
||||
|
||||
@XmlElement
|
||||
@ -56,6 +44,7 @@ public class Device {
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getDescription() {
|
||||
return description;
|
||||
@ -64,6 +53,7 @@ public class Device {
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -72,6 +62,7 @@ public class Device {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Long getDateOfEnrolment() {
|
||||
return dateOfEnrolment;
|
||||
@ -80,6 +71,7 @@ public class Device {
|
||||
public void setDateOfEnrolment(Long dateOfEnrolment) {
|
||||
this.dateOfEnrolment = dateOfEnrolment;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public Long getDateOfLastUpdate() {
|
||||
return dateOfLastUpdate;
|
||||
@ -88,6 +80,7 @@ public class Device {
|
||||
public void setDateOfLastUpdate(Long dateOfLastUpdate) {
|
||||
this.dateOfLastUpdate = dateOfLastUpdate;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getOwnership() {
|
||||
return ownership;
|
||||
@ -96,6 +89,7 @@ public class Device {
|
||||
public void setOwnership(String ownership) {
|
||||
this.ownership = ownership;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public boolean isStatus() {
|
||||
return status;
|
||||
@ -104,6 +98,7 @@ public class Device {
|
||||
public void setStatus(boolean status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public int getDeviceTypeId() {
|
||||
return deviceTypeId;
|
||||
@ -112,6 +107,7 @@ public class Device {
|
||||
public void setDeviceTypeId(int deviceTypeId) {
|
||||
this.deviceTypeId = deviceTypeId;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getDeviceIdentifier() {
|
||||
return deviceIdentifier;
|
||||
@ -120,6 +116,7 @@ public class Device {
|
||||
public void setDeviceIdentifier(String deviceIdentifier) {
|
||||
this.deviceIdentifier = deviceIdentifier;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
@ -128,6 +125,7 @@ public class Device {
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public List<Feature> getFeatures() {
|
||||
return features;
|
||||
@ -136,6 +134,7 @@ public class Device {
|
||||
public void setFeatures(List<Feature> features) {
|
||||
this.features = features;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public String getType() {
|
||||
return type;
|
||||
@ -144,6 +143,7 @@ public class Device {
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public List<Device.Property> getProperties() {
|
||||
return properties;
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
/*
|
||||
*
|
||||
* * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
* *
|
||||
* * WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* * Version 2.0 (the "License"); you may not use this file except
|
||||
* * in compliance with the License.
|
||||
* * You may obtain a copy of the License at
|
||||
* *
|
||||
* * http://www.apache.org/licenses/LICENSE-2.0
|
||||
* *
|
||||
* * Unless required by applicable law or agreed to in writing,
|
||||
* * software distributed under the License is distributed on an
|
||||
* * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* * KIND, either express or implied. See the License for the
|
||||
* * specific language governing permissions and limitations
|
||||
* * under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.common;
|
||||
|
||||
public class License {
|
||||
|
||||
private String licenseName;
|
||||
private String licenseText;
|
||||
private String licenseVersion;
|
||||
|
||||
public String getLicenseName() {
|
||||
return licenseName;
|
||||
}
|
||||
|
||||
public void setLicenseName(String licenseName) {
|
||||
this.licenseName = licenseName;
|
||||
}
|
||||
|
||||
public String getLicenseText() {
|
||||
return licenseText;
|
||||
}
|
||||
|
||||
public void setLicenseText(String licenseText) {
|
||||
this.licenseText = licenseText;
|
||||
}
|
||||
|
||||
public String getLicenseVersion() {
|
||||
return licenseVersion;
|
||||
}
|
||||
|
||||
public void setLicenseVersion(String licenseVersion) {
|
||||
this.licenseVersion = licenseVersion;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public final class DeviceManagementConstants {
|
||||
|
||||
public static final class Common {
|
||||
private Common() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
public static final String PROPERTY_SETUP = "setup";
|
||||
}
|
||||
|
||||
}
|
||||
@ -35,19 +35,26 @@ public class DeviceManagementRepository {
|
||||
|
||||
public void addDeviceManagementProvider(DeviceManagerService provider) {
|
||||
String deviceType = provider.getProviderType();
|
||||
providers.put(deviceType, provider);
|
||||
try {
|
||||
DeviceManagerUtil.registerDeviceType(deviceType);
|
||||
} 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) {
|
||||
String deviceType = provider.getProviderType();
|
||||
|
||||
try {
|
||||
DeviceManagerUtil.unregisterDeviceType(deviceType);
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Exception occurred while registering the device type.", e);
|
||||
}
|
||||
providers.remove(deviceType);
|
||||
}
|
||||
|
||||
public DeviceManagerService getDeviceManagementProvider(String 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.util.DeviceManagementDAOUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceManagerImpl implements DeviceManager {
|
||||
@ -51,10 +52,9 @@ public class DeviceManagerImpl implements DeviceManager {
|
||||
boolean status = dms.enrollDevice(device);
|
||||
|
||||
try {
|
||||
this.getDeviceTypeDAO().getDeviceType();
|
||||
org.wso2.carbon.device.mgt.core.dto.Device deviceDto = DeviceManagementDAOUtil.convertDevice(device);
|
||||
Integer deviceTypeId = this.getDeviceTypeDAO().getDeviceTypeIdByDeviceTypeName(device.getType());
|
||||
deviceDto.setDeviceType(deviceTypeId);
|
||||
deviceDto.setDeviceTypeId(deviceTypeId);
|
||||
this.getDeviceDAO().addDevice(deviceDto);
|
||||
|
||||
} catch (DeviceManagementDAOException e) {
|
||||
@ -106,7 +106,27 @@ public class DeviceManagerImpl implements DeviceManager {
|
||||
public List<Device> getAllDevices(String type) throws DeviceManagementException {
|
||||
DeviceManagerService dms =
|
||||
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
|
||||
|
||||
@ -28,7 +28,7 @@ public final class DeviceManagementConfig {
|
||||
|
||||
private DeviceManagementRepository deviceMgtRepository;
|
||||
|
||||
@XmlElement(name = "ManagementRepository", nillable = false)
|
||||
@XmlElement(name = "ManagementRepository", required = true)
|
||||
public DeviceManagementRepository getDeviceMgtRepository() {
|
||||
return deviceMgtRepository;
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class DeviceManagementRepository {
|
||||
|
||||
private DataSourceConfig dataSourceConfig;
|
||||
|
||||
@XmlElement(name = "DataSourceConfiguration", nillable = false)
|
||||
@XmlElement(name = "DataSourceConfiguration", required = false)
|
||||
public DataSourceConfig getDataSourceConfig() {
|
||||
return dataSourceConfig;
|
||||
}
|
||||
|
||||
@ -21,14 +21,14 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
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")
|
||||
public class DataSourceConfig {
|
||||
|
||||
private JNDILookupDefinition jndiLookupDefintion;
|
||||
|
||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||
@XmlElement(name = "JndiLookupDefinition", required = true)
|
||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
||||
return jndiLookupDefintion;
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ public class JNDILookupDefinition {
|
||||
private String jndiName;
|
||||
private List<JNDIProperty> jndiProperties;
|
||||
|
||||
@XmlElement(name = "Name", nillable = false)
|
||||
@XmlElement(name = "Name", required = false)
|
||||
public String getJndiName() {
|
||||
return jndiName;
|
||||
}
|
||||
@ -36,7 +36,7 @@ public class JNDILookupDefinition {
|
||||
this.jndiName = jndiName;
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name = "Environment", nillable = false)
|
||||
@XmlElementWrapper(name = "Environment", required = false)
|
||||
@XmlElement(name = "Property", nillable = false)
|
||||
public List<JNDIProperty> getJndiProperties() {
|
||||
return jndiProperties;
|
||||
|
||||
@ -39,4 +39,11 @@ public interface DeviceDAO {
|
||||
Device getDeviceByDeviceId(Long deviceId) 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
|
||||
|
||||
import java.util.List;
|
||||
@ -33,8 +32,10 @@ public interface DeviceTypeDAO {
|
||||
|
||||
List<DeviceType> getDeviceTypes() throws DeviceManagementDAOException;
|
||||
|
||||
DeviceIdentifier getDeviceType() throws DeviceManagementDAOException;
|
||||
DeviceType getDeviceType(Integer id) 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.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -62,7 +63,7 @@ public class DeviceDAOImpl implements DeviceDAO {
|
||||
stmt.setLong(4, new Date().getTime());
|
||||
stmt.setString(5, device.getOwnerShip());
|
||||
stmt.setString(6, device.getStatus().toString());
|
||||
stmt.setInt(7, device.getDeviceType());
|
||||
stmt.setInt(7, device.getDeviceTypeId());
|
||||
stmt.setString(8, device.getDeviceIdentificationId());
|
||||
stmt.setString(9, device.getOwnerId());
|
||||
stmt.setInt(10, device.getTenantId());
|
||||
@ -102,6 +103,47 @@ public class DeviceDAOImpl implements DeviceDAO {
|
||||
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 {
|
||||
try {
|
||||
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.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.DeviceTypeDAO;
|
||||
import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
|
||||
@ -90,9 +89,28 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceIdentifier getDeviceType() throws DeviceManagementDAOException {
|
||||
//TODO:
|
||||
return null;
|
||||
public DeviceType getDeviceType(Integer id) throws DeviceManagementDAOException {
|
||||
Connection conn = this.getConnection();
|
||||
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
|
||||
@ -124,6 +142,11 @@ public class DeviceTypeDAOImpl implements DeviceTypeDAO {
|
||||
return deviceTypeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeDeviceType(DeviceType deviceType) throws DeviceManagementDAOException {
|
||||
|
||||
}
|
||||
|
||||
private Connection getConnection() throws DeviceManagementDAOException {
|
||||
try {
|
||||
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.LogFactory;
|
||||
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.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.internal.DeviceManagementDataHolder;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
@ -32,7 +34,9 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
|
||||
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
|
||||
* @throws DeviceManagementDAOException if an error is observed when getting tenant id
|
||||
*/
|
||||
@ -94,12 +99,50 @@ public final class DeviceManagementDAOUtil {
|
||||
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||
}
|
||||
final InitialContext context = new InitialContext(jndiProperties);
|
||||
return (DataSource) context.doLookup(dataSourceName);
|
||||
return (DataSource) context.lookup(dataSourceName);
|
||||
} catch (Exception 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
|
||||
device) throws DeviceManagementDAOException {
|
||||
Device deviceBO = new Device();
|
||||
@ -120,4 +163,10 @@ public final class DeviceManagementDAOUtil {
|
||||
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 {
|
||||
|
||||
private static final long serialVersionUID = -8101106997837486245L;
|
||||
private String id;
|
||||
private Integer id;
|
||||
private String description;
|
||||
private String name;
|
||||
private Long dateOfEnrollment;
|
||||
@ -33,21 +33,21 @@ public class Device implements Serializable {
|
||||
private String ownerId;
|
||||
private String ownerShip;
|
||||
private int tenantId;
|
||||
private Integer deviceType;
|
||||
private Integer deviceTypeId;
|
||||
|
||||
public Integer getDeviceType() {
|
||||
return deviceType;
|
||||
public Integer getDeviceTypeId() {
|
||||
return deviceTypeId;
|
||||
}
|
||||
|
||||
public void setDeviceType(Integer deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
public void setDeviceTypeId(Integer deviceTypeId) {
|
||||
this.deviceTypeId = deviceTypeId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
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.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.core.DeviceManagerImpl;
|
||||
@ -49,14 +50,17 @@ import org.wso2.carbon.user.core.service.RealmService;
|
||||
* bind="setDeviceManagerService"
|
||||
* unbind="unsetDeviceManagerService"
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class DeviceManagementServiceComponent {
|
||||
|
||||
public static final String SETUP_OPTION = "setup";
|
||||
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class);
|
||||
private DeviceManagementRepository pluginRepository = new DeviceManagementRepository();
|
||||
|
||||
protected void activate(ComponentContext componentContext) {
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing device management core bundle");
|
||||
}
|
||||
/* Initializing Device Management Configuration */
|
||||
DeviceConfigurationManager.getInstance().initConfig();
|
||||
DeviceManagementConfig config = DeviceConfigurationManager.getInstance().getDeviceManagementConfig();
|
||||
@ -68,19 +72,24 @@ public class DeviceManagementServiceComponent {
|
||||
DeviceManagementDataHolder.getInstance().setDeviceManager(deviceManager);
|
||||
|
||||
/* If -Dsetup option enabled then create device management database schema */
|
||||
String setupOption = System.getProperty(SETUP_OPTION);
|
||||
String setupOption = System.getProperty(DeviceManagementConstants.Common.PROPERTY_SETUP);
|
||||
if (setupOption != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("-Dsetup is enabled. Device management repository schema initialization is about " +
|
||||
"to begin");
|
||||
}
|
||||
setupDeviceManagementSchema(dsConfig);
|
||||
this.setupDeviceManagementSchema(dsConfig);
|
||||
}
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Registering OSGi service DeviceManagementService");
|
||||
}
|
||||
BundleContext bundleContext = componentContext.getBundleContext();
|
||||
bundleContext.registerService(DeviceManagementService.class.getName(),
|
||||
new DeviceManagementService(), null);
|
||||
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Device management core bundle has been successfully initialized");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
String msg = "Error occurred while initializing device management core bundle";
|
||||
log.error(msg, e);
|
||||
@ -91,38 +100,43 @@ public class DeviceManagementServiceComponent {
|
||||
DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
|
||||
log.info("Initializing device management repository database schema");
|
||||
|
||||
// catch generic exception. If any error occurs wrap and throw DeviceManagementException
|
||||
try {
|
||||
initializer.createRegistryDatabase();
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException("Error occurred while initializing Device Management " +
|
||||
"database schema", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets Device Manager services
|
||||
* @param deviceManager An instance of DeviceManagerService
|
||||
*/
|
||||
protected void setDeviceManagerService(DeviceManagerService deviceManager) {
|
||||
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
|
||||
* @param deviceManager An instance of DeviceManagerService
|
||||
* Sets Device Manager service.
|
||||
* @param deviceManagerService An instance of DeviceManagerService
|
||||
*/
|
||||
protected void unsetDeviceManagerService(DeviceManagerService deviceManager) {
|
||||
protected void setDeviceManagerService(DeviceManagerService deviceManagerService) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Unsetting Device Management Service");
|
||||
log.debug("Setting Device Management Service Provider : '" +
|
||||
deviceManagerService.getProviderType() + "'");
|
||||
}
|
||||
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
|
||||
*/
|
||||
protected void setRealmService(RealmService realmService) {
|
||||
@ -133,7 +147,7 @@ public class DeviceManagementServiceComponent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsets Realm Service
|
||||
* Unsets Realm Service.
|
||||
* @param realmService An instance of 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.
|
||||
*
|
||||
* @param deviceTypeName device type
|
||||
* @param deviceType device type
|
||||
* @return status of the operation
|
||||
*/
|
||||
public static boolean registerDeviceType(String deviceTypeName) throws DeviceManagementException{
|
||||
boolean status = false;
|
||||
public static boolean registerDeviceType(String deviceType) throws DeviceManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
DeviceTypeDAO deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||
Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceTypeName);
|
||||
Integer deviceTypeId = deviceTypeDAO.getDeviceTypeIdByDeviceTypeName(deviceType);
|
||||
if (deviceTypeId == null) {
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setName(deviceTypeName);
|
||||
deviceTypeDAO.addDeviceType(deviceType);
|
||||
DeviceType dt = new DeviceType();
|
||||
dt.setName(deviceType);
|
||||
deviceTypeDAO.addDeviceType(dt);
|
||||
}
|
||||
status = true;
|
||||
} 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);
|
||||
}
|
||||
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.w3c.dom.Document;
|
||||
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.TestDBConfiguration;
|
||||
import org.wso2.carbon.device.mgt.core.common.TestDBConfigurations;
|
||||
@ -40,30 +41,23 @@ import javax.xml.bind.Unmarshaller;
|
||||
import java.io.File;
|
||||
import java.sql.*;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class DeviceMgtDAOTestSuite {
|
||||
|
||||
private TestDBConfiguration testDBConfiguration;
|
||||
private DeviceType devType = new DeviceType();
|
||||
private Connection conn = null;
|
||||
private Statement stmt = null;
|
||||
public class DeviceManagementDAOTests {
|
||||
|
||||
@BeforeClass
|
||||
@Parameters("dbType")
|
||||
public void setUpDB(String dbTypeStr) throws Exception {
|
||||
|
||||
DBTypes dbType = DBTypes.valueOf(dbTypeStr);
|
||||
testDBConfiguration = getTestDBConfiguration(dbType);
|
||||
TestDBConfiguration dbConfig = getTestDBConfiguration(dbType);
|
||||
|
||||
switch (dbType) {
|
||||
case H2:
|
||||
createH2DB(testDBConfiguration);
|
||||
createH2DB(dbConfig);
|
||||
BasicDataSource testDataSource = new BasicDataSource();
|
||||
testDataSource.setDriverClassName(testDBConfiguration.getDriverClass());
|
||||
testDataSource.setUrl(testDBConfiguration.getConnectionUrl());
|
||||
testDataSource.setUsername(testDBConfiguration.getUserName());
|
||||
testDataSource.setPassword(testDBConfiguration.getPwd());
|
||||
testDataSource.setDriverClassName(dbConfig.getDriverClass());
|
||||
testDataSource.setUrl(dbConfig.getConnectionUrl());
|
||||
testDataSource.setUsername(dbConfig.getUserName());
|
||||
testDataSource.setPassword(dbConfig.getPwd());
|
||||
DeviceManagementDAOFactory.init(testDataSource);
|
||||
default:
|
||||
}
|
||||
@ -71,11 +65,9 @@ public class DeviceMgtDAOTestSuite {
|
||||
|
||||
private TestDBConfiguration getTestDBConfiguration(DBTypes dbType) throws DeviceManagementDAOException,
|
||||
DeviceManagementException {
|
||||
|
||||
File deviceMgtConfig = new File("src/test/resources/testdbconfig.xml");
|
||||
Document doc = null;
|
||||
testDBConfiguration = null;
|
||||
TestDBConfigurations testDBConfigurations = null;
|
||||
Document doc;
|
||||
TestDBConfigurations dbConfigs;
|
||||
|
||||
doc = DeviceManagerUtil.convertToDocument(deviceMgtConfig);
|
||||
JAXBContext testDBContext = null;
|
||||
@ -83,92 +75,100 @@ public class DeviceMgtDAOTestSuite {
|
||||
try {
|
||||
testDBContext = JAXBContext.newInstance(TestDBConfigurations.class);
|
||||
Unmarshaller unmarshaller = testDBContext.createUnmarshaller();
|
||||
testDBConfigurations = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
||||
dbConfigs = (TestDBConfigurations) unmarshaller.unmarshal(doc);
|
||||
} catch (JAXBException e) {
|
||||
throw new DeviceManagementDAOException("Error parsing test db configurations", e);
|
||||
}
|
||||
|
||||
Iterator<TestDBConfiguration> itrDBConfigs = testDBConfigurations.getDbTypesList().iterator();
|
||||
while (itrDBConfigs.hasNext()) {
|
||||
testDBConfiguration = itrDBConfigs.next();
|
||||
if (testDBConfiguration.getDbType().equals(dbType.toString())) {
|
||||
break;
|
||||
for (TestDBConfiguration config : dbConfigs.getDbTypesList()) {
|
||||
if (config.getDbType().equals(dbType.toString())) {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
return testDBConfiguration;
|
||||
return null;
|
||||
}
|
||||
|
||||
private void createH2DB(TestDBConfiguration testDBConf) throws Exception {
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
Class.forName(testDBConf.getDriverClass());
|
||||
conn = DriverManager.getConnection(testDBConf.getConnectionUrl());
|
||||
stmt = conn.createStatement();
|
||||
stmt.executeUpdate("RUNSCRIPT FROM './src/test/resources/sql/CreateH2TestDB.sql'");
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
||||
} finally {
|
||||
TestUtils.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addDeviceTypeTest() throws DeviceManagementDAOException, DeviceManagementException {
|
||||
|
||||
DeviceTypeDAO deviceTypeMgtDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
|
||||
|
||||
devType.setName("IOS");
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setName("IOS");
|
||||
|
||||
deviceTypeMgtDAO.addDeviceType(devType);
|
||||
deviceTypeMgtDAO.addDeviceType(deviceType);
|
||||
Long deviceTypeId = null;
|
||||
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
try {
|
||||
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
||||
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()) {
|
||||
deviceTypeId = resultSet.getLong(1);
|
||||
}
|
||||
conn.close();
|
||||
} catch (SQLException 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");
|
||||
devType.setId(deviceTypeId);
|
||||
deviceType.setId(deviceTypeId);
|
||||
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = {"addDeviceTypeTest"})
|
||||
public void addDeviceTest() throws DeviceManagementDAOException, DeviceManagementException {
|
||||
|
||||
DeviceDAO deviceMgtDAO = DeviceManagementDAOFactory.getDeviceDAO();
|
||||
|
||||
Device device = new Device();
|
||||
|
||||
device.setDateOfEnrollment(new Date().getTime());
|
||||
device.setDateOfLastUpdate(new Date().getTime());
|
||||
device.setDescription("test description");
|
||||
device.setStatus(Status.ACTIVE);
|
||||
device.setDeviceIdentificationId("111");
|
||||
device.setDeviceType(devType.getId().intValue());
|
||||
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setId(Long.parseLong("1"));
|
||||
|
||||
device.setDeviceTypeId(deviceType.getId().intValue());
|
||||
device.setOwnerShip(OwnerShip.BYOD.toString());
|
||||
device.setOwnerId("111");
|
||||
device.setTenantId(-1234);
|
||||
deviceMgtDAO.addDevice(device);
|
||||
|
||||
Long deviceId = null;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
conn = DeviceManagementDAOFactory.getDataSource().getConnection();
|
||||
stmt = conn.createStatement();
|
||||
ResultSet resultSet = stmt
|
||||
.executeQuery("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
||||
stmt = conn.prepareStatement("SELECT ID from DM_DEVICE DEVICE where DEVICE.DEVICE_IDENTIFICATION='111'");
|
||||
rs = stmt.executeQuery();
|
||||
|
||||
while (resultSet.next()) {
|
||||
deviceId = resultSet.getLong(1);
|
||||
while (rs.next()) {
|
||||
deviceId = rs.getLong(1);
|
||||
}
|
||||
conn.close();
|
||||
} catch (SQLException sqlEx) {
|
||||
throw new DeviceManagementDAOException("error in fetch device by device identification id", sqlEx);
|
||||
} catch (SQLException e) {
|
||||
throw new DeviceManagementDAOException("error in fetch device by device identification id", e);
|
||||
} finally {
|
||||
TestUtils.cleanupResources(conn, stmt, rs);
|
||||
}
|
||||
|
||||
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">
|
||||
<parameter name="dbType" value="H2"/>
|
||||
<classes>
|
||||
|
||||
<class name="org.wso2.carbon.device.mgt.core.dao.DeviceMgtDAOTestSuite"/>
|
||||
<class name="org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOTests"/>
|
||||
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementRepositoryTests"/>
|
||||
<class name="org.wso2.carbon.device.mgt.core.DeviceManagementConfigTests"/>
|
||||
</classes>
|
||||
</test>
|
||||
</suite>
|
||||
@ -52,7 +52,7 @@
|
||||
<Bundle-Name>${project.artifactId}</Bundle-Name>
|
||||
<Bundle-Version>${project.version}</Bundle-Version>
|
||||
<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>
|
||||
<Import-Package>
|
||||
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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile;
|
||||
|
||||
import org.wso2.carbon.device.mgt.common.*;
|
||||
@ -22,14 +23,14 @@ import java.util.List;
|
||||
public abstract class AbstractMobileOperationManager implements OperationManager {
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier) throws OperationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
||||
OperationManagementException {
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.FeatureProperty;
|
||||
@ -32,20 +48,20 @@ public interface FeaturePropertyDAO {
|
||||
/**
|
||||
* Delete a given feature property from feature property table.
|
||||
*
|
||||
* @param propertyId Id of the feature property to be deleted.
|
||||
* @param property Property of the feature property to be deleted.
|
||||
* @return The status of the operation. If the operationId was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given feature property from feature property table.
|
||||
*
|
||||
* @param propertyId Id of the feature property to be retrieved.
|
||||
* @param property Property of the feature property to be retrieved.
|
||||
* @return Feature property object that holds data of the feature property represented by propertyId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
FeatureProperty getFeatureProperty(int propertyId) throws MobileDeviceManagementDAOException;
|
||||
FeatureProperty getFeatureProperty(String property) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a list of feature property corresponds to a feature id .
|
||||
|
||||
@ -25,14 +25,14 @@ import java.util.List;
|
||||
*/
|
||||
public interface MobileDeviceDAO {
|
||||
|
||||
MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean addDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
boolean addMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean updateDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
boolean updateMobileDevice(MobileDevice mobileDevice) throws MobileDeviceManagementDAOException;
|
||||
|
||||
boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException;
|
||||
List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
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.dao.impl.*;
|
||||
@ -39,7 +40,7 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
||||
|
||||
}
|
||||
|
||||
public void init(){
|
||||
public void init() throws DeviceManagementException {
|
||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
||||
if (dataSource != null) {
|
||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
||||
@ -52,16 +53,16 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
||||
return new MobileDeviceDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static OperationDAO getOperationDAO(){
|
||||
return new OperationDAOImpl(dataSource);
|
||||
public static MobileOperationDAO getMobileOperationDAO() {
|
||||
return new MobileOperationDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static OperationPropertyDAO geOperationPropertyDAO(){
|
||||
return new OperationPropertyDAOImpl(dataSource);
|
||||
public static MobileOperationPropertyDAO getMobileOperationPropertyDAO() {
|
||||
return new MobileOperationPropertyDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static DeviceOperationDAO getDeviceOperationDAO(){
|
||||
return new DeviceOperationDAOImpl(dataSource);
|
||||
public static MobileDeviceOperationDAO getMobileDeviceOperationDAO() {
|
||||
return new MobileDeviceOperationDAOImpl(dataSource);
|
||||
}
|
||||
|
||||
public static FeatureDAO getFeatureDAO() {
|
||||
@ -88,9 +89,11 @@ public class MobileDeviceManagementDAOFactory implements DataSourceListener {
|
||||
|
||||
@Override
|
||||
public void notifyObserver() {
|
||||
try {
|
||||
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource(mobileDataSourceConfig);
|
||||
if(dataSource!=null){
|
||||
MobileDeviceManagementDAOUtil.createDataSource(dataSource);
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Error occurred while resolving mobile device management metadata repository data source", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,29 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the mapping between device and operations.
|
||||
*/
|
||||
public interface DeviceOperationDAO {
|
||||
public interface MobileDeviceOperationDAO {
|
||||
/**
|
||||
* Add a new mapping to plugin device_operation table.
|
||||
*
|
||||
@ -16,7 +32,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the insert was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean addDeviceOperation(DeviceOperation deviceOperation)
|
||||
boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -26,7 +42,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateDeviceOperation(DeviceOperation deviceOperation)
|
||||
boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -37,7 +53,7 @@ public interface DeviceOperationDAO {
|
||||
* @return The status of the operation. If the deletion was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteDeviceOperation(String deviceId, int operationId)
|
||||
boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -49,7 +65,7 @@ public interface DeviceOperationDAO {
|
||||
* deviceId and operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
DeviceOperation getDeviceOperation(String deviceId, int operationId)
|
||||
MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -58,6 +74,6 @@ public interface DeviceOperationDAO {
|
||||
* @return Device operation mapping object list.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
|
||||
List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation related
|
||||
* information.
|
||||
*/
|
||||
public interface MobileOperationDAO {
|
||||
|
||||
/**
|
||||
* Add a new Mobile operation to plugin operation table.
|
||||
* @param operation Operation object that holds data related to the operation to be inserted.
|
||||
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a Mobile operation in the operation table.
|
||||
* @param operation Operation object that holds data has to be updated.
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given Mobile operation from plugin database.
|
||||
* @param operationId Operation code of the operation to be deleted.
|
||||
* @return The status of the operation. If the operationId was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given Mobile operation from plugin database.
|
||||
* @param operationId Operation id of the operation to be retrieved.
|
||||
* @return Operation object that holds data of the feature represented by operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation property related
|
||||
* information.
|
||||
*/
|
||||
public interface MobileOperationPropertyDAO {
|
||||
/**
|
||||
* Add a new mapping to plugin operation property table.
|
||||
*
|
||||
* @param operationProperty OperationProperty object that holds data related to the operation
|
||||
* property to be inserted.
|
||||
* @return The status of the operation. If the insert was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a feature in the feature table.
|
||||
*
|
||||
* @param operationProperty DeviceOperation object that holds data has to be updated.
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Deletes mobile operation properties of a given operation id from the plugin database.
|
||||
*
|
||||
* @param operationId Operation id of the mapping to be deleted.
|
||||
* @return The status of the operation. If the deletion was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteMobileOperationProperties(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given mobile operation property from plugin database.
|
||||
*
|
||||
* @param operationId Operation id of the mapping to be retrieved.
|
||||
* @param property Property of the mapping to be retrieved.
|
||||
* @return DeviceOperation object that holds data of the device operation mapping represented by
|
||||
* deviceId and operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
MobileOperationProperty getMobileOperationProperty(int operationId, String property)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve all the mobile operation properties related to the a operation id.
|
||||
*
|
||||
* @param operationId Operation id of the mapping to be retrieved.
|
||||
* @return Device operation mapping object list.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -1,45 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationDAO {
|
||||
|
||||
/**
|
||||
* Add a new operation to plugin operation table.
|
||||
* @param operation Operation object that holds data related to the operation to be inserted.
|
||||
* @return The last inserted Id is returned, if the insertion was unsuccessful -1 is returned.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
int addOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a operation in the operation table.
|
||||
* @param operation Operation object that holds data has to be updated.
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given operation from plugin database.
|
||||
* @param operationId Operation code of the operation to be deleted.
|
||||
* @return The status of the operation. If the operationId was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given operation from plugin database.
|
||||
* @param operationId Operation id of the operation to be retrieved.
|
||||
* @return Operation object that holds data of the feature represented by operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
Operation getOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
@ -1,61 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation property related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationPropertyDAO {
|
||||
/**
|
||||
* Add a new mapping to plugin operation property table.
|
||||
*
|
||||
* @param operationProperty OperationProperty object that holds data related to the operation property to be inserted.
|
||||
* @return The status of the operation. If the insert was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean addOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a feature in the feature table.
|
||||
*
|
||||
* @param operationProperty DeviceOperation object that holds data has to be updated.
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given device operation from plugin database.
|
||||
*
|
||||
* @param operationPropertyId Device id of the mapping to be deleted.
|
||||
* @return The status of the operation. If the deletion was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean deleteOperationProperty(int operationPropertyId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given device operation from plugin database.
|
||||
*
|
||||
* @param deviceId Device id of the mapping to be retrieved.
|
||||
* @param operationId Operation id of the mapping to be retrieved.
|
||||
* @return DeviceOperation object that holds data of the device operation mapping represented by deviceId and operationId.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
OperationProperty getOperationProperty(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve all the device operation mapping from plugin database.
|
||||
*
|
||||
* @return Device operation mapping object list.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -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;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@ -16,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeatureDAO
|
||||
* Implementation of FeatureDAO.
|
||||
*/
|
||||
public class FeatureDAOImpl implements FeatureDAO {
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
@ -16,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeaturePropertyDAO
|
||||
* Implementation of FeaturePropertyDAO.
|
||||
*/
|
||||
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
|
||||
@ -65,18 +81,17 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String updateDBQuery =
|
||||
"UPDATE MBL_FEATURE_PROPERTY SET PROPERTY = ?, FEATURE_ID = ? WHERE PROPERTY_ID = ?";
|
||||
"UPDATE MBL_FEATURE_PROPERTY SET FEATURE_ID = ? WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
stmt.setString(1, featureProperty.getProperty());
|
||||
stmt.setString(2, featureProperty.getFeatureID());
|
||||
stmt.setInt(3, featureProperty.getPropertyId());
|
||||
stmt.setString(1, featureProperty.getFeatureID());
|
||||
stmt.setString(2, featureProperty.getProperty());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating the feature property with property id - '" +
|
||||
featureProperty.getPropertyId() + "'";
|
||||
String msg = "Error occurred while updating the feature property with property - '" +
|
||||
featureProperty.getProperty() + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -86,7 +101,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteFeatureProperty(int propertyId)
|
||||
public boolean deleteFeatureProperty(String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -94,16 +109,16 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
|
||||
"DELETE FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setInt(1, propertyId);
|
||||
stmt.setString(1, property);
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while deleting feature property with property Id - " +
|
||||
propertyId;
|
||||
String msg = "Error occurred while deleting feature property with property - " +
|
||||
property;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -113,7 +128,7 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureProperty getFeatureProperty(int propertyId)
|
||||
public FeatureProperty getFeatureProperty(String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
@ -121,9 +136,9 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY_ID = ?";
|
||||
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, propertyId);
|
||||
stmt.setString(1, property);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
featureProperty = new FeatureProperty();
|
||||
@ -132,8 +147,8 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching property Id - '" +
|
||||
propertyId + "'";
|
||||
String msg = "Error occurred while fetching property - '" +
|
||||
property + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -152,15 +167,14 @@ public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT PROPERTY_ID,PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
|
||||
"SELECT PROPERTY, FEATURE_ID FROM MBL_FEATURE_PROPERTY WHERE FEATURE_ID = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setString(1, featureId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
featureProperty = new FeatureProperty();
|
||||
featureProperty.setPropertyId(resultSet.getInt(1));
|
||||
featureProperty.setProperty(resultSet.getString(2));
|
||||
featureProperty.setFeatureID(resultSet.getString(3));
|
||||
featureProperty.setProperty(resultSet.getString(1));
|
||||
featureProperty.setFeatureID(resultSet.getString(2));
|
||||
FeatureProperties.add(featureProperty);
|
||||
}
|
||||
return FeatureProperties;
|
||||
|
||||
@ -44,7 +44,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobileDevice getDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
public MobileDevice getMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileDevice mobileDevice = null;
|
||||
@ -80,7 +80,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDevice(MobileDevice mobileDevice)
|
||||
public boolean addMobileDevice(MobileDevice mobileDevice)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -106,8 +106,8 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while enrolling mobile device '" +
|
||||
mobileDevice.getMobileDeviceId() + "'";
|
||||
String msg = "Error occurred while adding the mobile device '" +
|
||||
mobileDevice.getMobileDeviceId() + "' to the mobile db.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -117,7 +117,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDevice(MobileDevice mobileDevice)
|
||||
public boolean updateMobileDevice(MobileDevice mobileDevice)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -153,7 +153,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
public boolean deleteMobileDevice(String deviceId) throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
@ -178,7 +178,7 @@ public class MobileDeviceDAOImpl implements MobileDeviceDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobileDevice> getAllDevices() throws MobileDeviceManagementDAOException {
|
||||
public List<MobileDevice> getAllMobileDevices() throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileDevice mobileDevice;
|
||||
|
||||
@ -1,11 +1,27 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.DeviceOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@ -16,19 +32,19 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of DeviceOperationDAO
|
||||
* Implementation of MobileDeviceOperationDAO.
|
||||
*/
|
||||
public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
public class MobileDeviceOperationDAOImpl implements MobileDeviceOperationDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(DeviceOperationDAOImpl.class);
|
||||
private static final Log log = LogFactory.getLog(MobileDeviceOperationDAOImpl.class);
|
||||
|
||||
public DeviceOperationDAOImpl(DataSource dataSource) {
|
||||
public MobileDeviceOperationDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDeviceOperation(DeviceOperation deviceOperation)
|
||||
public boolean addMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -40,9 +56,9 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, deviceOperation.getDeviceId());
|
||||
stmt.setInt(2, deviceOperation.getOperationId());
|
||||
stmt.setInt(3, deviceOperation.getSentDate());
|
||||
stmt.setInt(4, deviceOperation.getReceivedDate());
|
||||
stmt.setLong(2, deviceOperation.getOperationId());
|
||||
stmt.setLong(3, deviceOperation.getSentDate());
|
||||
stmt.setLong(4, deviceOperation.getReceivedDate());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
@ -50,7 +66,8 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding device id - '" +
|
||||
deviceOperation.getDeviceId() + " and operation id - " +
|
||||
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||
deviceOperation.getOperationId() +
|
||||
" to mapping table MBL_DEVICE_OPERATION";
|
||||
;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -61,7 +78,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceOperation(DeviceOperation deviceOperation)
|
||||
public boolean updateMobileDeviceOperation(MobileDeviceOperation deviceOperation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -69,10 +86,10 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
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.setInt(1, deviceOperation.getSentDate());
|
||||
stmt.setInt(2, deviceOperation.getReceivedDate());
|
||||
stmt.setLong(1, deviceOperation.getSentDate());
|
||||
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||
stmt.setString(3, deviceOperation.getDeviceId());
|
||||
stmt.setInt(4, deviceOperation.getOperationId());
|
||||
int rows = stmt.executeUpdate();
|
||||
@ -82,7 +99,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating device id - '" +
|
||||
deviceOperation.getDeviceId() + " and operation id - " +
|
||||
deviceOperation.getOperationId() + "of mapping table MBL_DEVICE_OPERATION";
|
||||
deviceOperation.getOperationId() + " in table MBL_DEVICE_OPERATION";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -92,7 +109,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDeviceOperation(String deviceId, int operationId)
|
||||
public boolean deleteMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -100,7 +117,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||
"DELETE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
stmt.setInt(2, operationId);
|
||||
@ -110,7 +127,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while deleting mapping table MBL_DEVICE_OPERATION with device id - '" +
|
||||
"Error occurred while deleting the table entry MBL_DEVICE_OPERATION with device id - '" +
|
||||
deviceId + " and operation id - " + operationId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -121,21 +138,21 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceOperation getDeviceOperation(String deviceId, int operationId)
|
||||
public MobileDeviceOperation getMobileDeviceOperation(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
DeviceOperation deviceOperation = null;
|
||||
MobileDeviceOperation deviceOperation = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? and OPERATION_ID=?";
|
||||
"SELECT DEVICE_ID, OPERATION_ID, SENT_DATE, RECEIVED_DATE FROM MBL_DEVICE_OPERATION WHERE DEVICE_ID = ? AND OPERATION_ID=?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
stmt.setInt(2, operationId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
deviceOperation = new DeviceOperation();
|
||||
deviceOperation = new MobileDeviceOperation();
|
||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
||||
@ -144,7 +161,7 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||
"Error occurred while fetching table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||
deviceId + " and operation id - " + operationId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -155,12 +172,12 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceOperation> getAllDeviceOperationOfDevice(String deviceId)
|
||||
public List<MobileDeviceOperation> getAllMobileDeviceOperationsOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
DeviceOperation deviceOperation = null;
|
||||
List<DeviceOperation> deviceOperations = new ArrayList<DeviceOperation>();
|
||||
MobileDeviceOperation deviceOperation = null;
|
||||
List<MobileDeviceOperation> deviceOperations = new ArrayList<MobileDeviceOperation>();
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
@ -169,17 +186,16 @@ public class DeviceOperationDAOImpl implements DeviceOperationDAO {
|
||||
stmt.setString(1, deviceId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
deviceOperation = new DeviceOperation();
|
||||
deviceOperation = new MobileDeviceOperation();
|
||||
deviceOperation.setDeviceId(resultSet.getString(1));
|
||||
deviceOperation.setOperationId(resultSet.getInt(2));
|
||||
deviceOperation.setSentDate(resultSet.getInt(3));
|
||||
deviceOperation.setReceivedDate(resultSet.getInt(4));
|
||||
deviceOperations.add(deviceOperation);
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entry with device id - '" +
|
||||
"Error occurred while fetching mapping table MBL_DEVICE_OPERATION entries of device id - '" +
|
||||
deviceId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -1,11 +1,27 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.OperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
@ -14,19 +30,19 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
/**
|
||||
* Implementation of OperationDAO
|
||||
* Implementation of MobileOperationDAO.
|
||||
*/
|
||||
public class OperationDAOImpl implements OperationDAO {
|
||||
public class MobileOperationDAOImpl implements MobileOperationDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(OperationDAOImpl.class);
|
||||
private static final Log log = LogFactory.getLog(MobileOperationDAOImpl.class);
|
||||
|
||||
public OperationDAOImpl(DataSource dataSource) {
|
||||
public MobileOperationDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addOperation(Operation operation)
|
||||
public int addMobileOperation(MobileOperation operation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
int status = -1;
|
||||
Connection conn = null;
|
||||
@ -35,10 +51,9 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION(FEATURE_CODE, CREATED_DATE) VALUES ( ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery, new String[] { "OPERATION_ID" });
|
||||
stmt.setString(1, operation.getFeatureCode());
|
||||
stmt.setInt(2, operation.getCreatedDate());
|
||||
stmt.setLong(2, operation.getCreatedDate());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
ResultSet rs = stmt.getGeneratedKeys();
|
||||
@ -47,8 +62,8 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding feature code - '" +
|
||||
operation.getFeatureCode() + "' to operations table";
|
||||
String msg = "Error occurred while adding the operation - '" +
|
||||
operation.getFeatureCode() + "' to MBL_OPERATION table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -58,7 +73,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateOperation(Operation operation)
|
||||
public boolean updateMobileOperation(MobileOperation operation)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -69,14 +84,14 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
"UPDATE MBL_OPERATION SET FEATURE_CODE = ?, CREATED_DATE = ? WHERE OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
stmt.setString(1, operation.getFeatureCode());
|
||||
stmt.setInt(2, operation.getCreatedDate());
|
||||
stmt.setLong(2, operation.getCreatedDate());
|
||||
stmt.setInt(3, operation.getOperationId());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while updating the operation with operation id - '" +
|
||||
String msg = "Error occurred while updating the MBL_OPERATION table entry with operation id - '" +
|
||||
operation.getOperationId() + "'";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
@ -87,7 +102,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteOperation(int operationId)
|
||||
public boolean deleteMobileOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
@ -103,7 +118,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while deleting operation with operation Id - ";
|
||||
String msg = "Error occurred while deleting MBL_OPERATION entry with operation Id - ";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -113,11 +128,11 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Operation getOperation(int operationId)
|
||||
public MobileOperation getMobileOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
Operation operation = null;
|
||||
MobileOperation operation = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
@ -126,13 +141,13 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
stmt.setInt(1, operation.getOperationId());
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
operation = new Operation();
|
||||
operation = new MobileOperation();
|
||||
operation.setOperationId(resultSet.getInt(1));
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching operationId - '" +
|
||||
operationId + "'";
|
||||
operationId + "' from MBL_OPERATION";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
@ -0,0 +1,212 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileOperationPropertyDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of MobileOperationPropertyDAO.
|
||||
*/
|
||||
public class MobileOperationPropertyDAOImpl implements MobileOperationPropertyDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(MobileOperationPropertyDAOImpl.class);
|
||||
|
||||
public MobileOperationPropertyDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY, VALUE) VALUES ( ?, ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setInt(1, operationProperty.getOperationId());
|
||||
stmt.setString(2, operationProperty.getProperty());
|
||||
stmt.setString(3, operationProperty.getValue());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while adding mobile operation property to MBL_OPERATION_PROPERTY table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateMobileOperationProperty(
|
||||
MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"UPDATE MBL_OPERATION_PROPERTY SET VALUE = ? WHERE OPERATION_ID = ? AND PROPERTY = ?";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, operationProperty.getValue());
|
||||
stmt.setInt(2, operationProperty.getOperationId());
|
||||
stmt.setString(3, operationProperty.getProperty());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while updating the mobile operation property in MBL_OPERATION_PROPERTY table.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteMobileOperationProperties(int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while deleting MBL_OPERATION_PROPERTY entry with operation Id - ";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MobileOperationProperty getMobileOperationProperty(int operationId,
|
||||
String property)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileOperationProperty mobileOperationProperty = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ? AND PROPERTY = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
stmt.setString(2, property);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
mobileOperationProperty = new MobileOperationProperty();
|
||||
mobileOperationProperty.setOperationId(resultSet.getInt(1));
|
||||
mobileOperationProperty.setProperty(resultSet.getString(2));
|
||||
mobileOperationProperty.setValue(resultSet.getString(3));
|
||||
break;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching the mobile operation property of Operation_id : " +
|
||||
operationId + " and Property : " + property;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return mobileOperationProperty;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(
|
||||
int operationId) throws MobileDeviceManagementDAOException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
MobileOperationProperty mobileOperationProperty = null;
|
||||
List<MobileOperationProperty> properties = new ArrayList<MobileOperationProperty>();
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT OPERATION_ID, PROPERTY, VALUE FROM MBL_OPERATION_PROPERTY WHERE OPERATION_ID = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setInt(1, operationId);
|
||||
ResultSet resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
mobileOperationProperty = new MobileOperationProperty();
|
||||
mobileOperationProperty.setOperationId(resultSet.getInt(1));
|
||||
mobileOperationProperty.setProperty(resultSet.getString(2));
|
||||
mobileOperationProperty.setValue(resultSet.getString(3));
|
||||
properties.add(mobileOperationProperty);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg =
|
||||
"Error occurred while fetching the mobile operation properties of Operation_id " +
|
||||
operationId;
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||
try {
|
||||
return dataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
||||
"management metadata repository datasource.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,87 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.OperationPropertyDAO;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of OperationPropertyDAO
|
||||
*/
|
||||
public class OperationPropertyDAOImpl implements OperationPropertyDAO {
|
||||
|
||||
private DataSource dataSource;
|
||||
private static final Log log = LogFactory.getLog(OperationPropertyDAOImpl.class);
|
||||
|
||||
public OperationPropertyDAOImpl(DataSource dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = this.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO MBL_OPERATION_PROPERTY(OPERATION_ID, PROPERTY_ID, VALUE) VALUES ( ?, ?, ?)";
|
||||
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setInt(1, operationProperty.getOperationId());
|
||||
stmt.setInt(2, operationProperty.getPropertyId());
|
||||
stmt.setString(3, operationProperty.getValue());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding feature property to operation property table";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
} finally {
|
||||
MobileDeviceManagementDAOUtil.cleanupResources(conn, stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override public boolean updateOperationProperty(OperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean deleteOperationProperty(int operationPropertyId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public OperationProperty getOperationProperty(String deviceId, int operationId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public List<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
|
||||
throws MobileDeviceManagementDAOException {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Connection getConnection() throws MobileDeviceManagementDAOException {
|
||||
try {
|
||||
return dataSource.getConnection();
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while obtaining a connection from the mobile device " +
|
||||
"management metadata repository datasource.";
|
||||
log.error(msg, e);
|
||||
throw new MobileDeviceManagementDAOException(msg, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -45,7 +45,7 @@ public class MobileDeviceManagementDAOUtil {
|
||||
* @param config Mobile data source configuration
|
||||
* @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;
|
||||
if (config == null) {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
@ -64,25 +64,10 @@ public class MobileDeviceManagementDAOUtil {
|
||||
for (JNDILookupDefinition.JNDIProperty prop : jndiPropertyList) {
|
||||
jndiProperties.put(prop.getName(), prop.getValue());
|
||||
}
|
||||
try {
|
||||
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(
|
||||
jndiConfig.getJndiName(), jndiProperties);
|
||||
} catch (DeviceManagementException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Error in looking up data source: " + e.getMessage());
|
||||
}
|
||||
log.error(e);
|
||||
}
|
||||
dataSource =
|
||||
MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), jndiProperties);
|
||||
} else {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
dataSource = MobileDeviceManagementDAOUtil.lookupDataSource(jndiConfig.getJndiName(), null);
|
||||
}
|
||||
}
|
||||
return dataSource;
|
||||
@ -96,10 +81,11 @@ public class MobileDeviceManagementDAOUtil {
|
||||
return (DataSource) InitialContext.doLookup(dataSourceName);
|
||||
}
|
||||
final InitialContext context = new InitialContext(jndiProperties);
|
||||
return (DataSource) context.doLookup(dataSourceName);
|
||||
return (DataSource) context.lookup(dataSourceName);
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException(
|
||||
"Error in looking up data source: " + e.getMessage(), e);
|
||||
String msg = "Error in looking up data source: " + e.getMessage();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,9 +129,7 @@ public class MobileDeviceManagementDAOUtil {
|
||||
try {
|
||||
MobileDeviceManagementDAOUtil.setupMobileDeviceManagementSchema(dataSource);
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error(
|
||||
"Exception occurred while initializing mobile device management database schema",
|
||||
e);
|
||||
log.error("Exception occurred while initializing mobile device management database schema", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,8 +147,7 @@ public class MobileDeviceManagementDAOUtil {
|
||||
try {
|
||||
initializer.createRegistryDatabase();
|
||||
} catch (Exception e) {
|
||||
throw new DeviceManagementException(
|
||||
"Error occurred while initializing Mobile Device Management " +
|
||||
throw new DeviceManagementException("Error occurred while initializing Mobile Device Management " +
|
||||
"database schema", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,44 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of Operations.
|
||||
*/
|
||||
public class DeviceOperation {
|
||||
String deviceId;
|
||||
int operationId;
|
||||
int sentDate;
|
||||
int receivedDate;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public int getSentDate() {
|
||||
return sentDate;
|
||||
}
|
||||
|
||||
public void setSentDate(int sentDate) {
|
||||
this.sentDate = sentDate;
|
||||
}
|
||||
|
||||
public int getReceivedDate() {
|
||||
return receivedDate;
|
||||
}
|
||||
|
||||
public void setReceivedDate(int 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -6,10 +22,11 @@ import java.io.Serializable;
|
||||
* DTO of features.
|
||||
*/
|
||||
public class Feature implements Serializable {
|
||||
int id;
|
||||
String code;
|
||||
String name;
|
||||
String description;
|
||||
|
||||
private int id;
|
||||
private String code;
|
||||
private String name;
|
||||
private String description;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
||||
@ -1,12 +1,28 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* DTO of feature property. Represents a property of a feature.
|
||||
*/
|
||||
public class FeatureProperty {
|
||||
int propertyId;
|
||||
String property;
|
||||
String featureID;
|
||||
|
||||
private String property;
|
||||
private String featureID;
|
||||
|
||||
public String getFeatureID() {
|
||||
return featureID;
|
||||
@ -16,14 +32,6 @@ public class FeatureProperty {
|
||||
this.featureID = featureID;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
public void setPropertyId(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* DTO of Mobile Device Operations.
|
||||
*/
|
||||
public class MobileDeviceOperation {
|
||||
|
||||
private String deviceId;
|
||||
private int operationId;
|
||||
private long sentDate;
|
||||
private long receivedDate;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public long getSentDate() {
|
||||
return sentDate;
|
||||
}
|
||||
|
||||
public void setSentDate(long sentDate) {
|
||||
this.sentDate = sentDate;
|
||||
}
|
||||
|
||||
public long getReceivedDate() {
|
||||
return receivedDate;
|
||||
}
|
||||
|
||||
public void setReceivedDate(long receivedDate) {
|
||||
this.receivedDate = receivedDate;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DTO of MobileOperation.
|
||||
*/
|
||||
public class MobileOperation {
|
||||
|
||||
private int operationId;
|
||||
private String featureCode;
|
||||
private long createdDate;
|
||||
private List<MobileOperationProperty> properties;
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public List<MobileOperationProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<MobileOperationProperty> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public String getFeatureCode() {
|
||||
return featureCode;
|
||||
}
|
||||
|
||||
public void setFeatureCode(String featureCode) {
|
||||
this.featureCode = featureCode;
|
||||
}
|
||||
|
||||
public long getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setCreatedDate(long createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* DTO of Mobile Operation property.
|
||||
*/
|
||||
public class MobileOperationProperty {
|
||||
|
||||
private int operationId;
|
||||
private String property;
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,36 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of operation.
|
||||
*/
|
||||
public class Operation {
|
||||
int operationId;
|
||||
String featureCode;
|
||||
int createdDate;
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int operationId) {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public String getFeatureCode() {
|
||||
return featureCode;
|
||||
}
|
||||
|
||||
public void setFeatureCode(String featureCode) {
|
||||
this.featureCode = featureCode;
|
||||
}
|
||||
|
||||
public int getCreatedDate() {
|
||||
return createdDate;
|
||||
}
|
||||
|
||||
public void setCreatedDate(int createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,44 +0,0 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of operation property.
|
||||
*/
|
||||
public class OperationProperty {
|
||||
int operationPropertyId;
|
||||
int getOperationId;
|
||||
int propertyId;
|
||||
String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getOperationPropertyId() {
|
||||
return operationPropertyId;
|
||||
}
|
||||
|
||||
public void setOperationPropertyId(int operationPropertyId) {
|
||||
this.operationPropertyId = operationPropertyId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return getOperationId;
|
||||
}
|
||||
|
||||
public void setOperationId(int getOperationId) {
|
||||
this.getOperationId = getOperationId;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
public void setPropertyId(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
}
|
||||
@ -47,10 +47,11 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
@Override
|
||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||
boolean status = false;
|
||||
boolean status;
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addDevice(mobileDevice);
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().addMobileDevice(
|
||||
mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while enrolling the Android device : " +
|
||||
device.getDeviceIdentifier();
|
||||
@ -62,11 +63,11 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
@Override
|
||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||
boolean status = false;
|
||||
boolean status;
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.updateDevice(mobileDevice);
|
||||
.updateMobileDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while updating the enrollment of the Android device : " +
|
||||
device.getDeviceIdentifier();
|
||||
@ -78,10 +79,10 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
@Override
|
||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
boolean status = false;
|
||||
boolean status;
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.deleteDevice(deviceId.getId());
|
||||
.deleteMobileDevice(deviceId.getId());
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while removing the Android device : " + deviceId.getId();
|
||||
log.error(msg, e);
|
||||
@ -95,7 +96,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
boolean isEnrolled = false;
|
||||
try {
|
||||
MobileDevice mobileDevice =
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getDevice(
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().getMobileDevice(
|
||||
deviceId.getId());
|
||||
if (mobileDevice != null) {
|
||||
isEnrolled = true;
|
||||
@ -122,10 +123,10 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
Device device = null;
|
||||
Device device;
|
||||
try {
|
||||
MobileDevice mobileDevice = MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||
getDevice(deviceId.getId());
|
||||
getMobileDevice(deviceId.getId());
|
||||
device = MobileDeviceManagementUtil.convertToDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg = "Error while fetching the Android device : " + deviceId.getId();
|
||||
@ -143,14 +144,13 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
|
||||
boolean status = false;
|
||||
boolean status;
|
||||
MobileDevice mobileDevice = MobileDeviceManagementUtil.convertToMobileDevice(device);
|
||||
try {
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceDAO()
|
||||
.updateDevice(mobileDevice);
|
||||
.updateMobileDevice(mobileDevice);
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg =
|
||||
"Error while updating the Android device : " + device.getDeviceIdentifier();
|
||||
String msg = "Error while updating the Android device : " + device.getDeviceIdentifier();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
@ -163,11 +163,11 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
try {
|
||||
List<MobileDevice> mobileDevices =
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||
getAllDevices();
|
||||
getAllMobileDevices();
|
||||
if (mobileDevices != null) {
|
||||
devices = new ArrayList<Device>();
|
||||
for (int x = 0; x < mobileDevices.size(); x++) {
|
||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevices.get(x)));
|
||||
for (MobileDevice mobileDevice : mobileDevices) {
|
||||
devices.add(MobileDeviceManagementUtil.convertToDevice(mobileDevice));
|
||||
}
|
||||
}
|
||||
} 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");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -15,25 +15,90 @@
|
||||
*/
|
||||
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.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.OperationManagementException;
|
||||
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.MobileDeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
import org.wso2.carbon.device.mgt.mobile.util.MobileDeviceManagementUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class AndroidMobileOperationManager extends AbstractMobileOperationManager {
|
||||
|
||||
private static final Log log = LogFactory.getLog(AndroidMobileOperationManager.class);
|
||||
|
||||
@Override
|
||||
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
||||
OperationManagementException {
|
||||
return false;
|
||||
boolean status = false;
|
||||
try {
|
||||
MobileDeviceOperation mobileDeviceOperation = null;
|
||||
MobileOperation mobileOperation =
|
||||
MobileDeviceManagementUtil.convertToMobileOperation(operation);
|
||||
int operationId = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||
.addMobileOperation(mobileOperation);
|
||||
if (operationId > 0) {
|
||||
for (MobileOperationProperty operationProperty : mobileOperation.getProperties()) {
|
||||
operationProperty.setOperationId(operationId);
|
||||
status = MobileDeviceManagementDAOFactory.getMobileOperationPropertyDAO()
|
||||
.addMobileOperationProperty(
|
||||
operationProperty);
|
||||
}
|
||||
for (DeviceIdentifier deviceIdentifier : devices) {
|
||||
mobileDeviceOperation = new MobileDeviceOperation();
|
||||
mobileDeviceOperation.setOperationId(operationId);
|
||||
mobileDeviceOperation.setDeviceId(deviceIdentifier.getId());
|
||||
status = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||
.addMobileDeviceOperation(
|
||||
new MobileDeviceOperation());
|
||||
}
|
||||
}
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg =
|
||||
"Error while adding an operation " + operation.getCode() + "to Android devices";
|
||||
log.error(msg, e);
|
||||
throw new OperationManagementException(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Operation> getOperations(DeviceIdentifier deviceIdentifier)
|
||||
throws OperationManagementException {
|
||||
return null;
|
||||
List<Operation> operations = new ArrayList<Operation>();
|
||||
List<MobileDeviceOperation> mobileDeviceOperations = null;
|
||||
MobileOperation mobileOperation = null;
|
||||
try {
|
||||
mobileDeviceOperations = MobileDeviceManagementDAOFactory.getMobileDeviceOperationDAO()
|
||||
.getAllMobileDeviceOperationsOfDevice(
|
||||
deviceIdentifier
|
||||
.getId());
|
||||
if (mobileDeviceOperations.size() > 0) {
|
||||
List<Integer> operationIds = MobileDeviceManagementUtil
|
||||
.getMobileOperationIdsFromMobileDeviceOperations(mobileDeviceOperations);
|
||||
for (Integer operationId : operationIds) {
|
||||
mobileOperation = MobileDeviceManagementDAOFactory.getMobileOperationDAO()
|
||||
.getMobileOperation(
|
||||
operationId);
|
||||
operations.add(MobileDeviceManagementUtil
|
||||
.convertMobileOperationToOperation(mobileOperation));
|
||||
}
|
||||
}
|
||||
} catch (MobileDeviceManagementDAOException e) {
|
||||
String msg =
|
||||
"Error while fetching the operations for the android device " +
|
||||
deviceIdentifier.getId();
|
||||
log.error(msg, e);
|
||||
throw new OperationManagementException(msg, e);
|
||||
}
|
||||
return operations;
|
||||
}
|
||||
|
||||
}
|
||||
@ -88,5 +88,4 @@ public class IOSDeviceManagerService implements DeviceManagerService {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
||||
services */
|
||||
this.removeAPIs();
|
||||
} 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
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,13 +21,16 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDevice;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileDeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Provides utility methods required by the mobile device management bundle.
|
||||
@ -112,4 +115,42 @@ public class MobileDeviceManagementUtil {
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
public static MobileOperation convertToMobileOperation(
|
||||
org.wso2.carbon.device.mgt.common.Operation operation) {
|
||||
MobileOperation mobileOperation = new MobileOperation();
|
||||
MobileOperationProperty operationProperty = null;
|
||||
List<MobileOperationProperty> properties = new LinkedList<MobileOperationProperty>();
|
||||
mobileOperation.setFeatureCode(operation.getCode());
|
||||
mobileOperation.setCreatedDate(new Date().getTime());
|
||||
Properties operationProperties = operation.getProperties();
|
||||
for (String key : operationProperties.stringPropertyNames()) {
|
||||
operationProperty = new MobileOperationProperty();
|
||||
operationProperty.setProperty(key);
|
||||
operationProperty.setValue(operationProperties.getProperty(key));
|
||||
properties.add(operationProperty);
|
||||
}
|
||||
mobileOperation.setProperties(properties);
|
||||
return mobileOperation;
|
||||
}
|
||||
|
||||
public static List<Integer> getMobileOperationIdsFromMobileDeviceOperations(
|
||||
List<MobileDeviceOperation> mobileDeviceOperations) {
|
||||
List<Integer> mobileOperationIds = new ArrayList<Integer>();
|
||||
for(MobileDeviceOperation mobileDeviceOperation:mobileDeviceOperations){
|
||||
mobileOperationIds.add(mobileDeviceOperation.getOperationId());
|
||||
}
|
||||
return mobileOperationIds;
|
||||
}
|
||||
|
||||
public static Operation convertMobileOperationToOperation(MobileOperation mobileOperation){
|
||||
Operation operation = new Operation();
|
||||
Properties properties = new Properties();
|
||||
operation.setCode(mobileOperation.getFeatureCode());
|
||||
for(MobileOperationProperty mobileOperationProperty:mobileOperation.getProperties()){
|
||||
properties.put(mobileOperationProperty.getProperty(),mobileOperationProperty.getValue());
|
||||
}
|
||||
operation.setProperties(properties);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ 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.
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
@ -78,6 +78,10 @@
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.policy.mgt.common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FeatureFilter {
|
||||
|
||||
List<Feature> evaluate(List<Policy> policyList, List<FeatureRules> featureRulesList);
|
||||
|
||||
List<Feature> extractFeatures(List<Policy> policyList);
|
||||
|
||||
List<Feature> evaluateFeatures(List<Feature> featureList, List<FeatureRules> featureRulesList);
|
||||
|
||||
void getDenyOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getPermitOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getFirstApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getLastApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getAllApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getHighestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
|
||||
void getLowestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList);
|
||||
}
|
||||
@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
import org.wso2.carbon.policy.evaluator.utils.Constants;
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This class is responsible for evaluating the policy (Configurations sets) and returning
|
||||
* the effective features set.
|
||||
*/
|
||||
|
||||
public class FeatureFilterImpl implements FeatureFilter {
|
||||
|
||||
/**
|
||||
* This method returns the effective feature list when policy list and feature aggregation rules are supplied.
|
||||
* @param policyList
|
||||
* @param featureRulesList
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Feature> evaluate(List<Policy> policyList, List<FeatureRules> featureRulesList) {
|
||||
return evaluateFeatures(extractFeatures(policyList), featureRulesList);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method extract the features from the given policy list in the order they are provided in the list.
|
||||
* @param policyList
|
||||
* @return
|
||||
*/
|
||||
public List<Feature> extractFeatures(List<Policy> policyList) {
|
||||
List<Feature> featureList = new ArrayList<Feature>();
|
||||
for (Policy policy : policyList) {
|
||||
featureList.addAll(policy.getFeaturesList());
|
||||
}
|
||||
return featureList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is responsible for supplying tasks to other methods to evaluate given features.
|
||||
* @param featureList
|
||||
* @param featureRulesList
|
||||
* @return
|
||||
*/
|
||||
public List<Feature> evaluateFeatures(List<Feature> featureList, List<FeatureRules> featureRulesList) {
|
||||
List<Feature> effectiveFeatureList = new ArrayList<Feature>();
|
||||
for (FeatureRules rule : featureRulesList) {
|
||||
String ruleName = rule.getEvaluationCriteria();
|
||||
String featureName = rule.getName();
|
||||
if (ruleName.equalsIgnoreCase(Constants.DENY_OVERRIDES)) {
|
||||
getDenyOverridesFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.PERMIT_OVERRIDES)) {
|
||||
getPermitOverridesFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.FIRST_APPLICABLE)) {
|
||||
getFirstApplicableFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.LAST_APPLICABLE)) {
|
||||
getLastApplicableFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.ALL_APPLICABLE)) {
|
||||
getAllApplicableFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.HIGHEST_APPLICABLE)) {
|
||||
getHighestApplicableFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
if (ruleName.equalsIgnoreCase(Constants.LOWEST_APPLICABLE)) {
|
||||
getLowestApplicableFeatures(featureName, featureList, effectiveFeatureList);
|
||||
}
|
||||
}
|
||||
return effectiveFeatureList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks up denied features, if there is no denied features it will add to the list, the final permitted feature.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getDenyOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
Feature evaluatedFeature = null;
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
if (feature.getRuleValue().equalsIgnoreCase("Deny")) {
|
||||
evaluatedFeature = feature;
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
return;
|
||||
} else {
|
||||
evaluatedFeature = feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (evaluatedFeature != null) {
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks up permitted features, if there is no permitted features it will add to the list, the final denied feature.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getPermitOverridesFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
Feature evaluatedFeature = null;
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
if (feature.getRuleValue().equalsIgnoreCase("Permit")) {
|
||||
evaluatedFeature = feature;
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
return;
|
||||
} else {
|
||||
evaluatedFeature = feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (evaluatedFeature != null) {
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks the first features of the give type.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getFirstApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
effectiveFeatureList.add(feature);
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks the last features of the give type.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getLastApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
Feature evaluatedFeature = null;
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
evaluatedFeature = feature;
|
||||
}
|
||||
}
|
||||
if (evaluatedFeature != null) {
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks the all features of the give type.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getAllApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
effectiveFeatureList.add(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks the feature with the highest value of given type.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getHighestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
Feature evaluatedFeature = null;
|
||||
int intValve = 0;
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
if (Integer.parseInt(feature.getRuleValue()) > intValve) {
|
||||
intValve = Integer.parseInt(feature.getRuleValue());
|
||||
evaluatedFeature = feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (evaluatedFeature != null) {
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method picks the feature with the lowest value of given type.
|
||||
* But if given policies do not have features of given type, it will not add anything.
|
||||
*
|
||||
* @param featureName
|
||||
* @param featureList
|
||||
* @param effectiveFeatureList
|
||||
*/
|
||||
public void getLowestApplicableFeatures(String featureName, List<Feature> featureList, List<Feature> effectiveFeatureList) {
|
||||
Feature evaluatedFeature = null;
|
||||
int intValve = 0;
|
||||
for (Feature feature : featureList) {
|
||||
if (feature.getName().equalsIgnoreCase(featureName)) {
|
||||
if (Integer.parseInt(feature.getRuleValue()) < intValve) {
|
||||
intValve = Integer.parseInt(feature.getRuleValue());
|
||||
evaluatedFeature = feature;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (evaluatedFeature != null) {
|
||||
effectiveFeatureList.add(evaluatedFeature);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
public class FeatureRules {
|
||||
|
||||
private String name;
|
||||
private String evaluationCriteria;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getEvaluationCriteria() {
|
||||
return evaluationCriteria;
|
||||
}
|
||||
|
||||
public void setEvaluationCriteria(String evaluationCriteria) {
|
||||
this.evaluationCriteria = evaluationCriteria;
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.evaluator;
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
import org.wso2.carbon.policy.evaluator.spi.PDPService;
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PDPServiceImpl implements PDPService {
|
||||
@Override
|
||||
public List<Policy> getEffectivePolicyList(List<Policy> policies, List<String> roles, String deviceType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Feature> getEffectiveFeatureList(List<Policy> policies, List<FeatureRules> featureRulesList) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PolicyFilter {
|
||||
|
||||
/**
|
||||
* This method will extract the policies related a given roles list from the policy list available.
|
||||
* @param policyList
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
public List<Policy> extractPoliciesRelatedToRoles(List<Policy> policyList, List<String> roles);
|
||||
|
||||
/**
|
||||
* This mehtod extract the policies related to a given device type from policy list.
|
||||
* @param policyList
|
||||
* @param deviceType
|
||||
* @return
|
||||
*/
|
||||
public List<Policy> extractPoliciesRelatedToDeviceType(List<Policy> policyList, String deviceType);
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.evaluator;
|
||||
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class PolicyFilterImpl implements PolicyFilter {
|
||||
|
||||
|
||||
/**
|
||||
* This method will extract the policies related a given roles list from the policy list available.
|
||||
*
|
||||
* @param policyList
|
||||
* @param roles
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Policy> extractPoliciesRelatedToRoles(List<Policy> policyList, List<String> roles) {
|
||||
|
||||
List<Policy> policies = new ArrayList<Policy>();
|
||||
|
||||
for (Policy policy : policyList) {
|
||||
List<String> roleList = policy.getRoleList();
|
||||
|
||||
for (String role : roleList) {
|
||||
if (roles.contains(role)) {
|
||||
policies.add(policy);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return policies;
|
||||
}
|
||||
|
||||
/**
|
||||
* This mehtod extract the policies related to a given device type from policy list.
|
||||
*
|
||||
* @param policyList
|
||||
* @param deviceType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Policy> extractPoliciesRelatedToDeviceType(List<Policy> policyList, String deviceType) {
|
||||
List<Policy> policies = new ArrayList<Policy>();
|
||||
|
||||
for (Policy policy : policyList) {
|
||||
if (policy.getDeviceType().equalsIgnoreCase(deviceType)) {
|
||||
policies.add(policy);
|
||||
}
|
||||
}
|
||||
return policies;
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,16 @@
|
||||
package org.wso2.carbon.policy.evaluator.spi;
|
||||
|
||||
|
||||
import org.wso2.carbon.policy.evaluator.FeatureRules;
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.Policy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PDPService {
|
||||
|
||||
List<Policy> getEffectivePolicyList(List<Policy> policies, List<String> roles, String deviceType);
|
||||
|
||||
List<Feature> getEffectiveFeatureList(List<Policy> policies, List<FeatureRules> featureRulesList);
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (c) 2015 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.evaluator.utils;
|
||||
|
||||
public class Constants {
|
||||
|
||||
public static final String DENY_OVERRIDES="deny_overrides";
|
||||
public static final String PERMIT_OVERRIDES="permit_overrides";
|
||||
public static final String FIRST_APPLICABLE="first_applicable";
|
||||
public static final String LAST_APPLICABLE="last_applicable";
|
||||
public static final String ALL_APPLICABLE="all_applicable";
|
||||
public static final String HIGHEST_APPLICABLE="highest_applicable";
|
||||
public static final String LOWEST_APPLICABLE="lowest_applicable";
|
||||
}
|
||||
@ -1,21 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ 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.
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
|
||||
@ -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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.common;
|
||||
@ -24,6 +22,15 @@ public class Feature {
|
||||
private String code;
|
||||
private String name;
|
||||
private Object attribute;
|
||||
private String ruleValue;
|
||||
|
||||
public String getRuleValue() {
|
||||
return ruleValue;
|
||||
}
|
||||
|
||||
public void setRuleValue(String ruleValue) {
|
||||
this.ruleValue = ruleValue;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.common;
|
||||
|
||||
import org.wso2.carbon.policy.mgt.common.Feature;
|
||||
import org.wso2.carbon.policy.mgt.common.FeatureManagementException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FeatureManagerService {
|
||||
|
||||
@ -1,19 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.policy.mgt.common;
|
||||
@ -25,6 +23,33 @@ public class Policy {
|
||||
private String policyName;
|
||||
private List<Feature> featuresList;
|
||||
private boolean generic;
|
||||
private List<String> roleList;
|
||||
private List<String> DeviceList;
|
||||
private String deviceType;
|
||||
|
||||
public List<String> getRoleList() {
|
||||
return roleList;
|
||||
}
|
||||
|
||||
public void setRoleList(List<String> roleList) {
|
||||
this.roleList = roleList;
|
||||
}
|
||||
|
||||
public List<String> getDeviceList() {
|
||||
return DeviceList;
|
||||
}
|
||||
|
||||
public void setDeviceList(List<String> deviceList) {
|
||||
DeviceList = deviceList;
|
||||
}
|
||||
|
||||
public String getDeviceType() {
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceType(String deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public boolean isGeneric() {
|
||||
return generic;
|
||||
|
||||
@ -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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.common;
|
||||
|
||||
@ -1,27 +1,21 @@
|
||||
/*
|
||||
* 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.
|
||||
* 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.
|
||||
* 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.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
|
||||
*/
|
||||
|
||||
@ -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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.wos2.carbon.policy.mgt.common;
|
||||
@ -36,7 +34,6 @@ public class PolicyManagementTestCase {
|
||||
|
||||
private PolicyManagement policyManagement = new PolicyManagement();
|
||||
|
||||
|
||||
@Test(groups = "policy.mgt.test", description = "Testing the adding policy to a device")
|
||||
public void testAddPolicy() throws FeatureManagementException, PolicyManagementException {
|
||||
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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.wos2.carbon.policy.mgt.common.utils;
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ 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.
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* 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.policy.mgt.core.config;
|
||||
|
||||
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.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* 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.policy.mgt.core.config.datasource;
|
||||
@ -24,15 +25,14 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
@XmlRootElement(name = "DataSourceConfiguration")
|
||||
public class DataSourceConfig {
|
||||
|
||||
private JNDILookupDefinition jndiLookupDefintion;
|
||||
private JNDILookupDefinition jndiLookupDefinition;
|
||||
|
||||
@XmlElement(name = "JndiLookupDefinition", nillable = true)
|
||||
public JNDILookupDefinition getJndiLookupDefintion() {
|
||||
return jndiLookupDefintion;
|
||||
public JNDILookupDefinition getJndiLookupDefinition() {
|
||||
return jndiLookupDefinition;
|
||||
}
|
||||
|
||||
public void setJndiLookupDefintion(JNDILookupDefinition jndiLookupDefintion) {
|
||||
this.jndiLookupDefintion = jndiLookupDefintion;
|
||||
public void setJndiLookupDefinition(JNDILookupDefinition jndiLookupDefinition) {
|
||||
this.jndiLookupDefinition = jndiLookupDefinition;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,16 +1,17 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.core.dao;
|
||||
@ -55,7 +53,7 @@ public class PolicyManagementDAOFactory {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.core.dao.impl;
|
||||
|
||||
@ -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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.core.internal;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.policy.mgt.core.internal;
|
||||
|
||||
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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.core.util;
|
||||
|
||||
public final class PolicyManagementConstants {
|
||||
|
||||
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,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with 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 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.
|
||||
* 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.policy.mgt.core.util;
|
||||
@ -61,7 +59,7 @@ public class PolicyManagerUtil {
|
||||
throw new RuntimeException("Device Management Repository data source configuration " +
|
||||
"is null and thus, is not initialized");
|
||||
}
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefintion();
|
||||
JNDILookupDefinition jndiConfig = config.getJndiLookupDefinition();
|
||||
if (jndiConfig != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Initializing Device Management Repository data source using the JNDI " +
|
||||
|
||||
@ -1,20 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ 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.
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
<ManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/MOBILE_MGT_DS</Name>
|
||||
<Name>jdbc/MobileDM_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</ManagementRepository>
|
||||
@ -28,7 +28,7 @@
|
||||
<APIs>
|
||||
<API>
|
||||
<Name>enrollment</Name>
|
||||
<Provider>admin</Provider>
|
||||
<Owner>admin</Owner>
|
||||
<Context>enrollment</Context>
|
||||
<Version>1.0.0</Version>
|
||||
<Endpoint>http://localhost:9763/</Endpoint>
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
<ManagementRepository>
|
||||
<DataSourceConfiguration>
|
||||
<JndiLookupDefinition>
|
||||
<Name>jdbc/DEVICE_MGT_DS</Name>
|
||||
<Name>jdbc/DM_DS</Name>
|
||||
</JndiLookupDefinition>
|
||||
</DataSourceConfiguration>
|
||||
</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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user