AppList update for device

revert-70aa11f8
manoj 9 years ago
parent 1aa22b29c5
commit 83698e7a99

@ -1,67 +0,0 @@
/*
* 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.device.mgt.core.app.mgt;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.mgt.common.*;
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.app.mgt.ApplicationManager;
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 java.util.List;
public class ApplicationManagementServiceImpl implements ApplicationManager {
private static final Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class);
@Override
public Application[] getApplications(String domain, int pageNumber,
int size) throws ApplicationManagementException {
return DeviceManagementDataHolder.getInstance().getAppManager().getApplications(domain, pageNumber, size);
}
@Override
public void updateApplicationStatus(
DeviceIdentifier deviceId, Application application, String status) throws ApplicationManagementException {
DeviceManagementDataHolder.getInstance().getAppManager().updateApplicationStatus(deviceId, application, status);
}
@Override
public String getApplicationStatus(DeviceIdentifier deviceId,
Application application) throws ApplicationManagementException {
return null;
}
@Override
public void installApplication(Operation operation, List<DeviceIdentifier> deviceIdentifiers)
throws ApplicationManagementException {
try {
DeviceManagementDataHolder.getInstance().getDeviceManagementProvider().addOperation(operation,
deviceIdentifiers);
} catch (OperationManagementException opMgtEx) {
String errorMsg = "Error occurred when add operations at install application";
log.error(errorMsg, opMgtEx);
throw new ApplicationManagementException();
}
DeviceManagementDataHolder.getInstance().getAppManager().installApplication(operation, deviceIdentifiers);
}
}

@ -26,6 +26,7 @@ import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.context.CarbonContext;
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.app.mgt.Application;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
@ -41,6 +42,7 @@ import org.wso2.carbon.device.mgt.core.config.identity.IdentityConfigurations;
import org.wso2.carbon.device.mgt.core.dao.DeviceDAO;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOException;
import org.wso2.carbon.device.mgt.core.dao.DeviceManagementDAOFactory;
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;
@ -52,7 +54,8 @@ import java.util.List;
* Implements Application Manager interface
*
*/
public class ApplicationManagerProviderServiceImpl implements ApplicationManagementProviderService {
public class ApplicationManagerProviderServiceImpl implements ApplicationManagementProviderService,
PluginInitializationListener {
private ConfigurationContext configCtx;
private ServiceAuthenticator authenticator;
@ -169,6 +172,25 @@ public class ApplicationManagerProviderServiceImpl implements ApplicationManagem
log.error(errorMsg+":"+deviceIdentifier.toString());
throw new ApplicationManagementException(errorMsg, deviceDaoEx);
}
}
@Override
public void registerDeviceManagementService(DeviceManagementService deviceManagementService) {
try {
pluginRepository.addDeviceManagementProvider(deviceManagementService);
} catch (DeviceManagementException e) {
log.error("Error occurred while registering device management plugin '" +
deviceManagementService.getProviderType() + "'", e);
}
}
@Override
public void unregisterDeviceManagementService(DeviceManagementService deviceManagementService) {
try {
pluginRepository.removeDeviceManagementProvider(deviceManagementService);
} catch (DeviceManagementException e) {
log.error("Error occurred while un-registering device management plugin '" +
deviceManagementService.getProviderType() + "'", e);
}
}
}

@ -25,7 +25,6 @@ import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
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;
@ -38,7 +37,6 @@ 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.api.mgt.ApplicationManagementProviderService;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagementServiceImpl;
import org.wso2.carbon.device.mgt.core.app.mgt.ApplicationManagerProviderServiceImpl;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfig;
import org.wso2.carbon.device.mgt.core.app.mgt.config.AppManagementConfigurationManager;
@ -120,8 +118,6 @@ public class DeviceManagementServiceComponent {
this.initLicenseManager();
/*Initialize Operation Manager*/
this.initOperationsManager();
/* Initializing app manager connector */
this.initAppManagerConnector();
OperationManagementDAOFactory.init(dsConfig);
/* If -Dsetup option enabled then create device management database schema */
@ -175,15 +171,6 @@ public class DeviceManagementServiceComponent {
DeviceManagementDataHolder.getInstance().setOperationManager(operationManager);
}
private void initAppManagerConnector() throws ApplicationManagementException {
AppManagementConfigurationManager.getInstance().initConfig();
AppManagementConfig appConfig =
AppManagementConfigurationManager.getInstance().getAppManagementConfig();
DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig);
ApplicationManagerProviderServiceImpl appManager = new ApplicationManagerProviderServiceImpl(appConfig, this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setAppManager(appManager);
}
private void registerServices(ComponentContext componentContext) {
if (log.isDebugEnabled()) {
log.debug("Registering OSGi service DeviceManagementProviderServiceImpl");
@ -201,7 +188,15 @@ public class DeviceManagementServiceComponent {
bundleContext.registerService(ServerStartupObserver.class, new APIRegistrationStartupObserver(), null);
/* Registering App Management service */
bundleContext.registerService(ApplicationManagementProviderService.class.getName(), new ApplicationManagementServiceImpl(), null);
try {
AppManagementConfigurationManager.getInstance().initConfig();
AppManagementConfig appConfig =
AppManagementConfigurationManager.getInstance().getAppManagementConfig();
bundleContext.registerService(ApplicationManagementProviderService.class.getName(),
new ApplicationManagerProviderServiceImpl(appConfig, pluginRepository), null);
} catch (ApplicationManagementException appMgtEx) {
log.error("Application management service not registered.");
}
}
private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {

Loading…
Cancel
Save