From 78435143326ac8cae17a46a6a4b57530dd5269a1 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sat, 17 Feb 2024 18:07:01 +0530 Subject: [PATCH 1/4] Fix application search issue --- .../device/mgt/core/device/mgt/core/common/Constants.java | 1 + .../core/device/mgt/core/dao/impl/ApplicationDAOImpl.java | 7 ++++++- .../src/main/resources/dbscripts/cdm/mysql.sql | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) 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/common/Constants.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/Constants.java index 71eaf20a5f..68111a5159 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/Constants.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/common/Constants.java @@ -21,6 +21,7 @@ package io.entgra.device.mgt.core.device.mgt.core.common; public class Constants { public static final String SCHEME_SEPARATOR = "://"; public static final String COLON = ":"; + public static final String QUERY_WILDCARD = "%"; public static final String URI_QUERY_SEPARATOR = "?"; public static final String URI_SEPARATOR = "/"; public static final String BASIC_AUTH_HEADER_PREFIX = "Basic "; 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/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java index fb3ad85549..30655aa1e4 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -17,6 +17,7 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import io.entgra.device.mgt.core.device.mgt.core.common.Constants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest; @@ -298,9 +299,13 @@ public class ApplicationDAOImpl implements ApplicationDAO { String filter = request.getFilter(); if (filter != null) { sql = sql + "AND NAME LIKE ? "; + filter = Constants.QUERY_WILDCARD.concat(filter).concat(Constants.QUERY_WILDCARD); } + + boolean isLimitPresent = false; if (request != null && request.getRowCount() != -1) { sql = sql + "LIMIT ? OFFSET ?"; + isLimitPresent = true; } Connection conn = this.getConnection(); try (PreparedStatement stmt = conn.prepareStatement(sql)) { @@ -312,7 +317,7 @@ public class ApplicationDAOImpl implements ApplicationDAO { if (filter != null){ stmt.setString(paramIdx++, filter); } - if (request != null && request.getRowCount() != -1) { + if (isLimitPresent) { stmt.setInt(paramIdx++, request.getRowCount()); stmt.setInt(paramIdx, request.getStartIndex()); } diff --git a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql index ce963d1437..b0de3dc590 100644 --- a/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql +++ b/features/device-mgt/io.entgra.device.mgt.core.device.mgt.basics.feature/src/main/resources/dbscripts/cdm/mysql.sql @@ -463,6 +463,8 @@ CREATE TABLE IF NOT EXISTS DM_APPLICATION ( )ENGINE = InnoDB; CREATE INDEX IDX_DM_APPLICATION ON DM_APPLICATION(DEVICE_ID, ENROLMENT_ID, TENANT_ID); +CREATE INDEX DM_APPLICATION_NAME ON DM_APPLICATION(NAME); +CREATE INDEX DM_APPLICATION_NAME_PLATFORM_TID ON DM_APPLICATION(NAME, PLATFORM, TENANT_ID); -- END OF POLICY RELATED TABLES -- -- 2.36.3 From 62f84461a55f65639c133be1dfc77e47cd475744 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sun, 18 Feb 2024 17:59:42 +0530 Subject: [PATCH 2/4] Add application search by package name --- .../service/api/DeviceManagementService.java | 7 ++- .../impl/DeviceManagementServiceImpl.java | 7 ++- .../mgt/api/jaxrs/util/DeviceMgtUtil.java | 10 ++++ .../mgt/common/app/mgt/ApplicationFilter.java | 53 +++++++++++++++++++ .../mgt/core/dao/impl/ApplicationDAOImpl.java | 26 +++++++-- 5 files changed, 95 insertions(+), 8 deletions(-) create mode 100644 components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/ApplicationFilter.java diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index acb161d77e..d2f3f1d847 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -2657,7 +2657,12 @@ public interface DeviceManagementService { name = "appName", value = "App name to be searched") @QueryParam("appName") - String appName); + String appName, + @ApiParam( + name = "packageName", + value = "App package name searched") + @QueryParam("packageName") + String packageName); @GET @Path("/application/{packageName}/versions") diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java index 9e82728d3a..d8f028c928 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/DeviceManagementServiceImpl.java @@ -27,6 +27,7 @@ import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationMana import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager; import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.DisenrollRequest; +import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtUtil; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; @@ -1564,11 +1565,13 @@ public class DeviceManagementServiceImpl implements DeviceManagementService { @QueryParam("offset") int offset, @DefaultValue("10") @QueryParam("limit") int limit, - @QueryParam("appName") String appName) { + @QueryParam("appName") String appName, + @QueryParam("packageName") String packageName) { PaginationRequest request = new PaginationRequest(offset, limit); ApplicationList applicationList = new ApplicationList(); request.setDeviceType(deviceType); - request.setFilter(appName); + request.setFilter(DeviceMgtUtil.buildAppSearchFilter(appName, packageName)); + try { PaginationResult paginationResult = DeviceMgtAPIUtils .getDeviceManagementService() diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java index ab818b32ae..d6955e4f39 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtUtil.java @@ -24,7 +24,9 @@ import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ProfileFeature; import io.entgra.device.mgt.core.device.mgt.api.jaxrs.exception.BadRequestException; import io.entgra.device.mgt.core.device.mgt.common.policy.mgt.Profile; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationFilter; +import com.google.gson.Gson; import javax.validation.ConstraintViolation; import java.util.ArrayList; import java.util.List; @@ -141,4 +143,12 @@ public class DeviceMgtUtil { errorResponse.setErrorItems(errorListItems); return errorResponse; } + + public static String buildAppSearchFilter(String appName, String packageName) { + //Create search filter as a Json string to attach into the filter in PaginationRequest + ApplicationFilter applicationFilter = new ApplicationFilter(); + applicationFilter.setAppName(appName); + applicationFilter.setPackageName(packageName); + return new Gson().toJson(applicationFilter); + } } \ No newline at end of file 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/app/mgt/ApplicationFilter.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.common/src/main/java/io/entgra/device/mgt/core/device/mgt/common/app/mgt/ApplicationFilter.java new file mode 100644 index 0000000000..f9f7c3d757 --- /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/app/mgt/ApplicationFilter.java @@ -0,0 +1,53 @@ +/* + * 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.device.mgt.common.app.mgt; + +public class ApplicationFilter { + public static final class FilterProperties { + public static final String REGEX_WHITESPACE = ".*\\s.*"; + public static final String REGEX_WHITESPACE_REPLACER = "\\s+"; + public static final String URL_ENCODE_SPACE = "%20"; + } + + private String appName; + private String packageName; + + public String getAppName() { + return appName; + } + + public void setAppName(String appName) { + this.appName = appName; + if (this.appName != null && !this.appName.isEmpty() && + //Check if the filter contains spaces and replace URL encode them + this.appName.matches(FilterProperties.REGEX_WHITESPACE)) { + this.appName = this.appName + .replaceAll(FilterProperties.REGEX_WHITESPACE_REPLACER, + FilterProperties.URL_ENCODE_SPACE); + } + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } +} 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/dao/impl/ApplicationDAOImpl.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java index 30655aa1e4..3691b10ee3 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.core/src/main/java/io/entgra/device/mgt/core/device/mgt/core/dao/impl/ApplicationDAOImpl.java @@ -17,6 +17,8 @@ */ package io.entgra.device.mgt.core.device.mgt.core.dao.impl; +import com.google.gson.Gson; +import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationFilter; import io.entgra.device.mgt.core.device.mgt.core.common.Constants; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -296,10 +298,21 @@ public class ApplicationDAOImpl implements ApplicationDAO { "PLATFORM = ? AND TENANT_ID = ?) "; try { - String filter = request.getFilter(); - if (filter != null) { + ApplicationFilter applicationFilter = new Gson().fromJson(request.getFilter(), ApplicationFilter.class); + boolean isAppNameFilterProvided = false; + if (null != applicationFilter.getAppName()) { sql = sql + "AND NAME LIKE ? "; - filter = Constants.QUERY_WILDCARD.concat(filter).concat(Constants.QUERY_WILDCARD); + applicationFilter.setAppName(Constants.QUERY_WILDCARD.concat(applicationFilter.getAppName()) + .concat(Constants.QUERY_WILDCARD)); + isAppNameFilterProvided = true; + } + + boolean isPackageFilterProvided = false; + if (null != applicationFilter.getPackageName()) { + sql = sql + "AND APP_IDENTIFIER LIKE ? "; + applicationFilter.setPackageName(Constants.QUERY_WILDCARD.concat(applicationFilter.getPackageName()) + .concat(Constants.QUERY_WILDCARD)); + isPackageFilterProvided = true; } boolean isLimitPresent = false; @@ -314,8 +327,11 @@ public class ApplicationDAOImpl implements ApplicationDAO { stmt.setInt(paramIdx++, tenantId); stmt.setString(paramIdx++, request.getDeviceType()); stmt.setInt(paramIdx++, tenantId); - if (filter != null){ - stmt.setString(paramIdx++, filter); + if (isAppNameFilterProvided){ + stmt.setString(paramIdx++, applicationFilter.getAppName()); + } + if (isPackageFilterProvided){ + stmt.setString(paramIdx++, applicationFilter.getPackageName()); } if (isLimitPresent) { stmt.setInt(paramIdx++, request.getRowCount()); -- 2.36.3 From 99b91ade01fe5408532477d4e3873428ae7f0258 Mon Sep 17 00:00:00 2001 From: Pahansith Date: Sun, 18 Feb 2024 18:44:09 +0530 Subject: [PATCH 3/4] Improve query param value --- .../mgt/api/jaxrs/service/api/DeviceManagementService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java index d2f3f1d847..f1e464a0d9 100644 --- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java +++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/DeviceManagementService.java @@ -2660,7 +2660,7 @@ public interface DeviceManagementService { String appName, @ApiParam( name = "packageName", - value = "App package name searched") + value = "App package name to be searched") @QueryParam("packageName") String packageName); -- 2.36.3 From 1c0a0227ab8f9efe67ec9192bea1f5b6df4b1054 Mon Sep 17 00:00:00 2001 From: "amalka.subasinghe" Date: Tue, 20 Feb 2024 11:02:51 +0530 Subject: [PATCH 4/4] post api publishing observer implementation --- .../publisher/APIPublisherStartupHandler.java | 9 ++++++++ .../publisher/PostApiPublishingObsever.java | 23 +++++++++++++++++++ .../internal/APIPublisherDataHolder.java | 18 ++++++++++++++- .../APIPublisherServiceComponent.java | 21 +++++++++++++++++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/PostApiPublishingObsever.java diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java index 244cc99b06..e039259b92 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/APIPublisherStartupHandler.java @@ -90,6 +90,15 @@ public class APIPublisherStartupHandler implements ServerStartupObserver { } catch (APIManagerPublisherException e) { log.error("failed to update scope role mapping.", e); } + + // execute after api publishing + for (PostApiPublishingObsever observer : APIPublisherDataHolder.getInstance().getPostApiPublishingObseverList()) { + if (log.isDebugEnabled()) { + log.debug("Executing " + observer.getClass().getName()); + } + observer.execute(); + } + log.info("Finish executing PostApiPublishingObsevers"); } }); t.start(); diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/PostApiPublishingObsever.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/PostApiPublishingObsever.java new file mode 100644 index 0000000000..392e780300 --- /dev/null +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/PostApiPublishingObsever.java @@ -0,0 +1,23 @@ +/* + * 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.apimgt.webapp.publisher; + +public interface PostApiPublishingObsever { + void execute(); + +} diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index 4f8e5599bf..d00f50e35f 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -22,6 +22,7 @@ import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServi import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIConfig; import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.PostApiPublishingObsever; import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.registry.core.service.RegistryService; @@ -32,9 +33,11 @@ import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.tenant.TenantManager; import org.wso2.carbon.utils.ConfigurationContextService; -import java.util.HashMap; import java.util.Map; import java.util.Stack; +import java.util.List; +import java.util.ArrayList; + public class APIPublisherDataHolder { @@ -52,6 +55,7 @@ public class APIPublisherDataHolder { private static APIPublisherDataHolder thisInstance = new APIPublisherDataHolder(); + private List postApiPublishingObseverList = new ArrayList<>(); private APIPublisherDataHolder() { } @@ -179,4 +183,16 @@ public class APIPublisherDataHolder { public void setMetadataManagementService(MetadataManagementService metadataManagementService) { this.metadataManagementService = metadataManagementService; } + + public List getPostApiPublishingObseverList() { + return postApiPublishingObseverList; + } + + public void addPostApiPublishingObseverList(PostApiPublishingObsever postApiPublishingObseverList) { + this.postApiPublishingObseverList.add(postApiPublishingObseverList); + } + + public void removePostApiPublishingObseverList(PostApiPublishingObsever postApiPublishingObsever) { + this.postApiPublishingObseverList.remove(postApiPublishingObsever); + } } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java index 7427bd930f..62684c2215 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherServiceComponent.java @@ -20,6 +20,7 @@ package io.entgra.device.mgt.core.apimgt.webapp.publisher.internal; import io.entgra.device.mgt.core.apimgt.extension.rest.api.APIApplicationServices; import io.entgra.device.mgt.core.apimgt.extension.rest.api.PublisherRESTAPIServices; import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.MetadataManagementService; +import io.entgra.device.mgt.core.apimgt.webapp.publisher.PostApiPublishingObsever; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; @@ -66,6 +67,12 @@ import java.util.HashMap; * policy="dynamic" * bind="setMetaDataMgtService" * unbind="unsetMetaDataMgtService" + * @scr.reference name="postApiPublishingObsever" + * interface="io.entgra.device.mgt.core.apimgt.webapp.publisher.PostApiPublishingObsever" + * cardinality="0..n" + * policy="dynamic" + * bind="setPostApiPublishingObsever" + * unbind="unsetPostApiPublishingObsever" */ public class APIPublisherServiceComponent { @@ -176,4 +183,18 @@ public class APIPublisherServiceComponent { APIPublisherDataHolder.getInstance().setMetadataManagementService(null); } + protected void setPostApiPublishingObsever(PostApiPublishingObsever postApiPublishingObsever) { + if (log.isDebugEnabled()) { + log.debug("Setting PostApiPublishingObsever"); + } + APIPublisherDataHolder.getInstance().addPostApiPublishingObseverList(postApiPublishingObsever); + } + + protected void unsetPostApiPublishingObsever(PostApiPublishingObsever postApiPublishingObsever) { + if (log.isDebugEnabled()) { + log.debug("Unsetting PostApiPublishingObsever"); + } + APIPublisherDataHolder.getInstance().removePostApiPublishingObseverList(postApiPublishingObsever); + } + } -- 2.36.3