Skip to content

Commit

Permalink
Merge branch 'master' into master-weblate
Browse files Browse the repository at this point in the history
  • Loading branch information
mackdk committed Jul 21, 2023
2 parents 547aec7 + 6fa0729 commit 4a95864
Show file tree
Hide file tree
Showing 76 changed files with 705 additions and 270 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/acceptance_tests_secondary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- '.github/workflows/acceptance_tests_secondary.yml'
- '.github/workflows/acceptance_tests_common.yml'
- '!java/*.changes*'
schedule:
- cron: '0 6 * * *'
jobs:
test-uyuni:
uses: ./.github/workflows/acceptance_tests_common.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/acceptance_tests_secondary_parallel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
- '.github/workflows/acceptance_tests_secondary_parallel.yml'
- '.github/workflows/acceptance_tests_common.yml'
- '!java/*.changes*'
schedule:
- cron: '0 6 * * *'
jobs:
test-uyuni:
uses: ./.github/workflows/acceptance_tests_common.yml
Expand Down
3 changes: 2 additions & 1 deletion java/buildconf/build-props.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@

<available file="${java.lib.dir}/log4j/log4j-core.jar" type="file" property="log4j-core" value="log4j/log4j-core" />
<available file="${java.lib.dir}/log4j/log4j-api.jar" type="file" property="log4j-api" value="log4j/log4j-api" />
<property name="log4j-jars" value="${log4j-core} ${log4j-api}"/>
<available file="${java.lib.dir}/log4j/log4j-jcl.jar" type="file" property="log4j-jcl" value="log4j/log4j-jcl" />
<property name="log4j-jars" value="${log4j-core} ${log4j-api} ${log4j-jcl}"/>

<condition property="jta11-jars" value="geronimo-jta-1.1-api" else="jta">
<available file="${java.lib.dir}/geronimo-jta-1.1-api.jar" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@

import org.hibernate.Session;

import java.io.Serializable;
import java.util.List;


