| 1 | #!/usr/bin/perl -w | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | package Apache::Sling::GroupUtil; | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use 5.008001; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 3 | ▶ | use Apache::Sling::URL; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | require Exporter; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | ▶ | use base qw(Exporter); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 3 | our @EXPORT_OK = (); | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 3 | our $VERSION = '0.27'; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | #{{{sub add_setup | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | 4 | ▶ | sub add_setup { | ||||||||||||||||||
|
Subroutine
add_setup: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||
| 22 | 4 | my ( $base_url, $act_on_group, $properties ) = @_; | |||||||||||||||||||
| 23 | 4 | ▶ | if ( !defined $base_url ) { croak 'No base url defined to add against!'; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 24 | 3 | ▶ | if ( !defined $act_on_group ) { croak 'No group name defined to add!'; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | # property_post_vars is set to q{} if no properties are specified: | ||||||||||||||||||||
| 27 | 2 | my $property_post_vars = | |||||||||||||||||||
| 28 | Apache::Sling::URL::properties_array_to_string($properties); | ||||||||||||||||||||
| 29 | 2 | my $post_variables = "\$post_variables = [':name','$act_on_group'"; | |||||||||||||||||||
| 30 | 2 | ▶ | if ( $property_post_vars ne q{} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 31 | 1 | $post_variables .= ",$property_post_vars"; | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | 2 | $post_variables .= "]"; | |||||||||||||||||||
| 34 | return | ||||||||||||||||||||
| 35 | 2 | "post $base_url/system/userManager/group.create.html $post_variables"; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | #}}} | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | #{{{sub add_eval | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 1 | ▶ | sub add_eval { | ||||||||||||||||||
|
Subroutine
add_eval: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 43 | 1 | my ($res) = @_; | |||||||||||||||||||
| 44 | 1 | return ( ${$res}->code eq '200' ); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | #}}} | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | #{{{sub delete_setup | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 3 | ▶ | sub delete_setup { | ||||||||||||||||||
|
Subroutine
delete_setup: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 52 | 3 | my ( $base_url, $act_on_group ) = @_; | |||||||||||||||||||
| 53 | 3 | ▶ | if ( !defined $base_url ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 1 | croak 'No base url defined to delete against!'; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 2 | ▶ | if ( !defined $act_on_group ) { croak 'No group name defined to delete!'; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 57 | 1 | my $post_variables = q{$post_variables = []}; | |||||||||||||||||||
| 58 | return | ||||||||||||||||||||
| 59 | 1 | "post $base_url/system/userManager/group/$act_on_group.delete.html $post_variables"; | |||||||||||||||||||
| 60 | } | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | #}}} | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | #{{{sub delete_eval | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 1 | ▶ | sub delete_eval { | ||||||||||||||||||
|
Subroutine
delete_eval: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 67 | 1 | my ($res) = @_; | |||||||||||||||||||
| 68 | 1 | return ( ${$res}->code eq '200' ); | |||||||||||||||||||
| 69 | } | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | #}}} | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | #{{{sub exists_setup | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 3 | ▶ | sub exists_setup { | ||||||||||||||||||
|
Subroutine
exists_setup: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 76 | 3 | my ( $base_url, $act_on_group ) = @_; | |||||||||||||||||||
| 77 | 3 | ▶ | if ( !defined $base_url ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 78 | 1 | croak 'No base url to check existence against!'; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | 2 | ▶ | if ( !defined $act_on_group ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 81 | 1 | croak 'No group to check existence of defined!'; | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | 1 | return "get $base_url/system/userManager/group/$act_on_group.json"; | |||||||||||||||||||
| 84 | } | ||||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | #}}} | ||||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | #{{{sub exists_eval | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | 1 | ▶ | sub exists_eval { | ||||||||||||||||||
|
Subroutine
exists_eval: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 91 | 1 | my ($res) = @_; | |||||||||||||||||||
| 92 | 1 | return ( ${$res}->code eq '200' ); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | #}}} | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | #{{{sub view_setup | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 6 | ▶ | sub view_setup { | ||||||||||||||||||
|
Subroutine
view_setup: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 100 | 6 | my ( $base_url, $act_on_group ) = @_; | |||||||||||||||||||
| 101 | 6 | ▶ | if ( !defined $base_url ) { croak 'No base url to view with defined!'; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 102 | 4 | ▶ | if ( !defined $act_on_group ) { croak 'No group to view defined!'; } | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 103 | 1 | return "get $base_url/system/userManager/group/$act_on_group.tidy.json"; | |||||||||||||||||||
| 104 | } | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | #}}} | ||||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | #{{{sub view_eval | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 2 | ▶ | sub view_eval { | ||||||||||||||||||
|
Subroutine
view_eval: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 111 | 2 | my ($res) = @_; | |||||||||||||||||||
| 112 | 2 | ▶ | return ( ${$res}->code eq '200' && ${$res}->content ne q{} ); | ||||||||||||||||||
|
Condition66%2/3
${$res;}->code eq '200' && ${$res;}->content ne ''
MC/DC50%1/2
${$res;}->code eq '200' && ${$res;}->content ne ''
${$res;}->code eq '200'
${$res;}->content ne ''
Truth table66%2/3
A && B
A= ${$res;}->code eq '200'B= ${$res;}->content ne ''
| |||||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | #}}} | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 3 | 1; | |||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | __END__ | ||||||||||||||||||||