parent
0d19e742bd
commit
4fc14edf1e
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.common;
|
||||
|
||||
public class DeviceSubscriptionFilterCriteria {
|
||||
private String name;
|
||||
private String owner;
|
||||
private String deviceStatus;
|
||||
private String filteringDeviceSubscriptionStatus; // COMPLETE, PENDING ...
|
||||
private String triggeredBy;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getDeviceStatus() {
|
||||
return deviceStatus;
|
||||
}
|
||||
|
||||
public void setDeviceStatus(String deviceStatus) {
|
||||
this.deviceStatus = deviceStatus;
|
||||
}
|
||||
|
||||
public String getFilteringDeviceSubscriptionStatus() {
|
||||
return filteringDeviceSubscriptionStatus;
|
||||
}
|
||||
|
||||
public void setFilteringDeviceSubscriptionStatus(String filteringDeviceSubscriptionStatus) {
|
||||
this.filteringDeviceSubscriptionStatus = filteringDeviceSubscriptionStatus;
|
||||
}
|
||||
|
||||
public String getTriggeredBy() {
|
||||
return triggeredBy;
|
||||
}
|
||||
|
||||
public void setTriggeredBy(String triggeredBy) {
|
||||
this.triggeredBy = triggeredBy;
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.common;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class SubscriptionEntity {
|
||||
private String identity;
|
||||
private String subscribedBy;
|
||||
private Timestamp subscribedTimestamp;
|
||||
private boolean unsubscribed;
|
||||
private String unsubscribedBy;
|
||||
private Timestamp unsubscribedTimestamp;
|
||||
private int applicationReleaseId;
|
||||
|
||||
public String getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(String identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public String getSubscribedBy() {
|
||||
return subscribedBy;
|
||||
}
|
||||
|
||||
public void setSubscribedBy(String subscribedBy) {
|
||||
this.subscribedBy = subscribedBy;
|
||||
}
|
||||
|
||||
public Timestamp getSubscribedTimestamp() {
|
||||
return subscribedTimestamp;
|
||||
}
|
||||
|
||||
public void setSubscribedTimestamp(Timestamp subscribedTimestamp) {
|
||||
this.subscribedTimestamp = subscribedTimestamp;
|
||||
}
|
||||
|
||||
public boolean getUnsubscribed() {
|
||||
return unsubscribed;
|
||||
}
|
||||
|
||||
public void setUnsubscribed(boolean unsubscribed) {
|
||||
this.unsubscribed = unsubscribed;
|
||||
}
|
||||
|
||||
public String getUnsubscribedBy() {
|
||||
return unsubscribedBy;
|
||||
}
|
||||
|
||||
public void setUnsubscribedBy(String unsubscribedBy) {
|
||||
this.unsubscribedBy = unsubscribedBy;
|
||||
}
|
||||
|
||||
public Timestamp getUnsubscribedTimestamp() {
|
||||
return unsubscribedTimestamp;
|
||||
}
|
||||
|
||||
public void setUnsubscribedTimestamp(Timestamp unsubscribedTimestamp) {
|
||||
this.unsubscribedTimestamp = unsubscribedTimestamp;
|
||||
}
|
||||
|
||||
public int getApplicationReleaseId() {
|
||||
return applicationReleaseId;
|
||||
}
|
||||
|
||||
public void setApplicationReleaseId(int applicationReleaseId) {
|
||||
this.applicationReleaseId = applicationReleaseId;
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.common;
|
||||
|
||||
public class SubscriptionInfo {
|
||||
private String applicationUUID;
|
||||
private String subscriptionType;
|
||||
private String deviceSubscriptionStatus;
|
||||
private String identifier;
|
||||
private String subscriptionStatus;
|
||||
private DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria;
|
||||
|
||||
public String getApplicationUUID() {
|
||||
return applicationUUID;
|
||||
}
|
||||
|
||||
public void setApplicationUUID(String applicationUUID) {
|
||||
this.applicationUUID = applicationUUID;
|
||||
}
|
||||
|
||||
public String getSubscriptionType() {
|
||||
return subscriptionType;
|
||||
}
|
||||
|
||||
public void setSubscriptionType(String subscriptionType) {
|
||||
this.subscriptionType = subscriptionType;
|
||||
}
|
||||
|
||||
public String getDeviceSubscriptionStatus() {
|
||||
return deviceSubscriptionStatus;
|
||||
}
|
||||
|
||||
public void setDeviceSubscriptionStatus(String deviceSubscriptionStatus) {
|
||||
this.deviceSubscriptionStatus = deviceSubscriptionStatus;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public String getSubscriptionStatus() {
|
||||
return subscriptionStatus;
|
||||
}
|
||||
|
||||
public void setSubscriptionStatus(String subscriptionStatus) {
|
||||
this.subscriptionStatus = subscriptionStatus;
|
||||
}
|
||||
|
||||
public DeviceSubscriptionFilterCriteria getDeviceSubscriptionFilterCriteria() {
|
||||
return deviceSubscriptionFilterCriteria;
|
||||
}
|
||||
|
||||
public void setDeviceSubscriptionFilterCriteria(DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria) {
|
||||
this.deviceSubscriptionFilterCriteria = deviceSubscriptionFilterCriteria;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt;
|
||||
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SubscriptionManagementHelperUtil {
|
||||
public static List<DeviceSubscriptionData> getDeviceSubscriptionData(List<DeviceSubscriptionDTO> deviceSubscriptionDTOS,
|
||||
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria) {
|
||||
// todo: filtering
|
||||
for (DeviceSubscriptionDTO deviceSubscriptionDTO : deviceSubscriptionDTOS) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getDeviceSubscriptionStatus(SubscriptionInfo subscriptionInfo) {
|
||||
return getDeviceSubscriptionStatus(subscriptionInfo.getDeviceSubscriptionFilterCriteria().
|
||||
getFilteringDeviceSubscriptionStatus(), subscriptionInfo.getDeviceSubscriptionStatus());
|
||||
}
|
||||
|
||||
public static String getDeviceSubscriptionStatus(String deviceSubscriptionStatusFilter, String deviceSubscriptionStatus) {
|
||||
return (deviceSubscriptionStatusFilter != null && !deviceSubscriptionStatusFilter.isEmpty()) ?
|
||||
deviceSubscriptionStatusFilter : deviceSubscriptionStatus;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt;
|
||||
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.GroupBasedSubscriptionManagementHelperServiceImpl;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl.RoleBasedSubscriptionManagementHelperServiceImpl;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class SubscriptionManagementServiceProvider {
|
||||
private SubscriptionManagementServiceProvider() {}
|
||||
|
||||
private static class SubscriptionManagementProviderServiceHolder {
|
||||
private static final SubscriptionManagementServiceProvider INSTANCE = new SubscriptionManagementServiceProvider();
|
||||
}
|
||||
|
||||
public static SubscriptionManagementServiceProvider getInstance() {
|
||||
return SubscriptionManagementProviderServiceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public SubscriptionManagementHelperService getSubscriptionManagementHelperService(SubscriptionInfo subscriptionInfo) {
|
||||
return getSubscriptionManagementHelperService(subscriptionInfo.getSubscriptionType());
|
||||
}
|
||||
|
||||
private SubscriptionManagementHelperService getSubscriptionManagementHelperService(String subscriptionType) {
|
||||
if (Objects.equals(subscriptionType, "role")) return RoleBasedSubscriptionManagementHelperServiceImpl.getInstance();
|
||||
if (Objects.equals(subscriptionType, "group")) return GroupBasedSubscriptionManagementHelperServiceImpl.getInstance();
|
||||
throw new UnsupportedOperationException("Subscription type: " + subscriptionType + " not supports");
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DeviceBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService {
|
||||
@Override
|
||||
public List<DeviceSubscriptionData> getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubscriptionEntity> getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubscriptionStatistics() throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionFilterCriteria;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.ApplicationReleaseDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.exception.DBConnectionException;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.exception.ApplicationManagementDAOException;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.exception.NotFoundException;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.ConnectionManagerUtil;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.SubscriptionManagementHelperUtil;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService;
|
||||
import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.dto.GroupDetailsDTO;
|
||||
import io.entgra.device.mgt.core.device.mgt.core.service.GroupManagementProviderService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GroupBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService {
|
||||
private static final Log log = LogFactory.getLog(GroupBasedSubscriptionManagementHelperServiceImpl.class);
|
||||
private GroupBasedSubscriptionManagementHelperServiceImpl() {}
|
||||
private static class GroupBasedSubscriptionManagementHelperServiceImplHolder {
|
||||
private static final GroupBasedSubscriptionManagementHelperServiceImpl INSTANCE
|
||||
= new GroupBasedSubscriptionManagementHelperServiceImpl();
|
||||
}
|
||||
|
||||
public static GroupBasedSubscriptionManagementHelperServiceImpl getInstance() {
|
||||
return GroupBasedSubscriptionManagementHelperServiceImplHolder.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceSubscriptionData> getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus());
|
||||
List<DeviceSubscriptionDTO> deviceSubscriptionDTOS;
|
||||
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
|
||||
try {
|
||||
ConnectionManagerUtil.openDBConnection();
|
||||
ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.
|
||||
getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId);
|
||||
|
||||
if (applicationReleaseDTO == null) {
|
||||
String msg = "Couldn't find an application release for application release UUID: " +
|
||||
subscriptionInfo.getApplicationUUID();
|
||||
log.error(msg);
|
||||
throw new NotFoundException(msg);
|
||||
}
|
||||
|
||||
ApplicationDTO applicationDTO = this.applicationDAO.getAppWithRelatedRelease(subscriptionInfo.getApplicationUUID(), tenantId);
|
||||
if (applicationDTO == null) {
|
||||
String msg = "Application not found for the release UUID: " + subscriptionInfo.getApplicationUUID();
|
||||
log.error(msg);
|
||||
throw new NotFoundException(msg);
|
||||
}
|
||||
|
||||
String deviceSubscriptionStatus = SubscriptionManagementHelperUtil.getDeviceSubscriptionStatus(subscriptionInfo);
|
||||
DeviceSubscriptionFilterCriteria deviceSubscriptionFilterCriteria = subscriptionInfo.getDeviceSubscriptionFilterCriteria();
|
||||
|
||||
GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService();
|
||||
GroupDetailsDTO groupDetailsDTO = groupManagementProviderService.getGroupDetailsWithDevices(subscriptionInfo.getIdentifier(),
|
||||
applicationDTO.getDeviceTypeId(), deviceSubscriptionFilterCriteria.getOwner(), deviceSubscriptionFilterCriteria.getName(),
|
||||
deviceSubscriptionFilterCriteria.getDeviceStatus(), offset, limit);
|
||||
|
||||
List<Integer> deviceIdsOwnByGroup = groupDetailsDTO.getDeviceIds();
|
||||
|
||||
if (Objects.equals("NEW", deviceSubscriptionStatus)) {
|
||||
|
||||
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
||||
isUnsubscribe, tenantId, deviceIdsOwnByGroup, null,
|
||||
subscriptionInfo.getSubscriptionType(), deviceSubscriptionFilterCriteria.getTriggeredBy(),
|
||||
null, limit, offset);
|
||||
for (DeviceSubscriptionDTO deviceSubscriptionDTO: deviceSubscriptionDTOS) {
|
||||
deviceIdsOwnByGroup.remove(deviceSubscriptionDTO.getDeviceId());
|
||||
}
|
||||
}
|
||||
|
||||
deviceSubscriptionDTOS = subscriptionDAO.getSubscriptionDetailsByDeviceIds(applicationReleaseDTO.getId(),
|
||||
isUnsubscribe, tenantId, deviceIdsOwnByGroup, deviceSubscriptionStatus, subscriptionInfo.getSubscriptionType(),
|
||||
deviceSubscriptionFilterCriteria.getTriggeredBy(), deviceSubscriptionStatus, limit, offset);
|
||||
|
||||
} catch (GroupManagementException e) {
|
||||
String msg = "Error encountered while retrieving group details for group: " + subscriptionInfo.getIdentifier();
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} catch (ApplicationManagementDAOException | DBConnectionException e) {
|
||||
String msg = "Error encountered while connecting to the database";
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} finally {
|
||||
ConnectionManagerUtil.closeDBConnection();
|
||||
}
|
||||
|
||||
return SubscriptionManagementHelperUtil.getDeviceSubscriptionData(deviceSubscriptionDTOS,
|
||||
subscriptionInfo.getDeviceSubscriptionFilterCriteria());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubscriptionEntity> getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset)
|
||||
throws ApplicationManagementException {
|
||||
final boolean isUnsubscribe = Objects.equals("unsubscribe", subscriptionInfo.getSubscriptionStatus());
|
||||
final int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
|
||||
try {
|
||||
ConnectionManagerUtil.openDBConnection();
|
||||
ApplicationReleaseDTO applicationReleaseDTO = applicationReleaseDAO.
|
||||
getReleaseByUUID(subscriptionInfo.getApplicationUUID(), tenantId);
|
||||
if (applicationReleaseDTO == null) {
|
||||
String msg = "Couldn't find an application release for application release UUID: " +
|
||||
subscriptionInfo.getApplicationUUID();
|
||||
log.error(msg);
|
||||
throw new NotFoundException(msg);
|
||||
}
|
||||
return subscriptionDAO.
|
||||
getGroupsSubscriptionDetailsByAppReleaseID(applicationReleaseDTO.getId(), isUnsubscribe, tenantId, offset, limit);
|
||||
} catch (DBConnectionException | ApplicationManagementDAOException e) {
|
||||
String msg = "Error encountered while connecting to the database";
|
||||
log.error(msg, e);
|
||||
throw new ApplicationManagementException(msg, e);
|
||||
} finally {
|
||||
ConnectionManagerUtil.closeDBConnection();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubscriptionStatistics() throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
81
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/RoleBasedSubscriptionManagementHelperServiceImpl.java → components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java
81
components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/RoleBasedSubscriptionManagementHelperServiceImpl.java → components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/src/main/java/io/entgra/device/mgt/core/application/mgt/core/util/subscription/mgt/impl/RoleBasedSubscriptionManagementHelperServiceImpl.java
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2018 - 2024, 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 io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.impl;
|
||||
|
||||
import io.entgra.device.mgt.core.application.mgt.common.DeviceSubscriptionData;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionEntity;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.SubscriptionInfo;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.DeviceSubscriptionDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.dto.SubscriptionsDTO;
|
||||
import io.entgra.device.mgt.core.application.mgt.common.exception.ApplicationManagementException;
|
||||
import io.entgra.device.mgt.core.application.mgt.core.util.subscription.mgt.service.SubscriptionManagementHelperService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class UserBasedSubscriptionManagementHelperServiceImpl implements SubscriptionManagementHelperService {
|
||||
@Override
|
||||
public List<DeviceSubscriptionData> getStatusBaseSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubscriptionEntity> getSubscriptions(SubscriptionInfo subscriptionInfo, int limit, int offset) throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubscriptionStatistics() throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in new issue