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
// 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.
// TODO Didn't found a better solution for now but if there is some time, we should find a better solution
// I also tried to set application property: server.tomcat.uri-encoding=UTF-8 but with no effect.
private void handleEncodedURIParams(final String uriQueryString) {
final MultiValueMap<String, String> override = new LinkedMultiValueMap<>();
this.params
@ -252,6 +251,7 @@ public class POSTMapper {
try {
val = Double.parseDouble(split[0]);
} catch (final Exception e) {
log.error("Failed to parse double: ", e.getMessage());
}
return new Threshold(
val,

View file

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

View file

@ -21,11 +21,11 @@ public class SettingsPublished {
@NotNull
@JsonProperty(ATTR_SETTINGS_PUBLISHED)
public final Boolean settingsPublished;
public final Boolean pubished;
@JsonCreator
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)
.call()
.onError(error -> log.warn("Failed to verify published settings. Cause: ", error.getMessage()))
.map(result -> result.settingsPublished)
.map(result -> result.pubished)
.getOr(false);
if (!settingsPublished) {

View file

@ -278,7 +278,7 @@ public class ExamSEBRestrictionSettings {
sebRestriction
.getAdditionalProperties()
.get(OpenEdxSEBRestriction.ATTR_BLACKLIST_CHAPTERS),
() -> chapters.chapters
() -> chapters.chapter_list
.stream()
.map(chapter -> new Tuple<>(chapter.id, chapter.name))
.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.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@ -42,6 +44,8 @@ import ch.ethz.seb.sebserver.gui.widget.WidgetFactory.ImageIcon;
@GuiProfile
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 ADD_TOOLTIP_SUFFIX = ".add" + TOOLTIP_SUFFIX;
private static final String REMOVE_TOOLTIP_SUFFIX = ".remove" + TOOLTIP_SUFFIX;
@ -159,6 +163,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
this.control.showSelection();
} catch (final Exception e) {
// ignore auto selection error
log.warn("Failed to apply auto selection: {}", e.getMessage());
}
// send new values to web-service
this.tableContext
@ -184,6 +189,7 @@ public class TableFieldBuilder extends AbstractTableFieldBuilder {
this.control.showSelection();
} catch (final Exception e) {
// ignore auto selection error
log.warn("Failed to apply auto selection: {}", e.getMessage());
}
// send new values to web-service
this.tableContext.getValueChangeListener()

View file

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

View file

@ -331,8 +331,6 @@ public class PageServiceImpl implements PageService {
} catch (final Exception e) {
log.error("Failed to set current PageState: ", e);
}
} else {
}
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.Composite;
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.util.Tuple;
@ -30,6 +32,7 @@ import ch.ethz.seb.sebserver.gui.service.page.PageService;
public final class MultiSelectionCheckbox extends Composite implements Selection {
private static final long serialVersionUID = -8507565817745610126L;
private static final Logger log = LoggerFactory.getLogger(MultiSelectionCheckbox.class);
private Listener listener = null;
private final Map<String, Button> checkboxes;
@ -90,6 +93,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection
}
} catch (final Exception e) {
// ignore
log.warn("Failed to get Tuple3<String>: {}", e.getMessage());
}
}

View file

@ -45,7 +45,9 @@ public class CacheConfig extends JCacheConfigurerSupport {
try {
final CachingProvider cachingProvider = Caching.getCachingProvider();
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();
composite.setCacheManagers(Arrays.asList(

View file

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