Namespace: OpenEdge.Core.Util
Class
TokenResolver
Parent classes:
Progress.Lang.Object

Inherits: Progress.Lang.Object

/* *************************************************************************************************************************
Copyright (c) 2018-2019 by Progress Software Corporation and/or one of its subsidiaries or affiliates. All rights reserved.
File:TokenResolver
Purpose:Resolves certain known token names into useful values
Author(s):pjudge
Created:Wed Nov 16 13:02:52 EST 2016
Notes:* Token substitutions are allowed for file names
the token format is ${<token>}, where
token = group "." arg
groups = session | env | guid | t[ime] | web | ver[sion]
cp | req[uest] | name | err
If a token cannot be resovled, or resolves to a value of
? (unknown) then the token name is used.
- any readable attribute on the session handle may be used
- any env var available via OE-GETENV() may be used
- Correlates to the SESSION:LOCAL-VERSION-INFO
- MAJOR, MINOR, MAINT
- a default-format GUID is used
- Values are taken from the time at which the file name is being built.
- The args are based on http://en.cppreference.com/w/c/chrono/strftime
TODAY: An ISO-DATE formatted DATE value is used
NOW } An ISO-DATE formatted DATETIME-TZ value is used
ISO }
HTTP:The datetime formatted as per https://tools.ietf.org/html/rfc7231#section-7.1.1.1
YYYY:The current year, incl century
YY:The current year, sans century
BB:The full month name (from the MONTH_LONG property)
B:The shortened month name (from the MONTH_SHORT property)
MM:The integer month value, with leading 0 if needed
M:The integer month value with no leading 0
DD:The integer day value, with leading 0 if needed
D:The integer month value, with no leading 0
HH:The hour value, in 24-hour clock format (ie 18 for 6pm)
H:The hour value, in 12-hour clock format (ie 6 for 6pm)
MMM:The minute value, with leading 0
SS:The second value, with leading 0
SSS:The millisecond value, with leading 0
Z:The timezone (based on the current session), with leading +/-
PP:The AM/PM indicator, as AM or PM
P:The AM/PM indicator, as A or P
AA:The full day of the week, from the WEEKDAY_LONG property
A:The short day of the week, from the WEEKDAY_SHORT property
W:The integer day of the week
Will return ? if we're not in a request (ie startup event procs). Values
are taken from the session:current-request-info
TPT:The adapter type (transport) for this request
CCID:The client context id
ID:The current request id
SESSION:The current session id
THREAD:(PASOE) the current thread id
WEBAPP["." webapp-type]
webapp-type
NAME:the context/webapp name (default)
PATH:the fully-qualified path of the webapp
SVC
any other cgi value
credential-arg "." db-name
credential-arg
The current user will be used (from the request info or the security-policy)
UID:The current user id
QUID:The qualified user id (user@domain)
DOMAIN:The domain name of the current user
PROP "." property-name : Returns the value of a property in the CP
property-name:The name of a property to return
db-name
An optional logical db name from which to extract the CP. If none is set, use the security-policy
tokenArg = format-expression "." logger-name
- logger-name : a named-hierarchy dotted-name
- named-hierarchy
something like OpenEdge.Net.DataObject.DataObjectHandler (a logger name) will become
O.N.D.DataObjectHandler (default or .1K)
o.n.d.DataObjectHandler (.1L)
OE.N.DO.DataObjectHandler (.1C)
OE.N.DO.DOH (.0C)
- format-expression
keep-expr case-expr
keep-expr:
number of significant entries to keep (from right)
0:All entries will be trimmed (ie zero kept)
1:Only the last/only will be keep whole (default)
2..n: The number of entries (from the right) to keep
case-expr
U:trimmed elements are upper-cased
L:trimmed elements are lower-cased
K:trimmed elements are left alone (default)
C:trimmed elements are Camel-cased (caps only written)
N:message number n (defaults to 1 if not an integer or none provided)
SEV:error severity
RETVAL:return value, if an AppError
STACK:the callstack, if enabled
TYPE:the error type (class)
/* Event published after a token is resolved by this resolver. Allows a listener to override the value




Method Summary
Options Name Purpose
OpenEdge.Core.Util.Token Parse (character) /* Extracts any tokens from a string, and returns them as an array of token objects @param character The string potentially containing tokens @return Token[] An array of tokens. May be indeterminate in size if there are no tokens. */
CHARACTER Resolve (character) /* Resolves any tokens in the file name into appropriate values @param character The source string @return character The resolved string */
CHARACTER ResolveError (character, Error) /* Resolves a ERR-based token arg, based on the type/logger name given @param character The token argument for ${ERR.*} tokens @param Progress.Lang.Error The error/exception to resolve @return character The resolved string */
CHARACTER ResolveName (character, character) /* Resolves a NAME-based token arg, based on the type/logger name given @param character The token argument for ${NAME.*} tokens @param character The (type) name to resolve @return character The resolved string */
CHARACTER ResolveTime (character, character[12], character[12], character[7], character[7], datetime-tz) /* Resolves a time-based token arg, based on the timestamp given @param character The token argument for ${T.*} tokens @param character[12] The long-form month names (ie January) @param character[12] The short-form month names (ie Jan) @param character[7] The long-form weekday names (ie Thursday) @param character[7] The short-form weekday names (ie Thurs) @param datetime-tz The timestamp to use to resolve the token @return character The resolved string */
CHARACTER ResolveTime (character, datetime-tz) /* Resolves a time-based token arg, based on the timestamp given @param character The token argument for ${T.*} tokens @param datetime-tz The timestamp to use to resolve the token @return character The resolved string */
CHARACTER ResolveToken (character, character, Object) /* Resolves a single token into appropriate values, optionally using some input context @param character (required) The token group @param character (optional) The token argument @param Progress.Lang.Object (optional) Context used to resolve the token. eg a TimeStamp for times @return character The token value. Returns the UNKNOWN value if the token cannot be resolved */
CHARACTER ResolveUser (character, handle) /* Resolves a CP-based token arg, based on the client-principal. It is the CALLER's responsibility to clean up the C-P object represented by this handle @param character The token argument for ${CP.*} tokens @param handle A user represented by a client-principal @return character The resolved string */
CHARACTER SplitTokenArg (character) /** Splits a .-delimited token argument into an array @param character the token argument to return @return character[] An array of character. If the input arg is empty/null we return a [1] array */

