PSUtilities Package Documentation June, 2005 Copyright © 2005 webMethods, Inc. All rights reserved. Trademarks The webMethods logo and Get There Faster are trademarks or registered trademarks of webMethods, Inc. Other product names used herein may be trademarks or registered trademarks of webMethods or other companies. Statement of Conditions WEBMETHODS, INC. PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OR CONDITIONS OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL WEBMETHODS BE LIABLE FOR ANY LOSS OF PROFITS, LOSS OF BUSINESS, LOSS OF USE OR DATA, INTERRUPTION OF BUSINESS, OR FOR INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY KIND, EVEN IF WEBMETHODS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES ARISING FROM ANY DEFECT OR ERROR IN THIS PUBLICATION OR IN THE WEBMETHODS SOFTWARE. webMethods, Inc. may revise this publication from time to time without notice. Some states or jurisdictions do not allow disclaimer of express or implied warranties in certain transactions; therefore, this statement may not apply to you. All rights reserved. No part of this work covered by copyright herein may be reproduced in any form or by any means—graphic, electronic or mechanical—including photocopying, recording, taping, or storage in an information retrieval system, without prior written permission of the copyright owner. RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the U.S. government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 (October 1988) and FAR 52.227-19 (June 1987). TABLE OF CONTENTS INTRODUCTION ......................................................................................................................... 5 FEEDBACK ............................................................................................................................ 5 DISCLAIMER .......................................................................................................................... 5 CUSTOMER ACCESS .............................................................................................................. 5 SERVICES DOCUMENTATION ................................................................................................. 6 BACKUP FOLDER ................................................................................................................... 6 PSUtilities.backup:aboutPageBackup ............................................................................. 6 PSUtilities.backup:fileListBackup .................................................................................... 6 PSUtilities.backup:packageBackup ................................................................................. 7 PSUtilities.backup.util:zipFiles2 ...................................................................................... 7 CONFIG FOLDER .................................................................................................................... 7 PSUtilities.config:checkParameterValidity ...................................................................... 9 PSUtilities.config:checkPathValidity ................................................................................ 9 PSUtilities.config:getParameterValue ............................................................................. 9 PSUtilities.config:getProperties ..................................................................................... 10 PSUtilities.config:loadPSUtilitiesConfig ......................................................................... 10 PSUtilities.config:setACLs ............................................................................................. 10 DATE FOLDER...................................................................................................................... 11 PSUtilities.date:calculateDateDifference ....................................................................... 11 PSUtilities.date:compareDates ..................................................................................... 11 PSUtilities.date:incrementDate ..................................................................................... 12 DB FOLDER ......................................................................................................................... 13 PSUtilities.db:localTransactionWrapper ........................................................................ 13 PSUtilities.db:xaTransactionWrapper ........................................................................... 13 EMAIL FOLDER..................................................................................................................... 14 PSUtilities.email:smtp .................................................................................................... 14 FILE FOLDER ....................................................................................................................... 15 PSUtilities.file:bytesToFile ............................................................................................. 15 PSUtilities.file:checkFileExistence ................................................................................ 16 PSUtilities.file:copyFile .................................................................................................. 16 PSUtilities.file:deleteFile ................................................................................................ 16 PSUtilities.file:getBasename ......................................................................................... 17 PSUtilities.file:getMimeType.......................................................................................... 17 PSUtilities.file:listFiles ................................................................................................... 17 PSUtilities.file:moveFile ................................................................................................. 18 PSUtilities.file:objectToFile ............................................................................................ 18 PSUtilities.file:streamToFile .......................................................................................... 19 PSUtilities.file:writeFile .................................................................................................. 19 FORMAT FOLDER ................................................................................................................. 20 PSUtilities.format:convertPackedDecimalToString ....................................................... 20 PSUtilities.format:convertStringToPackedDecimal ....................................................... 20 PSUtilities.format:convertStringToZonedDecimal ......................................................... 21 HASHTABLE FOLDER ............................................................................................................ 21 PSUtilities.hashtable:containsKey ................................................................................. 21 PSUtilities.hastable:createHashtable ............................................................................ 22 ©2002 webMethods, Inc. All rights reserved. Page 1 PSUtilities.backup:aboutPageBackup PSUtilities.hashtable:example ....................................................................................... 22 PSUtilities.hashtable:get ............................................................................................... 22 PSUtilities.hashtable:keys ............................................................................................. 22 PSUtilities.hashtable:put ............................................................................................... 23 PSUtilities.hashtable:remove ........................................................................................ 23 PSUtilities.hashtable:size .............................................................................................. 23 LIST FOLDER ....................................................................................................................... 23 PSUtilities.list:addToList ................................................................................................ 24 PSUtilities.list:createList ................................................................................................ 24 PSUtilities.list:getListSize .............................................................................................. 24 PSUtilities.list:listToArray .............................................................................................. 24 MATH FOLDER ..................................................................................................................... 25 PSUtilities.math:addDoubles ......................................................................................... 25 PSUtilities.math:addDoublesWithNulls ......................................................................... 25 PSUtilities.math:addFloatsWithNulls ............................................................................. 25 PSUtilities.math:addIntsWithNulls ................................................................................. 26 PSUtilities.math:compareFloats .................................................................................... 26 PSUtilities.math:compareInts ........................................................................................ 26 PSUtilities.math:divideDoubles ..................................................................................... 27 PSUtilities.math:getAbsoluteValue ................................................................................ 27 PSUtilities.math:multiplyDoubles .................................................................................. 27 PSUtilities.math:multiplyDoublesWithNulls ................................................................... 28 PSUtilities.math:multiplyFloatsWithNulls ....................................................................... 28 PSUtilities.math:multiplyIntsWithNulls ........................................................................... 28 PSUtilities.math:roundNumber ...................................................................................... 28 PSUtilities.math:subtractDoubles .................................................................................. 29 PSUtilities.math:subtractDoublesWithNulls ................................................................... 29 PSUtilities.math:subtractFloatsWithNulls ...................................................................... 29 PSUtilities.math:subtractIntsWithNulls .......................................................................... 30 PSUtilities.math:trimZeroes ........................................................................................... 30 PSUtilities.math:truncateNumber .................................................................................. 30 PERSISTENCE FOLDER ......................................................................................................... 30 MISC FOLDER ...................................................................................................................... 31 PSUtilities.misc:appendObjectList ................................................................................ 31 PSUtilities.misc:appendStringListToStringTable ........................................................... 31 PSUtilities.misc:checkThreadCount .............................................................................. 32 PSUtilities.misc:collectGarbage .................................................................................... 32 PSUtilities.misc:deepArrayCopy ................................................................................... 32 PSUtilities.misc:deepConvert ........................................................................................ 32 PSUtilities.misc:deepCopy ............................................................................................ 33 PSUtilities.misc:doInvoke .............................................................................................. 33 PSUtilities.misc:getHostInformation .............................................................................. 33 PSUtilities.misc:getRecordElements ............................................................................. 34 PSUtilities.misc:getServerConfigParameters ................................................................ 34 PSUtilities.misc:getServerInformation ........................................................................... 34 PSUtilities.misc:getServiceName .................................................................................. 34 PSUtilities.misc:getUser ................................................................................................ 35 PSUtilities.misc:invoke .................................................................................................. 35 PSUtilities.misc:invokeAndCatchErrors ........................................................................ 36 PSUtilities.misc:makeSystemCall ................................................................................. 36 PSUtilities.misc:matchServiceName ............................................................................. 37 PSUtilities.misc:println ................................................................................................... 37 ©2004 webMethods, Inc. All rights reserved. Page 2 PSUtilities.backup:aboutPageBackup PSUtilities.misc:sleep .................................................................................................... 37 PSUtilities.misc:spawnThread ....................................................................................... 37 PSUtilities.misc:spawnThread2 ..................................................................................... 38 PSUtilities.misc:throwError ............................................................................................ 38 OBJECT FOLDER .................................................................................................................. 39 PSUtilities.object:className......................................................................................... 39 PSUtilities.object:instanceOf ......................................................................................... 39 PROPERTIES FOLDER........................................................................................................... 39 PSUtilities.properties:getSpecificSystemProperties ...................................................... 39 PSUtilities.properties:getSystemProperties .................................................................. 40 PSUtilities.properties:getSystemProperty ..................................................................... 40 PSUtilities.properties:readPropertiesFile ...................................................................... 41 REGEX FOLDER ................................................................................................................... 41 REMOTE FOLDER ................................................................................................................. 41 PSUtilities.remote:getRemoteServerInfo ...................................................................... 41 PSUtilities.remote:getRemoteServerInfoHelper ............................................................ 42 PSUtilities.remote:runContextJob ................................................................................. 42 PSUtilities.remote:runTContextJob ............................................................................... 42 SESSION FOLDER ................................................................................................................ 43 PSUtilities.session:clearSession ................................................................................... 43 PSUtilities.session:getObjectFromSession ................................................................... 43 PSUtilities.session:getSessionID .................................................................................. 43 PSUtilities.session:getSessionKeys .............................................................................. 44 PSUtilities.session:putObjectInSession ........................................................................ 44 PSUtilities.session:removeObjectFromSession ............................................................ 44 SSL FOLDER ........................................................................................................................ 45 PSUtilities.ssl:deleteUserCertificate .............................................................................. 45 PSUtilities.ssl:extractCertificate .................................................................................... 45 PSUtilities.ssl:extractChain ........................................................................................... 45 PSUtilities.ssl:importUserCertificate .............................................................................. 46 STREAM FOLDER ................................................................................................................. 46 PSUtilities.stream:bytesToStream ................................................................................ 46 PSUtilities.stream:closeStream ..................................................................................... 47 PSUtilities.stream:closeStream ..................................................................................... 47 PSUtilities.stream:streamToBytes ................................................................................. 47 PSUtilities.stream:streamToString ................................................................................ 48 PSUtilities.stream:stringToStream ................................................................................ 48 STRING FOLDER .................................................................................................................. 48 PSUtilities.string:addLineSeparator .............................................................................. 48 PSUtilities.string:compareString .................................................................................... 48 PSUtilities.string:convertLineSeparator ......................................................................... 49 PSUtilities.string:decode64String .................................................................................. 49 PSUtilities.string:encode64String .................................................................................. 49 PSUtilities.string:isAlphanumeric .................................................................................. 50 PSUtilities.string:isDate ................................................................................................. 50 PSUtilities.string:isNullOrBlank ..................................................................................... 50 PSUtilities.string:isNumeric ........................................................................................... 51 PSUtilities.string:multiConcat ........................................................................................ 51 PSUtilities.string:padLeftWithNulls ................................................................................ 51 PSUtilities.string:padRightWithNulls ............................................................................. 52 PSUtilities.string:removeLineSeparators ....................................................................... 52 PSUtilities.string:substituteVariables ............................................................................. 52 ©2004 webMethods, Inc. All rights reserved. Page 3 PSUtilities.backup:aboutPageBackup PSUtilities.string:truncateString ..................................................................................... 53 ZIP FOLDER ......................................................................................................................... 53 PSUtilities.zip:unzipFiles ............................................................................................... 53 PSUtilities.zip:zipFiles ................................................................................................... 54 ©2004 webMethods, Inc. All rights reserved. Page 4 PSUtilities.backup:aboutPageBackup INTRODUCTION PSUtilities is a collection of custom-developed utility services developed by various webMethods Professional Services consultants. Feedback Please send all feedback on PSUtilities to gear@webmethods.com. Utility service submissions are always welcome. Disclaimer As a custom-developed set of utilities, PSUtilities is delivered as-is, with no support and no guarantees. Customer Access PSUtilities is available for (http://advantage.webmethods.com). ©2004 webMethods, Inc. All rights reserved. download from webMethods Advantage Page 5 PSUtilities.backup:aboutPageBackup SERVICES DOCUMENTATION backup Folder Contains services for making backups of the server’s About page, files and packages. PSUtil ities.backup:aboutPageBackup PSUtilities. Emails the contents of webMethods Administrator’s "About" page to a specified target email. The About page captures useful info about service packs, JVM, enabled packages, etc, and this service can be used to provide Technical Services with environment information, checking the consistency between several Integration Servers, etc. Input Parameters user String Server Administrator username pass String Server Administrator password to String Recipient email address mailhost String Mail server used for sending the email body String The email text to be sent Output Parameters None PSUtilities.backup:fileListBackup PSUtilities. Accepts a list of files, zips them and then emails them to targeted email address. Input Parameters to String Recipient email address mailhost String Mail server used for sending the email body String The email text to be sent FileList String[] List of files to zip and send. (e.g. config\server.cnf, config\users.cnf, server.sh, nohup.out) backupName String Name of the zip file Output Parameters output String Name of zipped output. It should be a valid location and name (e.g. \tmp\config.zip). Usage Notes 1) For security reasons, this service checks the input fileList against the list of allowedReadPaths and the input backupName against the list of allowedWritePaths specified in the PSUtilities configuration file. If either path is not on its respective allowed lists, an exception is thrown. ©2004 webMethods, Inc. All rights reserved. Page 6 PSUtilities.backup:packageBackup PSUtilities.backup:packageBackup PSUtilities. Zips specified packages and emails them to a targeted email address. Input Parameters to String Recipient email address mailhost String Mail server used for sending the email body String The email text to be sent packages String[] Comma delimited list of packages to zip and send method String Specifies method of transmitting package information. Currently, there is only one accepted value, but this service can be customized to support other transport and source control mechanisms. Value Description email Sends packages by email to target Output Parameters None PSUtilities.backup.util:zipFiles2 PSUtilities. Used as a helper service by PSUtilities.backup:fileListBackup to zip a list of files. config Folder The config folder contains services related to the PSUtilities configuration file (packages/PSUtilities/config/PSUtilities.cnf). This configuration file contains some parameters that are used to provide some additional validation checks to secure some of the PSUtilities services. For example, the PSUtilities.file:writeToFile service can be a huge security risk if the target filename is not properly validated. For example, under certain situations, it could be used to overwrite sensitive files like the /etc/passwd or C:\WINNT\system32\drivers\etc\hosts files. Therefore, the target filename is validated against a list of files to ensure that write permissions are available for the file. The file contains the following parameters: allowedReadPaths – list of paths that PSUtilities services can read from allowedWritePaths – list of paths that PSUtilities services can write to allowedDeletePaths – list of paths that PSUtilities services can delete ©2004 webMethods, Inc. All rights reserved. Page 7 PSUtilities.backup.util:zipFiles2 allowedCommands – list of the file system commands that can be invoked by the PSUtilities.misc:makeSystemCall service allowedServices – list of the services that can be invoked programmatically by services such as PSUtilities.misc:doInvoke and PSUtilities.misc:spawnThead maxSleep – used by the PSUtilities.misc:sleep Please keep the following in mind as you modify the parameters in the PSUtilities.cnf file: - The asterisk is the delimiter for allowed paths. - If a directory name is listed, access is allowed to all files in that directory (but not subdirectories). - If a file name is listed, access is allowed only to that file. For example, an entry of: allowedWritePaths C:\\wm6\\test*C:\\wm6\\test.txt will allow PSUtilities to write to any file in the directory c:\wm6\test, as well as to the file c:\wm6\test.txt If the extra security check outlined above is not required, you can also disable the security check in the services that use them by commenting out the security validation code. This start and end of the validation is clearly commented in each calling service. For example, in the writeToFile service, the following code can be commented out to remove the security validation check logic: // *** Check if path is on the allowed list *** try { if (!checkPathValidity(strFullFilename, "write")) { throw new ServiceException("Specified path is not on the write allowed list in the PSUtilities configuration file!"); } } catch (Exception e) { throw new ServiceException(e.getMessage()); } // *** End check *** ©2004 webMethods, Inc. All rights reserved. Page 8 PSUtilities.config:checkParameterValidity PSUtilities.config:checkParameterValidity PSUtilities. Checks the validity of the specified parameter against a list of valid values from the PSUtilities configuration file. Input Parameters ParamName String Name of parameter to be checked ParamValue String Value of parameter to be checked for validity Output Parameters Valid String Indicates whether the validity check was passed Value Description true The input parameter value was found on the list of valid parameter values. false The input parameter value was not found on the list of valid parameter values. PSUtilities.con fig:checkPathValidity PSUtilities. Checks if an action on the specified path is allowed by comparing it against a list of allowed paths from the PSUtilities configuration file. If the allowed path in the configuration file is a directory, the action is allowed on all files in the directory. If the allowed path in the configuration file is a file, then an action on that file is allowed. All filenames are canonicalized prior to the validity check comparison. Example usage: User wants to check if the following If the configuration file specifies that the c:\ directory is an allowed path for writes, then all files in the c:\ directory (e.g. c:\readme.txt) can be written to. Input Parameters action path String Description of the action being taken on the path Value Description read Check if specified path can be read write Check if specified path can be written to. delete Check if specified path can be deleted. String Pathname being checked Output Parameters valid Type String describing whether the validity check was passed Value Description true The specified action is allowed on the specified path. false The specified action is not allowed on the specified path. PSUtilities.config:getParameterValue PSUtilities. Gets the contents of a particular parameter value stored in memory. ©2004 webMethods, Inc. All rights reserved. Page 9 PSUtilities.config:getProperties Input Parameters paramName String Description of the action being taken on the path Output Parameters paramValue String String describing whether the validity check was passed PSUtilities.config:getProperties PSUtilities. Retrieves the entire contents of the static variable containing the cached configuration parameters. Input Parameters None Output Parameters properties Properties object Contains the entire contents of memory PSUtilities.config:loadPSUtilitiesC onfig PSUtilities. Reads the PSUtilities configuration parameters from the configuration file and loads them into a static Properties variable in memory. Input Parameters None Output Parameters None Usage Notes This service is a startup service of the PSUtilities package. Therefore, the PSUtilities configuration parameters loaded into memory each time the package is loaded. If the configuration file contents are modified while the package is loaded, either the package must be reloaded or this service must be executed in order to refresh the contents of the static memory variable. PSUtilities.config:setACLs PSUtilities. Sets the ACLs for the PSUtilities package. Input Parameters None Output Parameters None ©2004 webMethods, Inc. All rights reserved. Page 10 PSUtilities.date:calculateDateDifference Usage Notes This service is a startup service of the PSUtilities package which sets up the ACLs in the PSUtilities package. Please do not modify this service. date Folder Contains some date-related utility services. PSUtilities.date:calculateDateDifference PSUtilities. Calculates the difference between two dates in seconds, minutes, hours and days. Input Parameters startDateTime String Starting date and time, specified in the format specified by the StartDateFormat input parameter endDateTime String Ending date and time, specified in the format specified by the EndDateFormat input parameter startDateFormat String Starting date format (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) endDateFormat String Ending date format (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) Output Parameters dateDifferenceSec String The difference between the startingDateTime and endingDateTime, truncated to the nearest whole number of seconds dateDifferenceMin String The difference between the startingDateTime and endingDateTime, truncated to the nearest whole number of minutes dateDifferenceHr String The difference between the startingDateTime and endingDateTime, truncated to the nearest whole number of hours dateDifferenceDay String The difference between the startingDateTime and endingDateTime, truncated to the nearest whole number of days Usage Notes Please note: Each of the outputs individually represents the calculated date difference using a different scale. So the sum of these outputs does not equal the date Difference. Therefore, depending on the scale required, only one of output variables will typically be used in subsequent flow steps. PSUtilities.date:compareDates PSUtilities. Compares two dates. Input Parameters dateString1 String Date and time, specified in the format specified by the dateFormat1 input parameter ©2004 webMethods, Inc. All rights reserved. Page 11 PSUtilities.date:incrementDate dateFormat1 String Date format for dateString1 (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) dateString2 String Date and time, specified in the format specified by the dateFormat2 input parameter dateFormat2 String Date format for dateString2 (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) Output Parameters result String The difference between the startingDateTime and endingDateTime, truncated to the nearest whole number of seconds Value Description -1 dateString1 < dateString2 0 dateString1 = dateString2 1 dateString1 > dateString2 PSUtilities.date:incrementDate PSUtilities. Increments a date by a specified period. Input Parameters startingDate String Starting date and time, specified in the format specified by the startingDateFormat input parameter startingDateFormat String Date format for startingDate (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) endingDateFormat String Date format for endingDate (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) dateString2 String Date and time, specified in the format specified by the dateFormat2 input parameter addYears String Number of years to add to the startingDate addMonths String Number of months to add to the startingDate addDays String Number of days to add to the startingDate addHours String Number of hours to add to the startingDate addMinutes String Number of minutes to add to the startingDate addSeconds String Number of seconds to add to the startingDate Output Parameters endingDate String Ending date and time, calculated by incrementing the startingDate with the specified years, months, days, hours, minutes and seconds. Specified in the format specified by the endingDateFormat input parameter Usage Notes The addYears, addMonths, addDays, addHours, addMinutes, addSeconds inputs can be positive or negative. Example: If startingDate = 10/10/2001, addYears=1, addMonths=-1, endingDate = 09/10/2002 ©2004 webMethods, Inc. All rights reserved. Page 12 PSUtilities.db:localTransactionWrapper db Folder Contains a wrapper service for making WmDB calls with a global connection pool (watt.server.db.connectionCache = “server”). The wrapper provides a framework that enforces defensive coding tactics to minimize WmDB-related usage issues, and also abstracts the transaction management, connection management and exception trapping details. PSUtilities.db:localTransactionWrapper PSUtilities. This wrapper has been tested on IS 4.6 SP2 with fix 105 and 150. The wrapper handles all exceptions raised within, including ones from invoked DB flow service. localTransactionWrapper handles following cases: 1) nontransactional actions involving a single database. 2) transactional actions involving a single database. Input Parameters dbAlias String WmDB database alias. serviceNS String The namespace of flow service that contains the DB logic (e.g. myFolder.mySubFolder:myDBService). The flow service will be given a connection object named "localDBConnection" by the wrapper in addition to other inputs the service needs. input Document Optional. Input data for the service specified in the "serviceNS" parameter. transactionFlag String Optional. Indicates whether the target flow service should be treated by the database as a single logical unit of work. The default value is "false". Output Parameters successFlag String “true” or “false”. “false” indicates that an error occurred during target service processing. errorMsg String If an error occurs during processing of the target service, the error message will be populated in this field. output Document Target flow service’s output. PSUtilities.db:xaTransactionWrapper PSUtilities. This wrapper has been tested on IS 4.6 SP2 with fix 105 and 150. The wrapper handles all exceptions raised within, including ones from invoked DB flow service. xaTransactionWrapper handles transactional actions involving a two database aliases. Input Parameters dbAlias1 String WmDB database alias. dbAlias2 String WmDB database alias. serviceNS String The namespace of flow service that contains the DB logic (e.g. myFolder.mySubFolder:myDBService). The flow service will be given a connection object named "localDBConnection" by the wrapper in addition to other inputs the service needs. input Document Optional. Input data for the service specified in the "serviceNS" parameter. ©2004 webMethods, Inc. All rights reserved. Page 13 PSUtilities.email:smtp Output Parameters successFlag String “true” or “false”. “false” indicates that an error occurred during target service processing. errorMsg String If an error occurs during processing of the target service, the error message will be populated in this field. output Document Target flow service’s output. Usage Notes Please note: This is not a true XA-compliant database interaction. If the transaction is committed to the first database, and an exception occurs while committing the second database transaction fails, a compensating transaction must be implemented to manually rollback the first database transaction. email Folder Contains some email-related utility services. PSUtilities.email:smtp PSUtilities. Enhances the existing pub.client.smtp service by adding a priority variable. Input Parameters to String Receiver’s email address. If you specify multiple addresses, separate them with commas. cc String Optional. Additional receiver’s email addresses. If you specify multiple addresses, separate them with commas. bcc String Optional. Additional receiver’s email addresses. If you specify multiple addresses, separate them with commas. subject String Subject of the message. priority String Optional. Priority of the email (1, 2, 3 or 4) subjectCharset String The character set used to encode the MIME message headers (including subject). If subjectCharset is not specified, then charset is used if it is specified, If charset is not specified, the value in the server property watt.server.mail.charset is used. If that property is not set, then the utf-8 encoding is used. charset String The character encoding of the body text. If charset is not specified, the value in the server property watt.server.mail.charset is used. If that property is not set, then the utf-8 encoding is used. from String Sender’s email address. mailHost String SMTP host name for outbound messages. For example: smtp.webMethods.com body String Comments (text string) about the content. attachments Document List Optional. Attachments of the message. Each attachment defines one message part in a multi-part message. Key contenttype Description String MIME type of the message. For example: application/x-edi-message content byte[ ], String, or java.io.InputStream Content of the message. ©2004 webMethods, Inc. All rights reserved. Page 14 PSUtilities.file:bytesToFile filename encoding charset String Name of a local file to be attached to the message. Used only if content is not specified. String Optional. Encoding of the message. For example: base64 or 7bit. If encoding is not specified, 7bit is used. String Optional. Character set encoding of the attachment. This value is added to the Content-Type header for the attachment. Output Parameters error String Error messages generated, if any status String Final status of service. Usage Notes For security reasons, this service checks the input from address against the list of allowedFromEmails specified in the PSUtilities configuration file. If the input from address is not on the allowed list, an exception is thrown. This prevents this service from being used as a relay. file Folder Contains services for reading and writing to the file system. PSUtilities.file:bytesToFile PSUtilities. Writes the specified byte[] to a file Input Parameters filename String Fully qualified filename to be written to bytes byte[] The byte array to be written append String Specifies whether to append or overwrite if the specified file already exists. The default behavior is to create a new file (if file does not exist) or overwrite an existing file (if file already exists). Value Description true Append if file exists already false Overwrite if file exists already Output Parameters fullpath String Canonicalized version of the filename length String Number of bytes written Usage Notes For security reasons, this service checks the input filename against the list of allowedWritePaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. ©2004 webMethods, Inc. All rights reserved. Page 15 PSUtilities.file:checkFileExistence PSUtilities.file:checkFileExistence PSUtilities. Checks if a pathname exists, and if so, whether the pathname represents a file or directory. Input Parameters pathname String Fully-qualified path to be checked Output Parameters exists? isDirectory? String Indicates whether the specified pathname exists Value Description True Specified pathname exists False Specified pathname does not exist String Indicates whether the specified pathname is a file or a directory Value Description true Specified pathname is a directory false Specified pathname is a file Usage Notes For security reasons, this service checks the input filename against the list of allowedReadPaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. PSUtilities.file:co pyFile PSUtilities. Copies a file from one directory to another Input Parameters filename String Filename to be copied (without the full path) sourceDirectory String Directory the file will be copied from targetDirectory String Directory the file will be copied to Output Parameters message String Prints the confirmation message of the file copy Usage Notes For security reasons, this service checks the input sourceDirectory against the list of allowedReadPaths and the input targetDirectory against the list of allowedWritePaths specified in the PSUtilities configuration file. If either path is not on its respective allowed lists, an exception is thrown. PSUtilities.file:deleteFile PSUtilities. Deletes the specified file. Input Parameters filename String Fully-qualified path to be deleted ©2004 webMethods, Inc. All rights reserved. Page 16 PSUtilities.file:getBasename Output Parameters status length String Specifies the delete status Value Description true File deletion succeeded false File deletion failed String Length of the file that was deleted Usage Notes For security reasons, this service checks the input filename against the list of allowedDeletePaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. PSUtilities.file:getBasename PSUtilities. Given a full-qualified filename, removes the path portion to return only the filename (without the path). Input Parameters filename String Fully-qualified filename Output Parameters basename String filename (without the path) Usage Notes For security reasons, this service checks the input filename against the list of allowedReadPaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. PSUtilities.file:getMimeType PSUtilities. Given a filename, it determines the mime type based on the file extension. These associations are defined in the <IS_HOME>/lib/mime.types file. Input Parameters filename String Filename Output Parameters mimeType String Mime type associated with the input filename PSUtilities.file:listFiles PSUtilities. Lists all files in a specified directory. This service does not list subdirectories or recursively list subdirectory contents. Input Parameters directory String Directory name to query ©2004 webMethods, Inc. All rights reserved. Page 17 PSUtilities.file:moveFile filter String Optional. Filter string for the file list (e.g. *.java or EDI*.tx*) Output Parameters fileList StringList An array containing the filenames in the specified directory (not fully-qualified) fileList_fullpathnam es StringList An array containing all the fully-qualified filenames in the specified directory numFiles String Number of files in the specified directory Usage Notes For security reasons, this service checks the input directory against the list of allowedReadPaths specified in the PSUtilities configuration file. If the input directory is not on the allowed list, an exception is thrown. PSUtilities.file:moveFile PSUtilities. Moves a file from one directory to another with the same base filename or with a datetime stamp appended. Input Parameters sourcePath String Fully-qualified filename to be moved targetDir String Directory the file will be moved to useTimeStamp String Specifies whether a timestamp will be append to the target filename Value Description true Append a timestamp false Do not append a timestamp Output Parameters status String Status message targetFilePath String Fully-qualified pathname of the target file Usage Notes 2) For security reasons, this service checks the input sourcePath against the list of allowedReadPaths and the input targetDir against the list of allowedWritePaths specified in the PSUtilities configuration file. If either path is not on its respective allowed lists, an exception is thrown. 3) Please note that there is bug in java.io.File.renameTo() that could cause a misleading ‘status’ output. When the target directory denies permission to move a file into it, the service simply moves the file into the very same source directory, and returns a status of 'true' and an incorrect target file path. Beware! 4) java.io.File.renameTo() does not work when moving file from one disk to another. To move files from between mounted/shared directories, read the file into memory (pub.flow:readFile) and then write the file to disk (PSUtilities:bytesToFile). PSUtilities.file:objectToFile PSUtilities. Writes the specified Java object to a file ©2004 webMethods, Inc. All rights reserved. Page 18 PSUtilities.file:streamToFile Input Parameters filename String Fully qualified filename to be written to object Object Java object to be written Output Parameters None Usage Notes For security reasons, this service checks the input filename against the list of allowedWritePaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. PSUtilities.file:streamToFile PSUtilities. Writes the specified byte[] to a file Input Parameters filename String Fully qualified filename to be written to stream stream The stream to be written append String Specifies whether to append or overwrite if the specified file already exists. The default behavior is to create a new file (if file does not exist) or overwrite an existing file (if file already exists). Value Description true Append if file exists already false Overwrite if file exists already Output Parameters path String Canonicalized version of the filename length String Number of bytes written Usage Notes For security reasons, this service checks the input filename against the list of allowedWritePaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. PSUtilities.file:writeFile PSUtilities. Writes same text to a file Input Parameters filename String Fully qualified filename to be written to userData String Text to be written appendOverwriteFla g String Specifies whether to append or overwrite if the specified file already exists. The default behavior is to append Value Description ©2004 webMethods, Inc. All rights reserved. Page 19 PSUtilities.format:convertPackedDecimalToString append If file exists, append to file; if file does not exist, create new file <default> overwrite If file exists, overwrite; if file does not exist, create new file failIfFileExis If file exists, throw exception; if file does not exist, create new file ts Output Parameters None Usage Notes For security reasons, this service checks the input filename against the list of allowedWritePaths specified in the PSUtilities configuration file. If the input filename is not on the allowed list, an exception is thrown. format Folder Contains services that provide formatting services such as converting a string to a zoned decimal. The Multibyte File Parser provides a more comprehensive way to parse files with packed or zoned decimals, but if you need a quick way of performing package and zoned decimal formatting on individual fields, these services may be helpful. PSUtilities.format:convertPackedDecimalToString PSUtilities. Converts a packed decimal byte[] into the corresponding ASCII representation. Input Parameters bytes Object byte[] containing the packed decimal content. Output Parameters integer String ASCII string representation of the corresponding integer. PSUtilities.format:convertStringToPackedDecimal PSUtilities. Converts an ASCII string into the corresponding packed decimal representation. Input Parameters integer String ASCII string representation of a number. sign String Sign of the ASCII number. Value Description + Positive - negative <blank> unsigned ©2004 webMethods, Inc. All rights reserved. Page 20 PSUtilities.format:convertStringToZonedDecimal Output Parameters ByteStreamPackedD ecimalValue Object byte[] containing the packed decimal content. PSUtilities.format:convertStringToZonedDecimal PSUtilities. Converts a string into the corresponding zoned decimal. Input Parameters string String Decimal representation of a number. length String Length of the zoned decimal output. decimals String Number of decimals in the zoned decimal output. signed String Optional. Boolean specifying whether the zoned decimal should be signed or unsigned. Default is unsigned. true signed false unsigned Output Parameters zonedDecimal String Zoned decimal representation of the number. signed String Optional. String containing the sign of the zoned decimal (if the input value for signed is false). + positive - negative hashtable Folder Contains hashtable manipulation services. Contains services that provide the ability to create a hashtable, add elements to a hashtable, get the contents of a hashtable, remove elements from a hashtable and get the size of the hashtable. PSUtilities.hashtable:containsKey PSUtilities. Checks if the specified key exists in the hashtable Input Parameters Hashtable Object Hashtable object. key String Key of the hashtable element for which we are checking the existence. ©2004 webMethods, Inc. All rights reserved. Page 21 PSUtilities.hastable:createHashtable Output Parameters containsKey Object Boolean indicating whether key was found in the hashtable. true Key exists in hashtable. false Key does not exist in hashtable. PSUtilities.hastable :createHashtable PSUtilities. Creates a hashtable object. Input Parameters None Output Parameters Hashtable Object Hashtable object. PSUtilities.hashtable:example PSUtilities. Provides a simple flow service showing how to use some of the PSUtilities hashtable services. PSUtilities.hashtable:get PSUtilities. Gets the value for a specified key in the hashtable Input Parameters Hashtable Object Hashtable object. key String Key of the hashtable element that is being retrieved. Output Parameters value Object Value of the hashtable element retrieved. PSUtilities.hashtable:keys PSUtilities. Lists all the keys stored in the hashtable. Input Parameters Hashtable Object Hashtable object. Output Parameters keys StringList List of keys stored in the hashtable. ©2004 webMethods, Inc. All rights reserved. Page 22 PSUtilities.hashtable:put PSUtilities.hashtable:put PSUtilities. Put a key/value pair into the hashtable. Input Parameters Hashtable Object Input Hashtable object. key String Key of the hashtable element that is being retrieved. value Object Value of the hashtable element retrieved. Output Parameters Hashtable Object Output Hashtable object. PSUtilities.hashtable:remove PSUtilities. Removes a key/value pair into the hashtable. Input Parameters Hashtable Object Input Hashtable object. key String Key of the hashtable element that is being retrieved. Output Parameters Hashtable Object Output Hashtable object. value Object Value of the hashtable element retrieved. PSUtilities.hashtable:size PSUtilities. Gets the number of elements in the hashtable Input Parameters Hashtable Object Hashtable object. Output Parameters size String Number of elements in the hashtable. list Folder Contains services for that provide a higher-performance alternative for the WmPublic services pub.list:appendToDocumentList, pub.list:appendToRecordList. Those services used arrays to store the list structures, so it was necessary to construct a new array with each call. The services here are derived from the services in the WmSamples package, and use a linked list construct to reduce the ©2004 webMethods, Inc. All rights reserved. Page 23 PSUtilities.list:addToList overhead of adding documents to a list. These services could easily be extended to add Strings or other arbitrary Java objects to a list. PSUtilities.list:addToList PSUtilities. Adds a Document to the list. Input Parameters Document String Document to be appended to the list. list Object Linked list object (created using PSUtilities.list:createList). Output Parameters list Object Modified list object, with the Document added. PSUtilities.list:createList PSUtilities. Adds a Document to the list. Input Parameters initialListSize String Optional. Initial size of the linked list. The default is 100. Output Parameters list Object List object. PSUtilities.list:getListSize PSUtilities. Returns the size of the list. Input Parameters list Object List object. Output Parameters size String Size of the list. PSUtilities.list:listToArray PSUtilities. Converts the linked list object into a DocumentList. Input Parameters list Object Linked list object (created using PSUtilities.list:createList). ©2004 webMethods, Inc. All rights reserved. Page 24 PSUtilities.math:addDoubles Output Parameters DocumentList Object A DocumentList with the contents of the linked list. math Folder Contains services to perform mathematical operations. PSUtilities.math:addDoubles PSUtilities. Replaces pub.math:addFloats to provide better floating-point precision (by using java.math.BigDecimal). Input Parameters number1 String The first number to be added. Must be a double. number2 String The second number to be added. Must be a double. scale String Optional. The scale of the result. Defaults to 5. Output Parameters result String The sum (number1 + number2), represented as a String, that contains a double with the specified scale. PSUtilities.math:addDoublesWithNulls PSUtilities. Wrapper service for PSUtilities.math:addDoubles that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be added. num2 String The second number to be added. Output Parameters result String num1 + num2 PSUtilities.math:addFloatsWithNulls PSUtilities. Wrapper service for pub.math:addFloats that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be added. num2 String The second number to be added. ©2004 webMethods, Inc. All rights reserved. Page 25 PSUtilities.math:addIntsWithNulls Output Parameters result String num1 + num2 PSUtilities.math:addIntsWithNul ls PSUtilities. Wrapper service for pub.math:addInts that handles null values gracefully by treating them as 0. Input Parameters num1 String The first number to be added. num2 String The second number to be added. Output Parameters result String num1 + num2 PSUtilities.math:compareFloats PSUtilities. Compares one float value against another. Input Parameters firstNumber String The first number to be compared secondNumber String The second number to be compared. Output Parameters output String Result of the comparison Value Description -1 firstNumber < secondNumber 0 firstNumber = secondNumber 1 firstNumber > secondNumber PSUtilities.math:compareInts PSUtilities. Compares one integer value against another. Input Parameters firstNumber String The first number to be compared secondNumber String The second number to be compared. Output Parameters output String Result of the comparison Value Description ©2004 webMethods, Inc. All rights reserved. Page 26 PSUtilities.math:divideDoubles -1 firstNumber < secondNumber 0 firstNumber = secondNumber 1 firstNumber > secondNumber PSUtilities.math:divideDoubles PSUtilities. Replaces pub.math:divideFloats to provide better floating-point precision (by using java.math.BigDecimal). Input Parameters number1 String The dividend. Must be a double. number2 String The divisor. Must be a double. (Note that dividend/divisor = quotient) scale String Optional. The scale of the result. Defaults to 5. Output Parameters result String The quotient (number1 / number2), represented as a String, that contains a double with the specified scale. PSUtilities.math:getAbsoluteValue PSUtilities. Returns the absolute value of the input. Input Parameters number String Input number Output Parameters positiveNumber String Absolute value of number. PSUtilities.math:multiplyDoubles PSUtilities. Replaces pub.math:multiplyFloats to provide better floating-point precision (by using java.math.BigDecimal). Input Parameters number1 String First number to be multiplied. Must be a double. number2 String Second number to be multiplied. Must be a double. scale String Optional. The scale of the result. Defaults to 5. Output Parameters result String The product (number1 * number2), represented as a String, that contains a double with the specified scale. ©2004 webMethods, Inc. All rights reserved. Page 27 PSUtilities.math:multiplyDoublesWithNulls PSUtilities.math:multiplyDoublesWithNulls PSUtilities. Wrapper service for PSUtilities.math:multipleDoubles that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be multiplied. num2 String The second number to be multiplied. Output Parameters result String num1 * num2 PSUtilities.math:multiplyFloatsWithNulls PSUtilities. Wrapper service for pub.math:multiplyFloats that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be multiplied. num2 String The second number to be multiplied. Output Parameters result String num1 * num2 PSUtilities.math:multiplyIntsWithNulls PSUtilities. Wrapper service for pub.math:multiplyInt that handles null values gracefully by treating them as 0. Input Parameters num1 String The first number to be multiplied. num2 String The second number to be multiplied. Output Parameters result String num1 * num2 PSUtilities.math:roundNumber PSUtilities. Round a number to the specified precision. Input Parameters number String Number to be rounded. precision String The rounding precision (e.g. -3 = round to the nearest 1000, 3 = round to the nearest .001). ©2004 webMethods, Inc. All rights reserved. Page 28 PSUtilities.math:subtractDoubles Output Parameters roundedNumber String Rounded number PSUtilities.math: subtractDoubles PSUtilities. Replaces pub.math:subtractFloats to provide better floating-point precision (by using java.math.BigDecimal). Input Parameters number1 String First number to be subtracted. Must be a double. number2 String Second number to be subtracted. Must be a double. scale String Optional. The scale of the result. Defaults to 5. Output Parameters result String The result (number1 – number2), represented as a String, that contains a double with the specified scale. PSUtilities.math: subtractDoublesWithNulls PSUtilities. Wrapper service for PSUtilities.math:subtractDoubles that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be subtracted. num2 String The second number to be subtracted. Output Parameters result String num1 – num2 PSUtilities.math: subtractFloatsWithNulls PSUtilities. Wrapper service for pub.math:subtractFloats that handles null values gracefully by treating them as 0.0. Input Parameters num1 String The first number to be subtracted. num2 String The second number to be subtracted. Output Parameters result String num1 – num2 ©2004 webMethods, Inc. All rights reserved. Page 29 PSUtilities.math:subtractIntsWithNulls PSUtilities.math: subtractIntsWithNulls PSUtilities. Wrapper service for pub.math:subtractInt that handles null values gracefully by treating them as 0. Input Parameters num1 String The first number to be subtracted. num2 String The second number to be subtracted. Output Parameters String num1 – num2 result PSUtilities.math:trimZeroes PSUtilities. Removes insignificant leading and trailing zeroes from a whole number. (e.g. input: 00983400.00, output: 983400) Input Parameters number String Number to be trimmed. Output Parameters trimmedNumber String Trimmed number Usage Notes Note number must be >= 1 for this service to work correctly. PSUtilities.math:truncateNumber PSUtilities. Truncates a number to the specified precision. Input Parameters number String Number to be truncated. precision String The truncation precision (e.g. -3 = truncate at the 1000 digit, 3 = truncate at the.001 digit). Output Parameters truncatedNumber String Truncated number persistence Folder The persistence folder does not contain any utility services. Instead it contains some example services that demonstrate how to use a static variable build a cache of data in memory. The persistence folder contains the following services: Persist data into memory (PSUtilities.memory.persistence:saveDataToMemory) ©2004 webMethods, Inc. All rights reserved. Page 30 PSUtilities.misc:appendObjectList Retrieve data from memory (PSUtilities.memory.persistence:getDataFromMemory) List data stored in memory (PSUtilities.memory.persistence:listKeysInMemory) Clear the data from memory (PSUtilities.memory.persistence:clearMemory). Remove data stored (PSUtilities.memory.persistence:removeDataFromMemory). Test service to uses the services above (PSUtilities.memory.test:runPutDataInMemory) in memory misc Folder Contains miscellaneous utility services. PSUtilities.misc:appendObjectList PSUtilities. Appends an object to an objectList. Input Parameters object Object object to be appended. objectList Object[] objectList to be appended to Output Parameters newObjectList Object[] Resulting object list PSUtilities.misc:appendStringListToStringTable PSUtilities. Appends a stringList to a stringTable. Input Parameters fromStringList String[] StringList to be appended toStringTablet String[][] StringTable to be appended to Output Parameters toStringTable String[][] Resulting StringTable Usage Notes Note the number of columns in the StringTable must match the number of elements in the StringList. Otherwise, an exception will be thrown. ©2004 webMethods, Inc. All rights reserved. Page 31 PSUtilities.misc:checkThreadCount PSUtilities.misc:checkThr eadCount PSUtilities. Checks to see if the threadCount for a service has exceeded a specified number. Input Parameters serviceName String Service to check maximumThreads String Maximum number of allowed concurrent threads Output Parameters None Usage Notes Note if the maximum threadCount is exceeded, an exception will be thrown. PSUtilities.misc:collectGarbage PSUtilities. Manually sends a garbage collection request to the JVM. Input Parameters None Output Parameters None Usage Notes Note: It is possible that the garbage collection may not be initiated immediately if the JVM process is tied up with other tasks. PSUtilities.misc:deepArrayCopy PSUtilities. Creates a deep copy of the specified array object Input Parameters originalObjectList Object[] Array of objects to be cloned Output Parameters clonedObjectList Object[] Cloned array of objects PSUtilities.misc:deepConvert PSUtilities. Deep converts a Hashtable to a Values object. In other words, it will convert all objects within a Hashtable to a values object ©2004 webMethods, Inc. All rights reserved. Page 32 PSUtilities.misc:deepCopy Input Parameters Hashtable Hashtable Hashtable to be converted Output Parameters convertedValues Document Values object containing the Hashtable contents PSUtilities.misc:deepCopy PSUtilities. Creates a deep copy of the specified object Input Parameters originalObject Object Array of objects to be cloned Output Parameters clonedObject Object Cloned array of objects PSUtilities.misc:doInvoke PSUtilities. Used to invoke another service. Does the same thing as PSUtilities.misc:invoke, except this service takes in an explicitly passed pipeline. Input Parameters serviceNS String Fully qualified name of the service to invoke input String Input for the service Output Parameters None Usage Notes Note that because ACL checks are typically bypassed for internal invocations, this service can be used to circumvent the ACL checking. Therefore, for added security, this service checks the input servicename against the list of allowedServices specified in the PSUtilities configuration file. If the input servicename is not on the allowed list, an exception is thrown. PSUtilities.misc:getHostInformation PSUtilities. Gets the IP address of the specified host. Input Parameters host Object Array of objects to be cloned Output Parameters ipAddress String IP address of the specified host ©2004 webMethods, Inc. All rights reserved. Page 33 PSUtilities.misc:getRecordElements hostname String Hostname of the specified machine PSUtilities.misc:getRecordElements PSUtilities. Returns all the record elements as a list of keys and values. Input Parameters record Document Input document Output Parameters recordElementKeys StringList List of keys recordElementValue s StringList List of document values PSUtilities.misc:getServerConfigParameters PSUtilities. Returns a specified Integration Server parameters, or all Integration Server parameters if no parameter names are supplied. Input Parameters parameters StringList Optional. Stringlist of server parameters to retrieve Output Parameters paramList DocumentList List of parameter names and values paramCount String Number of parameters retrieved PSUtilities.misc:getServerInformation PSUtilities. Returns the current server's hostname, primary listening port, and current listening port. Input Parameters None Output Parameters serverName String Server hostname primaryPort String Primary IS listening port currentPort String Current IS listening port. When run as a scheduled service, the current listening port is null. PSUtilities.misc:getServiceName PSUtilities. Returns the calling service information ©2004 webMethods, Inc. All rights reserved. Page 34 PSUtilities.misc:getUser Input Parameters None Output Parameters folderPath String Server hostname serviceName String Primary IS listening port fullName String Current IS listening port. When run as a scheduled service, the current listening port is null. successFlag String Indicates whether the service call succeeded or failed errorMessage Value Description true Service succeeded without error false An exception occurred during service execution String Error message, if an error occurred Usage Notes 1) Because this service relies on a method invocation that retrieves the NSService object relating to the calling service, it will *NOT* work as desired if run independently. Instead, it will return information on the current service (this one) and set the "successFlag" and "errorMessage" values to indicate an error. 2) This service uses non-public APIs within the webMethods Integration Server. These APIs may change in future releases of the product without notice. These method invocations are commented in the service source code. PSUtilities.misc:getUser PSUtilities. Returns the user that is currently invoking the service. Input Parameters None Output Parameters username String Username invoking the service PSUtilities.misc:invoke PSUtilities. Used to invoke another service. Input Parameters folder String Name of the folder containing the service to invoke service String Name of the service to invoke Output Parameters None ©2004 webMethods, Inc. All rights reserved. Page 35 PSUtilities.misc:invokeAndCatchErrors Usage Notes Note that because ACL checks are typically bypassed for internal invocations, this service can be used to circumvent the ACL checking. Therefore, for added security, this service checks the input servicename against the list of allowedServices specified in the PSUtilities configuration file. If the input servicename is not on the allowed list, an exception is thrown. PSUtilities.misc:invokeAndCatchErrors PSUtilities. Used to invoke another service and catch any exceptions thrown by the service. Input Parameters folder String Name of the folder containing the service to invoke service String Name of the service to invoke Output Parameters error String Optional. Full error text of the exception errorMessage String Optional. The message portion of the exception Usage Notes Note that because ACL checks are typically bypassed for internal invocations, this service can be used to circumvent the ACL checking. Therefore, for added security, this service checks the input servicename against the list of allowedServices specified in the PSUtilities configuration file. If the input servicename is not on the allowed list, an exception is thrown. PSUtilities.misc:makeSystemCall PSUtilities. Executes an external command. Input Parameters command String Name of the command to be invoked. synchronous String Specified whether Value Description true Command is invoked synchronously (service waits for command to complete execution) false Command is invoked asynchronously (service does not wait for command to complete execution) Output Parameters status output String Indicates whether the subtractDoubles operation succeeded or failed Value Description 0 Normal execution termination >0 An exception occurred during execution String Optional. The output of the command ©2004 webMethods, Inc. All rights reserved. Page 36 PSUtilities.misc:matchServiceName error String Optional. Any error messages generated by the command Usage Notes 1) For added security, this service checks the input command against the list of allowedCommands specified in the PSUtilities configuration file. If the input command is not on the allowed list, an exception is thrown. This protects against someone maliciously invoking a command such as ‘rm –R *.*’ 2) The command format for Windows is as follows: a. For Windows 95/98/ME, use "command /c <command> ". b. For Windows NT/2000/XP, use "cmd /c <command> ". PSUtilities.misc: matchServiceName PSUtilities. Used internally by PSUtilities.misc:checkThreadCount. This service should not be called on its own. PSUtilities.misc:println PSUtilities. Writes a string to standard output. Input Parameters string String String to write to standard output Output Parameters None PSUtilities.misc:sleep PSUtilities. Sleeps the current thread for a specified time period Input Parameters millis String # of milliseconds to sleep for Output Parameters None Usage Notes 1) For added security, this service checks the input millis against the maxSleep parameter specified in the PSUtilities configuration file. If the input millis exceeds the maxSleep value, an exception is thrown. PSUtilities.misc:spawnThread PSUtilities. Used to invoke another service as part of a new thread. ©2004 webMethods, Inc. All rights reserved. Page 37 PSUtilities.misc:spawnThread2 Input Parameters serviceName String Fully-qualified service name to invoke Output Parameters None Usage Notes 1) Because ACL checks are typically bypassed for internal invocations, this service can be used to circumvent the ACL checking. Therefore, for added security, this service checks the input servicename against the list of allowedServices specified in the PSUtilities configuration file. If the input servicename is not on the allowed list, an exception is thrown. 2) Because the service is being invoked as part of a separate thread, the output of the invoked service will not be available to the spawnThread service. PSUtilities.misc:spawnThread2 PSUtilities. Same as spawnThread, but you can pass in an explicit IData object to constraint the input. Input Parameters serviceName String Fully-qualified service name to invoke input IData Input pipeline for the service to be invoked Output Parameters None Usage Notes 1) Because ACL checks are typically bypassed for internal invocations, this service can be used to circumvent the ACL checking. Therefore, for added security, this service checks the input servicename against the list of allowedServices specified in the PSUtilities configuration file. If the input servicename is not on the allowed list, an exception is thrown. 2) Because the service is being invoked as part of a separate thread, the output of the invoked service will not be available to the spawnThread service. PSUtilities.misc:throw Error PSUtilities. Throws a ServiceException containing the specified error message Input Parameters errorMessage String ServiceException error message Output Parameters None ©2004 webMethods, Inc. All rights reserved. Page 38 PSUtilities.object:className object Folder Contains utility services for working with Java objects. PSUtilities.object:className PSUtilities. Returns the class name of an object. Input Parameters object Object Object to return the classname Output Parameters name String Classname of the input object PSUtilities.object:instanceOf PSUtilities. Checks if a specified object is an instance of a specified class Input Parameters class Object Class name to check against object Object Object to check Output Parameters instanceof String Specifies whether object is an instance of the class Value Description true Object is an instance of the class false Object is not an instance of the class properties Folder Contains utility services for working with properties files. PSUtilities.properties:getSpecificSystemProperties PSUtilities. Returns a list of commonly-used system properties Input Parameters None ©2004 webMethods, Inc. All rights reserved. Page 39 PSUtilities.properties:getSystemProperties Output Parameters SystemProperties Document System properties retrieved Value Description java.version See Javadoc pages for System.getProperties() method for a description of these properties java.vendor java.vendor.ur l java.home java.class.ver sion java.class.pat h os.name os.arch file.separator path.separator line.separator user.name user.home user.dir PSUtilities.properties:getSystemProperties PSUtilities. Returns a list of all system properties Input Parameters None Output Parameters propertyList StringTable System properties list PSUtilities.properties:getSystemProperty PSUtilities. Returns a specified system property value Input Parameters propertyName String Name of the system property to be retrieved Output Parameters property String System property value ©2004 webMethods, Inc. All rights reserved. Page 40 PSUtilities.properties:readPropertiesFile PSUtilities.propert ies:readPropertiesFile PSUtilities. Reads a specified properties file and outputs the contents Input Parameters filename String Fully-qualified name of the property file Output Parameters property Properties Object containing all the properties read from the specified file <propertyname_1> String Value of <propertyname_1> … … <propertyname_n> String Value of <propertyname_n> regex Folder The regex folder exposes the regex classes offered with JVM 1.4. These services require JVM 1.4 or higher. Please see the java.util.regex API documentation for an explanation of each exposed service. remote Folder Contains utility services for invoking remote services. PSUtilities.remote:getRemoteServerInfo PSUtilities. Retrieves the connection parameters for a remote server alias Input Parameters alias String Name of the system property to be retrieved Output Parameters host String Hostname of remote server port String Port of remote server user String Username for remote server pass String Password for remote server ssl String System property value ©2004 webMethods, Inc. All rights reserved. Page 41 PSUtilities.remote:getRemoteServerInfoHelper Value Description true Remote connection uses https false Remote connection does not use https privKeyFile String Private key filename certFiles StringList An array containing all of the certificate filenames PSUtilities.remote:getRemoteServerInfoHelper PSUtilities. Used as a helper service by PSUtilities.remote:getRemoteServerInfo. There should not be any need to call this service directly. PSUtilities.remote:runContextJob PSUtilities. Performs a remote invoke to a service on an external webMethods Integration Server. Input Parameters host String Hostname of remote server port String Port of remote server username String Username for remote server password String Password for remote server useSSL String System property value Value Description true Remote connection uses https false Remote connection does not use https privKeyFile String Private key filename certFiles StringList An array containing all of the certificate filenames Output Parameters None PSUtilities.remote:runTContextJob PSUtilities. Performs a guaranteed delivery call to a service on an external webMethods Integration Server. Input Parameters host String Hostname of remote server port String Port of remote server username String Username for remote server password String Password for remote server ©2004 webMethods, Inc. All rights reserved. Page 42 PSUtilities.session:clearSession ttl String Time-to-live for the guaranteed delivery request retries String Maximum # of retries for the guaranteed delivery request useSSL String System property value Value Description true Remote connection uses https false Remote connection does not use https privKeyFile String Private key filename certFiles StringList An array containing all of the certificate filenames Output Parameters None session Folder Contains utility services for accessing webMethods session contents. PSUtilities.session:clearSession PSUtilities. Removes all entries from the current session. Input Parameters None Output Parameters deleteCount String Number of elements removed from the session PSUtilities.session:getObjectFromSession PSUtilities. Retrieves a specified object from the session. Input Parameters objectName String Name of the session object key to retrieve Output Parameters object Object Object retrieved PSUtilities.session:getSessionID PSUtilities. Retrieves the current webMethods Session ID ©2004 webMethods, Inc. All rights reserved. Page 43 PSUtilities.session:getSessionKeys Input Parameters None Output Parameters sessionID String ID of the current webMethods session PSUtilities.session:getSessionKeys PSUtilities. Retrieves all keys contained in the current session. Input Parameters None Output Parameters keyCount String Number of keys found sessionKeys StringList Array of containing all of the object keys in the session PSUtilities.session:putObjectInSession PSUtilities. Retrieves all keys contained in the current session. If an object key of the same name already exists in the session, the new object will replace it. Input Parameters objectName String Name of the session object key object Object Object to be added to the session Output Parameters None PSUtilities.session:removeObjectFromSession PSUtilities. Removes a specified object from the session Input Parameters objectName String Name of the session object key to remove Output Parameters object Object Object removed ©2004 webMethods, Inc. All rights reserved. Page 44 PSUtilities.ssl:deleteUserCertificate ssl Folder SSL-related utility services. PSUtilities.ssl:deleteUserCertificate PSUtilities. Deletes a specified certificate from the webMethods Server Input Parameters issuer String Issuer of the certificate (issuerDN) serialNum String Serial number of the certificate Output Parameters error String Optional. Error message, if any. PSUtilities.ssl:extractCertificate PSUtilities. Extracts out the key fields from a specified certificate Input Parameters certificate byte[] Certificate object Output Parameters subjectDN String Subject name on the certificate issuerDN String Issuer DN name on the certificate issuerSN String Issuer serial number on the certificate notBefore String Valid date notAfter String Valid date PSUtilities.ssl:extractChain PSUtilities. Gets the certificate chain for the current request Input Parameters None Output Parameters hasChain String Boolean indicating whether a certificate chain was found Value Description true Certificate chain is present false No certificate chain is present ©2004 webMethods, Inc. All rights reserved. Page 45 PSUtilities.ssl:importUserCertificate certificates RecordList Certificate chain contents Value Description certificate byte[] Certificate object subjectDN String Subject name on the certificate issuerDN String Issuer DN name on the certificate issuerSN String Issuer serial number on the certificate notBefore String Valid date notAfter String Valid date PSUtilities.ssl:importUserCertificate PSUtilities. Imports the specified certificate to the Integration Server Input Parameters certificatePath String Optional. Fully-qualified path for the certificate certificate byte[] Optional. Certificate contents (either certificatePath or certificate must not be null) user String Optional. User to associate this certificate to Output Parameters certificateIssuerCN String Issuer name on the certificate certificateSubjectCN String Subject name on the certificate certificateSerialNum ber String Serial number on the certificate errorMsg String Error messages encountered during import Usage Notes 1) Note that this service expects the certificate in .der format 2) The Integration Server user must already exist. 3) In case the certificate has already been imported, an exception will be thrown. stream Folder Contains utility services for working with streams. PSUtilities.stream:bytesToStream PSUtilities. Converts a byte[] to a stream ©2004 webMethods, Inc. All rights reserved. Page 46 PSUtilities.stream:closeStream Input Parameters buffer byte[] byte[] contents length String Length of the buffer Output Parameters blockStream Stream Stream object PSUtilities.stream:closeStream PSUtilities. This service takes a java.io.InputStream (or a subclass) or a java.io.OutputStream (or a subclass) and closes it. This service is useful because if you use pub.file:getFile with the stream option, the stream never gets closed. The closeStream service accepts a stream, detects whether it is an input or output stream, and then closes it. Input Parameters stream Stream Stream object Output Parameters message String Optional. Success message PSUtilities.stream:closeStream PSUtilities. This service takes a java.io.InputStream (or a subclass) or a java.io.OutputStream (or a subclass) and closes it. This service is useful because if you use pub.file:getFile with the stream option, the stream never gets closed. The closeStream service accepts a stream, detects whether it is an input or output stream, and then closes it. Input Parameters stream Stream Stream object Output Parameters message String Optional. Success message PSUtilities.stream:streamToBytes PSUtilities. Converts a stream to a byte[] Input Parameters stream Stream Stream object Output Parameters bytes byte[] byte[] contents ©2004 webMethods, Inc. All rights reserved. Page 47 PSUtilities.stream:streamToString PSUtilities.stream:streamToString PSUtilities. Converts a stream to a String Input Parameters stream Stream Stream object Output Parameters sring String String object PSUtilities.stream:stringToStream PSUtilities. Converts a String to a stream Input Parameters sring String String object Output Parameters stream Stream Stream object string Folder Contains utility services for working with Strings. PSUtilities.string:addLineSeparator PSUtilities. Adds a line separator to the specified string. Input Parameters inString String Input string Output Parameters outString String Output string Usage Notes The line separator will depend on the System Property (either \r [UNIX] or \r\n [DOS]) PSUtilities.st ring:compareString PSUtilities. Compares the values of two strings to see if they are equal ©2004 webMethods, Inc. All rights reserved. Page 48 PSUtilities.string:convertLineSeparator Input Parameters string1 String Input string 1 string2 String Input string 2 Output Parameters isEqual String Boolean indicating whether the two strings are the same Value Description true string1 = string2 false string1 <> string2 Usage Notes If both Strings are null, isEqual will be “true”. If one String is null and the other is not null, isEqual will be “false”. PSUtilities.string:convertLineSeparator PSUtilities. Converts Unix \r end-of-line characters in the input string to DOS \r\n characters. Input Parameters inString String Input string Output Parameters outString String Output string PSUtilities.string:decode64String PSUtilities. base64 decodes the given string. This service simply wraps the pub.string:base64Decode service to make it slightly easier to call. Input Parameters encodedString String Encoded string Output Parameters decodedString String Decoded string PSUtilities.string:encode6 4String PSUtilities. base64 encodes the given string. This service simply wraps the pub.string:base64Encode service to make it slightly easier to call. Input Parameters decodedString String Decoded string ©2004 webMethods, Inc. All rights reserved. Page 49 PSUtilities.string:isAlphanumeric Output Parameters encodedString String Encoded string PSUtilities.string:isAlphanumeric PSUtilities. Checks if the specified string is alphanumeric (0-9, A-z) Input Parameters input String String to check Output Parameters isAlphanumeric String Boolean indicating whether the input string is alphanumeric Value Description true Input string is alphanumeric false Input string is not alphanumeric PSUtilities.string:isDate PSUtilities. Checks if the specified string is a date Input Parameters input String String to check dateFormat String Date format (using the Java date format syntax, e.g. yyyyMMdd HH:mm:ss.SSS) Output Parameters isDate String Boolean indicating whether the input string is a date in the specified dateFormat Value Description true Input string is a date false Input string is not a date PSUtilities.string:isNullOrBlank PSUtilities. Checks if the specified string is null or blank. Input Parameters inString String String to check Output Parameters result String Boolean indicating whether the input string is null or blank Value Description ©2004 webMethods, Inc. All rights reserved. Page 50 PSUtilities.string:isNumeric true Input string is either null or blank false Input string is not null and not blank PSUtilities.string:isNumeric PSUtilities. Checks if the specified string is numeric. Input Parameters input String String to check Output Parameters isNumeric String Boolean indicating whether the input string is numeric (0-9) Value Description true Input string is numeric false Input string is not numeric PSUtilities.string:multiConcat PSUtilities. Concatenates up to 10 strings together to form a single string. Input Parameters inStr1 String Input string 1 InStr2 String Input string 2 InStr3 String Input string 3 InStr4 String Input string 4 InStr5 String Input string 5 InStr6 String Input string 6 InStr7 String Input string 7 InStr8 String Input string 8 InStr9 String Input string 9 inStr10 String Input string 10 Output Parameters outStr String Concatenated string PSUtilities.string:padLeftWithNulls PSUtilities. Performs the same function as pub.string:padLeft, except that it handles a null inString without throwing an exception. Note: A null inString is treated as an empty string. ©2004 webMethods, Inc. All rights reserved. Page 51 PSUtilities.string:padRightWithNulls Input Parameters inString String String to pad padString String String to pad with length String Required length of the output string Output Parameters value String Padded string PSUtilities.string:padRightWithNulls PSUtilities. Performs the same function as pub.string:padRight, except that it handles a null inString without throwing an exception. Note: A null inString is treated as an empty string. Input Parameters inString String String to pad padString String String to pad with length String Required length of the output string Output Parameters value String Padded string PSUtilities.string:removeLineSeparators PSUtilities. Removes all the lineSeparators from a specified string. Input Parameters inString String Input string Output Parameters outString String Output string PSUtilities.string:substituteVariables PSUtilities. Performs variable substitution based on specified inputString and other pipeline variables. All text beginning and ending with % is substituted with the pipeline variable whose name is contained in the % signs. Input Parameters inputString String Input string Output Parameters outputString String Output string ©2004 webMethods, Inc. All rights reserved. Page 52 PSUtilities.string:truncateString Usage Notes 1) "\%" overrides special meaning of % and denotes "%" in outputString 2) No substitution occurs if % pair is not found. 3) If the substitution variable is not found in the pipeline, no substitution is made. 4) Example: inputString = "Our revenue has increased by %revenueIncreasePercent%\%" Pipeline: revenueIncreasePercent = "100" outputString = "Our revenue has increased by 100%" PSUtilities.string:truncateString PSUtilities. Truncates the given string to maxLength characters. Input Parameters inString String Input string maxLength String Length to truncate the string to Output Parameters outString String Truncated string zip Folder Contains utility services for zipping and unzipping files. PSUtilities.zip:unzipFiles PSUtilities. Unzips a file. Input Parameters zipFileName String Fully-qualified filename of the zip file targetDirectory String Target directory for the unzipped files Output Parameters numFilesProcessed String Number of files unzipped unzippedFileNames StringList Names of the unzipped files Usage Notes 1) This service has not been tested extensively, and there are known bugs. 2) targetDirectory should NOT have trailing slash (e.g. Valid: c:\temp, Invalid: c:\temp\) ©2004 webMethods, Inc. All rights reserved. Page 53 PSUtilities.zip:zipFiles 3) For security reasons, this service checks the input zipFileName against the list of allowedReadPaths and the input targetDirectory against the list of allowedWritePaths specified in the PSUtilities configuration file. If either path is not on its respective allowed lists, an exception is thrown. PSUtilities.zip:z ipFiles PSUtilities. Zips the contents of a directory or file. Input Parameters sourcePath String Either a file or directory that will be zipped zipFileName String Fully-qualified filename of the zip file Output Parameters numFilesZipped String Number of files unzipped Usage Notes Usage Notes 1) This service has not been tested extensively, and there are known bugs. 2) zipFiles recursively zips all subdirectories in the specified directory. Empty subdirectories are not included in the zip. 3) If sourcePath is a directory, do not include the trailing slash (e.g. Valid: c:\temp, Invalid: c:\temp\) 4) For security reasons, this service checks the input sourcePath against the list of allowedReadPaths and the input zipFileName against the list of allowedWritePaths specified in the PSUtilities configuration file. If either path is not on its respective allowed lists, an exception is thrown. ©2004 webMethods, Inc. All rights reserved. Page 54 PSUtilities.zip:zipFiles ©2004 webMethods, Inc. All rights reserved. Page 55 Worldwide Headquarters South Tower 3877 Fairfax Ridge Rd Fairfax, VA 22030 USA Tel: 703 460 2500 Fax: 703 460 2599 US West Coast 432 Lakeside Drive Sunnyvale, CA 94088 Tel: 408 962 5000 Fax: 408 962 5329 ABOUT WEBMETHODS, INC. webMethods is a leading provider of business integration software to the Global 2000 and large government agencies. Our technology lets our customers integrate, assemble and optimize available IT assets to drive business process productivity. Currently, more than 1,200 customers are meeting customer demands, reducing costs, creating new revenue opportunities and reclaiming ROI. Faster. webMethods is headquartered in Fairfax, Va., with offices throughout the United States, Europe, Asia Pacific and Japan. More information about the company can be found at www.webMethods.com. NASDAQ: WEBM. European Headquarters Barons Court 20 The Avenue Egham, Surrey TW20 9AU United Kingdom Tel: 44 0 1784 221700 Fax: 44 0 1784 221701 Asia-Pacific Headquarters Level 15 Philips Building 15 Blue Street North Sydney NSW 2060 Australia Tel: 61 2 8919 1111 Fax: 61 2 8920 2917 webMethods Japan KK Izumi Garden Tower 30F 1-6-1 Roppongi, Minato-ku Tokyo 106-6030 Japan Tel: 81 3 6229 3700 Fax: 81 3 6229 3701 www.webMethods.com ©2005 webMethods, Inc. All right reserved. The webMethods logo and Get There Faster are trademarks or registered trademarks of webMethods, Inc. All other names mentioned are trademarks, registered trademarks or service marks of their respective companies.