=== modified file 'rules/convert/language_statements.rules'
--- rules/convert/language_statements.rules	2019-09-03 17:36:26 +0000
+++ rules/convert/language_statements.rules	2019-11-04 17:49:50 +0000
@@ -76,6 +76,8 @@
 ** 047 CA  20190611          Legacy ANNOTATION nodes which are not hidden must be emitted as Java
 **                           annotations.
 ** 048 CA  20190903          Added GLOBAL support for SUBSCRIBE/UNSUBSCRIBE (cross-session messaging).
+** 049 SBI 20191004          Added DELETE-SOURCE-CONTENT and NOT-EMBEDDED-CONTENT optional flags
+**                           for OPEN-MIME-RESOURCE.
 */
  -->
  
@@ -862,6 +864,16 @@
          </action>
       </rule>
       
+      <rule>type == prog.kw_not_embedded and 
+            parent.type == prog.kw_openmime
+         <action>createJavaAst(java.bool_false, "false", closestPeerId)</action>
+      </rule>
+      
+      <rule>type == prog.kw_del_s_c and 
+            parent.type == prog.kw_openmime
+         <action>createJavaAst(java.bool_true, "true", closestPeerId, 0)</action>
+      </rule>
+      
       <rule>type == prog.create_timer and parent.type == prog.statement
          <action>
             createPeerAst(java.static_method_call, "PSTimer.create", closestPeerId)

=== modified file 'src/com/goldencode/p2j/uast/progress.g'
--- src/com/goldencode/p2j/uast/progress.g	2019-09-12 14:35:21 +0000
+++ src/com/goldencode/p2j/uast/progress.g	2019-11-04 17:50:35 +0000
@@ -1985,6 +1985,8 @@
 **     HC  20190819          Added missing definitions for TABSET:COLOR attribute.
 **     CA  20190903          Added GLOBAL support for SUBSCRIBE/UNSUBSCRIBE (cross-session messaging).
 ** 377 HC  20190911          Added new method and attributes to HTML-BROWSER widget.
+** 378 SBI 20191004          Added DELETE-SOURCE-CONTENT and NOT-EMBEDDED-CONTENT optional flags
+**                           for OPEN-MIME-RESOURCE.
 */
 
 /*
@@ -3586,6 +3588,7 @@
       KW_DEL_NODE;
       KW_DEL_PROC;
       KW_DEL_R_L;
+      KW_DEL_S_C; // FWD extension
       KW_DEL_S_R;
       KW_DEL_S_RS;
       KW_DEL_WORD;
@@ -3639,6 +3642,7 @@
       KW_EDIT_TAB;
       KW_EH_FL;    // FWD extension, not real 4GL!
       KW_EH_SR;    // FWD extension, not real 4GL!
+      KW_NOT_EMBEDDED;  // FWD extension
       KW_EMPTY;
       KW_EMPTY_DS;
       KW_EMPTY_SN;
@@ -7962,6 +7966,7 @@
       attrsAndMethods.put( KW_DEL_LINE, METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_NODE, METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_R_L , METH_LOGICAL );
+      attrsAndMethods.put( KW_DEL_S_C , ATTR_LOGICAL ); // FWD extension
       attrsAndMethods.put( KW_DEL_S_R , METH_LOGICAL );
       attrsAndMethods.put( KW_DEL_S_RS, METH_LOGICAL );
       attrsAndMethods.put( KW_DELETE  , METH_LOGICAL );
@@ -8002,6 +8007,7 @@
       attrsAndMethods.put( KW_EDIT_UND, METH_LOGICAL );
       attrsAndMethods.put( KW_EH_FL,    ATTR_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EH_SR,    ATTR_LOGICAL ); // FWD extension, not real 4GL
+      attrsAndMethods.put( KW_NOT_EMBEDDED, ATTR_LOGICAL ); // FWD extension
       attrsAndMethods.put( KW_EMB_FILE, METH_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EMB_URL,  METH_LOGICAL ); // FWD extension, not real 4GL
       attrsAndMethods.put( KW_EMPTY   , ATTR_LOGICAL );
@@ -27473,11 +27479,23 @@
    
 /**
  * Matches the FWD-extension language statement <code>OPEN-MIME-RESOURCE</code> and a mandatory
- * pair of resource mime type character and its url character expression.
+ * pair of resource mime type character and its url character expression. If an optional
+ * <code>DELETE-SOURCE-CONTENT</code> is present, then it forces to delete the original input file
+ * when the transfer is complete.
  */
 open_mime_resource_stmt
    :
