We already have a lot of places setting a user agent.
I believe the best would be to create a UserAgentGenerator component that can be reused
with one method, such as generate(String prefix).
Note that for non-human user-agent using a suffix of “bot” could be a good rule added by
the generator in addition to the version.
Right now I see for example that the link checker just sets:
httpClientBuilder.setUserAgent("XWikiLinkChecker”);
Thanks
-Vincent
On 07 Apr 2016, at 09:34, Thomas Mortagne
<thomas.mortagne(a)xwiki.com> wrote:
So the question is do you want the version of your module or do you
want the version of the product since those might not be in sync
(anyone can do a product based on some version of XWiki platform).
What you saw on
https://www.xwiki.org/xwiki/bin/view/FAQ/How+can+I+find+the+version+of+XWik…
is the version of the product.
If the goal is to set something like the version of "XWiki" then what
is described on
https://www.xwiki.org/xwiki/bin/view/FAQ/How+can+I+find+the+version+of+XWik…
is not what you want. What you need is the version of you own
extension basically and you can do that by asking Extension Manager
the version of the installed extension with the id of your module.
@Inject
private CoreExtensionRepository coreExtensionRepository;
...
CoreExtension myself =
this.coreExtensionRepository.getCoreExtension("org.xwiki.commons:xwiki-commons-somehttpmodule")
Version version = myself.getId().getVersion()
The import issue you have is probably because you are missing
xwiki-commons-extension-api dependency in your pom.xml.
Another more Java standard approach would be to get the version from
the MANIFEST which would be much easier... if we did not forget to
configure Maven to set the version in the MANIFEST (just noticed it).
It would be something like
this.getClass().getPackage().getSpecificationVersion(). I guess this
would require a different discussion on the mailing list, will send a
mail about that.
Note that we have the version in the MANIFEST but in a custom field
set by the bundle plugin (Bundle-Version) and I would really prefer
using it in a more standard location.
On Thu, Apr 7, 2016 at 12:41 AM, Sean Whalen <whalenster(a)gmail.com> wrote:
> To creat a proper user agent string.
>
> On Wed, Apr 6, 2016 at 4:41 AM, Thomas Mortagne <thomas.mortagne(a)xwiki.com>
> wrote:
>
>> Why do you need to know the version to fix XWIKI-13284 ? Usually
>> xwiki-platform modules are supposed to be written for a specific
>> version of their dependencies.
>>
>> On Tue, Apr 5, 2016 at 11:19 PM, Sean Whalen <whalenster(a)gmail.com> wrote:
>>> Hello,
>>>
>>> I'm very close to having code to contribute for XWIKI-13284 Add support
>> for
>>> loading RSS feeds over HTTPS in the RSS Macro
>>>
>>>
https://jira.xwiki.org/browse/XWIKI-13284
>>>
>>> I've looked over the code here
>>>
>>>
>>
https://www.xwiki.org/xwiki/bin/view/FAQ/How+can+I+find+the+version+of+XWik…
>>>
>>> @Inject
>>> private CoreExtensionRepository coreExtensionRepository;
>>> ...
>>> CoreExtension distributionExtension = this.coreExtensionRepository.
>>> getEnvironmentExtension()
>>> Version version = distributionExtension.getId().getVersion()
>>>
>>> But I can't seem to import
>>> org.xwiki.extension.repository.CoreExtensionRepository from
>>> org.xwiki.rendering.internal.macro.rss. org.xwiki.extention will not
>>> resolve with org.xwiki.rendering.internal.macro.rss open in InteliJ. I'm
>>> new to Java web development. What am I missing?