Commit 30a2e6fe authored by Volodymyr Yurchenko's avatar Volodymyr Yurchenko
Browse files

TJAlien command parser knows how to handle quotes

parent cafcbd59
......@@ -42,6 +42,7 @@ set(SRCS
TJAlienSAXHandler.cxx
TJAlienSystem.cxx
TJClientFile.cxx
TJAlienConnectionManager.cxx
)
string(REGEX REPLACE "T" "src/T" SRCS "${SRCS}")
......
......@@ -187,12 +187,37 @@ TGridResult *TJAlien::Command(const char *command, bool interactive, UInt_t stre
TList *options = new TList();
TObjString *sCommand = (TObjString *) tokens->At(0);
if (interactive) Info("Command", "Command = \"%s\"", sCommand->GetString().Data());
if (interactive) Info("Command", "Command = \"%s\"", sCommand->GetString().Data());
TString opt;
bool append = false;
for (int i = 1; i < tokens->GetEntries(); i++)
{
TObjString *opt = (TObjString*) tokens->At(i);
if (interactive) Info("Command", "Option = \"%s\"", opt->GetString().Data());
options->Add(opt);
TObjString *token = (TObjString *) tokens->At(i);
if (token->GetString().Contains('\"'))
{
if (append) {
opt.Append(" ");
opt.Append(Strip(token->GetString().Data(), '\"'));
append = false;
}
else {
opt = Strip(token->GetString().Data(), '\"');
append = true;
continue;
}
}
else
{
if (append) {
opt.Append(" ");
opt.Append(token->GetString().Data());
continue;
}
else
opt = token->GetString();
}
if (interactive) Info("Command", "Option = \"%s\"", opt.Data());
options->Add(new TObjString(opt));
}
TString *s = new TString(sCommand->GetString());
......
......@@ -485,7 +485,8 @@ TJAlienFile *TJAlienFile::Open(const char *url, Option_t *option,
if (gMonitoringWriter)
gMonitoringWriter->SendFileOpenProgress(0, 0, 0, kFALSE);
delete result;
if (result)
delete result;
return 0;
}
......@@ -504,7 +505,6 @@ TJAlienFile::~TJAlienFile() {
//______________________________________________________________________________
void TJAlienFile::Close(Option_t * option)
{
UNUSED(option);
if (!IsOpen()) return;
// Close file
......@@ -516,38 +516,26 @@ void TJAlienFile::Close(Option_t * option)
// If WRITE operation we need to commit the LFN and PFN to the catalogue
TString command("commit");
command += " ";
Long64_t siz = GetSize();
if (siz <= 0)
Error("Close", "the reported size of the written file is <= 0");
TString sSize("");
sSize += siz;
command += " \"";
command += fAuthz;
command += " ";
command += sSize;
command += "\" ";
command += siz;
command += " ";
command += fLfn;
TJAlienResult *result = (TJAlienResult*) gGrid->Command(command.Data());
delete command;
TObjString *errorMessage = 0;
Int_t exitcode = ((TJAlien *) gGrid)->GetExitCode(result, errorMessage);
if (exitcode != 0)
{
::Error("Close", "%s", errorMessage->GetString().Data());
delete result;
}
TJAlienResult *jalienResult = dynamic_cast < TJAlienResult * >(result);
TList *list = dynamic_cast < TList * >(jalienResult);
if (!list) {
if (result) {
delete result;
}
Error("Close", "cannot commit envelope for %s", fLfn.Data());
gSystem->Unlink(fLfn);
return;
}
if (result->GetKey(0, "lfn") != 0) {
......@@ -561,7 +549,8 @@ void TJAlienFile::Close(Option_t * option)
gSystem->Unlink(fLfn);
}
delete result;
if (result)
delete result;
}
//______________________________________________________________________________
......@@ -584,10 +573,10 @@ void TJAlienFile::Mirror()
if (exitcode != 0)
{
::Error("Close", "%s", errorMessage->GetString().Data());
delete result;
}
delete command;
delete result;
if (result)
delete result;
}
//______________________________________________________________________________
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment