Code cleanup

This commit is contained in:
anhefti 2022-06-27 14:58:32 +02:00
parent 34e4280a76
commit 0cce03198c
11 changed files with 27 additions and 14 deletions

View file

@ -57,8 +57,7 @@ public class POSTMapper {
// NOTE: this is a workaround since URI parameter are not automatically decoded in the HTTPServletRequest // NOTE: this is a workaround since URI parameter are not automatically decoded in the HTTPServletRequest
// while parameter from form-urlencoded body part are. // while parameter from form-urlencoded body part are.
// I also tried to set application property: server.tomcat.uri-encoding=UTF-8 bit with no effect. // I also tried to set application property: server.tomcat.uri-encoding=UTF-8 but with no effect.
// TODO Didn't found a better solution for now but if there is some time, we should find a better solution
private void handleEncodedURIParams(final String uriQueryString) { private void handleEncodedURIParams(final String uriQueryString) {
final MultiValueMap<String, String> override = new LinkedMultiValueMap<>(); final MultiValueMap<String, String> override = new LinkedMultiValueMap<>();
this.params this.params
@ -252,6 +251,7 @@ public class POSTMapper {
try { try {
val = Double.parseDouble(split[0]); val = Double.parseDouble(split[0]);
} catch (final Exception e) { } catch (final Exception e) {
log.error("Failed to parse double: ", e.getMessage());
} }
return new Threshold( return new Threshold(
val, val,

View file

@ -26,24 +26,24 @@ public final class Chapters {
public static final String ATTR_CHAPTERS = "chapters"; public static final String ATTR_CHAPTERS = "chapters";
public final List<Chapter> chapters; public final List<Chapter> chapter_list;
@JsonCreator @JsonCreator
public Chapters(@JsonProperty(ATTR_CHAPTERS) final Collection<Chapter> chapters) { public Chapters(@JsonProperty(ATTR_CHAPTERS) final Collection<Chapter> chapters) {
final List<Chapter> c = (chapters != null) ? new ArrayList<>(chapters) : new ArrayList<>(); final List<Chapter> c = (chapters != null) ? new ArrayList<>(chapters) : new ArrayList<>();
Collections.sort(c); Collections.sort(c);
this.chapters = Utils.immutableListOf(c); this.chapter_list = Utils.immutableListOf(c);
} }
public Collection<Chapter> getChapters() { public Collection<Chapter> getChapters() {
return this.chapters; return this.chapter_list;
} }
@Override @Override
public String toString() { public String toString() {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
builder.append("Chapters [chapters="); builder.append("Chapters [chapters=");
builder.append(this.chapters); builder.append(this.chapter_list);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View file

@ -21,11 +21,11 @@ public class SettingsPublished {
@NotNull @NotNull
@JsonProperty(ATTR_SETTINGS_PUBLISHED) @JsonProperty(ATTR_SETTINGS_PUBLISHED)
public final Boolean settingsPublished; public final Boolean pubished;
@JsonCreator @JsonCreator
public SettingsPublished(@JsonProperty(ATTR_SETTINGS_PUBLISHED) final Boolean settingsPublished) { public SettingsPublished(@JsonProperty(ATTR_SETTINGS_PUBLISHED) final Boolean settingsPublished) {
this.settingsPublished = settingsPublished; this.pubished = settingsPublished;
} }
} }

View file

@ -303,7 +303,7 @@ public class SEBSettingsForm implements TemplateComposer {
.withURIVariable(API.PARAM_MODEL_ID, this.nodeId) .withURIVariable(API.PARAM_MODEL_ID, this.nodeId)
.call() .call()
.onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage())) .onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage()))
.map(result -> result.settingsPublished) .map(result -> result.pubished)
.getOr(false); .getOr(false);
if (!settingsPublished) { if (!settingsPublished) {

View file

@ -278,7 +278,7 @@ public class ExamSEBRestrictionSettings {
sebRestriction sebRestriction
.getAdditionalProperties() .getAdditionalProperties()
.get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS), .get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS),
() -> chapters.chapters () -> chapters.chapter_list
.stream() .stream()
.map(chapter -> new Tuple<>(chapter.id, chapter.name)) .map(chapter -> new Tuple<>(chapter.id, chapter.name))
.collect(Collectors.toList()))) .collect(Collectors.toList())))

View file

@ -20,6 +20,8 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn; import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.TableItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -42,6 +44,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.ImageIcon;
@GuiProfile @GuiProfile
public class TableFieldBuilder extends AbstractTableFieldBuilder { public class TableFieldBuilder extends AbstractTableFieldBuilder {
private static final Logger log = LoggerFactory.getLogger(TableFieldBuilder.class);
private static final String TOOLTIP_SUFFIX = ".tooltip"; private static final String TOOLTIP_SUFFIX = ".tooltip";
private static final String ADD_TOOLTIP_SUFFIX = ".add" + TOOLTIP_SUFFIX; private static final String ADD_TOOLTIP_SUFFIX = ".add" + TOOLTIP_SUFFIX;
private static final String REMOVE_TOOLTIP_SUFFIX = ".remove" + TOOLTIP_SUFFIX; private static final String REMOVE_TOOLTIP_SUFFIX = ".remove" + TOOLTIP_SUFFIX;
@ -159,6 +163,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
this.control.showSelection(); this.control.showSelection();
} catch (final Exception e) { } catch (final Exception e) {
// ignore auto selection error // ignore auto selection error
log.warn("Failed to apply auto selection: {}", e.getMessage());
} }
// send new values to web-service // send new values to web-service
this.tableContext this.tableContext
@ -184,6 +189,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
this.control.showSelection(); this.control.showSelection();
} catch (final Exception e) { } catch (final Exception e) {
// ignore auto selection error // ignore auto selection error
log.warn("Failed to apply auto selection: {}", e.getMessage());
} }
// send new values to web-service // send new values to web-service
this.tableContext.getValueChangeListener() this.tableContext.getValueChangeListener()

