My problem really is not around creating the condition so much as how to assess the Settings in a Repo. So I want to know if a merge check is Enabled or Disabled, and add a banner if it is Enabled. You will notice I temporarily added code to see what context I had, and how they looked.
I received the following (I deleted some text):
2019-06-12 10:47:14,734 WARN Item : request Object : org.apache.catalina.connector.RequestFacade@4cc9f5fb
2019-06-12 10:47:14,734 WARN Item : principal Object : InternalNormalUser{id=651, username=jdoe}
2019-06-12 10:47:14,735 WARN Item : repository Object : NG/my-repo[228]
2019-06-12 10:47:14,735 WARN 3 Entries found in context!
So great news, I got a repository Object. Wait how do I get it settings? This is where I am stuck.
atlassian-plugin.xml
<web-panel name="My Panel" key="my-banner-panel" location="bitbucket.web.repository.banner" weight="2000">
<resource name="view" type="static"><![CDATA[<div class="aui-message">
<p class="title">
<strong>REPO FROZEN</strong>
</p>
<p>An Administrator has currently FROZEN this repository.</p>
</div>]]>
</resource>
</web-panel>
IsMergeCheckEnabledCondition.java
public class IsMergeCheckEnabledCondition implements Condition {
private static final Logger log = LogManager.getLogger("com.atlassian.bitbucket");
public static final String MERGE_CHECK = "mergeCheck";
private String mergeCheckName;
IsMergeCheckEnabledCondition()
{
; //this.repoService = repositoryService;
}
@Override
public void init(Map<String, String> params)
{
mergeCheckName = params.get(MERGE_CHECK);
}
@Nonnull
@Override
public boolean shouldDisplay(Map<String, Object> context)
{
int count = 0;
for (Map.Entry<String, Object> entry : context.entrySet())
{
count++;
log.warn("Item : " + entry.getKey() + " Object : " + entry.getValue());
}
log.warn(count + " Entries found in context!");
return true;
}
}