Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup in the CobblerXMLRPCHelper class #9360

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
package com.redhat.rhn.manager.kickstart.cobbler;

import com.redhat.rhn.common.RhnRuntimeException;
import com.redhat.rhn.common.conf.ConfigDefaults;
import com.redhat.rhn.common.util.MethodUtil;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.frontend.integration.IntegrationService;
import com.redhat.rhn.frontend.xmlrpc.util.XMLRPCInvoker;
Expand All @@ -41,8 +41,8 @@
*/
public class CobblerXMLRPCHelper implements XMLRPCInvoker {

private XmlRpcClient client;
private static Logger log = LogManager.getLogger(CobblerXMLRPCHelper.class);
private final XmlRpcClient client;
private static final Logger log = LogManager.getLogger(CobblerXMLRPCHelper.class);
/**
* Constructor
*/
Expand All @@ -51,7 +51,7 @@ public CobblerXMLRPCHelper() {
client = new XmlRpcClient(getCobblerUrl(), false);
}
catch (MalformedURLException e) {
throw new RuntimeException(e);
throw new RhnRuntimeException(e);
}
}

Expand All @@ -70,7 +70,7 @@ public Object invokeMethod(String procedureName, List args) throws XmlRpcFault {
retval = client.invoke(procedureName, args);
}
catch (XmlRpcException e) {
throw new RuntimeException("XmlRpcException calling cobbler.", e);
throw new RhnRuntimeException("XmlRpcException calling cobbler.", e);
}
return retval;
}
Expand All @@ -90,17 +90,12 @@ public static CobblerConnection getConnection(User user) {
* @return the autehnticated cobbler connection
*/
public static CobblerConnection getConnection(String userName) {
String token =
IntegrationService.get().getAuthToken(userName);
return (CobblerConnection)MethodUtil.getClassFromConfig(
CobblerConnection.class.getName(),
ConfigDefaults.get().getCobblerServerUrl(), token);
String token = IntegrationService.get().getAuthToken(userName);
return new CobblerConnection(ConfigDefaults.get().getCobblerServerUrl(), token);
}

private static String getCobblerUrl() {
CobblerConnection conn = (CobblerConnection)MethodUtil.getClassFromConfig(
CobblerConnection.class.getName(),
ConfigDefaults.get().getCobblerServerUrl());
CobblerConnection conn = new CobblerConnection(ConfigDefaults.get().getCobblerServerUrl());
return conn.getUrl();
}

Expand All @@ -112,15 +107,4 @@ private static String getCobblerUrl() {
public static CobblerConnection getAutomatedConnection() {
return getConnection(ConfigDefaults.get().getCobblerAutomatedUser());
}

/**
* Returns the cobbler version number
* @return the cobbler version number
*/
public static Double getCobblerVersion() {
CobblerConnection connection =
getConnection(ConfigDefaults.get().getCobblerAutomatedUser());

return connection.getVersion();
}
}
Loading