View file

@ -79,6 +79,8 @@ public class BrowserViewModeRule implements ValueChangeRule {
break; break;
} }
default: { default: {
log.warn("Unexpected state");
break;
} }
} }
} }

View file

@ -331,8 +331,6 @@ public class PageServiceImpl implements PageService {
} catch (final Exception e) { } catch (final Exception e) {
log.error("Failed to set current PageState: ", e); log.error("Failed to set current PageState: ", e);
} }
} else {
} }
callback.accept(result); callback.accept(result);
}); });

View file

@ -20,6 +20,8 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ch.ethz.seb.sebserver.gbl.Constants; import ch.ethz.seb.sebserver.gbl.Constants;
import ch.ethz.seb.sebserver.gbl.util.Tuple; import ch.ethz.seb.sebserver.gbl.util.Tuple;
@ -30,6 +32,7 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService;
public final class MultiSelectionCheckbox extends Composite implements Selection { public final class MultiSelectionCheckbox extends Composite implements Selection {
private static final long serialVersionUID = -8507565817745610126L; private static final long serialVersionUID = -8507565817745610126L;
private static final Logger log = LoggerFactory.getLogger(MultiSelectionCheckbox.class);
private Listener listener = null; private Listener listener = null;
private final Map<String, Button> checkboxes; private final Map<String, Button> checkboxes;
@ -90,6 +93,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection
} }
} catch (final Exception e) { } catch (final Exception e) {
// ignore // ignore
log.warn("Failed to get Tuple3<String>: {}", e.getMessage());
} }
} }

View file

@ -45,7 +45,9 @@ public class CacheConfig extends JCacheConfigurerSupport {
try { try {
final CachingProvider cachingProvider = Caching.getCachingProvider(); final CachingProvider cachingProvider = Caching.getCachingProvider();
final javax.cache.CacheManager cacheManager = final javax.cache.CacheManager cacheManager =
cachingProvider.getCacheManager(new URI(this.jCacheConfig), this.getClass().getClassLoader()); cachingProvider.getCacheManager(
new URI(this.jCacheConfig),
Thread.currentThread().getContextClassLoader());
final CompositeCacheManager composite = new CompositeCacheManager(); final CompositeCacheManager composite = new CompositeCacheManager();
composite.setCacheManagers(Arrays.asList( composite.setCacheManagers(Arrays.asList(

View file

@ -23,6 +23,7 @@ import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -236,7 +237,7 @@ public class CertificateDAOImpl implements CertificateDAO {
if (StringUtils.isBlank(dn)) { if (StringUtils.isBlank(dn)) {
return String.valueOf(certificate.getSerialNumber()); return String.valueOf(certificate.getSerialNumber());
} else { } else {
return dn.replace(" ", "_").toLowerCase(); return dn.replace(" ", "_").toLowerCase(Locale.ENGLISH);
} }
} catch (final CertificateEncodingException e) { } catch (final CertificateEncodingException e) {
log.warn("Error while trying to get alias from certificate subject name. Use serial number as alias"); log.warn("Error while trying to get alias from certificate subject name. Use serial number as alias");