Tuesday, March 20, 2012

Rename File in Unix through PeopleCode

                                             Rename File in Unix through PeopleCode

Exec("mv <path>/file1.csv <path>/file2.csv", %Exec_Asynchronous + %FilePath_Absolute);

How to zip files through peoplecode

                               How to zip files through peoplecode
Exec("gzip -c <path>/file.txt > <path>/file.gz", %Exec_Asynchronous + %FilePath_Absolute);
Exec("gunzip -c <path>/file.gz >", %Exec_Asynchronous + %FilePath_Absolute);
gzip -c file.txt > file.gz
http://examplenow.com/gzip/
gzip [-acdfhlLnNqrtvV19] [-S suffix] [file ...]
gunzip [-acfhlLnNqrtvV] [-S suffix] [file ...]
gzcat -fhLV [file ...]
http://www.mkssoftware.com/docs/man1/gzip.1.asp

Monday, March 19, 2012

Base64 Encoding, Decoding


Base64 Encoding, Decoding

SCC_COMMON_UTILITIES.UTIL.Base64Wrapper.OnExecute
 (This Appl package has all the methods needed for base64 encode and decode)

class Base64Wrapper
   method Base64Wrapper();
   method encode(&filename As string) Returns string;
   method decode(&filename As string, &base64data As string) Returns boolean;
   rem method getErrorDetails() Returns string;
private
   instance JavaObject &joB64;
end-class;
method base64Encode
   Local number &nbr_retcode;
   Local File &file;
      &nbr_retcode = GetAttachment(&fileURL, &sysfilename, &tempFilename);
   %This.delay();
   If &nbr_retcode > 0 Then
      throw CreateException(18179, 207, "", &displayFilename);
   End-If;
   &Base64String = &b64w.encode(&tempFilename);
   %This.cleanupTempFile();
   end-method;;
method Base64Wrapper
   rem &joB64 = CreateJavaObject("com.peoplesoft.hrms.hrs.base64Utils");
   &joB64 = CreateJavaObject("com.peoplesoft.hr.sa.base64Utils");
end-method;
method encode
   /+ &filename as String +/
   /+ Returns String +/ 
   Local string &filedata;
   &filedata = &joB64.base64Encode(&filename);
   Return &filedata;
end-method;
method decode
   /+ &filename as String, +/
   /+ &base64data as String +/
   /+ Returns Boolean +/
   Return &joB64.base64Decode(&filename, &base64data);
   end-method;
/*method getErrorDetails
   /+ Returns String +/
   Return &joB64.getErrorDetails();
end-method;*/
HRS_HROI_RESUMEEXTRACT:Util(Application Package)
HRS_HROI:UTIL:Base64Wrapper;
class Base64Wrapper
   method Base64Wrapper();
   method encode(&filename As string) Returns string;
   method decode(&filename As string, &base64data As string) Returns boolean;
private
   instance JavaObject &joB64;
end-class;
method Base64Wrapper
   &joB64 = CreateJavaObject("com.peoplesoft.hrms.hrs.base64Utils");
end-method;
method encode
   /+ &filename as String +/
   /+ Returns String +/
      Local string &filedata; 
      &filedata = &joB64.base64Encode(&filename);
   Return &filedata;
end-method;
method decode
   /+ &filename as String, +/
   /+ &base64data as String +/
   /+ Returns Boolean +/
   Return &joB64.base64Decode(&filename, &base64data);
   end-method;;