APP Manager Integration

4.x.x
manoj 10 years ago
parent 2d5f8fe937
commit 2ae89bef59

@ -17,7 +17,9 @@
*/
package org.wso2.carbon.device.mgt.common;
public class DeviceIdentifier {
import java.io.Serializable;
public class DeviceIdentifier implements Serializable{
private String id;
private String type;
@ -29,7 +31,6 @@ public class DeviceIdentifier {
public void setType(String type) {
this.type = type;
}
public String getId() {
return id;
}

@ -15,11 +15,12 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.device.mgt.core.app.mgt;
package org.wso2.carbon.device.mgt.common.app.mgt;
import org.wso2.carbon.device.mgt.common.Credential;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.app.mgt.oauth.dto.Credential;
import org.wso2.carbon.device.mgt.core.dto.Application;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import java.util.List;
/**
* This will handle the Application management side of MDM by acting a bridge between
@ -68,4 +69,7 @@ public interface AppManagerConnector {
*/
Credential getClientCredentials() throws AppManagerConnectorException;
void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers) throws
AppManagerConnectorException;
}

@ -18,7 +18,10 @@
package org.wso2.carbon.device.mgt.common.spi;
import org.wso2.carbon.device.mgt.common.*;
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.FeatureManager;
import java.util.List;
@ -31,14 +34,14 @@ public interface DeviceManager {
/**
* Method to retrieve the provider type that implements DeviceManager interface.
*
* @return Returns provider type
* @return Returns provider type
*/
String getProviderType();
/**
* Method to return feature manager implementation associated with a particular platform-specific plugin.
*
* @return Returns an instance of feature manager
* @return Returns an instance of feature manager
*/
FeatureManager getFeatureManager();
@ -110,7 +113,7 @@ public interface DeviceManager {
* Method to retrieve metadata of a device corresponding to a particular type that carries a specific identifier.
*
* @param deviceId Fully qualified device identifier
* @return Metadata corresponding to a particular device
* @return Metadata corresponding to a particular device
* @throws DeviceManagementException If some unusual behaviour is observed obtaining the device object
*/
Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException;
@ -133,5 +136,4 @@ public interface DeviceManager {
*/
boolean setOwnership(DeviceIdentifier deviceId, String ownershipType) throws DeviceManagementException;
}

@ -18,7 +18,7 @@
package org.wso2.carbon.device.mgt.core;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import java.util.HashMap;
@ -26,13 +26,13 @@ import java.util.Map;
public class DeviceManagementRepository {
private Map<String, DeviceManager> providers;
private Map<String, DeviceMgtService> providers;
public DeviceManagementRepository() {
providers = new HashMap<String, DeviceManager>();
providers = new HashMap<String, DeviceMgtService>();
}
public void addDeviceManagementProvider(DeviceManager provider) throws DeviceManagementException {
public void addDeviceManagementProvider(DeviceMgtService provider) throws DeviceManagementException {
String deviceType = provider.getProviderType();
try {
DeviceManagerUtil.registerDeviceType(deviceType);
@ -43,7 +43,7 @@ public class DeviceManagementRepository {
providers.put(deviceType, provider);
}
public void removeDeviceManagementProvider(DeviceManager provider) throws DeviceManagementException {
public void removeDeviceManagementProvider(DeviceMgtService provider) throws DeviceManagementException {
String deviceType = provider.getProviderType();
try {
DeviceManagerUtil.unregisterDeviceType(deviceType);
@ -54,7 +54,7 @@ public class DeviceManagementRepository {
providers.remove(deviceType);
}
public DeviceManager getDeviceManagementProvider(String type) {
public DeviceMgtService getDeviceManagementProvider(String type) {
return providers.get(type);
}

@ -22,10 +22,8 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
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.OperationManagementException;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages;
@ -37,9 +35,8 @@ import org.wso2.carbon.device.mgt.core.dao.util.DeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import org.wso2.carbon.device.mgt.core.dto.Status;
import org.wso2.carbon.device.mgt.core.email.EmailConstants;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.internal.EmailServiceDataHolder;
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
@ -54,8 +51,6 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
private DeviceDAO deviceDAO;
private DeviceTypeDAO deviceTypeDAO;
private DeviceManagementRepository pluginRepository;
private OperationManager operationManager;
private LicenseManager licenseManager;
private static Log log = LogFactory.getLog(DeviceManagementServiceProviderImpl.class);
@ -63,15 +58,11 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
this.pluginRepository = pluginRepository;
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.operationManager = new OperationManagerImpl();
this.licenseManager = new LicenseManagerImpl();
}
public DeviceManagementServiceProviderImpl(){
public DeviceManagementServiceProviderImpl() {
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.operationManager = new OperationManagerImpl();
this.licenseManager = new LicenseManagerImpl();
}
@Override
@ -104,7 +95,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
}
} catch (DeviceManagementDAOException e) {
throw new DeviceManagementException("Error occurred while obtaining the device for id " +
"'" + deviceId.getId() + "' and type:"+deviceId.getType(), e);
"'" + deviceId.getId() + "' and type:" + deviceId.getType(), e);
}
return convertedDevice;
}
@ -256,7 +247,8 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
}
@Override
public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties) throws DeviceManagementException {
public void sendEnrolmentInvitation(EmailMessageProperties emailMessageProperties)
throws DeviceManagementException {
List<NotificationMessages> notificationMessages = DeviceConfigurationManager.getInstance()
.getNotificationMessagesConfig().getNotificationMessagesList();
@ -267,9 +259,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
String url = "";
String subject = "";
for(NotificationMessages notificationMessage : notificationMessages){
for (NotificationMessages notificationMessage : notificationMessages) {
if (DeviceManagementConstants.EmailNotifications.ENROL_NOTIFICATION_TYPE.
equals(notificationMessage.getType())) {
equals(notificationMessage.getType())) {
messageHeader = notificationMessage.getHeader();
messageBody = notificationMessage.getBody();
messageFooter = notificationMessage.getFooter();
@ -283,18 +275,18 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
try {
messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}",
URLEncoder.encode(emailMessageProperties.getFirstName(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
URLEncoder.encode(emailMessageProperties.getFirstName(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
messageBody = messageBody + System.getProperty("line.separator") + url.replaceAll("\\{"
+ EmailConstants.EnrolmentEmailConstants.DOWNLOAD_URL + "\\}",
URLDecoder.decode(emailMessageProperties.getEnrolmentUrl(),
EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME));
messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
messageBuilder.append(messageHeader).append(System.getProperty("line.separator"));
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
} catch (IOException e) {
log.error("IO error in processing enrol email message "+emailMessageProperties);
log.error("IO error in processing enrol email message " + emailMessageProperties);
throw new DeviceManagementException("Error replacing tags in email template '" +
emailMessageProperties.getSubject() + "'", e);
}
@ -314,9 +306,9 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
String url = "";
String subject = "";
for(NotificationMessages notificationMessage : notificationMessages){
for (NotificationMessages notificationMessage : notificationMessages) {
if (DeviceManagementConstants.EmailNotifications.USER_REGISTRATION_NOTIFICATION_TYPE.
equals(notificationMessage.getType())) {
equals(notificationMessage.getType())) {
messageHeader = notificationMessage.getHeader();
messageBody = notificationMessage.getBody();
messageFooter = notificationMessage.getFooter();
@ -350,7 +342,7 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
messageBuilder.append(messageBody).append(System.getProperty("line.separator")).append(messageFooter);
} catch (IOException e) {
log.error("IO error in processing enrol email message "+emailMessageProperties);
log.error("IO error in processing enrol email message " + emailMessageProperties);
throw new DeviceManagementException("Error replacing tags in email template '" +
emailMessageProperties.getSubject() + "'", e);
}
@ -402,12 +394,12 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
@Override
public License getLicense(String deviceType, String languageCode) throws LicenseManagementException {
return licenseManager.getLicense(deviceType, languageCode);
return DeviceManagementDataHolder.getInstance().getLicenseManager().getLicense(deviceType, languageCode);
}
@Override
public boolean addLicense(String type, License license) throws LicenseManagementException {
return licenseManager.addLicense(type, license);
return DeviceManagementDataHolder.getInstance().getLicenseManager().addLicense(type, license);
}
public DeviceDAO getDeviceDAO() {
@ -425,55 +417,58 @@ public class DeviceManagementServiceProviderImpl implements DeviceManagementServ
@Override
public boolean addOperation(Operation operation, List<DeviceIdentifier> devices) throws
OperationManagementException {
return operationManager.addOperation(operation, devices);
return DeviceManagementDataHolder.getInstance().getOperationManager().addOperation(operation, devices);
}
@Override
public List<? extends Operation> getOperations(DeviceIdentifier deviceId) throws OperationManagementException {
return operationManager.getOperations(deviceId);
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperations(deviceId);
}
@Override
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId) throws OperationManagementException {
return operationManager.getPendingOperations(deviceId);
public List<? extends Operation> getPendingOperations(DeviceIdentifier deviceId)
throws OperationManagementException {
return DeviceManagementDataHolder.getInstance().getOperationManager().getPendingOperations(deviceId);
}
@Override
public Operation getNextPendingOperation(DeviceIdentifier deviceId) throws OperationManagementException {
return operationManager.getNextPendingOperation(deviceId);
return DeviceManagementDataHolder.getInstance().getOperationManager().getNextPendingOperation(deviceId);
}
@Override
public void updateOperation(int operationId, Operation.Status operationStatus)
throws OperationManagementException {
operationManager.updateOperation(operationId, operationStatus);
DeviceManagementDataHolder.getInstance().getOperationManager().updateOperation(operationId, operationStatus);
}
@Override
public void deleteOperation(int operationId) throws OperationManagementException {
operationManager.deleteOperation(operationId);
DeviceManagementDataHolder.getInstance().getOperationManager().deleteOperation(operationId);
}
@Override
public Operation getOperationByDeviceAndOperationId(DeviceIdentifier deviceId, int operationId)
throws OperationManagementException {
return operationManager.getOperationByDeviceAndOperationId(deviceId, operationId);
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationByDeviceAndOperationId(
deviceId, operationId);
}
@Override
public List<? extends Operation> getOperationsByDeviceAndStatus(DeviceIdentifier identifier,
Operation.Status status) throws OperationManagementException, DeviceManagementException {
return operationManager.getOperationsByDeviceAndStatus(identifier, status);
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationsByDeviceAndStatus(identifier,
status);
}
@Override
public Operation getOperation(int operationId) throws OperationManagementException {
return operationManager.getOperation(operationId);
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperation(operationId);
}
@Override
public List<? extends Operation> getOperationsForStatus(Operation.Status status)
throws OperationManagementException {
return operationManager.getOperationsForStatus(status);
return DeviceManagementDataHolder.getInstance().getOperationManager().getOperationsForStatus(status);
}
}

@ -17,16 +17,20 @@
*/
package org.wso2.carbon.device.mgt.core.app.mgt;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.Credential;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.core.app.mgt.oauth.dto.Credential;
import org.wso2.carbon.device.mgt.core.dto.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.core.internal.DeviceManagementDataHolder;
import java.util.List;
public class AppManagementServiceImpl implements AppManagerConnector {
@Override
public Application[] getApplicationList(String domain, int pageNumber,
int size) throws AppManagerConnectorException {
public Application[] getApplicationList(String domain, int pageNumber, int size) throws AppManagerConnectorException {
return DeviceManagementDataHolder.getInstance().getAppManager().getApplicationList(domain, pageNumber, size);
}
@ -48,4 +52,10 @@ public class AppManagementServiceImpl implements AppManagerConnector {
return DeviceManagementDataHolder.getInstance().getAppManager().getClientCredentials();
}
@Override
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws AppManagerConnectorException {
DeviceManagementDataHolder.getInstance().getAppManager().installApplication(operation, deviceIdentifiers);
}
}

@ -18,12 +18,26 @@
*/
package org.wso2.carbon.device.mgt.core.app.mgt;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.core.DeviceManagementRepository;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
public class AppManagerConnectorFactory {
private static DeviceManagementRepository pluginRepository;
public DeviceManagementRepository getPluginRepository() {
return pluginRepository;
}
public void setPluginRepository(DeviceManagementRepository pluginRepository) {
this.pluginRepository = pluginRepository;
}
public static AppManagerConnector getConnector(AppManagementConfig config) {
return new RemoteAppManagerConnector(config);
return new RemoteAppManagerConnector(config, pluginRepository);
}
}

@ -23,19 +23,25 @@ import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.Credential;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementRepository;
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.app.mgt.oauth.dto.Credential;
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.dto.Application;
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;
import java.rmi.RemoteException;
import java.util.List;
/**
* Implements AppManagerConnector interface
@ -45,12 +51,14 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
private ConfigurationContext configCtx;
private ServiceAuthenticator authenticator;
private String oAuthAdminServiceUrl;
private DeviceManagementRepository pluginRepository;
private static final String GET_APP_LIST_URL = "store/apis/assets/mobileapp?domain=carbon.super&page=1";
private static final Log log = LogFactory.getLog(RemoteAppManagerConnector.class);
public RemoteAppManagerConnector(AppManagementConfig appManagementConfig) {
public RemoteAppManagerConnector(AppManagementConfig appManagementConfig, DeviceManagementRepository pluginRepository) {
IdentityConfigurations identityConfig = DeviceConfigurationManager.getInstance().getDeviceManagementConfig().
getDeviceManagementConfigRepository().getIdentityConfigurations();
this.authenticator =
@ -63,6 +71,7 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
throw new IllegalArgumentException("Error occurred while initializing Axis2 Configuration Context. " +
"Please check if an appropriate axis2.xml is provided", e);
}
this.pluginRepository = pluginRepository;
}
@Override
@ -93,6 +102,16 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
return credential;
}
@Override
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws AppManagerConnectorException {
for(DeviceIdentifier deviceIdentifier:deviceIdentifiers){
DeviceMgtService dms = this.getPluginRepository().getDeviceManagementProvider(deviceIdentifier.getType());
dms.installApplication(operation,deviceIdentifiers);
}
}
private OAuthConsumerAppDTO getAppInfo() throws AppManagerConnectorException {
OAuthConsumerAppDTO appInfo = null;
try {
@ -133,4 +152,7 @@ public class RemoteAppManagerConnector implements AppManagerConnector {
throw new AppManagerConnectorException(msg, e);
}
public DeviceManagementRepository getPluginRepository() {
return pluginRepository;
}
}

@ -19,8 +19,7 @@
package org.wso2.carbon.device.mgt.core.app.mgt.config;
import org.w3c.dom.Document;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
import org.wso2.carbon.utils.CarbonUtils;

@ -21,7 +21,7 @@ package org.wso2.carbon.device.mgt.core.app.mgt.oauth;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.transport.http.HttpTransportProperties;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
/**
* Authenticate a given service client.

@ -20,8 +20,9 @@
package org.wso2.carbon.device.mgt.core.internal;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;
import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
@ -40,6 +41,7 @@ public class DeviceManagementDataHolder {
private APIPublisherService apiPublisherService;
private AppManagerConnector appManager;
private AppManagementConfig appManagerConfig;
private OperationManager operationManager;
private static DeviceManagementDataHolder thisInstance = new DeviceManagementDataHolder();
@ -126,4 +128,11 @@ public class DeviceManagementDataHolder {
this.appManagerConfig = appManagerConfig;
}
public OperationManager getOperationManager() {
return operationManager;
}
public void setOperationManager(OperationManager operationManager) {
this.operationManager = operationManager;
}
}

@ -27,7 +27,10 @@ import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.License;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
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.DeviceManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService;
import org.wso2.carbon.device.mgt.core.DeviceManagementConstants;
import org.wso2.carbon.device.mgt.core.DeviceManagementRepository;
import org.wso2.carbon.device.mgt.core.DeviceManagementServiceProviderImpl;
@ -35,8 +38,8 @@ import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService;
import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherServiceImpl;
import org.wso2.carbon.device.mgt.core.api.mgt.APIRegistrationStartupObserver;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagementServiceImpl;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.core.app.mgt.RemoteAppManagerConnector;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfigurationManager;
@ -47,6 +50,7 @@ import org.wso2.carbon.device.mgt.core.config.license.LicenseConfig;
import org.wso2.carbon.device.mgt.core.config.license.LicenseConfigurationManager;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.license.mgt.LicenseManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import org.wso2.carbon.device.mgt.core.operation.mgt.dao.OperationManagementDAOFactory;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementService;
import org.wso2.carbon.device.mgt.core.service.DeviceManagementServiceImpl;
@ -67,7 +71,7 @@ import java.util.List;
* bind="setRealmService"
* unbind="unsetRealmService"
* @scr.reference name="device.manager.service"
* interface="org.wso2.carbon.device.mgt.common.spi.DeviceManager"
* interface="org.wso2.carbon.device.mgt.common.spi.DeviceMgtService"
* cardinality="0..n"
* policy="dynamic"
* bind="setDeviceManager"
@ -98,14 +102,13 @@ public class DeviceManagementServiceComponent {
private static final Object LOCK = new Object();
private boolean isInitialized;
private List<DeviceManager> deviceManagers = new ArrayList<DeviceManager>();
private List<DeviceMgtService> deviceManagers = new ArrayList<DeviceMgtService>();
protected void activate(ComponentContext componentContext) {
try {
if (log.isDebugEnabled()) {
log.debug("Initializing device management core bundle");
}
/* Initializing Device Management Configuration */
DeviceConfigurationManager.getInstance().initConfig();
DeviceManagementConfig config =
@ -114,15 +117,16 @@ public class DeviceManagementServiceComponent {
DataSourceConfig dsConfig = config.getDeviceManagementConfigRepository().getDataSourceConfig();
DeviceManagementDAOFactory.init(dsConfig);
DeviceManagementService deviceManagementProvider =
new DeviceManagementServiceProviderImpl(this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider);
/* Initializing license manager */
this.initLicenseManager();
/*Initialize Operation Manager*/
this.initOperationsManager();
/* Initializing app manager connector */
this.initAppManagerConnector();
DeviceManagementService deviceManagementProvider =
new DeviceManagementServiceProviderImpl(this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider);
OperationManagementDAOFactory.init(dsConfig);
/* If -Dsetup option enabled then create device management database schema */
@ -138,7 +142,7 @@ public class DeviceManagementServiceComponent {
}
synchronized (LOCK) {
for (DeviceManager deviceManager : deviceManagers) {
for (DeviceMgtService deviceManager : deviceManagers) {
this.registerDeviceManagementProvider(deviceManager);
}
this.isInitialized = true;
@ -169,21 +173,20 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setLicenseConfig(licenseConfig);
}
private void initOperationsManager() throws OperationManagementException {
OperationManager operationManager = new OperationManagerImpl();
DeviceManagementDataHolder.getInstance().setOperationManager(operationManager);
}
private void initAppManagerConnector() throws AppManagerConnectorException {
AppManagementConfigurationManager.getInstance().initConfig();
AppManagementConfig appConfig =
AppManagementConfigurationManager.getInstance().getAppManagementConfig();
DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig);
RemoteAppManagerConnector appManager = new RemoteAppManagerConnector(appConfig);
RemoteAppManagerConnector appManager = new RemoteAppManagerConnector(appConfig,this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setAppManager(appManager);
}
// private void initAPIProviders() throws DeviceManagementException {
// for (APIConfig config : APIPublisherConfig.getInstance().getApiConfigs()) {
// config.init();
// }
// }
private void registerServices(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("Registering OSGi service DeviceManagementServiceImpl");
@ -231,7 +234,7 @@ public class DeviceManagementServiceComponent {
}
}
private void registerDeviceManagementProvider(DeviceManager deviceManager) {
private void registerDeviceManagementProvider(DeviceMgtService deviceManager) {
try {
this.getPluginRepository().addDeviceManagementProvider(deviceManager);
} catch (DeviceManagementException e) {
@ -245,7 +248,7 @@ public class DeviceManagementServiceComponent {
*
* @param deviceManager An instance of DeviceManager
*/
protected void setDeviceManager(DeviceManager deviceManager) {
protected void setDeviceManager(DeviceMgtService deviceManager) {
if (log.isDebugEnabled()) {
log.debug("Setting Device Management Service Provider: '" + deviceManager.getProviderType() + "'");
}
@ -262,7 +265,7 @@ public class DeviceManagementServiceComponent {
*
* @param deviceManager An Instance of DeviceManager
*/
protected void unsetDeviceManager(DeviceManager deviceManager) {
protected void unsetDeviceManager(DeviceMgtService deviceManager) {
if (log.isDebugEnabled()) {
log.debug("Unsetting Device Management Service Provider : '" + deviceManager.getProviderType() + "'");
}

@ -18,6 +18,7 @@
package org.wso2.carbon.device.mgt.core.service;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnector;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManager;
import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManager;

@ -23,7 +23,7 @@ import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
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.core.internal.DeviceManagementDataHolder;
import org.wso2.carbon.device.mgt.core.operation.mgt.OperationManagerImpl;
import java.util.List;
public class DeviceManagementServiceImpl implements DeviceManagementService {

@ -22,6 +22,7 @@ import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService;
public class DeviceManagementRepositoryTests {
@ -34,7 +35,7 @@ public class DeviceManagementRepositoryTests {
@Test
public void testAddDeviceManagementService() {
DeviceManager sourceProvider = new TestDeviceManager();
DeviceMgtService sourceProvider = new TestDeviceManager();
try {
this.getRepository().addDeviceManagementProvider(sourceProvider);
} catch (DeviceManagementException e) {
@ -47,7 +48,7 @@ public class DeviceManagementRepositoryTests {
@Test(dependsOnMethods = "testAddDeviceManagementService")
public void testRemoveDeviceManagementService() {
DeviceManager sourceProvider = new TestDeviceManager();
DeviceMgtService sourceProvider = new TestDeviceManager();
try {
this.getRepository().removeDeviceManagementProvider(sourceProvider);
} catch (DeviceManagementException e) {

@ -17,15 +17,15 @@
*/
package org.wso2.carbon.device.mgt.core;
import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.FeatureManager;
import org.wso2.carbon.device.mgt.common.spi.DeviceManager;
import org.wso2.carbon.device.mgt.common.*;
import org.wso2.carbon.device.mgt.common.app.mgt.AppManagerConnectorException;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
import org.wso2.carbon.device.mgt.common.spi.DeviceMgtService;
import java.util.List;
public class TestDeviceManager implements DeviceManager {
public class TestDeviceManager implements DeviceMgtService {
public static final String DEVICE_TYPE_TEST = "Test";
@ -89,4 +89,9 @@ public class TestDeviceManager implements DeviceManager {
return false;
}
@Override
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws AppManagerConnectorException {
}
}

Loading…
Cancel
Save