-      KW_OPENMIME^ expr expr (expr)? stmt_term
+      KW_OPENMIME^ expr expr
+      ( options { generateAmbigWarnings = false; } 
+         :
+         KW_NOT_EMBEDDED
+      )?
+      ( 
+         options { generateAmbigWarnings = false; }
+         :
+         KW_DEL_S_C
+      )
+      stmt_term
    ;
    
 /**
@@ -32715,6 +32733,7 @@
          new Keyword("delete-result-list-entry"       ,  0, KW_DEL_R_L , false),
          new Keyword("delete-selected-row"            ,  0, KW_DEL_S_R , false),
          new Keyword("delete-selected-rows"           ,  0, KW_DEL_S_RS, false),
+         new Keyword("delete-source-content"          ,  0, KW_DEL_S_C , false),  // FWD extension
          new Keyword("delete-word"                    ,  0, KW_DEL_WORD, false),  // missing in keyword index, found in prog handbook as a key function
          new Keyword("descending"                     ,  4, KW_DESCEND , true ),  // handles "separate keyword" desc too
          new Keyword("description"                    ,  0, KW_DESCR   , false),  // missing in keyword index, found in customer code
@@ -32787,6 +32806,7 @@
          new Keyword("else"                           ,  0, KW_ELSE    , true ),
          new Keyword("embed-image-by-file"            ,  0, KW_EMB_FILE, false),  // FWD extension, not a real 4GL keyword
          new Keyword("embed-image-by-url"             ,  0, KW_EMB_URL , false),  // FWD extension, not a real 4GL keyword
+         new Keyword("not-embedded-content"           ,  0, KW_NOT_EMBEDDED, false),  // FWD extension
          new Keyword("empty"                          ,  0, KW_EMPTY   , false),
          new Keyword("empty-dataset"                  ,  0, KW_EMPTY_DS, false),  // missing from keyword index and UNTESTED at this time
          new Keyword("empty-selection"                ,  0, KW_EMPTY_SN, false),  // missing in keyword index, found elsewhere in lang ref

=== modified file 'src/com/goldencode/p2j/ui/ClientExports.java'
--- src/com/goldencode/p2j/ui/ClientExports.java	2019-10-03 01:18:23 +0000
+++ src/com/goldencode/p2j/ui/ClientExports.java	2019-11-04 17:58:48 +0000
@@ -246,6 +246,7 @@
 **                           Triggering events directly from server must lookup the trigger on
 **                           the client.
 ** 154 SVL 20191002          Added rowEntryCreated/Deleted and checkDeleteEntryRowIndex.
+** 155 SBI 20191004          Added deleteContent parameter for openMimeResource.
 */
 
 /*
@@ -3122,6 +3123,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    path
@@ -3129,11 +3133,17 @@
     * @param    embedded
     *           The document is embedded in the template document.
     */
-   public void openMimeResource(String mimeType, String path, boolean embedded);
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  path,
+                                boolean embedded);
 
    /**
     * Opens the specified file resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    filePath
     *           The file system path on the legacy system or the host system. If the legacy system
     *           path is given, then it is resolved to the host system path.
@@ -3142,7 +3152,10 @@
     * @param    preferredMimeTypes
     *           The preferred resource mime types.
     */
