Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this tutorial, we will following the guideline of developing a plugin to develop our Not Permission plugin. Please also refer to the very first tutorial How to develop a Bean Shell Hash Variable for more details steps.

...

The following of this tutorial is prepared with a Macbook Pro and Joget Source Code version 5.0.0. Please refer to Guideline of for developing a plugin for other platform command.

...

Code Block
- Home
  - joget
    - plugins
    - jw-community
      -5.0.01

The "plugins" directory is the folder we will create and store all our plugins and the "jw-community" directory is where the Joget Workflow Source code stored.

...

Code Block
languagebash
cd joget/plugins/
~/joget/jw-community/5.0.01/wflow-plugin-archetype/create-plugin.sh org.joget.tutorial not_permission 5.0.01

Then, the shell script will ask us to key in a version for your plugin and ask us for confirmation before generate the maven project.

...

Code Block
languagejava
titleImplementation of all basic abstract methods
collapsetrue
package org.joget.tutorial;
 
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.apps.form.model.FormPermission;
import org.joget.apps.userview.model.UserviewPermission;
 
public class NotPermission extends UserviewPermission implements FormPermission {
    
    private final static String MESSAGE_PATH = "messages/NotPermission";
 
    public String getName() {
        return "Not Permission";
    }
 
    public String getVersion() {
        return "5.0.0";
    }
 
    public String getDescription() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorial.NotPermission.pluginDesc", getClassName(), MESSAGE_PATH);
    }
 
    public String getLabel() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.tutorial.NotPermission.pluginLabel", getClassName(), MESSAGE_PATH);
    }
 
    public String getClassName() {
        return getClass().getName();
    }
 
    public String getPropertyOptions() {
        return AppUtil.readPluginResource(getClassName(), "/properties/notPermission.json", null, true, MESSAGE_PATH);
    }
    
    @Override
    public boolean isAuthorize() {
        throw new UnsupportedOperationException("Not supported yet."); 
    }
}

...

Code Block
languagejava
    public void start(BundleContext context) {
        registrationList = new ArrayList<ServiceRegistration>();
        //Register plugin here
        registrationList.add(context.registerService(NotPermission.class.getName(), new NotPermission(), null));
    }

f. Build it and testing

Let build our plugin. Once the building process is done, we will found a "not_permission-5.0.0.jar" file is created under "not_permission/target" directory.

Then, let upload the plugin jar to Manage Plugins. After upload the jar file, double check the plugin is uploaded and activated correctly.

Image Added

Let us open an userview and change one of the category permission to Not Permission. We will want the current user not in a "Managers" group.

Image Added

Image Added

Image Added

After done the configuration and save the userview. Let us test it. First, check the admin user is not in "Managers" group.

Image Added

Check the userview, the "Personal" category configured with not in "Managers" group is shown correctly.

Image Added

Now, assign the "admin" user to "Managers" group.

Image Added

The "Personal" category is now disappeared.

Image Added

8. Take a step further, share it or sell it

You can download the source code from not_permission.zip.

To download the ready-to-use plugin jar, please find it in http://marketplace.joget.org/.