-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notification for users with disabled SCC data forwarding (jsc#SUM…
…A-431)
- Loading branch information
1 parent
dde0d80
commit 9296dff
Showing
13 changed files
with
247 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
java/code/src/com/redhat/rhn/domain/notification/types/SCCOptOutWarning.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* This software is licensed to you under the GNU General Public License, | ||
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
* along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv2. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.rhn.domain.notification.types; | ||
|
||
import com.redhat.rhn.common.localization.LocalizationService; | ||
import com.redhat.rhn.domain.notification.NotificationMessage; | ||
|
||
public class SCCOptOutWarning implements NotificationData { | ||
|
||
private static final LocalizationService LOCALIZATION_SERVICE = LocalizationService.getInstance(); | ||
|
||
@Override | ||
public NotificationMessage.NotificationMessageSeverity getSeverity() { | ||
return NotificationMessage.NotificationMessageSeverity.WARNING; | ||
} | ||
|
||
@Override | ||
public NotificationType getType() { | ||
return NotificationType.SCCOptOutWarning; | ||
} | ||
|
||
@Override | ||
public String getSummary() { | ||
return LOCALIZATION_SERVICE.getMessage("notification.sccoptoutwarning.summary"); | ||
} | ||
|
||
@Override | ||
public String getDetails() { | ||
return LOCALIZATION_SERVICE.getMessage("notification.sccoptoutwarning.detail"); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
java/code/src/com/redhat/rhn/frontend/action/satellite/SCCDataForwardingConfigAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* This software is licensed to you under the GNU General Public License, | ||
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
* along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv2. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.redhat.rhn.frontend.action.satellite; | ||
|
||
import com.redhat.rhn.common.conf.Config; | ||
import com.redhat.rhn.domain.user.User; | ||
import com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand; | ||
|
||
/** | ||
* This class extends the {@link BaseConfigAction} class to provide specific command configuration for enabling SCC | ||
* data forwarding. | ||
*/ | ||
public class SCCDataForwardingConfigAction extends BaseConfigAction { | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
protected String getCommandClassName() { | ||
return Config.get().getString( | ||
"web.com.redhat.rhn.frontend.action.satellite.GeneralConfigAction.command", | ||
"com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand" | ||
); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
@Override | ||
public ConfigureSatelliteCommand getCommand(User user) { | ||
return (ConfigureSatelliteCommand) super.getCommand(user); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
.../code/src/com/suse/manager/webui/controllers/admin/EnableSCCDataForwardingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright (c) 2024 SUSE LLC | ||
* | ||
* This software is licensed to you under the GNU General Public License, | ||
* version 2 (GPLv2). There is NO WARRANTY for this software, express or | ||
* implied, including the implied warranties of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 | ||
* along with this software; if not, see | ||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. | ||
* | ||
* Red Hat trademarks are not licensed under GPLv2. No permission is | ||
* granted to use or replicate Red Hat trademarks that are incorporated | ||
* in this software or its documentation. | ||
*/ | ||
package com.suse.manager.webui.controllers.admin; | ||
|
||
import static com.suse.manager.webui.utils.SparkApplicationHelper.withUser; | ||
import static spark.Spark.get; | ||
|
||
import com.redhat.rhn.common.conf.ConfigDefaults; | ||
import com.redhat.rhn.common.localization.LocalizationService; | ||
import com.redhat.rhn.common.security.PermissionException; | ||
import com.redhat.rhn.common.validator.ValidatorError; | ||
import com.redhat.rhn.domain.role.RoleFactory; | ||
import com.redhat.rhn.domain.user.User; | ||
import com.redhat.rhn.frontend.action.satellite.SCCDataForwardingConfigAction; | ||
import com.redhat.rhn.manager.satellite.ConfigureSatelliteCommand; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import spark.ModelAndView; | ||
import spark.Request; | ||
import spark.Response; | ||
import spark.template.jade.JadeTemplateEngine; | ||
|
||
/** | ||
* Controller class providing backend code to enable SCC data forwarding. | ||
*/ | ||
public class EnableSCCDataForwardingController { | ||
|
||
private EnableSCCDataForwardingController() { } | ||
|
||
private static final SCCDataForwardingConfigAction CONFIG_ACTION = new SCCDataForwardingConfigAction(); | ||
|
||
/** | ||
* Initializes the routes. | ||
* | ||
* @param jade the jade engine | ||
*/ | ||
public static void initRoutes(JadeTemplateEngine jade) { | ||
get("/manager/admin/enable-scc-data-forwarding", withUser(EnableSCCDataForwardingController::enable), jade); | ||
} | ||
|
||
/** | ||
* Route to enable data forwarding | ||
* @param request - the request | ||
* @param response - the response | ||
* @param user - the user | ||
* @return - jade template with confirmation message | ||
*/ | ||
public static ModelAndView enable(Request request, Response response, User user) { | ||
String message = LocalizationService.getInstance().getMessage("scc-data-forwarding.enabled"); | ||
|
||
if (!user.hasRole(RoleFactory.ORG_ADMIN)) { | ||
throw new PermissionException("Only Org Admins can change SCC data forwarding property."); | ||
} | ||
|
||
if (ConfigDefaults.get().isForwardRegistrationEnabled()) { | ||
message = LocalizationService.getInstance().getMessage("scc-data-forwarding.not-changed"); | ||
} | ||
else { | ||
ConfigureSatelliteCommand csc = CONFIG_ACTION.getCommand(user); | ||
csc.updateBoolean(ConfigDefaults.FORWARD_REGISTRATION, Boolean.TRUE); | ||
ValidatorError[] verrors = csc.storeConfiguration(); | ||
if (verrors != null && verrors.length > 0) { | ||
StringBuilder errorMsg = new StringBuilder(); | ||
errorMsg.append("The following errors happened when enabling SCC data forwarding:\n"); | ||
for (var error: verrors) { | ||
errorMsg.append(error.getLocalizedMessage()); | ||
} | ||
message = errorMsg.toString(); | ||
} | ||
} | ||
|
||
Map<String, Object> data = new HashMap<>(); | ||
data.put("message", message); | ||
return new ModelAndView(data, "templates/admin/enable-scc-data-forwarding-confirm.jade"); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
java/code/src/com/suse/manager/webui/templates/admin/enable-scc-data-forwarding-confirm.jade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
h1 #{message} | ||
p | ||
a(href="/rhn/manager/notification-messages") Return to notifications |
2 changes: 2 additions & 0 deletions
2
java/spacewalk-java.changes.welder.scc-data-forwarding-warning
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add notification for users with disabled SCC data forwarding | ||
(jsc#SUMA-431) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- Add notification for users with disabled SCC data forwarding | ||
(jsc#SUMA-431) |