-   public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes);
+   public void openMimeResource(boolean      deleteContent,
+                                String       filePath,
+                                boolean      embedded,
+                                List<String> preferredMimeTypes);
 
    /**
     * Set an attribute for a widget implemented at the driver level.  These are custom attributes

=== modified file 'src/com/goldencode/p2j/ui/chui/ThinClient.java'
--- src/com/goldencode/p2j/ui/chui/ThinClient.java	2019-10-03 01:18:23 +0000
+++ src/com/goldencode/p2j/ui/chui/ThinClient.java	2019-11-04 17:52:25 +0000
@@ -2536,6 +2536,7 @@
 **                           Triggering events directly from server must lookup the trigger on
 **                           the client.
 ** 910 SVL 20191002          Added rowEntryCreated/Deleted and checkDeleteEntryRowIndex.
+** 911 SBI 20191104          Added deleteContent parameter for openMimeResource.
 */
 
 /*
@@ -23021,6 +23022,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -23029,12 +23033,15 @@
     *           The document is embedded in the template document.
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    {
       urlString = UiUtils.resolveResourceUrl(urlString);
       try
       {
-         tk.getInstanceDriver().openMimeResource(mimeType, urlString, embedded);
+         tk.getInstanceDriver().openMimeResource(deleteContent, mimeType, urlString, embedded);
       }
       catch (MalformedURLException e)
       {
@@ -23045,6 +23052,9 @@
    /**
     * Opens the specified file resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    filePath
     *           The file system path on the legacy system or the host system. If the legacy system
     *           path is given, then it is resolved to the host system path.
@@ -23053,7 +23063,10 @@
     * @param    preferredMimeTypes
     *           The preferred resource mime types.
     */
-   public void openMimeResource(String filePath, boolean embedded, List<String> preferredMimeTypes)
+   public void openMimeResource(boolean      deleteContent,
+                                String       filePath,
+                                boolean      embedded,
+                                List<String> preferredMimeTypes)
    {
       // getting FSD instance
       FileSystemDaemon fsd = getFileSystemDaemon();
@@ -23070,13 +23083,13 @@
             
             if (mimeType != null && preferredMimeTypes.contains(mimeType))
             {
-               openMimeResource(mimeType, "file:///" + fName, embedded);
+               openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
             }
             else
             {
                mimeType = preferredMimeTypes.get(0); // takes the default mime type
                
-               openMimeResource(mimeType, "file:///" + fName, embedded);
+               openMimeResource(deleteContent, mimeType, "file:///" + fName, embedded);
             }
          }
       }

=== modified file 'src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java'
--- src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java	2019-09-25 06:28:38 +0000
+++ src/com/goldencode/p2j/ui/client/driver/ScreenDriver.java	2019-11-04 09:50:33 +0000
@@ -405,6 +405,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -415,7 +418,10 @@
     * @throws   MalformedURLException
     *           If the string presentation of the target resource url is malformed. 
     */
