Test the Plugin Licensing without servlets

Bahar Çağlar October 29, 2012

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

0 votes
Florin Manaila
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.
October 29, 2012

#if(!licenseOk)

#parse("licenseError.vm")

#else

#parse("someView.vm")

#end

0 votes
Florin Manaila
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.
October 29, 2012

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.

Bahar Çağlar October 29, 2012

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?

Bahar Çağlar October 29, 2012

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?

Florin Manaila
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.
October 29, 2012

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

Florin Manaila
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.
October 29, 2012

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.

Bahar Çağlar October 29, 2012

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

Florin Manaila
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.
October 29, 2012

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.

Bahar Çağlar October 29, 2012

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

Bahar Çağlar October 29, 2012

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

Florin Manaila
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.
October 29, 2012

#if(!licenseOk)

#parse("licenseError.vm")

#else

#parse("someView.vm")

#end

Bahar Çağlar October 29, 2012

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;
    }

Florin Manaila
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.
October 29, 2012

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

Bahar Çağlar October 29, 2012

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

Bahar Çağlar October 29, 2012

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?

Florin Manaila
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.
October 29, 2012

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?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events