Skip to content

Commit 781ca87

Browse files
committed
Address PR review feedback
- Update migration script to use the existing 'systems.software.appstreams' RBAC namespace instead of creating a new one. - Fix typo in the endpoint path within the migration script. - Remove unnecessary DISTINCT clause from LIST_SSM_SERVERS_IN_CHANNEL_SQL query. - Rename 'getAppStreamChannelFromPath' to 'resolveAppStreamChannel'. - Change invalid channel handling to use 'response.redirect' instead of a server-side forward, ensuring the URL matches the view. - Add a shortcut link to the SSM Overview tab.
1 parent 397170f commit 781ca87

File tree

7 files changed

+36
-26
lines changed

7 files changed

+36
-26
lines changed

java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4657,6 +4657,12 @@ organization. You may grant or remove the organization administrator role in the
46574657
<context context-type="sourcefile">/rhn/ssm/Index.do</context>
46584658
</context-group>
46594659
</trans-unit>
4660+
<trans-unit id="ssm.overview.appstreams">
4661+
<source>AppStreams</source>
4662+
</trans-unit>
4663+
<trans-unit id="ssm.overview.appstreams.manage">
4664+
<source>&lt;a href="/rhn/manager/systems/ssm/appstreams"&gt;Enable and disable&lt;/a&gt; AppStreams on the selected systems</source>
4665+
</trans-unit>
46604666
<trans-unit id="ssm.overview.product_migration">
46614667
<source>Product Migration</source>
46624668
</trans-unit>