-   public default void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public default void openMimeResource(boolean deleteContent,
+                                        String  mimeType,
+                                        String  urlString,
+                                        boolean embedded)
    throws MalformedURLException
    {
    // do nothing

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/AbstractGuiDriver.java	2019-11-04 18:01:52 +0000
@@ -107,6 +107,8 @@
 **     HC  20190313 Initial implementation of TREELIST widget. TREEVIEW widget refactored to make
 **                  it the base for the TREELIST widget.
 ** 051 HC  20190911 Implemented command invocation on driver widgets.
+** 052 SBI 20191004 Added common methods for initializing a temporary directory and coping, moving
+**                  resources. 
 */
 
 /*
@@ -166,6 +168,7 @@
 
 // this usage of AWT events is intentional, they are being used separately from the
 // AWT/Swing event model itself; no other AWT/Swing usage is occurring in this class
+
 import java.awt.event.MouseEvent;
 
 // WARNING: these AWT/ImageIO dependencies are being intentionally used in this generic GUI code
@@ -177,6 +180,8 @@
 import javax.imageio.stream.*;
 
 import java.io.*;
+import java.net.*;
+import java.nio.file.*;
 import java.text.*;
 import java.util.*;
 import java.util.concurrent.*;
@@ -195,6 +200,7 @@
 import com.goldencode.p2j.ui.client.driver.*;
 import com.goldencode.p2j.ui.client.widget.*;
 import com.goldencode.p2j.util.*;
+import com.google.common.io.ByteStreams;
 
 /**
  * Simple base class for GUI-specific screen driver implementation features. ChUI-specific
@@ -211,9 +217,15 @@
 extends AbstractDriver<GuiPrimitives, GuiOutputManager>
 implements GuiDriver<F, BufferedImage>
 {
+   /** Define the file schema to get local resources */
+   private static final String FILE_SCHEMA = "file";
+   
    /** Logger. */
    protected static final Logger LOG = LogHelper.getLogger(AbstractGuiDriver.class.getName());
    
+   /** Temporary files directory. */
+   protected String tmpDir;
+   
    /** Currently selected window emulator. */
    protected EmulatedWindowState ews = null;
    
@@ -297,6 +309,52 @@
    }
    
    /**
+    * Initializes client specific internal variables used with drag-n-drop.
+    * 
+    * @param    srv
+    *           Server to make config related calls.
+    */
+   public void initDragAndDrop(ServerExports srv)
+   {
+      // this is used in client only and only once
+      if (tmpDir != null)
+      {
+         return;
+      }
+
+      // setting up temporary files upload directory
+      try
+      {
+         Path tmpFile = Files.createTempFile("tmp-file", ".tmp");
+         String absolutePath = tmpFile.toAbsolutePath().toString();
+         tmpDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator) + 1);
+         Files.delete(tmpFile);
+      }
+      catch (IOException e)
+      {
+         // for the case the regular way above does not work
+         tmpDir = System.getProperty("user.home");
+      }
+      // create separate directory for fwd files
+      tmpDir = tmpDir.concat("fwd");
+      File tmpDirObj = new File(tmpDir);
+      if (!tmpDirObj.exists())
+      {
+         tmpDirObj.mkdir();
+      }
+      // adding file separator to the end
+      tmpDir = tmpDir.concat(File.separator);
+      
+      // getting the file size limit values considering overrides in server's directory
+      int [] uploadLimits = srv.getUploadFileSizeLimits();
+      // set up gui driver
+      if (uploadLimits[0] > 0 && uploadLimits[1] > uploadLimits[0])
+      {
+         setUploadFileSizeLimits(uploadLimits[0], uploadLimits[1]);
+      }
+   }
+   
+   /**
     * Notify the driver which side has control (client-side (when <code>true</code>) or server,
     * otherwise).
     * 
@@ -3837,6 +3895,97 @@
    }
    
    /**
+    * Makes a copy of the given resource and saves its content in a temporary file.
+    *  
+    * @param    url
+    *           The resource url.
+    * @param    deleteOnExit
+    *           Requests to delete this temporary file if JVM terminates normally.
+    * 
+    * @return   The temporary file that contains a copy of the given resource.
+    * 
+    * @throws   IOException
+    *           If an exception is thrown during this 3-stages process of creating new file,
+    *           opening the given url and coping the target resource.
+    */
+   protected File copyResource(URL url, boolean deleteOnExit)
+   throws IOException
+   {
+      File resourceFile = File.createTempFile("copiedResource", null, new File(tmpDir));
+      
+      try(InputStream input = url.openStream();
+          FileOutputStream output = new FileOutputStream(resourceFile))
+      {
+         ByteStreams.copy(input, output);
+      }
+      
+      if (deleteOnExit)
+      {
+         resourceFile.deleteOnExit();
+      }
+      
+      return resourceFile;
+   }
+   
+   /**
+    * Moves the given resource into a temporary file.
+    *  
+    * @param    url
+    *           The resource url.
+    * @param    deleteOnExit
+    *           Requests to delete this temporary file if JVM terminates normally.
+    * 
+    * @return   The temporary file that contains the given resource.
+    * 
+    * @throws   IOException
+    *           If an exception is thrown when moving into a temporary file.
+    * @throws   URISyntaxException
+    *           If the given url can't be converted into URI.
+    */
+   protected File moveResource(URL url, boolean deleteOnExit)
+   throws IOException,
+          URISyntaxException
+   {
+      StringBuilder fileName = new StringBuilder(UUID.randomUUID().toString());
+      
+      Path target = Paths.get(tmpDir, fileName.append(System.currentTimeMillis()).toString());
+      
+      Path source = Paths.get(url.toURI());
+      
+      Files.move(source, target, StandardCopyOption.REPLACE_EXISTING);
+      
+      File file = target.toFile();
+      
+      if (deleteOnExit)
+      {
+         file.deleteOnExit();
+      }
+      
+      return file;
+   }
+   
+   /**
+    * Tests if the given url represents the local file resource.
+    * 
+    * @param    url
+    *           The given resource
+    * 
+    * @return   True if the given url represents the local file resource, otherwise false.
+    */
+   protected boolean isLocalResource(URL url)
+   {
+      if (FILE_SCHEMA.equalsIgnoreCase(url.getProtocol()))
+      {
+         if (url.getHost() == null || url.getHost().isEmpty())
+         {
+            return true;
+         }
+      }
+      
+      return false;
+   }
+   
+   /**
     * Register the tooltip worker if this process was dalayed with regular registration.  Internal
     * version.
     * 

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java	2019-11-04 17:46:25 +0000
@@ -97,6 +97,7 @@
 ** 060 OM  20181001 Tracked document output using an UUID.
 ** 061 HC  20181212 Implemented support for asynchronous key state read emulation.
 ** 062 CA  20190309 Added infrastructure for driver implemented widgets.
+** 063 SBI 20191104 Implemented DELETE-SOURCE-CONTENT of OPEN-MIME-RESOURCE.
 */
 
 /*
@@ -723,7 +724,10 @@
             consumer.accept(os);
          }
          
-         openMimeResource(format.getMimeType(), outFile.toURI().normalize().toASCIIString(), true);
+         openMimeResource(false,
+                          format.getMimeType(),
+                          outFile.toURI().normalize().toASCIIString(),
+                          true);
       }
       catch (IOException e)
       {
@@ -741,6 +745,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -752,28 +759,69 @@
     *           If the string presentation of the target resource url is malformed. 
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    throws MalformedURLException
    {
       // test that urlString is well-formed. 
       URL url = new URL(urlString);
       
-      URI uri;
+      URI sourceURI;
       
       try
       {
-         uri = url.toURI();
+         sourceURI = url.toURI();
       }
       catch (URISyntaxException ex)
       {
          throw new MalformedURLException(ex.getMessage());
       }
       
+      boolean local = isLocalResource(url);
+      
+      URI uri;
+      
+      if (local)
+      {
+         File fileResource;
+         
+         try
+         {
+            if (deleteContent)
+            {
+               try
+               {
+                  fileResource = moveResource(url, true);
+               }
+               catch (URISyntaxException ex)
+               {
+                  throw new MalformedURLException(ex.getMessage());
+               }
+            }
+            else
+            {
+               fileResource = copyResource(url, true);
+            }
+         }
+         catch (IOException ex)
+         {
+            throw new RuntimeException(ex);
+         }
+         
+         uri = fileResource.toURI();
+      }
+      else
+      {
+         uri = sourceURI;
+      }
+      
       if (embedded)
       {
          try
          {
-            uri = buildOpenResourcePage(mimeType, urlString);
+            uri = buildOpenResourcePage(mimeType, uri.normalize().toASCIIString());
          }
          catch (IOException ex)
          {

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/GuiWebDriver.java	2019-11-04 17:47:08 +0000
@@ -139,6 +139,7 @@
 **                  hierarchy.
 ** 060 SBI 20190925 Added the web client storage setup.
 ** 061 HC  20190911 Implemented ad-hoc handler registration.
+** 062 SBI 20191104 Implemented DELETE-SOURCE-CONTENT of OPEN-MIME-RESOURCE.
 */
 
 /*
@@ -212,6 +213,7 @@
 import java.util.*;
 
 import com.goldencode.p2j.ui.client.driver.*;
+
 import org.eclipse.jetty.server.*;
 import org.eclipse.jetty.util.resource.*;
 
@@ -256,9 +258,6 @@
    /** Welcome page. */
    private static final String WELCOME_PAGE = "/index.html";
    
