Merge branch 'master' of https://github.com/geethkokila/product-cdm
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -45,6 +45,7 @@ public class DeviceManagementRepository {
|
||||
|
||||
public void removeDeviceManagementProvider(DeviceManagerService provider) {
|
||||
String deviceType = provider.getProviderType();
|
||||
|
||||
try {
|
||||
DeviceManagerUtil.unregisterDeviceType(deviceType);
|
||||
} catch (DeviceManagementException e) {
|
||||
@ -56,5 +57,4 @@ public class DeviceManagementRepository {
|
||||
public DeviceManagerService getDeviceManagementProvider(String type) {
|
||||
return providers.get(type);
|
||||
}
|
||||
|
||||
}
|
||||
@ -147,7 +147,7 @@ public class DeviceManagementDAOTests {
|
||||
DeviceType deviceType = new DeviceType();
|
||||
deviceType.setId(Long.parseLong("1"));
|
||||
|
||||
device.setDeviceType(deviceType.getId().intValue());
|
||||
device.setDeviceTypeId(deviceType.getId().intValue());
|
||||
device.setOwnerShip(OwnerShip.BYOD.toString());
|
||||
device.setOwnerId("111");
|
||||
device.setTenantId(-1234);
|
||||
|
||||
@ -48,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;
|
||||
|
||||
}
|
||||
|
||||
@ -53,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() {
|
||||
|
||||
@ -16,14 +16,14 @@
|
||||
|
||||
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.
|
||||
*
|
||||
@ -32,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;
|
||||
|
||||
/**
|
||||
@ -42,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;
|
||||
|
||||
/**
|
||||
@ -53,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;
|
||||
|
||||
/**
|
||||
@ -65,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;
|
||||
|
||||
/**
|
||||
@ -74,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;
|
||||
}
|
||||
@ -16,46 +16,44 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.Operation;
|
||||
|
||||
import java.util.List;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperation;
|
||||
|
||||
/**
|
||||
* This class represents the key operations associated with persisting operation related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationDAO {
|
||||
public interface MobileOperationDAO {
|
||||
|
||||
/**
|
||||
* Add a new operation to plugin operation table.
|
||||
* 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 addOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
int addMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Update a operation in the operation table.
|
||||
* 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 updateOperation(Operation operation) throws MobileDeviceManagementDAOException;
|
||||
boolean updateMobileOperation(MobileOperation operation) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given operation from plugin database.
|
||||
* 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 deleteOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
boolean deleteMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given operation from plugin database.
|
||||
* 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
|
||||
*/
|
||||
Operation getOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
MobileOperation getMobileOperation(int operationId) throws MobileDeviceManagementDAOException;
|
||||
|
||||
}
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.dao;
|
||||
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.MobileOperationProperty;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -24,15 +24,16 @@ import java.util.List;
|
||||
* This class represents the key operations associated with persisting operation property related
|
||||
* information.
|
||||
*/
|
||||
public interface OperationPropertyDAO {
|
||||
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.
|
||||
* @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)
|
||||
boolean addMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
@ -42,36 +43,38 @@ public interface OperationPropertyDAO {
|
||||
* @return The status of the operation. If the update was successful or not.
|
||||
* @throws MobileDeviceManagementDAOException
|
||||
*/
|
||||
boolean updateOperationProperty(OperationProperty operationProperty)
|
||||
boolean updateMobileOperationProperty(MobileOperationProperty operationProperty)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Delete a given device operation from plugin database.
|
||||
* Deletes mobile operation properties of a given operation id from the plugin database.
|
||||
*
|
||||
* @param operationPropertyId Device id of the mapping to be deleted.
|
||||
* @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 deleteOperationProperty(int operationPropertyId)
|
||||
boolean deleteMobileOperationProperties(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve a given device operation from plugin database.
|
||||
* Retrieve a given mobile operation property 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.
|
||||
* @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
|
||||
*/
|
||||
OperationProperty getOperationProperty(String deviceId, int operationId)
|
||||
MobileOperationProperty getMobileOperationProperty(int operationId, String property)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
|
||||
/**
|
||||
* Retrieve all the device operation mapping from plugin database.
|
||||
* 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<OperationProperty> getAllDeviceOperationOfDevice(String deviceId)
|
||||
List<MobileOperationProperty> getAllMobileOperationPropertiesOfOperation(int operationId)
|
||||
throws MobileDeviceManagementDAOException;
|
||||
}
|
||||
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeatureDAO
|
||||
* Implementation of FeatureDAO.
|
||||
*/
|
||||
public class FeatureDAOImpl implements FeatureDAO {
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of FeaturePropertyDAO
|
||||
* Implementation of FeaturePropertyDAO.
|
||||
*/
|
||||
public class FeaturePropertyDAOImpl implements FeaturePropertyDAO {
|
||||
|
||||
@ -81,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 {
|
||||
@ -102,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;
|
||||
@ -110,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 {
|
||||
@ -129,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;
|
||||
@ -137,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();
|
||||
@ -148,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 {
|
||||
@ -168,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;
|
||||
|
||||
@ -18,10 +18,10 @@ 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;
|
||||
@ -32,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;
|
||||
@ -66,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);
|
||||
@ -77,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;
|
||||
@ -85,7 +86,7 @@ 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.setLong(1, deviceOperation.getSentDate());
|
||||
stmt.setLong(2, deviceOperation.getReceivedDate());
|
||||
@ -98,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 {
|
||||
@ -108,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;
|
||||
@ -116,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);
|
||||
@ -126,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);
|
||||
@ -137,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));
|
||||
@ -160,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);
|
||||
@ -171,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 =
|
||||
@ -185,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);
|
||||
@ -19,9 +19,9 @@ 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;
|
||||
@ -30,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;
|
||||
@ -51,7 +51,6 @@ 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.setLong(2, operation.getCreatedDate());
|
||||
@ -63,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 {
|
||||
@ -74,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;
|
||||
@ -92,7 +91,7 @@ public class OperationDAOImpl implements OperationDAO {
|
||||
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);
|
||||
@ -103,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;
|
||||
@ -119,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 {
|
||||
@ -129,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 =
|
||||
@ -142,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,103 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.mobile.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,6 @@ package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
*/
|
||||
public class FeatureProperty {
|
||||
|
||||
private int propertyId;
|
||||
private String property;
|
||||
private String featureID;
|
||||
|
||||
@ -33,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;
|
||||
}
|
||||
|
||||
@ -17,9 +17,9 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of Operations.
|
||||
* DTO of Mobile Device Operations.
|
||||
*/
|
||||
public class DeviceOperation {
|
||||
public class MobileDeviceOperation {
|
||||
|
||||
private String deviceId;
|
||||
private int operationId;
|
||||
@ -19,14 +19,14 @@ package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* DTO of operation.
|
||||
* DTO of MobileOperation.
|
||||
*/
|
||||
public class Operation {
|
||||
public class MobileOperation {
|
||||
|
||||
private int operationId;
|
||||
private String featureCode;
|
||||
private long createdDate;
|
||||
private List<OperationProperty> properties;
|
||||
private List<MobileOperationProperty> properties;
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
@ -36,11 +36,11 @@ public class Operation {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public List<OperationProperty> getProperties() {
|
||||
public List<MobileOperationProperty> getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(List<OperationProperty> properties) {
|
||||
public void setProperties(List<MobileOperationProperty> properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
@ -17,13 +17,12 @@
|
||||
package org.wso2.carbon.device.mgt.mobile.dto;
|
||||
|
||||
/**
|
||||
* DTO of operation property.
|
||||
* DTO of Mobile Operation property.
|
||||
*/
|
||||
public class OperationProperty {
|
||||
public class MobileOperationProperty {
|
||||
|
||||
private int operationPropertyId;
|
||||
private int operationId;
|
||||
private int propertyId;
|
||||
private String property;
|
||||
private String value;
|
||||
|
||||
public String getValue() {
|
||||
@ -34,14 +33,6 @@ public class OperationProperty {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getOperationPropertyId() {
|
||||
return operationPropertyId;
|
||||
}
|
||||
|
||||
public void setOperationPropertyId(int operationPropertyId) {
|
||||
this.operationPropertyId = operationPropertyId;
|
||||
}
|
||||
|
||||
public int getOperationId() {
|
||||
return operationId;
|
||||
}
|
||||
@ -50,12 +41,12 @@ public class OperationProperty {
|
||||
this.operationId = operationId;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
public String getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
public void setPropertyId(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
public void setProperty(String property) {
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
}
|
||||
@ -50,7 +50,8 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
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();
|
||||
@ -66,7 +67,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
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();
|
||||
@ -81,7 +82,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
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;
|
||||
@ -125,7 +126,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
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();
|
||||
@ -147,7 +148,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
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();
|
||||
log.error(msg, e);
|
||||
@ -162,7 +163,7 @@ public class AndroidDeviceManagerService implements DeviceManagerService {
|
||||
try {
|
||||
List<MobileDevice> mobileDevices =
|
||||
MobileDeviceManagementDAOFactory.getMobileDeviceDAO().
|
||||
getAllDevices();
|
||||
getAllMobileDevices();
|
||||
if (mobileDevices != null) {
|
||||
devices = new ArrayList<Device>();
|
||||
for (MobileDevice mobileDevice : mobileDevices) {
|
||||
|
||||
@ -18,15 +18,17 @@ package org.wso2.carbon.device.mgt.mobile.impl.android;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.OperationManagementException;
|
||||
import org.wso2.carbon.device.mgt.mobile.AbstractMobileOperationManager;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOException;
|
||||
import org.wso2.carbon.device.mgt.mobile.dao.MobileDeviceManagementDAOFactory;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.DeviceOperation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
import 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 {
|
||||
@ -36,26 +38,67 @@ public class AndroidMobileOperationManager extends AbstractMobileOperationManage
|
||||
@Override
|
||||
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
|
||||
OperationManagementException {
|
||||
boolean status = false;
|
||||
try {
|
||||
MobileDeviceManagementDAOFactory.getOperationDAO().addOperation(
|
||||
new org.wso2.carbon.device.mgt.mobile.dto.Operation());
|
||||
MobileDeviceManagementDAOFactory.geOperationPropertyDAO()
|
||||
.addOperationProperty(new OperationProperty());
|
||||
MobileDeviceManagementDAOFactory.getDeviceOperationDAO()
|
||||
.addDeviceOperation(new DeviceOperation());
|
||||
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 updating the enrollment of the Android device : " +
|
||||
devices.get(0).getId();
|
||||
String msg =
|
||||
"Error while adding an operation " + operation.getCode() + "to Android devices";
|
||||
log.error(msg, e);
|
||||
throw new OperationManagementException(msg, e);
|
||||
}
|
||||
return false;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -21,9 +21,11 @@ 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.Operation;
|
||||
import org.wso2.carbon.device.mgt.mobile.dto.OperationProperty;
|
||||
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;
|
||||
@ -114,15 +116,41 @@ public class MobileDeviceManagementUtil {
|
||||
return device;
|
||||
}
|
||||
|
||||
public static Operation convertToOperation(org.wso2.carbon.device.mgt.common.Operation operation){
|
||||
Operation mobileOperation = new Operation();
|
||||
List<OperationProperty> properties = new LinkedList<OperationProperty>();
|
||||
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()) {
|
||||
String value = operationProperties.getProperty(key);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* 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.
|
||||
* 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.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";
|
||||
}
|
||||
@ -22,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;
|
||||
|
||||
@ -23,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;
|
||||
|
||||
10
pom.xml
@ -133,15 +133,7 @@
|
||||
<artifactId>org.eclipse.equinox.common</artifactId>
|
||||
<version>${eclipse.equinox.common.version}</version>
|
||||
</dependency>
|
||||
<!--Test dependencies-->
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12-beta-3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
|
||||
@ -251,7 +251,7 @@
|
||||
|
||||
<files>
|
||||
<file>
|
||||
<source>../agents/android/jax-rs/target/cdm-android-api.war</source>
|
||||
<source>../mobileservices/agents/android/jax-rs/target/cdm-android-api.war</source>
|
||||
<outputDirectory>wso2cdm-${pom.version}/repository/deployment/server/webapps
|
||||
</outputDirectory>
|
||||
<fileMode>755</fileMode>
|
||||
|
||||
@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
`FEATURE_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`CODE` VARCHAR(45) NULL ,
|
||||
`CODE` VARCHAR(45) NOT NULL ,
|
||||
`NAME` VARCHAR(100) NULL ,
|
||||
`DESCRIPTION` VARCHAR(200) NULL ,
|
||||
PRIMARY KEY (`FEATURE_ID`) );
|
||||
@ -30,7 +30,7 @@ CREATE TABLE IF NOT EXISTS `MBL_FEATURE` (
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`FEATURE_CODE` VARCHAR(45) NULL ,
|
||||
`FEATURE_CODE` VARCHAR(45) NOT NULL ,
|
||||
`CREATED_DATE` INT NULL ,
|
||||
PRIMARY KEY (`OPERATION_ID`) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
||||
@ -40,9 +40,9 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPING`
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPPING`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||
`DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`OPERATION_ID` INT NOT NULL ,
|
||||
`SENT_DATE` INT NULL ,
|
||||
@ -63,11 +63,10 @@ CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
-- Table `MBL_OPERATION_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
`OPERATION_PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`OPERATION_ID` INT NULL ,
|
||||
`PROPERTY_ID` INT NULL ,
|
||||
`OPERATION_ID` INT NOT NULL ,
|
||||
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||
`VALUE` TEXT NULL ,
|
||||
PRIMARY KEY (`OPERATION_PROPERTY_ID`) ,
|
||||
PRIMARY KEY (`OPERATION_ID`, `PROPERTY`) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_PROPERTY_MBL_OPERATION1`
|
||||
FOREIGN KEY (`OPERATION_ID` )
|
||||
REFERENCES `MBL_OPERATION` (`OPERATION_ID` )
|
||||
@ -78,13 +77,11 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION_PROPERTY` (
|
||||
-- Table `MBL_FEATURE_PROPERTY`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_FEATURE_PROPERTY` (
|
||||
`PROPERTY_ID` INT NOT NULL AUTO_INCREMENT ,
|
||||
`PROPERTY` VARCHAR(100) NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NULL ,
|
||||
PRIMARY KEY (`PROPERTY_ID`) ,
|
||||
`PROPERTY` VARCHAR(45) NOT NULL ,
|
||||
`FEATURE_ID` VARCHAR(45) NOT NULL ,
|
||||
PRIMARY KEY (`PROPERTY`) ,
|
||||
CONSTRAINT `fk_MBL_FEATURE_PROPERTY_MBL_FEATURE1`
|
||||
FOREIGN KEY (`FEATURE_ID` )
|
||||
REFERENCES `MBL_FEATURE` (`FEATURE_ID` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION);
|
||||
|
||||
|
||||
@ -3,12 +3,14 @@
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE` (
|
||||
`MOBILE_DEVICE_ID` VARCHAR(45) NOT NULL,
|
||||
`REG_ID` VARCHAR(45) NULL,
|
||||
`IMEI` VARCHAR(45) NULL,
|
||||
`IMSI` VARCHAR(45) NULL,
|
||||
`OS_VERSION` VARCHAR(45) NULL,
|
||||
`DEVICE_MODEL` VARCHAR(45) NULL,
|
||||
`VENDOR` VARCHAR(45) NULL,
|
||||
`REG_ID` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`IMEI` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`IMSI` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`OS_VERSION` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`DEVICE_MODEL` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`VENDOR` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`LATITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||
`LONGITUDE` VARCHAR(45) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`MOBILE_DEVICE_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
@ -32,20 +34,14 @@ CREATE TABLE IF NOT EXISTS `MBL_OPERATION` (
|
||||
`OPERATION_ID` INT NOT NULL AUTO_INCREMENT,
|
||||
`FEATURE_CODE` VARCHAR(45) NULL,
|
||||
`CREATED_DATE` INT NULL,
|
||||
PRIMARY KEY (`OPERATION_ID`) ,
|
||||
INDEX `fk_MBL_OPERATION_MBL_FEATURES1_idx` (`FEATURE_CODE` ASC) ,
|
||||
CONSTRAINT `fk_MBL_OPERATION_MBL_FEATURES1`
|
||||
FOREIGN KEY (`FEATURE_CODE` )
|
||||
REFERENCES `MBL_FEATURE` (`CODE` )
|
||||
ON DELETE NO ACTION
|
||||
ON UPDATE NO ACTION)
|
||||
PRIMARY KEY (`OPERATION_ID`))
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `MBL_DEVICE_OPERATION_MAPING`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPING` (
|
||||
CREATE TABLE IF NOT EXISTS `MBL_DEVICE_OPERATION_MAPPING` (
|
||||
`DEVICE_ID` VARCHAR(45) NOT NULL,
|
||||
`OPERATION_ID` INT NOT NULL,
|
||||
`SENT_DATE` INT NULL,
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0"?>
|
||||
<artifactType type="application/vnd.wso2-license+xml" shortName="license" singularLabel="License" pluralLabel="Licenses"
|
||||
hasNamespace="false" iconSet="10">
|
||||
<storagePath>/license/@{overview_provider}/@{overview_name}/@{overview_version}</storagePath>
|
||||
<nameAttribute>overview_name</nameAttribute>
|
||||
<ui>
|
||||
<list>
|
||||
<column name="Provider">
|
||||
<data type="path" value="overview_provider" href="@{storagePath}"/>
|
||||
</column>
|
||||
<column name="Name">
|
||||
<data type="path" value="overview_name" href="@{storagePath}"/>
|
||||
</column>
|
||||
<column name="Version">
|
||||
<data type="path" value="overview_version" href="@{storagePath}"/>
|
||||
</column>
|
||||
</list>
|
||||
</ui>
|
||||
<content>
|
||||
<table name="Overview">
|
||||
<field type="text" required="true">
|
||||
<name>Provider</name>
|
||||
</field>
|
||||
<field type="text" required="true">
|
||||
<name>Name</name>
|
||||
</field>
|
||||
<field type="text" required="true">
|
||||
<name>Version</name>
|
||||
</field>
|
||||
<field type="text">
|
||||
<name>Createdtime</name>
|
||||
</field>
|
||||
<field type="text-area">
|
||||
<name>License</name>
|
||||
</field>
|
||||
</table>
|
||||
</content>
|
||||
</artifactType>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
|
Before Width: | Height: | Size: 5.1 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1015 B After Width: | Height: | Size: 1015 B |
|
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 7.9 KiB After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 8.6 KiB After Width: | Height: | Size: 8.6 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 110 B After Width: | Height: | Size: 110 B |