Hi All,
We are using fileEventHandler for deploying the uploaded files and getLatest files in to targets.
If upload multiple files into Teamsite, its deploying only latest uplaoded file, but we want deploy all uploaded file into targets.
I am attaching the .ipl below, please correct me if any thing missing
----------------------------------------------------------------------------------------------------------------------
#!/teamsite/iw-home/iw-perl/bin/iwperl
#
######################################################################
# Description: The script uses the iwat clt to create handlers for
# CreateSFE, ModifyFSE, RenameFSE and DestroyFSE. If it is an images or files,
# a Open Deploy then
# invoked to deploy the files to the preview website.
######################################################################
######################################################################
# iw.cfg Modifications
#
# [iwserver]
# log_createfse=on
# log_renamefse=on
# log_destroyfse=on
# log_modifyfse=on
#
#####################################################################
######################################################################
# Command line calls to set up the hadler
#
# iwat CreateFSE "iwperl

/iw-home/local/bin/fileEventHandler.ipl"
# iwat RenameFSE "iwperl

/iw-home/local/bin/fileEventHandler.ipl"
# iwat DestroyFSE "iwperl

/iw-home/local/bin/fileEventHandler.ipl"
# iwat Update "iwperl

/iw-home/local/bin/fileEventHandler.ipl"
#
# To list all of the registered event Handlers run command: "iwlsat"
# To remove an event Handler run command: "iwrmat <ID>"
#
######################################################################
use File::Basename;
use TeamSite::Config;
$| = 1;
# Figure out our TeamSite home directory
chomp(my $iwhome = TeamSite::Config::iwgethome());
chomp(my $iwmount = TeamSite::Config::iwgetmount());
# get the teamsite passed ARGV command line parameters
my($date, $user, $role, $event, $workarea, $filepath, $modFilepath) = (
@ARGV[0..6]);
my $date = localtime();
my $deplScript = "TS_Events_Filelist_IIS";
my $logfile = $iwhome . "\\local\\logs\\fileEventHandler.log";
dtvlog("\nTEST $workarea $event $filepath", $logfile);
# Limit processing to 'main' workarea in 'aetv' branch.
if ($workarea eq '\\default\\main\\DIRECTV\\SITE_LAUNCH\\WORKAREA\\DIRECTV_CONTENT') {
my $file="";
#If it is an update event then Get Latest was issued need to get the $filepath and $modFilepath
if ($event eq "Update") {
HandleGetLatest();
exit;
}
#If it is an update event then Get Latest was issued need to get the $filepath and $modFilepath
if ($filepath =~ m/^\\zz_lfm_/) {
if ($event eq "RenameFSE") {
$filepath = $modFilepath;
$modFilepath = -1;
} else {
dtvlog("$event Temporary TeamSite file $filepath, ignoring.", $logfile);
exit;
}
}
# reset the attributes on the file
# Create the system command and run it.
my $fullfilepath = $iwmount . $workarea . $filepath;
#my $syscommand = "ATTRIB -R -S -H -A $fullfilepath";
#dtvlog("$event The syscommand is: $syscommand", $logfile);
#my $cmd = qq|$syscommand|;
#dtvlog ("Command completed: $cmd\n", $logfile);
#my $result = qx|$cmd|;
dtvlog("$event The fullfilepath is: $fullfilepath", $logfile);
if ($fullfilepath =~ m/^DIRECTV_CONTENT\\DTVAPP\\META-INF/
|| $fullfilepath =~ m/^DIRECTV_CONTENT\\DTVAPP\\WEB-INF/)
{
# Ignore Web-inf and meta-inf
dtvlog("$event Application Related TeamSite file $filepath, ignoring.", $logfile);
exit;
} elsif ($filepath =~ m/\\DTVAPP\\/ || $filepath =~ m/\\DTVAPP\//) {
#if it is DTVAPP use the DTVAPP deployment script
$deplScript = "TS_Events_Filelist_WLS";
$filepath =~ s/\\DTVAPP//;
$modFilepath =~ s/\\DTVAPP//;
dtvlog("$event I am here: $filepath $modFilepath", $logfile);
}
# Get the path from the root of the workarea.
if ($modFilepath) {
$file = $filepath . "\n" . $modFilepath;
} else {
$file = $filepath;
}
# Start Logging
dtvlog("$event Script Command Line: $iwhome\\local\\bin\\fileEventHandler.ipl \"$date\" $user $role $event $workarea $filepath $modFilepath", $logfile);
#Do FILE DEPLOYMENT
my $time = time();
my $name = $file;
$name =~ s/.+\///g;
$name =~ s/\.*//;
my $id = $time . "_" . $$;
$filelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY_" . $id . ".cfg";
# $filelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY" . ".cfg";
dtvlog("File List Test..==$filelist", $logfile);
open (LIST, ">$filelist")||(dtvlog("Problem Opening File: $filelist", $logfile));
print LIST $file . "\n";
close (LIST);
dtvlog("Starting Deployment", $logfile);
sleep(3);
odDeployFilelist($deplScript, $filelist, $logfile, $id);
dtvlog("Deployment Done", $logfile);
exit;
} else {
#If this is not the right workarea do nothing!!
exit;
}
##################################
# Handle GetLatest Event
##################################
sub HandleGetLatest
{
my $opid = $filepath;
$filepath = "";
my $geteventcmd = "$iwhome\\bin\\iwevents -n -u $opid";
my
@eventfiles = `$geteventcmd`;
my $iisfiles = "";
my $jspfiles = "";
#dtvlog("TEST I am in HandleGetLatest: $geteventcmd", $logfile);
# Flip through all files in an event.
foreach (
@eventfiles) {
#dtvlog("TEST I am in eventfiles: $_", $logfile);
## print "$_\n";
my (
@field) = split("\t", $_);
my $filetype = $field[2];
if ($filetype eq 'DIRECTORY') { next }
## For now we only care about files
my $filename = $field[3];
$filename =~ s#^/##;
my $update = $field[1]; #ADD/MODIFY/DELETE
my $ddtype;
if ($update eq 'ADD') { $ddtype = 'UPDATE'; }
elsif ($update eq 'FORCEADD') { $ddtype = 'UPDATE'; }
elsif ($update eq 'MODIFY') { $ddtype = 'UPDATE'; }
elsif ($update eq 'FORCEMODIFY') { $ddtype = 'UPDATE'; }
elsif ($update eq 'DELETE') { $ddtype = 'DELETE'; }
elsif ($update eq 'FORCEDELETE') { $ddtype = 'DELETE'; }
else { next }
$filename =~ s#^/##;
dtvlog("Update file: $filename $ddtype", $logfile);
#now we need to add this file to the correct filelist variable
my $otherfile = $filename;
if ($otherfile =~ m/\\DTVAPP\\META-INF/
|| $otherfile =~ m/\\DTVAPP\\WEB-INF/)
{
# Ignore Web-inf and meta-inf
dtvlog("$event Application Related TeamSite file $filename, ignoring.", $logfile);
} elsif ($otherfile =~ m/\\DTVAPP\\/ || $otherfile =~ m/\\DTVAPP\//) {
#if it is DTVAPP use the DTVAPP deployment script
$otherfile =~ s/\\DTVAPP//;
$jspfiles = $jspfiles . $otherfile . "\n";
} else {
#in this case we have IIS file
$iisfiles = $iisfiles . $otherfile . "\n";
}
} #foreach
my $time = time();
my $id = $time . "_" . $$;
# my $iisfilelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY_IIS" . $id . ".cfg";
#my $jspfilelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY_JSP_" . $id . ".cfg";
my $iisfilelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY_IIS" . ".cfg";
my $jspfilelist = $iwhome . "\\local\\logs\\temp\\filelist_OPENDEPLOY_JSP". ".cfg";
if (! $iisfiles eq "") {
open (LIST, ">$iisfilelist")||($error = 1);
print LIST $iisfiles;
#dtvlog("$otherfilelist \n Other files: \n $otherfiles", $logfile);
close (LIST);
odDeployFilelist("TS_Events_Filelist_IIS", $iisfilelist, $logfile, $id);
}
if (! $jspfiles eq "") {
open (LIST, ">$jspfilelist")||($error = 1);
print LIST $jspfiles;
#dtvlog("$otherfilelist \n Other files: \n $otherfiles", $logfile);
close (LIST);
odDeployFilelist("TS_Events_Filelist_WLS", $jspfilelist, $logfile, $id);
}
} #HandleGetLatest
sub odDeployFilelist {
my $filename = shift;
my $filelist = shift;
my $logfile = shift;
my $name = shift;
#my $odcommand = "D:\\Interwoven\\OpenDeployNG\\bin\\iwodcmd start $filename -k filelist=$filelist -inst _" . $name;
my $odcommand = "D:\\Interwoven\\OpenDeployNG\\bin\\iwodcmd start $filename -k filelist=$filelist";
dtvlog("About to run: $odcommand", $logfile);
# Create the OpenDeploy command and run it.
$cmd = qq|$odcommand|;
dtvlog ("Command completed: $cmd\n", $logfile);
my $result = qx|$cmd|;
dtvlog ($result . "\n", $logfile);
#close(PROCESS);
}
# Logs a line of text
sub dtvlog {
my $message = shift;
my $logfile = shift;
open (LOG, ">>$logfile");
($sec, $min, $hrs, $day, $month, $year) = (localtime) [0,1,2,3,4,5];
printf LOG "%04d-%02d-%02d %02d:%02d:%02d ", $year+1900, $month+1, $day, $hrs, $min, $sec;
print LOG "$message\n";
close LOG;
}
----------------------------------------------------------------------------------------------------
Thanks in advance...
Interwoven Developer.................