/**
* Elaboratable
*/
public interface Elaborator {
public interface Elaborator extends Serializable {

/**
* Returns an elaborated list for the given List of objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

import org.hibernate.Session;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
* ModeElaborator
*/
public class ModeElaborator implements Elaborator, Serializable {
public class ModeElaborator implements Elaborator {
private SelectMode mode;
private Map params;
private final HashMap<String, Object> params;

// increase this number on any data change
private static final long serialVersionUID = 1L;
Expand All @@ -36,9 +36,14 @@ public class ModeElaborator implements Elaborator, Serializable {
* @param select Select mode
* @param elabParams elaborator params
*/
public ModeElaborator(SelectMode select, Map elabParams) {
public ModeElaborator(SelectMode select, Map<String, Object> elabParams) {
mode = select;
params = elabParams;
if (elabParams != null) {
params = new HashMap<>(elabParams);
}
else {
params = null;
}
}

/**
Expand Down
5 changes: 0 additions & 5 deletions java/code/src/com/redhat/rhn/common/security/SessionSwap.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,6 @@ public static String rhnHmacData(List<String> text) {

String joinedText = StringUtils.join(text.iterator(), "\0");


if (log.isDebugEnabled()) {
log.debug("Data : [{}]", joinedText);
log.debug("Key : [{}]", swapKey);
}
String retval = HMAC.sha256(joinedText, swapKey.toString());
if (log.isDebugEnabled()) {
log.debug("retval: {}", retval);
Expand Down
16 changes: 15 additions & 1 deletion java/code/src/com/redhat/rhn/common/util/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ public static void setAttributes(Path path, String user, String group, Set<Posix
* @return String containing file.
*/
public static String readStringFromFile(String path) {
return readStringFromFile(path, false);
}


/**
* Read a file off disk into a String and return it.
*
* Expect weird stuff if the file is not textual.
*
* @param path of file to read in
* @param noLog don't log the content of the file
* @return String containing file.
*/
public static String readStringFromFile(String path, boolean noLog) {
if (log.isDebugEnabled()) {
log.debug("readStringFromFile: {}", StringUtil.sanitizeLogInput(path));
}
Expand All @@ -125,7 +139,7 @@ public static String readStringFromFile(String path) {
StringWriter writer = new StringWriter();
IOUtils.getInstance().copyWriter(input, writer);
String contents = writer.toString();
if (log.isDebugEnabled()) {
if (noLog && log.isDebugEnabled()) {
log.debug("contents: {}", contents);
}
return contents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ protected ActionMessages buildMessages(User u, Map<Long, List<Long>> successes,
if (srvrs.isEmpty()) {
continue;
}
else if (toId == -1L) {
else if (toId != null && toId == -1L) {
am = new ActionMessage("basesub.jsp.success-default", srvrs.size());
msgs.add(ActionMessages.GLOBAL_MESSAGE, am);
}
Expand All @@ -697,7 +697,7 @@ else if (toId == -1L) {
if (srvrs.isEmpty()) {
continue;
}
else if (toId == -1L) {
else if (toId != null && toId == -1L) {
am = new ActionMessage("basesub.jsp.skip-default", srvrs.size());
msgs.add(ActionMessages.GLOBAL_MESSAGE, am);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
package com.redhat.rhn.frontend.action.common;

import com.redhat.rhn.common.util.StringUtil;
import com.redhat.rhn.domain.common.CommonFactory;
import com.redhat.rhn.domain.common.TinyUrl;
import com.redhat.rhn.frontend.struts.RhnAction;
Expand All @@ -25,8 +24,6 @@
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

Expand All @@ -47,15 +44,6 @@ public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String token = request.getParameter(TY_TOKEN);
if (log.isDebugEnabled()) {
log.debug("token: {}", StringUtil.sanitizeLogInput(token));
Enumeration<String> e = request.getParameterNames();
while (e.hasMoreElements()) {
String name = e.nextElement();
log.debug("param.name: {} val: {}", StringUtil.sanitizeLogInput(name),
StringUtil.sanitizeLogInput(request.getParameter(name)));
}
}

TinyUrl turl = CommonFactory.lookupTinyUrl(token);
if (turl != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ public Map<String, Object> parseKickstartUrl(String url) {
KickstartSessionUpdateCommand cmd = new KickstartSessionUpdateCommand(kssid);
ksdata = cmd.getKsdata();
retval.put(SESSION, cmd.getKickstartSession());
log.debug("session: {}", retval.get(SESSION));
cmd.setSessionState(KickstartFactory.SESSION_STATE_CONFIG_ACCESSED);
cmd.store();
mode = SESSION;
Expand Down Expand Up @@ -192,8 +191,6 @@ else if (mode.equals(ORG_DEFAULT)) {


if (log.isDebugEnabled()) {
log.debug("session : {}",
StringUtil.sanitizeLogInput(retval.get(SESSION).toString()));
log.debug("options.containsKey(VIEW_LABEL): {}", options.containsKey(VIEW_LABEL));
log.debug("ksdata : {}", ksdata);
}
Expand Down Expand Up @@ -278,7 +275,6 @@ public String getKickstartHost() {
// gsaTRKpX6AxkUFQ11A==:fjs-0-12.rhndev.redhat.com

String proxyHeader = request.getHeader(XRHNPROXYAUTH);
log.debug("X-RHN-Proxy-Auth : {}", proxyHeader);

if (!StringUtils.isEmpty(proxyHeader)) {
String[] proxies = StringUtils.split(proxyHeader, ",");
Expand All @@ -288,7 +284,6 @@ public String getKickstartHost() {
log.debug("first1: {}", firstProxy);
String[] chunks = StringUtils.split(firstProxy, ":");
firstProxy = chunks[chunks.length - 1];
log.debug("first2: {}", firstProxy);
log.debug("Kickstart host from proxy header: {}", firstProxy);
return firstProxy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ public String saveCredentials(HttpServletRequest request, Long id, String user,
creds = new MirrorCredentialsDto(user, password);
}

if (logger.isDebugEnabled()) {
logger.debug("Saving credentials: {}:{}", user, password);
}
logger.debug("Saving credentials for user '{}'", user);
try {
credsManager.storeMirrorCredentials(creds, request);
}
Expand Down
8 changes: 4 additions & 4 deletions java/code/src/com/redhat/rhn/frontend/dto/AuditDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* AuditDto
Expand All @@ -27,7 +28,7 @@ public class AuditDto extends BaseDto {
private int milli;
private String node;

private LinkedHashMap<String, String> kvmap;
private Map<String, String> kvmap;

private String type;

Expand All @@ -39,8 +40,7 @@ public class AuditDto extends BaseDto {
* @param nodeIn Audit generating node
* @param kvmapIn HashMap of audit data
*/
public AuditDto(int serialIn, Date timeIn, int milliIn, String nodeIn,
LinkedHashMap<String, String> kvmapIn) {
public AuditDto(int serialIn, Date timeIn, int milliIn, String nodeIn, Map<String, String> kvmapIn) {
this.id = (long) serialIn;
this.serial = serialIn;
this.time = timeIn;
Expand Down Expand Up @@ -91,7 +91,7 @@ public String getNode() {
/**
* @return Returns the key-value audit data.
*/
public LinkedHashMap<String, String> getKvmap() {
public Map<String, String> getKvmap() {
return kvmap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,11 +595,12 @@ public byte[] getPackage(User loggedInUser, Integer pid) throws IOException {
}

byte[] toReturn = new byte[(int) file.length()];
BufferedInputStream br = new BufferedInputStream(new FileInputStream(file));
if (br.read(toReturn) != file.length()) {
throw new PackageDownloadException("api.package.download.ioerror");
try (BufferedInputStream br = new BufferedInputStream(new FileInputStream(file))) {
if (br.read(toReturn) != file.length()) {
throw new PackageDownloadException("api.package.download.ioerror");
}
return toReturn;
}
return toReturn;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5672,8 +5672,7 @@ public Map transitionDataForSystem(String clientCert) throws FileNotFoundExcepti
break;
}

try {
BufferedReader br = new BufferedReader(new FileReader(file));
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line;
String[] header = null;
Integer systemIdPos = null, uuidPos = null;
Expand Down Expand Up @@ -5719,7 +5718,6 @@ public Map transitionDataForSystem(String clientCert) throws FileNotFoundExcepti
}
}
}
br.close();
}
catch (IOException e) {
log.warn("Cannot read {}", file.getName());
Expand Down
Loading

0 comments on commit 4a95864

Please sign in to comment.