Modified DeviceManagerService to return operation status.

4.x.x
harshanL 10 years ago
parent 6f79ae79e2
commit 4b22589796

@ -39,7 +39,7 @@ public interface DeviceManagerService {
* @param device Metadata corresponding to the device being enrolled
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/
void enrollDevice(Device device) throws DeviceManagementException;
boolean enrollDevice(Device device) throws DeviceManagementException;
/**
* Method to modify the metadata corresponding to device enrollment
@ -48,7 +48,7 @@ public interface DeviceManagerService {
* @throws DeviceManagementException If some unusual behaviour is observed while modify the enrollment of a
* device
*/
void modifyEnrollment(Device device) throws DeviceManagementException;
boolean modifyEnrollment(Device device) throws DeviceManagementException;
/**
* Method to disenroll a particular device from CDM.
@ -56,7 +56,7 @@ public interface DeviceManagerService {
* @param deviceId Fully qualified device identifier
* @throws DeviceManagementException If some unusual behaviour is observed while disenrolling a device
*/
void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
/**
* Method to retrieve the status of the registration process of a particular device.
@ -84,7 +84,7 @@ public interface DeviceManagerService {
* @param status Indicates whether the device is active
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/
void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException;
boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException;
/**
* Method to retrieve metadata of all devices registered within CDM corresponding to a particular device type.
@ -108,7 +108,7 @@ public interface DeviceManagerService {
* @param device Updated device information related data
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/
void updateDeviceInfo(Device device) throws DeviceManagementException;
boolean updateDeviceInfo(Device device) throws DeviceManagementException;
/**
* Method to set the ownership type of a particular device. i.e. BYOD, COPE
@ -117,6 +117,6 @@ public interface DeviceManagerService {
* @param ownershipType Type of ownership
* @throws DeviceManagementException If some unusual behaviour is observed while enrolling a device
*/
void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException;
boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException;
}

@ -47,36 +47,38 @@ public class DeviceManager implements DeviceManagerService {
}
@Override
public void enrollDevice(Device device) throws DeviceManagementException {
public boolean enrollDevice(Device device) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(device.getType());
dms.enrollDevice(device);
boolean status = dms.enrollDevice(device);
try {
this.getDeviceDAO().addDevice(device);
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while enrolling the device '" +
device.getId() + "'", e);
}
return status;
}
@Override
public void modifyEnrollment(Device device) throws DeviceManagementException {
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(device.getType());
dms.modifyEnrollment(device);
boolean status = dms.modifyEnrollment(device);
try {
this.getDeviceDAO().updateDevice(device);
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while modifying the device '" +
device.getId() + "'", e);
}
return status;
}
@Override
public void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
dms.disenrollDevice(deviceId);
return dms.disenrollDevice(deviceId);
}
@Override
@ -94,10 +96,10 @@ public class DeviceManager implements DeviceManagerService {
}
@Override
public void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
dms.setActive(deviceId, status);
return dms.setActive(deviceId, status);
}
@Override
@ -115,17 +117,17 @@ public class DeviceManager implements DeviceManagerService {
}
@Override
public void updateDeviceInfo(Device device) throws DeviceManagementException {
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(device.getType());
dms.updateDeviceInfo(device);
return dms.updateDeviceInfo(device);
}
@Override
public void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
DeviceManagerService dms =
this.getPluginRepository().getDeviceManagementProvider(deviceId.getType());
dms.setOwnership(deviceId, ownershipType);
return dms.setOwnership(deviceId, ownershipType);
}
public DeviceDAO getDeviceDAO() {

@ -23,7 +23,7 @@ import java.io.Serializable;
public class Device implements Serializable {
private static final long serialVersionUID = -8101106997837486245L;
private Long id;
private String id;
private String description;
private String name;
private Long dateOfEnrolment;
@ -43,11 +43,11 @@ public class Device implements Serializable {
this.deviceType = deviceType;
}
public Long getId() {
public String getId() {
return id;
}
public void setId(Long id) {
public void setId(String id) {
this.id = id;
}

@ -31,18 +31,18 @@ public class DeviceManagementService implements DeviceManagerService {
}
@Override
public void enrollDevice(Device device) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device);
public boolean enrollDevice(Device device) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().enrollDevice(device);
}
@Override
public void modifyEnrollment(Device device) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device);
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().modifyEnrollment(device);
}
@Override
public void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().disenrollDevice(deviceId);
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().disenrollDevice(deviceId);
}
@Override
@ -56,8 +56,8 @@ public class DeviceManagementService implements DeviceManagerService {
}
@Override
public void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().setActive(deviceId, status);
public boolean setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().setActive(deviceId, status);
}
@Override
@ -71,13 +71,13 @@ public class DeviceManagementService implements DeviceManagerService {
}
@Override
public void updateDeviceInfo(Device device) throws DeviceManagementException {
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().updateDeviceInfo(device);
}
@Override
public void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
DeviceManagementDataHolder.getInstance().getDeviceManager().setOwnership(deviceId, ownershipType);
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
return DeviceManagementDataHolder.getInstance().getDeviceManager().setOwnership(deviceId, ownershipType);
}
}

