Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory-orchestrator
Commits
04540db2
Verified
Commit
04540db2
authored
7 months ago
by
dockx thibault
Browse files
Options
Download
Patches
Plain Diff
Feat(Orchestrator) - small refactor
small refactor
parent
3cd2dbc0
dev
61-orchestrator-lifecycle-array-supann-is-analyzed-with-static-numbering
63-orchestrator-mail-controller-format-of-mail-text-and-signature-are-not-utf8-usage-of-accents-is
70-create-unitests-for-orchestrator
73-orchestrator-create-a-librabry-in-core-orchestrator
78-redesign-audit-class
79-redesign-mail
80-redesign-notifications-class
81-redesign-reminders-class
82-redesign-lifecycle-class
main
revert-55863b23
1.1
2 merge requests
!72
Releasing Fusiondirectory Orchestrator 1.1
,
!60
Resolve "[Orchestrator] - Notifications must be updated to be aware of supannStatus values"
Pipeline
#29759
failed with stages
in 1 minute and 37 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/tasks/Notifications.php
+86
-33
plugins/tasks/Notifications.php
with
86 additions
and
33 deletions
+86
-33
plugins/tasks/Notifications.php
+
86
−
33
View file @
04540db2
...
...
@@ -69,46 +69,25 @@ class Notifications implements EndpointInterface
// Generate the mail form with all mail controller requirements
$mailTemplateForm
=
$this
->
generateMainTaskMailTemplate
(
$notificationsMainTask
);
// Simply retrieve the list of audited attributes, it is a json format and require decoding.
$auditAttributesJson
=
$this
->
retrieveAuditedAttributes
(
$task
);
$auditAttributes
=
NULL
;
// To set the var and reset its value.
// Decoding the json_format into an associative array, implode allows to put all values of array together.(forming the json correctly).
foreach
(
$auditAttributesJson
as
$auditAttribute
)
{
$auditAttributes
[]
=
json_decode
(
implode
(
$auditAttribute
),
TRUE
);
}
// Simply retrieve the list of audited attributes
$auditAttributes
=
$this
->
decodeAuditAttributes
(
$task
);
// Recovering monitored attributes list from the defined notification task.
$monitoredAttrs
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsattributes'
];
// Management of Supann Status
$monitoredSupannResource
[
'resource'
]
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsresource'
];
$monitoredSupannResource
[
'state'
]
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsstate'
];
$monitoredSupannResource
[
'subState'
]
=
$notificationsMainTask
[
0
][
'fdtasksnotificationssubstate'
]
??
NULL
;
// Reformat supann
$monitoredSupannResource
=
$this
->
getSupannResourceState
(
$notificationsMainTask
[
0
]);
// Simply remove keys with 'count' reported by ldap.
$this
->
gateway
->
unsetCountKeys
(
$monitoredAttrs
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredSupannResource
);
// Verify if there is a match between audited attributes and monitored attributes from main task. (values to values, not keys).
$matchingAttrs
=
NULL
;
// Allows to define but reset variable as well.
if
(
!
empty
(
$auditAttributes
))
{
foreach
(
$auditAttributes
as
$auditAttribute
=>
$attributeName
)
{
foreach
(
$monitoredAttrs
as
$monitoredAttr
)
{
// We actually need to verify attributeName as it can be NULL following specific audit elements ...
if
((
!
empty
(
$attributeName
))
&&
array_key_exists
(
$monitoredAttr
,
$attributeName
))
{
$matchingAttrs
[]
=
$monitoredAttr
;
}
}
}
// Verification if supannRessourceEtatDate with criteria from main tasks are matched.
if
(
$monitoredSupannResource
[
'resource'
][
0
]
!==
'NONE'
)
{
if
(
$this
->
verifySupannState
(
$monitoredSupannResource
,
$auditAttributes
))
{
// Simply create a match between audited and supannRessourceEtat, allowing further process below.
$matchingAttrs
[]
=
'supannRessourceEtat'
;
}
}
// Find matching attributes between audited and monitored attributes
$matchingAttrs
=
$this
->
findMatchingAttributes
(
$auditAttributes
,
$monitoredAttrs
);
// Verify Supann resource state if applicable
if
(
$this
->
shouldVerifySupannResource
(
$monitoredSupannResource
,
$auditAttributes
))
{
// Adds it to the mating attrs for further notification process.
$matchingAttrs
[]
=
'supannRessourceEtat'
;
}
if
(
!
empty
(
$matchingAttrs
))
{
...
...
@@ -136,6 +115,81 @@ class Notifications implements EndpointInterface
return
$result
;
}
/**
* Determine if Supann resource verification is needed.
*
* @param array $monitoredSupannResource
* @param array|null $auditAttributes
* @return bool
*/
private
function
shouldVerifySupannResource
(
array
$monitoredSupannResource
,
?array
$auditAttributes
):
bool
{
if
(
!
empty
(
$auditAttributes
))
{
return
$monitoredSupannResource
[
'resource'
][
0
]
!==
'NONE'
&&
$this
->
verifySupannState
(
$monitoredSupannResource
,
$auditAttributes
);
}
return
FALSE
;
}
/**
* Get the Supann resource state.
*
* @param array $notificationsMainTask
* @return array
*/
private
function
getSupannResourceState
(
array
$notificationsMainTask
):
array
{
return
[
'resource'
=>
$notificationsMainTask
[
'fdtasksnotificationsresource'
],
'state'
=>
$notificationsMainTask
[
'fdtasksnotificationsstate'
],
'subState'
=>
$notificationsMainTask
[
'fdtasksnotificationssubstate'
]
??
NULL
];
}
/**
* Decode audit attributes from the task.
*
* @param array $task
* @return array|null
*/
private
function
decodeAuditAttributes
(
array
$task
):
?array
{
$auditAttributesJson
=
$this
->
retrieveAuditedAttributes
(
$task
);
$auditAttributes
=
[];
// Decoding the json_format into an associative array, implode allows to put all values of array together.(forming the json correctly).
foreach
(
$auditAttributesJson
as
$auditAttribute
)
{
$auditAttributes
[]
=
json_decode
(
implode
(
$auditAttribute
),
TRUE
);
}
return
$auditAttributes
;
}
/**
* Find matching attributes between audit and monitored attributes.
*
* @param array|null $auditAttributes
* @param array $monitoredAttrs
* @return array
*/
private
function
findMatchingAttributes
(
?array
$auditAttributes
,
array
$monitoredAttrs
):
array
{
$matchingAttrs
=
[];
if
(
!
empty
(
$auditAttributes
))
{
foreach
(
$auditAttributes
as
$attributeName
)
{
foreach
(
$monitoredAttrs
as
$monitoredAttr
)
{
if
(
!
empty
(
$attributeName
)
&&
array_key_exists
(
$monitoredAttr
,
$attributeName
))
{
$matchingAttrs
[]
=
$monitoredAttr
;
}
}
}
}
return
$matchingAttrs
;
}
/**
* @param array $supannResource
* @param array $auditedAttrs
...
...
@@ -375,5 +429,4 @@ class Notifications implements EndpointInterface
return
$result
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets