diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java index d847fd8f9b..b7cd91f34e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/spi/DeviceManagementService.java @@ -26,6 +26,7 @@ import io.entgra.device.mgt.core.device.mgt.common.license.mgt.License; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringManager; import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; /** @@ -65,4 +66,6 @@ public interface DeviceManagementService { DeviceEnrollmentInvitationDetails getDeviceEnrollmentInvitationDetails(); License getLicenseConfig(); + + DeviceTypeMetaDefinition getDeviceTypeMetaDefinition(); } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java new file mode 100644 index 0000000000..4084b93245 --- /dev/null +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/type/mgt/DeviceTypeMetaDetails.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018 - 2023, 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.device.mgt.common.type.mgt; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlType; + +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "DeviceTypeMetaDetails", propOrder = { + "storeVisibilityEnabled" +}) +public class DeviceTypeMetaDetails { + + @XmlElement(name = "storeVisibilityEnabled") + private boolean storeVisibilityEnabled; + + public boolean isStoreVisibilityEnabled() { + return storeVisibilityEnabled; + } + + public void setStoreVisibilityEnabled(boolean storeVisibilityEnabled) { + this.storeVisibilityEnabled = storeVisibilityEnabled; + } +} + + diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java index c0c9dbddb1..6ad7b53c74 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/DeviceManagementPluginRepository.java @@ -85,7 +85,7 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis if (isInitiated) { /* Initializing Device Management Service Provider */ provider.init(); - DeviceTypeMetaDefinition deviceTypeDefinition = null; + DeviceTypeMetaDefinition deviceTypeDefinition; if (provider instanceof DeviceTypeDefinitionProvider) { DeviceTypeServiceIdentifier deviceTypeIdentifier = new DeviceTypeServiceIdentifier( provider.getType()); @@ -102,6 +102,8 @@ public class DeviceManagementPluginRepository implements DeviceManagerStartupLis if (existingProvider != null) { removeDeviceManagementProvider(provider); } + } else { + deviceTypeDefinition = provider.getDeviceTypeMetaDefinition(); } DeviceManagerUtil.registerDeviceType(deviceType, tenantId, isSharedWithAllTenants, deviceTypeDefinition); diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java index 516159d597..0df3bdad7e 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/test/java/io/entgra/device/mgt/core/device/mgt/core/TestDeviceManagementService.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -135,4 +136,9 @@ public class TestDeviceManagementService implements DeviceManagementService { } @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java index 049c5e6cdf..b357c94cca 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/DeviceTypeManagerService.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDetails; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.CarbonContext; @@ -38,6 +39,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.ConfigProperties; import io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config.DeviceStatusTaskConfiguration; @@ -81,6 +83,7 @@ public class DeviceTypeManagerService implements DeviceManagementService { private DeviceTypePlatformDetails deviceTypePlatformDetails; private DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails; private GeneralConfig generalConfig; + private DeviceTypeMetaDefinition deviceTypeMetaDefinition; private boolean isRegistryBasedConfigs = false; private boolean isScheduled = false; private String notifierType; @@ -108,6 +111,8 @@ public class DeviceTypeManagerService implements DeviceManagementService { this.setDeviceEnrollmentInvitationDetails(deviceTypeConfiguration); this.licenseConfig = new License(); this.setLicenseConfig(deviceTypeConfiguration); + this.deviceTypeMetaDefinition = new DeviceTypeMetaDefinition(); + this.setDeviceTypeMetaDefinition(deviceTypeConfiguration); } @Override @@ -261,6 +266,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { return licenseConfig; } + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return deviceTypeMetaDefinition; + } + private void setProvisioningConfig(String tenantDomain, DeviceTypeConfiguration deviceTypeConfiguration) { if (deviceTypeConfiguration.getProvisioningConfig() != null) { boolean sharedWithAllTenants = deviceTypeConfiguration.getProvisioningConfig().isSharedWithAllTenants(); @@ -388,4 +398,11 @@ public class DeviceTypeManagerService implements DeviceManagementService { licenseConfig.setText(license.getText()); } } + + public void setDeviceTypeMetaDefinition(DeviceTypeConfiguration deviceTypeConfiguration) { + DeviceTypeMetaDetails deviceTypeMetaDefinitions = deviceTypeConfiguration.getDeviceTypeMetaDetails(); + if (deviceTypeMetaDefinitions != null) { + deviceTypeMetaDefinition.setStoreVisibilityEnabled(deviceTypeMetaDefinitions.isStoreVisibilityEnabled()); + } + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java index cf94ccc235..3d8d95b1bf 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/main/java/io/entgra/device/mgt/core/device/mgt/extensions/device/type/template/config/DeviceTypeConfiguration.java @@ -18,6 +18,7 @@ package io.entgra.device.mgt.core.device.mgt.extensions.device.type.template.config; import io.entgra.device.mgt.core.device.mgt.common.invitation.mgt.DeviceEnrollmentInvitationDetails; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDetails; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import javax.xml.bind.annotation.XmlElement; @@ -93,6 +94,8 @@ public class DeviceTypeConfiguration { protected DeviceTypePlatformDetails deviceTypePlatformDetails; @XmlElement(name = "DeviceEnrollmentInvitationDetails", required = true) protected DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails; + @XmlElement(name = "DeviceTypeMetaDetails") + protected DeviceTypeMetaDetails deviceTypeMetaDetails; public DeviceTypePlatformDetails getDeviceTypePlatformDetails() { return deviceTypePlatformDetails; @@ -417,4 +420,12 @@ public class DeviceTypeConfiguration { DeviceEnrollmentInvitationDetails deviceEnrollmentInvitationDetails) { this.deviceEnrollmentInvitationDetails = deviceEnrollmentInvitationDetails; } + + public DeviceTypeMetaDetails getDeviceTypeMetaDetails() { + return deviceTypeMetaDetails; + } + + public void setDeviceTypeMetaDetails(DeviceTypeMetaDetails deviceTypeMetaDetails) { + this.deviceTypeMetaDetails = deviceTypeMetaDetails; + } } diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java index fd61ec4cdc..3591d9caa8 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.extensions/src/test/java/io/entgra/device/mgt/core/device/mgt/extensions/mock/TypeXDeviceManagementService.java @@ -33,6 +33,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -124,4 +125,9 @@ public class TypeXDeviceManagementService implements DeviceManagementService { @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } } diff --git a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java index 6fad650b84..db4f5d7037 100644 --- a/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java +++ b/components/policy-mgt/io.entgra.device.mgt.core.policy.mgt.core/src/test/java/io/entgra/device/mgt/core/policy/mgt/core/mock/TypeXDeviceManagementService.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.PolicyMonitoringMa import io.entgra.device.mgt.core.device.mgt.common.pull.notification.PullNotificationSubscriber; import io.entgra.device.mgt.core.device.mgt.common.push.notification.PushNotificationConfig; import io.entgra.device.mgt.core.device.mgt.common.spi.DeviceManagementService; +import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypeMetaDefinition; import io.entgra.device.mgt.core.device.mgt.common.type.mgt.DeviceTypePlatformDetails; import java.util.ArrayList; @@ -118,4 +119,9 @@ public class TypeXDeviceManagementService implements DeviceManagementService { @Override public License getLicenseConfig() { return null; } + + @Override + public DeviceTypeMetaDefinition getDeviceTypeMetaDefinition() { + return null; + } }