Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
devel:documentation:roles:dev:duplicate-role [2019/03/15 15:21] tomiskar |
devel:documentation:roles:dev:duplicate-role [2019/03/18 08:50] (current) tomiskar |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Duplicate role ====== | ====== Duplicate role ====== | ||
+ | |||
+ | {{tag> role duplicate processor state }} | ||
Role is duplicated by '' | Role is duplicated by '' | ||
Line 10: | Line 12: | ||
<note tip>Form attributes registered by processor can be localized in the custom module. Each attribute can have different module - module is preset automatically by the processor' | <note tip>Form attributes registered by processor can be localized in the custom module. Each attribute can have different module - module is preset automatically by the processor' | ||
+ | |||
+ | <note tip>If role is duplicated into different environment and role with the same base code already exists there, then new role on the target environment is not created, but updated by the source (selected) role. E.g. when some basic role attribute is changed or some automatic role is added => this changes can be " | ||
===== Processors | ===== Processors | ||
Line 25: | Line 29: | ||
Prepares role's basic properties. | Prepares role's basic properties. | ||
- | <note tip> | + | <note tip> |
<code properties> | <code properties> | ||
Line 41: | Line 45: | ||
Here is the role persisted into database. | Here is the role persisted into database. | ||
+ | |||
+ | <note tip> | ||
<code properties> | <code properties> | ||
Line 55: | Line 61: | ||
* Default order: **50** | * Default order: **50** | ||
- | Duplicate role form attributes | + | Duplicate role form attributes |
Parameters provided to the bulk action form: | Parameters provided to the bulk action form: | ||
Line 74: | Line 80: | ||
* Default order: **100** | * Default order: **100** | ||
- | Duplicate | + | Duplicate |
Parameters provided to the bulk action form: | Parameters provided to the bulk action form: | ||
Line 90: | Line 96: | ||
=== Custom processor example === | === Custom processor example === | ||
+ | |||
+ | Core processor can be disabled and overriden by processor implemented in custom module, if behavior of the core processor has to be changed. | ||
<code java> | <code java> | ||
Line 137: | Line 145: | ||
</ | </ | ||
+ | ==== DuplicateRoleAutomaticByTreeProcessor ==== | ||
+ | |||
+ | @since 9.5.0 | ||
+ | |||
+ | * Event content: '' | ||
+ | * Event type: '' | ||
+ | * Default order: **200** | ||
+ | |||
+ | Duplicate configured automatic roles by tree structure. Automatic roles are duplicated recursively, | ||
+ | |||
+ | Parameters provided to the bulk action form: | ||
+ | * **Duplicate automatic roles** - if automatic roles will be duplicated (both by tree structure and attribute). | ||
+ | |||
+ | Configuration properties: | ||
+ | <code properties> | ||
+ | ## Enable / disable | ||
+ | idm.sec.core.processor.core-duplicate-role-automatic-by-tree-processor.enabled=true | ||
+ | </ | ||
+ | |||
+ | ==== DuplicateRoleAutomaticByAttributeProcessor ==== | ||
+ | |||
+ | @since 9.5.0 | ||
+ | |||
+ | * Event content: '' | ||
+ | * Event type: '' | ||
+ | * Default order: **300** | ||
+ | |||
+ | Duplicate configured automatic roles by attribute. Automatic roles are duplicated recursively, | ||
+ | |||
+ | Parameters provided to the bulk action form: | ||
+ | * **Duplicate automatic roles** - if automatic roles will be duplicated (both by tree structure and attribute). | ||
+ | |||
+ | Configuration properties: | ||
+ | <code properties> | ||
+ | ## Enable / disable | ||
+ | idm.sec.core.processor.core-duplicate-role-automatic-by-attribute-processor.enabled=true | ||
+ | </ | ||
+ | |||
+ | ===== Example processor ===== | ||
+ | |||
+ | Processors can be registered to process event with type '' | ||
+ | |||
+ | <code java> | ||
+ | /** | ||
+ | * Duplicate role - example processor, just create log | ||
+ | */ | ||
+ | @Enabled(ExampleModuleDescriptor.MODULE_ID) | ||
+ | @Component(DuplicateRoleLogProcessor.PROCESSOR_NAME) | ||
+ | @Description(" | ||
+ | public class DuplicateRoleLogProcessor | ||
+ | extends CoreEventProcessor< | ||
+ | implements RoleProcessor { | ||
+ | |||
+ | private static final org.slf4j.Logger LOG = org.slf4j.LoggerFactory.getLogger(DuplicateRoleLogProcessor.class); | ||
+ | // | ||
+ | public static final String PROCESSOR_NAME = " | ||
+ | public static final String PARAMETER_INCLUDE_LOG = " | ||
+ | |||
+ | public DuplicateRoleLogProcessor() { | ||
+ | super(RoleEventType.DUPLICATE); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public String getName() { | ||
+ | return PROCESSOR_NAME; | ||
+ | } | ||
+ | |||
+ | /** | ||
+ | * Adds form attribute - if log will be created - into bulk action form. | ||
+ | */ | ||
+ | @Override | ||
+ | public List< | ||
+ | IdmFormAttributeDto include = new IdmFormAttributeDto( | ||
+ | PARAMETER_INCLUDE_LOG, | ||
+ | " | ||
+ | PersistentType.BOOLEAN); | ||
+ | include.setDefaultValue(Boolean.TRUE.toString()); | ||
+ | // | ||
+ | return Lists.newArrayList(include); | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public boolean conditional(EntityEvent< | ||
+ | return super.conditional(event) | ||
+ | && | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public EventResult< | ||
+ | IdmRoleDto duplicate = event.getContent(); | ||
+ | IdmRoleDto originalSource = event.getOriginalSource(); | ||
+ | // | ||
+ | LOG.info(" | ||
+ | // | ||
+ | return new DefaultEventResult<> | ||
+ | } | ||
+ | |||
+ | @Override | ||
+ | public int getOrder() { | ||
+ | return 10000; // on the end | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
- | ... | + | ===== Entity state usage ===== |
- | TODO: | + | When some role composition or automatic role (~related |
- | - all registered processors, orders | + | |
- | - entity | + | |
- | - create duplicate vs update duplicate | + | |
- | - how to register new processor | + | |
- | - how to override processor + custom from test | + | |