| 1 | # Net::SDEE.pm | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # $Id: SDEE.pm,v 1.4 2005/03/07 20:12:39 jminieri Exp $ | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # Copyright (c) 2004-2005 Joe Minieri <jminieri@mindspring.com> and OpenService (www.open.com). | ||||||||||||||||||||||||||||
| 6 | # All rights reserved. | ||||||||||||||||||||||||||||
| 7 | # This program is free software; you can redistribute it and/or modify it under the same | ||||||||||||||||||||||||||||
| 8 | # terms as Perl itself. | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | package Net::SDEE; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use 5.006001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use XML::SDEE; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Net::SDEE::Query; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Net::SDEE::Session; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Net::SDEE::Subscription; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||||
| 27 | # These are the parameters for each query type | ||||||||||||||||||||||||||||
| 28 | 1 | my @_open_parameters = qw/action sessionId startTime events idsAlertSeverities force/; | |||||||||||||||||||||||||||
| 29 | 1 | my @_get_parameters = qw/action sessionId subscriptionId timeout maxNbrOfEvents confirm/; | |||||||||||||||||||||||||||
| 30 | 1 | my @_cancel_parameters = qw/action sessionId subscriptionId/; | |||||||||||||||||||||||||||
| 31 | 1 | my @_close_parameters = qw/action sessionId subscriptionId/; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | ########################################################################################## | ||||||||||||||||||||||||||||
| 34 | # | ||||||||||||||||||||||||||||
| 35 | # AUTOLOAD get/set methods when they're generic | ||||||||||||||||||||||||||||
| 36 | # | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | use vars '$AUTOLOAD'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: not called CC=4 SCAR=27.2
| |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 40 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $method =($AUTOLOAD =~ /.*::([_\w]+)$/)[0]; | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | return if $method eq 'DESTROY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | # | ||||||||||||||||||||||||||||
| 46 | # Pass all unknown methods to the session object | ||||||||||||||||||||||||||||
| 47 | 0 | ▶ | unless(defined($method) and exists($self->{ _session }->{ $method })) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $method and exists $self->{"_session"}{$method}
MC/DC0%0/2
defined $method and exists $self->{"_session"}{$method}
defined $method
exists $self->{"_session"}{$method}
Truth table0%0/3
A and B
A= defined $methodB= exists $self->{"_session"}{$method}
| |||||||||||||||||||||||||||||
| 48 | 0 | $self->call_debug("No such parameter $method"); | |||||||||||||||||||||||||||
| 49 | 0 | return undef; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | # set this up for next time | ||||||||||||||||||||||||||||
| 53 | 0 | ▶ | *{$AUTOLOAD} = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 54 | 0 | my ($self, $value) = @_; | |||||||||||||||||||||||||||
| 55 | 0 | ▶ | if (defined($value)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | return $self->{ _session }->{ $method } = $value; | |||||||||||||||||||||||||||
| 57 | } else { | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return defined($self->{ _session }->{ $method })?$self->{ _session }->{ $method }:undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 0 | }; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | goto &$AUTOLOAD; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||
| 65 | ########################################################################################## | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | ########################################################################################## | ||||||||||||||||||||||||||||
| 68 | # | ||||||||||||||||||||||||||||
| 69 | # Debug callback routine | ||||||||||||||||||||||||||||
| 70 | # | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub debug_log { | ||||||||||||||||||||||||||
|
Subroutine
debug_log: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 72 | 0 | my $message = shift; | |||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | unless(defined($message)) { return undef } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # caller 0 = current | ||||||||||||||||||||||||||||
| 77 | # caller 1 = eval | ||||||||||||||||||||||||||||
| 78 | # caller 2 = call_debug | ||||||||||||||||||||||||||||
| 79 | # caller 3 = actual caller | ||||||||||||||||||||||||||||
| 80 | 0 | my $caller = (caller(3))[3]; | |||||||||||||||||||||||||||
| 81 | 0 | print "$caller() $message\n"; | |||||||||||||||||||||||||||
| 82 | #warn $message; | ||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub debug_callback { | ||||||||||||||||||||||||||
|
Subroutine
debug_callback: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | my ($self, $callback) = @_; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | unless(defined($callback)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | return $self->{ _debug_callback }; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | $self->set_callback('_debug_callback', $callback); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub call_debug { | ||||||||||||||||||||||||||
|
Subroutine
call_debug: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | return unless(defined($self->{ _debug_callback })); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if(defined($self->debug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | my $handler = $self->{ _debug_callback }; | |||||||||||||||||||||||||||
| 102 | 0 | my $ret = eval { &$handler(@_); }; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | ▶ | return (defined($ret))?$ret:$@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | } else { | ||||||||||||||||||||||||||||
| 106 | 0 | return undef; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | sub debug { | ||||||||||||||||||||||||||
|
Subroutine
debug: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 111 | 0 | my ($self, $debug) = @_; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if(defined($debug)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | 0 | return $self->{ _debug } = $debug; | |||||||||||||||||||||||||||
| 115 | } else { | ||||||||||||||||||||||||||||
| 116 | 0 | return $self->{ _debug }; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | # | ||||||||||||||||||||||||||||
| 121 | ########################################################################################## | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | ########################################################################################## | ||||||||||||||||||||||||||||
| 124 | # | ||||||||||||||||||||||||||||
| 125 | # Callback setting/executing methods | ||||||||||||||||||||||||||||
| 126 | # | ||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub execute { | ||||||||||||||||||||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 128 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | return unless(defined($self->{ _callback })); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | my $handler = $self->{ _callback }; | |||||||||||||||||||||||||||
| 133 | 0 | my $ret = eval { | |||||||||||||||||||||||||||
| 134 | # block out die/warn just in case... | ||||||||||||||||||||||||||||
| 135 | 0 | local $SIG{ __DIE__ }; | |||||||||||||||||||||||||||
| 136 | 0 | local $SIG{ __WARN__ }; | |||||||||||||||||||||||||||
| 137 | 0 | &$handler(@_); | |||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | ▶ | return (defined($ret))?$ret:$@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | 0 | ▶ | sub set_callback { | ||||||||||||||||||||||||||
|
Subroutine
set_callback: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 144 | 0 | my ($self, $which, $callback) = @_; | |||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | 0 | ▶ | unless(defined($callback) and defined($which)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $callback and defined $which
MC/DC0%0/2
defined $callback and defined $which
defined $callback
defined $which
Truth table0%0/3
A and B
A= defined $callbackB= defined $which
| |||||||||||||||||||||||||||||
| 147 | 0 | return $self->{ $which }; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if(ref($callback) eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | 0 | $self->{ $which } = $callback; | |||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||
| 153 | 0 | return undef; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub callback { | ||||||||||||||||||||||||||
|
Subroutine
callback: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | 0 | my ($self, $callback) = @_; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | unless(defined($callback)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | return $self->{ _callback }; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 0 | $self->set_callback('_callback', $callback); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | ▶ | sub returnResults { | ||||||||||||||||||||||||||
|
Subroutine
returnResults: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 168 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 169 | 0 | my $results = shift; | |||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if(defined($self->returnRawXML)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | # return RAW XML only | ||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return defined($self->callback)?$self->execute($results, @_):$results; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 0 | my $returnContents; | |||||||||||||||||||||||||||
| 177 | 0 | ▶ | unless(defined($self->{ _xml }->XML)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 178 | 0 | $self->{ _xml }->consume($results); | |||||||||||||||||||||||||||
| 179 | 0 | ▶ | if($self->{ _xml }->isError) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 0 | $self->call_debug( $self->{ _xml }->getErrorString ); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | if(defined($self->returnXML)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 185 | # return PROCESSED XML only | ||||||||||||||||||||||||||||
| 186 | 0 | $returnContents = $self->{ _xml }->SDEE; | |||||||||||||||||||||||||||
| 187 | 0 | ▶ | return defined($self->callback)?$self->execute($returnContents, @_):$returnContents; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | # return only events | ||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if(defined($self->callback)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | # execute "callback" for each event | ||||||||||||||||||||||||||||
| 193 | 0 | my @returnValues; | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | while(my $event = $self->{ _xml }->getEvent) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | my $ret = $self->execute($event, @_); | |||||||||||||||||||||||||||
| 196 | 0 | push(@returnValues, $ret); | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | 0 | return \@returnValues; | |||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||
| 200 | 0 | $returnContents = $self->{ _xml }->getEvents; | |||||||||||||||||||||||||||
| 201 | 0 | ▶ | return defined($self->callback)?$self->execute($returnContents, @_):$returnContents; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | # | ||||||||||||||||||||||||||||
| 205 | ########################################################################################## | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | ########################################################################################## | ||||||||||||||||||||||||||||
| 208 | # | ||||||||||||||||||||||||||||
| 209 | # set/get methods | ||||||||||||||||||||||||||||
| 210 | # | ||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub returnRawXML { | ||||||||||||||||||||||||||
|
Subroutine
returnRawXML: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 212 | 0 | my ($self, $returnRawXML) = @_; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if(defined($returnRawXML)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | return $self->{ _returnRawXML } = $returnRawXML; | |||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||
| 217 | 0 | return $self->{ _returnRawXML }; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | sub returnXML { | ||||||||||||||||||||||||||
|
Subroutine
returnXML: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 222 | 0 | my ($self, $returnXML) = @_; | |||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if(defined($returnXML)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 0 | return $self->{ _returnXML } = $returnXML; | |||||||||||||||||||||||||||
| 226 | } else { | ||||||||||||||||||||||||||||
| 227 | 0 | return $self->{ _returnXML }; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub returnEvents { | ||||||||||||||||||||||||||
|
Subroutine
returnEvents: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | 0 | my ($self, $returnEvents) = @_; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | ▶ | if(defined($returnEvents)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 0 | return $self->{ _returnEvents } = $returnEvents; | |||||||||||||||||||||||||||
| 236 | } else { | ||||||||||||||||||||||||||||
| 237 | 0 | return $self->{ _returnEvents }; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | # | ||||||||||||||||||||||||||||
| 241 | ########################################################################################## | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | ########################################################################################## | ||||||||||||||||||||||||||||
| 244 | # | ||||||||||||||||||||||||||||
| 245 | 0 | ▶ | sub getNumberOfSubscriptions { | ||||||||||||||||||||||||||
|
Subroutine
getNumberOfSubscriptions: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | return scalar keys %{$self->{ _subscriptions }}; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub getSubscription { | ||||||||||||||||||||||||||
|
Subroutine
getSubscription: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 252 | 0 | my ($self, $subscriptionId) = @_; | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | unless(defined($subscriptionId) and exists($self->{ _subscriptions }->{ $subscriptionId })) { return undef } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $subscriptionId and exists $self->{"_subscriptions"}{$subscriptionId}
MC/DC0%0/2
defined $subscriptionId and exists $self->{"_subscriptions"}{$subscriptionId}
defined $subscriptionId
exists $self->{"_subscriptions"}{$subscriptionId}
Truth table0%0/3
A and B
A= defined $subscriptionIdB= exists $self->{"_subscriptions"}{$subscriptionId}
| |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | return $self->{ _subscriptions }->{ $subscriptionId }; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 0 | ▶ | sub getSubscriptionIds { | ||||||||||||||||||||||||||
|
Subroutine
getSubscriptionIds: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 260 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | my @returnValue = keys %{$self->{ _subscriptions }}; | |||||||||||||||||||||||||||
| 263 | 0 | return \@returnValue; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | sub addSubscription { | ||||||||||||||||||||||||||
|
Subroutine
addSubscription: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 267 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if( $#_ == 0 and ref($_[0]) eq 'Net::SDEE::Subscription') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$#_ == 0 and ref $_[0] eq "Net::SDEE::Subscription"
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "Net::SDEE::Subscription"
$#_ == 0
ref $_[0] eq "Net::SDEE::Subscription"
Truth table0%0/3
A and B
A= $#_ == 0B= ref $_[0] eq "Net::SDEE::Subscription"
| |||||||||||||||||||||||||||||
| 270 | 0 | return $self->open($_[0]); | |||||||||||||||||||||||||||
| 271 | } else { | ||||||||||||||||||||||||||||
| 272 | 0 | return $self->open(Net::SDEE::Subscription->new(@_)); | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | sub deleteSubscription { | ||||||||||||||||||||||||||
|
Subroutine
deleteSubscription: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 277 | 0 | my ($self, $subscriptionId) = @_; | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 0 | ▶ | unless(defined($subscriptionId) and exists($self->{ _subscriptions }->{ $subscriptionId })) { return undef } | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $subscriptionId and exists $self->{"_subscriptions"}{$subscriptionId}
MC/DC0%0/2
defined $subscriptionId and exists $self->{"_subscriptions"}{$subscriptionId}
defined $subscriptionId
exists $self->{"_subscriptions"}{$subscriptionId}
Truth table0%0/3
A and B
A= defined $subscriptionIdB= exists $self->{"_subscriptions"}{$subscriptionId}
| |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 0 | return delete($self->{ _subscriptions }->{ $subscriptionId }); | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub addQuery { | ||||||||||||||||||||||||||
|
Subroutine
addQuery: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 285 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if( $#_ == 0 and ref($_[0]) eq 'Net::SDEE::Query') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$#_ == 0 and ref $_[0] eq "Net::SDEE::Query"
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "Net::SDEE::Query"
$#_ == 0
ref $_[0] eq "Net::SDEE::Query"
Truth table0%0/3
A and B
A= $#_ == 0B= ref $_[0] eq "Net::SDEE::Query"
| |||||||||||||||||||||||||||||
| 288 | 0 | $self->{ _query } = $_[0]; | |||||||||||||||||||||||||||
| 289 | } else { | ||||||||||||||||||||||||||||
| 290 | 0 | $self->{ _query } = Net::SDEE::Query->new(@_); | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub addSession { | ||||||||||||||||||||||||||
|
Subroutine
addSession: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 295 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if( $#_ == 0 and ref($_[0]) eq 'Net::SDEE::Session') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$#_ == 0 and ref $_[0] eq "Net::SDEE::Session"
MC/DC0%0/2
$#_ == 0 and ref $_[0] eq "Net::SDEE::Session"
$#_ == 0
ref $_[0] eq "Net::SDEE::Session"
Truth table0%0/3
A and B
A= $#_ == 0B= ref $_[0] eq "Net::SDEE::Session"
| |||||||||||||||||||||||||||||
| 298 | 0 | $self->{ _session } = $_[0]; | |||||||||||||||||||||||||||
| 299 | } else { | ||||||||||||||||||||||||||||
| 300 | 0 | $self->{ _session } = Net::SDEE::Session->new(@_); | |||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | # | ||||||||||||||||||||||||||||
| 304 | ########################################################################################## | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | ########################################################################################## | ||||||||||||||||||||||||||||
| 307 | # | ||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 309 | 0 | my $caller = shift; | |||||||||||||||||||||||||||
| 310 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | ▶ | my $class = (ref($caller) or $caller); | ||||||||||||||||||||||||||
|
Condition0%0/3
ref $caller || $caller
MC/DC0%0/2
ref $caller || $caller
ref $caller
$caller
Truth table0%0/3
A || B
A= ref $callerB= $caller
| |||||||||||||||||||||||||||||
| 313 | 0 | my $self = bless { | |||||||||||||||||||||||||||
| 314 | '_xml', XML::SDEE->new(), | ||||||||||||||||||||||||||||
| 315 | '_session', undef, | ||||||||||||||||||||||||||||
| 316 | '_subscriptions', {}, | ||||||||||||||||||||||||||||
| 317 | '_query', undef, | ||||||||||||||||||||||||||||
| 318 | '_callback', undef, | ||||||||||||||||||||||||||||
| 319 | '_returnXML', undef, | ||||||||||||||||||||||||||||
| 320 | '_returnRawXML', undef, | ||||||||||||||||||||||||||||
| 321 | '_returnEvents', undef, | ||||||||||||||||||||||||||||
| 322 | '_debug', undef, | ||||||||||||||||||||||||||||
| 323 | '_debug_callback', \&debug_log | ||||||||||||||||||||||||||||
| 324 | }, $class; | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if(defined($args{ Session }) and ref($args{ Session }) eq 'Net::SDEE::Session') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args{"Session"} and ref $args{"Session"} eq "Net::SDEE::Session"
MC/DC0%0/2
defined $args{"Session"} and ref $args{"Session"} eq "Net::SDEE::Session"
defined $args{"Session"}
ref $args{"Session"} eq "Net::SDEE::Session"
Truth table0%0/3
A and B
A= defined $args{"Session"}B= ref $args{"Session"} eq "Net::SDEE::Session"
| |||||||||||||||||||||||||||||
| 327 | 0 | $self->{ _session } = $args{ Session }; | |||||||||||||||||||||||||||
| 328 | 0 | delete($args{ Session }); # clean up for loop @ bottom | |||||||||||||||||||||||||||
| 329 | } else { | ||||||||||||||||||||||||||||
| 330 | 0 | $self->{ _session } = Net::SDEE::Session->new(); | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | ▶ | if(defined($args{ Query }) and ref($args{ Query }) eq 'Net::SDEE::Query') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $args{"Query"} and ref $args{"Query"} eq "Net::SDEE::Query"
MC/DC0%0/2
defined $args{"Query"} and ref $args{"Query"} eq "Net::SDEE::Query"
defined $args{"Query"}
ref $args{"Query"} eq "Net::SDEE::Query"
Truth table0%0/3
A and B
A= defined $args{"Query"}B= ref $args{"Query"} eq "Net::SDEE::Query"
| |||||||||||||||||||||||||||||
| 334 | 0 | $self->{ _query } = $args{ Query }; | |||||||||||||||||||||||||||
| 335 | 0 | delete($args{ Query }); # clean up for loop @ bottom | |||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | # we should NOT have both, so drop the subscription if we do... | ||||||||||||||||||||||||||||
| 338 | 0 | delete($args{ Subscription }); | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | # | ||||||||||||||||||||||||||||
| 342 | # Note, we cannot pass in a Subscription because we need an Subscription ID that | ||||||||||||||||||||||||||||
| 343 | # we only get when we connect. | ||||||||||||||||||||||||||||
| 344 | # | ||||||||||||||||||||||||||||
| 345 | 0 | foreach my $attribute ( keys %args ) { | |||||||||||||||||||||||||||
| 346 | 0 | $self->$attribute( $args{ $attribute }); | |||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | # | ||||||||||||||||||||||||||||
| 350 | # If we've set 'returnXML', then make sure 'returnEvents' is unset. | ||||||||||||||||||||||||||||
| 351 | # Also, if 'returnXML' is not set, make sure 'returnEvents' is set. | ||||||||||||||||||||||||||||
| 352 | 0 | ▶ | if(defined($self->returnRawXML)) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 353 | # return RAW XML | ||||||||||||||||||||||||||||
| 354 | 0 | $self->returnXML(undef); | |||||||||||||||||||||||||||
| 355 | 0 | $self->returnEvents(undef); | |||||||||||||||||||||||||||
| 356 | } elsif(defined($self->returnXML)) { | ||||||||||||||||||||||||||||
| 357 | # return PROCESSED XML | ||||||||||||||||||||||||||||
| 358 | 0 | $self->returnRawXML(undef); | |||||||||||||||||||||||||||
| 359 | 0 | $self->returnEvents(undef); | |||||||||||||||||||||||||||
| 360 | } else { | ||||||||||||||||||||||||||||
| 361 | # return Events | ||||||||||||||||||||||||||||
| 362 | 0 | $self->returnXML(undef); | |||||||||||||||||||||||||||
| 363 | 0 | $self->returnRawXML(undef); | |||||||||||||||||||||||||||
| 364 | 0 | $self->returnEvents(1); | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | return $self; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | # | ||||||||||||||||||||||||||||
| 371 | # Opens a session | ||||||||||||||||||||||||||||
| 372 | # Parameters: | ||||||||||||||||||||||||||||
| 373 | # - action = open | ||||||||||||||||||||||||||||
| 374 | # - startTime = 0 | ||||||||||||||||||||||||||||
| 375 | # - events = evtype | ||||||||||||||||||||||||||||
| 376 | # - idsAlertSeverities | ||||||||||||||||||||||||||||
| 377 | # - force = yes/no | ||||||||||||||||||||||||||||
| 378 | # | ||||||||||||||||||||||||||||
| 379 | # Response Code: | ||||||||||||||||||||||||||||
| 380 | # - errLimitExceeded = server has reached subscription limit | ||||||||||||||||||||||||||||
| 381 | # | ||||||||||||||||||||||||||||
| 382 | # Return subscriptionID | ||||||||||||||||||||||||||||
| 383 | # | ||||||||||||||||||||||||||||
| 384 | 0 | ▶ | sub open { | ||||||||||||||||||||||||||
|
Subroutine
open: not called CC=13 SCAR=52.0
Pod
documented
| |||||||||||||||||||||||||||||
| 385 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | my $subscription = undef; | |||||||||||||||||||||||||||
| 388 | 0 | ▶ | if(defined($_[0]) and ref($_[0]) eq 'Net::SDEE::Subscription') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $_[0] and ref $_[0] eq "Net::SDEE::Subscription"
MC/DC0%0/2
defined $_[0] and ref $_[0] eq "Net::SDEE::Subscription"
defined $_[0]
ref $_[0] eq "Net::SDEE::Subscription"
Truth table0%0/3
A and B
A= defined $_[0]B= ref $_[0] eq "Net::SDEE::Subscription"
| |||||||||||||||||||||||||||||
| 389 | # got a subscription object | ||||||||||||||||||||||||||||
| 390 | 0 | $subscription = shift; | |||||||||||||||||||||||||||
| 391 | } else { | ||||||||||||||||||||||||||||
| 392 | # don't have a subscription object, make a new one | ||||||||||||||||||||||||||||
| 393 | 0 | $subscription = Net::SDEE::Subscription->new(); | |||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | unless(defined($subscription->sessionId)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if(my $sessionId = $self->{ _session }->sessionId) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | 0 | $subscription->sessionId($sessionId); | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if( $#_ > 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 403 | 0 | my %args = @_; | |||||||||||||||||||||||||||
| 404 | 0 | foreach my $parameter (keys %args) { | |||||||||||||||||||||||||||
| 405 | 0 | $subscription->$parameter($args{ $parameter }); | |||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | $subscription->action('open'); | |||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | my $LWP = LWP::UserAgent->new(); | |||||||||||||||||||||||||||
| 412 | my $result = $LWP->post( | ||||||||||||||||||||||||||||
| 413 | $self->{ _session }->getURL, | ||||||||||||||||||||||||||||
| 414 | $subscription->getParameters(@_open_parameters), | ||||||||||||||||||||||||||||
| 415 | 0 | %{ $self->{ _session }->getHeader } | |||||||||||||||||||||||||||
| 416 | ); | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if($result->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 419 | 0 | ▶ | if($self->{ _session }->Type eq 'subscription') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if(my $cookie = $result->headers('SET-COOKIE')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | 0 | $self->{ _session }->Cookie((split(';', $cookie))[0]); | |||||||||||||||||||||||||||
| 422 | } else { | ||||||||||||||||||||||||||||
| 423 | 0 | $self->call_debug( 'No Cookie in header: ' . $result->status_line); | |||||||||||||||||||||||||||
| 424 | 0 | return undef; | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 0 | $self->{ _session }->state('opened'); | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | $self->{ _xml }->reset; | |||||||||||||||||||||||||||
| 430 | 0 | $self->{ _xml }->consume($result->content); | |||||||||||||||||||||||||||
| 431 | 0 | ▶ | if(my $sessionId = $self->{ _xml }->sessionId) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 432 | 0 | $self->sessionId($sessionId); | |||||||||||||||||||||||||||
| 433 | 0 | $subscription->sessionId($sessionId); | |||||||||||||||||||||||||||
| 434 | 0 | $self->call_debug("New SessionID: $sessionId"); | |||||||||||||||||||||||||||
| 435 | } elsif($sessionId = $self->{ _session }->sessionId) { | ||||||||||||||||||||||||||||
| 436 | 0 | $self->call_debug("Existing SessionID: $sessionId"); | |||||||||||||||||||||||||||
| 437 | } else { | ||||||||||||||||||||||||||||
| 438 | 0 | $self->call_debug('NO SessionID'); | |||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if(my $subscriptionId = $self->{ _xml }->subscriptionId) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 441 | 0 | $subscription->subscriptionId($subscriptionId); | |||||||||||||||||||||||||||
| 442 | 0 | $self->{ _subscriptions }->{ $subscriptionId } = $subscription; | |||||||||||||||||||||||||||
| 443 | 0 | $self->call_debug("New SubscriptionID: $subscriptionId"); | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | } else { | ||||||||||||||||||||||||||||
| 446 | 0 | $self->call_debug( 'open failed: ' . $result->status_line); | |||||||||||||||||||||||||||
| 447 | 0 | return undef; | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | 0 | return $self->returnResults($result->content, $subscription->subscriptionId); | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | # | ||||||||||||||||||||||||||||
| 453 | # Retrieve Events | ||||||||||||||||||||||||||||
| 454 | # Parameters: | ||||||||||||||||||||||||||||
| 455 | # - action = get | ||||||||||||||||||||||||||||
| 456 | # - timeout = # (blocking, waiting for events ) | ||||||||||||||||||||||||||||
| 457 | # - maxNbrOfEvents = # | ||||||||||||||||||||||||||||
| 458 | # - confirm = yes/no | ||||||||||||||||||||||||||||
| 459 | # * unconfirmed events will be resent | ||||||||||||||||||||||||||||
| 460 | # | ||||||||||||||||||||||||||||
| 461 | # Response Codes: | ||||||||||||||||||||||||||||
| 462 | # - missedEvents - server dropped events since last retrieval | ||||||||||||||||||||||||||||
| 463 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 464 | # - errInUse - retrieval already taking place | ||||||||||||||||||||||||||||
| 465 | # | ||||||||||||||||||||||||||||
| 466 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||
| 467 | 0 | my ($self, $subscriptionId) = @_; | |||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||
| 469 | 0 | my $parameters; | |||||||||||||||||||||||||||
| 470 | 0 | ▶ | if(defined($subscriptionId)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | # setup for subscription | ||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | # perhaps should call open() to fix these? but what to do w/ returned XML? | ||||||||||||||||||||||||||||
| 474 | 0 | ▶ | unless(defined($self->{ _subscriptions }->{ $subscriptionId })) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 475 | 0 | $self->call_debug("No such subscription Id: $subscriptionId"); | |||||||||||||||||||||||||||
| 476 | 0 | return undef; | |||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||
| 478 | 0 | ▶ | unless( $self->{ _session }->state eq 'opened' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 479 | 0 | $self->call_debug('Session state is ' . $self->{ _session }->state); | |||||||||||||||||||||||||||
| 480 | 0 | return undef; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | 0 | $self->{ _subscriptions }->{ $subscriptionId }->action('get'); | |||||||||||||||||||||||||||
| 483 | 0 | $parameters = $self->{ _subscriptions }->{ $subscriptionId }->getParameters(@_get_parameters); | |||||||||||||||||||||||||||
| 484 | } else { | ||||||||||||||||||||||||||||
| 485 | # setup for query | ||||||||||||||||||||||||||||
| 486 | 0 | ▶ | unless(defined($self->{ _query })) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 487 | 0 | $self->{ _query } = Net::SDEE::Query->new(); | |||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||
| 489 | 0 | $parameters = $self->{ _query }->getParameters(@_get_parameters); | |||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | 0 | my $LWP = LWP::UserAgent->new(); | |||||||||||||||||||||||||||
| 493 | my $result = $LWP->post( | ||||||||||||||||||||||||||||
| 494 | $self->{ _session }->getURL, | ||||||||||||||||||||||||||||
| 495 | $parameters, | ||||||||||||||||||||||||||||
| 496 | 0 | %{ $self->{ _session }->getHeader } | |||||||||||||||||||||||||||
| 497 | ); | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if($result->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 500 | # | ||||||||||||||||||||||||||||
| 501 | # Response Codes: | ||||||||||||||||||||||||||||
| 502 | # - missedEvents - server dropped events since last retrieval | ||||||||||||||||||||||||||||
| 503 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 504 | # - errInUse - retrieval already taking place | ||||||||||||||||||||||||||||
| 505 | # | ||||||||||||||||||||||||||||
| 506 | } else { | ||||||||||||||||||||||||||||
| 507 | 0 | $self->call_debug('http session failed ' . $result->status_line); | |||||||||||||||||||||||||||
| 508 | 0 | $self->{ _session }->state('closed'); | |||||||||||||||||||||||||||
| 509 | 0 | return undef; | |||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||
| 511 | 0 | $self->{ _xml }->reset; | |||||||||||||||||||||||||||
| 512 | 0 | return $self->returnResults($result->content, $subscriptionId); | |||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | # | ||||||||||||||||||||||||||||
| 516 | # Cancels a blocked subscription | ||||||||||||||||||||||||||||
| 517 | # | ||||||||||||||||||||||||||||
| 518 | # Parameters: | ||||||||||||||||||||||||||||
| 519 | # - action = cancel | ||||||||||||||||||||||||||||
| 520 | # | ||||||||||||||||||||||||||||
| 521 | # Response Codes: | ||||||||||||||||||||||||||||
| 522 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 523 | # | ||||||||||||||||||||||||||||
| 524 | # Return ?? XML document? | ||||||||||||||||||||||||||||
| 525 | # | ||||||||||||||||||||||||||||
| 526 | 0 | ▶ | sub cancel { | ||||||||||||||||||||||||||
|
Subroutine
cancel: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 527 | 0 | my ($self, $subscriptionId) = @_; | |||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||
| 529 | 0 | ▶ | return undef unless(defined($subscriptionId)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||
| 531 | 0 | $self->call_debug("SubscriptionId: $subscriptionId"); | |||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 0 | my $subscription; | |||||||||||||||||||||||||||
| 534 | 0 | ▶ | unless($subscription = $self->getSubscription( $subscriptionId )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 535 | 0 | $self->call_debug("NO subscription $subscriptionId"); | |||||||||||||||||||||||||||
| 536 | 0 | return undef; | |||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||
| 539 | 0 | $subscription->action('cancel'); | |||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | 0 | my $LWP = LWP::UserAgent->new(); | |||||||||||||||||||||||||||
| 542 | my $result = $LWP->post( | ||||||||||||||||||||||||||||
| 543 | $self->{ _session }->getURL, | ||||||||||||||||||||||||||||
| 544 | $subscription->getParameters(@_cancel_parameters), | ||||||||||||||||||||||||||||
| 545 | 0 | %{ $self->{ _session }->getHeader } | |||||||||||||||||||||||||||
| 546 | ); | ||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||
| 548 | 0 | ▶ | if($result->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 549 | # | ||||||||||||||||||||||||||||
| 550 | # Response Codes: | ||||||||||||||||||||||||||||
| 551 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 552 | # | ||||||||||||||||||||||||||||
| 553 | } else { | ||||||||||||||||||||||||||||
| 554 | 0 | $self->call_debug( 'cancel failed: ' . $result->status_line); | |||||||||||||||||||||||||||
| 555 | 0 | return undef; | |||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | 0 | $self->{ _xml }->reset; | |||||||||||||||||||||||||||
| 558 | 0 | return $self->returnResults($result->content, $subscriptionId); | |||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | # | ||||||||||||||||||||||||||||
| 562 | # Closes a subscription | ||||||||||||||||||||||||||||
| 563 | # | ||||||||||||||||||||||||||||
| 564 | # Parameters: | ||||||||||||||||||||||||||||
| 565 | # - action = close | ||||||||||||||||||||||||||||
| 566 | # | ||||||||||||||||||||||||||||
| 567 | # Response Codes: | ||||||||||||||||||||||||||||
| 568 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 569 | # | ||||||||||||||||||||||||||||
| 570 | # Return ?? XML document? | ||||||||||||||||||||||||||||
| 571 | # | ||||||||||||||||||||||||||||
| 572 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||
|
Subroutine
close: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 573 | 0 | my ($self, $subscriptionId) = @_; | |||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||
| 575 | 0 | ▶ | return undef unless(defined($subscriptionId)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||
| 577 | 0 | my $subscription; | |||||||||||||||||||||||||||
| 578 | 0 | ▶ | unless($subscription = $self->getSubscription( $subscriptionId )) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 579 | 0 | $self->call_debug("NO subscription $subscriptionId"); | |||||||||||||||||||||||||||
| 580 | 0 | return undef; | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | 0 | my $sessionId = $subscription->sessionId; | |||||||||||||||||||||||||||
| 584 | 0 | $self->call_debug("SessionId: $sessionId, SubscriptionId: $subscriptionId"); | |||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||
| 586 | 0 | $subscription->action('close'); | |||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||
| 588 | 0 | my $LWP = LWP::UserAgent->new(); | |||||||||||||||||||||||||||
| 589 | my $result = $LWP->post( | ||||||||||||||||||||||||||||
| 590 | $self->{ _session }->getURL, | ||||||||||||||||||||||||||||
| 591 | $subscription->getParameters(@_close_parameters), | ||||||||||||||||||||||||||||
| 592 | 0 | %{ $self->{ _session }->getHeader } | |||||||||||||||||||||||||||
| 593 | ); | ||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||
| 595 | 0 | $self->deleteSubscription($subscriptionId); | |||||||||||||||||||||||||||
| 596 | 0 | ▶ | if($result->is_success) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 597 | # | ||||||||||||||||||||||||||||
| 598 | # Response Codes: | ||||||||||||||||||||||||||||
| 599 | # - errNotFound - subscription not open | ||||||||||||||||||||||||||||
| 600 | # | ||||||||||||||||||||||||||||
| 601 | } else { | ||||||||||||||||||||||||||||
| 602 | 0 | $self->call_debug( 'close failed: ' . $result->status_line); | |||||||||||||||||||||||||||
| 603 | 0 | return undef; | |||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||
| 605 | 0 | $self->{ _xml }->reset; | |||||||||||||||||||||||||||
| 606 | 0 | return $self->returnResults($result->content, $subscriptionId); | |||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||
| 609 | # | ||||||||||||||||||||||||||||
| 610 | # get ALL | ||||||||||||||||||||||||||||
| 611 | 0 | ▶ | sub getAll { | ||||||||||||||||||||||||||
|
Subroutine
getAll: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 612 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | 0 | my $returnAll = {}; | |||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | 0 | foreach my $subscriptionId ( @{ $self->getSubscriptionIds } ) { | |||||||||||||||||||||||||||
| 617 | 0 | ▶ | if(my $return_value =$self->get($subscriptionId)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 618 | 0 | $self->call_debug($return_value); | |||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | 0 | return $returnAll; | |||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||
| 625 | # | ||||||||||||||||||||||||||||
| 626 | # close ALL | ||||||||||||||||||||||||||||
| 627 | 0 | ▶ | sub closeAll { | ||||||||||||||||||||||||||
|
Subroutine
closeAll: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 628 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||
| 630 | 0 | my $returnAll = {}; | |||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | # need to close ALL the subscriptions | ||||||||||||||||||||||||||||
| 633 | 0 | foreach my $subscriptionId ( @{ $self->getSubscriptionIds }) { | |||||||||||||||||||||||||||
| 634 | 0 | ▶ | if(my $return_value =$self->close($subscriptionId)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 635 | 0 | $self->call_debug($return_value); | |||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||
| 639 | 0 | return $returnAll; | |||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | # | ||||||||||||||||||||||||||||
| 643 | # Close the session, just in case we forgot... | ||||||||||||||||||||||||||||
| 644 | 0 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 645 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||
| 647 | # need to close ALL the subscriptions | ||||||||||||||||||||||||||||
| 648 | 0 | $self->closeAll(); | |||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||
| 651 | # | ||||||||||||||||||||||||||||
| 652 | ########################################################################################## | ||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||
| 654 | 1 | 1; | |||||||||||||||||||||||||||
| 655 | __END__ | ||||||||||||||||||||||||||||