diff -r 000000000000 -r 83f4b4db085c bldsystemtools/commonbldutils/GenResult/send_xml_to_diamonds.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bldsystemtools/commonbldutils/GenResult/send_xml_to_diamonds.pl Tue Feb 02 01:39:43 2010 +0200 @@ -0,0 +1,92 @@ +# Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# Script to send XML data to diamonds +# +# +use HTTP::Request::Common qw(POST); +use LWP::UserAgent; + +use Getopt::Long; + +my $iServer; +my $iUrl; +my $iFile; +my $iHelp; +my $res; + +my $import_failed_message = "XML was not sent successfully to Diamonds via REST interface!\n"; +my $import_succeed_message = "XML was sent successfully to Diamonds via REST interface.\n"; + +my $ua = LWP::UserAgent->new(); + +GetOptions('s=s' => \$iServer, 'u=s' => \$iUrl, 'f=s' => \$iFile, 'h' => \$iHelp); +if ((!defined $iServer) || (!defined $iUrl) || (!defined $iFile) || ($iHelp)) +{ + Usage(); +} + +my $absoluteUrl = "http://".$iServer.$iUrl; +my $request = HTTP::Request->new(POST => $absoluteUrl); +$request->header('Content-Type' => 'text/xml'); + +open (FH,"<$iFile") or die "$iFile:$!\n"; +my @filecon = ; +my $XmlContent = join("",@filecon); +$request->content($XmlContent); +$res = $ua->request($request); + +print "Response status:".$res->code()."\n"; +print "Response reason:".$res->message()."\n"; + +if ($res->code() != 200) +{ + print "ERROR in sending XML data\n"; +} +else +{ + print "Server response:".$res->content()."\n"; +} + +sub Usage() +{ + print <