Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 293747 - [Help][Print]Add maximum printed topics and maximum connections to the preference to optimize the quick print operation
Summary: [Help][Print]Add maximum printed topics and maximum connections to the prefer...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: User Assistance (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M3   Edit
Assignee: Hao Zhang CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 171987 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-29 23:07 EDT by Hao Zhang CLA
Modified: 2010-11-01 21:21 EDT (History)
3 users (show)

See Also:


Attachments
Patch V1 (25.29 KB, patch)
2009-11-15 21:48 EST, Hao Zhang CLA
no flags Details | Diff
Patch V2 (28.39 KB, patch)
2009-11-18 09:46 EST, Hao Zhang CLA
no flags Details | Diff
Patch V3 (28.39 KB, patch)
2009-11-18 09:57 EST, Hao Zhang CLA
cgold: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hao Zhang CLA 2009-10-29 23:07:23 EDT
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
Build Identifier: 

Some enhancement in the quick print function. Add maximum printed topics and maximum connections to the preference to optimize the quick print operation. So that block issue would be prevent when overload condition occur.

Reproducible: Always
Comment 1 Chris Goldthorpe CLA 2009-10-30 18:10:55 EDT
This enhancement seems useful for limiting the memory consumed on the server when printing.
Comment 2 Hao Zhang CLA 2009-11-15 21:48:50 EST
Created attachment 152257 [details]
Patch V1

I have added parameter maxConnections & maxTopics.
So that the performance could be enhanced in aspect of 'print selected topic and all subtopics'.
Comment 3 Chris Goldthorpe CLA 2009-11-17 18:48:50 EST
I have tested the code and it is working. I also could not see any potential XSS vulnerabilities in the jsp files I did notice a few things that should be changed:

1. Mismatched html tags. I examined the html when printing Workbench User Guide > Getting started > Basic tutorial > Editors and Views. I saw this html early in the file:


<body dir="ltr" onload="print()">
<div id="toc"><h1>Editors and views</h1><h2>Contents</h2><div id="toc_content"><div class="toc_entry">1. <a href="#section1">Editors</a></div><div class="toc_entry">2. <a href="#section2">Views</a></div></div></div><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html lang="en">

<HEAD>

and this at the end:


</BODY>
</HTML>

</body>
</html>

It appears that the </body> and </html> at the end of the file should appear much earlier.

2. The new preferences need to be documented in the help page /org.eclipse.platform.doc.isv/guide/ua_help_setup_preferences.htm

3. In PrintData.generateResources() there is a synchronized section of code that contains these lines:

  RequestDispatcher rd = context.getRequestDispatcher("/advanced/printError.jsp"); //$NON-NLS-1$
  request.setAttribute("msg", "noConnection"); //$NON-NLS-1$ //$NON-NLS-2$
  rd.forward(request, response);

while I don't know if any of these could cause a problem it is always good to have as few lines as possible in a synchronized area. This could be accomplished by adding functions like

	private static boolean synchronized getLock() {
		if (allowedConnections > 0) {
			allowedConnections--;
			return true;
		}
		return false;
	}

        private static boolean synchronized releaseLock() {
            allowedConnections++;
        }

and replacing the start of generateResources() with 

	public void generateResources(Writer out) throws IOException, ServletException {
		if (!getLock()) {
			RequestDispatcher rd = context.getRequestDispatcher("/advanced/printError.jsp"); //$NON-NLS-1$
			request.setAttribute("msg", "noConnection"); //$NON-NLS-1$ //$NON-NLS-2$
			rd.forward(request, response);
			return;
		}

so that the synchronized area is minimized. 

I also have a couple of suggestions:

4. I think that there should be a value of maxTopics which can be used to indicate no limit, for example a value of 0 could mean there is no limit.
5. The defaults are 100 for maxTopics and 50 for maxConnections, maybe maxTopics should be higher (500) and maxConnections lower (5).
6. Have you thought about having a way for the user to print a large book in sections so that an entire book can still be printed?
Comment 4 Hao Zhang CLA 2009-11-18 09:46:48 EST
Created attachment 152474 [details]
Patch V2
Comment 5 Hao Zhang CLA 2009-11-18 09:57:16 EST
Created attachment 152477 [details]
Patch V3

Sorry, patch v2 is submitted by mistake.
Here is the latest patch.
Comment 6 Hao Zhang CLA 2009-11-18 10:35:54 EST
Hi Chirs,

I've updated the patch.

For question 1, I modified print.jsp and the method generateToc in PrintData.
Now, mismatched html tags will not occur.

For question 2, I've added these two parameters in /org.eclipse.platform.doc.isv/guide/ua_help_setup_preferences.htm.

For question 3, that's really a good refactor of synchronize section. I've refactor related code in PrintData.
To reproduce the 'noConnection error', you can follow this step:
* Set maxConnection as 1
* Open Firefox, Perform print task with large amount of topics
* Meanwhile, perform the same task in IE ASAP.
Then task will be successfully done in FF. And in IE, 'noConnection' alert will display.

For question 5, I've set default of maxTopics as 500, and default of maxConnections as 10.

For question 4 and 6, now user can set maxTopics a large value to realize this.
Cause lack of perfect solution at present, maybe we could make an enhancement on this issue in the future.
Comment 7 Chris Goldthorpe CLA 2009-11-18 14:14:42 EST
Patch committed to HEAD, Fixed.
Comment 8 Hao Zhang CLA 2010-11-01 21:21:15 EDT
*** Bug 171987 has been marked as a duplicate of this bug. ***