Hello Java Team, can you please give me a jump start on the Java code? I can't figure it out. Where are the packages/the number calculated and populated at /rhn/systems/SystemList.do. I found "rhn/frontend/dto/SystemOverview.java" and "BaseDto" but they contain no loading logic. "setOutdatedPackages" from SystemOverview.java is not being used anywhere. I want to have a look if/how it is feasible to (conditionally?) filter out modular packages to make the overview look nicer. Thank you and best wishes, Stefan
Hi Let's do a deep dive how to follow the java path Starting point is the URL /rhn/systems/SystemList.do - check struts config: java/code/webapp/WEB-INF/struts-config.xml => you can find action path: <action path="/systems/SystemList" scope="request" input="/WEB-INF/pages/systems/systemlist.jsp" type="com.redhat.rhn.frontend.action.systems.SystemListSetupAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <set-property property="postRequiredIfSubmitted" value="true" /> <forward name="default" path="/WEB-INF/pages/systems/systemlist.jsp"/> </action> "type" is the java class which is called when this page is shown. Look now in SystemListSetupAction. - This class has only 1 function getDataResult() which is calling SystemManager.systemList() - Looking into com.redhat.rhn.manager.system.SystemManager systemList() method you can find: SelectMode m = ModeFactory.getMode("System_queries", "visible_to_user"); Map<String, Object> params = new HashMap<String, Object>(); params.put("user_id", user.getId()); Map<String, Object> elabParams = new HashMap<String, Object>(); return makeDataResult(params, elabParams, pc, m, SystemOverview.class); The mode query "visible_to_user" is executed which is defined in file java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml Here you can find the SQL query which is executed, but "there is always another level of indirection":-) <mode name="visible_to_user" class="com.redhat.rhn.frontend.dto.SystemOverview"> <query name="available_to_user" /> <elaborator name="system_overview" /> <elaborator name="system_config_files_with_diffs" /> <elaborator name="entitlements"/> <elaborator name="is_virtual_guest" /> <elaborator name="is_virtual_host" /> </mode> The "query" is "available_to_user" (in the same file) <query name="available_to_user" params="user_id"> SELECT DISTINCT S.id, S.name, (SELECT 1 FROM rhnServerFeaturesView SFV WHERE SFV.server_id = S.id AND SFV.label = 'ftr_system_grouping') AS selectable FROM rhnServer S inner join rhnUserServerPerms USP on S.id = USP.server_id WHERE USP.user_id = :user_id </query> After this is executed, 5 elaborators are executed on the result. E.g. "system_overview". That query can be found again in the same file: <query name="system_overview" params=""> SELECT SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME, security_errata, bug_errata, enhancement_errata, SERVER_ADMINS, GROUP_COUNT, MODIFIED, CHANNEL_LABELS, CHANNEL_ID, HISTORY_COUNT, LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE, SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED, PROXY_ID AS IS_PROXY FROM rhnServerOverview WHERE server_id IN (%s) ORDER BY UPPER(COALESCE(SERVER_NAME, '(none)')), SERVER_ID </query> The "server_id IN (%s)" is filled with the result of the main query (S.id) but only page by page. If your page is showing 25 systems, only the first 25 IDs are inserted here. When you click in the UI on "next page", the next 25 IDs are used. "rhnServerOverview" is a view which is specified in schema/spacewalk/common/views/rhnServerOverview.sql All these data are filled in the DTO class specified in the main query. To find out which data are used in the UI, you need to check the JSP package. Have again a look in the struts config and you can find the page input="/WEB-INF/pages/systems/systemlist.jsp" Full path is: java/code/webapp/WEB-INF/pages/systems/systemlist.jsp This file "include" a fragment file="/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf" Here you can see that "current.outdatedPackages" is used. I hope it helps. Am Mittwoch, 5. Januar 2022, 11:26:21 CET schrieb Stefan Bluhm:
Hello Java Team,
can you please give me a jump start on the Java code? I can't figure it out.
Where are the packages/the number calculated and populated at /rhn/systems/SystemList.do. I found "rhn/frontend/dto/SystemOverview.java" and "BaseDto" but they contain no loading logic. "setOutdatedPackages" from SystemOverview.java is not being used anywhere.
I want to have a look if/how it is feasible to (conditionally?) filter out modular packages to make the overview look nicer.
Thank you and best wishes,
Stefan
-- Regards Michael Calmer -------------------------------------------------------------------------- Michael Calmer SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, D-90409 Nuernberg T: +49 (0) 911 74053 0 F: +49 (0) 911 74053575 - e-mail: Michael.Calmer@suse.com -------------------------------------------------------------------------- SUSE Software Solutions Germany GmbH, GF: Ivo Totev (HRB 36809, AG Nürnberg)
Big Thank You Michael for taking the time and doing all the thinking for me! This really helps! ----- Ursprüngliche Mail ----- Von: "Michael Calmer" An: "devel" <devel@lists.uyuni-project.org> Gesendet: Mittwoch, 5. Januar 2022 12:33:23 Betreff: Re: Java package logic location Hi Let's do a deep dive how to follow the java path Starting point is the URL /rhn/systems/SystemList.do - check struts config: java/code/webapp/WEB-INF/struts-config.xml => you can find action path: <action path="/systems/SystemList" scope="request" input="/WEB-INF/pages/systems/systemlist.jsp" type="com.redhat.rhn.frontend.action.systems.SystemListSetupAction" className="com.redhat.rhn.frontend.struts.RhnActionMapping"> <set-property property="postRequiredIfSubmitted" value="true" /> <forward name="default" path="/WEB-INF/pages/systems/systemlist.jsp"/> </action> "type" is the java class which is called when this page is shown. Look now in SystemListSetupAction. - This class has only 1 function getDataResult() which is calling SystemManager.systemList() - Looking into com.redhat.rhn.manager.system.SystemManager systemList() method you can find: SelectMode m = ModeFactory.getMode("System_queries", "visible_to_user"); Map<String, Object> params = new HashMap<String, Object>(); params.put("user_id", user.getId()); Map<String, Object> elabParams = new HashMap<String, Object>(); return makeDataResult(params, elabParams, pc, m, SystemOverview.class); The mode query "visible_to_user" is executed which is defined in file java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml Here you can find the SQL query which is executed, but "there is always another level of indirection":-) <mode name="visible_to_user" class="com.redhat.rhn.frontend.dto.SystemOverview"> <query name="available_to_user" /> <elaborator name="system_overview" /> <elaborator name="system_config_files_with_diffs" /> <elaborator name="entitlements"/> <elaborator name="is_virtual_guest" /> <elaborator name="is_virtual_host" /> </mode> The "query" is "available_to_user" (in the same file) <query name="available_to_user" params="user_id"> SELECT DISTINCT S.id, S.name, (SELECT 1 FROM rhnServerFeaturesView SFV WHERE SFV.server_id = S.id AND SFV.label = 'ftr_system_grouping') AS selectable FROM rhnServer S inner join rhnUserServerPerms USP on S.id = USP.server_id WHERE USP.user_id = :user_id </query> After this is executed, 5 elaborators are executed on the result. E.g. "system_overview". That query can be found again in the same file: <query name="system_overview" params=""> SELECT SERVER_ID AS ID, OUTDATED_PACKAGES, SERVER_NAME, security_errata, bug_errata, enhancement_errata, SERVER_ADMINS, GROUP_COUNT, MODIFIED, CHANNEL_LABELS, CHANNEL_ID, HISTORY_COUNT, LAST_CHECKIN_DAYS_AGO, PENDING_UPDATES, OS, RELEASE, SERVER_ARCH_NAME, LAST_CHECKIN, LOCKED, PROXY_ID AS IS_PROXY FROM rhnServerOverview WHERE server_id IN (%s) ORDER BY UPPER(COALESCE(SERVER_NAME, '(none)')), SERVER_ID </query> The "server_id IN (%s)" is filled with the result of the main query (S.id) but only page by page. If your page is showing 25 systems, only the first 25 IDs are inserted here. When you click in the UI on "next page", the next 25 IDs are used. "rhnServerOverview" is a view which is specified in schema/spacewalk/common/views/rhnServerOverview.sql All these data are filled in the DTO class specified in the main query. To find out which data are used in the UI, you need to check the JSP package. Have again a look in the struts config and you can find the page input="/WEB-INF/pages/systems/systemlist.jsp" Full path is: java/code/webapp/WEB-INF/pages/systems/systemlist.jsp This file "include" a fragment file="/WEB-INF/pages/common/fragments/systems/system_listdisplay.jspf" Here you can see that "current.outdatedPackages" is used. I hope it helps. Am Mittwoch, 5. Januar 2022, 11:26:21 CET schrieb Stefan Bluhm:
Hello Java Team,
can you please give me a jump start on the Java code? I can't figure it out.
Where are the packages/the number calculated and populated at /rhn/systems/SystemList.do. I found "rhn/frontend/dto/SystemOverview.java" and "BaseDto" but they contain no loading logic. "setOutdatedPackages" from SystemOverview.java is not being used anywhere.
I want to have a look if/how it is feasible to (conditionally?) filter out modular packages to make the overview look nicer.
Thank you and best wishes,
Stefan
-- Regards Michael Calmer -------------------------------------------------------------------------- Michael Calmer SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, D-90409 Nuernberg T: +49 (0) 911 74053 0 F: +49 (0) 911 74053575 - e-mail: Michael.Calmer@suse.com -------------------------------------------------------------------------- SUSE Software Solutions Germany GmbH, GF: Ivo Totev (HRB 36809, AG Nürnberg)
participants (2)
-
Michael Calmer
-
Stefan Bluhm