diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AMIndexerPreprocessor.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AMIndexerPreprocessor.java new file mode 100644 index 000000000000..3eec76ec1592 --- /dev/null +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/AMIndexerPreprocessor.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024, WSO2 LLc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 LLc. 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.apimgt.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.registry.core.Resource; +import org.wso2.carbon.registry.core.exceptions.RegistryException; +import org.wso2.carbon.registry.indexing.indexer.IndexerPreProcessor; + +public class AMIndexerPreprocessor implements IndexerPreProcessor { + + private static final Log log = LogFactory.getLog(AMIndexerPreprocessor.class); + + @Override + public void processResource(Resource resource) throws RegistryException { + if (APIConstants.API_RXT_MEDIA_TYPE.equals(resource.getMediaType())) { + if (log.isDebugEnabled()) { + log.debug("Analyzing API in " + resource.getPath()); + } + if (!resource.getProperties().isEmpty() && !resource.getProperties().contains("visible_organizations")) { + if (log.isDebugEnabled()) { + log.debug("Update property for the resource in " + resource.getPath()); + } + resource.setProperty("visible_organizations", "all"); + } + } + + } + +} diff --git a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/internal/APIManagerComponent.java b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/internal/APIManagerComponent.java index c2094d7d88af..6a3c9cdbe87c 100644 --- a/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/internal/APIManagerComponent.java +++ b/components/apimgt/org.wso2.carbon.apimgt.impl/src/main/java/org/wso2/carbon/apimgt/impl/internal/APIManagerComponent.java @@ -47,6 +47,7 @@ import org.wso2.carbon.apimgt.common.gateway.jwttransformer.JWTTransformer; import org.wso2.carbon.apimgt.eventing.EventPublisherException; import org.wso2.carbon.apimgt.eventing.EventPublisherFactory; +import org.wso2.carbon.apimgt.impl.AMIndexerPreprocessor; import org.wso2.carbon.apimgt.impl.APIConstants; import org.wso2.carbon.apimgt.impl.APIManagerAnalyticsConfiguration; import org.wso2.carbon.apimgt.impl.APIManagerConfiguration; @@ -122,6 +123,7 @@ import org.wso2.carbon.registry.core.session.UserRegistry; import org.wso2.carbon.registry.core.utils.AuthorizationUtils; import org.wso2.carbon.registry.core.utils.RegistryUtils; +import org.wso2.carbon.registry.indexing.indexer.IndexerPreProcessor; import org.wso2.carbon.registry.indexing.service.TenantIndexingLoader; import org.wso2.carbon.user.api.AuthorizationManager; import org.wso2.carbon.user.api.UserStoreException; @@ -216,6 +218,7 @@ protected void activate(ComponentContext componentContext) throws Exception { bundleContext.registerService(Notifier.class.getName(),new KeyTemplateNotifier(), null); bundleContext.registerService(Notifier.class.getName(), new CorrelationConfigNotifier(), null); bundleContext.registerService(Notifier.class.getName(), new GatewayPolicyNotifier(), null); + bundleContext.registerService(IndexerPreProcessor.class.getName(), new AMIndexerPreprocessor(), null); if (configuration.getMarketplaceAssistantConfigurationDto().isAuthTokenProvided()) { bundleContext.registerService(Notifier.class.getName(), new MarketplaceAssistantApiPublisherNotifier(), null); }