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
a4f9d357
Commit
a4f9d357
authored
1 month ago
by
Oana-Eliza Alexa
Browse files
Options
Download
Patches
Plain Diff
Refactor libraries
parent
e2cd05a6
80-redesign-notifications-class
1 merge request
!76
Draft: Resolve "Redesign notifications class"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/tasks/Notifications.php
+18
-61
plugins/tasks/Notifications.php
with
18 additions
and
61 deletions
+18
-61
plugins/tasks/Notifications.php
+
18
−
61
View file @
a4f9d357
...
...
@@ -62,6 +62,7 @@ class Notifications implements EndpointInterface
foreach
(
$notificationsSubTasks
as
$task
)
{
// If the tasks must be treated - status and scheduled - process the sub-tasks
if
(
$this
->
gateway
->
statusAndScheduleCheck
(
$task
))
{
// Retrieve data from the main task
$notificationsMainTask
=
$this
->
getNotificationsMainTask
(
$task
[
'fdtasksgranularmaster'
][
0
]);
$notificationsMainTaskName
=
$task
[
'fdtasksgranularmaster'
][
0
];
...
...
@@ -98,26 +99,26 @@ class Notifications implements EndpointInterface
private
function
getMatchingAttrs
(
array
$notificationsMainTask
,
array
$task
):
array
{
// Simply retrieve the list of audited attributes
$auditAttributes
=
$this
->
decodeAuditAttributes
(
$task
);
// Simply retrieve the list of audited attributes
$auditAttributes
=
$this
->
decodeAuditAttributes
(
$task
);
// Recovering monitored attributes list from the defined notification task.
$monitoredAttrs
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsattributes'
];
// Reformat supann
$monitoredSupannResource
=
$this
->
getSupannResourceState
(
$notificationsMainTask
[
0
]);
// Recovering monitored attributes list from the defined notification task.
$monitoredAttrs
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsattributes'
];
// Reformat supann
$monitoredSupannResource
=
$this
->
getSupannResourceState
(
$notificationsMainTask
[
0
]);
// Simply remove keys with 'count' reported by ldap.
$this
->
gateway
->
unsetCountKeys
(
$monitoredAttrs
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredSupannResource
);
// Simply remove keys with 'count' reported by ldap.
$this
->
gateway
->
unsetCountKeys
(
$monitoredAttrs
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredSupannResource
);
// Find matching attributes between audited and monitored attributes
$matchingAttrs
=
$this
->
findMatching
Attribute
s
(
$auditAttributes
,
$monitoredAttrs
);
// Find matching attributes between audited and monitored attributes
$matchingAttrs
=
Utils
::
findMatching
Key
s
(
$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'
;
}
// Verify Supann resource state if applicable
if
(
$this
->
shouldVerifySupannResource
(
$monitoredSupannResource
,
$auditAttributes
))
{
// Adds it to the mating attrs for further notification process.
$matchingAttrs
[]
=
'supannRessourceEtat'
;
}
return
$matchingAttrs
;
}
...
...
@@ -172,30 +173,6 @@ class Notifications implements EndpointInterface
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
...
...
@@ -211,30 +188,10 @@ class Notifications implements EndpointInterface
}
// Get all the values only of a multidimensional array.
$auditedValues
=
$this
->
getArrayValuesRecursive
(
$auditedAttrs
);
$auditedValues
=
Utils
::
getArrayValuesRecursive
(
$auditedAttrs
);
return
in_array
(
$monitoredSupannState
,
$auditedValues
);
}
/**
* @param $array
* @return array
* Note : simply return all values of a multi-dimensional array.
*/
public
function
getArrayValuesRecursive
(
$array
)
{
$values
=
[];
foreach
(
$array
as
$value
)
{
if
(
is_array
(
$value
))
{
// If value is an array, merge its values recursively
$values
=
array_merge
(
$values
,
$this
->
getArrayValuesRecursive
(
$value
));
}
else
{
// If value is not an array, add it to the result
$values
[]
=
$value
;
}
}
return
$values
;
}
/**
* @param string $mainTaskDn
* @return array
...
...
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