Project

General

Profile

Bug #10476

Webspeed request for .r file fails

Added by Radu Apetrii 11 months ago. Updated 11 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
Due date:
% Done:

0%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
reviewer:
production:
No
env_name:
topics:

History

#1 Updated by Radu Apetrii 11 months ago

Executing a file coming from a webspeed request involves a couple of additional steps rather than the classic method of running a file. If one would do run test.r, that would work in FWD as long as we have the test.p or test.w involved in the conversion. When searching for the file in FWD, if the .r version cannot be found, the search happens for .p or .w, and that is perfectly fine.

For a webspeed request (e.g. https://localhost:7443/WService=WSBroker1/test.r), however, there is an additional search involved. Because we go through the webspeed files (web-disp, web-util and so on), there is additional logic to be computed. More precisely, in Relname.java (the one from webspeed/adecomm) there is this piece of code:

         loopLabel0:
         for (i.assign(1); _isLessThanOrEqual(i, cnt); i.increment())
         {
            dir.assign(entry(i, EnvironmentOps.getSearchPath()));

            /* Get the full pathname of the directory without any fancy characters. */
            if (_isEqual(dir, ""))
            {
               dir.assign(".");
            }

            FileSystemOps.initFileInfo(dir);
            dir.assign(concat(replaceAll(FileSystemOps.fileInfoGetFullPath(), "\\", "/"), "/"));

            /* Strip the PROPATH dir out of the filename. */
            if (_begins(filename, dir))
            {
               cLongestProPath.assign(_isGreaterThan(numEntries(dir, "/"), numEntries(cLongestProPath, "/")) ? dir : cLongestProPath);
            }
         }

which searches for the path of the test.r file. Because there is no such file, the search will return ?, which will result in an error later on.

The call chain to reach this point is: WebDisp WEB-NOTIFY trigger -> WebUtil.runWebObject() -> Relname.execute() (the one from webspeed/webutil) -> Relname.execute() (the one from webspeed/adecomm). I also want to point out that the initial search (the one where it also searches for .p or .w) works fine. It is reaching this code the thing that puts a dent in the execution.

#3 Updated by Constantin Asofiei 11 months ago

What is relname 4GL code doing that it needs to look for the .r file on disk, and not rely just on SEARCH function to locate the .r file in the PROPATH?

#4 Updated by Radu Apetrii 11 months ago

In relname, it first does FILE-INFO:FILE-NAME = filename, where filename is test.r. This triggers the initial search, the one that finds the .w version. This line works fine, nothing to comment about.

Then, it does this (which is the 4GL code corresponding to the java code in the first note):

/* At this point, filename will equal the FULL-PATHNAME of the file (if it
   exists, or the original name, if it does not.  
   Go through the directories in PROPATH looking for one that matches.  */

cnt = NUM-ENTRIES(PROPATH).
DO i = 1 TO cnt:
  dir = ENTRY (i, PROPATH).
  /* Get the full pathname of the directory without any fancy characters. */
  IF dir = "" THEN dir = ".". 
  ASSIGN FILE-INFO:FILE-NAME = dir
         dir = REPLACE (FILE-INFO:FULL-PATHNAME, "~\":U, "~/":U) + "~/":U
         .

  /* Strip the PROPATH dir out of the filename. */
  IF filename BEGINS dir THEN
  ASSIGN cLongestProPath 
  = 
  IF NUM-ENTRIES(dir, '/') > NUM-ENTRIES(cLongestProPath, '/') 
  THEN dir 
  ELSE cLongestProPath.
END.

After the first search, filename will not be equal to the FULL-PATHNAME, so it goes through the set propaths trying to find the full path of the file.

#5 Updated by Constantin Asofiei 11 months ago

I'm thinking to just remove this code in FWD's .java converted file. What is cLongestProPath used for, after this loop finds it in 4GL?

#6 Updated by Radu Apetrii 11 months ago

After that loop, the code does this

IF cLongestProPath <> "" THEN
  DO:
  p_relname = SUBSTRING (filename, LENGTH(cLongestProPath, "CHARACTER":U) + 1, -1, "CHARACTER":U).
  RETURN.
  END.

Then, it goes back to web-util, where it does this

/* If the rcode or the file was not in the propath then error */
  IF cSearchFile = ? THEN DO:
      /* If we found rcode but the file was not in the propath then reject it */
    DYNAMIC-FUNCTION ("logNote":U IN web-utilities-hdl, "WARNING":U,
      SUBSTITUTE ("&1 was requested by &2 but was not in the propath and was rejected. (Ref: &3)", 
                  pcFilename, REMOTE_ADDR, HTTP_REFERER)) NO-ERROR.
    DYNAMIC-FUNCTION ("ShowErrorScreen":U IN web-utilities-hdl, 
                            "Unable to run web object file") NO-ERROR.  
    RETURN.
  END. /* Not found in the propath */

  /* If this is configured then perform the check, if its left blank, then 
     allow anything.  Check and see if there is a more restricted path for 
     running objects. */
  ASSIGN
    cSearchFile = SEARCH(cSearchFile).

For reference, cSearchFile here in web-util is the returned value from relname (p_relname variable). In my case, because cSearchFile is ?, the program throws the error and then returns.

#7 Updated by Constantin Asofiei 11 months ago

OK, comment out the code in FWD .java file to just use p_relname to be what SEARCH returns from PROPATH and see what happens.

#8 Updated by Radu Apetrii 11 months ago

It worked! It is now able to execute the file fine.

Also available in: Atom PDF