Merge branch 'local_develop'
This commit is contained in:
commit
5f95f27d8d
.gitignorepom.xml
src
main
java/se/su/dsv/scipro
ApplicationSettings.javaSciProApplication.javaSciProSession.java
admin
basepages
basepanels/mainmenu
components
data
icons
opponent/panels
peer
data/dao/controllers
interfaces
pages
AbstractProjectPeerPage.javaAbstractSupervisorPeerPage.javaPeerTestPage.javaProjectPeerReviewPage.javaSupervisorPeerReviewPage.java
panels
project/pages
repository
security/auth
ExternalAuthenticationRequestHelper.javaMockRemoteUserFilter.javaRoleBasedAuthorizationStrategy.java
util
workerthreads
resources
webapp
test/java/se/su/dsv/scipro
configuration
dao/jpa
TestCommentThreadDaoJpa.javaTestProjectPartnerDaoJPA-context.xmlTestProjectPartnerDaoJPA.javaTestProjectScheduleDaoJPA.java
security/auth
util
wicket
target/work/WicketMockServlet-filestore
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
\.settings/
|
||||
\.project
|
||||
\.classpath
|
||||
\target/**/*
|
||||
\target/*
|
108
pom.xml
108
pom.xml
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>se.su.dsv</groupId>
|
||||
@ -18,10 +19,10 @@
|
||||
<url>http://wiquery.googlecode.com/svn/repo/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- WICKET DEPENDENCIES -->
|
||||
<!-- WICKET DEPENDENCIES -->
|
||||
<dependency>
|
||||
<groupId>org.apache.wicket</groupId>
|
||||
<artifactId>wicket</artifactId>
|
||||
@ -32,7 +33,13 @@
|
||||
<artifactId>wicket-spring</artifactId>
|
||||
<version>${wicket.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Servlet API, needed for compilation. -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- LOGGING DEPENDENCIES - LOG4J -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
@ -45,10 +52,8 @@
|
||||
<version>${slf4j.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
since we want the jcl over slf4j, we need to bump up the version of
|
||||
slf4j-api that wicket brings in
|
||||
-->
|
||||
<!-- since we want the jcl over slf4j, we need to bump up the version of
|
||||
slf4j-api that wicket brings in -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
@ -57,7 +62,7 @@
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
<version>1.2.16</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
@ -67,14 +72,14 @@
|
||||
<version>1.8.0.10</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.13</version>
|
||||
<scope>runtime</scope>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>5.1.13</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Spring Deps -->
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
@ -161,7 +166,7 @@
|
||||
<version>${hibernate.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Jackrabbit dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.jackrabbit</groupId>
|
||||
@ -184,8 +189,8 @@
|
||||
<version>2.1.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Additional dependencies -->
|
||||
|
||||
<!-- Additional dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.wicket</groupId>
|
||||
<artifactId>wicket-extensions</artifactId>
|
||||
@ -236,8 +241,14 @@
|
||||
<version>2010-09-21</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Library with wicket components -->
|
||||
<dependency>
|
||||
<groupId>org.wamblee</groupId>
|
||||
<artifactId>wamblee-wicket-components</artifactId>
|
||||
<version>0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<build>
|
||||
@ -298,21 +309,60 @@
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.1.1</version>
|
||||
<configuration>
|
||||
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Used for deploying directly from Maven/Eclipse -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.cargo</groupId>
|
||||
<artifactId>cargo-maven2-plugin</artifactId>
|
||||
|
||||
<configuration>
|
||||
<!-- Container configuration -->
|
||||
<container>
|
||||
<containerId>tomcat6x</containerId>
|
||||
<type>remote</type>
|
||||
</container>
|
||||
|
||||
<!-- Configuration to use with the Container -->
|
||||
<configuration>
|
||||
|
||||
<type>runtime</type>
|
||||
<properties>
|
||||
<cargo.tomcat.manager.url>https://thesis.dsv.su.se/manager</cargo.tomcat.manager.url>
|
||||
<cargo.remote.username>janne</cargo.remote.username>
|
||||
<cargo.remote.password>Lai2xoo6</cargo.remote.password>
|
||||
</properties>
|
||||
</configuration>
|
||||
|
||||
<!-- Deployer configuration -->
|
||||
<deployer>
|
||||
<type>remote</type>
|
||||
<deployables>
|
||||
<deployable>
|
||||
<groupId>se.su.dsv</groupId>
|
||||
<artifactId>SciPro</artifactId>
|
||||
<type>war</type>
|
||||
</deployable>
|
||||
</deployables>
|
||||
</deployer>
|
||||
|
||||
</configuration>
|
||||
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
<finalName>scipro2</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<slf4j.version>1.5.11</slf4j.version>
|
||||
<wicket.version>1.4.15</wicket.version>
|
||||
<wiquery.version>1.2.3</wiquery.version>
|
||||
<slf4j.version>1.6.1</slf4j.version>
|
||||
<wicket.version>1.4.17</wicket.version>
|
||||
<wiquery.version>1.2.4</wiquery.version>
|
||||
<jetty.version>6.1.25</jetty.version>
|
||||
<hibernate.version>3.5.1-Final</hibernate.version>
|
||||
<org.springframework.version>3.0.5.RELEASE</org.springframework.version>
|
||||
|
@ -11,6 +11,7 @@ public class ApplicationSettings {
|
||||
|
||||
private boolean enableRemoteUserLookup;
|
||||
private String remoteLookupUrl;
|
||||
private boolean acceptExternalAuthentication;
|
||||
|
||||
public boolean isEnableRemoteUserLookup() {
|
||||
return enableRemoteUserLookup;
|
||||
@ -28,4 +29,12 @@ public class ApplicationSettings {
|
||||
return remoteLookupUrl;
|
||||
}
|
||||
|
||||
public boolean isAcceptExternalAuthentication(){
|
||||
return acceptExternalAuthentication;
|
||||
}
|
||||
|
||||
public void setAcceptExternalAuthentication(boolean pAcceptExternalAuthentication){
|
||||
acceptExternalAuthentication = pAcceptExternalAuthentication;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package se.su.dsv.scipro;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.Page;
|
||||
@ -9,6 +13,7 @@ import org.apache.wicket.Response;
|
||||
import org.apache.wicket.Session;
|
||||
import org.apache.wicket.authorization.strategies.CompoundAuthorizationStrategy;
|
||||
import org.apache.wicket.protocol.http.WebApplication;
|
||||
import org.apache.wicket.protocol.http.WebRequest;
|
||||
import org.odlabs.wiquery.ui.themes.IThemableApplication;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
@ -23,6 +28,7 @@ import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPerProjectClassPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminPeerSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminServerEnvironmentSettingsPage;
|
||||
import se.su.dsv.scipro.basepages.DemoPage;
|
||||
import se.su.dsv.scipro.basepages.errorpages.AccessDeniedPage;
|
||||
import se.su.dsv.scipro.basepages.errorpages.NotFoundPage;
|
||||
@ -44,18 +50,6 @@ import se.su.dsv.scipro.knol.resource.page.ResourcePage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LoginPage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
import se.su.dsv.scipro.message.pages.PrivateMessagesPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerRequestSubmissionPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplateCreationPage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePage;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePreviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewGuidePage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerStatsPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewGuidePage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerStatsPage;
|
||||
import se.su.dsv.scipro.project.pages.FinalSeminarProjectListPage;
|
||||
import se.su.dsv.scipro.project.pages.NoActiveProjectPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectEventPage;
|
||||
@ -69,6 +63,7 @@ import se.su.dsv.scipro.repository.pages.RepositoryDownloadPage;
|
||||
import se.su.dsv.scipro.repository.pages.SysAdminFilePage;
|
||||
import se.su.dsv.scipro.schedule.templates.pages.ScheduleTemplateDetailsPage;
|
||||
import se.su.dsv.scipro.security.auth.ComponentSecurityLogger;
|
||||
import se.su.dsv.scipro.security.auth.ExternalAuthenticationRequestHelper;
|
||||
import se.su.dsv.scipro.security.auth.MetaDataActionStrategy;
|
||||
import se.su.dsv.scipro.security.auth.RoleBasedAuthorizationStrategy;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorAntiPlagiarismLinkPage;
|
||||
@ -108,6 +103,10 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
*/
|
||||
private String systemNotice = null;
|
||||
|
||||
/**
|
||||
* Logger instance.
|
||||
*/
|
||||
private Logger logger = Logger.getLogger(SciProApplication.class);
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
@ -192,6 +191,7 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
mountBookmarkablePage("admin/files", SysAdminFilePage.class);
|
||||
mountBookmarkablePage("admin/allfinalseminars", AdminFinalSeminarPage.class);
|
||||
mountBookmarkablePage("admin/settings", AdminGeneralSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/serverenvironment", AdminServerEnvironmentSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/finalseminargeneralsettings", AdminFinalSeminarSettingsPage.class);
|
||||
mountBookmarkablePage("admin/settings/finalseminarprojectlevel", AdminFinalSeminarSettingsPerProjectClassPage.class);
|
||||
mountBookmarkablePage("admin/settings/peer", AdminPeerSettingsPage.class);
|
||||
@ -274,8 +274,7 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void setKerberosConfigs(){
|
||||
javax.servlet.ServletContext context = getServletContext();
|
||||
Logger logger = Logger.getRootLogger();
|
||||
java.util.Set<String> resources = context.getResourcePaths("/WEB-INF/classes/");
|
||||
Set<String> resources = context.getResourcePaths("/WEB-INF/classes/");
|
||||
if(!resources.contains(jaasPath) || !resources.contains(krb5Path)){
|
||||
logger.log(Level.FATAL, "Path to authentication config files not correct. " +
|
||||
"Users will not be able to log in!");
|
||||
@ -307,6 +306,49 @@ public class SciProApplication extends RepositoryApplication implements IThemabl
|
||||
public Session newSession(Request request, Response response) {
|
||||
return new SciProSession(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebRequest newWebRequest(final HttpServletRequest request){
|
||||
final WebRequest webRequest = super.newWebRequest(request);
|
||||
if(attemptExternalAuthentication(webRequest)){
|
||||
logger.debug("External authentication used successfully");
|
||||
}
|
||||
return webRequest;
|
||||
}
|
||||
/**
|
||||
* Private utility, just to keep stuff out of the calling method.
|
||||
* In short: scan incoming request for REMOTE_USER, check for a session, create one if none exists, attempt authentication and return status.
|
||||
* @param usingRequest
|
||||
* @return true if external auth was completed, false if not.
|
||||
*/
|
||||
private boolean attemptExternalAuthentication(final WebRequest usingRequest){
|
||||
SciProSession session = (SciProSession)getSessionStore().lookup(usingRequest);
|
||||
final ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(usingRequest.getHttpServletRequest());
|
||||
if(helper.isExternalAuthSupported()){//Attempt external auth
|
||||
if(session == null){//Can't do this without a usable session, attempt manual bind
|
||||
getSessionStore().bind(usingRequest,new SciProSession(usingRequest));
|
||||
session = (SciProSession)getSessionStore().lookup(usingRequest);
|
||||
}
|
||||
if(session != null){
|
||||
if(session.isLoggedIn()){
|
||||
if(!helper.isRemoteUserValid(session.getUser())){//This check may not be needed and may hinder performance, but better safe than sorry for now.
|
||||
logger.debug("User is logged in as '"+session.getUser().getEmailAddress()+"', but conflicting info ('"+helper.getExternalAuthRemoteUser()+"') is supplied via external authentication protocols.");
|
||||
}
|
||||
}else{
|
||||
//logger.info("Attempting sign in with external auth data");
|
||||
if(!helper.signIn(session)){
|
||||
logger.error("User '"+helper.getExternalAuthRemoteUser()+"' passes external authentication but cannot be signed in.");
|
||||
}else{
|
||||
logger.debug("Signed in user '"+helper.getExternalAuthRemoteUser()+"' via external authentication");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
throw new IllegalStateException("External authentication was attempted, but no session was available for sign in.");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceReference getTheme(Session session) {
|
||||
|
@ -57,6 +57,9 @@ public class SciProSession extends WebSession {
|
||||
|
||||
private String loggedInIdentity = null;
|
||||
|
||||
//Logger instance
|
||||
private static Logger logger = Logger.getLogger(SciProSession.class);
|
||||
|
||||
/*
|
||||
* It's important not to hold the actual object, if we do, no changes to it
|
||||
* or it's attributes will be visible for the user unless they logout or re-select their active project.
|
||||
@ -105,16 +108,117 @@ public class SciProSession extends WebSession {
|
||||
return loggedInIdentity;
|
||||
}
|
||||
|
||||
|
||||
public synchronized boolean login(final String username, final String password) throws FailedLoginException, NullPointerException{
|
||||
final boolean loginSuccess = authenticate(username, password);
|
||||
if(loginSuccess){
|
||||
loggedIn = true;
|
||||
/**
|
||||
* Local login procedures, delegates authentication to authenticate() and sign in procedures to signInAuthenticatedUser() if authentication succeeds.
|
||||
* An administrator can log in as a different user in the system by using 'adminusername::otherusername' notation,
|
||||
* this is implemented as a regular login followed by a su-like switch (via switchAuthenticatedUser).
|
||||
* @param username is expected to be in the format "localdsvusername" or "localdsvusername::optionalotherusername".
|
||||
*/
|
||||
public boolean login(final String username, final String password) throws FailedLoginException, NullPointerException{
|
||||
String[] tmp = username.split("::");
|
||||
String authenticatedUserName = username;
|
||||
String switchToUserName = null;
|
||||
if(tmp.length > 0){
|
||||
authenticatedUserName = tmp[0];
|
||||
if(tmp.length > 1)
|
||||
switchToUserName = tmp[1];
|
||||
}
|
||||
return loginSuccess;
|
||||
//logger.info("Attempting authentication as "+authenticatedUserName);
|
||||
final boolean authenticationSuccess = authenticate(authenticatedUserName, password);
|
||||
if(!authenticationSuccess)
|
||||
return false;
|
||||
//logger.info("Successfully authenticated user "+authenticatedUserName);
|
||||
final boolean signInSuccess = signInAuthenticatedUser(authenticatedUserName,"DSV.SU.SE");
|
||||
if(switchToUserName != null){
|
||||
if(!switchAuthenticatedUser(switchToUserName,"DSV.SU.SE"))
|
||||
logger.error("Can't switch from '"+authenticatedUserName+"' to '"+switchToUserName+"'");
|
||||
}
|
||||
return signInSuccess;
|
||||
}
|
||||
/**
|
||||
* Sign in a user and bypass normal authentication routines completely.
|
||||
* This user has to already be present in database tables or login will fail.
|
||||
* @param username is expected to be one of the users registered username
|
||||
* @param realm is expected to be the matching realm from the supplied username
|
||||
* @return status of the sign-in request
|
||||
*/
|
||||
public boolean signInAuthenticatedUser(final String username, final String realm){
|
||||
//Query for the user
|
||||
user = userDao.getUserByUsername(username,realm);
|
||||
if(user == null){
|
||||
try{
|
||||
user = doUserLookup(username);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+username+" found in the database or in daisy.");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
//Set mail-address session attributes
|
||||
setLoggedInIdentity(username+"@"+realm);
|
||||
if(user.getEmailAddress() == null || user.getEmailAddress().trim().equals("")){
|
||||
user.setEmailAddress(getLoggedInIdentity());
|
||||
user = userDao.save(user);
|
||||
}
|
||||
//Assign roles
|
||||
if(roleDao.isStudent(user)){
|
||||
iRoles.add(new Student());
|
||||
}
|
||||
if(roleDao.isExternal(user)){
|
||||
iRoles.add(new External());
|
||||
}
|
||||
if(roleDao.isEmployee(user)){
|
||||
iRoles.add(new Employee());
|
||||
}
|
||||
if(roleDao.isAdmin(user)){
|
||||
iRoles.add(new Admin());
|
||||
}
|
||||
if(roleDao.isSysadmin(user)){
|
||||
iRoles.add(new SysAdmin());
|
||||
}
|
||||
if(iRoles.isEmpty()){
|
||||
iRoles.add(new DefaultRole());
|
||||
}
|
||||
//Set active project from users settings
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if(userSettings != null){
|
||||
Project activeProject = userSettings.getActiveProject();
|
||||
if(activeProject != null)
|
||||
activeProjectId = activeProject.getId();
|
||||
}
|
||||
else {
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
// With this userSettings.created() will return a users first login date and userSettings.modified() will return last login
|
||||
userSettings.setLastModified(new Date());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
|
||||
logger.info("User: "+getLoggedInIdentity()+ " logged in to "+this.getApplication().getClass().getSimpleName()+
|
||||
" as: "+user.getFirstName()+" "+user.getLastName()+" "+user.getUserNames()+ " at: "+new Date());
|
||||
loggedIn = true;
|
||||
return loggedIn;
|
||||
}
|
||||
/**
|
||||
* Switch currently logged in user (basically a poor mans 'su') to someone else, the currently logged in user has to be registered as an admin for this to succeed.
|
||||
* Also, the new user has to exist in local database tables or it will fail.
|
||||
* @param suUser
|
||||
* @param suRealm
|
||||
* @return true if the switch was successful, else false.
|
||||
*/
|
||||
public boolean switchAuthenticatedUser(final String suUser, final String suRealm){
|
||||
if(!isLoggedIn() || user == null)//Terminate early
|
||||
return false;
|
||||
logger.info("Currently logged in user: '"+user.getEmailAddress()+"' attempting switch to '"+suUser+"@"+suRealm+"'");
|
||||
if(suUser != null && roleDao.isSysadmin(user)){
|
||||
iRoles.clear();
|
||||
return signInAuthenticatedUser(suUser, suRealm);
|
||||
}else{
|
||||
logger.error("User does not have the privilege to switch user");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void logout()
|
||||
{
|
||||
loggedIn = false;
|
||||
@ -123,96 +227,18 @@ public class SciProSession extends WebSession {
|
||||
public synchronized final boolean isLoggedIn() {
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses normal Wicket/JAAS stuff to authenticate a user/password combination.
|
||||
* @param username
|
||||
* @param password
|
||||
* @return true if authentication succeeds, else false.
|
||||
* @throws NullPointerException
|
||||
* @throws FailedLoginException
|
||||
*/
|
||||
private synchronized boolean authenticate(String username, final String password) throws NullPointerException, FailedLoginException {
|
||||
Authenticator auth = new Authenticator();
|
||||
/*
|
||||
* An administrator can log in as a different user in the system by using 'adminusername::otherusername' for login
|
||||
*/
|
||||
String[] tmp = username.split("::");
|
||||
String loggedInAsUsername = null;
|
||||
if(tmp.length > 0){
|
||||
username = tmp[0];
|
||||
if(tmp.length > 1)
|
||||
loggedInAsUsername = tmp[1];
|
||||
}
|
||||
try {
|
||||
try{
|
||||
auth.authenticate(username, password);
|
||||
this.user = userDao.getUserByUsername(username);
|
||||
if( user == null){
|
||||
try{
|
||||
user = doUserLookup(username);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+username+" found in the database, or in daisy, despite successful authentication ");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
setLoggedInIdentity(username+"@"+"dsv.su.se");
|
||||
if(user.getEmailAddress() == null || user.getEmailAddress().trim().equals("")){
|
||||
user.setEmailAddress(getLoggedInIdentity());
|
||||
user = userDao.save(user);
|
||||
}
|
||||
/*
|
||||
* Here we switch the logged in user to be that of the person chosen be the logged-in-as by a sysadmin
|
||||
*/
|
||||
|
||||
if(loggedInAsUsername != null && roleDao.isSysadmin(user)){
|
||||
user = userDao.getUserByUsername(loggedInAsUsername);
|
||||
if( user == null){
|
||||
try{
|
||||
user = doUserLookup(loggedInAsUsername);
|
||||
if(user == null){
|
||||
throw new NullPointerException("No user with username "+loggedInAsUsername+" found in the database, or in daisy, despite successful authentication ");
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(roleDao.isStudent(user)){
|
||||
iRoles.add(new Student());
|
||||
}
|
||||
if(roleDao.isExternal(user)){
|
||||
iRoles.add(new External());
|
||||
}
|
||||
if(roleDao.isEmployee(user)){
|
||||
iRoles.add(new Employee());
|
||||
}
|
||||
if(roleDao.isAdmin(user)){
|
||||
iRoles.add(new Admin());
|
||||
}
|
||||
if(roleDao.isSysadmin(user)){
|
||||
iRoles.add(new SysAdmin());
|
||||
}
|
||||
|
||||
if(iRoles.isEmpty()){
|
||||
iRoles.add(new DefaultRole());
|
||||
}
|
||||
/*
|
||||
* Set active project from users settings
|
||||
*/
|
||||
UserSettings userSettings = userSettingsDao.getUserSettings(user);
|
||||
if(userSettings != null){
|
||||
Project activeProject = userSettings.getActiveProject();
|
||||
if(activeProject != null)
|
||||
activeProjectId = activeProject.getId();
|
||||
}
|
||||
else {
|
||||
userSettings = new UserSettings(user);
|
||||
}
|
||||
/*
|
||||
* With this userSettings.created() will return a users first login date and userSettings.modified() will return last login
|
||||
*/
|
||||
userSettings.setLastModified(new Date());
|
||||
userSettings = userSettingsDao.save(userSettings);
|
||||
|
||||
Logger logger = Logger.getLogger("Application");
|
||||
logger.log(Level.INFO, "User: "+getLoggedInIdentity()+ " logged in to "+this.getApplication().getClass().getSimpleName()+
|
||||
" as: "+user.getFirstName()+" "+user.getLastName()+" "+user.getUserNames()+ " at: "+new Date());
|
||||
return true;
|
||||
} catch (FailedLoginException e) {
|
||||
//e.printStackTrace();
|
||||
|
@ -10,6 +10,7 @@ import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminFinalSeminarSettingsPerProjectClassPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminPeerSettingsPage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminServerEnvironmentSettingsPage;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
@ -29,9 +30,10 @@ public abstract class AbstractAdminSettingsPage extends AbstractAdminPage {
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("General settings", AdminGeneralSettingsPage.class));
|
||||
items.add(new MenuItem("Server Environment", AdminServerEnvironmentSettingsPage.class));
|
||||
items.add(new MenuItem("Final seminar general settings", AdminFinalSeminarSettingsPage.class));
|
||||
items.add(new MenuItem("Final seminar project level settings", AdminFinalSeminarSettingsPerProjectClassPage.class));
|
||||
items.add(new MenuItem("Peer settings", AdminPeerSettingsPage.class, ImageIcon.ICON_SETTINGS));
|
||||
items.add(new MenuItem("Peer settings", AdminPeerSettingsPage.class /*,ImageIcon.ICON_SETTINGS */));
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
import se.su.dsv.scipro.project.panels.ProjectPartnerPanel;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
@ -3,17 +3,29 @@
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<h3 class="section">Final Seminar Settings</h3>
|
||||
<form wicket:id="maxActiveParticipationForm">
|
||||
<p><label>Set max active participants on a final seminar:</label> <input wicket:id="maxActiveParticipation"
|
||||
type="text" /></p>
|
||||
<p><label>Set days before a final seminar a student can register as an active participant:</label> <input wicket:id="registerAsActive"
|
||||
type="text" /></p>
|
||||
<p><label>Set days before a final seminar a student can register as an opponent:</label> <input wicket:id="registerAsOpponent"
|
||||
type="text" /></p>
|
||||
<p><label>The file format of theses and opposition-reports must be PDF:</label> <input type="checkbox" wicket:id="finalSeminarThesisMustBeAPDF" /></p>
|
||||
<div> <input type="submit" value="Save"
|
||||
name="NoticeSubmit" /></div>
|
||||
<h5 class="peer-title">Final Seminar Settings</h5>
|
||||
<form wicket:id="finalSeminarSettingsForm">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="1">Max active participants on a final seminar:</label></td>
|
||||
<td><input name="1" wicket:id="finalSeminarMaxActiveParticipants" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="2">Minimum number of days before a final seminar a student can register as an active participant:</label></td>
|
||||
<td><input name="2" wicket:id="daysBeforeFinalSeminarCanRegisterAsActiveParticipant" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="3">Minimum number of days before a final seminar a student can register as an opponent:</label></td>
|
||||
<td><input name="3" wicket:id="daysBeforeFinalSeminarCanRegisterAsOpponent" type="text" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="4">File format of uploaded theses and opposition-reports must be PDF:</label></td>
|
||||
<td><input name="4" type="checkbox" wicket:id="finalSeminarThesisMustBeAPDF" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<button type="submit" ><img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/> Save changes</button>
|
||||
|
||||
</form>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
|
@ -1,73 +1,50 @@
|
||||
package se.su.dsv.scipro.admin.pages.settings;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RequiredTextField;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.admin.models.SettingsModel;
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
|
||||
public class AdminFinalSeminarSettingsPage extends AbstractAdminSettingsPage {
|
||||
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
private GeneralSystemSettings settings;
|
||||
|
||||
|
||||
public AdminFinalSeminarSettingsPage(final PageParameters pp){
|
||||
public AdminFinalSeminarSettingsPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
add(new MaxActiveParticipationForm("maxActiveParticipationForm"));
|
||||
|
||||
add(new FinalSeminarSettingsForm(
|
||||
"finalSeminarSettingsForm",
|
||||
new CompoundPropertyModel<GeneralSystemSettings>(generalSystemSettingsDao.getGeneralSystemSettingsInstance())));
|
||||
}
|
||||
|
||||
private class MaxActiveParticipationForm extends Form<SettingsModel> {
|
||||
|
||||
private class FinalSeminarSettingsForm extends Form<GeneralSystemSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MaxActiveParticipationForm(String id) {
|
||||
super(id, new CompoundPropertyModel<SettingsModel>(
|
||||
new SettingsModel()));
|
||||
settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
TextField<Integer> activeParticipation = new TextField<Integer>(
|
||||
"maxActiveParticipation");
|
||||
TextField<Integer> registerAsActive = new TextField<Integer>(
|
||||
"registerAsActive");
|
||||
TextField<Integer> registerAsOpponent = new TextField<Integer>(
|
||||
"registerAsOpponent");
|
||||
CheckBox pdfCheckBox = new CheckBox(
|
||||
"finalSeminarThesisMustBeAPDF");
|
||||
SettingsModel settingsModel = ((SettingsModel) getDefaultModelObject());
|
||||
settingsModel.setMaxActiveParticipation(settings.getFinalSeminarMaxActiveParticipants());
|
||||
settingsModel.setRegisterAsActive(settings.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant());
|
||||
settingsModel.setRegisterAsOpponent(settings.getDaysBeforeFinalSeminarCanRegisterAsOpponent());
|
||||
settingsModel.setFinalSeminarThesisMustBeAPDF(settings.isFinalSeminarThesisMustBeAPDF());
|
||||
public FinalSeminarSettingsForm(String id, IModel<GeneralSystemSettings> model) {
|
||||
super(id, model );
|
||||
TextField<Integer> activeParticipation = new RequiredTextField<Integer>("finalSeminarMaxActiveParticipants");
|
||||
TextField<Integer> registerAsActive = new RequiredTextField<Integer>("daysBeforeFinalSeminarCanRegisterAsActiveParticipant");
|
||||
TextField<Integer> registerAsOpponent = new RequiredTextField<Integer>("daysBeforeFinalSeminarCanRegisterAsOpponent");
|
||||
CheckBox pdfCheckBox = new CheckBox("finalSeminarThesisMustBeAPDF");
|
||||
add(registerAsActive);
|
||||
add(registerAsOpponent);
|
||||
add(activeParticipation);
|
||||
add(pdfCheckBox);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSubmit() {
|
||||
SettingsModel settingsModel = ((SettingsModel) getDefaultModelObject());
|
||||
settings.setFinalSeminarMaxActiveParticipants(settingsModel.getMaxActiveParticipation());
|
||||
settings.setDaysBeforeFinalSeminarCanRegisterAsActiveParticipant(settingsModel.getRegisterAsActive());
|
||||
settings.setDaysBeforeFinalSeminarCanRegisterAsOpponent(settingsModel.getRegisterAsOpponent());
|
||||
settings.setFinalSeminarThesisMustBeAPDF(settingsModel.isFinalSeminarThesisMustBeAPDF());
|
||||
generalSystemSettingsDao.save(settings);
|
||||
setModelObject( generalSystemSettingsDao.save(getModelObject()) );
|
||||
info("Final seminar settings saved");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
<div class="append-bottom">
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<form wicket:id="peerSettingsForm">
|
||||
<form wicket:id="settingsForm">
|
||||
<ul class="no-list-style">
|
||||
<li wicket:id="projectClassList" class="append-bottom">
|
||||
<h5 wicket:id="projectClassName" class="peer-box-subtitle"></h5>
|
||||
|
@ -23,7 +23,7 @@ public class AdminFinalSeminarSettingsPerProjectClassPage extends AbstractAdminS
|
||||
public AdminFinalSeminarSettingsPerProjectClassPage(final PageParameters pp){
|
||||
super(pp);
|
||||
|
||||
final Form<Void> peerSettingsForm = new Form<Void>("peerSettingsForm"){
|
||||
final Form<Void> settingsForm = new Form<Void>("settingsForm"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
@ -32,26 +32,26 @@ public class AdminFinalSeminarSettingsPerProjectClassPage extends AbstractAdminS
|
||||
}
|
||||
};
|
||||
|
||||
peerSettingsForm.add(new ListView<ProjectClass>("projectClassList", projectClassDao.findAll()){
|
||||
settingsForm.add(new ListView<ProjectClass>("projectClassList", projectClassDao.findAll()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<ProjectClass> item) {
|
||||
item.add(new Label("projectClassName", item.getModelObject().getName()));
|
||||
item.add(new PeerProjectClassSettingsForm("projectClassSettingsForm", item.getModelObject()));
|
||||
item.add(new SettingsPerProjectClassForm("projectClassSettingsForm", item.getModelObject()));
|
||||
add(item);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
peerSettingsForm.add(new Button("submit"));
|
||||
add(peerSettingsForm);
|
||||
settingsForm.add(new Button("submit"));
|
||||
add(settingsForm);
|
||||
}
|
||||
|
||||
private class PeerProjectClassSettingsForm extends Form<ProjectClassSettings> {
|
||||
private class SettingsPerProjectClassForm extends Form<ProjectClassSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public PeerProjectClassSettingsForm(final String id, final ProjectClass projectClass){
|
||||
public SettingsPerProjectClassForm(final String id, final ProjectClass projectClass){
|
||||
super(id, new CompoundPropertyModel<ProjectClassSettings>(projectClass.getProjectClassSettings()));
|
||||
|
||||
TextField<Integer> numDaysBetweenPeerReviewsOnSameProject =
|
||||
|
@ -5,8 +5,21 @@
|
||||
<wicket:extend>
|
||||
|
||||
<div class="append-bottom">
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<h5 class="peer-title">General settings</h5>
|
||||
<form wicket:id="peerSettingsForm">
|
||||
<form wicket:id="peerRatingsSettingsForm">
|
||||
<table>
|
||||
<tr>
|
||||
<td><label for="peerRatingsEnabled">Enable peers to rate reviews and the display of ratings: </label></td>
|
||||
<td><input type="checkbox" wicket:id="peerRatingsEnabled" name="peerRatingsEnabled"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label for="peerDisplayNumberOfReviewsPerformed">Display users number of reviews performed on portal page</label></td>
|
||||
<td><input type="checkbox" wicket:id="peerDisplayNumberOfReviewsPerformed" name="peerDisplayNumberOfReviewsPerformed"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<h5 class="peer-title">Settings for levels</h5>
|
||||
<ul class="no-list-style">
|
||||
<li wicket:id="projectClassList" class="append-bottom">
|
||||
<h5 wicket:id="projectClassName" class="peer-box-subtitle"></h5>
|
||||
|
@ -3,15 +3,19 @@ package se.su.dsv.scipro.admin.pages.settings;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.CheckBox;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextField;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
|
||||
@ -19,6 +23,8 @@ public class AdminPeerSettingsPage extends AbstractAdminSettingsPage {
|
||||
|
||||
@SpringBean
|
||||
private ProjectClassDao projectClassDao;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
public AdminPeerSettingsPage(final PageParameters pp){
|
||||
super(pp);
|
||||
@ -43,11 +49,30 @@ public class AdminPeerSettingsPage extends AbstractAdminSettingsPage {
|
||||
}
|
||||
|
||||
});
|
||||
CompoundPropertyModel<GeneralSystemSettings> ratingsModel = new CompoundPropertyModel<GeneralSystemSettings>(generalSystemSettingsDao.getGeneralSystemSettingsInstance());
|
||||
PeerRatingsSettingsForm peerRatingsSettingsForm = new PeerRatingsSettingsForm("peerRatingsSettingsForm", ratingsModel);
|
||||
peerSettingsForm.add(peerRatingsSettingsForm);
|
||||
|
||||
peerSettingsForm.add(new Button("submit"));
|
||||
add(peerSettingsForm);
|
||||
}
|
||||
|
||||
private class PeerRatingsSettingsForm extends Form<GeneralSystemSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public PeerRatingsSettingsForm(String id, IModel<GeneralSystemSettings> model) {
|
||||
super(id, model);
|
||||
|
||||
CheckBox peerRatingsEnabled = new CheckBox("peerRatingsEnabled");
|
||||
add(peerRatingsEnabled);
|
||||
CheckBox peerDisplayNumberOfReviewsPerformed = new CheckBox("peerDisplayNumberOfReviewsPerformed");
|
||||
add(peerDisplayNumberOfReviewsPerformed);
|
||||
}
|
||||
@Override
|
||||
public void onSubmit(){
|
||||
setModelObject(generalSystemSettingsDao.save(getModelObject()));
|
||||
}
|
||||
}
|
||||
|
||||
private class PeerProjectClassSettingsForm extends Form<ProjectClassSettings> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
17
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.html
Normal file
17
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.html
Normal file
@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<body>
|
||||
<wicket:extend>
|
||||
<h3 class="section">Server/Request environment</h3>
|
||||
<div style="overflow:auto;height:390px;">
|
||||
<ul>
|
||||
<li wicket:id="requestAttributes">
|
||||
<span wicket:id="name">[name]</span>:
|
||||
<span wicket:id="value">[value]</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</wicket:extend>
|
||||
</body>
|
||||
</html>
|
49
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.java
Normal file
49
src/main/java/se/su/dsv/scipro/admin/pages/settings/AdminServerEnvironmentSettingsPage.java
Normal file
@ -0,0 +1,49 @@
|
||||
package se.su.dsv.scipro.admin.pages.settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
|
||||
import se.su.dsv.scipro.admin.pages.AbstractAdminSettingsPage;
|
||||
import se.su.dsv.scipro.util.KeyValuePair;
|
||||
|
||||
public class AdminServerEnvironmentSettingsPage extends AbstractAdminSettingsPage {
|
||||
public AdminServerEnvironmentSettingsPage(final PageParameters pp) {
|
||||
super(pp);
|
||||
add(new ListView<KeyValuePair<String>>("requestAttributes",getRequestAttributes()){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Override
|
||||
protected void populateItem(ListItem<KeyValuePair<String>> item){
|
||||
KeyValuePair<String> pair = item.getModelObject();
|
||||
item.add(new Label("name",pair.getKey()));
|
||||
item.add(new Label("value","'"+pair.getValue()+"'"));
|
||||
}
|
||||
});
|
||||
}
|
||||
private List<KeyValuePair<String>> getRequestAttributes(){
|
||||
final HttpServletRequest rawRequest = getWebRequestCycle().getWebRequest().getHttpServletRequest();
|
||||
List<KeyValuePair<String>> list = new ArrayList<KeyValuePair<String>>();
|
||||
list.add(new KeyValuePair<String>("[CALL] getRemoteUser",rawRequest.getRemoteUser()));
|
||||
list.add(new KeyValuePair<String>("[CALL] getAuthType",rawRequest.getAuthType()));
|
||||
@SuppressWarnings("rawtypes") Enumeration attributes = rawRequest.getAttributeNames();
|
||||
while(attributes.hasMoreElements()){
|
||||
final String key = (String)attributes.nextElement();
|
||||
final String value = rawRequest.getAttribute(key).toString();
|
||||
list.add(new KeyValuePair<String>("[ATTR] "+key,value));
|
||||
}
|
||||
Map<String,String> envs = System.getenv();
|
||||
for(String key : envs.keySet()){
|
||||
list.add(new KeyValuePair<String>("[ENV] "+key,envs.get(key)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import se.su.dsv.scipro.admin.pages.ProjectManagementPage;
|
||||
import se.su.dsv.scipro.admin.pages.SystemMaintenancePage;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminGeneralSettingsPage;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.pages.PeerReviewTemplatePage;
|
||||
|
||||
public class AdminTabMenuPanel extends AbstractMenuPanel {
|
||||
@ -35,7 +36,7 @@ public class AdminTabMenuPanel extends AbstractMenuPanel {
|
||||
items.add(new MenuItem("System maintenance", SystemMaintenancePage.class));
|
||||
items.add(new MenuItem("All final seminars", AdminFinalSeminarPage.class));
|
||||
items.add(new MenuItem("Peer review templates", PeerReviewTemplatePage.class));
|
||||
items.add(new MenuItem("Settings", AdminGeneralSettingsPage.class));
|
||||
items.add(new MenuItem("Settings", AdminGeneralSettingsPage.class, ImageIcon.ICON_SETTINGS));
|
||||
items.add(new MenuItem("Role management", AdminRolePage.class));
|
||||
items.add(new MenuItem("Project partner", AdminProjectPartnerPage.class));
|
||||
|
||||
@ -44,7 +45,7 @@ public class AdminTabMenuPanel extends AbstractMenuPanel {
|
||||
|
||||
@Override
|
||||
protected MenuType getMenuType() {
|
||||
return MenuType.TAB;
|
||||
return MenuType.TAB_MULTIPLE_ROWS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<!--[if lt IE 7]> <html class="ie ie6 lte9 lte8 lte7"> <![endif]-->
|
||||
<!--[if IE 7]> <html class="ie ie7 lte9 lte8 lte7"> <![endif]-->
|
||||
<!--[if IE 8]> <html class="ie ie8 lte9 lte8"> <![endif]-->
|
||||
<!--[if IE 9]> <html class="ie ie9 lte9"> <![endif]-->
|
||||
<!--[if gt IE 9]> <html> <![endif]-->
|
||||
<!--[if !IE]><!-->
|
||||
<html lang="en"
|
||||
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
|
||||
<!--<![endif]-->
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title wicket:id="pageTitle">SciPro DSV</title>
|
||||
@ -16,18 +24,37 @@
|
||||
<!-- <link href='http://fonts.googleapis.com/css?family=Vollkorn' rel='stylesheet' type='text/css' />
|
||||
<link href='http://fonts.googleapis.com/css?family=Ubuntu:regular,bold' rel='stylesheet' type='text/css' /> -->
|
||||
<!--<link rel="stylesheet" href="css/scipro.css" media="screen,projection" />-->
|
||||
<!--[if lte IE 9]>
|
||||
<link rel="stylesheet" href="css/scipro-ie.css" media="screen,projection" />
|
||||
<![endif]-->
|
||||
|
||||
<!-- <link type="text/css" href="css/smoothness/jquery-ui-1.8.10.custom.css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script> -->
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-24546333-1']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="ajax-loader" style="display: none;"><img src="images/ajax-loader.gif" class="ajax-loader-image" alt="" /></div>
|
||||
<div id="ajax-loader" style="display: none;"><img
|
||||
src="images/ajax-loader.gif" class="ajax-loader-image" alt="" /></div>
|
||||
<div wicket:id="systemNotice" id="system-notice"></div>
|
||||
<div class="container">
|
||||
<wicket:child />
|
||||
</div>
|
||||
<div class="container"><wicket:child /></div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
<!--[if gt IE 9]> </html> <![endif]-->
|
||||
<!--[if IE 9]> </html> <![endif]-->
|
||||
<!--[if IE 8]> </html> <![endif]-->
|
||||
<!--[if IE 7]> </html> <![endif]-->
|
||||
<!--[if lt IE 7]> </html> <![endif]-->
|
||||
|
||||
|
||||
|
||||
|
@ -103,6 +103,35 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="span-18 last">
|
||||
<h3 wicket:id="tooltipDemo">MouseOver here for tooltip</h3>
|
||||
<h3>Highlighted form components</h3>
|
||||
<div wicket:id="radioChoices"></div>
|
||||
|
||||
<div>
|
||||
<span class="hilight">
|
||||
<!-- Just stick a normal wicket:id onto the input to use it with wicket.
|
||||
To get the highlight effect it must be contained in this span and the order of input+label is important -->
|
||||
<input id="d1" type="checkbox" class="question-display"></input>
|
||||
<label for="d1">Checkbox</label>
|
||||
</span>
|
||||
<span class="hilight">
|
||||
<input id="d2" type="checkbox" checked class="question-display"></input>
|
||||
<label for="d2">Checked Checkbox</label>
|
||||
</span>
|
||||
|
||||
<span class="hilight">
|
||||
<input id="d3" type="checkbox" checked disabled class="question-display"></input>
|
||||
<label for="d3">Checked Checkbox disabled</label>
|
||||
</span>
|
||||
|
||||
<span class="hilight">
|
||||
<input id="d4" type="checkbox" disabled class="question-display"></input>
|
||||
<label for="d4">Checkbox disabled</label>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="span-5 last">
|
||||
<h3>Icons</h3>
|
||||
<table>
|
||||
|
@ -1,13 +1,22 @@
|
||||
package se.su.dsv.scipro.basepages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.Component;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.ajax.AjaxRequestTarget;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.components.ExpandableMultiLineLabel;
|
||||
import se.su.dsv.scipro.components.SciProTooltipBehavior;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.icons.AjaxActionIcon;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
|
||||
public class DemoPage extends PublicPage {
|
||||
|
||||
@ -22,6 +31,25 @@ public class DemoPage extends PublicPage {
|
||||
public DemoPage(final PageParameters pp){
|
||||
super(pp);
|
||||
|
||||
/* Highlighted form components */
|
||||
QuestionOption yes = new QuestionOption(null, "Yes");
|
||||
QuestionOption no = new QuestionOption(null, "No");
|
||||
QuestionOption maybe = new QuestionOption(null,"Maybe");
|
||||
List<QuestionOption> options = new ArrayList<QuestionOption>();
|
||||
options.add(yes);options.add(no);options.add(maybe);
|
||||
|
||||
Model<QuestionOption> radioSelectionModel = new Model<QuestionOption>(maybe);
|
||||
|
||||
RadioChoice<QuestionOption> radioChoice = new RadioChoice<QuestionOption>("radioChoices",radioSelectionModel,options);
|
||||
radioChoice.setRenderBodyOnly(true);
|
||||
//Messy stuff needed because Wicket normally just sticks a <br> between each input tag.
|
||||
radioChoice.setPrefix("<span class=\"hilight\">");
|
||||
radioChoice.setSuffix("</span></br>");
|
||||
add(radioChoice);
|
||||
|
||||
Component tooltipAnchor = new WebMarkupContainer("tooltipDemo").add(new SciProTooltipBehavior("Look at the pretty tooltip!"));
|
||||
add(tooltipAnchor);
|
||||
|
||||
add(new ImageIcon("yesIcon", ImageIcon.ICON_YES));
|
||||
add(new ImageIcon("noIcon", ImageIcon.ICON_NO));
|
||||
add(new ImageIcon("checkIcon", ImageIcon.ICON_CHECK));
|
||||
|
@ -52,7 +52,9 @@ public abstract class AbstractMainMenuItem extends Panel {
|
||||
BookmarkablePageLink<Void> result = new BookmarkablePageLink<Void>(id, targetPageClass, pp);
|
||||
result.setOutputMarkupId(true);
|
||||
if(targetPageClass == containerPageClass || (targetPageClass.getSuperclass().isAssignableFrom(containerPageClass) && targetPageClass.getSuperclass() != MenuPage.class) ){
|
||||
result.setMarkupId("current");
|
||||
//TODO Should prefereably be replaced with the line below because repeating id's aren't valid html. I couldn't get the CSS to work though //mpeters
|
||||
result.setMarkupId("current");
|
||||
//result.add(new AttributeAppender("class", new Model<String>("current"), " "));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -6,14 +6,15 @@ import java.util.List;
|
||||
import org.apache.wicket.IClusterable;
|
||||
import org.apache.wicket.Page;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.behavior.AttributeAppender;
|
||||
import org.apache.wicket.behavior.SimpleAttributeModifier;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
|
||||
@ -26,6 +27,7 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
{
|
||||
put(MenuType.NONE, "abstract-menu");
|
||||
put(MenuType.TAB, "abstract-menu tab-menu");
|
||||
put(MenuType.TAB_MULTIPLE_ROWS, "abstract-menu multi-tab-menu");
|
||||
put(MenuType.HORIZONTAL, "abstract-menu horizontal-menu");
|
||||
put(MenuType.VERTICAL, "abstract-menu vertical-menu");
|
||||
}
|
||||
@ -34,12 +36,13 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
public enum MenuType {
|
||||
NONE,
|
||||
TAB,
|
||||
TAB_MULTIPLE_ROWS,
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
}
|
||||
|
||||
|
||||
public AbstractMenuPanel(final String id, final Class<? extends Page> tabCommonSuperClass,final Class<? extends Page> containerClass) {
|
||||
public AbstractMenuPanel(final String id, final Class<? extends Page> menuContainerCommonSuperClass,final Class<? extends Page> containerClass) {
|
||||
super(id);
|
||||
|
||||
final WebMarkupContainer menuContainer = new WebMarkupContainer("menuContainer");
|
||||
@ -52,11 +55,28 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
@Override
|
||||
protected void populateItem( ListItem<MenuItem> item ) {
|
||||
final MenuItem mi = item.getModelObject();
|
||||
if( (mi.getTargetClass().getSuperclass().isAssignableFrom(containerClass)
|
||||
&& mi.getTargetClass().getSuperclass() != tabCommonSuperClass)
|
||||
|| mi.getTargetClass() == containerClass){
|
||||
item.setMarkupId("current");
|
||||
item.setOutputMarkupId(true);
|
||||
boolean highLightAsCurrentByInterface = false;
|
||||
Class<?> menuItemInterface = mi.getMenuHilightInterface();
|
||||
if( menuItemInterface != null ){
|
||||
for( Class<?> actualPageInterface : containerClass.getInterfaces() ){
|
||||
if( actualPageInterface.equals(menuItemInterface) ){
|
||||
highLightAsCurrentByInterface = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( highLightAsCurrentByInterface || mi.getTargetClass() == containerClass
|
||||
||
|
||||
(
|
||||
mi.getTargetClass().getSuperclass().isAssignableFrom(containerClass)
|
||||
&&
|
||||
mi.getTargetClass().getSuperclass() != menuContainerCommonSuperClass
|
||||
)
|
||||
){
|
||||
//item.setMarkupId("current");
|
||||
//item.setOutputMarkupId(true);
|
||||
//Replaced the above because it generates invalid markup if two menus are added to the same page (id no longer unique)
|
||||
item.add(new AttributeAppender("class", new Model<String>("current"), " "));
|
||||
}
|
||||
|
||||
BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>("menuItem", mi.getTargetClass(), mi.getPageParameters());
|
||||
@ -98,22 +118,37 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
private Class<? extends Page> targetClass;
|
||||
private PageParameters pp;
|
||||
private String iconName;
|
||||
private Class<? extends MenuHighlight> menuHilightInterface;
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass) {
|
||||
this(name, targetClass, null, null);
|
||||
this(name, targetClass, null, null, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface) {
|
||||
this(name, targetClass, menuHilightInterface, null, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, PageParameters pp){
|
||||
this(name, targetClass, pp, null);
|
||||
this(name, targetClass, null, pp, null);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, PageParameters pp){
|
||||
this(name, targetClass, menuHilightInterface, pp, null);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, String iconName) {
|
||||
this(name, targetClass, null, iconName);
|
||||
this(name, targetClass, null, null, iconName);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, String iconName) {
|
||||
this(name, targetClass, menuHilightInterface, null, iconName);
|
||||
}
|
||||
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, PageParameters pp, String iconName) {
|
||||
this(name, targetClass, null, pp, iconName);
|
||||
}
|
||||
public MenuItem(final String name, final Class<? extends Page> targetClass, final Class<? extends MenuHighlight> menuHilightInterface, PageParameters pp, String iconName) {
|
||||
this.name = name;
|
||||
this.targetClass = targetClass;
|
||||
this.menuHilightInterface = menuHilightInterface;
|
||||
this.pp = pp;
|
||||
this.iconName = iconName == null ? ImageIcon.ICON_EMPTY : iconName;
|
||||
}
|
||||
@ -133,6 +168,16 @@ public abstract class AbstractMenuPanel extends Panel {
|
||||
public String getIconName() {
|
||||
return iconName;
|
||||
}
|
||||
|
||||
public MenuItem setMenuHilightInterface(Class<? extends MenuHighlight> menuHilightInterface) {
|
||||
this.menuHilightInterface = menuHilightInterface;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Class<? extends MenuHighlight> getMenuHilightInterface() {
|
||||
return menuHilightInterface;
|
||||
}
|
||||
|
||||
|
||||
}//MenuItem
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
/**
|
||||
* An invisible Panel that can trigger the hiding of wicket-enclosures which EmptyPanel doesn't do.
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public final class InvisiblePanel extends WebMarkupContainer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public InvisiblePanel(String id) {
|
||||
super(id);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
12
src/main/java/se/su/dsv/scipro/components/MenuHighlight.java
Normal file
12
src/main/java/se/su/dsv/scipro/components/MenuHighlight.java
Normal file
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
/**
|
||||
* Base interface only signaling intent, that is if a menu item needs to be highlighted.
|
||||
* Should preferably not be used directly, subclass it instead so intent is clear.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface MenuHighlight {
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package se.su.dsv.scipro.components;
|
||||
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.wamblee.wicket.behavior.ServerTooltipBehavior;
|
||||
/**
|
||||
* Attempt at making a generally usable tooltip for all SciPro pages.
|
||||
* I've looked at Mootip, Prototip and both disrupt other Javascript, BeautytipBehavor (visural wicket)
|
||||
* isn't bad but has NO delay and therefore pops up immediately.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class SciProTooltipBehavior extends ServerTooltipBehavior {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SciProTooltipBehavior(String aText) {
|
||||
super(aText);
|
||||
this.background("#FFFF66");
|
||||
this.border("outset grey 1px");
|
||||
this.padding("5px 20px 5px 20px");
|
||||
}
|
||||
public SciProTooltipBehavior(IModel<String> model){
|
||||
this(model.getObject());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,31 +1,44 @@
|
||||
package se.su.dsv.scipro.data.dao.jpa;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
|
||||
/**
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
* @author Martin Peters
|
||||
*
|
||||
*/
|
||||
|
||||
@Repository("generalSystemSettingsDao")
|
||||
public class GeneralSystemSettingsDaoJPAImp extends AbstractDaoJPAImp<GeneralSystemSettings>
|
||||
implements GeneralSystemSettingsDao {
|
||||
|
||||
|
||||
private static final long INSTANCE_ID = 1L;
|
||||
|
||||
public GeneralSystemSettingsDaoJPAImp() {
|
||||
super(GeneralSystemSettings.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = false)
|
||||
public GeneralSystemSettings getGeneralSystemSettingsInstance(){
|
||||
GeneralSystemSettings generalSystemSettings = load(1L);
|
||||
GeneralSystemSettings generalSystemSettings = load(INSTANCE_ID);
|
||||
if (generalSystemSettings == null) {
|
||||
generalSystemSettings = new GeneralSystemSettings();
|
||||
generalSystemSettings = new GeneralSystemSettings(INSTANCE_ID);
|
||||
save(generalSystemSettings);
|
||||
}
|
||||
return generalSystemSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = false)
|
||||
public GeneralSystemSettings save(GeneralSystemSettings object){
|
||||
if(object.getId() == null)
|
||||
throw new UnsupportedOperationException("You're not supposed to be creating new instances of this object manually!");
|
||||
return super.save(object);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@ package se.su.dsv.scipro.data.dataobjects;
|
||||
import javax.persistence.Basic;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
@ -27,8 +26,9 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private Long id = null;
|
||||
@Override
|
||||
public Long getId() { return id; }
|
||||
|
||||
@Basic(optional=false)
|
||||
private int finalSeminarMaxActiveParticipants = 6;
|
||||
@ -40,7 +40,26 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
private int daysBeforeFinalSeminarCanRegisterAsOpponent = 3;
|
||||
|
||||
@Basic(optional=true)
|
||||
private int projectPartnerDaysToLive;
|
||||
private int projectPartnerDaysToLive;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean finalSeminarThesisMustBeAPDF = false;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean peerRatingsEnabled = true;
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean peerDisplayNumberOfReviewsPerformed = true;
|
||||
|
||||
public GeneralSystemSettings(){
|
||||
}
|
||||
/**
|
||||
* Not part of the public API, do NOT USE
|
||||
*/
|
||||
public GeneralSystemSettings(Long id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public int getProjectPartnerDaysToLive() {
|
||||
return projectPartnerDaysToLive;
|
||||
@ -50,10 +69,6 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
this.projectPartnerDaysToLive = projectPartnerDaysToLive;
|
||||
}
|
||||
|
||||
@Basic(optional=false)
|
||||
private boolean finalSeminarThesisMustBeAPDF = false;
|
||||
|
||||
|
||||
public int getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant() {
|
||||
return daysBeforeFinalSeminarCanRegisterAsActiveParticipant;
|
||||
}
|
||||
@ -80,26 +95,27 @@ public class GeneralSystemSettings extends DomainObject{
|
||||
this.finalSeminarMaxActiveParticipants = finalSeminarMaxActiveParticipants;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return the finalSeminarThesisMustBeAPDF
|
||||
*/
|
||||
public boolean isFinalSeminarThesisMustBeAPDF() {
|
||||
return finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param finalSeminarThesisMustBeAPDF the finalSeminarThesisMustBeAPDF to set
|
||||
*/
|
||||
public void setFinalSeminarThesisMustBeAPDF(boolean finalSeminarThesisMustBeAPDF) {
|
||||
this.finalSeminarThesisMustBeAPDF = finalSeminarThesisMustBeAPDF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getId() {
|
||||
return id;
|
||||
|
||||
public void setPeerRatingsEnabled(boolean peerRatingsEnabled) {
|
||||
this.peerRatingsEnabled = peerRatingsEnabled;
|
||||
}
|
||||
public boolean isPeerRatingsEnabled() {
|
||||
return peerRatingsEnabled;
|
||||
}
|
||||
public void setPeerDisplayNumberOfReviewsPerformed(boolean peerDisplayNumberOfReviewsPerformed) {
|
||||
this.peerDisplayNumberOfReviewsPerformed = peerDisplayNumberOfReviewsPerformed;
|
||||
}
|
||||
public boolean isPeerDisplayNumberOfReviewsPerformed() {
|
||||
return peerDisplayNumberOfReviewsPerformed;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -65,6 +65,9 @@ public class ImageIcon extends Image {
|
||||
if(alt != null){
|
||||
add(new AttributeAppender("alt", true, new Model<String>(alt), " "));
|
||||
}
|
||||
else {
|
||||
add(new AttributeAppender("alt", true, new Model<String>(name), " "));
|
||||
}
|
||||
}
|
||||
|
||||
public ImageIcon(String id, String name){
|
||||
|
@ -1,8 +1,6 @@
|
||||
package se.su.dsv.scipro.opponent.panels;
|
||||
|
||||
import org.apache.wicket.markup.html.WebPage;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Fragment;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
@ -11,7 +9,6 @@ import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
import se.su.dsv.scipro.icons.HelpIconDialog;
|
||||
import se.su.dsv.scipro.icons.HelpIconPanelDialog;
|
||||
|
||||
public class AvailableFinalSeminarHelpPanel extends Panel {
|
||||
@ -29,47 +26,29 @@ public class AvailableFinalSeminarHelpPanel extends Panel {
|
||||
int registerAsOpponent = 0;
|
||||
int registerAsActiveParticpant = 0;
|
||||
int maxActiveParticpants = 0;
|
||||
GeneralSystemSettings settings = generalSystemSettingsDao
|
||||
.getGeneralSystemSettingsInstance();
|
||||
GeneralSystemSettings settings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
|
||||
settings = generalSystemSettingsDao.save(settings);
|
||||
registerAsActiveParticpant = settings
|
||||
.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant();
|
||||
registerAsOpponent = settings
|
||||
.getDaysBeforeFinalSeminarCanRegisterAsOpponent();
|
||||
registerAsActiveParticpant = settings.getDaysBeforeFinalSeminarCanRegisterAsActiveParticipant();
|
||||
registerAsOpponent = settings.getDaysBeforeFinalSeminarCanRegisterAsOpponent();
|
||||
maxActiveParticpants = settings.getFinalSeminarMaxActiveParticipants();
|
||||
|
||||
ProjectClassSettings bachelorSettings = projectClassDao
|
||||
.getProjectClass(ProjectClass.BACHELOR)
|
||||
.getProjectClassSettings();
|
||||
ProjectClassSettings masterSettings = projectClassDao.getProjectClass(
|
||||
ProjectClass.MASTER).getProjectClassSettings();
|
||||
int maxOpponentsBachelor = bachelorSettings
|
||||
.getMaxOpponentsOnFinalSeminar();
|
||||
ProjectClassSettings bachelorSettings = projectClassDao.getProjectClass(ProjectClass.BACHELOR).getProjectClassSettings();
|
||||
ProjectClassSettings masterSettings = projectClassDao.getProjectClass(ProjectClass.MASTER).getProjectClassSettings();
|
||||
int maxOpponentsBachelor = bachelorSettings.getMaxOpponentsOnFinalSeminar();
|
||||
int maxOpponentsMaster = masterSettings.getMaxOpponentsOnFinalSeminar();
|
||||
int maxActiveParticipationBachelor = bachelorSettings
|
||||
.getMaxFinalSeminarActiveParticipation();
|
||||
int maxActiveParticipationMaster = masterSettings
|
||||
.getMaxFinalSeminarActiveParticipation();
|
||||
int maxOppositionsBachelor = bachelorSettings
|
||||
.getMaxRegisterAsOpponent();
|
||||
int maxActiveParticipationBachelor = bachelorSettings.getMaxFinalSeminarActiveParticipation();
|
||||
int maxActiveParticipationMaster = masterSettings.getMaxFinalSeminarActiveParticipation();
|
||||
int maxOppositionsBachelor = bachelorSettings.getMaxRegisterAsOpponent();
|
||||
int maxOppositionsMaster = masterSettings.getMaxRegisterAsOpponent();
|
||||
add(new Label("maxActiveParticpants",
|
||||
String.valueOf(maxActiveParticpants)));
|
||||
add(new Label("activeRegister",
|
||||
String.valueOf(registerAsActiveParticpant)));
|
||||
add(new Label("maxActiveParticpants", String.valueOf(maxActiveParticpants)));
|
||||
add(new Label("activeRegister", String.valueOf(registerAsActiveParticpant)));
|
||||
add(new Label("opponentRegister", String.valueOf(registerAsOpponent)));
|
||||
add(new Label("maxOpponentsBachelor",
|
||||
String.valueOf(maxOpponentsBachelor)));
|
||||
add(new Label("maxOpponentsBachelor", String.valueOf(maxOpponentsBachelor)));
|
||||
add(new Label("maxOpponentsMaster", String.valueOf(maxOpponentsMaster)));
|
||||
add(new Label("maxActiveBachelor",
|
||||
String.valueOf(maxActiveParticipationBachelor)));
|
||||
add(new Label("maxActiveMaster",
|
||||
String.valueOf(maxActiveParticipationMaster)));
|
||||
add(new Label("maxOppositionsBachelor",
|
||||
String.valueOf(maxOppositionsBachelor)));
|
||||
add(new Label("maxOppositionsMaster",
|
||||
String.valueOf(maxOppositionsMaster)));
|
||||
add(new Label("maxActiveBachelor", String.valueOf(maxActiveParticipationBachelor)));
|
||||
add(new Label("maxActiveMaster", String.valueOf(maxActiveParticipationMaster)));
|
||||
add(new Label("maxOppositionsBachelor", String.valueOf(maxOppositionsBachelor)));
|
||||
add(new Label("maxOppositionsMaster", String.valueOf(maxOppositionsMaster)));
|
||||
}
|
||||
|
||||
public Panel getHelpIcon(String id) {
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
@ -24,14 +25,12 @@ public class ProjectFinalSeminarContainerPanel extends Panel {
|
||||
|
||||
final List<FinalSeminar> seminars = finalSeminarDao.findFinalSeminarsByProject(project);
|
||||
|
||||
add(new OpponentPanel("addSeminar", project){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return seminars.size() == 0 && isSupervisorView;
|
||||
}
|
||||
});
|
||||
if(isSupervisorView && !seminars.isEmpty() ){
|
||||
add(new OpponentPanel("addSeminar", project));
|
||||
}
|
||||
else {
|
||||
add(new EmptyPanel("addSeminar"));
|
||||
}
|
||||
add(new Label("noSeminarsMessage", "No final seminar has been created for this project"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.controllers;
|
||||
|
||||
/**
|
||||
* toStrings could be replaced with keys for property lookups if this were to be translated.
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public enum NotReviewableReason {
|
||||
|
||||
PART_OF_PROJECT
|
||||
{@Override
|
||||
public String toString() {
|
||||
return "You are part of this project";
|
||||
}},
|
||||
RECENTLY_REVIEWED{@Override
|
||||
public String toString() {
|
||||
return "You have recently reviewed work from this project";
|
||||
}},
|
||||
DIFFERENT_PROJECTCLASS{@Override
|
||||
public String toString() {
|
||||
return "This request is in a different level";
|
||||
}},
|
||||
OTHERS_PAST_PRIORITY_AGE{@Override
|
||||
public String toString() {
|
||||
return "There are other prioritized requests";
|
||||
}},
|
||||
YOU_ARE_SUPERVISOR{@Override
|
||||
public String toString() {
|
||||
return "You cannot review in your supervisor-role";
|
||||
}},
|
||||
OTHER
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package se.su.dsv.scipro.peer.data.dao.controllers;
|
||||
|
||||
public class Pair<H,T>{
|
||||
|
||||
public final H head;
|
||||
|
||||
public final T tail;
|
||||
|
||||
public Pair(H head, T tail){
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,7 @@ public interface PeerPortalController {
|
||||
|
||||
public List<Tuple> getPeerRequests(final ProjectClass projectClass, final Project project, final Student student);
|
||||
|
||||
public boolean isReviewableTo(final PeerRequest peerRequest, final Student student, final Project project);
|
||||
public Pair<Boolean,NotReviewableReason> isReviewableTo(final PeerRequest peerRequest, final Student student, final Project project);
|
||||
|
||||
public PeerReview acceptReview(PeerRequest request, Student student, Project project) throws Exception;
|
||||
|
||||
|
@ -95,7 +95,9 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
int given = peerReviewDao.countReviewsGiven(requestingStudent, requestingProject);
|
||||
int received = peerReviewDao.countReviewsReceived(requestingStudent, requestingProject);
|
||||
|
||||
boolean isReviewable = this.isReviewableTo(peerRequest, student, project); //Checks basics reviewable rules
|
||||
Pair<Boolean,NotReviewableReason> pair = this.isReviewableTo(peerRequest, student, project); //Checks basics reviewable rules
|
||||
NotReviewableReason notReviewableReason = pair.tail;
|
||||
boolean isReviewable = pair.head;
|
||||
if( isReviewable ){ //If it's reviewable at all do following:
|
||||
/*
|
||||
* Reviews come sorted, oldest first. If it's older than priorityDate, flag that we've found
|
||||
@ -111,15 +113,17 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
* reviewable.
|
||||
*/
|
||||
isReviewable = reviewOlderThanPriorityDate;
|
||||
notReviewableReason = NotReviewableReason.OTHERS_PAST_PRIORITY_AGE;
|
||||
}
|
||||
if( (given - received > 0) ) {
|
||||
/*
|
||||
* ..except those with good ratio, they are reviewable any time
|
||||
*/
|
||||
isReviewable = true;
|
||||
notReviewableReason = null;
|
||||
}
|
||||
}
|
||||
result.add(new Tuple(peerRequest, isReviewable , given, received ));
|
||||
result.add(new Tuple(peerRequest, isReviewable , given, received, notReviewableReason));
|
||||
}
|
||||
|
||||
Collections.sort(result, new Comparator<Tuple>() {
|
||||
@ -133,16 +137,18 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for "basic reviewability". Does not take into account the more complex rule that looks at all other available requests
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean isReviewableTo(final PeerRequest peerRequest, final Student student, final Project activeProject){
|
||||
public Pair<Boolean,NotReviewableReason> isReviewableTo(final PeerRequest peerRequest, final Student student, final Project activeProject){
|
||||
if( student == null || activeProject == null || peerRequest == null )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.YOU_ARE_SUPERVISOR);
|
||||
|
||||
final Project requestingProject = peerRequest.getProject();
|
||||
final ProjectClass requestingProjectClass = requestingProject.getProjectClass();
|
||||
@ -152,10 +158,10 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
* happening but it's a cheap safeguard.
|
||||
*/
|
||||
if( !requestingProjectClass.equals(reviewingProjectClass) )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.DIFFERENT_PROJECTCLASS);
|
||||
//You may not review something you're part of!
|
||||
if( projectDao.isPartOf(student.getUser(), requestingProject ) )
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.PART_OF_PROJECT);
|
||||
|
||||
/*
|
||||
* This last section handles reviews performed previously by the student on the same
|
||||
@ -177,12 +183,12 @@ public class PeerPortalControllerImpl implements PeerPortalController {
|
||||
if( sameProject ){
|
||||
boolean reviewPerformedBeforeLimit = pr.getLastModified().compareTo( earliestPermissibleDateSinceReview.toDate() ) > 0;
|
||||
if( reviewPerformedBeforeLimit ){
|
||||
return false;
|
||||
return new Pair<Boolean,NotReviewableReason>(false,NotReviewableReason.RECENTLY_REVIEWED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return new Pair<Boolean,NotReviewableReason>(true,null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -11,11 +11,14 @@ public class Tuple implements IClusterable {
|
||||
public final boolean isReviewable;
|
||||
public final Integer givenReviews;
|
||||
public final Integer receivedReviews;
|
||||
public final NotReviewableReason notReviewableReason;
|
||||
|
||||
public Tuple(PeerRequest peerRequest, boolean isReviewable, int givenReviews, int receivedReviews){
|
||||
public Tuple(PeerRequest peerRequest, boolean isReviewable, int givenReviews, int receivedReviews, NotReviewableReason notReviewableReason){
|
||||
this.peerRequest = peerRequest;
|
||||
this.isReviewable = isReviewable;
|
||||
this.givenReviews = givenReviews;
|
||||
this.receivedReviews = receivedReviews;
|
||||
}
|
||||
this.notReviewableReason = notReviewableReason;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package se.su.dsv.scipro.peer.interfaces;
|
||||
|
||||
import se.su.dsv.scipro.components.MenuHighlight;
|
||||
/**
|
||||
* Used to highlight hierarchy for peer review pages
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public interface MenuHighlightReviewPage extends MenuHighlight{
|
||||
|
||||
}
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
@ -13,6 +12,7 @@ import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.exceptions.AccessDeniedException;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectPage;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
@ -30,7 +30,7 @@ public abstract class AbstractProjectPeerPage extends ProjectPage {
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("Peer portal", ProjectPeerPortalPage.class, ImageIcon.ICON_FIND));
|
||||
items.add(new MenuItem("My requests & reviews", ProjectPeerStatsPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("My requests & reviews", ProjectPeerStatsPage.class, MenuHighlightReviewPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("Request peer review", PeerRequestSubmissionPage.class, ImageIcon.ICON_ADD));
|
||||
items.add(new MenuItem("How to write a good review", ProjectPeerReviewGuidePage.class, ImageIcon.ICON_HELP));
|
||||
return items;
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import se.su.dsv.scipro.components.AbstractMenuPanel;
|
||||
import se.su.dsv.scipro.icons.ImageIcon;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.supervisor.pages.AbstractSupervisorPage;
|
||||
@ -21,7 +22,7 @@ public abstract class AbstractSupervisorPeerPage extends AbstractSupervisorPage
|
||||
@Override
|
||||
protected List<MenuItem> getItemList() {
|
||||
final List<MenuItem> items = new ArrayList<MenuItem>();
|
||||
items.add(new MenuItem("My projects", SupervisorPeerStatsPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("My projects", SupervisorPeerStatsPage.class, MenuHighlightReviewPage.class, ImageIcon.ICON_STATISTICS));
|
||||
items.add(new MenuItem("Peer portal", SupervisorPeerPortalPage.class, ImageIcon.ICON_FIND));
|
||||
items.add(new MenuItem("How to write a good review", SupervisorPeerReviewGuidePage.class, ImageIcon.ICON_HELP));
|
||||
return items;
|
||||
|
@ -1,55 +0,0 @@
|
||||
package se.su.dsv.scipro.peer.pages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.basepages.MenuPage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.MailEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.MailEvent;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.QuestionDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewTemplateDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.Question;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.QuestionOption;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.ReviewTemplate;
|
||||
import se.su.dsv.scipro.security.auth.Authorization;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
|
||||
@Authorization(authorizedRoles={Roles.SYSADMIN})
|
||||
public class PeerTestPage extends MenuPage {
|
||||
|
||||
@SpringBean
|
||||
private QuestionDao questionDao;
|
||||
@SpringBean
|
||||
private ReviewTemplateDao rtDao;
|
||||
@SpringBean
|
||||
private UserDao userDao;
|
||||
@SpringBean
|
||||
private MailEventDao mailEventDao;
|
||||
|
||||
public PeerTestPage(){
|
||||
ReviewTemplate rt = new ReviewTemplate();
|
||||
rt.setName("Template for something");
|
||||
Question q = new Question();
|
||||
q.setQuestion("Really?");
|
||||
q.setRadioChoiceQuestion(true);
|
||||
q.setReviewTemplate(rt);
|
||||
q.getRadioOptions().add(new QuestionOption(q, "Yes"));
|
||||
q.getRadioOptions().add(new QuestionOption(q, "No"));
|
||||
|
||||
rt.getQuestions().add(q);
|
||||
//rt = rtDao.save(rt);
|
||||
System.out.println(questionDao.findAll());
|
||||
System.out.println(questionDao.findAll().get(0).getRadioOptions());
|
||||
|
||||
User recipient = userDao.getUserByUsername("mpeters");
|
||||
User replyUser = userDao.getUserByUsername("dan-kjel");
|
||||
ArrayList<User> senderstmp = new ArrayList<User>();
|
||||
senderstmp.add(replyUser);
|
||||
MailEvent me = new MailEvent("subject åäö","this is the message åäö",recipient,"SciPro-avsändare åäö","no-reply@thesis.dsv.su.se", senderstmp,null);
|
||||
me = mailEventDao.save(me);
|
||||
}
|
||||
|
||||
}
|
@ -6,9 +6,10 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.exceptions.PageNotFoundException;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.peer.panels.PeerReviewPanel;
|
||||
|
||||
public class ProjectPeerReviewPage extends AbstractProjectPeerPage {
|
||||
public class ProjectPeerReviewPage extends AbstractProjectPeerPage implements MenuHighlightReviewPage {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
@ -6,9 +6,10 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import se.su.dsv.scipro.exceptions.PageNotFoundException;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.interfaces.MenuHighlightReviewPage;
|
||||
import se.su.dsv.scipro.peer.panels.PeerReviewPanel;
|
||||
|
||||
public class SupervisorPeerReviewPage extends AbstractSupervisorPeerPage {
|
||||
public class SupervisorPeerReviewPage extends AbstractSupervisorPeerPage implements MenuHighlightReviewPage {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
@ -29,6 +29,7 @@
|
||||
<!-- List of available reviews -->
|
||||
<div class="prepend-top append-bottom span-14 last">
|
||||
<!-- Review -->
|
||||
<div wicket:id="topNavigator" class="append-bottom"></div>
|
||||
<div wicket:id="requestList" class="append-bottom span-14 last bordered-box">
|
||||
<h5 wicket:id="projectTitle" class="bordered-box-title">The superduper project</h5>
|
||||
<div class="peer-request-content bordered-box-content">
|
||||
@ -50,33 +51,42 @@
|
||||
<span wicket:id="requestComment"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
<a wicket:id="reviewLink" href="#" class="button">Review this request
|
||||
<img src="css/blueprint/plugins/buttons/icons/tick.png" alt=""/>
|
||||
</a>
|
||||
|
||||
<span wicket:id="notReviewableMsg" class="disabled-button">
|
||||
<img src="css/blueprint/plugins/buttons/icons/cross.png" alt=""/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- End review -->
|
||||
<div wicket:id="bottomNavigator"></div>
|
||||
</div>
|
||||
<!-- End of available reviews -->
|
||||
</div>
|
||||
<!-- End left column -->
|
||||
<div class="span-6 last">
|
||||
<wicket:enclosure>
|
||||
<div class="rounded-box">
|
||||
<span class="box-title">Most frequent reviewers</span>
|
||||
<div wicket:id="mostFrequentPanel" class="append-bottom"></div>
|
||||
</div>
|
||||
<div class="rounded-box">
|
||||
</wicket:enclosure>
|
||||
|
||||
<div class="rounded-box" wicket:id="bestRatedContainer">
|
||||
<span class="box-title">Best rated reviewers</span>
|
||||
<div wicket:id="bestRatedPanel" class="append-bottom"></div>
|
||||
</div>
|
||||
<div>
|
||||
<i><span class="small right">Last 12 months</span></i>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</wicket:panel>
|
||||
|
@ -6,11 +6,12 @@ import java.util.List;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.link.Link;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.panel.EmptyPanel;
|
||||
import org.apache.wicket.markup.html.list.PageableListView;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.Model;
|
||||
@ -19,11 +20,16 @@ import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
import org.apache.wicket.util.string.Strings;
|
||||
|
||||
import se.su.dsv.scipro.components.ExpandableMultiLineLabel;
|
||||
import se.su.dsv.scipro.components.InvisiblePanel;
|
||||
import se.su.dsv.scipro.components.SciProTooltipBehavior;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClassSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.exceptions.UpdatedSincePageLoadException;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.NotReviewableReason;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.PeerPortalController;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.Tuple;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
@ -35,22 +41,26 @@ import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.util.JavascriptEventConfirmation;
|
||||
|
||||
public class PeerPortalPanel extends Panel {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
private static final int REQUESTS_PER_PAGE = 8;
|
||||
|
||||
@SpringBean
|
||||
private PeerPortalController peerPortalController;
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
|
||||
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
|
||||
public PeerPortalPanel(final String id, final ProjectClass projectClass){
|
||||
this(id, null, null, projectClass);
|
||||
}
|
||||
|
||||
|
||||
public PeerPortalPanel(final String id, final Project project, final Student student, final ProjectClass nullIfStudentViewProjectClass){
|
||||
super(id);
|
||||
|
||||
|
||||
final ProjectClass projectClass;
|
||||
if(project == null) {
|
||||
projectClass = nullIfStudentViewProjectClass;
|
||||
@ -58,9 +68,9 @@ public class PeerPortalPanel extends Panel {
|
||||
else {
|
||||
projectClass = project.getProjectClass();
|
||||
}
|
||||
|
||||
|
||||
List<Tuple> requests = peerPortalController.getPeerRequests(projectClass, project, student);
|
||||
|
||||
|
||||
add(new Label("numRequests", "" + requests.size()));
|
||||
add(new Label("requestsInClass", new Model<String>(){
|
||||
private static final long serialVersionUID = 1L;
|
||||
@ -70,39 +80,40 @@ public class PeerPortalPanel extends Panel {
|
||||
return projectClass.getName().toLowerCase();
|
||||
}
|
||||
}));
|
||||
ProjectClassSettings projectClassSettings = projectClass.getProjectClassSettings();
|
||||
|
||||
final ProjectClassSettings projectClassSettings = projectClass.getProjectClassSettings();
|
||||
|
||||
add(new Label("getNumDaysToSubmitPeerReview", new PropertyModel<String>(projectClassSettings, "getNumDaysToSubmitPeerReview")));
|
||||
add(new Label("getNumDaysBetweenPeerReviewsOnSameProject", new PropertyModel<String>(projectClassSettings, "getNumDaysBetweenPeerReviewsOnSameProject")));
|
||||
add(new Label("getNumDaysBeforePeerRequestPriority", new PropertyModel<String>(projectClassSettings, "getNumDaysBeforePeerRequestPriority")));
|
||||
|
||||
|
||||
|
||||
|
||||
add(new FeedbackPanel("feedbackPanel"));
|
||||
|
||||
|
||||
final PatternDateConverter dpc = new PatternDateConverter("yyyy-MM-dd HH:mm", false);
|
||||
|
||||
final ListView<Tuple> requestList = new ListView<Tuple>("requestList", requests){
|
||||
|
||||
final PageableListView<Tuple> requestList = new PageableListView<Tuple>("requestList", requests, REQUESTS_PER_PAGE ){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
protected void populateItem(ListItem<Tuple> item) {
|
||||
final PeerRequest request = item.getModelObject().peerRequest;
|
||||
final boolean isReviewable = item.getModelObject().isReviewable;
|
||||
final NotReviewableReason notReviewableReason = item.getModelObject().notReviewableReason;
|
||||
final String projectTitle = request.getProject().getTitle();
|
||||
final int daysToComplete = request.getProject().getProjectClass().getProjectClassSettings().getNumDaysToSubmitPeerReview();
|
||||
final int daysToComplete = projectClassSettings.getNumDaysToSubmitPeerReview();
|
||||
item.add(new Label("projectTitle", projectTitle ));
|
||||
item.add(new DateLabel("requestDate", new Model<Date>(request.getDateCreated()), dpc));
|
||||
item.add(request.getRequester().getUser().getDisplayComponent("requester"));
|
||||
|
||||
|
||||
Student requestingStudent = request.getRequester();
|
||||
Project requestingProject = request.getProject();
|
||||
Integer given = peerReviewDao.countReviewsGiven(requestingStudent, requestingProject);
|
||||
Integer received = peerReviewDao.countReviewsReceived(requestingStudent, requestingProject);
|
||||
item.add(new Label("given", given.toString() ));
|
||||
item.add(new Label("received", received.toString() ));
|
||||
|
||||
|
||||
Link<Void> templateLink = PeerReviewTemplatePreviewPage.getPopupLink("templateLink", request.getReviewTemplate() );
|
||||
|
||||
|
||||
templateLink.add(new Label("templateName", new Model<String>(){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -111,68 +122,112 @@ public class PeerPortalPanel extends Panel {
|
||||
return request.getReviewTemplate() != null ? request.getReviewTemplate().getName() : "No template attached";
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
templateLink.setEnabled(request.getReviewTemplate() != null);
|
||||
item.add(templateLink);
|
||||
|
||||
|
||||
if(request.getComment() != null){
|
||||
item.add(new ExpandableMultiLineLabel("requestComment", 50, request.getComment(), false));
|
||||
} else {
|
||||
item.add(new Label("requestComment", "No comment provided"));
|
||||
}
|
||||
|
||||
if(student != null && project != null){
|
||||
Link<Void> reviewLink = new Link<Void>("reviewLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
Link<Void> reviewLink = new Link<Void>("reviewLink"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return isReviewable;
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return isReviewable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick() {
|
||||
try{
|
||||
PeerReview review = peerPortalController.acceptReview(request, student, project);
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PeerReview.PP_PEER_REVIEW_ID, review.getId());
|
||||
setResponsePage(ProjectPeerReviewPage.class, pp);
|
||||
} catch (UpdatedSincePageLoadException ue) {
|
||||
getSession().error("Another user has already accepted the request, please choose another one");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
} catch (Exception e){
|
||||
getSession().error("An error occured, please try again");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
}
|
||||
@Override
|
||||
public void onClick() {
|
||||
try{
|
||||
PeerReview review = peerPortalController.acceptReview(request, student, project);
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PeerReview.PP_PEER_REVIEW_ID, review.getId());
|
||||
setResponsePage(ProjectPeerReviewPage.class, pp);
|
||||
} catch (UpdatedSincePageLoadException ue) {
|
||||
error("Another user has already accepted the request, please choose another one");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
} catch (Exception e){
|
||||
error("An error occured, please try again");
|
||||
setResponsePage(ProjectPeerPortalPage.class);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
};
|
||||
if(isReviewable){
|
||||
String confirmString = "Please confirm that you want to peer review \""+projectTitle+"\" within "+daysToComplete+" days.";
|
||||
confirmString = Strings.escapeMarkup(confirmString, true, true).toString();
|
||||
reviewLink.add(new JavascriptEventConfirmation("onClick", confirmString));
|
||||
|
||||
item.add(reviewLink);
|
||||
} else {
|
||||
item.add(new EmptyPanel("reviewLink"));
|
||||
}
|
||||
|
||||
item.add(new Label("notReviewableMsg", "You cannot review this request"){
|
||||
item.add(reviewLink);
|
||||
|
||||
Label notReviewableMsg = new Label("notReviewableMsg", "You cannot review this request"){
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
return !isReviewable;
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
item.add(notReviewableMsg);
|
||||
|
||||
if( notReviewableReason != null){
|
||||
notReviewableMsg.add( new SciProTooltipBehavior( notReviewableReason.toString() ) );
|
||||
}
|
||||
|
||||
add(item);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
add(requestList);
|
||||
|
||||
add(new MostFrequentReviewersPanel("mostFrequentPanel"));
|
||||
add(new BestRatedReviewersPanel("bestRatedPanel"));
|
||||
class RequestListNavigator extends PagingNavigator{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Boolean visible = null;
|
||||
|
||||
public RequestListNavigator(String id, org.apache.wicket.markup.html.navigation.paging.IPageable pageable) {
|
||||
super(id, pageable);
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible(){
|
||||
if(visible == null){
|
||||
if(REQUESTS_PER_PAGE > requestList.getViewSize()){
|
||||
visible = false;
|
||||
} else {
|
||||
visible = true;
|
||||
}
|
||||
}
|
||||
return visible;
|
||||
}
|
||||
@Override
|
||||
public void onDetach(){
|
||||
visible = null;
|
||||
super.onDetach();
|
||||
}
|
||||
}
|
||||
|
||||
PagingNavigator topRequestListNavigator = new RequestListNavigator("topNavigator", requestList);
|
||||
add(topRequestListNavigator);
|
||||
|
||||
PagingNavigator bottomRequestListNavigator = new RequestListNavigator("bottomNavigator", requestList);
|
||||
add(bottomRequestListNavigator);
|
||||
|
||||
GeneralSystemSettings gsettings = generalSystemSettingsDao.getGeneralSystemSettingsInstance();
|
||||
final String mostFrequentPanel = "mostFrequentPanel";
|
||||
final String bestRatedContainer = "bestRatedContainer";
|
||||
|
||||
if(gsettings.isPeerDisplayNumberOfReviewsPerformed()){
|
||||
add(new MostFrequentReviewersPanel(mostFrequentPanel));
|
||||
} else {
|
||||
add(new InvisiblePanel(mostFrequentPanel));
|
||||
}
|
||||
if( gsettings.isPeerRatingsEnabled() ){
|
||||
add(new WebMarkupContainer(bestRatedContainer).add(new BestRatedReviewersPanel("bestRatedPanel") ) );
|
||||
} else {
|
||||
add(new InvisiblePanel(bestRatedContainer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package se.su.dsv.scipro.peer.panels;
|
||||
|
||||
import org.apache.wicket.feedback.FeedbackMessage;
|
||||
import org.apache.wicket.feedback.IFeedbackMessageFilter;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
|
||||
@ -20,14 +18,7 @@ public class PeerReviewPanel extends Panel {
|
||||
add(new DisplayReviewPanel("displayReview", review));
|
||||
add(new CommentThreadPanel("comments",review, 4));
|
||||
|
||||
add(new FeedbackPanel("feedback", new IFeedbackMessageFilter() {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public boolean accept(FeedbackMessage message) {
|
||||
return message.getLevel() == FeedbackMessage.INFO;
|
||||
}
|
||||
}));
|
||||
add(new FeedbackPanel("feedback"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
<div class="span-12 last">
|
||||
<form wicket:id="reviewForm">
|
||||
<div wicket:id="topFeedbackPanel" class="last"></div>
|
||||
<!-- <div wicket:id="topFeedbackPanel" class="last"></div>-->
|
||||
|
||||
<div class="prepend-top last">
|
||||
<h5 class="peer-title" wicket:id="questionsHeading">Questions</h5>
|
||||
@ -24,8 +24,15 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<wicket:enclosure>
|
||||
<div class="last append-bottom">
|
||||
<h5 class="peer-title">General comments</h5>
|
||||
<h5 class="peer-title">Comment from requester</h5>
|
||||
<div wicket:id="requestComment"></div>
|
||||
</div>
|
||||
</wicket:enclosure>
|
||||
|
||||
<div class="last append-bottom">
|
||||
<h5 class="peer-title">Your comments</h5>
|
||||
<textarea wicket:id="reviewComment"></textarea>
|
||||
</div>
|
||||
<div class="last append-bottom">
|
||||
|
@ -10,6 +10,7 @@ import org.apache.wicket.RequestCycle;
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.MultiLineLabel;
|
||||
import org.apache.wicket.markup.html.form.Button;
|
||||
import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
@ -58,8 +59,7 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
// @SpringBean
|
||||
// private AnswerDao answerDao;
|
||||
|
||||
@SpringBean
|
||||
private PeerRequestDao peerRequestDao;
|
||||
|
||||
@ -166,6 +166,13 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
MultiLineLabel requestComment = new MultiLineLabel("requestComment", reviewModel.getObject().getPeerRequest().getComment());
|
||||
if(reviewModel.getObject().getPeerRequest().getComment() == null)
|
||||
requestComment.setVisible(false);
|
||||
add(requestComment);
|
||||
|
||||
|
||||
commentTextArea = new TextArea<String>("reviewComment", new PropertyModel<String>(reviewModel, "comment"));
|
||||
add(commentTextArea);
|
||||
|
||||
@ -276,7 +283,7 @@ public class PeerReviewPerformReviewPanel extends Panel {
|
||||
"Please confirm that you have completed the review and taken care to highlight both strengths and weaknesses."));
|
||||
add(submitButton);
|
||||
|
||||
add(new ComponentFeedbackPanel("topFeedbackPanel",submitButton));
|
||||
//add(new ComponentFeedbackPanel("topFeedbackPanel",submitButton));
|
||||
add(new ComponentFeedbackPanel("bottomFeedbackPanel",submitButton));
|
||||
}//PerformReviewForm
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
<li><strong>Accept date: </strong><span wicket:id="acceptDate">2011-03-08 10:58</span></li>
|
||||
</ul>
|
||||
|
||||
<div>
|
||||
<div wicket:id="ratingPanelContainer">
|
||||
<strong>Review rating:</strong>
|
||||
<div wicket:id="ratingPanel"></div>
|
||||
</div>
|
||||
|
@ -4,19 +4,18 @@ import java.util.Date;
|
||||
|
||||
import org.apache.wicket.datetime.PatternDateConverter;
|
||||
import org.apache.wicket.datetime.markup.html.basic.DateLabel;
|
||||
import org.apache.wicket.markup.html.WebMarkupContainer;
|
||||
import org.apache.wicket.markup.html.basic.Label;
|
||||
import org.apache.wicket.markup.html.panel.Panel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.Model;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.components.InvisiblePanel;
|
||||
import se.su.dsv.scipro.data.DomainObjectDetachableModel;
|
||||
import se.su.dsv.scipro.data.dataobjects.FileDescription;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.repository.components.FileDownloadLink;
|
||||
import se.su.dsv.scipro.repository.components.FileOpenLink;
|
||||
|
||||
public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
|
||||
@ -24,6 +23,8 @@ public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
|
||||
@SpringBean
|
||||
private PeerReviewDao peerReviewDao;
|
||||
@SpringBean
|
||||
private GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
|
||||
public ReviewPageReviewDetailsPanel(final String id, final PeerReview review) {
|
||||
super(id);
|
||||
@ -36,7 +37,13 @@ public class ReviewPageReviewDetailsPanel extends Panel {
|
||||
add(review.getReviewer().getUser().getDisplayComponent("reviewer"));
|
||||
add(review.getProject().getHeadSupervisor().getUser().getDisplayComponent("supervisor"));
|
||||
add(new DateLabel("acceptDate", new Model<Date>(review.getDateCreated()), dpc));
|
||||
add(new PeerReviewRatingPanel("ratingPanel", reviewModel ));
|
||||
|
||||
final String ratingPanelContainer = "ratingPanelContainer";
|
||||
if(generalSystemSettingsDao.getGeneralSystemSettingsInstance().isPeerRatingsEnabled()){
|
||||
add(new WebMarkupContainer(ratingPanelContainer).add(new PeerReviewRatingPanel("ratingPanel", reviewModel )));
|
||||
} else {
|
||||
add(new InvisiblePanel(ratingPanelContainer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,15 +15,12 @@ import org.apache.wicket.markup.html.form.Form;
|
||||
import org.apache.wicket.markup.html.form.RadioChoice;
|
||||
import org.apache.wicket.markup.html.form.SubmitLink;
|
||||
import org.apache.wicket.markup.html.form.TextArea;
|
||||
import org.apache.wicket.markup.html.list.ListItem;
|
||||
import org.apache.wicket.markup.html.list.ListView;
|
||||
import org.apache.wicket.markup.html.navigation.paging.PagingNavigator;
|
||||
import org.apache.wicket.markup.html.panel.FeedbackPanel;
|
||||
import org.apache.wicket.markup.repeater.Item;
|
||||
import org.apache.wicket.markup.repeater.data.DataView;
|
||||
import org.apache.wicket.model.CompoundPropertyModel;
|
||||
import org.apache.wicket.model.IModel;
|
||||
import org.apache.wicket.model.LoadableDetachableModel;
|
||||
import org.apache.wicket.model.PropertyModel;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
|
@ -115,8 +115,10 @@ public class FileOpenLink extends ResourceLink<Void> {
|
||||
in = fileRepository.retrieveFileByIdentifier(fileDesc.getIdentifier());
|
||||
return in;
|
||||
}
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
in.close();
|
||||
if( in != null )
|
||||
in.close();
|
||||
}
|
||||
@Override
|
||||
public long length(){
|
||||
|
@ -33,7 +33,6 @@ public class RepositoryDownloadPage extends WebPage {
|
||||
failAndRedirect();
|
||||
|
||||
String uuid = pp.getString(PP_KEY);
|
||||
//System.out.println("Attempting to download:"+uuid);
|
||||
try{
|
||||
FileDescription fd = fileRepository.retrieveFileDescriptionByIdentifier(uuid);
|
||||
IResourceStream stream = fileRepository.getFileStream(fd);
|
||||
|
@ -22,8 +22,6 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
|
||||
private long projectId;
|
||||
|
||||
private static final String PROJECT_URL_KEY = "id";
|
||||
|
||||
@Override
|
||||
protected String getBasePath(){
|
||||
return super.fileRepository.getProjectRootPath(projectId);
|
||||
@ -36,7 +34,7 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
public ProjectFilePanel(String id, PageParameters pp, FilePanelContainer fpc) {
|
||||
super(id, pp, fpc);
|
||||
|
||||
Long projectId = pp.getAsLong(PROJECT_URL_KEY);
|
||||
Long projectId = pp.getAsLong(Project.PP_PROJECT_ID);
|
||||
if(projectId == null){
|
||||
failAndRedirect();
|
||||
}
|
||||
@ -60,13 +58,13 @@ public class ProjectFilePanel extends AbstractFilePanel {
|
||||
|
||||
public static PageParameters getPrefabricatedPageParameters(Project project){
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PROJECT_URL_KEY, project.getId());
|
||||
pp.put(Project.PP_PROJECT_ID, project.getId());
|
||||
return pp;
|
||||
}
|
||||
|
||||
public static PageParameters getPrefabricatedPageParameters(Long projectId){
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.put(PROJECT_URL_KEY, projectId);
|
||||
pp.put(Project.PP_PROJECT_ID, projectId);
|
||||
return pp;
|
||||
}
|
||||
|
||||
|
191
src/main/java/se/su/dsv/scipro/security/auth/ExternalAuthenticationRequestHelper.java
Normal file
191
src/main/java/se/su/dsv/scipro/security/auth/ExternalAuthenticationRequestHelper.java
Normal file
@ -0,0 +1,191 @@
|
||||
package se.su.dsv.scipro.security.auth;
|
||||
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.wicket.injection.web.InjectorHolder;
|
||||
import org.apache.wicket.spring.injection.annot.SpringBean;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.Username;
|
||||
|
||||
/**
|
||||
* Helper class for performing authentication via request-headers.
|
||||
* Typical usage:
|
||||
* <code>
|
||||
* helper = new ExternalAuthentificationRequestHelper(request);
|
||||
* if(helper.isExternalAuthSupported() && helper.signIn(session))
|
||||
* success();
|
||||
* else
|
||||
* fail();
|
||||
* </code>
|
||||
* @author robi-ekl
|
||||
*
|
||||
*/
|
||||
public final class ExternalAuthenticationRequestHelper{
|
||||
//Wrapped request
|
||||
private final HttpServletRequest req;
|
||||
//remote user attribute
|
||||
private String remoteUser=null;
|
||||
//if remote user is on the username@realm form, this attribute holds the username
|
||||
private String remoteUserId=null;
|
||||
//if remote user is on the username@realm form, this attribute holds the realm
|
||||
private String remoteUserRealm=null;
|
||||
//logger instance
|
||||
private Logger logger = Logger.getLogger(this.getClass());
|
||||
@SpringBean
|
||||
private ApplicationSettings appSettings;
|
||||
/**
|
||||
* Construct a utility wrapper from a servlet request.
|
||||
* Throws IllegalStateException if the request is null.
|
||||
* @param request
|
||||
*/
|
||||
public ExternalAuthenticationRequestHelper(final HttpServletRequest request) throws IllegalStateException{
|
||||
if(request==null)
|
||||
throw new IllegalStateException("Request is null, this is considered illegal.");
|
||||
InjectorHolder.getInjector().inject(this);
|
||||
req = request;
|
||||
formatUserString();
|
||||
}
|
||||
/**
|
||||
* Exposed query method.
|
||||
* @return The remote user as retrieved from the request, null if none exists.
|
||||
*/
|
||||
public String getExternalAuthRemoteUser(){
|
||||
return remoteUser;
|
||||
}
|
||||
/**
|
||||
* Exposed query method.
|
||||
* @return If remote user is on the username@realm form, this attribute holds the username, else getExternalAuthRemoteUser().
|
||||
*/
|
||||
public String getExternalAuthRemoteUserId(){
|
||||
return remoteUserId;
|
||||
}
|
||||
/**
|
||||
* Exposed query method.
|
||||
* @return If remote user is on the username@realm form, this attribute holds the realm, else null.
|
||||
*/
|
||||
public String getExternalAuthRemoteUserRealm(){
|
||||
return remoteUserRealm;
|
||||
}
|
||||
/**
|
||||
* Internal query method
|
||||
*/
|
||||
private boolean isExternalAuthInfoOnRequest(){
|
||||
return (remoteUser!=null);
|
||||
}
|
||||
/**
|
||||
* Internal query method
|
||||
*/
|
||||
private String getExternalAuthType(){
|
||||
return req.getAuthType();
|
||||
}
|
||||
/**
|
||||
* Query method.
|
||||
* @return true if the application is configured to accept external authentication and the needed information is available on the request, else false.
|
||||
*/
|
||||
public boolean isExternalAuthSupported(){
|
||||
if(appSettings.isAcceptExternalAuthentication() && !isExternalAuthInfoOnRequest())
|
||||
logger.warn("External authentication support is ON, but REMOTE_USER is not populated");
|
||||
if(!appSettings.isAcceptExternalAuthentication() && isExternalAuthInfoOnRequest())
|
||||
logger.warn("External authentication support is OFF, but REMOTE_USER is populated");
|
||||
return (appSettings.isAcceptExternalAuthentication() && isExternalAuthInfoOnRequest());
|
||||
}
|
||||
/**
|
||||
* Private utility method for dumping headers.
|
||||
*/
|
||||
private void dumpAuthInfo(){
|
||||
logger.debug("---Standard methods---");
|
||||
logger.debug("Request implementation:" + req.getClass().getName());
|
||||
logger.debug("getAuthType = '" + getExternalAuthType() +"'");
|
||||
logger.debug("getRemoteUser = '"+getExternalAuthRemoteUser()+"'");
|
||||
logger.debug("---Scanning explicitly named attributes---");
|
||||
final String[] params = {"Shib-Application-ID","Shib-Session-ID","Shib-Identity-Provider",
|
||||
"Shib-Authentication-Instant","Shib-Authentication-Method","Shib-AuthnContext-Class","Shib-AuthnContext-Decl","REMOTE_USER","HTTP_REMOTE_USER"};
|
||||
for(final String param:params){
|
||||
logger.debug("getParameter'"+param+"' = '"+req.getParameter(param)+"'");
|
||||
logger.debug("getHeader'"+param+"' = '"+req.getHeader(param)+"'");
|
||||
logger.debug("getAttribute'"+param+"' = '"+req.getAttribute(param)+"'");
|
||||
}
|
||||
{
|
||||
logger.debug("---Iterating over all attributes, parameters, headers and ENV-variables---");
|
||||
logger.debug("All available attributes: ");
|
||||
@SuppressWarnings("rawtypes") Enumeration attributes = req.getAttributeNames();
|
||||
while(attributes.hasMoreElements()){
|
||||
String name = (String)attributes.nextElement();
|
||||
logger.debug("\t'"+name+"' = '"+req.getAttribute(name)+"'");
|
||||
}
|
||||
}
|
||||
{
|
||||
logger.debug("All available parameters: ");
|
||||
@SuppressWarnings("rawtypes") Enumeration parameters = req.getParameterNames();
|
||||
while(parameters.hasMoreElements()){
|
||||
String name = (String)parameters.nextElement();
|
||||
logger.debug("\t'"+name+"' = '"+req.getParameter(name)+"'");
|
||||
}
|
||||
}
|
||||
{
|
||||
logger.debug("All available headers: ");
|
||||
@SuppressWarnings("rawtypes") Enumeration headers = req.getHeaderNames();
|
||||
while(headers.hasMoreElements()){
|
||||
String name = (String)headers.nextElement();
|
||||
logger.debug("\t'"+name+"' = '"+req.getHeader(name)+"'");
|
||||
}
|
||||
}
|
||||
{
|
||||
logger.debug("All available ENV-variables:");
|
||||
Map<String,String> envs = System.getenv();
|
||||
for(String key : envs.keySet()){
|
||||
logger.debug("'"+key+"' = '"+envs.get(key)+"'");
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Query method for checking the validity of a User against this wrapped request.
|
||||
* @param user
|
||||
* @return true if the user matches that on the request, false if not.
|
||||
*/
|
||||
public boolean isRemoteUserValid(final User user){
|
||||
if(user != null && isExternalAuthSupported()){
|
||||
final Set<Username> usernames = user.getUserNames();
|
||||
for(final Username username:usernames){
|
||||
if(username.getUserName().equals(getExternalAuthRemoteUserId()) && username.getRealm().equals(getExternalAuthRemoteUserRealm())){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Private utility method.
|
||||
*/
|
||||
private void formatUserString(){
|
||||
remoteUser = req.getRemoteUser();
|
||||
if(remoteUser != null && remoteUser.contains("@")){
|
||||
String[] split = remoteUser.split("@");
|
||||
remoteUserId = split[0];
|
||||
remoteUserRealm = split[1].toUpperCase();
|
||||
}else{
|
||||
remoteUserId = remoteUser;
|
||||
remoteUserRealm = "DSV.SU.SE";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Signs the stored remote user in on the supplied SciProSession.
|
||||
* @param session If null, method fails gracefully by returning false.
|
||||
* @return true on success, else false.
|
||||
*/
|
||||
public boolean signIn(final SciProSession session){
|
||||
if(session != null && isExternalAuthSupported()){
|
||||
//dumpAuthInfo();
|
||||
return session.signInAuthenticatedUser(getExternalAuthRemoteUserId(), getExternalAuthRemoteUserRealm());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package se.su.dsv.scipro.security.auth;
|
||||
|
||||
import java.io.IOException;
|
||||
import javax.servlet.Filter;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.FilterConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
* Throw-away implementation of a servlet filter, main task is to fake the getRemoteUser() call for the request chain.
|
||||
*/
|
||||
public final class MockRemoteUserFilter implements Filter {
|
||||
private Logger logger = Logger.getLogger(this.getClass());
|
||||
//Default value unless supplied via init parameter
|
||||
private String fakedUser = "SOME_GUY";
|
||||
private FilterConfig cfg = null;
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public MockRemoteUserFilter() {
|
||||
}
|
||||
/**
|
||||
* @see Filter#destroy()
|
||||
*/
|
||||
public void destroy() {
|
||||
cfg = null;
|
||||
}
|
||||
/**
|
||||
* Wraps the passed request and alters the behavior of getRemoteUser() for later links of the chain.
|
||||
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
|
||||
*/
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
logger.info("Faking external authentication user: "+fakedUser);
|
||||
if(cfg != null){
|
||||
HttpServletRequestWrapper wrapper = new ModifiedRemoteUserRequestWrapper((HttpServletRequest)request,fakedUser);
|
||||
// pass the request along the filter chain
|
||||
chain.doFilter(wrapper, response);
|
||||
return;
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
/**
|
||||
* @see Filter#init(FilterConfig)
|
||||
*/
|
||||
public void init(FilterConfig fConfig) throws ServletException {
|
||||
cfg = fConfig;
|
||||
if(cfg!=null){
|
||||
fakedUser = cfg.getInitParameter("fakedUser");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Private RequestWrapper, of no interest to anyone outside of this class.
|
||||
*/
|
||||
class ModifiedRemoteUserRequestWrapper extends HttpServletRequestWrapper{
|
||||
private final String fakedUser;
|
||||
ModifiedRemoteUserRequestWrapper(final HttpServletRequest request,final String fakedUser){
|
||||
super(request);
|
||||
this.fakedUser = fakedUser;
|
||||
}
|
||||
@Override
|
||||
public String getRemoteUser(){
|
||||
return fakedUser;
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
public class RoleBasedAuthorizationStrategy implements IAuthorizationStrategy {
|
||||
|
||||
public boolean isActionAuthorized(Component component, Action action) {
|
||||
//System.out.println("Comp: "+component+" action: "+action);
|
||||
boolean ok = false;
|
||||
Class<? extends Component> authRequired = null;
|
||||
if (component instanceof BookmarkablePageLink<?>) {
|
||||
@ -38,10 +39,11 @@ public class RoleBasedAuthorizationStrategy implements IAuthorizationStrategy {
|
||||
if ( !annotation.requiresLoggedInUser() )
|
||||
ok = true;
|
||||
else {
|
||||
SciProSession session = SciProSession.get();
|
||||
//Check for presence of login and if present check for authorization
|
||||
if( SciProSession.get().isLoggedIn() ){//&& annotation.authorizedRoles().length > 0){ If no roles added, ok will be false
|
||||
if( session.isLoggedIn() ){//&& annotation.authorizedRoles().length > 0){ If no roles added, ok will be false
|
||||
for( Roles role : annotation.authorizedRoles() ){
|
||||
if( SciProSession.get().authorizedForRole(role) ){
|
||||
if( session.authorizedForRole(role) ){
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
@ -69,17 +71,15 @@ public class RoleBasedAuthorizationStrategy implements IAuthorizationStrategy {
|
||||
}
|
||||
|
||||
public <T extends Component> boolean isInstantiationAuthorized(Class<T> componentClass) {
|
||||
|
||||
//Not annotated classes aren't checked further
|
||||
Authorization annotation = (Authorization) componentClass.getAnnotation(Authorization.class);
|
||||
if (annotation != null) {
|
||||
|
||||
//If component doesn't require login anyone may do it any time
|
||||
if( !annotation.requiresLoggedInUser() )
|
||||
return true;
|
||||
|
||||
SciProSession session = SciProSession.get();
|
||||
//If page requires login and user isn't logged in, send them to login page first
|
||||
if( annotation.requiresLoggedInUser() && !SciProSession.get().isLoggedIn() )
|
||||
if( annotation.requiresLoggedInUser() && !session.isLoggedIn() )
|
||||
throw new RestartResponseAtInterceptPageException(LoginPage.class);
|
||||
|
||||
//We only check pages for instantiation authorization, other components are handled via ActionAuthorization
|
||||
@ -88,7 +88,7 @@ public class RoleBasedAuthorizationStrategy implements IAuthorizationStrategy {
|
||||
|
||||
//Check the users role for authorization to instantiate the component
|
||||
for(Roles role : annotation.authorizedRoles()){
|
||||
if( SciProSession.get().authorizedForRole(role) )
|
||||
if( session.authorizedForRole(role) )
|
||||
return true;
|
||||
}
|
||||
//No roles were added to the annotation or user was not authorized for the roles that were added
|
||||
|
79
src/main/java/se/su/dsv/scipro/util/KeyValuePair.java
Normal file
79
src/main/java/se/su/dsv/scipro/util/KeyValuePair.java
Normal file
@ -0,0 +1,79 @@
|
||||
package se.su.dsv.scipro.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Small utility class for immutable (yes it's immutable and no it's never going to be otherwise) key/value pairs.
|
||||
* The "value" field is parameterized, but the key is always intended to be a simple String.
|
||||
* The Serializable properties of this depends on those of the parameterized type.
|
||||
* Typical usage:
|
||||
* <code>
|
||||
* KeyValuePair<SomeType> pair = new KeyValuePair<SomeType>("thisIsAKey",someObject);
|
||||
* pair.getKey();
|
||||
* pair.getValue();
|
||||
* </code>
|
||||
* @param <V>
|
||||
*/
|
||||
public final class KeyValuePair<V> implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String key;
|
||||
private final V value;
|
||||
/**
|
||||
* Default and only constructor, provide key and value.
|
||||
* null values are accepted for both key and value, and should be safe to use (yet nonsensical).
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public KeyValuePair(final String key, final V value){
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
/**
|
||||
* Getter for wrapped key String
|
||||
* @return The key
|
||||
*/
|
||||
public String getKey(){
|
||||
return key;
|
||||
}
|
||||
/**
|
||||
* Getter for wrapped Value
|
||||
* @return The value
|
||||
*/
|
||||
public V getValue(){
|
||||
return value;
|
||||
}
|
||||
/**
|
||||
* Equals override, behaves in a logical fashion (two objects are equal if both key and value matches).
|
||||
* Null values are accounted for, ie: two objects with null key+value are considered equal.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object o){
|
||||
if(o==this)
|
||||
return true;
|
||||
if(!(o instanceof KeyValuePair))
|
||||
return false;
|
||||
@SuppressWarnings("unchecked")
|
||||
final KeyValuePair<V> other = (KeyValuePair<V>)o;
|
||||
return ((key==null?other.key==null:key.equals(other.key)) &&
|
||||
(value==null?other.value==null:value.equals(other.value)));
|
||||
}
|
||||
/**
|
||||
* Hash-code override, uses both components in a standard fashion.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode(){
|
||||
final int w = 31;
|
||||
int result = 17;//Why hello there Mr Bloch, how are we feeling today ?
|
||||
result = w * result + (key==null?0:key.hashCode());
|
||||
result = w * result + (value==null?0:value.hashCode());
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* Standard override, return String format not exposed and subject to change.
|
||||
* Any parsing of this representation is strongly advised against and done at your own risk.
|
||||
*/
|
||||
@Override
|
||||
public String toString(){
|
||||
return ("{"+key+":"+value+"}");
|
||||
}
|
||||
}
|
@ -16,71 +16,72 @@ import se.su.dsv.scipro.util.PropsUtils;
|
||||
|
||||
@Component
|
||||
public class MailEventWorker extends AbstractWorker {
|
||||
|
||||
|
||||
@Autowired
|
||||
private MailEventDao mailEventDao;
|
||||
|
||||
|
||||
public MailEventWorker(){ }
|
||||
|
||||
@Override
|
||||
protected void doManualTransactionWork(){
|
||||
|
||||
Properties props;
|
||||
try {
|
||||
Properties props = PropsUtils.load("email.properties");
|
||||
|
||||
List<MailEvent> mailEvents = new ArrayList<MailEvent>();
|
||||
|
||||
this.beginTransaction();
|
||||
mailEvents.addAll( mailEventDao.findAll() );
|
||||
this.commitTransaction();
|
||||
|
||||
for( MailEvent mailEvent : mailEvents ){
|
||||
try{
|
||||
this.beginTransaction();
|
||||
System.out.println("Emailing, events:"+mailEventDao.countAll());
|
||||
|
||||
final String subject = mailEvent.getSubject();
|
||||
final String fromName = mailEvent.getFromName();
|
||||
final String fromEmail = mailEvent.getFromEmail();
|
||||
final Set<User> recipients = mailEvent.getRecipients();
|
||||
final String[] recipientsEmails = new String[recipients.size()];
|
||||
int i = 0;
|
||||
for( User u : recipients ){
|
||||
recipientsEmails[i] = u.getEmailAddress();
|
||||
i++;
|
||||
}
|
||||
final String messageBody = mailEvent.getMessageBody();
|
||||
|
||||
final Set<User> replyToUsers = mailEvent.getReplyTo();
|
||||
final String[] replyToEmails = new String[replyToUsers.size()];
|
||||
i = 0;
|
||||
for( User u : replyToUsers ){
|
||||
replyToEmails[i] = u.getEmailAddress();
|
||||
i++;
|
||||
}
|
||||
//TODO test-
|
||||
//String[] tmp = new String[]{"mpeters@dsv.su.se"};
|
||||
|
||||
boolean sendMailEnabled = Boolean.parseBoolean(props.getProperty("sendMailEnabled"));
|
||||
if( sendMailEnabled ){
|
||||
Mail.mail(fromName, fromEmail, recipientsEmails /* tmp */, replyToEmails, subject, messageBody, props, false);
|
||||
}
|
||||
mailEventDao.delete(mailEvent);
|
||||
|
||||
System.out.println("Email sent, events: "+mailEventDao.countAll());
|
||||
this.commitTransaction();
|
||||
|
||||
} catch(Exception e){
|
||||
this.rollbackTransaction();
|
||||
e.printStackTrace();
|
||||
//throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
props = PropsUtils.load("email.properties");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
throw new RuntimeException(e1);
|
||||
}
|
||||
|
||||
List<MailEvent> mailEvents = new ArrayList<MailEvent>();
|
||||
|
||||
this.beginTransaction();
|
||||
mailEvents.addAll( mailEventDao.findAll() );
|
||||
this.commitTransaction();
|
||||
|
||||
for( MailEvent mailEvent : mailEvents ){
|
||||
try{
|
||||
this.beginTransaction();
|
||||
|
||||
final String subject = mailEvent.getSubject();
|
||||
final String fromName = mailEvent.getFromName();
|
||||
final String fromEmail = mailEvent.getFromEmail();
|
||||
final Set<User> recipients = mailEvent.getRecipients();
|
||||
final String[] recipientsEmails = new String[recipients.size()];
|
||||
int i = 0;
|
||||
for( User u : recipients ){
|
||||
recipientsEmails[i] = u.getEmailAddress();
|
||||
i++;
|
||||
}
|
||||
final String messageBody = mailEvent.getMessageBody();
|
||||
|
||||
final Set<User> replyToUsers = mailEvent.getReplyTo();
|
||||
final String[] replyToEmails = new String[replyToUsers.size()];
|
||||
i = 0;
|
||||
for( User u : replyToUsers ){
|
||||
replyToEmails[i] = u.getEmailAddress();
|
||||
i++;
|
||||
}
|
||||
//TODO test-
|
||||
//String[] tmp = new String[]{"mpeters@dsv.su.se"};
|
||||
|
||||
boolean sendMailEnabled = Boolean.parseBoolean(props.getProperty("sendMailEnabled"));
|
||||
if( sendMailEnabled ){ //If false, mail-events "vanish"
|
||||
Mail.mail(fromName, fromEmail, recipientsEmails /* tmp */, replyToEmails, subject, messageBody, props, false);
|
||||
}
|
||||
mailEvent = mailEventDao.reLoad(mailEvent); //Re-attach to session so delete works
|
||||
mailEventDao.delete(mailEvent);
|
||||
|
||||
this.commitTransaction();
|
||||
|
||||
} catch(Exception e){
|
||||
this.rollbackTransaction();
|
||||
e.printStackTrace();
|
||||
//throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}//doManualTransactionWork
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -83,8 +83,8 @@
|
||||
<!-- DEVELOPMENT VARIABLE, REMOVE FOR PRODUCTION USE -->
|
||||
<!-- <property name="hibernate.hbm2ddl.auto" value="update" /> -->
|
||||
|
||||
<!-- Local mysql production settings database -->
|
||||
|
||||
<!-- production settings database -->
|
||||
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/scipro"></property>
|
||||
@ -96,7 +96,7 @@
|
||||
<property name="hibernate.c3p0.timeout" value="1800"></property>
|
||||
<property name="hibernate.c3p0.acquire_increment" value="2"></property>
|
||||
<property name="hibernate.c3p0.idle_test_period" value="360"></property>
|
||||
|
||||
|
||||
<!--
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
|
||||
<property name="hibernate.hbm2ddl.auto" value="update" />
|
||||
@ -173,6 +173,7 @@
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectClassSettings</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.WorkerData</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.MailEvent</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.ProjectPartner</class>
|
||||
<class>se.su.dsv.scipro.data.dataobjects.CheckPlagiarismEvent</class>
|
||||
|
||||
|
||||
@ -192,21 +193,20 @@
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
|
||||
<property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:hsqldb:mem:test"></property>
|
||||
<property name="hibernate.show_sql" value="true" />
|
||||
<property name="hibernate.show_sql" value="false" />
|
||||
<property name="hibernate.format_sql" value="true" />
|
||||
|
||||
|
||||
<!-- Local mysql test database -->
|
||||
<!--
|
||||
<!--
|
||||
<property name="hibernate.hbm2ddl.auto" value="create" />
|
||||
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
|
||||
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"></property>
|
||||
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/scipro"></property>
|
||||
<property name="hibernate.connection.username" value="root"></property>
|
||||
<property name="hibernate.connection.password" value="root"></property>
|
||||
<property name="hibernate.c3p0.idle_test_period" value="3600"></property>
|
||||
-->
|
||||
|
||||
<property name="hibernate.connection.username" value=""></property>
|
||||
<property name="hibernate.connection.password" value=""></property>
|
||||
<property name="hibernate.c3p0.idle_test_period" value="3600"></property>
|
||||
-->
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
|
@ -82,7 +82,9 @@
|
||||
-->
|
||||
<property name="enableRemoteUserLookup" value="true"></property>
|
||||
<!-- This property points to the location of the daisy json search -->
|
||||
<property name="remoteLookupUrl" value="https://thesis.dsv.su.se/projectplan/json" />
|
||||
<property name="remoteLookupUrl" value="https://thesis.dsv.su.se/match/json" />
|
||||
<!-- External auth support (via J2EE standard mechanism REMOTE_USER), if true: other authentication mechanics will be bypassed.-->
|
||||
<property name="acceptExternalAuthentication" value="true"/>
|
||||
</bean>
|
||||
|
||||
<!-- Defines the class used for lookup in username against a remote server NOW AUTOWIRED AND DEPRECATED, NOT MAINTAINED-->
|
||||
|
@ -1,6 +1,6 @@
|
||||
log4j.appender.Stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n
|
||||
log4j.appender.Stdout.layout.conversionPattern=%d{HH:mm:ss,SSS}[%p] - %c{1} - %m\n
|
||||
|
||||
log4j.rootLogger=INFO,Stdout
|
||||
|
||||
@ -8,5 +8,3 @@ log4j.logger.wicket=INFO
|
||||
log4j.logger.wicket.protocol.http.HttpSessionStore=INFO
|
||||
log4j.logger.wicket.version=INFO
|
||||
log4j.logger.wicket.RequestCycle=INFO
|
||||
|
||||
|
||||
|
@ -10,11 +10,29 @@
|
||||
<filter-name>osiv</filter-name>
|
||||
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>osiv</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
<!-- Filter for faking an authenticated REMOTE_USER, should never be used in a production environment-->
|
||||
<!-- filter>
|
||||
<description>
|
||||
</description>
|
||||
<display-name>MockRemoteUserFilter</display-name>
|
||||
<filter-name>MockRemoteUserFilter</filter-name>
|
||||
<filter-class>se.su.dsv.scipro.security.auth.MockRemoteUserFilter</filter-class>
|
||||
<init-param>
|
||||
<description>
|
||||
</description>
|
||||
<param-name>fakedUser</param-name>
|
||||
<param-value>robi-ekl@dsv.su.se</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>MockRemoteUserFilter</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping-->
|
||||
|
||||
<filter>
|
||||
<filter-name>wicket.WicketWarp</filter-name>
|
||||
@ -24,11 +42,9 @@
|
||||
<param-value>se.su.dsv.scipro.SciProApplication</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
|
||||
<filter-mapping>
|
||||
<filter-name>wicket.WicketWarp</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
|
||||
<!-- These to be able to enable a non-standard not found page -->
|
||||
<dispatcher>REQUEST</dispatcher>
|
||||
<dispatcher>ERROR</dispatcher>
|
||||
|
@ -1,9 +0,0 @@
|
||||
#main-nav .current a,
|
||||
#main-nav li:hover > a {
|
||||
behavior: url('border-radius.htc');
|
||||
}
|
||||
|
||||
|
||||
/* Checked styles for IE(9) */
|
||||
span.hilight > input[type=radio]:checked + label { background-color: PaleGreen;}
|
||||
span.hilight > input[type=checkbox]:checked + label { background-color: PaleGreen;}
|
@ -442,7 +442,10 @@ ul.multiobject-selected-list li {
|
||||
font-size:93%;
|
||||
line-height:normal;
|
||||
}
|
||||
|
||||
.tab-menu img {
|
||||
height: 12px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
.tab-menu ul {
|
||||
margin:0;
|
||||
padding: 0px 10px 0;
|
||||
@ -470,15 +473,64 @@ ul.multiobject-selected-list li {
|
||||
.tab-menu a:hover {
|
||||
color:#333;
|
||||
}
|
||||
.tab-menu #current {
|
||||
.tab-menu .current {
|
||||
background-image:url("../images/tab_left_on.gif");
|
||||
}
|
||||
.tab-menu #current a {
|
||||
.tab-menu .current a {
|
||||
background-image:url("../images/tab_right_on.gif");
|
||||
color:#333;
|
||||
padding-bottom:5px;
|
||||
}
|
||||
|
||||
.multi-tab-menu {
|
||||
float:left;
|
||||
width:100%;
|
||||
/* background: url("../images/tab_bg.gif") repeat-x bottom;*/
|
||||
font-size:93%;
|
||||
line-height:normal;
|
||||
}
|
||||
.multi-tab-menu img {
|
||||
height: 12px;
|
||||
vertical-align:middle;
|
||||
}
|
||||
.multi-tab-menu ul {
|
||||
margin:0;
|
||||
padding: 0px 10px 0;
|
||||
list-style:none;
|
||||
}
|
||||
.multi-tab-menu li {
|
||||
float:left;
|
||||
background:url("../images/tab_left.gif") no-repeat left top;
|
||||
margin:0 0 3px 0;
|
||||
padding:0 0 0 9px;
|
||||
border-bottom: 1px solid #78645A;
|
||||
}
|
||||
.multi-tab-menu a {
|
||||
float:left;
|
||||
display:block;
|
||||
background:url("../images/tab_right.gif") no-repeat right top;
|
||||
padding:5px 15px 4px 6px;
|
||||
text-decoration:none;
|
||||
font-weight:bold;
|
||||
color:#765;
|
||||
}
|
||||
/* Commented Backslash Hack
|
||||
hides rule from IE5-Mac \*/
|
||||
.multi-tab-menu a {float:none;}
|
||||
/* End IE5-Mac hack */
|
||||
.multi-tab-menu a:hover {
|
||||
color:#333;
|
||||
}
|
||||
.multi-tab-menu .current {
|
||||
background-image:url("../images/tab_left_on.gif");
|
||||
border-bottom: 1px solid transparent !important;
|
||||
}
|
||||
.multi-tab-menu .current a {
|
||||
background-image:url("../images/tab_right_on.gif");
|
||||
color:#333;
|
||||
}
|
||||
|
||||
|
||||
.vertical-menu ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
@ -502,7 +554,7 @@ ul.multiobject-selected-list li {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.vertical-menu #current a {
|
||||
.vertical-menu .current a {
|
||||
color: black;
|
||||
background-color: #DDE7EE;
|
||||
}
|
||||
@ -534,7 +586,7 @@ ul.multiobject-selected-list li {
|
||||
border-bottom-color: black;
|
||||
}
|
||||
|
||||
.horizontal-menu #current a {
|
||||
.horizontal-menu .current a {
|
||||
border-bottom-color: #2DB300;
|
||||
}
|
||||
|
||||
@ -789,14 +841,11 @@ span.hilight > input + label:hover, span.hilight > input:focus + label {
|
||||
color: #2C7AD0;
|
||||
}
|
||||
|
||||
/* Highlight checked form components, IE-specific variant in scipro-ie.css */
|
||||
span.hilight > input[type=radio]:checked + label {
|
||||
text-shadow: lime 0px 0px 5px;
|
||||
}
|
||||
span.hilight > input[type=checkbox]:checked + label {
|
||||
text-shadow: lime 0px 0px 5px;
|
||||
}
|
||||
|
||||
/* Highlight checked form components, IE9-specific variant below, older IE's don't work */
|
||||
span.hilight > input[type=radio]:checked + label { text-shadow: lime 0px 0px 5px; }
|
||||
span.hilight > input[type=checkbox]:checked + label { text-shadow: lime 0px 0px 5px; }
|
||||
.ie9 span.hilight > input[type=radio]:checked + label { background-color: PaleGreen; }
|
||||
.ie9 span.hilight > input[type=checkbox]:checked + label { background-color: PaleGreen; }
|
||||
|
||||
.question-feedback {
|
||||
margin-left: 1.5em;
|
||||
|
BIN
src/main/webapp/images/tab_bg.png
Normal file
BIN
src/main/webapp/images/tab_bg.png
Normal file
Binary file not shown.
After ![]() (image error) Size: 180 B |
@ -2,10 +2,15 @@ package se.su.dsv.scipro.configuration;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
@ -13,7 +18,10 @@ import junit.framework.Assert;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Assert that deploy configuration is upheld before build can be completed.
|
||||
@ -25,10 +33,25 @@ public class TestDeployConfiguration {
|
||||
private static String persistenceXmlPath = "META-INF"+File.separator+"persistence.xml";
|
||||
private static String repositoryContext = "META-INF"+File.separator+"repositoryContext.xml";
|
||||
private static String baseRepository = "META-INF"+File.separator+"base-repository.xml";
|
||||
private static String webXmlPath = "src"+File.separator+"main"+File.separator+"webapp"+File.separator+"WEB-INF"+File.separator+"web.xml";
|
||||
|
||||
@Test
|
||||
public void testWicketDeploymentConfiguration() throws XPathExpressionException, IOException, SAXException, ParserConfigurationException {
|
||||
String path = System.getProperty("user.dir")+File.separator+webXmlPath;
|
||||
|
||||
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
|
||||
domFactory.setNamespaceAware(false);
|
||||
DocumentBuilder builder = domFactory.newDocumentBuilder();
|
||||
Document doc = builder.parse(new FileInputStream(path));
|
||||
|
||||
Node nodes = (Node) XPathFactory.newInstance().newXPath().evaluate("//web-app/context-param/param-name[.='configuration']/../param-value", doc, XPathConstants.NODE);
|
||||
|
||||
Assert.assertEquals("deployment", nodes.getTextContent());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDatabasePath() throws XPathExpressionException, IOException {
|
||||
InputSource persistenceXml = getInputSource(persistenceXmlPath);
|
||||
InputSource persistenceXml = getInputSource(persistenceXmlPath);
|
||||
Assert.assertEquals("jdbc:mysql://localhost/scipro",
|
||||
XPathFactory.newInstance().newXPath().evaluate(
|
||||
"(//*[@name='hibernate.connection.url']/@value)[1]",
|
||||
@ -81,10 +104,6 @@ public class TestDeployConfiguration {
|
||||
return new InputSource( is );
|
||||
}
|
||||
|
||||
private InputStream getResourceAsStream(String filePath){
|
||||
return Thread.currentThread().getContextClassLoader().getResourceAsStream(filePath);
|
||||
}
|
||||
|
||||
private static String readResourceAsString(String filePath) throws IOException{
|
||||
return readResourceAsString(filePath, "UTF-8");
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.TreeSet;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -32,6 +33,7 @@ import se.su.dsv.scipro.data.dataobjects.User;
|
||||
* @author Johan Aschan - aschan@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class TestCommentThreadDaoJpa {
|
||||
|
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
|
||||
default-autowire="byName">
|
||||
|
||||
<bean id="entityManagerFactory"
|
||||
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
|
||||
<property name="persistenceUnitName" value="testPersistenceUnit" />
|
||||
</bean>
|
||||
|
||||
<!--
|
||||
enable the configuration of transactional behavior based on
|
||||
annotations
|
||||
-->
|
||||
<tx:annotation-driven transaction-manager="transactionManager" />
|
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="projectPartnerDao" class="se.su.dsv.scipro.data.dao.jpa.ProjectPartnerDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="projectClassDao" class="se.su.dsv.scipro.data.dao.jpa.ProjectClassDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
<bean id="userDao" class="se.su.dsv.scipro.data.dao.jpa.UserDaoJPAImp">
|
||||
<property name="entityManagerFactory" ref="entityManagerFactory" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
@ -0,0 +1,77 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectPartner;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
|
||||
@Ignore
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class TestProjectPartnerDaoJPA {
|
||||
|
||||
|
||||
private User user;
|
||||
private ProjectPartner projectPartner;
|
||||
private ProjectClass projectClass;
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectClassDao projectClassDao;
|
||||
|
||||
@Autowired
|
||||
private ProjectPartnerDao projectPartnerDao;
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testCountProjectPartnerInSpan(){
|
||||
user = new User();
|
||||
user = userDao.save(user);
|
||||
projectPartner = new ProjectPartner(user);
|
||||
projectPartner.setInfoText("testtext");
|
||||
projectClass = new ProjectClass("test", "moo", "bleh");
|
||||
projectClass = projectClassDao.save(projectClass);
|
||||
projectPartner.setProjectClass(projectClass);
|
||||
projectPartner = projectPartnerDao.save(projectPartner);
|
||||
Assert.assertEquals(1, projectPartnerDao.countProjectPartnerInSpan(projectClass, 2));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback
|
||||
public void testProjectPartnerInSpan(){
|
||||
user = new User();
|
||||
user = userDao.save(user);
|
||||
projectPartner = new ProjectPartner(user);
|
||||
projectPartner.setInfoText("testtext");
|
||||
projectClass = new ProjectClass("test2", "moo2", "bleh2");
|
||||
projectClass = projectClassDao.save(projectClass);
|
||||
projectPartner.setProjectClass(projectClass);
|
||||
projectPartner = projectPartnerDao.save(projectPartner);
|
||||
|
||||
int count = projectPartnerDao.countProjectPartnerInSpan(projectClass, 2);
|
||||
ProjectPartner temp = projectPartnerDao.getProjectPartnerInSpan(projectClass, 5, 0, count).get(0);
|
||||
|
||||
Assert.assertEquals("testtext", temp.getInfoText());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,27 +1,6 @@
|
||||
package se.su.dsv.scipro.dao.jpa;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectScheduleDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Event;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectSchedule;
|
||||
import org.junit.Ignore;
|
||||
|
||||
/**
|
||||
* @author Dan Kjellman <dan-kjel@dsv.su.se>
|
||||
@ -29,6 +8,7 @@ import se.su.dsv.scipro.data.dataobjects.ProjectSchedule;
|
||||
*/
|
||||
//@RunWith(SpringJUnit4ClassRunner.class)
|
||||
//@ContextConfiguration
|
||||
@Ignore
|
||||
public class TestProjectScheduleDaoJPA {
|
||||
|
||||
|
||||
|
@ -0,0 +1,192 @@
|
||||
package se.su.dsv.scipro.security.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.apache.wicket.protocol.http.HttpSessionStore;
|
||||
import org.apache.wicket.session.ISessionStore;
|
||||
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
|
||||
import org.apache.wicket.spring.test.ApplicationContextMock;
|
||||
import org.apache.wicket.util.tester.WicketTester;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.orm.jpa.LocalEntityManagerFactoryBean;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.StringResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.Role;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.SysAdmin;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.Username;
|
||||
import se.su.dsv.scipro.json.IUserLookup;
|
||||
import se.su.dsv.scipro.repository.util.RepositoryManager;
|
||||
|
||||
public class TestAuthRoutines {
|
||||
private SciProSession session;
|
||||
private WicketTester wt;
|
||||
private User user;
|
||||
private Role sysAdm;
|
||||
private IUserLookup fixedLookup;
|
||||
private ApplicationSettings appSettings;
|
||||
@Before
|
||||
public void init(){
|
||||
final ApplicationContextMock ac = new ApplicationContextMock();
|
||||
//Create mock object in need of config
|
||||
appSettings = new ApplicationSettings();
|
||||
appSettings.setAcceptExternalAuthentication(true);
|
||||
//Fake a lookup mechanism
|
||||
fixedLookup = new IUserLookup(){
|
||||
@Override
|
||||
public User lookup(String username) throws Exception{
|
||||
if(username.equals("kalle-kula"))
|
||||
return user;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
};
|
||||
//Create mock user and associated data
|
||||
user = new User();
|
||||
user.setDateCreated(new Date());
|
||||
user.setEmailAddress("kalle-kula@dsv.su.se");
|
||||
user.setFirstName("Kalle");
|
||||
user.setLastName("Kula");
|
||||
user.setIdentifier(new Long(666));
|
||||
user.setLastModified(new Date());
|
||||
Set<Role> roles = new HashSet<Role>();
|
||||
//Faked student
|
||||
Role role = new Student();
|
||||
role.setId(new Long(555));
|
||||
role.setUser(user);
|
||||
roles.add(new Student());
|
||||
user.setRoles(roles);
|
||||
//Faked sysadm, added later
|
||||
sysAdm = new SysAdmin();
|
||||
sysAdm.setId(new Long(444));
|
||||
Set<Username> usernames = new HashSet<Username>();
|
||||
Username username = new Username();
|
||||
username.setUserName("kalle-kula");
|
||||
username.setRealm("DSV.SU.SE");
|
||||
usernames.add(username);
|
||||
user.setUserNames(usernames);
|
||||
//Put stuff on bean context
|
||||
ac.putBean("entityManagerFactory",Mockito.mock(LocalEntityManagerFactoryBean.class));
|
||||
ac.putBean("repositoryManager",Mockito.mock(RepositoryManager.class));
|
||||
ac.putBean("applicationSettings",appSettings);
|
||||
ac.putBean("userDao",Mockito.mock(UserDao.class));
|
||||
ac.putBean("stringResourceDao",Mockito.mock(StringResourceDao.class));
|
||||
RoleDao mockedRoleDao = Mockito.mock(RoleDao.class);
|
||||
Mockito.when(mockedRoleDao.isSysadmin(user)).thenAnswer(new Answer<Boolean>() {
|
||||
@Override
|
||||
public Boolean answer(InvocationOnMock invocation) throws Throwable {
|
||||
return user.getRoles().contains(sysAdm);
|
||||
}
|
||||
});
|
||||
ac.putBean("roleDao",mockedRoleDao);
|
||||
ac.putBean("projectDao",Mockito.mock(ProjectDao.class));
|
||||
ac.putBean("userSettingsDao",Mockito.mock(UserSettingsDao.class));
|
||||
ac.putBean("userFullLookup",fixedLookup);
|
||||
//Create tester
|
||||
wt = new WicketTester(new SciProApplication(){
|
||||
@Override
|
||||
protected ISessionStore newSessionStore(){
|
||||
return new HttpSessionStore(this);
|
||||
}
|
||||
@Override
|
||||
protected SpringComponentInjector getSpringInjector() {
|
||||
return new SpringComponentInjector(this, ac, true);
|
||||
}
|
||||
});
|
||||
wt.setupRequestAndResponse();
|
||||
session = (SciProSession)wt.getWicketSession();
|
||||
}
|
||||
@Test
|
||||
public void testAuthenticationHelper() throws IllegalStateException {
|
||||
//Try with faulty request
|
||||
ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(wt.getServletRequest());
|
||||
Assert.assertFalse(helper.isExternalAuthSupported());
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUser()==null);
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUserId()==null);
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUserRealm().equals("DSV.SU.SE"));
|
||||
Assert.assertFalse(helper.isRemoteUserValid(user));
|
||||
Assert.assertFalse(helper.signIn(null));
|
||||
//Try with conforming request
|
||||
helper = new ExternalAuthenticationRequestHelper(new HttpServletRequestWrapper(wt.getServletRequest()){
|
||||
@Override
|
||||
public String getRemoteUser(){
|
||||
return "kalle-kula@dsv.su.se";
|
||||
}
|
||||
});
|
||||
Assert.assertTrue(helper.isExternalAuthSupported());
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUser().equals("kalle-kula@dsv.su.se"));
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUserId().equals("kalle-kula"));
|
||||
Assert.assertTrue(helper.getExternalAuthRemoteUserRealm().equals("DSV.SU.SE"));
|
||||
Assert.assertTrue(helper.isRemoteUserValid(user));
|
||||
}
|
||||
@Test
|
||||
public void testTurnOffViaSettings(){
|
||||
appSettings.setAcceptExternalAuthentication(false);
|
||||
ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(wt.getServletRequest());
|
||||
Assert.assertFalse(helper.isExternalAuthSupported());
|
||||
}
|
||||
@Test(expected=IllegalStateException.class)
|
||||
public void testNullRequest(){
|
||||
//At this point, an exception should be thrown
|
||||
new ExternalAuthenticationRequestHelper(null);
|
||||
}
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testSessionSignInAndSu(){
|
||||
ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(new HttpServletRequestWrapper(wt.getServletRequest()){
|
||||
@Override
|
||||
public String getRemoteUser(){
|
||||
return "kalle-kula@dsv.su.se";
|
||||
}
|
||||
});
|
||||
Assert.assertTrue(helper.isExternalAuthSupported());
|
||||
Assert.assertTrue(helper.signIn(session));
|
||||
Assert.assertTrue(helper.isRemoteUserValid(user));
|
||||
Assert.assertTrue(session.isLoggedIn());
|
||||
Assert.assertTrue(session.getUser().getIdentifier().equals(user.getIdentifier()));
|
||||
//User not authorized to switch, this should fail
|
||||
Assert.assertFalse(session.switchAuthenticatedUser("kalle-kula", "dsv.su.se"));
|
||||
//Change his roles and try again
|
||||
Set<Role> roles = user.getRoles();
|
||||
sysAdm.setUser(user);
|
||||
roles.add(sysAdm);
|
||||
user.setRoles(roles);
|
||||
Assert.assertTrue(session.switchAuthenticatedUser("kalle-kula", "dsv.su.se"));
|
||||
Assert.assertTrue(session.getUser().getIdentifier().equals(user.getIdentifier()));
|
||||
//This should fail with an exception, there is no such user
|
||||
session.switchAuthenticatedUser("somebody","somewhere.se");
|
||||
}
|
||||
@Test(expected=NullPointerException.class)
|
||||
public void testFailedAuthenticatedSignIn(){
|
||||
ExternalAuthenticationRequestHelper helper = new ExternalAuthenticationRequestHelper(new HttpServletRequestWrapper(wt.getServletRequest()){
|
||||
@Override
|
||||
public String getRemoteUser(){
|
||||
return "some-dude@ki.se";
|
||||
}
|
||||
});
|
||||
//This should throw exceptions, not sure about this interface (throwing exceptions when authentication passes but no user can be located).
|
||||
helper.signIn(session);
|
||||
}
|
||||
@Test
|
||||
public void testFailedSwitchAuthentitedUser(){
|
||||
Assert.assertFalse(session.isLoggedIn());
|
||||
Assert.assertFalse(session.switchAuthenticatedUser("some-dude-who-is-not-real","someplace.se"));
|
||||
Assert.assertFalse(session.switchAuthenticatedUser("some-dude","someplace.se"));
|
||||
}
|
||||
}
|
22
src/test/java/se/su/dsv/scipro/util/TestKeyValuePair.java
Normal file
22
src/test/java/se/su/dsv/scipro/util/TestKeyValuePair.java
Normal file
@ -0,0 +1,22 @@
|
||||
package se.su.dsv.scipro.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestKeyValuePair {
|
||||
@Test
|
||||
public void testEqualsOperations() {
|
||||
KeyValuePair<String> kvpOne = new KeyValuePair<String>("key","value");
|
||||
KeyValuePair<String> kvpTwo = new KeyValuePair<String>("key","value");
|
||||
KeyValuePair<String> kvpThree = new KeyValuePair<String>("key3","value");
|
||||
KeyValuePair<String> kvpFour = new KeyValuePair<String>(null,null);
|
||||
KeyValuePair<TestKeyValuePair> kvpFive = new KeyValuePair<TestKeyValuePair>("key",this);
|
||||
|
||||
Assert.assertTrue(kvpOne.equals(kvpOne));
|
||||
Assert.assertTrue(kvpFour.equals(kvpFour));
|
||||
Assert.assertTrue(kvpOne.equals(kvpTwo) && kvpTwo.equals(kvpOne));
|
||||
Assert.assertFalse(kvpOne.equals(kvpThree) && kvpThree.equals(kvpOne));
|
||||
Assert.assertFalse(kvpFour.equals(kvpThree) && kvpThree.equals(kvpFour));
|
||||
Assert.assertFalse(kvpOne.equals(kvpFive) && kvpFive.equals(kvpOne));
|
||||
}
|
||||
}
|
184
src/test/java/se/su/dsv/scipro/wicket/BaseWicketTest.java
Normal file
184
src/test/java/se/su/dsv/scipro/wicket/BaseWicketTest.java
Normal file
@ -0,0 +1,184 @@
|
||||
package se.su.dsv.scipro.wicket;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.apache.wicket.Request;
|
||||
import org.apache.wicket.Response;
|
||||
import org.apache.wicket.Session;
|
||||
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
|
||||
import org.apache.wicket.spring.test.ApplicationContextMock;
|
||||
import org.apache.wicket.util.tester.WicketTester;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
import org.springframework.orm.jpa.LocalEntityManagerFactoryBean;
|
||||
|
||||
import se.su.dsv.scipro.ApplicationSettings;
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.data.controllers.FinalSeminarUploadController;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.BoardMessageDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CommentDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.CommentThreadDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FileDescriptionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarActiveParticipationDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.FinalSeminarOppositionDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GeneralSystemSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.GroupEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.HandInActivityDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.MessageBoardDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectClassSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectEventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectPartnerDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectScheduleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ScheduleTemplateDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.StringResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.WorkerDataDao;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.peer.data.dao.controllers.PeerPortalController;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerRequestDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.PeerReviewDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewRatingDao;
|
||||
import se.su.dsv.scipro.peer.data.dao.interfaces.ReviewTemplateDao;
|
||||
import se.su.dsv.scipro.repository.FileRepository;
|
||||
import se.su.dsv.scipro.repository.util.RepositoryManager;
|
||||
/**
|
||||
* A class that serves as a base for testing Wicket-pages, it containts a WicketTester and a mocked-up
|
||||
* applicationContext that can easily be extended or modified to suit the individual tests
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
public class BaseWicketTest {
|
||||
|
||||
protected WicketTester tester;
|
||||
|
||||
/*
|
||||
* Add beans to be mocked-up. Note that the name of the field is identical
|
||||
* to the name that will be given to the bean in the applicationContext.
|
||||
*/
|
||||
@Mock EventDao eventDao;
|
||||
@Mock UserDao userDao;
|
||||
@Mock RoleDao roleDao;
|
||||
@Mock ProjectDao projectDao;
|
||||
@Mock ProjectClassDao projectClassDao;
|
||||
@Mock UserSettingsDao userSettingsDao;
|
||||
@Mock FinalSeminarDao finalSeminarDao;
|
||||
@Mock FinalSeminarOppositionDao finalSeminarOppositionDao;
|
||||
@Mock PeerReviewDao peerReviewDao;
|
||||
@Mock PeerRequestDao peerRequestDao;
|
||||
@Mock ProjectEventDao projectEventDao;
|
||||
@Mock BoardMessageDao boardMessageDao;
|
||||
@Mock MessageBoardDao messageBoardDao;
|
||||
@Mock CommentThreadDao commentThreadDao;
|
||||
@Mock ProjectScheduleDao projectScheduleDao;
|
||||
@Mock FileDescriptionDao fileDescriptionDao;
|
||||
@Mock FileRepository fileRepository;
|
||||
@Mock WorkerDataDao workerDataDao;
|
||||
@Mock ReviewRatingDao reviewRatingDao;
|
||||
@Mock PeerPortalController peerPortalController;
|
||||
@Mock CommentDao commentDao;
|
||||
@Mock ReviewTemplateDao reviewTemplateDao;
|
||||
@Mock FinalSeminarActiveParticipationDao finalSeminarActiveParticipationDao;
|
||||
@Mock FinalSeminarUploadController finalSeminarUploadController;
|
||||
@Mock GeneralSystemSettingsDao generalSystemSettingsDao;
|
||||
@Mock ProjectClassSettingsDao projectClassSettingsDao;
|
||||
@Mock GroupEventDao groupEventDao;
|
||||
@Mock HandInActivityDao handInActivityDao;
|
||||
@Mock ScheduleTemplateDao scheduleTemplateDao;
|
||||
@Mock ProjectPartnerDao projectPartnerDao;
|
||||
|
||||
@Mock ApplicationSettings applicationSettings;
|
||||
|
||||
@Mock RepositoryManager repositoryManager;
|
||||
@Mock StringResourceDao stringResourceDao;
|
||||
|
||||
@Mock EntityManagerFactoryInfo entityManagerFactory = Mockito.mock(LocalEntityManagerFactoryBean.class);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
/*
|
||||
* Setup a new mock applicationContext
|
||||
*/
|
||||
final ApplicationContextMock acm = new ApplicationContextMock();
|
||||
|
||||
/*
|
||||
* Initialize annotated Mockups
|
||||
*/
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
/*
|
||||
* Add mocked-up beans to applicationContext, replaces a lot of lines like: acm.putBean("userDao", userDao);
|
||||
*/
|
||||
for(Field f : BaseWicketTest.class.getDeclaredFields()){
|
||||
if( f.isAnnotationPresent(Mock.class) ){
|
||||
try {
|
||||
acm.putBean(f.getName(), f.get(this));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up behavior that is always true for any test, like behavior of reLoad-methods
|
||||
*/
|
||||
Mockito.when(projectDao.reLoad( Mockito.any(Project.class) )).thenAnswer(new Answer<Project>() {
|
||||
@Override
|
||||
public Project answer(InvocationOnMock invocation) throws Throwable {
|
||||
return (Project) invocation.getArguments()[0];
|
||||
}
|
||||
});
|
||||
|
||||
Mockito.when(generalSystemSettingsDao.getGeneralSystemSettingsInstance()).thenReturn(new GeneralSystemSettings());
|
||||
|
||||
/*
|
||||
* Setup a new wicket-tester instance
|
||||
*/
|
||||
tester = new WicketTester(new SciProApplication(){
|
||||
/* (non-Javadoc)
|
||||
* @see se.su.dsv.scipro.WicketApplication#getGuiceInjector()
|
||||
*/
|
||||
@Override
|
||||
protected SpringComponentInjector getSpringInjector() {
|
||||
return new SpringComponentInjector(this, acm, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Session newSession(Request request, Response response) {
|
||||
if(MockSciProSession.currentSession == null){
|
||||
//Default session is a student-session
|
||||
MockSciProSession.currentSession = new MockSciProSession(request);
|
||||
}
|
||||
return MockSciProSession.currentSession;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void setLoggedIn(boolean loggedIn){
|
||||
MockSciProSession.currentSession.setLoggedIn(loggedIn);
|
||||
}
|
||||
protected void setUser(User user){
|
||||
MockSciProSession.currentSession.setUser(user);
|
||||
}
|
||||
protected void setActiveProject(Project activeProject){
|
||||
MockSciProSession.currentSession.setActiveProject(activeProject);
|
||||
}
|
||||
|
||||
}
|
91
src/test/java/se/su/dsv/scipro/wicket/MockSciProSession.java
Normal file
91
src/test/java/se/su/dsv/scipro/wicket/MockSciProSession.java
Normal file
@ -0,0 +1,91 @@
|
||||
package se.su.dsv.scipro.wicket;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import org.apache.wicket.Request;
|
||||
|
||||
import se.su.dsv.scipro.SciProSession;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.security.auth.roles.Employee;
|
||||
import se.su.dsv.scipro.security.auth.roles.IRole;
|
||||
import se.su.dsv.scipro.security.auth.roles.Roles;
|
||||
import se.su.dsv.scipro.security.auth.roles.Student;
|
||||
import se.su.dsv.scipro.security.auth.roles.SysAdmin;
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class MockSciProSession extends SciProSession {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static MockSciProSession currentSession = null;
|
||||
|
||||
private IRole currentRole = new Student();
|
||||
public Project mockActiveProject = null;
|
||||
public User mockUser = null;
|
||||
|
||||
public MockSciProSession(Request request) {
|
||||
super(request);
|
||||
}
|
||||
/**
|
||||
* Set if the user is logged in or not
|
||||
* @param loggedIn
|
||||
*/
|
||||
public void setLoggedIn(boolean loggedIn){
|
||||
try {
|
||||
Field field = SciProSession.class.getDeclaredField("loggedIn");
|
||||
field.setAccessible(true);
|
||||
field.set(this, loggedIn);
|
||||
|
||||
} catch (SecurityException e) {
|
||||
e.printStackTrace();
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean authorizedForRole(Roles role) {
|
||||
return currentRole.authorizedForRole(role);
|
||||
}
|
||||
@Override
|
||||
public boolean hasActualRole(Roles role){
|
||||
return currentRole.isActualRole(role);
|
||||
}
|
||||
|
||||
public void setLoggedinAsStudent(){
|
||||
currentRole = new Student();
|
||||
}
|
||||
public void setLoggedInAsSysAdmin(){
|
||||
currentRole = new SysAdmin();
|
||||
}
|
||||
public void setLoggedInAsEmployee(){
|
||||
currentRole = new Employee();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getActiveProject(){
|
||||
return mockActiveProject;
|
||||
}
|
||||
@Override
|
||||
public void setActiveProject(Project project){
|
||||
mockActiveProject = project;
|
||||
}
|
||||
@Override
|
||||
public User getUser(){
|
||||
return mockUser;
|
||||
}
|
||||
@Override
|
||||
public void setUser(User user){
|
||||
mockUser = user;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,107 +1,193 @@
|
||||
package se.su.dsv.scipro.wicket;
|
||||
|
||||
import org.apache.wicket.spring.injection.annot.SpringComponentInjector;
|
||||
import org.apache.wicket.spring.test.ApplicationContextMock;
|
||||
import org.apache.wicket.util.tester.WicketTester;
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
import org.springframework.orm.jpa.LocalEntityManagerFactoryBean;
|
||||
|
||||
import se.su.dsv.scipro.HomePage;
|
||||
import se.su.dsv.scipro.SciProApplication;
|
||||
import se.su.dsv.scipro.admin.pages.AdminProjectPartnerPage;
|
||||
import se.su.dsv.scipro.admin.pages.SystemMaintenancePage;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.EventDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.ProjectDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.RoleDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.StringResourceDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserDao;
|
||||
import se.su.dsv.scipro.data.dao.interfaces.UserSettingsDao;
|
||||
import se.su.dsv.scipro.admin.pages.settings.AdminServerEnvironmentSettingsPage;
|
||||
import se.su.dsv.scipro.data.dataobjects.GeneralSystemSettings;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LoginPage;
|
||||
import se.su.dsv.scipro.loginlogout.pages.LogoutPage;
|
||||
import se.su.dsv.scipro.project.pages.FinalSeminarProjectListPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectFilePage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectOppositionPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectPartnerPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectSchedulePlannerPage;
|
||||
import se.su.dsv.scipro.project.pages.ProjectStartPage;
|
||||
import se.su.dsv.scipro.repository.util.RepositoryManager;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorFinalSeminarListingPage;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorProjectDetailsPage;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorScheduleTemplatesPage;
|
||||
import se.su.dsv.scipro.supervisor.pages.SupervisorStartPage;
|
||||
|
||||
/**
|
||||
* @author Richard Wilkinson - richard.wilkinson@jweekend.com
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class TestWicketPages {
|
||||
public class TestWicketPages extends BaseWicketTest {
|
||||
|
||||
User activeUser;
|
||||
ProjectClass bachelor;
|
||||
Project activeProject;
|
||||
|
||||
protected WicketTester tester;
|
||||
|
||||
@Before
|
||||
public void setup()
|
||||
{
|
||||
final ApplicationContextMock acm = new ApplicationContextMock();
|
||||
public void setup() {
|
||||
super.setup();
|
||||
|
||||
activeUser = new User();
|
||||
activeUser.setFirstName("Hugo");
|
||||
activeProject = new Project();
|
||||
activeProject.setProjectClass(bachelor);
|
||||
|
||||
EventDao eventDao = Mockito.mock(EventDao.class);
|
||||
UserDao userDao = Mockito.mock(UserDao.class);
|
||||
RoleDao roleDao = Mockito.mock(RoleDao.class);
|
||||
ProjectDao projectDao = Mockito.mock(ProjectDao.class);
|
||||
UserSettingsDao userSettingsDao = Mockito.mock(UserSettingsDao.class);
|
||||
|
||||
EntityManagerFactoryInfo emf = Mockito.mock(LocalEntityManagerFactoryBean.class);
|
||||
RepositoryManager repositoryManager = Mockito.mock(RepositoryManager.class);
|
||||
StringResourceDao stringResourceDao = Mockito.mock(StringResourceDao.class);
|
||||
|
||||
acm.putBean("eventDao", eventDao);
|
||||
acm.putBean("userDao", userDao);
|
||||
acm.putBean("roleDao", roleDao);
|
||||
acm.putBean("projectDao", projectDao);
|
||||
acm.putBean("userSettingsDao", userSettingsDao);
|
||||
acm.putBean("repositoryManager", repositoryManager);
|
||||
acm.putBean("stringResourceDao", stringResourceDao);
|
||||
acm.putBean("entityManagerFactory", emf);
|
||||
|
||||
tester = new WicketTester(new SciProApplication(){
|
||||
/* (non-Javadoc)
|
||||
* @see se.su.dsv.scipro.WicketApplication#getGuiceInjector()
|
||||
*/
|
||||
@Override
|
||||
protected SpringComponentInjector getSpringInjector() {
|
||||
return new SpringComponentInjector(this, acm, true);
|
||||
}
|
||||
});
|
||||
Mockito.when(projectDao.load(Mockito.eq(1L))).thenReturn(activeProject);
|
||||
Mockito.when(projectDao.isPartOf(activeUser, activeProject)).thenReturn(true);
|
||||
|
||||
this.setUser(activeUser);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Common pages
|
||||
*/
|
||||
@Test
|
||||
public void testStartPage() {
|
||||
public void testStartPage() throws Exception {
|
||||
|
||||
tester.startPage(HomePage.class);
|
||||
tester.assertRenderedPage(LoginPage.class);
|
||||
|
||||
this.setLoggedIn(true);
|
||||
|
||||
tester.startPage(HomePage.class);
|
||||
tester.assertRenderedPage(HomePage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLogoutPage() {
|
||||
tester.startPage(LogoutPage.class);
|
||||
tester.assertRenderedPage(LogoutPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoginPage() {
|
||||
tester.startPage(LoginPage.class);
|
||||
tester.assertRenderedPage(LoginPage.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Project/author/student pages
|
||||
*/
|
||||
@Test
|
||||
public void testProjectStartPage() {
|
||||
//tester.startPage(ProjectStartPage.class);
|
||||
//tester.assertRenderedPage(NoActiveProjectPage.class);
|
||||
|
||||
//TODO: Set an active project so that the following test works
|
||||
|
||||
//tester.startPage(ProjectStartPage.class);
|
||||
//tester.assertRenderedPage(ProjectStartPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectStartPage() {
|
||||
tester.startPage(ProjectStartPage.class);
|
||||
public void testfinalSeminarPages(){
|
||||
this.setActiveProject(activeProject);
|
||||
|
||||
tester.startPage(FinalSeminarProjectListPage.class);
|
||||
tester.assertRenderedPage(FinalSeminarProjectListPage.class);
|
||||
|
||||
Mockito.when(generalSystemSettingsDao.getGeneralSystemSettingsInstance()).thenReturn(new GeneralSystemSettings());
|
||||
Mockito.when(projectClassDao.getProjectClass(Mockito.anyString())).thenReturn(new ProjectClass());
|
||||
|
||||
tester.startPage(ProjectOppositionPage.class);
|
||||
tester.assertRenderedPage(ProjectOppositionPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectSchedulePage() {
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
|
||||
tester.startPage(ProjectSchedulePlannerPage.class);
|
||||
tester.assertRenderedPage(ProjectSchedulePlannerPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectFilePage() {
|
||||
tester.startPage(ProjectFilePage.class);
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(Project.PP_PROJECT_ID, "1" );
|
||||
|
||||
Mockito.when(fileRepository.getProjectRootPath(1L)).thenReturn("/test/path/only");
|
||||
|
||||
tester.startPage(ProjectFilePage.class,pp);
|
||||
tester.assertRenderedPage(ProjectFilePage.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Supervisor pages
|
||||
*/
|
||||
@Test
|
||||
public void testSupervisorStartPage(){
|
||||
MockSciProSession.currentSession.setLoggedInAsEmployee();
|
||||
tester.startPage(SupervisorStartPage.class);
|
||||
tester.assertRenderedPage(SupervisorStartPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupervisorFinalSeminarPage(){
|
||||
tester.startPage(SupervisorFinalSeminarListingPage.class);
|
||||
tester.assertRenderedPage(SupervisorFinalSeminarListingPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupervisorProjectDetailsPage(){
|
||||
//TODO Hidden, remove this line when pages below are published
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
|
||||
tester.startPage(SupervisorProjectDetailsPage.class);
|
||||
tester.assertRenderedPage(SupervisorProjectDetailsPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupervisorScheduleTemplatesPage(){
|
||||
tester.startPage(SupervisorScheduleTemplatesPage.class);
|
||||
tester.assertRenderedPage(SupervisorScheduleTemplatesPage.class);
|
||||
}
|
||||
|
||||
/*
|
||||
* Admin pages
|
||||
*/
|
||||
@Test
|
||||
public void testSystemSettingsPage() {
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
|
||||
tester.startPage(SystemMaintenancePage.class);
|
||||
tester.assertRenderedPage(SystemMaintenancePage.class);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAdminProjectPartnerPage() {
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
|
||||
tester.startPage(AdminProjectPartnerPage.class);
|
||||
tester.assertRenderedPage(AdminProjectPartnerPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProjectPartnerPage() {
|
||||
tester.startPage(ProjectPartnerPage.class);
|
||||
tester.assertRenderedPage(ProjectPartnerPage.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAdminServerEnvironmentSettingsPage(){
|
||||
tester.startPage(AdminServerEnvironmentSettingsPage.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
171
src/test/java/se/su/dsv/scipro/wicket/TestWicketPeerPages.java
Normal file
171
src/test/java/se/su/dsv/scipro/wicket/TestWicketPeerPages.java
Normal file
@ -0,0 +1,171 @@
|
||||
package se.su.dsv.scipro.wicket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.apache.wicket.PageParameters;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import se.su.dsv.scipro.basepages.errorpages.AccessDeniedPage;
|
||||
import se.su.dsv.scipro.data.dataobjects.CommentThread;
|
||||
import se.su.dsv.scipro.data.dataobjects.Employee;
|
||||
import se.su.dsv.scipro.data.dataobjects.Project;
|
||||
import se.su.dsv.scipro.data.dataobjects.ProjectClass;
|
||||
import se.su.dsv.scipro.data.dataobjects.Student;
|
||||
import se.su.dsv.scipro.data.dataobjects.User;
|
||||
import se.su.dsv.scipro.data.dataobjects.interfaces.Commentable;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerRequest;
|
||||
import se.su.dsv.scipro.peer.data.dataobjects.PeerReview;
|
||||
import se.su.dsv.scipro.peer.pages.PeerRequestSubmissionPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.ProjectPeerStatsPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerPortalPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerReviewPage;
|
||||
import se.su.dsv.scipro.peer.pages.SupervisorPeerStatsPage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Martin Peters - mpeters@dsv.su.se
|
||||
*
|
||||
*/
|
||||
public class TestWicketPeerPages extends BaseWicketTest {
|
||||
|
||||
User requester;
|
||||
Student requesterRole;
|
||||
User reviewer;
|
||||
Student reviewerRole;
|
||||
User supervisor;
|
||||
Employee supervisorRole;
|
||||
|
||||
Project activeProject;
|
||||
Project requestingProject;
|
||||
Project reviewingProject;
|
||||
|
||||
ProjectClass bachelor;
|
||||
User activeUser;
|
||||
|
||||
@Before
|
||||
public void setup(){
|
||||
super.setup();
|
||||
|
||||
/*
|
||||
* Initialize peer-stuff
|
||||
*/
|
||||
requestingProject = new Project();
|
||||
reviewingProject = new Project();
|
||||
activeProject = new Project();
|
||||
|
||||
bachelor = new ProjectClass(ProjectClass.BACHELOR, "Bachelor", null);
|
||||
activeProject.setProjectClass(bachelor);
|
||||
requestingProject.setProjectClass(bachelor);
|
||||
reviewingProject.setProjectClass(bachelor);
|
||||
|
||||
PeerReview review = new PeerReview();
|
||||
review.setProject(reviewingProject);
|
||||
review.setAborted(false);
|
||||
review.setDeleted(false);
|
||||
PeerRequest request = new PeerRequest();
|
||||
request.setProject(requestingProject);
|
||||
review.setPeerRequest(request);
|
||||
|
||||
requester = new User();
|
||||
requesterRole = new Student();
|
||||
requesterRole.setUser(requester);
|
||||
request.setRequester(requesterRole);
|
||||
|
||||
reviewer = new User();
|
||||
reviewerRole = new Student();
|
||||
reviewerRole.setUser(reviewer);
|
||||
review.setReviewer(reviewerRole);
|
||||
|
||||
supervisor = new User();
|
||||
supervisorRole = new Employee();
|
||||
supervisorRole.setUser(supervisor);
|
||||
|
||||
requestingProject.setHeadSupervisor(supervisorRole);
|
||||
reviewingProject.setHeadSupervisor(supervisorRole);
|
||||
|
||||
activeUser = new User();
|
||||
activeUser.setFirstName("Hugo");
|
||||
|
||||
Mockito.when(projectDao.load(Mockito.eq(1L))).thenReturn(activeProject);
|
||||
Mockito.when(projectDao.isPartOf(activeUser, activeProject)).thenReturn(true);
|
||||
Mockito.when(peerReviewDao.load(Mockito.eq(1L))).thenReturn(review);
|
||||
Mockito.when(commentThreadDao.getCommentThread(Mockito.any(Commentable.class))).thenReturn(new CommentThread());
|
||||
|
||||
this.setActiveProject(activeProject);
|
||||
this.setLoggedIn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStudentPeerPages() {
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, "1" );
|
||||
|
||||
MockSciProSession.currentSession.setUser(reviewer);
|
||||
|
||||
//TODO Remove this block when peer review functionality is enabled
|
||||
MockSciProSession.currentSession.setLoggedinAsStudent();
|
||||
tester.startPage(ProjectPeerReviewPage.class, pp);
|
||||
tester.assertRenderedPage(AccessDeniedPage.class);
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
|
||||
tester.startPage(ProjectPeerReviewPage.class, pp);
|
||||
tester.assertRenderedPage(ProjectPeerReviewPage.class);
|
||||
|
||||
|
||||
Assert.assertNotNull(MockSciProSession.currentSession.getActiveProject().getProjectClass().getProjectClassSettings());
|
||||
tester.startPage(ProjectPeerPortalPage.class);
|
||||
tester.assertRenderedPage(ProjectPeerPortalPage.class);
|
||||
|
||||
activeProject.getProjectParticipants().add(reviewerRole);
|
||||
tester.startPage(PeerRequestSubmissionPage.class);
|
||||
tester.assertRenderedPage(PeerRequestSubmissionPage.class);
|
||||
|
||||
tester.startPage(ProjectPeerStatsPage.class);
|
||||
tester.assertRenderedPage(ProjectPeerStatsPage.class);
|
||||
|
||||
MockSciProSession.currentSession.setUser(activeUser);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Supervisor pages
|
||||
*/
|
||||
@Test
|
||||
public void testSupervisorPeerPages() {
|
||||
|
||||
Assert.assertNotNull(MockSciProSession.currentSession.getUser());
|
||||
|
||||
List<ProjectClass> resultList = new ArrayList<ProjectClass>();
|
||||
resultList.add(bachelor);
|
||||
Mockito.when(projectClassDao.findAll()).thenReturn(resultList);
|
||||
Mockito.when(projectClassDao.getProjectClass(ProjectClass.BACHELOR)).thenReturn(bachelor);
|
||||
|
||||
MockSciProSession.currentSession.setLoggedinAsStudent();
|
||||
tester.startPage(SupervisorPeerPortalPage.class);
|
||||
tester.assertRenderedPage(AccessDeniedPage.class);
|
||||
|
||||
MockSciProSession.currentSession.setLoggedInAsEmployee();
|
||||
tester.startPage(SupervisorPeerPortalPage.class);
|
||||
tester.assertRenderedPage(AccessDeniedPage.class);
|
||||
//TODO Fix these so proper behavior is ensured once peer functionality is enabled
|
||||
MockSciProSession.currentSession.setLoggedInAsSysAdmin();
|
||||
tester.startPage(SupervisorPeerPortalPage.class);
|
||||
tester.assertRenderedPage(SupervisorPeerPortalPage.class);
|
||||
|
||||
tester.startPage(SupervisorPeerStatsPage.class);
|
||||
tester.assertRenderedPage(SupervisorPeerStatsPage.class);
|
||||
|
||||
PageParameters pp = new PageParameters();
|
||||
pp.add(PeerReview.PP_PEER_REVIEW_ID, "1" );
|
||||
tester.startPage(SupervisorPeerReviewPage.class,pp);
|
||||
tester.assertRenderedPage(SupervisorPeerReviewPage.class);
|
||||
}
|
||||
|
||||
}
|
BIN
target/work/WicketMockServlet-filestore/2225/4400/e95749e4_308e_4698_a057_bb86050ac96e/pm-null
Normal file
BIN
target/work/WicketMockServlet-filestore/2225/4400/e95749e4_308e_4698_a057_bb86050ac96e/pm-null
Normal file
Binary file not shown.
BIN
target/work/WicketMockServlet-filestore/2349/5733/fd6064a1_8b84_4446_82cc_69fd7167e7c6/pm-null
Normal file
BIN
target/work/WicketMockServlet-filestore/2349/5733/fd6064a1_8b84_4446_82cc_69fd7167e7c6/pm-null
Normal file
Binary file not shown.
BIN
target/work/WicketMockServlet-filestore/4435/793/a137fc0e_994c_4fd1_94a7_801290d34f88/pm-null
Normal file
BIN
target/work/WicketMockServlet-filestore/4435/793/a137fc0e_994c_4fd1_94a7_801290d34f88/pm-null
Normal file
Binary file not shown.
BIN
target/work/WicketMockServlet-filestore/6408/4902/a7851e5b_30d6_4edf_a954_3f4f8c6690fb/pm-null
Normal file
BIN
target/work/WicketMockServlet-filestore/6408/4902/a7851e5b_30d6_4edf_a954_3f4f8c6690fb/pm-null
Normal file
Binary file not shown.
BIN
target/work/WicketMockServlet-filestore/7238/3517/7b8c41d4_a788_46e0_a576_ab3eb0b03be8/pm-null
Normal file
BIN
target/work/WicketMockServlet-filestore/7238/3517/7b8c41d4_a788_46e0_a576_ab3eb0b03be8/pm-null
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user