java/code/src/com/redhat/rhn/manager/ssm/SsmManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public class SsmManager {
7777
public static final String SSM_SYSTEM_FEATURE = "ftr_system_grouping";
7878

7979
private static final String LIST_SSM_SERVERS_IN_CHANNEL_SQL = """
80-
SELECT DISTINCT ST.element as server_id
80+
SELECT ST.element as server_id
8181
FROM rhnSet ST
8282
JOIN rhnServerChannel rsc ON ST.element = rsc.server_id
8383
WHERE ST.user_id = :user_id

java/code/src/com/suse/manager/webui/controllers/appstreams/AppStreamsController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,10 @@ public static String getPackagesInModule(Request req, Response res, User user) {
244244
* @return the ModelAndView object to render the page
245245
*/
246246
public static ModelAndView ssmConfigureAppstreams(Request request, Response response, User user) {
247-
var channel = getAppStreamChannelFromPath(user, request.params("channelId"));
247+
var channel = resolveAppStreamChannel(user, request.params("channelId"));
248248
if (channel == null) {
249-
return ssmAppstreamsChannelSelection(request, response, user);
249+
response.redirect("/manager/systems/ssm/appstreams");
250+
return null;
250251
}
251252
var ssmAppStreams = AppStreamsManager.listSsmChannelAppStreams(channel.getId(), user);
252253
Map<String, Set<SsmAppStreamModuleResponse>> modulesMap = new HashMap<>();
@@ -284,7 +285,7 @@ public static ModelAndView ssmAppstreamsChannelSelection(Request request, Respon
284285
return new ModelAndView(data, "templates/ssm/appstreams-channel-selection.jade");
285286
}
286287

287-
private static ChannelAppStreamsJson getAppStreamChannelFromPath(User user, String channelId) {
288+
private static ChannelAppStreamsJson resolveAppStreamChannel(User user, String channelId) {
288289
if (channelId == null) {
289290
LOG.warn("Invalid request, no channelId parameter");
290291
return null;

java/code/webapp/WEB-INF/pages/ssm/ssmindex.jsp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@
6565
</div>
6666
</li>
6767
</rhn:require>
68+
<rhn:require acl="all_systems_in_set_have_feature(ftr_package_updates)">
69+
<li class="list-group-item">
70+
<div class="row">
71+
<div class="col-sm-2">
72+
<rhn:icon type="system-state" title="ssm.overview.appstreams" />
73+
<bean:message key="ssm.overview.appstreams"/>
74+
</div>
75+
<div class="col-sm-10">
76+
<bean:message key="ssm.overview.appstreams.manage"/>
77+
</div>
78+
</div>
79+
</li>
80+
</rhn:require>
6881
<rhn:require acl="authorized_for(systems.software.migration); all_systems_in_set_have_feature(ftr_package_updates)">
6982
<li class="list-group-item">
7083
<div class="row">

schema/spacewalk/common/data/endpointNamespace.sql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5225,31 +5225,31 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52255225
INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52265226
SELECT ns.id, ep.id
52275227
FROM access.namespace ns, access.endpoint ep
5228-
WHERE ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
5228+
WHERE ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
52295229
AND ep.endpoint = '/rhn/manager/systems/ssm/appstreams' AND ep.http_method = 'GET'
52305230
ON CONFLICT DO NOTHING;
52315231
INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52325232
SELECT ns.id, ep.id
52335233
FROM access.namespace ns, access.endpoint ep
5234-
WHERE ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
5234+
WHERE ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
52355235
AND ep.endpoint = '/rhn/manager/systems/ssm/appstreams/configure/:channelId' AND ep.http_method = 'GET'
52365236
ON CONFLICT (endpoint_id, namespace_id) DO NOTHING;
52375237
INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52385238
SELECT ns.id, ep.id
52395239
FROM access.namespace ns, access.endpoint ep
5240-
WHERE ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
5240+
WHERE ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
52415241
AND ep.endpoint = '/rhn/manager/api/ssm/appstreams/save' AND ep.http_method = 'POST'
52425242
ON CONFLICT (endpoint_id, namespace_id) DO NOTHING;
52435243
INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52445244
SELECT ns.id, ep.id
52455245
FROM access.namespace ns, access.endpoint ep
5246-
WHERE ns.namespace = 'system.appstreams' AND ns.access_mode = 'W'
5247-
AND ep.endpoint = '/rhn/manager/system/api/appstreams/ssmEnable' AND ep.http_method = 'POST'
5246+
WHERE ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
5247+
AND ep.endpoint = '/rhn/manager/api/system/appstreams/ssmEnable' AND ep.http_method = 'POST'
52485248
ON CONFLICT (endpoint_id, namespace_id) DO NOTHING;
52495249
INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
52505250
SELECT ns.id, ep.id
52515251
FROM access.namespace ns, access.endpoint ep
5252-
WHERE ns.namespace = 'system.appstreams' AND ns.access_mode = 'W'
5252+
WHERE ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
52535253
AND ep.endpoint = '/rhn/manager/api/system/appstreams/ssmDisable' AND ep.http_method = 'POST'
52545254
ON CONFLICT (endpoint_id, namespace_id) DO NOTHING;
52555255

schema/spacewalk/common/data/namespace.sql

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,6 @@ INSERT INTO access.namespace (namespace, access_mode, description)
687687
INSERT INTO access.namespace (namespace, access_mode, description)
688688
VALUES ('systems.migration', 'W', 'Perform product migration on systems')
689689
ON CONFLICT (namespace, access_mode) DO NOTHING;
690-
INSERT INTO access.namespace (namespace, access_mode, description)
691-
VALUES ('systems.appstreams', 'W', 'Manage AppStreams on systems (SSM)')
692-
ON CONFLICT (namespace, access_mode) DO NOTHING;
693690
INSERT INTO access.namespace (namespace, access_mode, description)
694691
VALUES ('users.list.active', 'R', NULL)
695692
ON CONFLICT (namespace, access_mode) DO NOTHING;

schema/spacewalk/upgrade/susemanager-schema-5.2.1-to-susemanager-schema-5.2.2/100-ssm-appstreams-rbac.sql

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
INSERT INTO access.namespace (namespace, access_mode, description)
2-
SELECT 'systems.appstreams', 'W', 'Manage AppStreams on systems (SSM)'
3-
WHERE NOT EXISTS (
4-
SELECT 1 FROM access.namespace
5-
WHERE namespace = 'systems.appstreams' AND access_mode = 'W'
6-
);
7-
81
INSERT INTO access.endpoint (class_method, endpoint, http_method, scope, auth_required)
92
SELECT '', '/rhn/manager/systems/ssm/appstreams', 'GET', 'W', True
103
WHERE NOT EXISTS (
@@ -50,7 +43,7 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
5043
SELECT ns.id, ep.id
5144
FROM access.namespace ns, access.endpoint ep
5245
WHERE
53-
ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
46+
ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
5447
AND ep.endpoint = '/rhn/manager/systems/ssm/appstreams' AND ep.http_method = 'GET'
5548
AND NOT EXISTS (
5649
SELECT 1 FROM access.endpointNamespace en
@@ -61,7 +54,7 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
6154
SELECT ns.id, ep.id
6255
FROM access.namespace ns, access.endpoint ep
6356
WHERE
64-
ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
57+
ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
6558
AND ep.endpoint = '/rhn/manager/systems/ssm/appstreams/configure/:channelId' AND ep.http_method = 'GET'
6659
AND NOT EXISTS (
6760
SELECT 1 FROM access.endpointNamespace en
@@ -72,7 +65,7 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
7265
SELECT ns.id, ep.id
7366
FROM access.namespace ns, access.endpoint ep
7467
WHERE
75-
ns.namespace = 'systems.appstreams' AND ns.access_mode = 'W'
68+
ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
7669
AND ep.endpoint = '/rhn/manager/api/ssm/appstreams/save' AND ep.http_method = 'POST'
7770
AND NOT EXISTS (
7871
SELECT 1 FROM access.endpointNamespace en
@@ -83,8 +76,8 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
8376
SELECT ns.id, ep.id
8477
FROM access.namespace ns, access.endpoint ep
8578
WHERE
86-
ns.namespace = 'system.appstreams' AND ns.access_mode = 'W'
87-
AND ep.endpoint = '/rhn/manager/system/api/appstreams/ssmEnable' AND ep.http_method = 'POST'
79+
ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
80+
AND ep.endpoint = '/rhn/manager/api/system/appstreams/ssmEnable' AND ep.http_method = 'POST'
8881
AND NOT EXISTS (
8982
SELECT 1 FROM access.endpointNamespace en
9083
WHERE en.namespace_id = ns.id AND en.endpoint_id = ep.id
@@ -94,7 +87,7 @@ INSERT INTO access.endpointNamespace (namespace_id, endpoint_id)
9487
SELECT ns.id, ep.id
9588
FROM access.namespace ns, access.endpoint ep
9689
WHERE
97-
ns.namespace = 'system.appstreams' AND ns.access_mode = 'W'
90+
ns.namespace = 'systems.software.appstreams' AND ns.access_mode = 'W'
9891
AND ep.endpoint = '/rhn/manager/api/system/appstreams/ssmDisable' AND ep.http_method = 'POST'
9992
AND NOT EXISTS (
10093
SELECT 1 FROM access.endpointNamespace en

0 commit comments

Comments
 (0)