https://proj.goldencode.com/https://proj.goldencode.com/favicon.ico2019-05-08T17:47:20ZGolden Code RedmineUser Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=733312019-05-08T17:47:20ZGreg Shah
<ul></ul><p><code>OPEN-MIME-RESOURCE</code> is often used when 4GL code generates some output and wants to get it to the user. There is a common case where this output is transient and only needs to exist until it has been loaded into the user's browser.</p>
<p>If I recall correctly, today we copy the input content into a temporary location, send it and then delete the temporary copy.</p>
<p>This task is intended to add a <code>DELETE-SOURCE-CONTENT</code> optional keyword to the <code>OPEN-MIME-RESOURCE</code> syntax. If present, we would do one of the following:</p>
<ul>
<li>Avoid doing a temporary copy (which should save time) and delete the original input file when the transfer is complete.</li>
<li>Still do the temporary copy but make sure to delete the input file just before <code>OPEN-MIME-RESOURCE</code> returns.</li>
</ul>
<p>The result is the same from the 4GL developer's perspective, but if we can save a copy that is good.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=733322019-05-08T17:47:28ZGreg Shah
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/3474">Feature #3474</a>: OPEN-MIME-RESOURCE</i> added</li></ul> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=801862019-10-30T14:18:38ZSergey Ivanovskiy
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>WIP</i></li><li><strong>Assignee</strong> set to <i>Sergey Ivanovskiy</i></li></ul> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=801992019-10-31T14:50:34ZSergey Ivanovskiy
<ul></ul><p>The current implementation uses <code>WebBrowserManager.openMimeResource</code> to generate java code for <code>OPEN-MIME-RESOURCE</code>. Planning to add a shortcut key word of <code>DELETE-SOURCE-CONTENT</code> as <code>KW_DEL_S_C</code> according to presenting shortcuts in <code>progress.g</code> with this rule <br /><pre>
/**
* 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. If an optional
* <code>DELETE-SOURCE-CONTENT</code> is present, then it forces to delete the original input file
* when the transfer is complete.<br /> */<br />open_mime_resource_stmt<br /> :<br /> KW_OPENMIME^ expr expr (expr)? (KW_DEL_S_C)? stmt_term<br /> ;</p>
</pre>
<p>Could we add type conversion rules to <code>language_statements.rules</code> for child nodes of this type <code>== prog.kw_openmime</code> in order to<br />use java types?<br />Now I need to add <code>openMimeResource</code> for all possible combinations of <code>character|String</code> and <code>logical|boolean</code>.<br />Also there are ambitious parameters "EMBEDED" and "DELETE-SOURCE-CONTENT" boolean flag. Planning to add true value node as a first child node if <code>DELETE-SOURCE-CONTENT</code> is present by this rule<br /><pre>
<rule>type == prog.kw_del_s_c and
parent.type == prog.kw_openmime
<action>createJavaAst(java.bool_true, "true", closestPeerId, 0)</action>
</rule>
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802032019-11-01T09:29:33ZSergey Ivanovskiy
<ul></ul><p>For the swing client we open the target file by external programs which don't send us notifications that the target file is opened successfully. Don't know if it makes sense to copy the target content into a temporary file that will be deleted on JVM exit event. In this case the source file can be deleted immediately after its content has been copied successfully.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802062019-11-01T21:02:47ZSergey Ivanovskiy
<ul></ul><p>However, for Linux we can use <code>lsof | grep "absolute file path"</code> in order to check if this file is opened. Another way to check an access attribute using <code>stat</code>. Thus, we can wait until the file access attribute is changed so the file is opened.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802072019-11-01T21:53:00ZSergey Ivanovskiy
<ul><li><strong>File</strong> <a href="/attachments/download/8505/4077.patch">4077.patch</a><a href="/attachments/8505/4077.patch"><img src="/images/magnifier.png" alt="Magnifier" /></a> added</li></ul><p>Prepared this diff for the commit candidate.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802082019-11-01T22:01:55ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>However, for Linux we can use <code>lsof | grep "absolute file path"</code> in order to check if this file is opened. Another way to check an access attribute using <code>stat</code>. Thus, we can wait until the file access attribute is changed so the file is opened.</p>
</blockquote>
<p>This whole think is tricky. Both for Swing and Web clients. You cannot assume that once the file is closed it is safe for deletion. The process displaying the mime resource may access the file any time during its execution. Similarly for Web, the resource can be fetched multiple times by the browser - the typical cases are when the browser shows the blocking dialog and only shows the resource when the user confirms it is safe. Or when the resource is displayed and then printed on user request. Or when the user refreshes the browser window showing the mime resource. Also the behavior may vary depending on the browser caching settings.</p>
<p>I think we need to scope the file lifetime with the user session. Once the user session terminates, the resource files served in the terminated session would be deleted. The disadvantage is that we could end up with many pending files, but the delivery would be reliable.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802302019-11-04T08:28:25ZSergey Ivanovskiy
<ul></ul><p>For the web client we copy the file and then deliver its copied content. This temporary file is deleted only after its content has been send by <code>DocumentOutputHandler.handle</code>. Thus for the web client if <code>DELETE-SOURCE-CONTENT</code> is present then the target file can be deleted immediately after its content is send. <br />For the swing client this file is opened by an external program and it can't be deleted immediately unless this file is copied into a temporary file. All these temporary files can be deleted after the user session terminates. In this case we can't delete this target file if <code>DELETE-SOURCE-CONTENT</code> is provided. Is there a way to get rid of coping the target file content into a temporary file?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802352019-11-04T13:00:23ZSergey Ivanovskiy
<ul><li><strong>Status</strong> changed from <i>WIP</i> to <i>Review</i></li><li><strong>% Done</strong> changed from <i>0</i> to <i>100</i></li></ul><p>Please review the committed revision 11339 (4077a). Now <code>OPEN-MIME-RESOURCE</code> is defined by<br /><pre>
OPEN-MIME-RESOURCE <mime-type> <url> [NOT-EMBEDDED] [DELETE-SOURCE].
</pre><br />Where:</p>
<pre><code>mime-type is the resource <code>MIME</code> type. It can hold any valid character expression.</code></pre>
<pre><code>url is the resource <code>URL</code> (the path to the resource) and it can be any valid character expression.</code></pre>
<pre><code>NOT-EMBEDDED represents that the given resource is not displayed as an embedded document in the web browser, the given resource becomes embedded by default if this flag is omitted.</code></pre>
<pre><code>If DELETE-SOURCE is present and the given resource is local file, then it must be deleted after this method returns.<br /> If DELETE-SOURCE is omitted, then the given resource is not deleted.</code></pre>
<p>Fixed [NOT-EMBEDDED-CONTENT] in the committed revision 11340 (4077a).<br />Renamed [NOT-EMBEDDED-CONTENT] to [NOT-EMBEDDED] and [DELETE-SOURCE-CONTENT] to [DELETE-SOURCE] in the committed revision 11342 (4077a).</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802402019-11-04T15:59:05ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Is there a way to get rid of coping the target file content into a temporary file?</p>
</blockquote>
<p>Can we actually move the file? This would be more efficient and wouldn't need additional storage.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802412019-11-04T15:59:51ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>NOT-EMBEDED-CONTENT represents that the given resource is not embedded into template document, the given resource becomes embedded by default if this flag is omitted.</p>
</blockquote>
<p>The correct spelling should be NOT-EMBEDDED-CONTENT.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802422019-11-04T16:29:33ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Is there a way to get rid of coping the target file content into a temporary file?</p>
</blockquote>
<p>Can we actually move the file? This would be more efficient and wouldn't need additional storage.</p>
</blockquote>
<p>Yes, it is a good idea, planning to use it in the case if DELETE-SOURCE-CONTENT is provided.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802432019-11-04T18:16:51ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>The correct spelling should be NOT-EMBEDDED-CONTENT.</p>
</blockquote>
<p>Please review the committed revision 11340 (4077a). Fixed this key word, added history changes and used move instead of copy for the swing client.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802452019-11-04T22:20:28ZHynek Cihlar
<ul></ul><p>Code review 4077a.</p>
<p><code>KW_NOT_EMBEDDED</code> should be shortened to 11 chars.</p>
<p>coping => copying</p>
<p>Does it make sense to shorten <code>DELETE-SOURCE-CONTENT</code> to <code>DELETE-SOURCE</code> and <code>NOT-EMBEDDED-CONTENT</code> to <code>NOT-EMBEDDED</code>?</p>
<p><code>private static final String FILE_SCHEMA</code> should be moved below <code>protected static final Logger LOG</code>.</p>
<p><code>AGD.tmpDir</code><br />I don't think we need to fallback in a <code>~/fwd</code> dir for a temp location. The Java runtime uses <code>java.io.tmpdir</code> property to read the temp dir location (on Unix systems it is /tmp by default). Just use <code>File.createTempFile()</code>, if needed we can simply set this property to change the temp location.</p>
<p>Doing this <code>throw new MalformedURLException(ex.getMessage());</code> the call stack and type of the original exception is lost. Maybe <code>openMimeResource</code> should throw <code>URISyntaxException</code>? Or just a <code>RuntimeException</code> similarly as for <code>IOException</code>.</p>
<p>Why the change from <code>urlString</code> to <code>uri.normalize().toASCIIString()</code>? I don't think this is needed. However in <code>TemplateHelper.fill()</code> encoding must be specified to match the template. Ideally a <code>Reader</code> instead of an <code>InputStream</code> should be passed to <code>fill()</code>, since only the caller knows what encoding the passed in template source uses.</p>
<p><code>GuiWebDriver.FILE_SCHEMA</code>, shouldn't the file scheme be "file"?</p>
<p><code>GuiWebDriver</code>, again I think we should rely on the <code>java.io.tmpdir</code> for temp dir, respectively just use <code>File.createTempFile</code></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802532019-11-05T15:48:03ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>I don't think we need to fallback in a ~/fwd dir for a temp location. The Java runtime uses java.io.tmpdir property to read the temp dir location (on Unix systems it is /tmp by default). Just use File.createTempFile(), if needed we can simply set this property to change the temp location.</p>
</blockquote>
<p>I reused the temporary directory that is used already for our code. Don't understand the matter of these proposed changes.</p>
<blockquote>
<p>Doing this throw new MalformedURLException(ex.getMessage()); the call stack and type of the original exception is lost.</p>
</blockquote>
<p>I think it doesn't matter to do this change because the call stack follows from this context <code>URL.toURI()</code>.</p>
<blockquote>
<p>Why the change from urlString to uri.normalize().toASCIIString()? I don't think this is needed. However in TemplateHelper.fill() encoding must be specified to match the template. Ideally a Reader instead of an InputStream should be passed to fill(), since only the caller knows what encoding the passed in template source uses.</p>
</blockquote>
<p>What is incorrect?</p>
<blockquote>
<p>GuiWebDriver.FILE_SCHEMA, shouldn't the file scheme be "file"?</p>
</blockquote>
<p>If I understand correctly, you propose to use "file" instead of GuiWebDriver.FILE_SCHEMA.</p>
<blockquote>
<p>GuiWebDriver, again I think we should rely on the java.io.tmpdir for temp dir, respectively just use File.createTempFile</p>
</blockquote>
<p>I guess that you mean <code>AbstarctGuiDriver.moveResource(URL url, boolean deleteOnExit)</code> implementation where I used this code because it creates a simple path instead of empty file. If my guess is incorrect, then please express your proposals more thoroughly.</p>
<p>Agree with all other found issues.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802542019-11-05T16:28:36ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>I don't think we need to fallback in a ~/fwd dir for a temp location. The Java runtime uses java.io.tmpdir property to read the temp dir location (on Unix systems it is /tmp by default). Just use File.createTempFile(), if needed we can simply set this property to change the temp location.</p>
</blockquote>
<p>I reused the temporary directory that is used already for our code. Don't understand the matter of these proposed changes.</p>
</blockquote>
<p>I'm questioning the logic around <code>AbstractGuiDriver.tmpDir</code>, in <code>initDragAndDrop</code>. I don't think it is needed, as it should be covered by <code>File.createTempFile</code>.</p>
<p>But I see now, that you just moved it up from <code>GuiWebDriver</code>.</p>
<blockquote><blockquote>
<p>Doing this throw new MalformedURLException(ex.getMessage()); the call stack and type of the original exception is lost.</p>
</blockquote>
<p>I think it doesn't matter to do this change because the call stack follows from this context <code>URL.toURI()</code>.</p>
</blockquote>
<p>While this is a minor issue, I still think it unnecessarily complicates things. When this exception happens you will have to inspect the code to figure out what was the exact cause. Having the exact call stack will help the clarity.</p>
<blockquote>
<blockquote>
<p>Why the change from urlString to uri.normalize().toASCIIString()? I don't think this is needed. However in TemplateHelper.fill() encoding must be specified to match the template. Ideally a Reader instead of an InputStream should be passed to fill(), since only the caller knows what encoding the passed in template source uses.</p>
</blockquote>
<p>What is incorrect?</p>
</blockquote>
<p>I don't think it is incorrect, I'm just not sure if the change is needed.</p>
<blockquote>
<blockquote>
<p>GuiWebDriver.FILE_SCHEMA, shouldn't the file scheme be "file"?</p>
</blockquote>
<p>If I understand correctly, you propose to use "file" instead of GuiWebDriver.FILE_SCHEMA.</p>
</blockquote>
<p>The protocol name should not include colon.</p>
<blockquote><blockquote>
<p>GuiWebDriver, again I think we should rely on the java.io.tmpdir for temp dir, respectively just use File.createTempFile</p>
</blockquote>
<p>I guess that you mean <code>AbstarctGuiDriver.moveResource(URL url, boolean deleteOnExit)</code> implementation where I used this code because it creates a simple path instead of empty file. If my guess is incorrect, then please express your proposals more thoroughly.</p>
</blockquote>
<p>This is already covered above in the first point.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802552019-11-05T16:34:32ZSergey Ivanovskiy
<ul><li><strong>File</strong> <a href="/attachments/download/8510/4077a_up_to_rev11340.patch">4077a_up_to_rev11340.patch</a><a href="/attachments/8510/4077a_up_to_rev11340.patch"><img src="/images/magnifier.png" alt="Magnifier" /></a> added</li></ul><p>Hynek, it looks like you examined the old code because I did this change in rev 11340 - changed this constant <code>file:</code> to this one <code>"file"</code>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802592019-11-05T16:56:42ZSergey Ivanovskiy
<ul></ul><p>This change <code>from urlString to uri.normalize().toASCIIString()</code> is needed because <code>uri</code> can point to the temporary file here (it is your proposed change). It can be that <code>uri.normalize()</code> is not required but it needs to be sure that <code>tmpDir</code> has no "." and ".." in its path<br /><pre>
if (embedded)
{
try
{
uri = buildOpenResourcePage(mimeType, uri.normalize().toASCIIString());
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
}
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802612019-11-05T17:36:02ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>This change <code>from urlString to uri.normalize().toASCIIString()</code> is needed because <code>uri</code> can point to the temporary file here (it is your proposed change). It can be that <code>uri.normalize()</code> is not required but it needs to be sure that <code>tmpDir</code> has no "." and ".." in its path<br />[...]</p>
</blockquote>
<p>I don't think that <code>toASCIIString()</code> removes "." and "..". These are valid ASCII chars.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802672019-11-05T18:55:20ZSergey Ivanovskiy
<ul></ul><p>Yes, <code>uri.normalize()</code> should do it.</p>
<p>Please review the committed revision 11341 that fixed the rest of the found issues listed in <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-15">#4077-15</a>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802682019-11-05T18:58:02ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Yes, <code>uri.normalize()</code> should do it.</p>
</blockquote>
<p>So <code>toASCIIString()</code> is not needed, correct?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802692019-11-05T19:02:10ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Yes, <code>uri.normalize()</code> should do it.</p>
</blockquote>
<p>So <code>toASCIIString()</code> is not needed, correct?</p>
</blockquote>
<p>I think it is needed because it transforms url to ascii string.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802712019-11-05T19:03:48ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Yes, <code>uri.normalize()</code> should do it.</p>
</blockquote>
<p>So <code>toASCIIString()</code> is not needed, correct?</p>
</blockquote>
<p>I think it is needed because it transforms url to ascii string.</p>
</blockquote>
<p>The template is UTF-8 encoded, it doesn't have to be transformed. My point is that this may potentially complicate debugging.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=802722019-11-05T19:11:46ZSergey Ivanovskiy
<ul></ul><p>While checking the diff I found missed changes in <code>progress.g</code> due to renaming. So the committed rev 11342 (4077a) looks to be a final candidate.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=803462019-11-07T09:17:39ZHynek Cihlar
<ul></ul><p>Code review 4077a revisions 11342 and 11341. The changes are good. My only concern is <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-24">#4077-24</a>, which still remains.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807052019-11-18T17:12:02ZGreg Shah
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Yes, <code>uri.normalize()</code> should do it.</p>
</blockquote>
<p>So <code>toASCIIString()</code> is not needed, correct?</p>
</blockquote>
<p>I think it is needed because it transforms url to ascii string.</p>
</blockquote>
<p>The template is UTF-8 encoded, it doesn't have to be transformed. My point is that this may potentially complicate debugging.</p>
</blockquote>
<p>Sergey: Please respond on this.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807072019-11-18T17:20:11ZSergey Ivanovskiy
<ul></ul><p>I didn't respond to this note <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-24">#4077-24</a> because it is not an issue and this change doesn't complicate debugging. The input url is not encoded so there is no reason that the debugging will be potentially complicated.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807122019-11-18T17:36:34ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>I didn't respond to this note <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-24">#4077-24</a> because it is not an issue and this change doesn't complicate debugging. The input url is not encoded so there is no reason that the debugging will be potentially complicated.</p>
</blockquote>
<p>Sergey, with the call <code>toASCIIString()</code> you change the url passed to the HTML template, all non-ASCII chars are escaped. This is (1) unnecessary as the template is UTF-8 and (2) may complicate debugging - to find the generated URL in the template or in the code you have to remember to encode/decode the url.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807132019-11-18T17:44:42ZSergey Ivanovskiy
<ul></ul><p>Hynek, I don't understand why url should not be encoded. Urls can be external and it seems that they can have native chars?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807152019-11-18T17:52:19ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek, I don't understand why url should not be encoded. Urls can be external and it seems that they can have native chars?</p>
</blockquote>
<p>URLs are encoded in order to overcome charset limitations of the target systems. If you wanted to persist a URL in an ASCII text file for example, then you would have to encode the URL (i.e. use <code>toASCIIString</code> to convert all the non-ASCII chars to ASCII chars). But in your case, this is not needed, you persist the URL in an HTML template which is UTF-8 encoded and so capable to encode all unicode chars.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807162019-11-18T17:57:50ZSergey Ivanovskiy
<ul></ul><p>Yes, if these url strings are UTF-8, then we can leave them as they are. Is it possible that urls have non unicode strings?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807172019-11-18T18:05:14ZSergey Ivanovskiy
<ul></ul><p>It seems that if we would remove toASCIIString() usage here, then the following code would be incorrect <br /><pre>
public void openMimeResource(boolean deleteContent,
String mimeType,
String urlString,
boolean embedded)
throws MalformedURLException,
URISyntaxException
{
// test that urlString is well-formed.
URL url = new URL(urlString);
URI uri = url.toURI();
String id = uri.toASCIIString();
boolean local = false;
if (isLocalResource(url))
{
local = true;
id = resolveResourceId(deleteContent, mimeType, url);
}
websock.openMimeResource(id, mimeType, embedded, local);
}
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807192019-11-18T18:12:50ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>It seems that if we would remove toASCIIString() usage here, then the following code would be incorrect <br />[...]</p>
</blockquote>
<p>You can pass encoded or un-encoded URI to <code>openMimeResource</code>, both will work fine. However the call to <code>toASCIIString</code> in <code>openMimeResource</code> is needed so that the URL can be passed later on in a URL parameter, see <code>buildOpenResourceUrl</code> in <code>p2j.socjet.js</code>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807252019-11-18T18:55:11ZSergey Ivanovskiy
<ul></ul><p>What is about native no unicode characters?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807272019-11-18T19:24:23ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>What is about native no unicode characters?</p>
</blockquote>
<p>Sorry, can you rephrase the question?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807292019-11-18T19:56:01ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>What is about native no unicode characters?</p>
</blockquote>
<p>Sorry, can you rephrase the question?</p>
</blockquote>
<p>Can these urls given in no unicode characters be used in UTF-8 template without encoding them into UTF-8?<br />Examples, <a class="external" href="http://παράδειγμα.δοκιμή">http://παράδειγμα.δοκιμή</a> or <a class="external" href="http://правительство.рф">http://правительство.рф</a></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807302019-11-18T20:07:30ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>What is about native no unicode characters?</p>
</blockquote>
<p>Sorry, can you rephrase the question?</p>
</blockquote>
<p>Can these urls given in no unicode characters be used in UTF-8 template without encoding them into UTF-8?<br />Examples, <a class="external" href="http://παράδειγμα.δοκιμή">http://παράδειγμα.δοκιμή</a> or <a class="external" href="http://правительство.рф">http://правительство.рф</a></p>
</blockquote>
<p>Java strings are already unicode (encoded as UTF-16). So the value of the String variable passed to the HTML template can be serialized as UTF-8. So the URLs above will work fine.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807312019-11-18T20:22:49ZGreg Shah
<ul></ul><p>What about strings with spaces, tabs and control characters?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807322019-11-18T20:30:23ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>What is about native no unicode characters?</p>
</blockquote>
<p>Sorry, can you rephrase the question?</p>
</blockquote>
<p>Can these urls given in no unicode characters be used in UTF-8 template without encoding them into UTF-8?<br />Examples, <a class="external" href="http://παράδειγμα.δοκιμή">http://παράδειγμα.δοκιμή</a> or <a class="external" href="http://правительство.рф">http://правительство.рф</a></p>
</blockquote>
<p>Java strings are already unicode (encoded as UTF-16). So the value of the String variable passed to the HTML template can be serialized as UTF-8. So the URLs above will work fine.</p>
</blockquote>
<p>It seems that this serialization can be incorrect because it depends on the java default encoding but urls can have different encoding. Does this point make sense?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807332019-11-18T20:39:16ZHynek Cihlar
<ul></ul><p>Greg Shah wrote:</p>
<blockquote>
<p>What about strings with spaces, tabs and control characters?</p>
</blockquote>
<p>These are illegal for the <code>URI</code> class, you would get <code>URISyntaxException</code> before the ASCII encoding would take place.</p>
<p>It is not big deal to have the <code>toASCIIString</code> modify the URLs. I just don't think it is necessary and I can imagine it could cause minor troubles when tracing the execution.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807342019-11-18T20:42:24ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote><blockquote>
<p>Java strings are already unicode (encoded as UTF-16). So the value of the String variable passed to the HTML template can be serialized as UTF-8. So the URLs above will work fine.</p>
</blockquote>
<p>It seems that this serialization can be incorrect because it depends on the java default encoding but urls can have different encoding.</p>
</blockquote>
<blockquote>
<p>Does this point make sense?</p>
</blockquote>
<p>Yes and no. In fact the default encoding being used is another issue which can potentially cause troubles. While the HTML template is assumed to be UTF-8, the default encoding could be different from UTF-8. This by itself is not correct and may result in the template being rendered wrong. Instead of default encoding the UTF-8 should be used when serializing the HTML template.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807362019-11-18T20:46:44ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote><blockquote>
<p>Java strings are already unicode (encoded as UTF-16). So the value of the String variable passed to the HTML template can be serialized as UTF-8. So the URLs above will work fine.</p>
</blockquote>
<p>It seems that this serialization can be incorrect because it depends on the java default encoding but urls can have different encoding.</p>
</blockquote>
<blockquote>
<p>Does this point make sense?</p>
</blockquote>
<p>Yes and no. In fact the default encoding being used is another issue which can potentially cause troubles. While the HTML template is assumed to be UTF-8, the default encoding could be different from UTF-8. This by itself is not correct and may result in the template being rendered wrong. Instead of default encoding the UTF-8 should be used when serializing the HTML template.</p>
</blockquote>
<p>I think that this point makes sense so the current solution produces a correct result even if the default java encoding is not or is UTF-8. Thus, we can conclude that we should leave it as is now. Any case there is always a possibility to rewrite the code totally.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807382019-11-18T20:57:39ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote><blockquote>
<p>Yes and no. In fact the default encoding being used is another issue which can potentially cause troubles. While the HTML template is assumed to be UTF-8, the default encoding could be different from UTF-8. This by itself is not correct and may result in the template being rendered wrong. Instead of default encoding the UTF-8 should be used when serializing the HTML template.</p>
</blockquote>
<p>I think that this point makes sense so the current solution produces a correct result even if the default java encoding is not or is UTF-8. Thus, we can conclude that we should leave it as is now. Any case there is always a possibility to rewrite the code totally.</p>
</blockquote>
<p>Besides the minor URL encoding issue, the default encoding is more serious. This will break as soon as somebody tries to put a localized title in the HTML template on a system where UTF-8 is not the default encoding, like Windows.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807412019-11-18T21:39:06ZSergey Ivanovskiy
<ul></ul><p>Adding a localized title is a separated task and I believe it will be done by correct changes if this task will be needed to implement. I don't understand what are issues we are trying to resolve?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807422019-11-18T21:42:45ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Adding a localized title is a separated task and I believe it will be done by correct changes if this task will be needed to implement. I don't understand what are issues we are trying to resolve?</p>
</blockquote>
<p>I'm mentioning this because (1) it is a problem and (2) it is very close to the changes you made.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807442019-11-18T21:58:55ZSergey Ivanovskiy
<ul></ul><p>It seems that you didn't provide any proofs or evidences that there are issues. Please be more specific to the code because I don't know what requirements will be changed or what code flow will be in the future.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807452019-11-18T22:13:27ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>It seems that you didn't provide any proofs or evidences that there are issues. Please be more specific to the code because I don't know what requirements will be changed or what code flow will be in the future.</p>
</blockquote>
<p>In <code>SwingGuiDriver.buildOpenResourcePage</code> <code>PrintWriter</code> is constructed with default charset. When the default charset is not UTF-8, any locale specific strings will be encoded incorrectly in <code>TemplateHelper.fill</code>. The solution is to specify UTF-8 encoding in the writer's ctor.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807542019-11-19T07:57:10ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>It seems that you didn't provide any proofs or evidences that there are issues. Please be more specific to the code because I don't know what requirements will be changed or what code flow will be in the future.</p>
</blockquote>
<p>In <code>SwingGuiDriver.buildOpenResourcePage</code> <code>PrintWriter</code> is constructed with default charset. When the default charset is not UTF-8, any locale specific strings will be encoded incorrectly in <code>TemplateHelper.fill</code>. The solution is to specify UTF-8 encoding in the writer's ctor.</p>
</blockquote>
<p>I added comments that "A key provider must return an ASCII string" and rebased 4077a over the current trunc version rev 11339. Please review these changes rev 11334 (4077a).</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807552019-11-19T08:08:14ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>It seems that you didn't provide any proofs or evidences that there are issues. Please be more specific to the code because I don't know what requirements will be changed or what code flow will be in the future.</p>
</blockquote>
<p>In <code>SwingGuiDriver.buildOpenResourcePage</code> <code>PrintWriter</code> is constructed with default charset. When the default charset is not UTF-8, any locale specific strings will be encoded incorrectly in <code>TemplateHelper.fill</code>. The solution is to specify UTF-8 encoding in the writer's ctor.</p>
</blockquote>
<p>I added comments that "A key provider must return an ASCII string" and rebased 4077a over the current trunc version rev 11339. Please review these changes rev 11334 (4077a).</p>
</blockquote>
<p>This is not correct. The title is built from a file name, it can be locale specific.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807652019-11-19T11:39:20ZSergey Ivanovskiy
<ul></ul><p>Yes, I agree with this point.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807752019-11-19T14:32:32ZSergey Ivanovskiy
<ul></ul><p>Checking my changes I fixed <code>open_mime_resource_stmt</code> rule in <code>progress.g</code> and the found <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-50">#4077-50</a>. I would like to note that html source files are not displayed by Firefox and Chrome because there is no available plugin for this mime type. Please review the committed revision 11345.(4077a)</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807762019-11-19T14:35:01ZSergey Ivanovskiy
<ul></ul><p>The browser plugin for this mime type is not supported.<br /><pre>
<embed id="embeddedDocument" type="plain/html" src="https://ru.wikipedia.org/wiki/%D0%93%D0%B0%D0%B3%D0%B0%D1%80%D0%B8%D0%BD,_%D0%AE%D1%80%D0%B8%D0%B9_%D0%90%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B5%D0%B2%D0%B8%D1%87" width="1855" height="1056">
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807792019-11-19T15:14:43ZSergey Ivanovskiy
<ul></ul><p>To do homogeneous changes we can use this code with the same results<br /><pre>
=== 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-11-19 14:10:34 +0000
+++ src/com/goldencode/p2j/ui/client/gui/driver/swing/SwingGuiDriver.java 2019-11-19 14:56:04 +0000
@@ -811,7 +811,7 @@
{
try
{
- uri = buildOpenResourcePage(mimeType, uri.normalize().toASCIIString());
+ uri = buildOpenResourcePage(mimeType, uri.toString());
}
catch (IOException ex)
{
@@ -993,7 +993,8 @@
keysProvider.put("isStreamed", () -> "false");
keysProvider.put("documentTitle", () -> StringEscapeUtils.escapeHtml(
TemplateHelper.native2Ascii(doc.getAbsolutePath())));
- keysProvider.put("documentPath", () -> url);
+ keysProvider.put("documentPath", () -> StringEscapeUtils.escapeHtml(
+ TemplateHelper.native2Ascii(url)));
keysProvider.put("documentType", () -> mimeType);
TemplateHelper.fill(templatePage, keysProvider, writer);
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=807952019-11-19T20:57:30ZHynek Cihlar
<ul></ul><p>Code review 4077a revision 11345.</p>
<p>With<br /><pre>
keysProvider.put("documentTitle", () -> StringEscapeUtils.escapeHtml(
TemplateHelper.native2Ascii(doc.getAbsolutePath())));
</pre></p>
<p>the end user will be presented with raw bytes in the place of locale specific characters. I don't think this is what we want.</p>
<p>Please reread <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-48">#4077-48</a>. The solution is really trivial, undo the code above and change <code>PrintWriter writer = new PrintWriter(doc);</code> to <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> in <code>SwingGuiDriver.buildOpenResourcePage</code>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808032019-11-20T06:58:43ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Code review 4077a revision 11345.</p>
<p>With<br />[...]</p>
<p>the end user will be presented with raw bytes in the place of locale specific characters. I don't think this is what we want.</p>
<p>Please reread <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is complete (Closed)" href="https://proj.goldencode.com/issues/4077#note-48">#4077-48</a>. The solution is really trivial, undo the code above and change <code>PrintWriter writer = new PrintWriter(doc);</code> to <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> in <code>SwingGuiDriver.buildOpenResourcePage</code>.</p>
</blockquote>
<p>Yes, it is my mistake that the title string is given by <code>\\u</code> entities, but it needs to be represented by html entities <br /><pre>
https://example.org/test.pdf?q=&#x043c;&#x043e;&#x0439;%20&#x0434;&#x043e;&#x043c%20;&#x042d;&#x0444;&#x0438;&#x043e;&#x043f;&#x0438;&#x044f;%20&#x0410;&#x0444;&#x0440;&#x0438;&#x043a;&#x0430;&amp;q=q'werty
</pre><br />It can be easily fixed.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808042019-11-20T07:05:12ZSergey Ivanovskiy
<ul></ul><p>Testing several documents opened sequentially by 4GL business code I detected race conditions with the Swing client. It is a worse issue.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808062019-11-20T08:09:39ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Testing several documents opened sequentially by 4GL business code I detected race conditions with the Swing client. It is a worse issue.</p>
</blockquote>
<p>What is the use case?</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808072019-11-20T08:17:37ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>but it needs to be represented by html entities</p>
</blockquote>
<p>The HTML page is encoded in UTF-8, so any unicode char will work OK. The only chars that need to be escaped are <code>&</code>, <code><</code>, <code>></code> and <code>"</code>, <code>'</code> for attribute values. Make sure you use <code>UTF-8</code> encoding for the <code>PrintWriter</code> instance and only use <code>StringEscapeUtils.escapeHtml</code>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808122019-11-20T09:18:45ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>Testing several documents opened sequentially by 4GL business code I detected race conditions with the Swing client. It is a worse issue.</p>
</blockquote>
<p>What is the use case?</p>
</blockquote>
<p>Actually, it is not a truly race condition. It happens due to the same file name was generated for different resource files.<br /><pre>
- File doc = new File(getPrintOutputDir(), getPrintOutputFile(null, MediaType.HTML));
+ File doc = new File(getPrintOutputDir(),
+ getPrintOutputFile(UUID.randomUUID().toString(),
+ MediaType.HTML));
</pre></p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808142019-11-20T09:24:46ZSergey Ivanovskiy
<ul></ul><p>I wouldn't want to use <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> because of the following reasons. Source strings can be from non UTF-8 and the default java encoding can be different. It seems that we shouldn't code "UTF-8" inside the code. I understand that html template specifies its encoding as UTF-8 but ASCII is a subset of UTF-8.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808162019-11-20T09:49:31ZSergey Ivanovskiy
<ul></ul><p>Please review the committed revision 11346. If this solution will not be approved, then <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> will be applied instead.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808172019-11-20T10:06:01ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>I wouldn't want to use <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> because of the following reasons. Source strings can be from non UTF-8 and the default java encoding can be different.</p>
</blockquote>
<p>The source Java string is already in unicode (in UTF-16, but this is not that important) so can be represented in UTF-8. Both UTF-16 and UTF-8 are unicodes but with different encodings. These can be interchanged with proper encoders (i.e. when you set UTF-8 in the <code>Writer</code> instance).</p>
<p>We must not use the default encoding as this gives unexpected results, depending what the OS default encoding for Java is set to.</p>
<blockquote>
<p>It seems that we shouldn't code "UTF-8" inside the code.</p>
</blockquote>
<p>We don't code in UTF-8. Here the UTF-8 encoding is what the HTML template is set to and hence must serialize UTF-8 strings in it.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808192019-11-20T10:18:07ZSergey Ivanovskiy
<ul></ul><p>Hynek Cihlar wrote:</p>
<blockquote>
<p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>I wouldn't want to use <code>PrintWriter writer = new PrintWriter(doc, "UTF-8");</code> because of the following reasons. Source strings can be from non UTF-8 and the default java encoding can be different.</p>
</blockquote>
<p>The source Java string is already in unicode (in UTF-16, but this is not that important) so can be represented in UTF-8. Both UTF-16 and UTF-8 are unicodes but with different encodings. These can be interchanged with proper encoders (i.e. when you set UTF-8 in the <code>Writer</code> instance).</p>
<p>We must not use the default encoding as this gives unexpected results, depending what the OS default encoding for Java is set to.</p>
</blockquote>
<p>I think that the presented rev 11346 should give expected results. I will use your proposed solution, because it should work if the default java encoding is UTF-8.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808212019-11-20T10:36:04ZHynek Cihlar
<ul></ul><p>Sergey Ivanovskiy wrote:</p>
<blockquote>
<p>I think that the presented rev 11346 should give expected results.</p>
</blockquote>
<p>Even with 11346 the encoding issue would not be fully resolved. Consider the HTML template localized, in Czech for example. It would get deserialized, template values filled and serialized back. If the serialization was performed in encoding other than UTF-8 (and since the template specifies UTF-8) the result would be garbage for the Czech characters.</p>
<p>You will also have to specify UTF-8 encoding when reading the template. Change <code>BufferedReader reader = new BufferedReader(new InputStreamReader(template));</code> to <code>BufferedReader reader = new BufferedReader(new InputStreamReader(template, "UTF-8"));</code> in <code>TemplateHelper.fill</code>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808232019-11-20T10:48:05ZSergey Ivanovskiy
<ul></ul><p>Yes, thank you, I will change this too. For localized resources native to ascii conversion is usually used and several templates share the same name with different language suffixes.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808252019-11-20T11:58:20ZSergey Ivanovskiy
<ul></ul><p>Please review the committed revision 11347 (4077a).</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808262019-11-20T12:35:51ZHynek Cihlar
<ul></ul><p>Code review 4077a revision 11347. The changes are good. I have no more concerns for 4077a.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808372019-11-20T14:03:07ZGreg Shah
<ul></ul><p>Code Review Task Branch 4077a Revision 11347</p>
<p>I'm good with the changes, except some minor things:</p>
<p>1. In <code>progress.g</code>, there is no need for the additional usage of <code>attrsAndMethods.put()</code>. These are not attributes of a handle based resource so this extra code should be removed.</p>
<p>2. In <code>ScreenDriver</code>, please use <code>import java.net.*</code> instead of the explicit exceptions.</p>
<p>Please make these changes and then merge this into 3809e.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=808422019-11-20T15:58:54ZSergey Ivanovskiy
<ul></ul><p>Committed these fixes in rev 11348 (4077a) and then merged 4077a into 3809e as rev 11390.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=824172020-01-06T13:30:22ZGreg Shah
<ul><li><strong>Status</strong> changed from <i>Review</i> to <i>Test</i></li></ul><p>Sergey: Please update the documentation to fully explain the new syntax. You MUST leave the old syntax there as well, since it is incompatible but is available for a specific range of FWD revisions. Please make it clear which revisions use the old syntax and which ones use the new syntax. The new syntax is not yet in trunk so put a placeholder there for now ("3809e revision <cite>?" where ?</cite> is the revision in which you added the new syntax). When 3809e merges to trunk we can change this placeholder to be the trunk revision.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=824212020-01-06T14:22:22ZSergey Ivanovskiy
<ul></ul><p>Greg, please review these changes <a class="external" href="https://proj.goldencode.com/projects/p2j/wiki/OPEN-MIME-RESOURCE#section-3">https://proj.goldencode.com/projects/p2j/wiki/OPEN-MIME-RESOURCE#section-3</a>.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=824472020-01-06T15:57:34ZGreg Shah
<ul></ul><p>I made some additional edits. Also, please note that the FWD implementation details are now also out of date.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=830822020-01-21T14:24:52ZGreg Shah
<ul></ul><p>3809e was merged to trunk as revision 11340.</p>
<p>Sergey: Please update the FWD implementation details in the OPEN-MIME-TYPE documentation so that it is complete. Remember that we can't delete the old documentation, we just have to make it clear that as of revision 11340 there is a different implementation. Please read my edits to the docs so that you have an idea how to format this.</p>
<p>Once the documentation is complete I will close this task.</p> User Interface - Feature #4077: add option to OPEN-MIME-RESOURCE to delete the original source file when the send is completehttps://proj.goldencode.com/issues/4077?journal_id=835132020-01-31T18:33:04ZGreg Shah
<ul><li><strong>Status</strong> changed from <i>Test</i> to <i>Closed</i></li></ul>