how to convert my wft file into ipm
Hi,
i am using 7.4.1 TS in Linux box i want to convert my older wft file into ipm. can any one help me on this please
my workflow file
================
<template_script><![CDATA[
#------------------------------------------------------------------------------
# File email_template_html.wft
# Use scrubs and deploys the email template files
#
# This template uses the following HTTP request keys:
#
# iw_user The name (user id) of the current user
# iw_workarea The workarea's vpath
# iw_file A list of files, each relative to iw_workarea
# iw_template_file The path to this template file relative to
# iw-home/local/config/wft
#
# Copyright 2003 Interwoven Inc.
# All rights reserved.
#------------------------------------------------------------------------------
use TeamSite::Config;
# Set $debugging to 1 to enable debugging; 0 to disable.
my $debugging = 1;
# Returns the location of the TeamSite installation directory
my $iwhome = TeamSite::Config::iwgethome();
my $temp_dir = (($^O eq "MSWin32") ? "C:/temp" : "/tmp");
my $wft_base_name = __VALUE__('iw_template_file');
# Split the path into the part before the last slash (the directory) and
# the part after (the filename).
$wft_base_name =~ m|^(.*)[\\/]([^\\/]+)$|;
my $this_dir = $1;
$wft_base_name = $2;
$wft_base_name =~ s|\.[^\.]+$||; # Remove the extension
my $default_debug_file = "$iwhome/tmp/$wft_base_name.xml";
# The path to TeamSite Perl.
my $iwperl = "$iwhome/iw-perl/bin/iwperl";
my $wft_dir = TeamSite::Config::iwgetlocation("iwconfigs")."/wft";
my $command_1 = "$iwperl $iwhome/custom/bin/external_tasks/email_template_html.ipl";
for my $arg ( @arguments ) {
# Put quotes around each argument in case there are spaces.
# $command_1 .= ' "' . $arg . '"';
}
CGI_info(
tag_table_options => "border=0",
error_label_bgcolor => "#EEEEEE" ,
valid_bgcolor => "#EEEEEE" ,
);
# Add debugging fields to the form if debugging has been switched on.
if ($debugging) {
TAG_info(
iw_output_file =>
[ label => '',
html => 'Write job spec to:'
. '<input type="text" value="'
. $default_debug_file . '" size="40">',
is_required => 'false',
],
iw_debug_mode =>
[ label => '',
html => '<input type="checkbox" value="true">'
. ' Display job spec instead',
is_required => 'false',
],
);
}
# Take the list of files in 'iw_file' and sort them in unencoded form.
my @submit_file = (__ELEM__('iw_file') ? sort __VALUE__('iw_file') : ());
]]></template_script><?xml version="1.0" standalone="no"?>
<!DOCTYPE workflow SYSTEM "iwwf.dtd">
<workflow name="email_template_prod"
owner="__TAG__('iw_user');"
creator="__TAG__('iw_user');"
description="Direct Html Deploy Workflow">
<externaltask name="modify_submit_files"
owner="__TAG__('iw_user');"
description="Scrub, submit, deploy files"
start="t"
readonly="t">
<areavpath v="__TAG__('iw_workarea');"/>
<successors>
<successorset description="Retry Later">
<!-- <succ v="verify_files_in_prod"/> -->
<succ v="end"/>
</successorset>
</successors>
<command v='__INSERT__($command_1);'/>
<template_script><![CDATA[
if (@submit_file != 0)
{
__INSERT__("<files>\n");
for (my $i=0; $i < @submit_file; ++$i)
{
__INSERT__(" " x 12 . "<file path='$submit_file[$i]' " . "comment='__TAG__(File_comment_$i);'/>\n");
}
__INSERT__(" " x 8 . "</files>");
}
]]></template_script>
</externaltask>
<endtask name="end">
</endtask>
</workflow>
email_template_html.ipl
=======================
#!/opt/iba/cms/autonomy/TeamSite/iw-perl/bin/iwperl -w
#-----------------------------------------------------------------------------
# File email_template_html.ipl
#
# Use Program to scrub the email template files and deploy them to the destination
# server
#
#
#
#
#
# Migrated from Windows 2003 to Linux Redhat
#
#-----------------------------------------------------------------------------
# Flush the output buffer right away.
$| = 1;
use strict; # Try to catch errors as early as possible.
use TeamSite::WFtask;
use TeamSite::WFworkflow;
use TeamSite::Config;
use File::Basename;
use File:ath;
my $iwhome = TeamSite::Config::iwgethome();
(my $basename = $0) =~ s|^.*[\\/]||;
$iwhome =~ tr|\\|/|; # Replace backslashed with forward slashes.
my $DEBUG = 1;
my @content;
my $log_file = "$iwhome/local/logs/email_template_log.log";
my $debug_file = "$iwhome/local/logs/email_template_debug.log";
my @deleteArray;
sub INDENT () { ' ' }
my ($jobId, $taskId, $areavpath) = @ARGV[0..2];
my $job = TeamSite::WFworkflow->new($jobId);
my $task = TeamSite::WFtask->new($taskId);
my $area = $task->GetArea;
my @files = $task->GetFiles;
my $task_owner = $task->GetOwner;
$task_owner =~ m|.*\/(.*)|;
my $task_owner_id = $1;
$area =~ m|.*\/(.*)\/WORKAREA|;
my $site = $1;
$area =~ m|(.*)?\/WORKAREA\/|;
my $stage = $1."\/STAGING";
my $user = "$task_owner"; #get and store user running this script
if ($DEBUG) {
#start_debug_log();
}
log_info("Starting");
log_info("Starting");
&main();
log_info("Done");
exit;
sub main {
log_info("AREA ::: $area");
log_info("STAGE ::: $stage");
log_info("USER ::: $user");
log_info("SITE ::: $site");
delete_files();
my $delArraysize = @deleteArray;
my $fileArraysize = @files;
if ($delArraysize > 0 && $fileArraysize == 0)
{
log_info("inside delete deploy");
del_submit_files();
my ($deploy_code,$deploy_results) = del_deploy_files();;
print "\n\ndeploy_results = $deploy_results\n";
if ($deploy_code > 0)
{
&deploy_failed_email($deploy_code,$deploy_results);
}
}
elsif ($delArraysize == 0 && $fileArraysize > 0)
{
log_info("inside normal deploy");
&scrub_files();
&submit_files();
my ($deploy_code,$deploy_results) = &deploy_files();
print "\n\ndeploy_results = $deploy_results\n";
if ($deploy_code > 0)
{
&deploy_failed_email($deploy_code,$deploy_results);
}
}
# Record when the execution ended.
debug('[END ', timestamp(), " $0]");
$task->CallBack(0, "Complete");
}
sub delete_files {
print "<-------- Delete funtion starts here---------->\n";
my $tudpath = "/shared/cms/tud/cms_app/cms";
my $result = "";
my $fileList = "/tmp/email_deploy_".$taskId.".txt";
open (LIST,">$fileList");
my $cmd = "${iwhome}/bin/iwlistmod $area";
$result= `$cmd 2>&1`;
print LIST $result."\n";
close (LIST);
open (F, '<', $fileList) || die $!;
my @lines = <F>;
my $i = 0;
foreach my $file ( @files )
{
print "====== files: @files=======\n";
foreach my $line (@lines)
{
if ($line =~ $file)
{
my $filesize = -s $fileList;
print "<-------------find my file type here : $line-----> \n\n\n\n\n\n\n\n";
if ( firstTwo("$line") eq 'x+' )
{
my $tempLine = extractFile($line);
print "<-------------templine-----> \n";
# push @deleteArray, $file;
# unlink "$tudpath/$file";
#push(@deleteArray, $tempLine);
#my $delfile=$tudpath/$file;
#system (rm -f $delfile);
#push @deleteArray, $file;
#unlink "$tudpath/$file";
#my $num_removed = unlink $delfile;
#print "delete file: $num_removed files were removed\n";
#unlink $delfile or warn "Unable to remove '$delfile': $!";
#unlink $delfile;
#push(@deleteArray, $tempLine);
my $delfile="$tudpath/$file";
my $num_removed = unlink $delfile;
print "delete file: $num_removed files were removed\n";
print "file path :::: $tudpath/$file";
#system "rm -f $tudpath/$file";
}
}
else
{
}
}
$i++;
}
close (F);
my $num_removed = unlink $fileList;
print "$num_removed files were removed\n";
#unlink $fileList or warn "Unable to remove '$fileList': $!";
print "<-------- Delete funtion Ends here---------->\n";
} #delete sub
sub extractFile {
$_[0] =~ m|(\S+$)|;
return $1;
}
sub firstTwo {
$_[0] =~ m|(^.{2})|;
return $1;
}
sub del_deploy_files
{
my $r_code = 0;
my $result1 = "";
my $result2 = "";
my $fileList = "/tmp/email_deploy_".$taskId.".txt";
log_info("INSIDE DELETE DEPLOY");
log_info("FILELIST ====> $fileList ");
log_info("fileList del_deploy_files= $fileList");
open (LIST,">$fileList");
for my $file ( @deleteArray )
{
if (($file =~ m|html\\direct|))
{
print LIST $file."\n";
}
}
close LIST;
my $deployment1 = "emailtemplatehtml";
my $deployment2 = "direct_NGN_web";
my $destDir1 = "/shared/cms/tud/cms_app/cms";
#my $destDir2 = "/opt/iba/cms/apache/direct";
my $server = lc($ENV{COMPUTERNAME});
#find(\&wanted, $destDir2);
my $contentlen = @content;
for (my $i=$contentlen;$i>0;$i--) {
if (-f $content[$i]){
unlink $content[$i];
}
if(-d $content[$i]){
rmdir $content[$i];
}
}
#my $secure_bat = "E:/cmssftp/scripts/scpweb.bat";
my $cmd1= "/opt/iba/cms/autonomy/OpenDeployNG/bin/iwodcmd start \"$deployment1\" -k branch=\"/tmp\" -k dest_dir=\"$destDir1\" -k filelist=\"$fileList\"";
log_info(" deploy command ::: $cmd1");
#my $cmd2 = "/opt/iba/cms/autonomy/OpenDeployNG/bin/iwodcmd start $deployment2 -k branch=$stage -k dest_dir=$destDir2 -k filelist=$fileList ";
$result1 = `$cmd1 2>&1`;
#$result2 = `$cmd2 2>&1`;
my $status = $?;
$r_code = $status >>= 8;
#print LISTER "$r_code \n";
# if($r_code == 0)
# {
# my $cmd3 = "$secure_bat";
# print LISTER "Calling Direct Web SCP.bat \n";
# $result2= `$cmd3 2>&1`;
# }
# else
# {
# print LISTER "Could not call Direct Web SCP.bat \n";
# }
unlink $fileList;
#code to delete temp scrubbed files
for my $file ( @files ) {
my $delFilePath = "/tmp/".$file;
log_info("deleting ::: $delFilePath");
unlink $delFilePath;
}
}
#local submit to keep versions growing:
sub del_submit_files {
log_info("INSIDE DELETE SUBMIT");
for my $file ( @deleteArray )
{
my $sfile = $areavpath."/".$file;
log_info("File ===> $sfile");
my $cmd = $iwhome."/bin/iwsubmit -c \"Modified by user: $task_owner \" -i \"Modified by user: $task_owner \" " . $sfile . " \"Modified by workflow\" ";
my $return = `$cmd 2>&1`;
}
} #submit_files sub
sub deploy_failed_email
{
my ($dep_code,$dep_results) = @_;
my $email_to = $task_owner_id."\@transunion.com";
my $email_from = "noreply\@transunion.com";
my $email_subject = $ENV{COMPUTERNAME} . " - Direct Html Prod Deploy Failed" ;
my $email_body = "Direct Html Prod Deploy Failed\n\nPlease contact the CMS Team\n" ;
my %mail = ( To => "$email_to",
From => "$email_from",
Subject => "$email_subject",
smtp_temp => '10.216.36.18',
smtp => 'smtpint-n.corp.transunion.com',
smtp_old => 'linmail1prd.tuc.com'
);
my $message = <<END_OF_BODY;
$email_body
Job: $jobId
Task: $taskId
END_OF_BODY
if (scalar @files)
{
$message .= "Files:\n";
for my $file ( @files )
{
#$file =~ m|html\\direct\\(.*)|;
$file =~ m|.*(\..*$)|;
$message .= $1."\n";
}
}
$message .= "\n\n" . "= = = " x 10 . "\n\nOpenDeploy Results: ".$dep_code."\n$dep_results\n" ;
$mail{body} = $message;
sendmail(%mail) or die $Mail:endmail::error;
}
sub submit_files
{
if (scalar @files) {
for my $file ( @files ) {
my $fullFile = $areavpath."/".$file;
log_info("fullFile path in submit files = $fullFile");
my $cmd = $iwhome."/bin/iwsubmit -c \"Modified by user: $task_owner \" -i \"Modified by user: $task_owner \" " . $fullFile . " \"Modified by workflow\" ";
log_info("Submit: " . $cmd);
my $return = `$cmd 2>&1`;
log_info("Submit Return: ".chomp($return));
}
}
}
sub deploy_files
{
my $r_code = 0;
my $result1 = "";
my $result2 = "";
log_info("Going to open and write to a file");
if (scalar @files) {
my $fileList = "/tmp/email_deploy_".$taskId.".txt";
log_info("fileList path in deploy files = $fileList");
open(my $fh, '>>',"$fileList") or die "Could not open file '$fileList' $!";
for my $file ( @files ) {
print $fh $file."\n";
}
close $fh;
log_info("Filelist written to temp file");
my $deployment1 = "emailtemplatehtml";
my $deployment2 = "direct_NGN_web";
my $destDir1 = "/shared/cms/tud/cms_app/cms";
#my $destDir2 = "E:/cmssftp/directwebcontent";
my $server = lc($ENV{COMPUTERNAME});
#find(\&wanted, $destDir2);
my $contentlen = @content;
for (my $i=$contentlen;$i>0;$i--) {
if (-f $content[$i]){
unlink $content[$i];
}
if(-d $content[$i]){
rmdir $content[$i];
}
}
#my $secure_bat = "E:/cmssftp/scripts/scpweb.bat";
my $cmd1= "/opt/iba/cms/autonomy/OpenDeployNG/bin/iwodcmd start \"$deployment1\" -k branch=\"/tmp\" -k dest_dir=\"$destDir1\" -k filelist=\"$fileList\"";
log_info(" deploy command ::: $cmd1");
# my $cmd2 = "/opt/iba/cms/autonomy/OpenDeployNG/bin/iwodcmd start $deployment2 -k branch=$stage -k dest_dir=$destDir2 -k filelist=$fileList ";
$result1 = `$cmd1 2>&1`;
#$result2 = `$cmd2 2>&1`;
my $status = $?;
$r_code = $status >>= 8;
#print LISTER "$r_code \n";
# if($r_code == 0)
# {
# my $cmd3 = "$secure_bat";
# print LISTER "Calling Direct Web SCP.bat \n";
# $result2= `$cmd3 2>&1`;
# }
# else
# {
# print LISTER "Could not call Direct Web SCP.bat \n";
# }
unlink $fileList;
}
#code to delete temp scrubbed files
for my $file ( @files ) {
my $delFilePath = "/tmp/".$file;
log_info("deleting ::: $delFilePath");
unlink $delFilePath;
}
return ($r_code,$result1);
}
sub scrub_files
{
# Files
if (scalar @files) {
log_info(INDENT, 'Files');
for my $file ( @files ) {
my $fullFile = $areavpath."/".$file;
log_info("Scrubbing $fullFile");
log_info(INDENT x 2, $fullFile);
$fullFile =~ m|.*(\..*$)|;
my $fileExt = $1;
log_info(INDENT x 3, "File Extension: ".$fileExt);
if ($fileExt eq ".html") {
# if ($fileExt eq ".html" or $fileExt eq ".css") {
open (IN,"<$fullFile");
local $/ = undef;
my $file_contents = <IN>;
close(IN);
if ($site eq "direct") {
$site = "direct";
}
# use the Perl qr// syntax to make a variable work in a regular expression
# If $site = "hongkong", and we execute this statement:
# my $re = qr/$site/;
# Then these 2 statements are equivalent:
# $file_contents =~ s|/html/hongkong||gs;
# $file_contents =~ s|/html/${re}||gs;
my $re = qr/$site/;
#$string =~ /(.*)(${re})(.*)/;
#mapArray[1][0] = "English|/sites/ca/interstitial/australia_en.page|Yes";
#$file_contents =~ s|/html/hongkong||gs;
$file_contents =~ s|/html/${re}||gs;
# only make these changes for .html files
if ($fileExt eq ".html") {
# in order to preserve fully qualified links to .page files, which are valid,
# rename all the links that start with "http" and end with ".page", so we can put them back later
# something unique: ~~EGAP~~ ( 2 tildas, the word "page" backwords and in upper case, 2 more tildas
$file_contents =~ s|(http.*?)\.page|$1\.~~EGAP~~|gm;
# we also need to preserve fully qualified links to .page files
# i.e. India in the selector (http://www.transunion.com/sites/corporate/interstitial/india.page)
# so we do something similar to above - rename FULLY QUALIFIED links that contain "/sites/" to
&
Comments
-
Unfortunately for you, there's no tool to automatically convert WTF into IPM. Shouldn't be too hard to do manually though -- you can still use your email IPL as-is, you just need to recreate the model with your single task. The only marginally difficult part is converting some of your inline tag stuff to WFM variables. Not entirely sure if you even need to -- your workflow looks fairly simple at a glance but I didn't read it in detail.
0
Categories
- All Categories
- 108 Developer Announcements
- 53 Articles
- 106 General Questions
- 144 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 899 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 120 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- Docker Automation
- LiveSite Content Services (LSCS) REST API
- Single Page Application (SPA) Modules
- TeamSite Add-ons
If you are interested in gaining full access to the content, you can register for a My Support account here.