Skip to content

Commit

Permalink
Add indexed document modification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chamilaadhi committed Aug 29, 2024
1 parent 364cec9 commit ba78056
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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");
}
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit ba78056

Please sign in to comment.