add notify mechanisam to plugins for some operations - Ex -: IOS send push note to apns when add operation

revert-70aa11f8
manoj 9 years ago
parent 99f82e4817
commit e1dc3d2ea3

@ -18,9 +18,13 @@
*/
package org.wso2.carbon.device.mgt.common.spi;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import java.util.List;
/**
* Composite interface that acts as the SPI exposing all device management as well as application management
@ -41,4 +45,6 @@ public interface DeviceManagementService extends ApplicationManager {
ApplicationManager getApplicationManager();
void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds) throws DeviceManagementException;
}

@ -32,13 +32,16 @@ import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.app.mgt.oauth.ServiceAuthenticator;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.dao.*;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.PluginInitializationListener;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceException;
import org.wso2.carbon.identity.oauth.stub.OAuthAdminServiceStub;
import org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO;
@ -112,10 +115,16 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
try {
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation, deviceIds);
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().notifyOperationToDevices
(operation, deviceIds);
} catch (OperationManagementException opeEx) {
String errorMsg = "Error in add operation at app installation:" + opeEx.getErrorMessage();
log.error(errorMsg, opeEx);
throw new ApplicationManagementException(errorMsg, opeEx);
}catch (DeviceManagementException deviceEx){
String errorMsg = "Error in notify operation at app installation:" + deviceEx.getErrorMessage();
log.error(errorMsg, deviceEx);
throw new ApplicationManagementException(errorMsg, deviceEx);
}
}

@ -106,6 +106,7 @@ public class DeviceManagementServiceComponent {
private static List<PluginInitializationListener> listeners = new ArrayList<>();
private static List<DeviceManagementService> deviceManagers = new ArrayList<>();
private static List<DeviceManagerStartupListener> startupListeners = new ArrayList<>();
private DeviceManagementPluginRepository pluginRepository = new DeviceManagementPluginRepository();
@SuppressWarnings("unused")
protected void activate(ComponentContext componentContext) {

@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorization
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;

@ -23,6 +23,7 @@ import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
@ -161,6 +162,6 @@ public interface DeviceManagementProviderService extends OperationManager {
boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
EnrolmentInfo.Status status) throws DeviceManagementException;
void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)throws DeviceManagementException;
}

@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
@ -792,6 +793,24 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv
}
}
@Override
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
throws DeviceManagementException {
try {
for (DeviceIdentifier deviceId : deviceIds) {
DeviceManagementService dms =
getPluginRepository().getDeviceManagementService(deviceId.getType());
dms.notifyOperationToDevices(operation, deviceIds);
}
} catch (DeviceManagementException deviceMgtEx) {
String errorMsg = "Error in notify operations to plugins for app installation:" + deviceMgtEx.getErrorMessage();
log.error(errorMsg, deviceMgtEx);
throw new DeviceManagementException(errorMsg, deviceMgtEx);
}
}
@Override
public License getLicense(String deviceType, String languageCode) throws DeviceManagementException {
DeviceManager deviceManager = this.getDeviceManager(deviceType);

@ -58,6 +58,12 @@ public class TestDeviceManagementService implements DeviceManagementService {
return null;
}
@Override
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> deviceIds)
throws DeviceManagementException {
}
@Override
public Application[] getApplications(String domain, int pageNumber, int size)
throws ApplicationManagementException {

Loading…
Cancel
Save