public class SourceNameMapper
extends java.lang.Object
The mapping data is loaded from the directory into data structures that
are static
. This means that at this time this mapping data
is global to the entire server rather than being context-local. The
reason for this is to reduce the amount of memory used for this data
since 2+ map entries exist for each original source file (thus these maps
each contain thousands of entries for any reasonably sized
application).
The current implementation assumes a single root path for all Progress procedure file names and single base package path for the generated Java classes. Despite these assumptions it is possible to translate Progress procedure names incorrectly (to a Java class name which does not belong to the subtree specified by the single root or which does not belong to the base package path). These problems are caused by using mismatching absolute paths for Progress names or names which start with a dot ('.') for Java class names. The leading dot is stripped from the returned class name and is not returned as a result of a mapping.
The source file name can be in one of the many forms: relative path, absolute path, can contain references to current and to upper level directories. Also, the source file name can use the file naming format of the original operating system used to run the Progress program rather than the current operating system used to run the converted Java application. To this the directory contains values that define the original source system's parameters such as path delimiter, file name delimiter and case sensitivity.
Modifier and Type | Class and Description |
---|---|
(package private) static class |
SourceNameMapper.ExternalProgram
Container for all external program information.
|
private static class |
SourceNameMapper.InternalEntryKey
Map key for internal entry objects.
|
private static class |
SourceNameMapper.LegacyClass
Container for all legacy class information.
|
private static class |
SourceNameMapper.WorkArea
Container for context-local data.
|
Modifier and Type | Field and Description |
---|---|
private static java.lang.String |
altFileSep
Alternative name element separator used for the Progress file name data.
|
private static java.lang.String |
ATTR_JNAME
Java name attribute.
|
private static java.lang.String |
ATTR_LIBNAME
LIBNAME attribute.
|
private static java.lang.String |
ATTR_MAP_TO
MAP-TO attribute.
|
private static java.lang.String |
ATTR_PARAM_MODE
Parameter MODE attribute.
|
private static java.lang.String |
ATTR_PNAME
Progress name attribute.
|
private static java.lang.String |
ATTR_TYPE
TYPE attribute.
|
private static java.util.Map<java.lang.Class<?>,SourceNameMapper.LegacyClass> |
classMap
Association between converted legacy 4GL programs to their defined internal entries.
|
(package private) static java.lang.String |
CONSTRUCTOR
Suffix of the constructor internal procedure.
|
(package private) static java.lang.String |
CTOR_PREFIX
Prefix of the constructor or destructor internal procedure.
|
private static java.lang.String |
custpkgroot
Custom package to init data for.
|
(package private) static java.lang.String |
DESTRUCTOR
Suffix of the destructor internal procedure.
|
static int |
DYNAMIC_EXTENT
Constant identifying dynamic-extent parameters.
|
private static java.lang.String |
ELEM_CMAP
Class mappings element.
|
private static java.lang.String |
ELEM_MMAP
Methods mappings element.
|
private static java.lang.String |
ELEM_PARAM
Parameter info element.
|
private static java.lang.String |
ELEM_REST_SERVICE
Rest service mappings element.
|
private static java.lang.String |
fileSep
Name element separator used for the Progress file name data.
|
private static java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> |
j2pMap
Progress Java class name to procedure file name map table.
|
private static java.lang.String[] |
legacyRoots
The 4GL legacy roots for source files.
|
private static ContextLocal<SourceNameMapper.WorkArea> |
local
Context-local data.
|
private static java.util.logging.Logger |
LOG
logger
|
static int |
NO_EXTENT
Constant identifying no-extent parameters.
|
private static java.util.Set<java.lang.String> |
NOT_A_CLASS
Set of
Class.forName(java.lang.String) lookups by convertName(java.lang.String) which do not resolve to a Java class for
the given program name. |
private static java.lang.String |
OONAME
Qualified OO name attribute.
|
private static java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> |
p2jMap
Progress procedure file name to Java class name map table.
|
private static java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> |
p2jMap_ci
Progress procedure file name to Java class name map table (case-insensitive).
|
private static java.util.Map<java.lang.String,java.util.List<SourceNameMapper.ExternalProgram>> |
p2jNonExtMap
Map of program names without extension to the programs which can be resolved with this name.
|
private static java.util.Map<java.lang.String,java.util.List<SourceNameMapper.ExternalProgram>> |
p2jNonExtMap_ci
Map of program names without extension to the programs which can be resolved with this name (ci).
|
private static java.util.Map<java.lang.String,java.lang.String> |
pathAliases
Map of aliases (r-code folders) to their source folders (conversion folders).
|
private static java.util.Map<java.lang.String,java.lang.String> |
pathAliases_ci
Map of aliases (r-code folders) to their source folders (conversion folders).
|
private static java.lang.String |
pkgroot
Base path for all Java packages.
|
private static java.lang.String |
proroot
Base path for Progress 4GL code.
|
private static java.lang.String |
PUBLISHED_EVENTS
Named events attribute.
|
private static java.util.List<SourceNameMapper.ExternalProgram> |
servicePrograms
The list of programs exposed as services (the 'with-services' attribute or 'rest-service' nodes).
|
(package private) static java.lang.String |
STATIC_CONSTRUCTOR
Suffix of the static constructor internal procedure.
|
private static java.lang.String |
WITH_SERVICES
'with-services' attribute.
|
Constructor and Description |
---|
SourceNameMapper() |
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
addPkg(java.lang.String name)
Construct a full class name (including packages) for the stored package
root and the given class name.
|
private static SourceNameMapper.ExternalProgram |
buildExternalProgram(java.lang.String pname,
java.lang.String jname,
org.w3c.dom.Element classMap)
Collect the
SourceNameMapper.ExternalProgram info contained in the classMap
node. |
private static java.lang.String |
buildInternalEntries(SourceNameMapper.ExternalProgram extProg,
boolean prv)
Build the internal-entries 4GL attribute for the given external program.
|
(package private) static InternalEntry |
buildInternalEntry(LegacySignature ls,
java.lang.String jname)
Build an
InternalEntry matching the specified legacy signature. |
(package private) static void |
buildLegacyClass(java.lang.Class<?> cls)
Build a legacy class entry by resolving all the legacy methods (marked with the
LegacySignature annotation) and register them. |
(package private) static void |
buildLegacyProgram(SourceNameMapper.ExternalProgram extprog)
Build a map of legacy method names to their Java
Method , for the given external program. |
private static InternalEntry |
buildMethod(java.lang.String pname,
java.lang.String jname,
org.w3c.dom.Element methMap)
Collect the
InternalEntry info contained in the methMap node. |
private static Parameter |
buildParameter(LegacyParameter lp)
Build a
Parameter instance from the specified LegacyParameter annotation. |
private static void |
buildParameters(org.w3c.dom.Element node,
InternalEntry ie)
Build the parameters for the specified internal entry.
|
private static java.lang.String |
canonicalize(java.lang.String progName)
Convert the given Progress file name into a simple relative path
form.
|
static java.lang.String |
convertJavaMethod(java.lang.String clsName,
java.lang.String methodName,
boolean function)
Convert a java method name to a legacy name.
|
static java.lang.String |
convertJavaProg(java.lang.Class<?> cls)
Get the legacy 4gL class name for the Java class name.
|
static java.lang.String |
convertJavaProg(java.lang.String jname)
Get the legacy 4gL name for the Java class name.
|
static java.lang.String |
convertJavaProg(java.lang.String customRoot,
java.lang.String jname)
Get the legacy 4GL name for the Java class name.
|
static java.lang.String |
convertJavaProgSafe(java.lang.String jname)
Get the legacy 4gL name for the Java class name or, if not a legacy program, return the
java class name, without the base package.
|
private static java.lang.String[] |
convertName(java.lang.String legacyProgName)
Convert a Progress file name into Java class name.
|
private static java.lang.String[] |
convertName(java.lang.String legacyProgName,
java.util.function.Function<java.lang.String,SourceNameMapper.ExternalProgram> lookup)
Convert a Progress file name into Java class name.
|
static java.lang.String |
convertNameToClass(java.lang.String legacy)
Uses the
convertName(String) worker for finding the name of the Java class name of
a converted P4GL procedure name. |
static java.lang.String |
convertOOToClass(java.lang.String legacyClsName)
Convert a legacy 4GL class name to a converted Java class file.
|
static InternalEntry |
findLegacyAccessor(java.lang.Class<?> type,
java.lang.String pname,
boolean getter,
boolean indexed)
Look into all the properties with the specified legacy name (in the given legacy type) and
return the getter or setter matching exactly the specified signature.
|
static java.lang.String |
findLegacyEntryName(java.lang.Class<?> type,
java.lang.String mname)
Given a converted class name, find the legacy name for a Java method defined in that program or legacy
class.
|
static InternalEntry |
findLegacyMethod(java.lang.Class<?> type,
java.lang.String pname,
InternalEntry signature)
Look into all the methods with the specified legacy name (in the given type) and return the
one matching exactly the specified signature.
|
static java.lang.Integer |
findLegacyPropertyExtent(java.lang.Class<?> type,
java.lang.String pname)
Find the property's extent, if it applies.
|
static int |
getExtentForParam(java.lang.String pname,
InternalEntry ie,
java.lang.String iename,
boolean func,
int param)
Get the extent of the parameter at 0-based position (for the given internal entry).
|
private static SourceNameMapper.ExternalProgram |
getExternalProgram(java.lang.String pname)
Get the
SourceNameMapper.ExternalProgram of the given Legacy 4GL program name. |
static java.lang.String |
getInternalEntries(java.lang.String pname,
boolean prv)
Get the internal-entries attribute of the given external procedure.
|
static InternalEntry |
getInternalEntry(java.lang.String pname,
java.lang.String iename,
boolean func)
Helper function to obtain the Java object that holds the state of a single internal entry.
|
private static boolean |
getLegacyCaseSensitive()
Worker to get the case-sensitivity from the legacy environment.
|
private static java.lang.String |
getLegacyPathSeparator()
Worker to get the path separator from the legacy environment.
|
static java.lang.String |
getLibraryName(java.lang.String pname,
java.lang.String iename)
Get the library name attribute of the given internal-entry.
|
static java.lang.String |
getMapTo(java.lang.String pname,
java.lang.String ieName)
Get the map-to attribute of the passed internal-entry.
|
static java.lang.String |
getMethodName(java.lang.String pname,
java.lang.String ieName,
boolean function)
Get the java name of the passed internal-entry and 4GL program.
|
static java.util.List<InternalEntry> |
getOverloads(java.lang.Class<?> type,
java.lang.String iename)
Get all the overloaded methods in the given legacy class, with the specified name,
and with name with possible _[0-9]+ suffix.
|
static java.lang.String |
getPackageRoot()
Get the
package root . |
private static Parameter |
getParameter(java.lang.String pname,
java.lang.String iename,
boolean func,
int param)
Private utility method for locating a parameter of a routine.
|
static java.lang.String |
getParameterModes(java.lang.String pname)
Get the string representation of the parameter modes for this external
procedure.
|
static java.lang.String |
getParameterModes(java.lang.String pname,
InternalEntry ie,
java.lang.String ieName,
boolean function)
Get the string representation of the parameter modes for this internal
entry.
|
static java.lang.String |
getParameterModes(java.lang.String pname,
java.lang.String ieName,
boolean function)
Get the string representation of the parameter modes for this internal
entry.
|
static java.util.List<Parameter> |
getParameters(java.lang.String pname,
InternalEntry ie,
java.lang.String ieName,
boolean function)
Get the parameters for this internal entry.
|
static java.lang.String |
getPublishedEvents(java.lang.String pname)
Get the published named events by the specified procedure.
|
static java.lang.String |
getSignature(java.lang.String pname,
java.lang.String ieName)
Get the 4GL-style signature of the given internal-entry.
|
static java.lang.Class |
getTypeForParam(java.lang.String pname,
InternalEntry ie,
java.lang.String iename,
boolean func,
int param)
Get the type/class of the parameter at 0-based position (for the given internal entry).
|
static boolean |
hasLegacyMethod(java.lang.Class<?> type,
java.lang.String pname)
Check if the given legacy class defines a method with a given name.
|
private static void |
initMappingData()
This method loads all mapping data from a URL which is calculated
using the
pkgroot and the name_map.xml with
all "." characters converted to file separators and an extra file
separator added before the file name portion. |
static boolean |
isFunction(java.lang.String pname,
java.lang.String iename)
Check if the specified internal-entry is a function.
|
static boolean |
isInHandle(java.lang.String pname,
InternalEntry ie,
java.lang.String iename,
boolean function)
Check if the specified internal-entry is defined IN handle.
|
static boolean |
isPrivate(java.lang.String pname,
java.lang.String iename,
boolean function)
Check if the specified internal-entry is defined PRIVATE.
|
static boolean |
isSuper(java.lang.String pname,
java.lang.String iename,
boolean function)
Check if the specified internal-entry is defined IN SUPER.
|
private static void |
loadPathAliases()
Load the path aliases from the directory, into the
pathAliases map. |
static java.lang.String |
lookupLegacyName(java.lang.String legacy)
Uses the
convertName(String) worker for detecting the if the legacy is a
name of a converted legacy procedure. |
static java.lang.String |
normalizeLegacyName(java.lang.String legacy)
Normalize the given legacy external program name, considering the
SourceNameMapper.WorkArea.caseSens state. |
static void |
registerLegacyClass(java.lang.Class<?> type)
Register the specified legacy class.
|
static void |
registerServices()
Register all exposed legacy services.
|
private static void |
registerServices(SourceNameMapper.ExternalProgram extProg,
java.lang.String qname)
Given this external program (which may be associated with a legacy OO class), register all
of its exposed services.
|
private static java.lang.String |
removePkg(java.lang.String name)
Remove the package prefix from the given class name.
|
private static java.lang.String |
removeUpPath(java.lang.String relName)
Remove any
.. entries from the given relative path name. |
static java.lang.String[] |
resolvePathAliases(java.util.Map<java.lang.String,java.lang.String> pathAliases,
java.lang.String pname)
Given a program name, replace all folder names which have an associated 'source' folder,
and return the new path.
|
private static java.lang.String[] |
resolvePathAliases(java.lang.String pname)
Given a program name, replace all folder names which have an associated 'source' folder,
and return the new path.
|
private static void |
setSearchPath(java.lang.String searchPath)
Notification that the search path has changed - it updates the
SourceNameMapper.WorkArea.propath
value. |
public static final int NO_EXTENT
public static final int DYNAMIC_EXTENT
static final java.lang.String STATIC_CONSTRUCTOR
static final java.lang.String CONSTRUCTOR
static final java.lang.String DESTRUCTOR
static final java.lang.String CTOR_PREFIX
private static final java.util.logging.Logger LOG
private static final ContextLocal<SourceNameMapper.WorkArea> local
private static final java.util.Set<java.lang.String> NOT_A_CLASS
Class.forName(java.lang.String)
lookups by convertName(java.lang.String)
which do not resolve to a Java class for
the given program name.private static final java.lang.String ELEM_REST_SERVICE
private static final java.lang.String ELEM_CMAP
private static final java.lang.String ELEM_MMAP
private static final java.lang.String ELEM_PARAM
private static final java.lang.String ATTR_PNAME
private static final java.lang.String ATTR_JNAME
private static final java.lang.String ATTR_TYPE
private static final java.lang.String ATTR_LIBNAME
private static final java.lang.String ATTR_MAP_TO
private static final java.lang.String ATTR_PARAM_MODE
private static final java.lang.String PUBLISHED_EVENTS
private static final java.lang.String WITH_SERVICES
private static final java.lang.String OONAME
private static java.util.Map<java.lang.String,java.lang.String> pathAliases
private static java.util.Map<java.lang.String,java.lang.String> pathAliases_ci
private static volatile java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> p2jMap
private static volatile java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> p2jMap_ci
private static volatile java.util.Map<java.lang.String,java.util.List<SourceNameMapper.ExternalProgram>> p2jNonExtMap
private static volatile java.util.Map<java.lang.String,java.util.List<SourceNameMapper.ExternalProgram>> p2jNonExtMap_ci
private static java.util.Map<java.lang.String,SourceNameMapper.ExternalProgram> j2pMap
private static java.util.List<SourceNameMapper.ExternalProgram> servicePrograms
private static volatile java.util.Map<java.lang.Class<?>,SourceNameMapper.LegacyClass> classMap
private static java.lang.String[] legacyRoots
private static java.lang.String pkgroot
private static java.lang.String custpkgroot
private static java.lang.String proroot
private static final java.lang.String fileSep
private static final java.lang.String altFileSep
fileSep
and this.public static void registerServices()
public static java.lang.String[] resolvePathAliases(java.util.Map<java.lang.String,java.lang.String> pathAliases, java.lang.String pname)
pname
- The legacy program name.public static java.lang.String convertJavaProg(java.lang.String jname)
jname
- The external-program's converted java name.null
if the given java
program is not registered in name_map.xml.public static java.lang.String convertJavaProg(java.lang.Class<?> cls)
cls
- The converted FWD class mapping a legacy 4GL class.null
if the given java
program is not registered in name_map.xml.public static java.lang.String convertJavaProgSafe(java.lang.String jname)
jname
- A java class name which may or may not be associated with a legacy 4GL program.public static java.lang.String convertJavaProg(java.lang.String customRoot, java.lang.String jname)
jname
- The external-program's converted java name.customRoot
- Custom root package name.null
if the given java
program is not registered in name_map.xml.public static java.lang.String convertJavaMethod(java.lang.String clsName, java.lang.String methodName, boolean function)
clsName
- The class name where the method is defined.methodName
- The method's name.function
- Flag indicating that this method maps a legacy function (when true)
or
procedure (when false
).null
if not found.public static java.lang.String normalizeLegacyName(java.lang.String legacy)
SourceNameMapper.WorkArea.caseSens
state.legacy
- The legacy name to be normalizedpublic static java.lang.String convertNameToClass(java.lang.String legacy)
convertName(String)
worker for finding the name of the Java class name of
a converted P4GL procedure name.legacy
- Progress file name.null
is returned.public static java.lang.String convertOOToClass(java.lang.String legacyClsName)
legacyClsName
- The qualified legacy class name.null
is returned.public static java.lang.String lookupLegacyName(java.lang.String legacy)
convertName(String)
worker for detecting the if the legacy
is a
name of a converted legacy procedure. In affirmative case, the normalized name of the
procedure filename is returned.legacy
- Progress file name.null
is
returned.public static java.lang.String getPackageRoot()
package root
.public static java.lang.String getMethodName(java.lang.String pname, java.lang.String ieName, boolean function)
pname
- Legacy 4GL program name.ieName
- Legacy internal-entry name.function
- true
if the search is for a user-defined
function.null
public static java.lang.String getMapTo(java.lang.String pname, java.lang.String ieName)
pname
- Legacy 4GL program name.ieName
- Legacy internal-entry name.null
if the ATTR_MAP_TO
does not exist or the internal
entry does not resolve to a function.public static java.lang.String getLibraryName(java.lang.String pname, java.lang.String iename)
pname
- Legacy 4GL program name.iename
- Legacy internal-entry name.null
.public static java.lang.String getParameterModes(java.lang.String pname)
pname
- Legacy 4GL program name.public static java.lang.String getParameterModes(java.lang.String pname, java.lang.String ieName, boolean function)
pname
- Legacy 4GL program name.ieName
- Legacy internal-entry name. If null or the empty string, the
external procedure's parameters are used.function
- true
if this is a function call.public static java.lang.String getParameterModes(java.lang.String pname, InternalEntry ie, java.lang.String ieName, boolean function)
pname
- Legacy 4GL program name.ie
- If non-null, the already resolved internal entry.ieName
- Legacy internal-entry name. If null or the empty string, the
external procedure's parameters are used.function
- true
if this is a function call.public static java.util.List<Parameter> getParameters(java.lang.String pname, InternalEntry ie, java.lang.String ieName, boolean function)
pname
- Legacy 4GL program name.ie
- If non-null, the already resolved internal entry.ieName
- Legacy internal-entry name. If null or the empty string, the
external procedure's parameters are used.function
- true
if this is a function call.public static java.lang.String getSignature(java.lang.String pname, java.lang.String ieName)
null
.pname
- Legacy 4GL program name.ieName
- Legacy internal-entry name.public static java.lang.String getInternalEntries(java.lang.String pname, boolean prv)
null
.pname
- Legacy 4GL program name.prv
- Flag to include or not the private members.public static java.lang.String getPublishedEvents(java.lang.String pname)
pname
- Legacy 4GL program name.public static int getExtentForParam(java.lang.String pname, InternalEntry ie, java.lang.String iename, boolean func, int param)
pname
- Legacy 4GL program name.ie
- If non-null, the already resolved internal entry.iename
- Legacy internal-entry name.func
- Flag indicating if this is a function or a procedure.param
- 0-based index of the parameter to be checked.public static java.lang.Class getTypeForParam(java.lang.String pname, InternalEntry ie, java.lang.String iename, boolean func, int param)
pname
- Legacy 4GL program name.ie
- If non-null, the already resolved internal entry.iename
- Legacy internal-entry name.func
- Flag indicating if this is a function or a procedure.param
- 0-based index of the parameter to be checked.null
if parameters do not point
to a valid parameter.public static boolean isSuper(java.lang.String pname, java.lang.String iename, boolean function)
false
.pname
- Legacy 4GL program name.iename
- Legacy internal-entry name.function
- Flag indicating if this is a function or a procedure.public static boolean isFunction(java.lang.String pname, java.lang.String iename)
false
.pname
- Legacy 4GL program name.iename
- Legacy internal-entry name.public static boolean isPrivate(java.lang.String pname, java.lang.String iename, boolean function)
false
.pname
- Legacy 4GL program name.iename
- Legacy internal-entry name.function
- Flag indicating if this is a function or a procedure.public static boolean isInHandle(java.lang.String pname, InternalEntry ie, java.lang.String iename, boolean function)
false
.pname
- Legacy 4GL program name.iename
- ie
- If non-null, the already resolved internal entry.
Legacy internal-entry name.function
- Flag indicating if this is a function or a procedure.public static InternalEntry getInternalEntry(java.lang.String pname, java.lang.String iename, boolean func)
pname
- Legacy 4GL program name (the external procedure).iename
- Legacy internal-entry name.func
- true
if the search should be for a function.null
if the external procedure does not exist
or if the external procedure has no such internal entry.public static java.util.List<InternalEntry> getOverloads(java.lang.Class<?> type, java.lang.String iename)
type
- The legacy _BaseObject_
sub-class.iename
- The legacy name.public static void registerLegacyClass(java.lang.Class<?> type)
This is used to register legacy builtin 4GL classes - these always need to be marked with
the LegacyResource
annotation.
type
- The class representing a builtin 4GL type.public static java.lang.Integer findLegacyPropertyExtent(java.lang.Class<?> type, java.lang.String pname)
type
- The legacy OO class.pname
- The legacy OO property name.null
if it does not apply.public static InternalEntry findLegacyAccessor(java.lang.Class<?> type, java.lang.String pname, boolean getter, boolean indexed)
type
- The class matching the legacy OO type.pname
- The legacy property name.getter
- Flag indicating to retrieve a getter or setter.indexed
- Flag indicating to retrieve the indexed getter or setter.InternalEntry
or null
if not found.public static boolean hasLegacyMethod(java.lang.Class<?> type, java.lang.String pname)
pname
- The legacy method name.true
if there is a method defined with the given name.public static java.lang.String findLegacyEntryName(java.lang.Class<?> type, java.lang.String mname)
type
- The converted class name.mname
- The Java method name.public static InternalEntry findLegacyMethod(java.lang.Class<?> type, java.lang.String pname, InternalEntry signature)
type
- The class matching the legacy OO type.pname
- The legacy method name.signature
- The legacy signature to match.private static java.lang.String[] convertName(java.lang.String legacyProgName)
canonicalize(java.lang.String)
.
A simple lookup is tried first, taking into account if there is a .r, .p, or .w extension
which may have been left off the 4GL statement. If this fails direct check for absolute path
if attempted using one of the roots from legacyRoots
. In multiple project scenario,
the project name is also added as a path token in order to match the structure from
name_map.xml
.
If this mapping does not exist then each path segment of the PROPATH is tried in order. The given program name is check to see if it is prefixed with the PROPATH segment, if so that prefix is removed and a lookup is done with this name. The first match found ends the search.
Absolute paths are converted into relative paths based on the existence of a matching path
in the legacy PROPATH (see EnvironmentOps.getLegacySearchPath()
). To handle additional
absolute paths, one must add the appropriate path prefix to the legacy PROPATH and it will
be removed here.
This same PROPATH processing is how names relative to the current directory can be handled. This is the only way to handle that case since the current directory in the source system is runtime information that is not available here.
The legacy PROPATH is the key configuration tool by which one specifies to this method how to remove absolute and current directory relative prefixes. This means that the legacy PROPATH that is used here may need to be different than the PROPATH on the original system.
As a fallback, if no mapping can be found and if the given progName
is a fully
qualified Java class name which references a valid Java class, then the progName
is
returned unchanged.
In Windows it can verify the absolute or relative program name is in current PROPATH directory set. This allows to properly map the following program names used in PROGRESS RUN statement: "c:/path/to/project/stcases/uast/rundir/absolute/program.p" "rundir/../../uast/rundir/relative/test11.p." "../uast/rundir/relative/test5.p"
If no program name is explicitly found with a .r
extension, R-code program
names are looked up using the p2jNonExtMap
(the program name without the extension).
If pathAliases
is specified, and the program can be found (as it is or after
removing the .r
extension) in the propath, the lookup falls back to resolving
the aliased folders in the program name, via resolvePathAliases(java.util.Map<java.lang.String, java.lang.String>, java.lang.String)
.
legacyProgName
- Progress file name.String
array with three components:
null
is returned.private static java.lang.String[] convertName(java.lang.String legacyProgName, java.util.function.Function<java.lang.String,SourceNameMapper.ExternalProgram> lookup)
canonicalize(java.lang.String)
.
A simple lookup is tried first. If this fails direct check for absolute path if attempted
using one of the roots from legacyRoots
. In multiple project scenario, the project
name is also added as a path token in order to match the structure from
name_map.xml
.
If this mapping does not exist then each path segment of the PROPATH is tried in order. The given program name is check to see if it is prefixed with the PROPATH segment, if so that prefix is removed and a lookup is done with this name. The first match found ends the search.
Absolute paths are converted into relative paths based on the existence of a matching path
in the legacy PROPATH (see EnvironmentOps.getLegacySearchPath()
). To handle additional
absolute paths, one must add the appropriate path prefix to the legacy PROPATH and it will
be removed here.
This same PROPATH processing is how names relative to the current directory can be handled. This is the only way to handle that case since the current directory in the source system is runtime information that is not available here.
The legacy PROPATH is the key configuration tool by which one specifies to this method how to remove absolute and current directory relative prefixes. This means that the legacy PROPATH that is used here may need to be different than the PROPATH on the original system.
As a fallback, if no mapping can be found and if the given progName
is a fully
qualified Java class name which references a valid Java class, then the progName
is
returned unchanged.
In Windows it can verify the absolute or relative program name is in current PROPATH directory set. This allows to properly map the following program names used in PROGRESS RUN statement: "c:/path/to/project/stcases/uast/rundir/absolute/program.p" "rundir/../../uast/rundir/relative/test11.p." "../uast/rundir/relative/test5.p"
legacyProgName
- Progress file name.lookup
- The lookup function used to resolve a program name to a SourceNameMapper.ExternalProgram
.String
array with three components:
null
is returned.private static SourceNameMapper.ExternalProgram getExternalProgram(java.lang.String pname)
SourceNameMapper.ExternalProgram
of the given Legacy 4GL program name.pname
- Legacy 4GL program name.SourceNameMapper.ExternalProgram
or null
if not a valid pname.private static void setSearchPath(java.lang.String searchPath)
SourceNameMapper.WorkArea.propath
value.searchPath
- The new PROPATH value.private static java.lang.String removeUpPath(java.lang.String relName)
..
entries from the given relative path name.relName
- Relative file path.private static Parameter getParameter(java.lang.String pname, java.lang.String iename, boolean func, int param)
pname
- Legacy 4GL program name.iename
- Legacy internal-entry name.func
- Flag indicating if this is a function or a procedure.param
- 0-based index of the parameter to be checked.null
if parameters do not point to a valid
parameter.private static java.lang.String[] resolvePathAliases(java.lang.String pname)
pname
- The legacy program name.private static void loadPathAliases()
pathAliases
map. This map
contains as key the 'aliased' name which is an alias for a 'source' folder.
The directory contains these mappings in the /server/default/path-aliases
or
/server/<server-id>/path-aliases
node. The child nodes have as class
path-alias
and this structure:
<node class="path-alias" name="alias1">
<node-attribute name="source" value="src1"/>
<node-attribute name="alias" value="obj1"/>
</node>
The alias1
name is just an unique ID for each child.
private static void registerServices(SourceNameMapper.ExternalProgram extProg, java.lang.String qname)
extProg
- The external program specification.qname
- Fully qualified, converted, Java class name.private static void initMappingData()
pkgroot
and the name_map.xml
with
all "." characters converted to file separators and an extra file
separator added before the file name portion. This URL is expected to
be found in the application's JAR file. Note that this will silently
return if the mapping data is not found. Any file system configuration
data will be read from the directory via the EnvironmentOps
helper.private static SourceNameMapper.ExternalProgram buildExternalProgram(java.lang.String pname, java.lang.String jname, org.w3c.dom.Element classMap)
SourceNameMapper.ExternalProgram
info contained in the classMap
node.pname
- The legacy 4GL program name.jname
- The converted class name.classMap
- The DOM node containing the info for this external program.SourceNameMapper.ExternalProgram
instance for this DOM node.private static InternalEntry buildMethod(java.lang.String pname, java.lang.String jname, org.w3c.dom.Element methMap)
InternalEntry
info contained in the methMap
node.pname
- The legacy 4GL internal-entry name.jname
- The converted internal-entry name.methMap
- The DOM node containing the info for this internal-entry.InternalEntry
instance for this DOM node.private static void buildParameters(org.w3c.dom.Element node, InternalEntry ie)
node
- The current node from where the parameters are read.ie
- The internal entry where to save the parameters.private static java.lang.String buildInternalEntries(SourceNameMapper.ExternalProgram extProg, boolean prv)
extProg
- The SourceNameMapper.ExternalProgram
instance.prv
- Flag to include or not the private members.static void buildLegacyProgram(SourceNameMapper.ExternalProgram extprog)
Method
, for the given external program.
Only methods marked with LegacySignature
are included.
static void buildLegacyClass(java.lang.Class<?> cls)
LegacySignature
annotation) and register them.
The InternalEntry
will be linked with the defining Java method.
cls
- The Java class associated with the legacy 4GL type.static InternalEntry buildInternalEntry(LegacySignature ls, java.lang.String jname)
InternalEntry
matching the specified legacy signature.ls
- The signature.jname
- The converted Java name.private static Parameter buildParameter(LegacyParameter lp)
Parameter
instance from the specified LegacyParameter
annotation.lp
- The parameter signature.private static java.lang.String canonicalize(java.lang.String progName)
.
and ..
are
processed. Empty path elements are removed.
If SourceNameMapper.WorkArea.caseSens
is false, the program name is lower-cased.
progName
- Input name.private static java.lang.String addPkg(java.lang.String name)
name
- Class name.private static java.lang.String removePkg(java.lang.String name)
name
- Class name.private static java.lang.String getLegacyPathSeparator()
SourceNameMapper.WorkArea.pathSep
private static boolean getLegacyCaseSensitive()
SourceNameMapper.WorkArea.caseSens