mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Improve app subscription functionality
Further integrate app management component with device mgt
This commit is contained in:
parent
dd707b98f2
commit
e41742b777
@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, 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.application.mgt.common;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DeviceConnectorException;
|
|
||||||
|
|
||||||
public class AndroidApplication {
|
|
||||||
private String type;
|
|
||||||
private String appIdentifier;
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 760343716452548282L;
|
|
||||||
|
|
||||||
public String getAppIdentifier() {
|
|
||||||
return appIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAppIdentifier(String appIdentifier) {
|
|
||||||
this.appIdentifier = appIdentifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setType(String type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toJSON() throws DeviceConnectorException {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
return gson.toJson(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.common;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Entgra (Pvt) Ltd. 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ApplicationReleaseArtifactPaths {
|
|
||||||
|
|
||||||
private String installerPath;
|
|
||||||
private String iconPath;
|
|
||||||
private String bannerPath;
|
|
||||||
private List<String> screenshotPaths;
|
|
||||||
|
|
||||||
public String getInstallerPath() { return installerPath; }
|
|
||||||
|
|
||||||
public void setInstallerPath(String installerPath) { this.installerPath = installerPath; }
|
|
||||||
|
|
||||||
public String getIconPath() { return iconPath; }
|
|
||||||
|
|
||||||
public void setIconPath(String iconPath) { this.iconPath = iconPath; }
|
|
||||||
|
|
||||||
public String getBannerPath() { return bannerPath; }
|
|
||||||
|
|
||||||
public void setBannerPath(String bannerPath) { this.bannerPath = bannerPath; }
|
|
||||||
|
|
||||||
public List<String> getScreenshotPaths() { return screenshotPaths; }
|
|
||||||
|
|
||||||
public void setScreenshotPaths(List<String> screenshotPaths) { this.screenshotPaths = screenshotPaths; }
|
|
||||||
}
|
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Entgra (Pvt) Ltd. 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.application.mgt.common;
|
||||||
|
|
||||||
|
public enum SubAction {
|
||||||
|
INSTALL, UNINSTALL
|
||||||
|
}
|
||||||
@ -39,8 +39,8 @@ public interface SubscriptionManager {
|
|||||||
ApplicationInstallResponse installApplicationForDevices(String applicationUUID, List<DeviceIdentifier> deviceList)
|
ApplicationInstallResponse installApplicationForDevices(String applicationUUID, List<DeviceIdentifier> deviceList)
|
||||||
throws ApplicationManagementException;
|
throws ApplicationManagementException;
|
||||||
|
|
||||||
ApplicationInstallResponse addBulkApInstallation(String applicationUUID, List<String> subscriberList,
|
<T> ApplicationInstallResponse performBulkAppInstallation(String applicationUUID, List<T> params, String subType)
|
||||||
String subType) throws ApplicationManagementException;
|
throws ApplicationManagementException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To install an application to given list of users.
|
* To install an application to given list of users.
|
||||||
|
|||||||
@ -619,7 +619,7 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
|
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException {
|
||||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
|
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||||
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||||
ApplicationList applicationList = new ApplicationList();
|
ApplicationList applicationList = new ApplicationList();
|
||||||
List<ApplicationDTO> appDTOs;
|
List<ApplicationDTO> appDTOs;
|
||||||
|
|||||||
@ -24,6 +24,8 @@ import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|||||||
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
import org.wso2.carbon.device.application.mgt.common.AppOperation;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse;
|
||||||
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.DeviceTypes;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.SubAction;
|
||||||
import org.wso2.carbon.device.application.mgt.common.SubsciptionType;
|
import org.wso2.carbon.device.application.mgt.common.SubsciptionType;
|
||||||
import org.wso2.carbon.device.application.mgt.common.SubscribingDeviceIdHolder;
|
import org.wso2.carbon.device.application.mgt.common.SubscribingDeviceIdHolder;
|
||||||
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
||||||
@ -65,6 +67,7 @@ import org.wso2.carbon.device.mgt.core.service.GroupManagementProviderService;
|
|||||||
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
import org.wso2.carbon.device.mgt.core.util.DeviceManagerUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -87,7 +90,8 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ApplicationInstallResponse installApplicationForDevices(String applicationUUID,
|
@Override
|
||||||
|
public ApplicationInstallResponse installApplicationForDevices(String applicationUUID,
|
||||||
List<DeviceIdentifier> deviceIdentifiers) throws ApplicationManagementException {
|
List<DeviceIdentifier> deviceIdentifiers) throws ApplicationManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Install application which has UUID: " + applicationUUID + " to " + deviceIdentifiers.size()
|
log.debug("Install application which has UUID: " + applicationUUID + " to " + deviceIdentifiers.size()
|
||||||
@ -99,102 +103,94 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new BadRequestException(msg);
|
throw new BadRequestException(msg);
|
||||||
}
|
}
|
||||||
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
|
||||||
.getDeviceManagementProviderService();
|
|
||||||
ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID);
|
ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID);
|
||||||
DeviceIDHolder filteredDeviceHolder = filterDeviceIdentifiers(applicationDTO, deviceIdentifiers);
|
DeviceIDHolder filteredDeviceHolder = filterDeviceIdentifiers(applicationDTO, deviceIdentifiers);
|
||||||
List<DeviceIdentifier> errorDeviceIdentifiers = filteredDeviceHolder.getErrorDeviceIdList();
|
List<DeviceIdentifier> errorDeviceIdentifiers = filteredDeviceHolder.getErrorDeviceIdList();
|
||||||
List<Device> filteredDeviceObjs = new ArrayList<>();
|
ApplicationInstallResponse applicationInstallResponse = performBulkAppInstallation(applicationUUID,
|
||||||
|
filteredDeviceHolder.getValidDeviceIDList(), SubsciptionType.DEVICE.toString());
|
||||||
//getting device objects by using device identifiers
|
|
||||||
for (DeviceIdentifier deviceIdentifier : filteredDeviceHolder.getValidDeviceIDList()) {
|
|
||||||
try {
|
|
||||||
Device device = deviceManagementProviderService.getDevice(deviceIdentifier, false);
|
|
||||||
if (device == null) {
|
|
||||||
String msg = "Couldn't found an device for device identifier " + deviceIdentifier.getId()
|
|
||||||
+ " and device type: " + deviceIdentifier.getType();
|
|
||||||
log.warn(msg);
|
|
||||||
errorDeviceIdentifiers.add(deviceIdentifier);
|
|
||||||
} else {
|
|
||||||
filteredDeviceObjs.add(device);
|
|
||||||
}
|
|
||||||
} catch (DeviceManagementException e) {
|
|
||||||
String msg = "Error occurred when getting device data for device identifier " + deviceIdentifier.getId()
|
|
||||||
+ " and device type " + deviceIdentifier.getType();
|
|
||||||
log.warn(msg);
|
|
||||||
errorDeviceIdentifiers.add(deviceIdentifier);
|
|
||||||
throw new ApplicationManagementException(msg, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
|
||||||
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
||||||
String deviceTypeName = deviceType.getName();
|
|
||||||
ApplicationInstallResponse applicationInstallResponse = installToDevices(deviceTypeName, filteredDeviceObjs,
|
|
||||||
applicationDTO, SubsciptionType.DEVICE.toString(), null);
|
|
||||||
applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers);
|
|
||||||
return applicationInstallResponse;
|
|
||||||
} else {
|
|
||||||
//todo improve thos
|
|
||||||
ApplicationInstallResponse applicationInstallResponse = installToDevices(null, filteredDeviceObjs,
|
|
||||||
applicationDTO, SubsciptionType.DEVICE.toString(), null);
|
|
||||||
applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers);
|
applicationInstallResponse.setErrorDevices(errorDeviceIdentifiers);
|
||||||
return applicationInstallResponse;
|
return applicationInstallResponse;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApplicationInstallResponse addBulkApInstallation(String applicationUUID, List<String> subscriberList,
|
public <T> ApplicationInstallResponse performBulkAppInstallation(String applicationUUID, List<T> params,
|
||||||
String subType) throws ApplicationManagementException {
|
String subType) throws ApplicationManagementException {
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("Install application release which has UUID " + applicationUUID + " to " + subscriberList.size()
|
log.debug("Install application release which has UUID " + applicationUUID + " to " + params.size()
|
||||||
+ " users.");
|
+ " users.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (subscriberList.isEmpty()) {
|
if (params.isEmpty()) {
|
||||||
String msg = "In order to install application release which has UUID " + applicationUUID + ", you shou"
|
String msg = "In order to install application release which has UUID " + applicationUUID + ", you should"
|
||||||
+ "ld provide list of subscribers. But found an empty list of users.";
|
+ " provide list of subscribers. But found an empty list of users.";
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new BadRequestException(msg);
|
throw new BadRequestException(msg);
|
||||||
}
|
}
|
||||||
if (SubsciptionType.USER.toString().equals(subType) && !SubsciptionType.ROLE.toString().equals(subType)
|
|
||||||
&& SubsciptionType.GROUP.toString().equals(subType)) {
|
boolean isValidSubType = Arrays.stream(SubsciptionType.values())
|
||||||
|
.anyMatch(sub -> sub.name().equalsIgnoreCase(subType));
|
||||||
|
if (!isValidSubType) {
|
||||||
String msg = "Found invalid subscription type to install application release witch has UUID: "
|
String msg = "Found invalid subscription type to install application release witch has UUID: "
|
||||||
+ applicationUUID + ". Subscription type is " + subType;
|
+ applicationUUID + ". Subscription type is " + subType;
|
||||||
log.error(msg);
|
log.error(msg);
|
||||||
throw new BadRequestException(msg);
|
throw new BadRequestException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID);
|
|
||||||
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
||||||
.getDeviceManagementProviderService();
|
.getDeviceManagementProviderService();
|
||||||
GroupManagementProviderService groupManagementProviderService = HelperUtil
|
GroupManagementProviderService groupManagementProviderService = HelperUtil
|
||||||
.getGroupManagementProviderService();
|
.getGroupManagementProviderService();
|
||||||
List<Device> filteredDevices = new ArrayList<>();
|
List<Device> filteredDevices = new ArrayList<>();
|
||||||
List<Device> subscriberDevices = new ArrayList<>();
|
List<Device> devices = new ArrayList<>();
|
||||||
for (String subscriber : subscriberList) {
|
List<String> subscribers = new ArrayList<>();
|
||||||
if (SubsciptionType.USER.toString().equals(subType)) {
|
|
||||||
subscriberDevices.addAll(deviceManagementProviderService.getDevicesOfUser(subscriber));
|
ApplicationDTO applicationDTO = getApplicationDTO(applicationUUID);
|
||||||
|
|
||||||
|
if (SubsciptionType.DEVICE.toString().equals(subType)) {
|
||||||
|
for (T param : params) {
|
||||||
|
DeviceIdentifier deviceIdentifier = (DeviceIdentifier) param;
|
||||||
|
devices.add(deviceManagementProviderService.getDevice(deviceIdentifier, false));
|
||||||
|
}
|
||||||
|
} else if (SubsciptionType.USER.toString().equals(subType)) {
|
||||||
|
for (T param : params) {
|
||||||
|
String username = (String) param;
|
||||||
|
subscribers.add(username);
|
||||||
|
devices.addAll(deviceManagementProviderService.getDevicesOfUser(username));
|
||||||
|
}
|
||||||
} else if (SubsciptionType.ROLE.toString().equals(subType)) {
|
} else if (SubsciptionType.ROLE.toString().equals(subType)) {
|
||||||
subscriberDevices.addAll(deviceManagementProviderService.getAllDevicesOfRole(subscriber));
|
for (T param : params) {
|
||||||
|
String roleName = (String) param;
|
||||||
|
subscribers.add(roleName);
|
||||||
|
devices.addAll(deviceManagementProviderService.getAllDevicesOfRole(roleName));
|
||||||
|
}
|
||||||
} else if (SubsciptionType.GROUP.toString().equals(subType)) {
|
} else if (SubsciptionType.GROUP.toString().equals(subType)) {
|
||||||
subscriberDevices.addAll(groupManagementProviderService.getAllDevicesOfGroup(subscriber));
|
for (T param : params) {
|
||||||
|
String groupName = (String) param;
|
||||||
|
subscribers.add(groupName);
|
||||||
|
devices.addAll(groupManagementProviderService.getAllDevicesOfGroup(groupName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
||||||
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
DeviceType deviceType = APIUtil.getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
||||||
String deviceTypeName = deviceType.getName();
|
String deviceTypeName = deviceType.getName();
|
||||||
for (Device device : subscriberDevices) {
|
for (Device device : devices) {
|
||||||
if (deviceTypeName.equals(device.getType())) {
|
if (deviceTypeName.equals(device.getType())) {
|
||||||
filteredDevices.add(device);
|
filteredDevices.add(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, subscriberList);
|
// if (SubsciptionType.DEVICE.toString().equals(subType)) {
|
||||||
|
// return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, null);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
return installToDevices(deviceTypeName, filteredDevices, applicationDTO, subType, subscribers);
|
||||||
} else {
|
} else {
|
||||||
//todo improve this
|
//todo improve this
|
||||||
return installToDevices(null, subscriberDevices, applicationDTO, subType, subscriberList);
|
// if (SubsciptionType.DEVICE.toString().equals(subType)) {
|
||||||
|
// return installToDevices(null, filteredDevices, applicationDTO, subType, null);
|
||||||
|
// }
|
||||||
|
return installToDevices(null, devices, applicationDTO, subType, subscribers);
|
||||||
}
|
}
|
||||||
} catch (DeviceManagementException e) {
|
} catch (DeviceManagementException e) {
|
||||||
String msg = "Error occurred while getting devices of given users or given roles.";
|
String msg = "Error occurred while getting devices of given users or given roles.";
|
||||||
@ -207,6 +203,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<DeviceIdentifier> uninstallApplication(String applicationUUID,
|
||||||
|
List<DeviceIdentifier> deviceList) throws ApplicationManagementException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private ApplicationInstallResponse installToDevices(String deviceType, List<Device> devices,
|
private ApplicationInstallResponse installToDevices(String deviceType, List<Device> devices,
|
||||||
ApplicationDTO applicationDTO, String subType, List<String> subscribers)
|
ApplicationDTO applicationDTO, String subType, List<String> subscribers)
|
||||||
throws ApplicationManagementException {
|
throws ApplicationManagementException {
|
||||||
@ -566,17 +568,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<DeviceIdentifier> uninstallApplication(String applicationUUID,
|
|
||||||
List<DeviceIdentifier> deviceList) throws ApplicationManagementException {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Activity addAppInstallOperationToDevices(ApplicationDTO application,
|
private Activity addAppInstallOperationToDevices(ApplicationDTO application,
|
||||||
List<DeviceIdentifier> deviceIdentifierList, String deviceType) throws ApplicationManagementException {
|
List<DeviceIdentifier> deviceIdentifierList, String deviceType) throws ApplicationManagementException {
|
||||||
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
DeviceManagementProviderService deviceManagementProviderService = HelperUtil
|
||||||
.getDeviceManagementProviderService();
|
.getDeviceManagementProviderService();
|
||||||
try {
|
try {
|
||||||
Operation operation = generateOperationPayloadByDeviceType(deviceType, application);
|
Operation operation = generateOperationPayloadByDeviceType(deviceType, application, null);
|
||||||
//todo refactor add operation code to get successful operations
|
//todo refactor add operation code to get successful operations
|
||||||
return deviceManagementProviderService.addOperation(deviceType, operation, deviceIdentifierList);
|
return deviceManagementProviderService.addOperation(deviceType, operation, deviceIdentifierList);
|
||||||
} catch (OperationManagementException e) {
|
} catch (OperationManagementException e) {
|
||||||
@ -602,7 +599,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
.collect(Collectors.groupingBy(DeviceIdentifier::getType));
|
.collect(Collectors.groupingBy(DeviceIdentifier::getType));
|
||||||
|
|
||||||
for (Map.Entry<String, List<DeviceIdentifier>> entry : deviceTypeIdentifierMap.entrySet()) {
|
for (Map.Entry<String, List<DeviceIdentifier>> entry : deviceTypeIdentifierMap.entrySet()) {
|
||||||
Operation operation = generateOperationPayloadByDeviceType(entry.getKey(), application);
|
Operation operation = generateOperationPayloadByDeviceType(entry.getKey(), application, null);
|
||||||
try {
|
try {
|
||||||
Activity activity = deviceManagementProviderService
|
Activity activity = deviceManagementProviderService
|
||||||
.addOperation(entry.getKey(), operation, entry.getValue());
|
.addOperation(entry.getKey(), operation, entry.getValue());
|
||||||
@ -643,11 +640,57 @@ public class SubscriptionManagerImpl implements SubscriptionManager {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationDTO application) {
|
private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationDTO application, String action) {
|
||||||
ProfileOperation operation = new ProfileOperation();
|
ProfileOperation operation = new ProfileOperation();
|
||||||
operation.setCode(INSTALL_APPLICATION);
|
operation.setCode(INSTALL_APPLICATION);
|
||||||
operation.setType(Operation.Type.PROFILE);
|
operation.setType(Operation.Type.PROFILE);
|
||||||
|
|
||||||
|
// if (DeviceTypes.ANDROID.toString().equalsIgnoreCase(deviceType)) {
|
||||||
|
// if (ApplicationType.ENTERPRISE.toString().equalsIgnoreCase(application.getType())) {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
// } else if (ApplicationType.PUBLIC.toString().equalsIgnoreCase(application.getType())) {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// } else if (ApplicationType.WEB_CLIP.toString().equalsIgnoreCase(application.getType())) {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// } else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) {
|
||||||
|
// if (ApplicationType.ENTERPRISE.toString().equalsIgnoreCase(application.getType())) {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
// } else if (ApplicationType.PUBLIC.toString().equalsIgnoreCase(application.getType())) {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
// } else if (ApplicationType.WEB_CLIP.toString().equalsIgnoreCase())
|
||||||
|
// application.getType() {
|
||||||
|
// if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// } else if (SubAction.UNINSTALL.toString().equalsIgnoreCase(action)) {
|
||||||
|
// log.error("aaaa");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
//todo: generate operation payload correctly for all types of devices.
|
//todo: generate operation payload correctly for all types of devices.
|
||||||
operation.setPayLoad(
|
operation.setPayLoad(
|
||||||
"{'type':'enterprise', 'url':'" + application.getApplicationReleaseDTOs().get(0).getInstallerName()
|
"{'type':'enterprise', 'url':'" + application.getApplicationReleaseDTOs().get(0).getInstallerName()
|
||||||
|
|||||||
@ -129,7 +129,7 @@ public interface SubscriptionManagementAPI {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("/install/{uuid}/{subType}")
|
@Path("/install/{uuid}/{subType}/{action}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
@ApiOperation(
|
@ApiOperation(
|
||||||
@ -149,7 +149,7 @@ public interface SubscriptionManagementAPI {
|
|||||||
value = {
|
value = {
|
||||||
|
|
||||||
})
|
})
|
||||||
Response addBulkAppInstalltion(
|
Response performBulkAppInstallation(
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "uuid",
|
name = "uuid",
|
||||||
value = "The application release UUID",
|
value = "The application release UUID",
|
||||||
@ -162,6 +162,12 @@ public interface SubscriptionManagementAPI {
|
|||||||
required = true
|
required = true
|
||||||
)
|
)
|
||||||
@PathParam("subType") String subType,
|
@PathParam("subType") String subType,
|
||||||
|
@ApiParam(
|
||||||
|
name = "action",
|
||||||
|
value = "Performing action.",
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
@PathParam("action") String action,
|
||||||
@ApiParam(
|
@ApiParam(
|
||||||
name = "subscribers",
|
name = "subscribers",
|
||||||
value = "Subscriber list of the application release.",
|
value = "Subscriber list of the application release.",
|
||||||
|
|||||||
@ -49,7 +49,7 @@ import javax.ws.rs.core.Response;
|
|||||||
@SwaggerDefinition(
|
@SwaggerDefinition(
|
||||||
info = @Info(
|
info = @Info(
|
||||||
version = "1.0.0",
|
version = "1.0.0",
|
||||||
title = "Admin Review Management Admin Service",
|
title = "Review Management Admin Service",
|
||||||
extensions = {
|
extensions = {
|
||||||
@Extension(properties = {
|
@Extension(properties = {
|
||||||
@ExtensionProperty(name = "name", value = "ReviewManagementAdminService"),
|
@ExtensionProperty(name = "name", value = "ReviewManagementAdminService"),
|
||||||
|
|||||||
@ -80,14 +80,15 @@ public class SubscriptionManagementAPIImpl implements SubscriptionManagementAPI{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@POST
|
@POST
|
||||||
@Path("/install/{uuid}/{subType}")
|
@Path("/install/{uuid}/{subType}/{action}")
|
||||||
public Response addBulkAppInstalltion(
|
public Response performBulkAppInstallation(
|
||||||
@PathParam("uuid") String uuid,
|
@PathParam("uuid") String uuid,
|
||||||
@PathParam("uuid") String subType,
|
@PathParam("subType") String subType,
|
||||||
|
@PathParam("action") String sction,
|
||||||
@Valid List<String> subscribers) {
|
@Valid List<String> subscribers) {
|
||||||
try {
|
try {
|
||||||
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
SubscriptionManager subscriptionManager = APIUtil.getSubscriptionManager();
|
||||||
ApplicationInstallResponse response = subscriptionManager.addBulkApInstallation(uuid, subscribers, subType);
|
ApplicationInstallResponse response = subscriptionManager.performBulkAppInstallation(uuid, subscribers, subType);
|
||||||
return Response.status(Response.Status.OK).entity(response).build();
|
return Response.status(Response.Status.OK).entity(response).build();
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
String msg = "Couldn't found an application release for UUID: " + uuid + ". Hence, verify the payload";
|
String msg = "Couldn't found an application release for UUID: " + uuid + ". Hence, verify the payload";
|
||||||
|
|||||||
@ -18,12 +18,12 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.util;
|
package org.wso2.carbon.device.mgt.jaxrs.util;
|
||||||
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp;
|
import org.wso2.carbon.device.mgt.common.app.mgt.android.AppStoreApplication;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.android.AppStoreApplication;
|
import org.wso2.carbon.device.mgt.common.app.mgt.android.EnterpriseApplication;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.android.EnterpriseApplication;
|
import org.wso2.carbon.device.mgt.common.app.mgt.android.WebApplication;
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.android.WebApplication;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException;
|
import org.wso2.carbon.device.mgt.jaxrs.exception.UnknownApplicationTypeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -18,11 +18,11 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.util;
|
package org.wso2.carbon.device.mgt.jaxrs.util;
|
||||||
|
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.ios.AppStoreApplication;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.ios.EnterpriseApplication;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.ios.RemoveApplication;
|
||||||
|
import org.wso2.carbon.device.mgt.common.app.mgt.ios.WebClip;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp;
|
import org.wso2.carbon.device.mgt.jaxrs.beans.MobileApp;
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ios.AppStoreApplication;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ios.EnterpriseApplication;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ios.RemoveApplication;
|
|
||||||
import org.wso2.carbon.device.mgt.jaxrs.beans.ios.WebClip;
|
|
||||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||||
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
import org.wso2.carbon.device.mgt.core.operation.mgt.ProfileOperation;
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
package org.wso2.carbon.device.mgt.common.app.mgt.android;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
package org.wso2.carbon.device.mgt.common.app.mgt.android;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.android;
|
package org.wso2.carbon.device.mgt.common.app.mgt.android;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.ios;
|
package org.wso2.carbon.device.mgt.common.app.mgt.ios;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.ios;
|
package org.wso2.carbon.device.mgt.common.app.mgt.ios;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.ios;
|
package org.wso2.carbon.device.mgt.common.app.mgt.ios;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.wso2.carbon.device.mgt.jaxrs.beans.ios;
|
package org.wso2.carbon.device.mgt.common.app.mgt.ios;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user