Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0045768Openbravo ERPA. Platformpublic2021-01-21 11:092021-01-25 09:34
vmromanos 
cberner 
normaltrivialalways
closedfixed 
5
 
PR21Q2 
alostale
Core
No
0045768: PrintController.java, increase post() visibility
Use case: I want to extend the printing process to:
1) Run some validations before printing a record
2) Run some business logic just after printing a record

To achieve that I need to develop a custom class that extends from PrintController and override doPost() to implement my logic and then call the super.doPost().

The problem is that the doPost() runs
final VariablesSecureApp vars = new VariablesSecureApp(request);
at the beginning of the method, which makes the vars.command to be reset to "DEFAULT".

This crashes the "send by email" feature (which expects a vars.command="EMAIL").

To workaround this I could easily override the post() method, which doesn't recalculate the vars variable, and which is called by the doPost().

The problem is that post() has package visibility, so I can't override it outside its package.
Create a class that extends PrintController in an external module.
Try to override post(). It's not visible outside the package.
Change PrintController.post() visibility to public or protected.


In the future, we should add some hooks to the printing process to allow easy extensibility.
No tags attached.
depends on backport 0045775PR20Q4.2 closed cberner PrintController.java, increase post() visibility 
depends on backport 0045776PR20Q3.4 closed cberner PrintController.java, increase post() visibility 
depends on backport 0045777PR21Q1.1 closed cberner PrintController.java, increase post() visibility 
Issue History
2021-01-21 11:09vmromanosNew Issue
2021-01-21 11:09vmromanosAssigned To => platform
2021-01-21 11:09vmromanosModules => Core
2021-01-21 11:09vmromanosTriggers an Emergency Pack => No
2021-01-21 12:10cbernerAssigned Toplatform => cberner
2021-01-21 12:23hgbotNote Added: 0125710
2021-01-25 06:56alostaleStatusnew => scheduled
2021-01-25 09:32hgbotResolutionopen => fixed
2021-01-25 09:32hgbotStatusscheduled => closed
2021-01-25 09:32hgbotFixed in Version => PR21Q2
2021-01-25 09:32hgbotNote Added: 0125747
2021-01-25 09:32hgbotNote Added: 0125748
2021-01-25 09:32cbernerStatusclosed => new
2021-01-25 09:32cbernerResolutionfixed => open
2021-01-25 09:32cbernerFixed in VersionPR21Q2 =>
2021-01-25 09:33cbernerStatusnew => scheduled
2021-01-25 09:33cbernerNote Added: 0125753
2021-01-25 09:33cbernerStatusscheduled => resolved
2021-01-25 09:33cbernerFixed in Version => PR21Q2
2021-01-25 09:33cbernerFixed in SCM revision => c46750835f6e84c13e79ce45496d28a85e9acb74
2021-01-25 09:33cbernerResolutionopen => fixed
2021-01-25 09:34cbernerReview Assigned To => alostale
2021-01-25 09:34cbernerStatusresolved => closed

Notes
(0125710)
hgbot   
2021-01-21 12:23   
Merge Request created: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/269 [^]
(0125747)
hgbot   
2021-01-25 09:32   
Directly closing issue as related merge request is already approved.

Repository: https://gitlab.com/openbravo/product/openbravo [^]
Changeset: c46750835f6e84c13e79ce45496d28a85e9acb74
Author: Cristian Berner <cristian.berner@openbravo.com>
Date: 2021-01-22T14:11:34+01:00
URL: https://gitlab.com/openbravo/product/openbravo/-/commit/c46750835f6e84c13e79ce45496d28a85e9acb74 [^]

Fixes ISSUE-45768: Allow extending printing process by increasing post method visibility

post method visibility has been set to protected, previously private to
allow overriding it by methods that need to.
One use-case is to handle vars and modification to vars in this method
differently. Those vars are then passed to doPost method.

---
M src/org/openbravo/erpCommon/utility/reporting/printing/PrintController.java
---
(0125748)
hgbot   
2021-01-25 09:32   
Merge request merged: https://gitlab.com/openbravo/product/openbravo/-/merge_requests/269 [^]
(0125753)
cberner   
2021-01-25 09:33   
Opened to create backport for 21Q1