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 7f136c04a22..576eec9a6ce 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 b70af47803d..0a722911e19 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 00000000000..150fddef098 --- /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 798d4ee58da..8d67accb132 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; }