Event Summary
Options Name Purpose
TokenResolved (Object, TokenResolverEventArgs) /* Event published after a token is resolved by this resolver. Allows a listener to override the value */

Property Summary
Options Name Purpose
CHARACTER MONTH_LONG
CHARACTER MONTH_SHORT
CHARACTER WEEKDAY_LONG
CHARACTER WEEKDAY_SHORT


Method Detail
Top

OpenEdge.Core.Util.Token Parse (character)

/* Extracts any tokens from a string, and returns them as an array of token objects
Parameters:
pBaseString CHARACTER
Returns OpenEdge.Core.Util.Token
Token[] An array of tokens. May be indeterminate in size if there are no tokens.
Top

CHARACTER Resolve (character)

/* Resolves any tokens in the file name into appropriate values
Parameters:
pcBaseString CHARACTER
Returns CHARACTER
character The resolved string
Top

CHARACTER ResolveError (character, Error)

/* Resolves a ERR-based token arg, based on the type/logger name given
Parameters:
pTokenArg CHARACTER
pError Progress.Lang.Error
Returns CHARACTER
character The resolved string
Top

CHARACTER ResolveName (character, character)

/* Resolves a NAME-based token arg, based on the type/logger name given
Parameters:
pTokenArg CHARACTER
pName CHARACTER
Returns CHARACTER
character The resolved string
Top

CHARACTER ResolveTime (character, character[12], character[12], character[7], character[7], datetime-tz)

/* Resolves a time-based token arg, based on the timestamp given
Parameters:
pTokenArg CHARACTER
pMonthLong CHARACTER
pMonthShort CHARACTER
pWeekdayLong CHARACTER
pWeekdayShort CHARACTER
pTimestamp DATETIME-TZ
Returns CHARACTER
character The resolved string
Top

CHARACTER ResolveTime (character, datetime-tz)

/* Resolves a time-based token arg, based on the timestamp given
Parameters:
pTokenArg CHARACTER
pTimestamp DATETIME-TZ
Returns CHARACTER
character The resolved string
Top

CHARACTER ResolveToken (character, character, Object)

/* Resolves a single token into appropriate values, optionally using some input context
Parameters:
pTokenGroup CHARACTER
pTokenArg CHARACTER
pContext Progress.Lang.Object
Returns CHARACTER
character The token value. Returns the UNKNOWN value if the token cannot be resolved
Top

CHARACTER ResolveUser (character, handle)

/* Resolves a CP-based token arg, based on the client-principal.
It is the CALLER's responsibility to clean up the C-P object represented by this handle
Parameters:
pTokenArg CHARACTER
pUser HANDLE
Returns CHARACTER
character The resolved string
Top

CHARACTER SplitTokenArg (character)

Purpose: Splits a .-delimited token argument into an array
Parameters:
pTokenArg CHARACTER
Returns CHARACTER
character[] An array of character. If the input arg is empty/null we return a [1] array


Event Detail
Top

TokenResolved (Object, TokenResolverEventArgs)

/* Event published after a token is resolved by this resolver. Allows a listener to override the value
Parameters:
pSender Progress.Lang.Object
pArgs OpenEdge.Core.Util.TokenResolverEventArgs


Property Detail
Top

CHARACTER MONTH_LONG

Returns CHARACTER
Top

CHARACTER MONTH_SHORT

Returns CHARACTER
Top

CHARACTER WEEKDAY_LONG

Returns CHARACTER
Top

CHARACTER WEEKDAY_SHORT

Returns CHARACTER


Copyright © 2022 Progress Software Corporation. All rights Reserved.

Progress® OpenEdge® Release 11.7.15