-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # java/code/src/com/suse/manager/webui/services/SaltServerActionService.java
- Loading branch information
Showing
73 changed files
with
4,743 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2025 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.common; | ||
|
||
public class RhnCustomError { | ||
private final String message; | ||
|
||
public RhnCustomError(String messageIn) { | ||
this.message = messageIn; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
} |
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,66 @@ | ||
/* | ||
* Copyright (c) 2025 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.common; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class RhnErrorReport { | ||
private final List<RhnCustomError> errors = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
/** | ||
* Registers a new error in the error report. | ||
* | ||
* @param message The error message. | ||
*/ | ||
public void register(String message) { | ||
errors.add(new RhnCustomError(message)); | ||
} | ||
|
||
/** | ||
* Checks if any errors have been registered. | ||
* | ||
* @return true if there are errors; false otherwise. | ||
*/ | ||
public boolean hasErrors() { | ||
return !errors.isEmpty(); | ||
} | ||
|
||
/** | ||
* Returns a copy of the current list of errors. | ||
* | ||
* @return A copy of the errors list. | ||
*/ | ||
public List<RhnCustomError> getErrors() { | ||
return new ArrayList<>(errors); | ||
} | ||
|
||
/** | ||
* Logs the errors following a RhnReportStrategy. | ||
* @param strategy The reporting strategy. | ||
*/ | ||
public void report(RhnReportStrategy<RhnCustomError> strategy) { | ||
strategy.report(errors); | ||
} | ||
|
||
/** | ||
* Logs the errors using the default validation reporting strategy. | ||
*/ | ||
public void report() { | ||
ErrorReportingStrategies.validationReportingStrategy().report(errors); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
java/code/src/com/redhat/rhn/common/RhnGeneralException.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,34 @@ | ||
/* | ||
* Copyright (c) 2025 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.common; | ||
|
||
import java.util.List; | ||
|
||
public class RhnGeneralException extends RuntimeException { | ||
private List<RhnCustomError> errors; | ||
|
||
/** | ||
* Constructor | ||
* @param errorsIn the list of errors | ||
*/ | ||
public RhnGeneralException(List<RhnCustomError> errorsIn) { | ||
this.errors = errorsIn; | ||
} | ||
|
||
public List<RhnCustomError> getErrors() { | ||
return errors; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
java/code/src/com/redhat/rhn/common/RhnReportStrategy.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,27 @@ | ||
/* | ||
* Copyright (c) 2025 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.common; | ||
|
||
import java.util.List; | ||
|
||
public interface RhnReportStrategy<E> { | ||
|
||
/** | ||
* Report a list of errors | ||
* @param errors the list of errors | ||
*/ | ||
void report(List<E> errors); | ||
|
||
} |
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
75 changes: 75 additions & 0 deletions
75
java/code/src/com/redhat/rhn/domain/action/ProxyConfigurationApplyAction.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,75 @@ | ||
/* | ||
* Copyright (c) 2025 SUSE LLC | ||
* Copyright (c) 2009--2010 Red Hat, Inc. | ||
* | ||
* 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.action; | ||
|
||
|
||
import com.redhat.rhn.domain.server.MinionSummary; | ||
import com.redhat.rhn.domain.server.Pillar; | ||
|
||
import com.suse.manager.webui.services.SaltServerActionService; | ||
import com.suse.proxy.ProxyConfigUtils; | ||
import com.suse.salt.netapi.calls.LocalCall; | ||
import com.suse.salt.netapi.calls.modules.State; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* ProxyConfigurationApply - Class representing TYPE_PROXY_CONFIGURATION_APPLY action | ||
*/ | ||
public class ProxyConfigurationApplyAction extends Action { | ||
|
||
private final Pillar pillar; | ||
private final Map<String, Object> proxyConfigFiles; | ||
|
||
/** | ||
* Default constructor | ||
* @param pillarIn the pillar | ||
* @param proxyConfigFilesIn the proxy configuration files | ||
*/ | ||
public ProxyConfigurationApplyAction(Pillar pillarIn, Map<String, Object> proxyConfigFilesIn) { | ||
this.setActionType(ActionFactory.TYPE_PROXY_CONFIGURATION_APPLY); | ||
this.pillar = pillarIn; | ||
this.proxyConfigFiles = proxyConfigFilesIn; | ||
} | ||
|
||
public Pillar getPillar() { | ||
return pillar; | ||
} | ||
|
||
public Map<String, Object> getProxyConfigFiles() { | ||
return proxyConfigFiles; | ||
} | ||
|
||
/** | ||
* Get the apply_proxy_config local call | ||
* @param minions the minions | ||
* @return the apply_proxy_config local call | ||
*/ | ||
public Map<LocalCall<?>, List<MinionSummary>> getApplyProxyConfigAction(List<MinionSummary> minions) { | ||
Map<String, Object> data = new HashMap<>(); | ||
data.putAll(ProxyConfigUtils.applyProxyConfigDataFromPillar(getPillar())); | ||
data.putAll(getProxyConfigFiles()); | ||
|
||
return Map.of( | ||
State.apply(Collections.singletonList(SaltServerActionService.APPLY_PROXY_CONFIG), Optional.of(data)), | ||
minions | ||
); | ||
} | ||
} |
Oops, something went wrong.