Test the Plugin Licensing without servlets

I wanna test my plugin licencing like explained in the link https://developer.atlassian.com/display/UPM/Tutorial%3A+Adding+Licensing+Support+to+Your+Add-on

Please look Step 6. Test the Plugin Licencing. I need to test my plugin valid or not without using servlets.

How can I do this?

Thanks for helps

2 answers

Install the latest version of the Universal Plugin Manager which comes bundled with the licensing module right in the plugins screen. (see Step 8) If you're using UPM < 2.0.1 and don't have a licensing page of your own, you cannot use the licenses.

Ok. well, I get it. How can I disable modules? or I have a page "sample.jspa" , and How can I make it invisible? How can I handle with it?

I am using the latest version of UPM as described step 8. If my license exprises, my plugin is still usable?UPM makes the modules disabled or somehing else. How does it manage valid and invalid licenses?

See ComponentAccessor.getPluginAccessor() and getPluginController(). They should provide you with the disable functions you need.

That's your job to decide what to do when the licenses expire. It only provides a way to tell what the license status is and then you decide how you want to handle it.

Thanks Florin. Do you know a documentation page about it?

Sorry, there is no other documentation that I know about. It's usually trial and error for me. I usually check this in the velocity files and render a message about the license being expired instead of showing the normal page. But this depends on what your plugin actually does. You usually need to check it somewhere at the "entrance" to the functionality it provides.

Yeah, I want to to use it in a velocity(vm) file. Can you give me your example please?

Oh, well. licenseOk is initialized in a java class or it is a velocity parameter, or anything else?

#if(!licenseOk)

#parse("licenseError.vm")

#else

#parse("someView.vm")

#end

There is a initVelocityContext method in LicenseServlet.java. Can I add like this?

private Map&lt;String, Object&gt; initVelocityContext(HttpServletResponse resp)
    {
        resp.setContentType("text/html;charset=utf-8");
        URI servletUri = URI.create(applicationProperties.getBaseUrl() + "/plugins/servlet/crm-plugin/license");

        final Map&lt;String, Object&gt; context = new HashMap&lt;String, Object&gt;();
        context.put("servletUri", servletUri);
        context.put("displayLicenseAdminUi", true);

        try
        {
            context.put("license", licenseManager.getLicense());
            context.put("upmLicensingAware", licenseManager.isUpmLicensingAware());
            context.put("pluginKey", licenseManager.getPluginKey());
            if (licenseManager.isUpmLicensingAware())
            {
                context.put("warningMessage", i18nResolver.getText("plugin.license.storage.admin.upm.licensing.aware", licenseManager.getPluginManagementUri()));
            }
        }
        catch (PluginLicenseStoragePluginUnresolvedException e)
        {
            context.put("errorMessage", i18nResolver.getText("plugin.license.storage.admin.plugin.unavailable"));
            context.put("displayLicenseAdminUi", false);
        }

        return context;
    }

In my case, I calculated it (see example in generated LicenseServlet.java from tutorial above) and put it in the velocity context.

Well, I can use it from license-admin.vm, but I cannot access it from another velocity files. What am I doing wrong? :(

I can get the license status like following: (in resources/license-admin.vm)

How can I get it from this vm? (resources/secure/settings.vm)

I tried to append the same velocity file(license), but all values are empty :S What is wrong with it?

You must populate the velocity context with those values in order to use them in the vm. Are you sure the context contains the values you need?

#if(!licenseOk)

#parse("licenseError.vm")

#else

#parse("someView.vm")

#end

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

362 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you