| 1 | package SharePoint::SOAPHandler; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.008000; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | #our @ISA = qw(CopyTree::VendorProof); | ||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use base qw(CopyTree::VendorProof); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Authen::NTLM qw/ntlmv2/;ntlmv2('sp'); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | #use base happens at compile time, so we don't get the runtime error from our, saying that | ||||||||||||||||||||||||||||||||
| 11 | #Can't locate package CopyTree::VendorProof for @SharePoint::SOAPHandler::ISA at (eval 8) line 2. | ||||||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = '0.0013'; | |||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | #use SOAP::Data; #included in SOAP::Lite | ||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use LWP::Debug; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use MIME::Base64 (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use File::Basename (); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub new{ | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 25 | 0 | my $class=shift; | |||||||||||||||||||||||||||||||
| 26 | 0 | my %args = @_; #not used, we set default args in bless, then offer option to reset | |||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | Carp::croak("Options to LWP::UserAgent should be key/value pairs, not hash reference") | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 28 | if ref($_[1]) eq 'HASH'; | ||||||||||||||||||||||||||||||||
| 29 | #NOTE: you will get an error "Attempt to bless into a reference at lib/SharePoint/soaphandler.pm line 24" if you (accidentally) called a method that doesn't exist. | ||||||||||||||||||||||||||||||||
| 30 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||
| 31 | sp_creds_uaargs => [(keep_alive=>1)], #requires for NTLM | ||||||||||||||||||||||||||||||||
| 32 | sp_creds_uaagent => 'Mozilla/5.0', | ||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | }, $class; | ||||||||||||||||||||||||||||||||
| 36 | 0 | return $self; | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub sp_creds_uaargs{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_uaargs: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 42 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 44 | #$inst->{'sp_creds_uaargs'}= [@_]; $inst; #mon aug 2 | ||||||||||||||||||||||||||||||||
| 45 | 0 | $inst->{'sp_creds_uaargs'}= shift; $inst; | |||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | 0 | else{@{$inst ->{'sp_creds_uaargs'}}} | |||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub sp_creds_domain{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_domain: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 50 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 52 | 0 | my $site = shift; | |||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ($site =~/%20/){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 54 | 0 | Carp::carp("Do not use %20 for spaces\n"); | |||||||||||||||||||||||||||||||
| 55 | 0 | $site =~s/%20/ /g; | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | 0 | $inst->{'sp_creds_domain'}=$site; $inst; | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | 0 | else{$inst ->{'sp_creds_domain'}} | |||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | sub sp_creds_user{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_user: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 64 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | 0 | my $domuser = shift; | |||||||||||||||||||||||||||||||
| 67 | 0 | my ($dom, $user)=split /\\/, $domuser; | |||||||||||||||||||||||||||||||
| 68 | 0 | $dom = uc($dom); | |||||||||||||||||||||||||||||||
| 69 | 0 | $domuser = join('\\', $dom, $user); | |||||||||||||||||||||||||||||||
| 70 | 0 | $inst->{'sp_creds_user'}= $domuser; $inst;} | |||||||||||||||||||||||||||||||
| 71 | 0 | else{$inst ->{'sp_creds_user'}} | |||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | sub sp_creds_password{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_password: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 74 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | if (@_){ $inst->{'sp_creds_password'}= shift; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 76 | 0 | else{$inst ->{'sp_creds_password'}} | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | #string, "Mozilla/5.0" | ||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub sp_creds_uaagent{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_uaagent: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 80 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if (@_){ $inst->{'sp_creds_uaagent'}= shift; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 82 | 0 | else{$inst ->{'sp_creds_uaagent'}} | |||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub sp_creds_credentials{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_credentials: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 86 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if (@_){ $inst->{'sp_creds_credentials'}= [@_]; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 0 | else{@{$inst ->{'sp_creds_credentials'}}} | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | #user agent object | ||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | sub sp_creds_schema_ua{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_schema_ua: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 92 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | if (@_){ $inst ->{'sp_creds_schema_ua'}=shift; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 94 | 0 | else{$inst -> {'sp_creds_schema_ua'}} | |||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||
| 96 | #sp_authorized root is the root web address just above the Shared Documents link | ||||||||||||||||||||||||||||||||
| 97 | #that the user cred is authorized to post | ||||||||||||||||||||||||||||||||
| 98 | #e.g., https://sharepoint.shit.net/sitelevel/subsitelevel/collaboration | ||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub sp_authorizedroot{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_authorizedroot: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 100 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | 0 | my $site = shift; | |||||||||||||||||||||||||||||||
| 103 | 0 | $site =~s/\/$//; #auto removes trailing slashes | |||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | if ($site =~/%20/){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 105 | 0 | Carp::carp("Do not use %20 for spaces\n"); | |||||||||||||||||||||||||||||||
| 106 | 0 | $site =~s/%20/ /g; | |||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||
| 108 | 0 | $inst->{'sp_authorizedroot'}=$site; $inst; | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | 0 | else{$inst ->{'sp_authorizedroot'}} | |||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | sub slvti{ | ||||||||||||||||||||||||||||||
|
Subroutine
slvti: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 113 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | if (@_){ $inst->{'slvti'}= shift; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 115 | 0 | else{$inst ->{'slvti'}} | |||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub sluri{ | ||||||||||||||||||||||||||||||
|
Subroutine
sluri: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 118 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (@_){$inst->{'sluri'}= shift;$inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 0 | else{$inst ->{'sluri'}} | |||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||
| 122 | #sitedata lists dirs | ||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | sub slsitedataobj{ | ||||||||||||||||||||||||||||||
|
Subroutine
slsitedataobj: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 124 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | if (@_){ $inst->{'slsitedataobj'}= shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $inst->{'slsitedataobj'}->on_action(sub{"$_[0]$_[1]"}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 127 | 0 | $inst; | |||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||
| 129 | 0 | else{$inst ->{'slsitedataobj'}} | |||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | sub slcopyobj{ | ||||||||||||||||||||||||||||||
|
Subroutine
slcopyobj: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 132 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 133 | 0 | ▶ | if (@_){ $inst->{'slcopyobj'}= shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | $inst->{'slcopyobj'}->on_action(sub{"$_[0]$_[1]"}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 135 | 0 | $inst; | |||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | 0 | else{$inst ->{'slcopyobj'}} | |||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | #dws creates and deletes dirs | ||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | sub sldwsobj{ | ||||||||||||||||||||||||||||||
|
Subroutine
sldwsobj: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 141 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if (@_){ $inst->{'sldwsobj'}= shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | $inst->{'sldwsobj'}->on_action(sub{"$_[0]$_[1]"}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 144 | 0 | $inst; | |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||
| 146 | 0 | else{$inst ->{'sldwsobj'}} | |||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||
| 148 | #list enables deleting of single files and listing list items, whatever that means for sharepoint | ||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | sub sllistobj{ | ||||||||||||||||||||||||||||||
|
Subroutine
sllistobj: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 150 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if (@_){ $inst->{'sllistobj'}= shift; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $inst->{'sllistobj'}->on_action(sub{"$_[0]$_[1]"}); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 153 | 0 | $inst; | |||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||
| 155 | 0 | else{$inst ->{'sllistobj'}} | |||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||
| 159 | #if there are shell env variables to tell anything to go through a proxy server, | ||||||||||||||||||||||||||||||||
| 160 | #this swtich says either to follow(0) or ignore(1) the proxy directions | ||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub sp_creds_proxy{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_proxy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 162 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if (@_){ $inst->{'sp_creds_proxy'}=[@_] ; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 164 | 0 | else{@{$inst ->{'sp_creds_proxy'}}} | |||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | sub sp_creds_noproxy{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_creds_noproxy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 167 | 0 | my $inst = shift; | |||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if (@_){ $inst->{'sp_creds_noproxy'}= [@_]; $inst;} | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 169 | 0 | else{@{$inst ->{'sp_creds_noproxy'}}} | |||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||
| 171 | #sp_connect requires two ua's, one for LWP and one for SOAP::Lite operations | ||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub sp_connect_lwp{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_connect_lwp: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 173 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | Carp::carp("sp_creds_uaargs not set\n") if (! $soap_inst->sp_creds_uaargs); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if (! $soap_inst->sp_creds_domain){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 176 | 0 | Carp::croak("sp_creds_domain not set\n"); | |||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | ▶ | elsif ($soap_inst->sp_creds_domain =~m/http/ or $soap_inst->sp_creds_domain =~m/\/\//){ | |||||||||||||||||||||||||||||||
|
Condition0%0/3
$soap_inst->sp_creds_domain =~ /http/ or $soap_inst->sp_creds_domain =~ m[//]
MC/DC0%0/2
$soap_inst->sp_creds_domain =~ /http/ or $soap_inst->sp_creds_domain =~ m[//]
$soap_inst->sp_creds_domain =~ /http/
$soap_inst->sp_creds_domain =~ m[//]
Truth table0%0/3
A or B
A= $soap_inst->sp_creds_domain =~ /http/B= $soap_inst->sp_creds_domain =~ m[//]
| |||||||||||||||||||||||||||||||||
| 179 | 0 | Carp::croak("sp_creds_domain should not contain protocol\n". | |||||||||||||||||||||||||||||||
| 180 | "use 'sharepoint.site:443' instead of 'https://sharepoint.site:443'" | ||||||||||||||||||||||||||||||||
| 181 | ); | ||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | Carp::carp("sp_creds_user not set\n") if (! $soap_inst->sp_creds_user); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | Carp::carp("sp_creds_password not set\n") if (! $soap_inst->sp_creds_password); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | Carp::carp("sp_creds_uaagent not set\n") if (! $soap_inst->sp_creds_uaagent); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 186 | #skip this sub if LWP shema_ua is already set | ||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if (ref $soap_inst ->sp_creds_schema_ua){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 188 | 0 | return $soap_inst; | |||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||
| 190 | 0 | $soap_inst ->sp_creds_credentials($soap_inst->sp_creds_domain, '', $soap_inst->sp_creds_user, $soap_inst->sp_creds_password); | |||||||||||||||||||||||||||||||
| 191 | 0 | my $sp_schema_ua = LWP::UserAgent->new($soap_inst->sp_creds_uaargs); | |||||||||||||||||||||||||||||||
| 192 | #LWP wants credentials in an array, not arrayref | ||||||||||||||||||||||||||||||||
| 193 | 0 | $sp_schema_ua -> credentials($soap_inst->sp_creds_credentials); | |||||||||||||||||||||||||||||||
| 194 | 0 | $sp_schema_ua ->agent($soap_inst->sp_creds_uaagent); | |||||||||||||||||||||||||||||||
| 195 | #$sp_schema_ua ->proxy($soap_inst->sp_creds_proxy); | ||||||||||||||||||||||||||||||||
| 196 | #$sp_schema_ua ->no_proxy($soap_inst->sp_creds_noproxy); | ||||||||||||||||||||||||||||||||
| 197 | 0 | $soap_inst ->sp_creds_schema_ua($sp_schema_ua); | |||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||
| 199 | 0 | return ($soap_inst); | |||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | sub sp_sitedataini{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_sitedataini: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 204 | 0 | my $soap_inst=shift; | |||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | return $soap_inst if (ref $soap_inst->slsitedataobj); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 0 | $soap_inst -> sp_connect_lwp; | |||||||||||||||||||||||||||||||
| 207 | 0 | $soap_inst->slvti($soap_inst->sp_authorizedroot()."/_vti_bin/SiteData.asmx"); | |||||||||||||||||||||||||||||||
| 208 | #remember this uri requires a trailing slash | ||||||||||||||||||||||||||||||||
| 209 | 0 | $soap_inst -> sluri("http://schemas.microsoft.com/sharepoint/soap/"); | |||||||||||||||||||||||||||||||
| 210 | #Important. SOAP::Lite-> proxy wants arguments to be in list form; uaargs is the same format | ||||||||||||||||||||||||||||||||
| 211 | #as LWP would prefer; | ||||||||||||||||||||||||||||||||
| 212 | #credentials is NOT the same: LWP wants array; SOAP::Lite::porxy wants array ref | ||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||
| 214 | 0 | $soap_inst -> slsitedataobj ( SOAP::Lite ->proxy ($soap_inst->slvti, $soap_inst ->sp_creds_uaargs, credentials =>[$soap_inst->sp_creds_credentials]) ); | |||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||
| 216 | 0 | $soap_inst -> slsitedataobj() -> schema->useragent($soap_inst->sp_creds_schema_ua); | |||||||||||||||||||||||||||||||
| 217 | #$soap_inst -> slsitedataobj() -> uri($s_uri); | ||||||||||||||||||||||||||||||||
| 218 | 0 | $soap_inst -> slsitedataobj() -> uri($soap_inst->sluri); | |||||||||||||||||||||||||||||||
| 219 | 0 | return $soap_inst;#->slsitedataobj; | |||||||||||||||||||||||||||||||
| 220 | #@$slsitedataobj ->on_action(sub{qq/$_[0]$_[1]/});#now included in sub slsitedataobj | ||||||||||||||||||||||||||||||||
| 221 | #################IMPORTANT################# | ||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | #=head1 IMPORTANT: Microsoft soap doesn't use header info that SOAP::Lite requires | ||||||||||||||||||||||||||||||||
| 224 | # | ||||||||||||||||||||||||||||||||
| 225 | #i.e. SOAP::Lite uses default schemas.soap.come/#Function (uri#method), while MS uses | ||||||||||||||||||||||||||||||||
| 226 | #shcemas.microsoft.com/soap/Function (urimethod) | ||||||||||||||||||||||||||||||||
| 227 | # | ||||||||||||||||||||||||||||||||
| 228 | #If this is not set properly, you will get soap errors. Took me 3 days printing Dumpers | ||||||||||||||||||||||||||||||||
| 229 | #to everything to discover this stupid error | ||||||||||||||||||||||||||||||||
| 230 | # | ||||||||||||||||||||||||||||||||
| 231 | #This function is now included when setting the obj, i.e. sub slsitedataobj | ||||||||||||||||||||||||||||||||
| 232 | # | ||||||||||||||||||||||||||||||||
| 233 | #=cut | ||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | sub carpenvproxy{ | ||||||||||||||||||||||||||||||
|
Subroutine
carpenvproxy: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 237 | 0 | Carp::carp("_____________________________________________________________\nYou might get a 500 can't connect error (Bad service 'port/')\n\t if your sharepoint is on https, and you have\n\t a https_proxy env var set,\n\t but the sharepoint does NOT require a proxy to connect.\n\t to fix, remove your https_proxy env variable. (in perl, delete \$ENV{'https_proxy'})\n\t". | |||||||||||||||||||||||||||||||
| 238 | " bug from SOAP::Transport::HTTP, calls for SUPER::env_proxy from LWP::UserAgent, does\n\t". | ||||||||||||||||||||||||||||||||
| 239 | " not know how to deal with https_proxy (no_proxy does not override https_proxy, only http_proxy\n"); | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub fdls{ | ||||||||||||||||||||||||||||||
|
Subroutine
fdls: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 244 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 245 | #my $sp_sitedataobj = shift; | ||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | Carp::croak("fdls item must be an instance, not a class\n") unless (ref $soap_inst); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||
| 248 | 0 | my $lsoption=shift; #'d', 'f', 'fdarrayrefs' or undef | |||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | $lsoption ='' if !($lsoption); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 250 | 0 | my $rootsearchfolder =shift; | |||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | $rootsearchfolder = $soap_inst ->SUPER::path if (!$rootsearchfolder); #'Shared Documents' or 'Shared Documents/something' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 252 | 0 | $rootsearchfolder=~s/\/$//;#removes trailing slashes, should be trouble | |||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | $soap_inst ->sp_sitedataini if (!ref $soap_inst->slsitedataobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 255 | 0 | my $sp_sitedataobj= $soap_inst->slsitedataobj; | |||||||||||||||||||||||||||||||
| 256 | 0 | my $in_strfolderurl=SOAP::Data::name('strFolderUrl'=>$rootsearchfolder); | |||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 258 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||
| 260 | 0 | my $enufolderobj=$sp_sitedataobj->EnumerateFolder($in_strfolderurl); | |||||||||||||||||||||||||||||||
| 261 | #SHAREPOINT BUG STUPID: if only 1 item is returned, we get a hashref; | ||||||||||||||||||||||||||||||||
| 262 | #if more than 1 item is returned, we get an array ref of hashrefs | ||||||||||||||||||||||||||||||||
| 263 | #if no items returned, we get scalar undef | ||||||||||||||||||||||||||||||||
| 264 | #REMEMBER: EnumerateFolder DOES NOT work on files - must test parent dir first | ||||||||||||||||||||||||||||||||
| 265 | 0 | my $resultref = $enufolderobj -> body ->{'EnumerateFolderResponse'}{'vUrls'}{'_sFPUrl'}; | |||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if (ref $resultref eq 'HASH'){#fix stupid SHAREPOINT bug | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 267 | 0 | $resultref = [$resultref]; | |||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | #Carp::carp("resultref is ". print Dumper $resultref); | ||||||||||||||||||||||||||||||||
| 271 | 0 | delete $soap_inst->{'sp_sitedataenufolderret'}; | |||||||||||||||||||||||||||||||
| 272 | 0 | $soap_inst->{'sp_sitedataenufolderret'}->{'dir'}=[]; | |||||||||||||||||||||||||||||||
| 273 | 0 | $soap_inst->{'sp_sitedataenufolderret'}->{'file'}=[]; | |||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ($resultref){ #$resultref is undef if no items returned | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 275 | 0 | for my $item (@$resultref){ | |||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ($item->{'IsFolder'} eq 'true'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 277 | #print "[d] ".$item->{'Url'}."\n";# if ($item->{'IsFolder'} eq 'true'); #Url, IsFolder, LastModified | ||||||||||||||||||||||||||||||||
| 278 | 0 | push @{$soap_inst->{'sp_sitedataenufolderret'}->{'dir'}}, $item ->{'Url'}; | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | else { | ||||||||||||||||||||||||||||||||
| 281 | #print "[f] ".$item->{'Url'}."\n"; | ||||||||||||||||||||||||||||||||
| 282 | 0 | push @{$soap_inst->{'sp_sitedataenufolderret'}->{'file'}}, $item ->{'Url'}; | |||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||
| 284 | }#end for my $item | ||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||
| 286 | 0 | $soap_inst ->SUPER::fdls_ret ( $lsoption, \@{$soap_inst->{'sp_sitedataenufolderret'}->{'file'}}, \@{$soap_inst->{'sp_sitedataenufolderret'}->{'dir'}} ); | |||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub sp_sitedatagetlistcol{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_sitedatagetlistcol: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 291 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | $soap_inst ->sp_sitedataini if (!ref $soap_inst->slsitedataobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 293 | 0 | my $sp_sitedataobj= $soap_inst->slsitedataobj; | |||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 295 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||
| 297 | 0 | my $getlistcolobj=$sp_sitedataobj->GetListCollection(); | |||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||
| 299 | 0 | my $resultref = $getlistcolobj -> body->{'GetListCollectionResponse'}{'vLists'}{'_sList'}; | |||||||||||||||||||||||||||||||
| 300 | 0 | return $resultref; | |||||||||||||||||||||||||||||||
| 301 | #the return is an array ref of hash refs of keys and values | ||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub sp_copyini{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_copyini: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 306 | 0 | my $soap_inst=shift; | |||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return $soap_inst if (ref $soap_inst->slcopyobj); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 308 | 0 | $soap_inst -> sp_connect_lwp; | |||||||||||||||||||||||||||||||
| 309 | 0 | $soap_inst->slvti($soap_inst->sp_authorizedroot()."/_vti_bin/Copy.asmx"); | |||||||||||||||||||||||||||||||
| 310 | #remember this uri requires a trailing slash | ||||||||||||||||||||||||||||||||
| 311 | 0 | $soap_inst -> sluri("http://schemas.microsoft.com/sharepoint/soap/"); | |||||||||||||||||||||||||||||||
| 312 | #Important. SOAP::Lite-> proxy wants arguments to be in list form; uaargs is the same format | ||||||||||||||||||||||||||||||||
| 313 | #as LWP would prefer; | ||||||||||||||||||||||||||||||||
| 314 | #credentials is NOT the same: LWP wants array; SOAP::Lite::porxy wants array ref | ||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||
| 316 | 0 | $soap_inst -> slcopyobj ( SOAP::Lite ->proxy ($soap_inst->slvti, $soap_inst ->sp_creds_uaargs, credentials =>[$soap_inst->sp_creds_credentials]) ); | |||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||
| 318 | 0 | $soap_inst -> slcopyobj() -> schema->useragent($soap_inst->sp_creds_schema_ua); | |||||||||||||||||||||||||||||||
| 319 | #$soap_inst -> slcopyobj() -> uri($s_uri); | ||||||||||||||||||||||||||||||||
| 320 | 0 | $soap_inst -> slcopyobj() -> uri($soap_inst->sluri); | |||||||||||||||||||||||||||||||
| 321 | 0 | return $soap_inst;#->slcopyobj; | |||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||
| 323 | #memory is a ref to a scalar, in bin mode | ||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub read_into_memory{ | ||||||||||||||||||||||||||||||
|
Subroutine
read_into_memory: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 325 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 326 | 0 | my $sourcepath =shift; #return obj from sitedataenufolder, e.g., "Shared Documents/index.html" | |||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $sourcepath=$soap_inst->SUPER::path if (!$sourcepath); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $soap_inst->sp_copyini if (!ref $soap_inst->slcopyobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 330 | 0 | my $sp_copyobj= $soap_inst->slcopyobj; | |||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 332 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||
| 334 | 0 | my $in_strfileurl=SOAP::Data::name('Url'=>$soap_inst->sp_authorizedroot()."/".$sourcepath); | |||||||||||||||||||||||||||||||
| 335 | 0 | my $getcopy=$sp_copyobj->GetItem($in_strfileurl); | |||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||
| 337 | 0 | my $result_bin=MIME::Base64::decode_base64( $getcopy -> body->{'GetItemResponse'}{'Stream'} ); | |||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | Carp::carp("source file/dir on sharepoint [$sourcepath] does not exit (no stream) - ignoring this entry\n") if (! $result_bin); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||
| 340 | #IMPORTANT: GetItem returns NO ERROR on files that doesn't exist | ||||||||||||||||||||||||||||||||
| 341 | 0 | return (\$result_bin); #I decided to not decode the file in case it's a binary. | |||||||||||||||||||||||||||||||
| 342 | #will rely on calling program to decode it to make data transfer safe | ||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||
| 346 | #memory is a ref to a scalar, in bin mode | ||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub write_from_memory{ | ||||||||||||||||||||||||||||||
|
Subroutine
write_from_memory: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 348 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 349 | 0 | my $binref =shift; | |||||||||||||||||||||||||||||||
| 350 | 0 | my $destinationurl = shift;# in this version, I will only support writeing to one single dest | |||||||||||||||||||||||||||||||
| 351 | #Shared Documents/something - do not use full path | ||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | $destinationurl = $soap_inst ->SUPER::path if (!$destinationurl); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 353 | 0 | my $sourceurl='local'; #doesn't do shit, but needs a value for it to work | |||||||||||||||||||||||||||||||
| 354 | 0 | my $fields=[];# = shift; #array ref of field items, | |||||||||||||||||||||||||||||||
| 355 | #my $stream = ; #array ref of single item byte stream, from slurping in binmode | ||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | Carp::carp ("no destinationurl in write_from_memory \n") if (! $destinationurl); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | Carp::carp ("no stream in write_from_memory \n") if (! $$binref); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | $soap_inst->sp_copyini if (!ref $soap_inst->slcopyobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 360 | 0 | my $sp_copyobj= $soap_inst->slcopyobj; | |||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 362 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||
| 364 | 0 | my $in_sourceurl=SOAP::Data::name('SourceUrl'=>$sourceurl); | |||||||||||||||||||||||||||||||
| 365 | #construct full path | ||||||||||||||||||||||||||||||||
| 366 | 0 | my $destinationurls = [$destinationurl]; | |||||||||||||||||||||||||||||||
| 367 | 0 | for my $destfileurl(@$destinationurls){ | |||||||||||||||||||||||||||||||
| 368 | 0 | $destfileurl = $soap_inst->sp_authorizedroot(). "/".$destfileurl; | |||||||||||||||||||||||||||||||
| 369 | 0 | $destfileurl = SOAP::Data::name ('string' => $destfileurl); | |||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||
| 371 | 0 | my $in_destinationurls=&soaparrayfmt("DestinationUrls", $destinationurls); | |||||||||||||||||||||||||||||||
| 372 | 0 | my $in_fields=&soaparrayfmt("Fields", $fields); | |||||||||||||||||||||||||||||||
| 373 | 0 | my $in_stream = SOAP::Data::name ('Stream' =>MIME::Base64::encode_base64($$binref)); | |||||||||||||||||||||||||||||||
| 374 | 0 | my $copyresult = $sp_copyobj ->CopyIntoItems($in_sourceurl, $in_destinationurls, $in_fields, $in_stream); | |||||||||||||||||||||||||||||||
| 375 | 0 | return $copyresult->body; #returns the same msg if file exists vs copy success | |||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | sub copy_local_files{ | ||||||||||||||||||||||||||||||
|
Subroutine
copy_local_files: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 382 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 383 | 0 | my $sourceurl=shift; | |||||||||||||||||||||||||||||||
| 384 | 0 | my $destinationurl = shift;# SCALAR now, different from sp_copyremotefiles | |||||||||||||||||||||||||||||||
| 385 | #Shared Documents/something - do not use full path | ||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | Carp::carp ("no sourceurl in sp_copypostfile \(copy no source\)\n") if (! $sourceurl); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 387 | 0 | ▶ | Carp::carp ("no destinationurls in sp_copypostfile \(copy no destination\)\n") if (! $destinationurl); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | $soap_inst -> sp_copyini if (!ref $soap_inst->slcopyobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 389 | 0 | my $sp_copyobj= $soap_inst->slcopyobj; | |||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 391 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||
| 393 | 0 | my $in_sourceurl=SOAP::Data::name('SourceUrl'=>$soap_inst->sp_authorizedroot().'/'.$sourceurl); | |||||||||||||||||||||||||||||||
| 394 | #construct full path | ||||||||||||||||||||||||||||||||
| 395 | 0 | my $destinationurls = [$destinationurl]; | |||||||||||||||||||||||||||||||
| 396 | 0 | for my $destfileurl(@$destinationurls){ | |||||||||||||||||||||||||||||||
| 397 | 0 | $destfileurl = $soap_inst->sp_authorizedroot(). "/".$destfileurl; | |||||||||||||||||||||||||||||||
| 398 | 0 | $destfileurl = SOAP::Data::name ('string' => $destfileurl); | |||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||
| 401 | 0 | my $in_destinationurls=&soaparrayfmt("DestinationUrls", $destinationurls); | |||||||||||||||||||||||||||||||
| 402 | 0 | my $copyresult = $sp_copyobj ->CopyIntoItemsLocal($in_sourceurl, $in_destinationurls) ->body; | |||||||||||||||||||||||||||||||
| 403 | 0 | return $copyresult; | |||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||
| 406 | #not really necessary functionally since write_from_memory and read_to_memory covers this, | ||||||||||||||||||||||||||||||||
| 407 | #but it is more efficient since files are moved within sharepoint | ||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | sub soaparrayfmt { | ||||||||||||||||||||||||||||||
|
Subroutine
soaparrayfmt: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 411 | 0 | my $arraytitle = shift; | |||||||||||||||||||||||||||||||
| 412 | 0 | my $arrayref = shift; | |||||||||||||||||||||||||||||||
| 413 | 0 | my $in_arraytitle =SOAP::Data::name($arraytitle =>\SOAP::Data::value( | |||||||||||||||||||||||||||||||
| 414 | SOAP::Data::name('anonymous' => @$arrayref) | ||||||||||||||||||||||||||||||||
| 415 | )#end value | ||||||||||||||||||||||||||||||||
| 416 | );#end name | ||||||||||||||||||||||||||||||||
| 417 | 0 | return $in_arraytitle; | |||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | sub sp_dwsini{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_dwsini: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 422 | 0 | my $soap_inst=shift; | |||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | return $soap_inst if (ref $soap_inst->sldwsobj); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 424 | 0 | $soap_inst -> sp_connect_lwp; | |||||||||||||||||||||||||||||||
| 425 | 0 | $soap_inst->slvti($soap_inst->sp_authorizedroot()."/_vti_bin/Dws.asmx"); | |||||||||||||||||||||||||||||||
| 426 | ####dws is the only one where the uri is in a sub dir | ||||||||||||||||||||||||||||||||
| 427 | #remember this uri requires a trailing slash | ||||||||||||||||||||||||||||||||
| 428 | 0 | $soap_inst -> sluri("http://schemas.microsoft.com/sharepoint/soap/dws/"); | |||||||||||||||||||||||||||||||
| 429 | #Important. SOAP::Lite-> proxy wants arguments to be in list form; uaargs is the same format | ||||||||||||||||||||||||||||||||
| 430 | #as LWP would prefer; | ||||||||||||||||||||||||||||||||
| 431 | #credentials is NOT the same: LWP wants array; SOAP::Lite::porxy wants array ref | ||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||
| 433 | 0 | $soap_inst -> sldwsobj ( SOAP::Lite ->proxy ($soap_inst->slvti, $soap_inst ->sp_creds_uaargs, credentials =>[$soap_inst->sp_creds_credentials]) ); | |||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||
| 435 | 0 | $soap_inst -> sldwsobj() -> schema->useragent($soap_inst->sp_creds_schema_ua); | |||||||||||||||||||||||||||||||
| 436 | #$soap_inst -> sldwsobj() -> uri($s_uri); | ||||||||||||||||||||||||||||||||
| 437 | 0 | $soap_inst -> sldwsobj() -> uri($soap_inst->sluri); | |||||||||||||||||||||||||||||||
| 438 | 0 | return $soap_inst;#->sldwsobj; | |||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub sp_dws{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_dws: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 443 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 444 | 0 | my $dirtomk = shift; | |||||||||||||||||||||||||||||||
| 445 | 0 | my $action=shift; | |||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | $soap_inst->sp_dwsini if (!ref $soap_inst->sldwsobj ); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 447 | 0 | my $sp_dwsobj= $soap_inst->sldwsobj; | |||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 449 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||
| 451 | #url starts with Shared Documents | ||||||||||||||||||||||||||||||||
| 452 | 0 | my $in_url=SOAP::Data::name('url'=>$dirtomk); | |||||||||||||||||||||||||||||||
| 453 | 0 | my $dwsret; | |||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | if ($action eq 'mkdir'){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 455 | 0 | $dwsret = $sp_dwsobj ->CreateFolder($in_url)->body->{'CreateFolderResponse'}{'CreateFolderResult'}; | |||||||||||||||||||||||||||||||
| 456 | #returns "<Error ID="13">AlreadyExists</Error>" if already exists, '<Result/>' if success | ||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||
| 458 | elsif ($action eq 'rmdir'){ | ||||||||||||||||||||||||||||||||
| 459 | 0 | $dwsret = $sp_dwsobj ->DeleteFolder($in_url)->body->{'DeleteFolderResponse'}{'DeleteFolderResult'}; | |||||||||||||||||||||||||||||||
| 460 | #returns '<Result/>' if success or folder does not exist | ||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||
| 462 | 0 | return $dwsret; | |||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | sub sp_listini{ | ||||||||||||||||||||||||||||||
|
Subroutine
sp_listini: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 465 | 0 | my $soap_inst=shift; | |||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | return $soap_inst if (ref $soap_inst->sllistobj); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 467 | 0 | $soap_inst -> sp_connect_lwp; | |||||||||||||||||||||||||||||||
| 468 | 0 | $soap_inst->slvti($soap_inst->sp_authorizedroot()."/_vti_bin/Lists.asmx"); | |||||||||||||||||||||||||||||||
| 469 | ####list is the only one where the uri is in a sub dir | ||||||||||||||||||||||||||||||||
| 470 | #remember this uri requires a trailing slash | ||||||||||||||||||||||||||||||||
| 471 | 0 | $soap_inst -> sluri("http://schemas.microsoft.com/sharepoint/soap/"); | |||||||||||||||||||||||||||||||
| 472 | #Important. SOAP::Lite-> proxy wants arguments to be in list form; uaargs is the same format | ||||||||||||||||||||||||||||||||
| 473 | #as LWP would prefer; | ||||||||||||||||||||||||||||||||
| 474 | #credentials is NOT the same: LWP wants array; SOAP::Lite::porxy wants array ref | ||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||
| 476 | 0 | $soap_inst -> sllistobj ( SOAP::Lite ->proxy ($soap_inst->slvti, $soap_inst ->sp_creds_uaargs, credentials =>[$soap_inst->sp_creds_credentials]) ); | |||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||
| 478 | 0 | $soap_inst -> sllistobj() -> schema->useragent($soap_inst->sp_creds_schema_ua); | |||||||||||||||||||||||||||||||
| 479 | #$soap_inst -> sllistobj() -> uri($s_uri); | ||||||||||||||||||||||||||||||||
| 480 | 0 | $soap_inst -> sllistobj() -> uri($soap_inst->sluri); | |||||||||||||||||||||||||||||||
| 481 | 0 | return $soap_inst;#->sllistobj; | |||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||
| 483 | } | ||||||||||||||||||||||||||||||||
| 484 | #returns "<Error ID="13">AlreadyExists</Error>" if already exists, '<Result/>' if success | ||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | sub cust_mkdir { | ||||||||||||||||||||||||||||||
|
Subroutine
cust_mkdir: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 486 | 0 | my $soap_inst =shift; | |||||||||||||||||||||||||||||||
| 487 | 0 | my $dirtomk = shift; | |||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ($dirtomk eq '/' or $dirtomk eq 'Shared Documents'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$dirtomk eq "/" or $dirtomk eq "Shared Documents"
MC/DC0%0/2
$dirtomk eq "/" or $dirtomk eq "Shared Documents"
$dirtomk eq "/"
$dirtomk eq "Shared Documents"
Truth table0%0/3
A or B
A= $dirtomk eq "/"B= $dirtomk eq "Shared Documents"
| |||||||||||||||||||||||||||||||||
| 489 | 0 | Carp::carp('should not be mkdiring a root'); | |||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||
| 491 | else { | ||||||||||||||||||||||||||||||||
| 492 | 0 | $soap_inst ->sp_dws($dirtomk, 'mkdir'); | |||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||
| 496 | #returns '<Result/>' if success or folder does not exist | ||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | sub cust_rmdir{ | ||||||||||||||||||||||||||||||
|
Subroutine
cust_rmdir: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 498 | 0 | my $soap_inst =shift; | |||||||||||||||||||||||||||||||
| 499 | 0 | my $dirtomk = shift; | |||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if ($dirtomk eq '/' or $dirtomk eq 'Shared Documents'){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$dirtomk eq "/" or $dirtomk eq "Shared Documents"
MC/DC0%0/2
$dirtomk eq "/" or $dirtomk eq "Shared Documents"
$dirtomk eq "/"
$dirtomk eq "Shared Documents"
Truth table0%0/3
A or B
A= $dirtomk eq "/"B= $dirtomk eq "Shared Documents"
| |||||||||||||||||||||||||||||||||
| 501 | 0 | Carp::carp('should not be rmdiring a root'); | |||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||
| 503 | elsif ($soap_inst ->is_fd($dirtomk) eq 'd'){ | ||||||||||||||||||||||||||||||||
| 504 | 0 | $soap_inst ->sp_dws($dirtomk, 'rmdir'); | |||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||
| 506 | else { | ||||||||||||||||||||||||||||||||
| 507 | 0 | Carp::croak("wait. you told me to delete something that's not a dir. I'll stop for your protection"); | |||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||
| 510 | 0 | ▶ | sub cust_rmfile{ | ||||||||||||||||||||||||||||||
|
Subroutine
cust_rmfile: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||
| 511 | 0 | my $soap_inst=shift; | |||||||||||||||||||||||||||||||
| 512 | 0 | my $filepath =shift; | |||||||||||||||||||||||||||||||
| 513 | 0 | ▶ | Carp::croak ("cannot rmfile a non-file") if ($soap_inst->is_fd($filepath) ne 'f'); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | $soap_inst ->sp_listini if (! ref $soap_inst ->sllistobj); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 515 | 0 | my $sp_listobj = $soap_inst -> sllistobj; | |||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | if ($ENV{'https_proxy'}){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 517 | 0 | $soap_inst ->carpenvproxy; | |||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||
| 519 | #first, we need the shared documents list id to do the delete. | ||||||||||||||||||||||||||||||||
| 520 | 0 | my $shareddoclistid =$soap_inst -> {'sllistid'}{'Shared Documents'} ; | |||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | if (!$shareddoclistid){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 522 | #the dataof function returns a series of blessed references. These series of refs are not put | ||||||||||||||||||||||||||||||||
| 523 | #in an arrayref. Rather, they are just a series of blessed items. You can put it in @results, | ||||||||||||||||||||||||||||||||
| 524 | #and each item will be a SOAP::Data instance. You CANNOT access these instances through @{blah->dataof('/blah') } | ||||||||||||||||||||||||||||||||
| 525 | #the error msg will say Not an ARRAY reference | ||||||||||||||||||||||||||||||||
| 526 | 0 | my @results = $sp_listobj ->GetListCollection() ->dataof('//GetListCollectionResult/Lists/List'); | |||||||||||||||||||||||||||||||
| 527 | 0 | for my $data (@results){#{ $sp_listobj ->GetListCollection() ->dataof('//GetListCollectionResult/Lists/List') }){ | |||||||||||||||||||||||||||||||
| 528 | 0 | ▶ | if ($data->attr ->{'Title'} eq "Shared Documents"){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 529 | 0 | $shareddoclistid = $data ->attr ->{'ID'} ; | |||||||||||||||||||||||||||||||
| 530 | 0 | $soap_inst -> {'sllistid'}{'Shared Documents'}=$shareddoclistid; | |||||||||||||||||||||||||||||||
| 531 | }#end if | ||||||||||||||||||||||||||||||||
| 532 | }#end for my $data | ||||||||||||||||||||||||||||||||
| 533 | }#end if !shareddoclistid | ||||||||||||||||||||||||||||||||
| 534 | 0 | my $in_str_listname = SOAP::Data::name('listName' => $shareddoclistid); | |||||||||||||||||||||||||||||||
| 535 | 0 | my $fullqualified = $soap_inst->sp_authorizedroot().'/'.$filepath; | |||||||||||||||||||||||||||||||
| 536 | 0 | my $xml = qq#<Batch OnError="Continue" PreCalc="TRUE" ListVersion="0"> <Method ID="1" Cmd="Delete"> <Field Name="ID">3</Field> <Field Name="FileRef">$fullqualified</Field> </Method> </Batch>#; | |||||||||||||||||||||||||||||||
| 537 | 0 | my $in_str_xml_xml = SOAP::Data->type ('xml' =>qq# <updates>$xml</updates>#); | |||||||||||||||||||||||||||||||
| 538 | #basically, we want the xml to look like this: (spaces between update tags and $xml will crash the command) | ||||||||||||||||||||||||||||||||
| 539 | # <soap:Body> | ||||||||||||||||||||||||||||||||
| 540 | # <UpdateListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> | ||||||||||||||||||||||||||||||||
| 541 | # <listName>$shareddoclistid</listName> | ||||||||||||||||||||||||||||||||
| 542 | # <updates>$xml</updates> | ||||||||||||||||||||||||||||||||
| 543 | # </UpdateListItems> | ||||||||||||||||||||||||||||||||
| 544 | # </soap:Body> | ||||||||||||||||||||||||||||||||
| 545 | 0 | $sp_listobj ->UpdateListItems($in_str_listname, $in_str_xml_xml); | |||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||
| 548 | 0 | ▶ | sub is_fd{ | ||||||||||||||||||||||||||||||
|
Subroutine
is_fd: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 549 | 0 | my $soap_inst = shift; | |||||||||||||||||||||||||||||||
| 550 | 0 | my $query =shift; | |||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ($query =~m/\/$/){ #if query ends with slash 'someting/' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 552 | 0 | Carp::carp("sharepoint file/dir should not have trailing slashes\n"); | |||||||||||||||||||||||||||||||
| 553 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||
| 555 | else { | ||||||||||||||||||||||||||||||||
| 556 | 0 | my $queryparent = File::Basename::dirname($query); | |||||||||||||||||||||||||||||||
| 557 | #in sharepoint, you can't really query the root Shared Documents folder. | ||||||||||||||||||||||||||||||||
| 558 | #to do it right, you're supposed to use getlistcollection. more resources - | ||||||||||||||||||||||||||||||||
| 559 | #not doing it. | ||||||||||||||||||||||||||||||||
| 560 | 0 | ▶ | if ($queryparent eq '.'){ #result of no slashes in $query | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | if ($query eq 'Shared Documents'){ | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 562 | 0 | return 'd'; | |||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||
| 564 | 0 | else {return 0} | |||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||
| 566 | 0 | my ($testfunderparent, $testdunderparent) = $soap_inst -> fdls('fdarrayrefs' , $queryparent);#only needs to return what's defined as file | |||||||||||||||||||||||||||||||
| 567 | #my @testparent = $soap_inst -> sp_ls($queryparent, 'f');#only needs to return what's defined as file | ||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if ( @$testfunderparent + @$testdunderparent ==0){#$query can not be anything if it's parent is not a dir | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 569 | # Carp::carp("query $query 's parent is not a valid folder..check your path[$query]\n"); | ||||||||||||||||||||||||||||||||
| 570 | 0 | return 0; | |||||||||||||||||||||||||||||||
| 571 | }#end if (! @testparent) | ||||||||||||||||||||||||||||||||
| 572 | else{ | ||||||||||||||||||||||||||||||||
| 573 | 0 | my %trackmatchf; | |||||||||||||||||||||||||||||||
| 574 | 0 | for my $file (@$testfunderparent) { | |||||||||||||||||||||||||||||||
| 575 | 0 | $trackmatchf {$file} ++; | |||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||
| 577 | 0 | my %trackmatchd; | |||||||||||||||||||||||||||||||
| 578 | 0 | for my $dir (@$testdunderparent){ | |||||||||||||||||||||||||||||||
| 579 | 0 | $trackmatchd{$dir} ++; | |||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | if ($trackmatchf {$query}){ | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 583 | # Carp::carp("query $query is a file through searching parent\n"); | ||||||||||||||||||||||||||||||||
| 584 | 0 | return 'f'; | |||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||
| 586 | elsif ($trackmatchd {$query}){ | ||||||||||||||||||||||||||||||||
| 587 | 0 | return 'd'; | |||||||||||||||||||||||||||||||
| 588 | } | ||||||||||||||||||||||||||||||||
| 589 | 0 | else {return 'pd'}; | |||||||||||||||||||||||||||||||
| 590 | }#end else | ||||||||||||||||||||||||||||||||
| 591 | } #end else main test | ||||||||||||||||||||||||||||||||
| 592 | |||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||||||
| 596 | 1 | 1; | |||||||||||||||||||||||||||||||
| 597 | __END__ | ||||||||||||||||||||||||||||||||