fixed privilege check on SEB Client Events list and update quiz filter

This commit is contained in:
anhefti 2020-03-03 09:36:43 +01:00
parent a37ab31ff1
commit e7af727854
7 changed files with 441 additions and 439 deletions

View file

@ -34,7 +34,7 @@ public class GuiInit implements ApplicationListener<ApplicationReadyEvent> {
SEBServerInit.INIT_LOGGER.info("----> **** GUI Service starting up... ****");
SEBServerInit.INIT_LOGGER.info("---->");
SEBServerInit.INIT_LOGGER.info("----> GUI Service sucessfully successfully started up!");
SEBServerInit.INIT_LOGGER.info("----> GUI Service successfully successfully started up!");
SEBServerInit.INIT_LOGGER.info("---->");
}

View file

@ -73,12 +73,12 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati
this.webserviceURIService = webserviceURIService;
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
String _defaultLogo = null;
String _defaultLogo;
if (!Constants.NO_NAME.equals(defaultLogoFileName)) {
try {
final String extension = ImageUploadSelection.SUPPORTED_IMAGE_FILES.stream()
.filter(ext -> defaultLogoFileName.endsWith(ext))
.filter(defaultLogoFileName::endsWith)
.findFirst()
.orElse(null);
@ -141,7 +141,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati
: null);
if (log.isDebugEnabled()) {
log.debug("Known and active gui entrypoint requested:", institutions);
log.debug("Known and active gui entrypoint requested: {}", institutions);
}
final String logoImageBase64 = requestLogoImage(institutionalEndpoint);
@ -184,9 +184,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati
}
try {
return requestURI.substring(
requestURI.lastIndexOf(Constants.SLASH) + 1,
requestURI.length());
return requestURI.substring(requestURI.lastIndexOf(Constants.SLASH) + 1);
} catch (final Exception e) {
log.error("Failed to extract institutional URL suffix: {}", e.getMessage());
return null;
@ -231,12 +229,12 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati
if (exchange.getStatusCodeValue() == HttpStatus.OK.value()) {
return exchange.getBody();
} else {
log.warn("Failed to verify insitution from requested entrypoint url: {}, response: {}",
log.warn("Failed to verify institution from requested entrypoint url: {}, response: {}",
institutionalEndpoint,
exchange);
}
} catch (final Exception e) {
log.warn("Failed to verify insitution from requested entrypoint url: {}",
log.warn("Failed to verify institution from requested entrypoint url: {}",
institutionalEndpoint,
e);
}
@ -245,7 +243,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati
}
/** TODO this seems not to work as expected. Different Theme is only possible in RAP on different
* entry-points and since entry-points are statically defined within the RAPConficuration
* entry-points and since entry-points are statically defined within the RAPConfiguration
* there is no possibility to apply them dynamically within an institution so far.
*
* @param institutionalEndpoint

View file

@ -63,7 +63,7 @@ public class RAPConfiguration implements ApplicationConfiguration {
}
}
public static interface EntryPointService {
public interface EntryPointService {
void loadLoginPage(final Composite parent);
@ -160,5 +160,5 @@ public class RAPConfiguration implements ApplicationConfiguration {
}
}
};
}
}

View file

@ -8,10 +8,7 @@
package ch.ethz.seb.sebserver.gui;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextListener;
import javax.servlet.ServletException;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import org.eclipse.rap.rwt.engine.RWTServlet;
import org.eclipse.rap.rwt.engine.RWTServletContextListener;
import org.slf4j.Logger;
@ -25,7 +22,8 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import ch.ethz.seb.sebserver.gbl.profile.GuiProfile;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextListener;
@Configuration
@GuiProfile
@ -73,7 +71,7 @@ public class RAPSpringConfig {
private static class RAPServletContextInitializer implements ServletContextInitializer {
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
public void onStartup(final ServletContext servletContext) {
servletContext.setInitParameter(
"org.eclipse.rap.applicationConfiguration",
RAPConfiguration.class.getName());

View file

@ -123,7 +123,7 @@ public class WidgetFactory {
private ImageData image = null;
private ImageData greyedImage = null;
private ImageIcon(final String fileName) {
ImageIcon(final String fileName) {
this.fileName = fileName;
}
@ -199,7 +199,7 @@ public class WidgetFactory {
public final String key;
private CustomVariant(final String key) {
CustomVariant(final String key) {
this.key = key;
}
}
@ -268,7 +268,7 @@ public class WidgetFactory {
* @param parent The parent Composite
* @return the scrolled Composite to add the form content */
public Composite createPopupScrollComposite(final Composite parent) {
final Composite grid = PageService.createManagedVScrolledComposite(
return PageService.createManagedVScrolledComposite(
parent,
scrolledComposite -> {
final Composite g = new Composite(scrolledComposite, SWT.NONE);
@ -277,7 +277,6 @@ public class WidgetFactory {
return g;
},
false);
return grid;
}
public Composite createWarningPanel(final Composite parent) {
@ -733,7 +732,7 @@ public class WidgetFactory {
new FileUploadSelection(parent, this.i18nSupport, readonly);
if (supportedFiles != null) {
supportedFiles.forEach(ext -> fileUploadSelection.withSupportFor(ext));
supportedFiles.forEach(fileUploadSelection::withSupportFor);
}
return fileUploadSelection;
}

View file

@ -23,6 +23,7 @@ import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetup;
import ch.ethz.seb.sebserver.gbl.model.institution.LmsSetupTestResult;
import ch.ethz.seb.sebserver.gbl.util.Result;
import ch.ethz.seb.sebserver.webservice.servicelayer.dao.FilterMap;
import org.joda.time.DateTimeZone;
/** Defines the LMS API access service interface with all functionality needed to access
* a LMS API within a given LmsSetup configuration.
@ -101,12 +102,12 @@ public interface LmsAPIService {
static Predicate<QuizData> quizFilterPredicate(final FilterMap filterMap) {
final String name = filterMap.getQuizName();
final DateTime from = filterMap.getQuizFromTime();
//final DateTime now = DateTime.now(DateTimeZone.UTC);
return q -> {
final boolean nameFilter = StringUtils.isBlank(name) || (q.name != null && q.name.contains(name));
final boolean startTimeFilter =
(from == null) || (q.startTime != null && (q.startTime.isEqual(from) || q.startTime.isAfter(from)));
return nameFilter && startTimeFilter /* && endTimeFilter */;
final boolean currentlyRunning = DateTime.now(DateTimeZone.UTC).isBefore(q.endTime);
return nameFilter && (startTimeFilter || currentlyRunning) ;
};
}

View file

@ -95,6 +95,8 @@ public class ClientEventController extends ReadonlyEntityController<ClientEvent,
filterMap.putIfAbsent(API.PARAM_INSTITUTION_ID, String.valueOf(institutionId));
}
try {
return this.paginationService.getPage(
pageNumber,
pageSize,
@ -102,6 +104,10 @@ public class ClientEventController extends ReadonlyEntityController<ClientEvent,
getSQLTableOfEntity().name(),
() -> this.clientEventDAO.allMatchingExtended(filterMap, this::hasReadAccess))
.getOrThrow();
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Override
@ -118,7 +124,7 @@ public class ClientEventController extends ReadonlyEntityController<ClientEvent,
protected GrantEntity toGrantEntity(final ClientEvent entity) {
return this.examDAO
.byClientConnection(entity.connectionId)
.getOrThrow();
.get();
}
@Override