@ -34,7 +34,7 @@ public final class DeviceManagementSchemaInitializer extends DatabaseCreator {
}
protected String getDbScriptLocation(String databaseType) {
String scriptName = "wso2_rss_" + databaseType + ".sql";
String scriptName = "wso2_cdm_" + databaseType + ".sql";
if (log.isDebugEnabled()) {
log.debug("Loading database script from :" + scriptName);
}

@ -0,0 +1,28 @@
/*
* Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.carbon.device.mgt.mobile.impl;
/**
* Constants used by Mobile device Management classes.
*/
public class MobileDeviceManagementConstants {
public final static String MOBILE_DEVICE_TYPE_ANDROID = "android";
public final static String MOBILE_DEVICE_TYPE_IOS = "ios";
public final static String MOBILE_DEVICE_TYPE_WINDOWS = "windows";
}

@ -20,6 +20,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.MobileDeviceManagementConstants;
import java.util.List;
@ -28,62 +29,61 @@ import java.util.List;
*/
public class AndroidDeviceManagerService implements DeviceManagerService {
private static final String DEVICE_MANAGER_ANDROID = "android";
@Override
public String getProviderType() {
return DEVICE_MANAGER_ANDROID;
}
@Override
public void enrollDevice(Device device) throws DeviceManagementException {
@Override
public String getProviderType() {
return MobileDeviceManagementConstants.MOBILE_DEVICE_TYPE_ANDROID;
}
@Override
public void modifyEnrollment(Device device) throws DeviceManagementException {
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
}
@Override
public void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
}
@Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
}
@Override
public void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
@Override
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true;
}
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public List<Device> getAllDevices(String type) throws DeviceManagementException {
return null;
}
@Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return null;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
@Override
public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
return true;
}
}
@Override
public List<Device> getAllDevices(String type) throws DeviceManagementException {
return null;
}
@Override
public void updateDeviceInfo(Device device) throws DeviceManagementException{
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return null;
}
@Override
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return true;
}
@Override
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
return true;
}
}

@ -20,6 +20,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.MobileDeviceManagementConstants;
import java.util.List;
@ -28,41 +29,40 @@ import java.util.List;
*/
public class IOSDeviceManagerService implements DeviceManagerService {
private static final String DEVICE_MANAGER_IOS = "ios";
@Override
public String getProviderType() {
return DEVICE_MANAGER_IOS;
return MobileDeviceManagementConstants.MOBILE_DEVICE_TYPE_IOS;
}
@Override
public void enrollDevice(Device device) throws DeviceManagementException {
}
@Override
public void modifyEnrollment(Device device) throws DeviceManagementException {
}
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
}
@Override
public void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
return true;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
return true;
}
@Override
public void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
return true;
}
@Override
@ -76,13 +76,15 @@ public class IOSDeviceManagerService implements DeviceManagerService {
}
@Override
public void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return true;
}
@Override
public void updateDeviceInfo(Device device) throws DeviceManagementException{
@Override
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
return true;
}
}
}

@ -20,6 +20,7 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
import org.wso2.carbon.device.mgt.mobile.impl.MobileDeviceManagementConstants;
import java.util.List;
@ -28,41 +29,40 @@ import java.util.List;
*/
public class WindowsDeviceManagerService implements DeviceManagerService {
private static final String DEVICE_MANAGER_WINDOWS = "windows";
@Override
public String getProviderType() {
return DEVICE_MANAGER_WINDOWS;
return MobileDeviceManagementConstants.MOBILE_DEVICE_TYPE_WINDOWS;
}
@Override
public void enrollDevice(Device device) throws DeviceManagementException {
}
@Override
public void modifyEnrollment(Device device) throws DeviceManagementException {
}
public boolean enrollDevice(Device device) throws DeviceManagementException {
return true;
}
@Override
public void disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
return true;
}
@Override
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
return true;
}
@Override
public boolean isRegistered(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
return true;
}
@Override
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
return false;
return true;
}
@Override
public void setActive(DeviceIdentifier deviceId, boolean status) throws DeviceManagementException {
public boolean setActive(DeviceIdentifier deviceId, boolean status)
throws DeviceManagementException {
return true;
}
@Override
@ -75,15 +75,15 @@ public class WindowsDeviceManagerService implements DeviceManagerService {
return null;
}
@Override
public void setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException {
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
throws DeviceManagementException {
return true;
}
@Override
public void updateDeviceInfo(Device device) throws DeviceManagementException{
}
@Override
public boolean updateDeviceInfo(Device device) throws DeviceManagementException {
return true;
}
}

Loading…
Cancel
Save