Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

textProvider in SDK Bamboo helloworld task example does not work

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 11, 2011

ExampleTaskConfigurator - https://bitbucket.org/atlassian/bamboo-sdk-examples/src/ed48459fc04e/part1/myfirstplugin/src/main/java/myfirstplugin/ExampleTaskConfigurator.java#cl-59 uses the textProvider to retrieve i18n values. However, none of the property values are available using this technique. For example, modify the code to always put out error messages - only the literal text gets displayed:

// if (StringUtils.isEmpty(sayValue))
// {
errorCollection.addError("say", "this is error text");
errorCollection.addError("say", textProvider.getText("helloworld.say.error"));
//}

The property file is accessed ok for the UI, just not in the java code.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Steffen Opel November 21, 2011

Your analysis just turned up in my search regarding the very same issue, thanks! It allowed me to find an alternate workaround by replacing textProvider.getText() with this.getI18nBean() as discovered via peeking into the Bamboo source, where textProvider doesn't seem to be used in several Tasks at least. It's worth noting though, that it is used by other Tasks, e.g. the Ant Task, which still does show validation errors properly, so there seems to be another configuration issue involved. Using this.getI18nBean() at least allows to avoid duplicating the messages for the moment ...


I'm also a bit suspicious about the respective snippet from atlassian-plugin.xml as generated by 'atlas-create-bamboo-plugin' (and probably the source for all the plugins exhibiting this error accordingly), e.g. from https://bitbucket.org/atlassian/bamboo-sdk-examples/src/ed48459fc04e/part1/myfirstplugin/src/main/resources/atlassian-plugin.xml:

<resource type="i18n" name="myfirstplugin language" location="english"/>

In contrast the respective fragment from a working plugin looks like so:

<resource type="i18n" name="i18n" location="com.example.product.plugins.task.i18n"/>

The i18n.properties files is located within the addressed Maven folder hierarchy as usual, i.e. resources/com/example/product/plugins/task/i18n.properties. I've tried to refactor my Task plugin accordingly, but to no avail.



Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2011

Thanks! That worked great. Regarding atlassian-plugin.xml - look at https://bitbucket.org/bob_swift/bamboo-groovy-task-plugin/src/tip/src/main/resources/atlassian-plugin.xml if you want my example.

Steffen Opel November 21, 2011

That's more what I'd expected indeed - I'll go ahead and refactor my resources along these lines as well, thanks for the example! Any guess on why the Plugin SDK seems to deviate from the established Maven standard directory layout here? Or might this simply be a bug in the code generator, which the weird 'name' composition seems to hint on?

Bob Swift OSS (Bob Swift Atlassian Apps)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2011

Don't know. I borrowed that part from my other plugins.

James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 21, 2011

Out of curiosity are you targetting Bamboo versions between 3.1 and 3.2? I think there might be the possability that another english.properties is being loaded from another plugin because they share the same package. Ill get someone to look into this.

Steffen Opel November 21, 2011

No, I've started with 'atlas-create-bamboo-plugin' from the Plugin SDK 3.7, which targets Bamboo version 3.3 by default. Thanks much for looking into this minor but spreading annoyance! There are several Bamboo Tasks out there suffering from this lack of validation error display already ;)

James Dumay
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 22, 2011

No worries Steffen - we take minor headaches for plugin developers very seriously and we have scheduled someone to take a look at it next week.

EDIT: You can follow the status here

Jason Huntley
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 21, 2012

I'm making a custom repository plugin and here is what I had to add to my setTextProvider method to get i18n working:

@Override
    public synchronized void setTextProvider(TextProvider textProvider) {
        if (this.textProvider==null) {
        	super.setTextProvider(textProvider);
        	this.textProvider=textProvider;
        }

        if (getName() == null) {
            I18nBeanFactory i18nBeanFactory = i18nBeanFactoryReference.get();
            this.textProvider = new TextProviderAdapter(i18nBeanFactory.getI18nBean(Locale.getDefault()));
        }
    }

TAGS
AUG Leaders

Atlassian Community Events