From b4d749702258daf2bf50b19aac6799c27b8d895e Mon Sep 17 00:00:00 2001 From: "tcdlpds@gmail.com" Date: Sat, 16 Jan 2021 20:57:33 +0530 Subject: [PATCH] Modify DeviceTypeCommonService --- .../GenericSubscriptionDAOImpl.java | 2 +- .../core/impl/SubscriptionManagerImpl.java | 6 ++- .../common/general/QREnrollmentDetails.java | 37 +++++++++++++++++++ .../common/spi/DeviceTypeCommonService.java | 4 +- 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/general/QREnrollmentDetails.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java index 7f136c04a2..576eec9a6c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/subscription/GenericSubscriptionDAOImpl.java @@ -46,7 +46,7 @@ import java.util.Map; import java.util.StringJoiner; public class GenericSubscriptionDAOImpl extends AbstractDAOImpl implements SubscriptionDAO { - private static Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class); + private static final Log log = LogFactory.getLog(GenericSubscriptionDAOImpl.class); @Override public void addDeviceSubscription(String subscribedBy, List deviceIds, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index b70af47803..0a722911e1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -371,10 +371,12 @@ public class SubscriptionManagerImpl implements SubscriptionManager { List deviceSubscriptionDTOS = this.subscriptionDAO .getDeviceSubscriptions(applicationDTO.getApplicationReleaseDTOs().get(0).getId(), tenantId); + AtomicBoolean isAppSubscribable = new AtomicBoolean(true); for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) { - if (device.getId() == deviceSubscriptionDTO.getDeviceId() && !deviceSubscriptionDTO - .isUnsubscribed()) { + if (device.getId() == deviceSubscriptionDTO.getDeviceId() && + (Operation.Status.PENDING.toString().equals(deviceSubscriptionDTO.getStatus()) + || Operation.Status.IN_PROGRESS.toString().equals(deviceSubscriptionDTO.getStatus()))) { isAppSubscribable.set(false); break; } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/general/QREnrollmentDetails.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/general/QREnrollmentDetails.java new file mode 100644 index 0000000000..150fddef09 --- /dev/null +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/general/QREnrollmentDetails.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2021, 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.mgt.common.general; + +public class QREnrollmentDetails { + String ownershipType; + String username; + String enrollmentMode; + + public String getOwnershipType() { return ownershipType; } + + public void setOwnershipType(String ownershipType) { this.ownershipType = ownershipType; } + + public String getUsername() { return username; } + + public void setUsername(String username) { this.username = username; } + + public String getEnrollmentMode() { return enrollmentMode; } + + public void setEnrollmentMode(String enrollmentMode) { this.enrollmentMode = enrollmentMode; } +} diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceTypeCommonService.java b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceTypeCommonService.java index 798d4ee58d..8d67accb13 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceTypeCommonService.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.common/src/main/java/org/wso2/carbon/device/mgt/common/spi/DeviceTypeCommonService.java @@ -19,6 +19,7 @@ package org.wso2.carbon.device.mgt.common.spi; import org.wso2.carbon.device.mgt.common.QREnrollmentPayload; import org.wso2.carbon.device.mgt.common.exceptions.DeviceManagementException; +import org.wso2.carbon.device.mgt.common.general.QREnrollmentDetails; /** * This implementation populates device type plugin management service. @@ -28,9 +29,10 @@ public interface DeviceTypeCommonService { /** * To get Enrollment QR code against Ownership type * + * @param qrEnrollmentDetails QR Enrollment Details * @return {@link QREnrollmentPayload} object with payload to generate QR, invalidPlatformConfigs * and optionalPlatformConfigs. * @throws DeviceManagementException if error occurred while generating the QR String for Ownership */ - QREnrollmentPayload getEnrollmentQRCode(String ownershipType) throws DeviceManagementException; + QREnrollmentPayload getEnrollmentQRCode(QREnrollmentDetails qrEnrollmentDetails) throws DeviceManagementException; }