-   /** Define the file schema to get local resources */
-   private static final String FILE_SCHEMA = "file:";
-   
    /** A bogus AWT component used to raise mouse events, on notification from the JS code. */
    private static final Component BOGUS_AWT_COMPONENT = new Component()
    {
@@ -286,9 +285,6 @@
    
    /** Text sample to calculate scaling factor for monospace fonts. */
    private static final String TEXT_SAMPLE_MONO = "0.0";
-
-   /** Temporary files directory. */
-   private static String tmpDir = null;
    
    /** Delgated implementation for the embedded web server. */
    private EmbeddedWebServerImpl websrv;
@@ -546,52 +542,6 @@
    {
       websrv.removeHandler(handler);
    }
-
-   /**
-    * Initializes several web client specific internal variables used with drag-n-drop.
-    * 
-    * @param    srv
-    *           Server to make config related calls.
-    */
-   public void initDragAndDrop(ServerExports srv)
-   {
-      // this is used in web client only and only once
-      if (tmpDir != null)
-      {
-         return;
-      }
-
-      // setting up temporary files upload directory
-      try
-      {
-         Path tmpFile = Files.createTempFile("tmp-file", ".tmp");
-         String absolutePath = tmpFile.toAbsolutePath().toString();
-         tmpDir = absolutePath.substring(0, absolutePath.lastIndexOf(File.separator) + 1);
-         Files.delete(tmpFile);
-      }
-      catch (IOException e)
-      {
-         // for the case the regular way above does not work
-         tmpDir = System.getProperty("user.home");
-      }
-      // create separate directory for fwd files
-      tmpDir = tmpDir.concat("fwd");
-      File tmpDirObj = new File(tmpDir);
-      if (!tmpDirObj.exists())
-      {
-         tmpDirObj.mkdir();
-      }
-      // adding file separator to the end
-      tmpDir = tmpDir.concat(File.separator);
-      
-      // getting the file size limit values considering overrides in server's directory
-      int [] uploadLimits = srv.getUploadFileSizeLimits();
-      // set up gui driver
-      if (uploadLimits[0] > 0 && uploadLimits[1] > uploadLimits[0])
-      {
-         setUploadFileSizeLimits(uploadLimits[0], uploadLimits[1]);
-      }
-   }
    
    /**
     * This is a special API which is used to delegate a call from converted 4GL code 
@@ -2571,6 +2521,9 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    urlString
@@ -2584,7 +2537,10 @@
     *           For other IO errors during file operations.
     */
    @Override
-   public void openMimeResource(String mimeType, String urlString, boolean embedded)
+   public void openMimeResource(boolean deleteContent,
+                                String  mimeType,
+                                String  urlString,
+                                boolean embedded)
    throws MalformedURLException
    {
       // test that urlString is well-formed. 
@@ -2605,14 +2561,11 @@
       
       boolean local = false;
       
-      if (urlString.startsWith(FILE_SCHEMA))
+      if (isLocalResource(url))
       {
-         if (url.getHost() == null || url.getHost().isEmpty())
-         {
-            local = true;
-            
-            id = resolveResourceId(mimeType, url);
-         }
+         local = true;
+         
+         id = resolveResourceId(deleteContent, mimeType, url);
       }
       
       websock.openMimeResource(id, mimeType, embedded, local);
@@ -2621,33 +2574,48 @@
    /**
     * Resolve the document ID used to retrieve the specified resource.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
     * @param    mimeType
     *           The resource mime type.
     * @param    url
     *           The resource URL - must be a local resource.
+    * 
+    * @throws   MalformedURLException 
+    *           If the string presentation of the target resource url is malformed. 
     */
-   String resolveResourceId(String mimeType, URL url)
+   String resolveResourceId(boolean deleteContent, String mimeType, URL url)
+   throws MalformedURLException
    {
-      final File temporaryFile;
-      try
+      final File resourceFile;
+      
+      if (deleteContent)
       {
-         temporaryFile = File.createTempFile("openMimeResource",
-                                             null,
-                                             new File(tmpDir));
-         try(InputStream input = url.openStream();
-             FileOutputStream output = new FileOutputStream(temporaryFile))
-         {
-            ByteStreams.copy(input, output);
+         try
+         {
+            resourceFile = Paths.get(url.toURI()).toFile();
+         }
+         catch (URISyntaxException ex)
+         {
+            throw new MalformedURLException(ex.getMessage());
          }
       }
-      catch (IOException ex)
+      else
       {
-         throw new RuntimeException(ex);
+         try
+         {
+            resourceFile = copyResource(url, false);
+         }
+         catch (IOException ex)
+         {
+            throw new RuntimeException(ex);
+         }
       }
       
       Consumer<OutputStream> consumer = output ->
       {
-         try(FileInputStream input = new FileInputStream(temporaryFile))
+         try(FileInputStream input = new FileInputStream(resourceFile))
          {
             ByteStreams.copy(input, output);
          }
@@ -2657,7 +2625,7 @@
          }
       };
       
-      Runnable finalizer = () -> { temporaryFile.delete(); };
+      Runnable finalizer = () -> { resourceFile.delete(); };
       
       UUID uuid = UUID.randomUUID();
       DocumentOutput docOut = new DocumentOutput(consumer,

=== modified file 'src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java'
--- src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java	2019-09-28 08:50:32 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/web/WebHtmlBrowser.java	2019-11-04 18:07:58 +0000
@@ -8,6 +8,7 @@
 ** 001 CA  20190310 Created initial version.
 ** 002 HC  20190911 Implemented BeforeNavigate2 event emit when existing page is navigated.
 **                  Implemented resource loading.
+** 003 SBI 20191004 Changed openUrl due to gd.resolveResourceId parameter changes.
 */
 
 /*
@@ -72,10 +73,10 @@
 import com.goldencode.p2j.ui.chui.ThinClient;
 import com.goldencode.p2j.ui.client.*;
 import com.goldencode.p2j.util.*;
+
 import org.eclipse.jetty.http.*;
 import org.eclipse.jetty.server.*;
 import org.eclipse.jetty.server.handler.*;
-import org.eclipse.jetty.util.*;
 import org.eclipse.jetty.util.resource.*;
 
 import javax.servlet.*;
@@ -263,7 +264,15 @@
             local = true;
             ThinClient tc = ThinClient.getInstance();
             GuiWebDriver gd = (GuiWebDriver) tc.getOutputManager().getInstanceDriver();
-            id = gd.resolveResourceId(mimeType, url);
+            try
+            {
+               id = gd.resolveResourceId(false, mimeType, url);
+            }
+            catch (MalformedURLException ex)
+            {
+               ex.printStackTrace();
+               return false;
+            }
          }
       }
 

=== modified file 'src/com/goldencode/p2j/util/WebBrowserManager.java'
--- src/com/goldencode/p2j/util/WebBrowserManager.java	2018-12-07 20:45:57 +0000
+++ src/com/goldencode/p2j/util/WebBrowserManager.java	2019-11-04 17:53:09 +0000
@@ -10,6 +10,7 @@
 ** 003 ECF 20180510 Added API variants to handle additional combinations of parameter types.
 ** 004 SBI 20180528 Fixed embedded optional parameter to be true by default.
 ** 005 SBI 20181207 Added openMimeResource(String filePath, boolean embedded).
+** 006 SBI 20191104 Added deleteContent parameter for openMimeResource.
 */
 /*
 ** This program is free software: you can redistribute it and/or modify
@@ -87,22 +88,67 @@
     */
    public static void openMimeResource(String mimeType, String path)
    {
-      openMimeResource(mimeType, path, true);
+      openMimeResource(false, mimeType, path, true);
    }
 
    /**
     * Opens the specified resource in a browser's window.
     * 
-    * @param    mimeType
-    *           The resource mime type.
-    * @param    path
-    *           The url path to the target resource.
-    * @param    embedded
-    *           The document is embedded in the template document.
-    */
-   public static void openMimeResource(String mimeType, String path, boolean embedded)
-   {
-      LogicalTerminal.getClient().openMimeResource(mimeType, path, embedded);
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
+    * @param    mimeType
+    *           The resource mime type.
+    * @param    path
+    *           The url path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    */
+   public static void openMimeResource(boolean deleteContent,
+                                       String  mimeType,
+                                       String  path,
+                                       boolean embedded)
+   {
+      LogicalTerminal.getClient().openMimeResource(deleteContent, mimeType, path, embedded);
+   }
+   
+   /**
+    * Opens the specified resource in a browser's window.
+    * 
+    * @param    mimeType
+    *           The resource mime type.
+    * @param    path
+    *           The url path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    */
+   public static void openMimeResource(String  mimeType, String  path, boolean embedded)
+   {
+      openMimeResource(false, mimeType, path, embedded);
+   }
+   
+   /**
+    * Opens the specified file resource in a browser's window.
+    * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
+    * @param    filePath
+    *           The file path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    * @param    preferredMimeTypes
+    *           The preferred resource mime types.
+    */
+   public static void openMimeResource(boolean      deleteContent,
+                                       String       filePath,
+                                       boolean      embedded,
+                                       List<String> preferredMimeTypes)
+   {
+      LogicalTerminal.getClient().openMimeResource(deleteContent,
+                                                   filePath,
+                                                   embedded,
+                                                   preferredMimeTypes);
    }
    
    /**
@@ -119,7 +165,7 @@
                                        boolean      embedded,
                                        List<String> preferredMimeTypes)
    {
-      LogicalTerminal.getClient().openMimeResource(filePath, embedded, preferredMimeTypes);
+      openMimeResource(false, filePath, embedded, preferredMimeTypes);
    }
    
    /**
@@ -155,6 +201,69 @@
    /**
     * Opens the specified resource in a browser's window.
     * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
+    * @param    mimeType
+    *           The resource mime type.
+    * @param    path
+    *           The url path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    */
+   public static void openMimeResource(boolean   deleteContent,
+                                       character mimeType,
+                                       character path,
+                                       boolean   embedded)
+   {
+      openMimeResource(deleteContent, mimeType.toJavaType(), path.toJavaType(), embedded);
+   }
+   
+   /**
+    * Opens the specified resource in a browser's window.
+    * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
+    * @param    mimeType
+    *           The resource mime type.
+    * @param    path
+    *           The url path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    */
+   public static void openMimeResource(boolean   deleteContent,
+                                       character mimeType,
+                                       String    path,
+                                       boolean   embedded)
+   {
+      openMimeResource(deleteContent, mimeType.toJavaType(), path, embedded);
+   }
+   
+   /**
+    * Opens the specified resource in a browser's window.
+    * 
+    * @param    deleteContent
+    *           Indicates if the source content will be deleted after the document is loaded by
+    *           the client.
+    * @param    mimeType
+    *           The resource mime type.
+    * @param    path
+    *           The url path to the target resource.
+    * @param    embedded
+    *           The document is embedded in the template document.
+    */
+   public static void openMimeResource(boolean   deleteContent,
+                                       String    mimeType,
+                                       character path,
+                                       boolean   embedded)
+   {
+      openMimeResource(deleteContent, mimeType, path.toJavaType(), embedded);
+   }
+   
+   /**
+    * Opens the specified resource in a browser's window.
+    * 
     * @param    mimeType
     *           The resource mime type.
     * @param    path
@@ -259,7 +368,7 @@
     */
    public static void openURL(String path)
    {
-      LogicalTerminal.getClient().openMimeResource("application/octet-stream", path, false);
+      LogicalTerminal.getClient().openMimeResource(false, "application/octet-stream", path, false);
    }
    
    /**

