SimpleUrlReadingCondition not working

package com.atlassian.bonfire.conditions;

import javax.annotation.Resource;
import com.google.common.annotations.VisibleForTesting;
import com.atlassian.plugin.webresource.condition.SimpleUrlReadingCondition;

/**
 * @since 2.9.1
 */
public class UrlReadingBonfireActivatedCondition extends SimpleUrlReadingCondition {
    @VisibleForTesting
    static final String BONFIRE_LICENSED_QUERY_PARAM_KEY = "jcap";

    @Resource(name = BonfireConditionEvaluator.SERVICE)
    BonfireConditionEvaluator conditionEvaluator;

    @Override
    protected boolean isConditionTrue() {
        return isLicenseActive();
    }

    @Override
    protected String queryKey() {
        return BONFIRE_LICENSED_QUERY_PARAM_KEY;
    }

    private boolean isLicenseActive() {
        return conditionEvaluator.shouldDisplay(AccessCheckMode.LICENSE);
    }
}

When I am trying to compile I am getting below error

> /Users/raghunandan.tata/sb/capture/capture-server/jira-capture-to-jira-bridge-parent/jira-capture-to-jira64-bridge/src/main/java/com/atlassian/bonfire/conditions/UrlReadingBonfireActivatedCondition.java:[5,50] cannot find symbol
> [ERROR]   symbol:   class SimpleUrlReadingCondition
> [ERROR]   location: package com.atlassian.plugin.webresource.condition

Can anyone please help whether SimpleUrlReadingCondition is deprecated or has it been upgraded to some other version?
Please tell me the possible solution for this

cc: @ DanielGrabke , @ FabienPenchenat

Hi @ RaghunandanTata,

Maybe you can implement the required functionality yourself:
Here’s a basic example of how you might create a custom condition class:

package com.atlassian.bonfire.conditions;

import javax.annotation.Resource;
import com.google.common.annotations.VisibleForTesting;

public class CustomUrlReadingCondition {
    @VisibleForTesting
    static final String BONFIRE_LICENSED_QUERY_PARAM_KEY = "jcap";

    @Resource(name = BonfireConditionEvaluator.SERVICE)
    BonfireConditionEvaluator conditionEvaluator;

    @Override
    protected boolean isConditionTrue() {
        return isLicenseActive();
    }

    @Override
    protected String queryKey() {
        return BONFIRE_LICENSED_QUERY_PARAM_KEY;
    }

    private boolean isLicenseActive() {
        return conditionEvaluator.shouldDisplay(AccessCheckMode.LICENSE);
    }
Or you could try to use the new dependency because its seems like you’re right. The SimpleUrlReadingCondition class has been deprecated and replaced by IsFeatureEnabledUrlReadingCondition in newer versions of the Atlassian framework. You’ll need to update your code to use the new class.

Here’s an example of how you can update your class to use IsFeatureEnabledUrlReadingCondition:

package com.atlassian.bonfire.conditions;

import javax.annotation.Resource;
import com.google.common.annotations.VisibleForTesting;
import com.atlassian.plugin.webresource.condition.IsFeatureEnabledUrlReadingCondition;

/**
 * @since 2.9.1
 */
public class UrlReadingBonfireActivatedCondition extends IsFeatureEnabledUrlReadingCondition {
    @VisibleForTesting
    static final String BONFIRE_LICENSED_QUERY_PARAM_KEY = "jcap";

    @Resource(name = BonfireConditionEvaluator.SERVICE)
    BonfireConditionEvaluator conditionEvaluator;

    @Override
    protected boolean isConditionTrue() {
        return isLicenseActive();
    }

    @Override
    protected String queryKey() {
        return BONFIRE_LICENSED_QUERY_PARAM_KEY;
    }

    private boolean isLicenseActive() {
        return conditionEvaluator.shouldDisplay(AccessCheckMode.LICENSE);
    }
}

Make sure to update your dependencies to include the new class and remove any references to the deprecated class.

Hopefully it will help :slight_smile:

Cheers,
Daniel