AJPerez
AJPerez

Reputation: 3595

How to compress files in Siebel?

I need to read several text files from our Siebel server and attach them to an email. However, some of these files may be too big to mail them. Compressing them would definitely solve the problem, given that they are plain text files.

Which leads to my question: how to compress files in Siebel? Is there any built-in business service / workflow / whatever in Siebel 7.8, which offers compressing functionality? I don't care about the file format: zip, tar.gz, 7z..., as long as I can extract the files whitout Siebel (no .SAF format, please).

There are 1.041 vanilla business services in our repository. One might think that, with such a huge number, there should be one to compress files, right? I hope so... I still haven't found it yet, though.

I know I could write a really simple Java class to perform the compression, and then consume it from Siebel as a Java BS... but I'd rather avoid this option if there is an alternative.

Upvotes: 0

Views: 756

Answers (1)

AJPerez
AJPerez

Reputation: 3595

I still haven't found any built-in business service to compress files. However, I've managed to build my own, using Clib.system to invoke Solaris commands tar and gzip. It's quite simple, you just need to wrap this in a business service:

// Input:
// - files: array of files to compress (each element should contain the full path)
// - target: full path to the file to be created, without the .tar.gz extension

function compress (files, target)
{
  // Build the tar file. We add the files one each time because passing long command lines
  // to Clib.system crashes the server
  for (var i = 0; i < files.length; i++) {
    var mode = (i == 0 ? "c" : "r");
    var command = "tar -" + mode + "f " + target + ".tar " + files[i].replace(/\s/g, "?");
    if (Clib.system(command) != 0) {
      throw "Error creating tar file";
    }
  }

  // Build the tar.gz file 
  var command = "gzip -c " + target + ".tar > " + target + ".tar.gz";
  if (Clib.system(command) != 0) {
    throw "Error creating tar.gz file";
  }
}

Upvotes: 1

Related Questions