minor fixes
This commit is contained in:
parent
652de887a5
commit
b8ac41b066
25 changed files with 57 additions and 46 deletions
|
@ -49,7 +49,7 @@ public class POSTMapper {
|
|||
|
||||
public String getString(final String name) {
|
||||
final String first = this.params.getFirst(name);
|
||||
if (StringUtils.isNoneBlank(first)) {
|
||||
if (StringUtils.isNotBlank(first)) {
|
||||
try {
|
||||
return URLDecoder.decode(first, "UTF-8");
|
||||
} catch (final UnsupportedEncodingException e) {
|
||||
|
|
|
@ -157,19 +157,19 @@ public final class Orientation implements Entity {
|
|||
}
|
||||
|
||||
public int xpos() {
|
||||
return this.xPosition != null ? this.xPosition.intValue() : -1;
|
||||
return this.xPosition != null ? this.xPosition.intValue() : 0;
|
||||
}
|
||||
|
||||
public int ypos() {
|
||||
return this.yPosition != null ? this.yPosition.intValue() : -1;
|
||||
return this.yPosition != null ? this.yPosition.intValue() : 0;
|
||||
}
|
||||
|
||||
public int width() {
|
||||
return this.width != null ? this.width.intValue() : -1;
|
||||
return this.width != null ? this.width.intValue() : 1;
|
||||
}
|
||||
|
||||
public int height() {
|
||||
return this.height != null ? this.height.intValue() : -1;
|
||||
return this.height != null ? this.height.intValue() : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -303,4 +303,14 @@ public final class Utils {
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
public static String preventResponseSplittingAttack(final String string) {
|
||||
final int xni = string.indexOf('\n');
|
||||
final int xri = string.indexOf('\r');
|
||||
if (xni >= 0 || xri >= 0) {
|
||||
throw new IllegalArgumentException("Illegal argument: " + string);
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ final class InstitutionalAuthenticationEntryPoint implements AuthenticationEntry
|
|||
log.info("No default gui entrypoint requested: {}", requestURI);
|
||||
|
||||
final String logoImageBase64 = requestLogoImage(requestURI);
|
||||
if (StringUtils.isNoneBlank(logoImageBase64)) {
|
||||
if (StringUtils.isNotBlank(logoImageBase64)) {
|
||||
// forward
|
||||
request.getSession().setAttribute(API.PARAM_LOGO_IMAGE, logoImageBase64);
|
||||
final RequestDispatcher dispatcher = request.getServletContext()
|
||||
|
|
|
@ -329,11 +329,11 @@ public class LmsSetupForm implements TemplateComposer {
|
|||
|
||||
if (testResult.isOk()) {
|
||||
return onOK.apply(action);
|
||||
} else if (StringUtils.isNoneBlank(testResult.tokenRequestError)) {
|
||||
} else if (StringUtils.isNotBlank(testResult.tokenRequestError)) {
|
||||
throw new PageMessageException(
|
||||
new LocTextKey("sebserver.lmssetup.action.test.tokenRequestError",
|
||||
testResult.tokenRequestError));
|
||||
} else if (StringUtils.isNoneBlank(testResult.quizRequestError)) {
|
||||
} else if (StringUtils.isNotBlank(testResult.quizRequestError)) {
|
||||
throw new PageMessageException(
|
||||
new LocTextKey("sebserver.lmssetup.action.test.quizRequestError", testResult.quizRequestError));
|
||||
} else {
|
||||
|
|
|
@ -96,7 +96,7 @@ public final class Form implements FormBinding {
|
|||
}
|
||||
|
||||
public void putStatic(final String name, final String value) {
|
||||
if (StringUtils.isNoneBlank(value)) {
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
this.staticValues.put(name, value);
|
||||
}
|
||||
}
|
||||
|
@ -208,7 +208,7 @@ public final class Form implements FormBinding {
|
|||
private void flush() {
|
||||
for (final Map.Entry<String, String> entry : this.staticValues.entrySet()) {
|
||||
final String value = entry.getValue();
|
||||
if (StringUtils.isNoneBlank(value)) {
|
||||
if (StringUtils.isNotBlank(value)) {
|
||||
this.objectRoot.put(entry.getKey(), value);
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ public final class Form implements FormBinding {
|
|||
for (final Map.Entry<String, List<FormFieldAccessor>> entry : this.formFields.entrySet()) {
|
||||
entry.getValue()
|
||||
.stream()
|
||||
.filter(ffa -> StringUtils.isNoneBlank(ffa.getStringValue()))
|
||||
.filter(ffa -> StringUtils.isNotBlank(ffa.getStringValue()))
|
||||
.forEach(ffa -> ffa.putJsonValue(entry.getKey(), this.objectRoot));
|
||||
}
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ public final class Form implements FormBinding {
|
|||
final Tuple<String> tuple,
|
||||
final ObjectNode jsonNode) {
|
||||
|
||||
if (StringUtils.isNoneBlank(tuple._2)) {
|
||||
if (StringUtils.isNotBlank(tuple._2)) {
|
||||
final ArrayNode arrayNode = jsonNode.putArray(tuple._1);
|
||||
final String[] split = StringUtils.split(tuple._2, Constants.LIST_SEPARATOR);
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
|
@ -367,7 +367,7 @@ public final class Form implements FormBinding {
|
|||
this.jsonValueAdapter = jsonValueAdapter;
|
||||
} else {
|
||||
this.jsonValueAdapter = (tuple, jsonObject) -> {
|
||||
if (StringUtils.isNoneBlank(tuple._2)) {
|
||||
if (StringUtils.isNotBlank(tuple._2)) {
|
||||
jsonObject.put(tuple._1, tuple._2);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -164,7 +164,7 @@ public class FormBuilder {
|
|||
|
||||
template.build(this);
|
||||
|
||||
if (StringUtils.isNoneBlank(template.group)) {
|
||||
if (StringUtils.isNotBlank(template.group)) {
|
||||
this.form.addToGroup(template.group, template.name);
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ public class FormBuilder {
|
|||
|
||||
Label valueLabel(final Composite parent, final String value, final int hspan) {
|
||||
final Label label = new Label(parent, SWT.NONE);
|
||||
label.setText((StringUtils.isNoneBlank(value)) ? value : Constants.EMPTY_NOTE);
|
||||
label.setText((StringUtils.isNotBlank(value)) ? value : Constants.EMPTY_NOTE);
|
||||
final GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, hspan, 1);
|
||||
gridData.verticalIndent = 4;
|
||||
label.setLayoutData(gridData);
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.springframework.stereotype.Service;
|
|||
import ch.ethz.seb.sebserver.gbl.Constants;
|
||||
import ch.ethz.seb.sebserver.gbl.model.Entity;
|
||||
import ch.ethz.seb.sebserver.gbl.model.EntityName;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Exam.ExamType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.ExamConfigurationMap;
|
||||
import ch.ethz.seb.sebserver.gbl.model.exam.Indicator.IndicatorType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup.LmsType;
|
||||
import ch.ethz.seb.sebserver.gbl.model.sebconfig.ConfigurationNode;
|
||||
|
@ -211,7 +211,7 @@ public class ResourceService {
|
|||
return this.i18nSupport.supportedLanguages()
|
||||
.stream()
|
||||
.map(locale -> new Tuple<>(locale.toLanguageTag(), locale.getDisplayLanguage(currentLocale)))
|
||||
.filter(tuple -> StringUtils.isNoneBlank(tuple._2))
|
||||
.filter(tuple -> StringUtils.isNotBlank(tuple._2))
|
||||
.sorted((t1, t2) -> t1._2.compareTo(t2._2))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
|
|
@ -67,11 +67,10 @@ public abstract class AbstractTableFieldBuilder implements InputFieldBuilder {
|
|||
final GridData gridData = new GridData(
|
||||
SWT.FILL, SWT.FILL,
|
||||
true, false,
|
||||
(tableContext.orientation != null) ? tableContext.orientation.width() : 1,
|
||||
(tableContext.orientation != null) ? tableContext.orientation.height() : 1);
|
||||
if (tableContext.orientation.height != null) {
|
||||
gridData.heightHint = tableContext.orientation.height * 20 + 40;
|
||||
}
|
||||
tableContext.orientation.width(),
|
||||
tableContext.orientation.height());
|
||||
|
||||
gridData.heightHint = tableContext.orientation.height() * 20 + 40;
|
||||
table.setLayoutData(gridData);
|
||||
table.setHeaderVisible(true);
|
||||
table.addListener(SWT.Resize, event -> adaptColumnWidth(table, tableContext));
|
||||
|
|
|
@ -178,7 +178,7 @@ public class CompositeTableFieldBuilder extends AbstractTableFieldBuilder {
|
|||
for (final TableValue val : map.values()) {
|
||||
final Orientation orientation = this.tableContext.getOrientation(val.attributeId);
|
||||
final String groupId = orientation.getGroupId();
|
||||
if (StringUtils.isNoneBlank(groupId)) {
|
||||
if (StringUtils.isNotBlank(groupId)) {
|
||||
final int cellIndex = this.columns.indexOf(groupId);
|
||||
if (cellIndex >= 0) {
|
||||
setValueToCell(
|
||||
|
|
|
@ -51,8 +51,8 @@ public class TableContext {
|
|||
this.attribute = Objects.requireNonNull(attribute);
|
||||
this.viewContext = Objects.requireNonNull(viewContext);
|
||||
|
||||
this.orientation = Objects.requireNonNull(viewContext
|
||||
.getOrientation(attribute.id));
|
||||
this.orientation = Objects.requireNonNull(
|
||||
viewContext.getOrientation(attribute.id));
|
||||
|
||||
this.rowAttributes = viewContext.getChildAttributes(attribute.id)
|
||||
.stream()
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.springframework.http.HttpHeaders;
|
|||
import org.springframework.http.MediaType;
|
||||
|
||||
import ch.ethz.seb.sebserver.gbl.api.API;
|
||||
import ch.ethz.seb.sebserver.gbl.util.Utils;
|
||||
|
||||
public abstract class AbstractDownloadServiceHandler implements DownloadServiceHandler {
|
||||
|
||||
|
@ -59,9 +60,10 @@ public abstract class AbstractDownloadServiceHandler implements DownloadServiceH
|
|||
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||
response.setContentLength(configFile.length);
|
||||
response.setHeader(
|
||||
HttpHeaders.CONTENT_DISPOSITION,
|
||||
"attachment; filename=\"" + downloadFileName + "\"");
|
||||
|
||||
final String header =
|
||||
"attachment; filename=\"" + Utils.preventResponseSplittingAttack(downloadFileName) + "\"";
|
||||
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, header);
|
||||
|
||||
log.debug("Write the download data to response output");
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public final class ColorSelection extends Composite implements Selection {
|
|||
final Label imageButton = widgetFactory.imageButton(
|
||||
ImageIcon.COLOR,
|
||||
this,
|
||||
(StringUtils.isNoneBlank(tooltipKeyPrefix)
|
||||
(StringUtils.isNotBlank(tooltipKeyPrefix)
|
||||
? new LocTextKey(tooltipKeyPrefix)
|
||||
: DEFAULT_SELECT_TOOLTIP_KEY),
|
||||
this::addColorSelection);
|
||||
|
|
|
@ -85,7 +85,7 @@ public final class MultiSelection extends Composite implements Selection {
|
|||
});
|
||||
this.labels.add(label);
|
||||
}
|
||||
if (StringUtils.isNoneBlank(selectionValue)) {
|
||||
if (StringUtils.isNotBlank(selectionValue)) {
|
||||
select(selectionValue);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection
|
|||
this.checkboxes.put(tuple._1, button);
|
||||
}
|
||||
|
||||
if (StringUtils.isNoneBlank(selectionValue)) {
|
||||
if (StringUtils.isNotBlank(selectionValue)) {
|
||||
select(selectionValue);
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ public final class MultiSelectionCheckbox extends Composite implements Selection
|
|||
public void applyToolTipsForItems(final List<Tuple<String>> mapping) {
|
||||
mapping
|
||||
.stream()
|
||||
.filter(tuple -> StringUtils.isNoneBlank(tuple._2))
|
||||
.filter(tuple -> StringUtils.isNotBlank(tuple._2))
|
||||
.forEach(tuple -> {
|
||||
final Button button = this.checkboxes.get(tuple._1);
|
||||
if (button != null) {
|
||||
|
|
|
@ -67,7 +67,7 @@ public final class RadioSelection extends Composite implements Selection {
|
|||
this.radioButtons.put(tuple._1, button);
|
||||
}
|
||||
|
||||
if (StringUtils.isNoneBlank(selectionValue)) {
|
||||
if (StringUtils.isNotBlank(selectionValue)) {
|
||||
select(selectionValue);
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public final class RadioSelection extends Composite implements Selection {
|
|||
public void applyToolTipsForItems(final List<Tuple<String>> mapping) {
|
||||
mapping
|
||||
.stream()
|
||||
.filter(tuple -> StringUtils.isNoneBlank(tuple._2))
|
||||
.filter(tuple -> StringUtils.isNotBlank(tuple._2))
|
||||
.forEach(tuple -> {
|
||||
final Button button = this.radioButtons.get(tuple._1);
|
||||
if (button != null) {
|
||||
|
|
|
@ -171,10 +171,10 @@ public class PaginationServiceImpl implements PaginationService {
|
|||
final com.github.pagehelper.Page<Object> startPage =
|
||||
PageHelper.startPage(getPageNumber(pageNumber), getPageSize(pageSize), true, true, false);
|
||||
|
||||
if (table != null && StringUtils.isNoneBlank(sort)) {
|
||||
if (table != null && StringUtils.isNotBlank(sort)) {
|
||||
final PageSortOrder sortOrder = PageSortOrder.getSortOrder(sort);
|
||||
final String sortColumnName = verifySortColumnName(sort, table);
|
||||
if (StringUtils.isNoneBlank(sortColumnName)) {
|
||||
if (StringUtils.isNotBlank(sortColumnName)) {
|
||||
switch (sortOrder) {
|
||||
case DESCENDING: {
|
||||
PageHelper.orderBy(sortColumnName + " DESC");
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ExamDAOImpl implements ExamDAO {
|
|||
final String name = filterMap.getQuizName();
|
||||
final DateTime from = filterMap.getExamFromTime();
|
||||
final Predicate<Exam> quizDataFilter = exam -> {
|
||||
if (StringUtils.isNoneBlank(name)) {
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
if (!exam.name.contains(name)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -396,7 +396,7 @@ public class ExamDAOImpl implements ExamDAO {
|
|||
|
||||
return Result.tryCatch(() -> {
|
||||
|
||||
final Collection<String> supporter = (StringUtils.isNoneBlank(record.getSupporter()))
|
||||
final Collection<String> supporter = (StringUtils.isNotBlank(record.getSupporter()))
|
||||
? Arrays.asList(StringUtils.split(record.getSupporter(), Constants.LIST_SEPARATOR_CHAR))
|
||||
: null;
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ final class OpenEdxLmsAPITemplate implements LmsAPITemplate {
|
|||
EdXPage page = getEdxPage(pageURI).getBody();
|
||||
if (page != null) {
|
||||
collector.addAll(page.results);
|
||||
while (StringUtils.isNoneBlank(page.next)) {
|
||||
while (StringUtils.isNotBlank(page.next)) {
|
||||
page = getEdxPage(page.next).getBody();
|
||||
collector.addAll(page.results);
|
||||
}
|
||||
|
|
|
@ -96,13 +96,13 @@ public class SebClientConfigServiceImpl implements SebClientConfigService {
|
|||
|
||||
this.httpScheme = environment.getRequiredProperty(WEB_SERVICE_HTTP_SCHEME_KEY);
|
||||
this.serverAddress = environment.getRequiredProperty(WEB_SERVICE_SERVER_ADDRESS_KEY);
|
||||
this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, (String) null);
|
||||
this.serverName = environment.getProperty(WEB_SERVICE_SERVER_NAME_KEY, "");
|
||||
this.serverPort = environment.getRequiredProperty(WEB_SERVICE_SERVER_PORT_KEY);
|
||||
this.discoveryEndpoint = environment.getRequiredProperty(WEB_SERVICE_EXAM_API_DISCOVERY_ENDPOINT_KEY);
|
||||
|
||||
this.serverURLPrefix = UriComponentsBuilder.newInstance()
|
||||
.scheme(this.httpScheme)
|
||||
.host((StringUtils.isNoneBlank(this.serverName))
|
||||
.host((StringUtils.isNotBlank(this.serverName))
|
||||
? this.serverName
|
||||
: this.serverAddress)
|
||||
.port(this.serverPort)
|
||||
|
|
|
@ -66,7 +66,7 @@ public class SebExamConfigServiceImpl implements SebExamConfigService, XMLValueC
|
|||
this.convertersByAttributeName = new HashMap<>();
|
||||
this.convertersByAttributeType = new HashMap<>();
|
||||
for (final XMLValueConverter converter : converters) {
|
||||
if (StringUtils.isNoneBlank(converter.name())) {
|
||||
if (StringUtils.isNotBlank(converter.name())) {
|
||||
this.convertersByAttributeName.put(converter.name(), converter);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ArrayOfStringConverter implements XMLValueConverter {
|
|||
final XMLValueConverterService xmlValueConverterService) throws IOException {
|
||||
|
||||
final String val = (value.value != null) ? value.value : attribute.getDefaultValue();
|
||||
if (StringUtils.isNoneBlank(val)) {
|
||||
if (StringUtils.isNotBlank(val)) {
|
||||
final String[] values = StringUtils.split(val, Constants.LIST_SEPARATOR);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(String.format(TEMPLATE, extractName(attribute)));
|
||||
|
|
|
@ -60,7 +60,7 @@ public class IntegerConverter implements XMLValueConverter {
|
|||
final XMLValueConverterService xmlValueConverterService) throws IOException {
|
||||
|
||||
final String val = (value.value != null) ? value.value : attribute.getDefaultValue();
|
||||
if (StringUtils.isNoneBlank(val)) {
|
||||
if (StringUtils.isNotBlank(val)) {
|
||||
out.write(Utils.toByteArray(String.format(TEMPLATE, extractName(attribute), val)));
|
||||
} else {
|
||||
out.write(Utils.toByteArray(String.format(TEMPLATE_EMPTY, extractName(attribute))));
|
||||
|
|
|
@ -61,7 +61,7 @@ public class StringConverter implements XMLValueConverter {
|
|||
final XMLValueConverterService xmlValueConverterService) throws IOException {
|
||||
|
||||
final String val = (value.value != null) ? value.value : attribute.getDefaultValue();
|
||||
if (StringUtils.isNoneBlank(val)) {
|
||||
if (StringUtils.isNotBlank(val)) {
|
||||
out.write(Utils.toByteArray(String.format(TEMPLATE, extractName(attribute), val)));
|
||||
} else {
|
||||
out.write(Utils.toByteArray(String.format(TEMPLATE_EMPTY, extractName(attribute))));
|
||||
|
|
|
@ -64,7 +64,7 @@ public class ConfigurationAttributeController extends EntityController<Configura
|
|||
public List<ConfigurationAttribute> getForIds(
|
||||
@RequestParam(name = API.PARAM_MODEL_ID_LIST, required = false) final String modelIds) {
|
||||
|
||||
if (StringUtils.isNoneBlank(modelIds)) {
|
||||
if (StringUtils.isNotBlank(modelIds)) {
|
||||
return super.getForIds(modelIds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue