+// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
#include "CreateConfigFile.h"
#include "CreateConfigFileResponse.h"
#include "GetFile.h"
#include "PutFileResponse.h"
#include "SimanSalomeServiceStub.h"
+#include "SimanIO_Link.hxx"
+
#include <Environment.h>
+#include <ServiceClient.h>
+
#include <iostream>
#include <fstream>
#include <sstream>
-#include <ServiceClient.h>
-#include <SimanIO_Link.hxx>
-
-
#include <algorithm>
-
-using namespace std;
using namespace org_splat_ws_server_service_salome;
using namespace wso2wsf;
}
// unification of the error handling in the RetrieveConf and StoreConf methods
-#define CONFIGURSION_ERROR(message) {cerr<<message<<endl;}
+#define CONFIGURSION_ERROR(message) {std::cerr<<message<<std::endl;}
SimanIO_Configuration SimanIO_Link::RetrieveConf()
{
return aResult;
}
- string aSimanWSHost(aSimanHost);
- string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService";
+ std::string aSimanWSHost(aSimanHost);
+ std::string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService";
Environment::initialize("SimanSalomeService.log",AXIS2_LOG_LEVEL_DEBUG);
char* aClientHomeEnv = getenv("WSFCPP_HOME");
return aResult;
}
- string aClientHome = AXIS2_GETENV("WSFCPP_HOME");
+ std::string aClientHome = AXIS2_GETENV("WSFCPP_HOME");
SimanSalomeServiceStub* aStub = new SimanSalomeServiceStub(aClientHome, anEndpointUri);
ServiceClient *client = aStub->getServiceClient();
aCreateConfigFileRequest->setArgs1(atoll(myScenario.c_str()));
aCreateConfigFileRequest->setArgs2(atoll(myUser.c_str()));
- //cout<<"StudyId = " << atoll(myStudy.c_str()) << "\n";
- //cout<<"ScenarioId = " << atoll(myScenario.c_str()) << "\n";
- //cout<<"UserId = " << atoll(myUser.c_str()) << "\n";
+ //std::cout<<"StudyId = " << atoll(myStudy.c_str()) << "\n";
+ //std::cout<<"ScenarioId = " << atoll(myScenario.c_str()) << "\n";
+ //std::cout<<"UserId = " << atoll(myUser.c_str()) << "\n";
CreateConfigFileResponse* aCreateConfigFileResponse = new CreateConfigFileResponse();
aCreateConfigFileResponse = aStub->createConfigFile(aCreateConfigFileRequest);
+ std::string aResponseFilePath = aCreateConfigFileResponse->get_return();
- string aResponseFilePath = aCreateConfigFileResponse->get_return();
-
- string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1);
+ std::string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1);
//Get the created config file to client
aGetFileResponse = aStub->getFile(aGetFileRequest);
//Parse the response and get the filename
- string aTmpDir = "/tmp";
- string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
- //string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/";
- string aClientFilePath = aClientFileDir + aResponseFileName;
+ std::string aTmpDir = "/tmp";
+ std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
+ //std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/";
+ std::string aClientFilePath = aClientFileDir + aResponseFileName;
//Create the directories
system(("mkdir -p " + aClientFileDir).c_str());
system(("chmod -Rf g+w " + aTmpDir + "/SimanSalome/").c_str());
//Download the siman-salome.conf file
- ofstream outputStream;
- outputStream.open(aClientFilePath.c_str(), ofstream::binary);
+ std::ofstream outputStream;
+ outputStream.open(aClientFilePath.c_str(), std::ofstream::binary);
int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv());
int* aBufSize = new int[aBufferSize];
unsigned char* aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize);
/*const*/ SimanIO_Document& aDoc = aDocIter.Document();
SimanIO_Document::FilesIterator aFileIter(aDoc);
for(; aFileIter.More(); aFileIter.Next()) {
- string aURL = aFileIter.URL();
- string aFileName = aURL.substr(aURL.find_last_of("/\\")+1);
+ std::string aURL = aFileIter.URL();
+ std::string aFileName = aURL.substr(aURL.find_last_of("/\\")+1);
int startUnderlineIndex = aFileName.find_first_of("_") + 1;
- string aSourceFileName = aFileName.substr(startUnderlineIndex);
+ std::string aSourceFileName = aFileName.substr(startUnderlineIndex);
- //cout << "aURL = " << aURL << "\n";
- string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault/";
+ //std::cout << "aURL = " << aURL << "\n";
+ std::string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault/";
//only for test only for WIN
//replace(aURL.begin(),aURL.end(),'/','\\');
aGetFileRequest->setArgs0(aPathToVault + aURL);
aGetFileResponse = aStub->getFile(aGetFileRequest);
- outputStream.open((aClientFileDir + aSourceFileName).c_str(), ofstream::binary);
+ outputStream.open((aClientFileDir + aSourceFileName).c_str(), std::ofstream::binary);
int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv());
int* aBufSize = new int[aBufferSize];
unsigned char* aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize);
//Set new URLs
aFileIter.SetURL((aClientFileDir + aSourceFileName).c_str());
- //cout << "New location of the files " << aClientFileDir + aFileName << "\n";
+ //std::cout << "New location of the files " << aClientFileDir + aFileName << "\n";
}//aFileIter
}//aDocIter
}//actIter
void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf)
{
- cout << "StoreConf method is started\n";
+ std::cout << "StoreConf method is started\n";
char* aSimanHost = getenv("SIMAN_WS_HOST");
if (aSimanHost == NULL)
{
CONFIGURSION_ERROR("The SIMAN_WS_HOST variable does not exist. Please set it.\n");
}
- string aSimanWSHost(aSimanHost);
- string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService";
+ std::string aSimanWSHost(aSimanHost);
+ std::string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService";
Environment::initialize("SimanSalomeService.log",AXIS2_LOG_LEVEL_DEBUG);
char* aClientHomeEnv = getenv("WSFCPP_HOME");
CONFIGURSION_ERROR("The WSFCPP_HOME variable does not exist. Please set it.\n");
}
- string aClientHome = AXIS2_GETENV("WSFCPP_HOME");
+ std::string aClientHome = AXIS2_GETENV("WSFCPP_HOME");
SimanSalomeServiceStub* aStub = new SimanSalomeServiceStub(aClientHome, anEndpointUri);
ServiceClient *client = aStub->getServiceClient();
PutFileResponse* aPutFileResponse = new PutFileResponse();
//Prepare salome-siman.conf file
- string aTmpDir = "/tmp";
- string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
- //string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/";
- string aClientFilePath = aClientFileDir + "salome-siman.conf";
- ofstream aSalomeSimanFile;
+ std::string aTmpDir = "/tmp";
+ std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/";
+ //std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/";
+ std::string aClientFilePath = aClientFileDir + "salome-siman.conf";
+ std::ofstream aSalomeSimanFile;
aSalomeSimanFile.open(aClientFilePath.c_str());
//Get the actual file URLs and put these files onto server.
/*const*/ SimanIO_Document& aDoc = aDocIter.Document();
SimanIO_Document::FilesIterator aFileIter(aDoc);
for(; aFileIter.More(); aFileIter.Next()) {
- string aURL = aFileIter.URL();
- string aFileName = aURL.substr(aURL.find_last_of("/\\")+1);
- cout << "aURL = " << aURL << "\n";
- cout << " aFileName= " << aFileName << "\n";
+ std::string aURL = aFileIter.URL();
+ std::string aFileName = aURL.substr(aURL.find_last_of("/\\")+1);
+ std::cout << "aURL = " << aURL << "\n";
+ std::cout << "aFileName= " << aFileName << "\n";
//get size of the input file
- ifstream inputStream (aURL.c_str(), ifstream::binary);
- inputStream.seekg(0,ifstream::end);
+ std::ifstream inputStream (aURL.c_str(), std::ifstream::binary);
+ inputStream.seekg(0,std::ifstream::end);
int aSize = inputStream.tellg();
inputStream.seekg(0);
char* aCopyBuffer;
aCopyBuffer = new char [aSize];
inputStream.read(aCopyBuffer,aSize);
+ std::cout << "Upload a file with the size" << aSize << "\n";
axutil_base64_binary_t* aRequestDH = axutil_base64_binary_create_with_plain_binary(Environment::getEnv(), reinterpret_cast<unsigned char*>(aCopyBuffer), aSize);
inputStream.close();
delete[] aCopyBuffer;
aPutFileResponse = aStub->putFile(aPutFileRequest);
+ std::cout << "End of upload. New file locaton is: " << aPutFileResponse->get_return() << "\n";
+
//Write information into salome-siman.conf file
- ostringstream activityId;
- ostringstream documentId;
+ std::ostringstream activityId;
+ std::ostringstream documentId;
activityId << actIter.ActivityId();
documentId << aDocIter.DocId();
aSalomeSimanFile << myScenario + "," + myUser + "," + activityId.str() + "," + documentId.str() + "," + aPutFileResponse->get_return() + "\n";
+ std::cout << "Line in the SalomeSimanFile " << myScenario + "," + myUser + "," + activityId.str() + "," + documentId.str() + "," + aPutFileResponse->get_return() <<"\n";
+ std::cout <<"==========\n";
}//aFileIter
}//aDocIter
aSalomeSimanFile.close();
//Put the salome-siman.conf file onto server
- ifstream inputStream (aClientFilePath.c_str(), ifstream::binary);
- inputStream.seekg(0,ifstream::end);
+ std::ifstream inputStream (aClientFilePath.c_str(), std::ifstream::binary);
+ inputStream.seekg(0,std::ifstream::end);
int aSize = inputStream.tellg();
inputStream.seekg(0);