Divers changement:
Ajout d'image pour le download (à changer) Changement de choose preference
This commit is contained in:
@@ -108,14 +108,16 @@ function writePerson() {
|
||||
|
||||
if (person.max <= person.min) {
|
||||
dwr.util.setValues({id:person.id, label:person.label, min:null, max:null });
|
||||
dwr.util.setValues({errorMax:"The max value should'nt be superior to the min value"});
|
||||
dwr.util.setValues({errorMax:"The max value should'nt be superior to the min value"});
|
||||
$('errorMax').style.display = "";
|
||||
}
|
||||
else {
|
||||
dwr.engine.beginBatch();
|
||||
AddCriteriaJS.setCriterionClick(person);
|
||||
fillTable();
|
||||
dwr.engine.endBatch();
|
||||
dwr.util.setValues({ id:-1, label:null, min:1, max:5 });
|
||||
dwr.util.setValues({ id:-1, label:null, min:1, max:5 });
|
||||
$('errorMax').style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="title"><fmt:message key="preference.title" /></h4>
|
||||
|
||||
<h4 class="title"><fmt:message key="preference.title" /></h4>
|
||||
|
||||
<form:form method="post" commandName="choosePreference">
|
||||
<spring:message var="message"/>
|
||||
<p class="formHelp">
|
||||
Choose the preference you have for each article.
|
||||
</p>
|
||||
|
||||
<form:form method="post" commandName="choosePreference">
|
||||
<c:if test="${not empty articleList}">
|
||||
<table>
|
||||
<c:forEach items="${articleList}" var="article" varStatus="i">
|
||||
@@ -30,8 +32,16 @@
|
||||
</table>
|
||||
<input type="submit" name="submit" value="<fmt:message key="button.OK"/>"/>
|
||||
</c:if>
|
||||
</form:form>
|
||||
|
||||
</form:form>
|
||||
|
||||
<c:if test="${param['message'] eq 'done'}">
|
||||
<p class="formOk">
|
||||
You have successfully updated the preference.<br/>
|
||||
You can modify your choices immediately or later.<br/>
|
||||
</p>
|
||||
</c:if>
|
||||
|
||||
<br />
|
||||
<a href="<c:url value="main.htm"/>">Home</a>
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<%@ include file="/WEB-INF/decorators/include.jsp"%>
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
|
||||
<h4 class="title"><fmt:message key="preference.title" /></h4>
|
||||
|
||||
|
||||
<fmt:message key="preference.ok"/>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -7,18 +7,11 @@
|
||||
<script type='text/javascript' src='./javascripts/effects.js'></script>
|
||||
<script type='text/javascript' src='./dwr/engine.js'></script>
|
||||
<script type='text/javascript' src='./dwr/util.js'></script>
|
||||
<script type='text/javascript' src='./dwr/interface/ManagerArticleJS.js'></script>
|
||||
<script type='text/javascript' src='./javascripts/yacos/manageArticle.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h4 class="title"><fmt:message key="manageArticle.title" /></h4>
|
||||
|
||||
<!-- <div id="authorList" class="dynamicFredList">
|
||||
<div class="dynamicListHeader" align="center"><fmt:message
|
||||
key="listarticle.title" /></div>
|
||||
</div> -->
|
||||
|
||||
<br />
|
||||
|
||||
<div id="articleList" class="dynamicFredList">
|
||||
@@ -41,9 +34,9 @@
|
||||
<li>Topic: <b>${article.topic}</b></li>
|
||||
</ul>
|
||||
</td>
|
||||
<td><a id="articleURL${i.index}" href="${article.URL_article}" />Download the article</a></td>
|
||||
<td><a id="modifyArticle${i.index}" href="" />Modify the article</a></td>
|
||||
<td><a id="suppressArticle${i.index}" href="" />Suppress the article</a></td>
|
||||
<td><a id="articleURL${i.index}" title="Download" href="<c:url value="/download.htm"><c:param name="articleId" value="${article.id}"/></c:url>"><img src="./images/cc-download_manager-128x128.png" alt="Download" /></a></td>
|
||||
<td><a id="modifyArticle${i.index}" title="Modify" href=""/><img src="./images/cc-button_ok-128x128.png" alt="Modify" /></a></td>
|
||||
<td><a id="suppressArticle${i.index}" title="Delete" href="" /><img src="./images/cc-button_cancel-128x128.png" alt="Delete" /></a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<%@ include file="/WEB-INF/decorators/include.jsp"%>
|
||||
|
||||
<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<h4 class="title">NO NAME</h4>
|
||||
Soumission OK
|
||||
<br />
|
||||
|
||||
<a href="<c:url value="main.htm"/>">Home</a>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -22,63 +22,25 @@
|
||||
<property name="mappings">
|
||||
<props>
|
||||
<prop key="/main.htm">MainController</prop>
|
||||
<prop key="/submissionArticleOK.htm">
|
||||
SArticleControllerOK
|
||||
</prop>
|
||||
<prop key="/listArticle.htm">
|
||||
ListArticleController
|
||||
</prop>
|
||||
<prop key="/manageArticle.htm">
|
||||
ManageArticleController
|
||||
</prop>
|
||||
<prop key="/registerUser.htm">
|
||||
SUserRegistrationController
|
||||
</prop>
|
||||
<prop key="/submissionArticle.htm">
|
||||
SArticleController
|
||||
</prop>
|
||||
<prop key="/choosePreference.htm">
|
||||
ChoosePreferenceController
|
||||
</prop>
|
||||
<prop key="/dispatchArticleList.htm">
|
||||
DispatchArticleListController
|
||||
</prop>
|
||||
<prop key="/dispatchArticle.htm">
|
||||
DispatchArticleController
|
||||
</prop>
|
||||
<prop key="/addConference.htm">
|
||||
AddConferenceController
|
||||
</prop>
|
||||
<prop key="/listArticle.htm">ListArticleController</prop>
|
||||
<prop key="/manageArticle.htm">ManageArticleController</prop>
|
||||
<prop key="/registerUser.htm">SUserRegistrationController</prop>
|
||||
<prop key="/submissionArticle.htm">SArticleController</prop>
|
||||
<prop key="/choosePreference.htm">ChoosePreferenceController</prop>
|
||||
<prop key="/dispatchArticleList.htm">DispatchArticleListController</prop>
|
||||
<prop key="/dispatchArticle.htm">DispatchArticleController</prop>
|
||||
<prop key="/addConference.htm">AddConferenceController</prop>
|
||||
<prop key="/evaluation.htm">EvaluationController</prop>
|
||||
<prop key="/createReport.htm">
|
||||
CreateReportController
|
||||
</prop>
|
||||
<prop key="/listConference.htm">
|
||||
ListConferenceController
|
||||
</prop>
|
||||
<prop key="/chooseConference.htm">
|
||||
ChooseConferenceController
|
||||
</prop>
|
||||
<prop key="/validateArticle.htm">
|
||||
ValidateArticleController
|
||||
</prop>
|
||||
<prop key="/valideOrReject.htm">
|
||||
ValideOrRejectController
|
||||
</prop>
|
||||
<prop key="/createReport.htm">CreateReportController</prop>
|
||||
<prop key="/listConference.htm">ListConferenceController</prop>
|
||||
<prop key="/chooseConference.htm">ChooseConferenceController</prop>
|
||||
<prop key="/validateArticle.htm">ValidateArticleController</prop>
|
||||
<prop key="/valideOrReject.htm">ValideOrRejectController</prop>
|
||||
<prop key="/login.htm">LogonController</prop>
|
||||
|
||||
<prop key="/listEvaluation.htm">
|
||||
ListEvaluationController
|
||||
</prop>
|
||||
<prop key="/download.htm">
|
||||
ArticleDownloadController
|
||||
</prop>
|
||||
<prop key="/listReport.htm">
|
||||
ListReportController
|
||||
</prop>
|
||||
<prop key="/forgotPassword.htm">
|
||||
ForgotPasswordController
|
||||
</prop>
|
||||
<prop key="/listEvaluation.htm">ListEvaluationController</prop>
|
||||
<prop key="/download.htm">ArticleDownloadController</prop>
|
||||
<prop key="/listReport.htm">ListReportController</prop>
|
||||
<prop key="/forgotPassword.htm">ForgotPasswordController</prop>
|
||||
<prop key="/detailArticle.htm">
|
||||
DetailArticleController
|
||||
</prop>
|
||||
@@ -89,9 +51,6 @@
|
||||
<bean id="MainController"
|
||||
class="org.yacos.web.author.controller.MainController" />
|
||||
|
||||
<bean id="SArticleControllerOK"
|
||||
class="org.yacos.web.author.controller.SArticleControllerOK" />
|
||||
|
||||
<bean id="ListArticleController"
|
||||
class="org.yacos.web.PCmember.controller.ListArticleController">
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
@@ -99,7 +58,6 @@
|
||||
|
||||
<bean id="ManageArticleController"
|
||||
class="org.yacos.web.author.controller.ManageArticleController">
|
||||
<dwr:remote javascript="ManagerArticleJS" />
|
||||
<property name="articleManager" ref="articleManager" />
|
||||
</bean>
|
||||
|
||||
@@ -276,10 +234,6 @@
|
||||
<dwr:configuration>
|
||||
<dwr:convert type="bean"
|
||||
class="org.yacos.web.chairman.form.FormConference">
|
||||
</dwr:convert>
|
||||
|
||||
<dwr:convert type="bean"
|
||||
class="org.yacos.web.author.form.ArticleBean">
|
||||
</dwr:convert>
|
||||
|
||||
<dwr:convert type="bean"
|
||||
|
||||
BIN
YACOSWeb/WebContent/images/cc-button_cancel-128x128.png
Normal file
BIN
YACOSWeb/WebContent/images/cc-button_cancel-128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
BIN
YACOSWeb/WebContent/images/cc-button_ok-128x128.png
Normal file
BIN
YACOSWeb/WebContent/images/cc-button_ok-128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
BIN
YACOSWeb/WebContent/images/cc-download_manager-128x128.png
Normal file
BIN
YACOSWeb/WebContent/images/cc-download_manager-128x128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -467,5 +467,4 @@ textarea {
|
||||
.yacos_button:hover {
|
||||
background-image: url(../images/button_background_hover.png);
|
||||
}
|
||||
|
||||
/* @end */
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.yacos.web.PCmember.controller;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -47,10 +45,10 @@ public class ChoosePreferenceController extends SimpleFormController {
|
||||
|
||||
List<Article> articleList=articleManager.getArticles(currentConferenceId);
|
||||
|
||||
getServletContext().setAttribute("articleList", articleList);
|
||||
request.getSession().setAttribute("articleList", articleList);
|
||||
|
||||
User currentUser = SessionService.getInstance().getCurrentUser();
|
||||
// TODO : mock object, replace with real user management
|
||||
|
||||
ArrayList<Preference> preferencesList = new ArrayList<Preference>();
|
||||
Preference pref;
|
||||
for(Article article : articleList){
|
||||
@@ -86,8 +84,9 @@ public class ChoosePreferenceController extends SimpleFormController {
|
||||
}
|
||||
|
||||
Map<String, String> model = new HashMap<String, String>();
|
||||
model.put("message", "preference.ok");
|
||||
return new ModelAndView(new RedirectView(getSuccessView()), "model", model);
|
||||
model.put("message", "done");
|
||||
|
||||
return new ModelAndView(new RedirectView(getSuccessView()), model);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.yacos.web.PCmember.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
public class ChoosePreferenceControllerOK extends SimpleFormController {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
logger.info("Returning choosePreference OK view");
|
||||
|
||||
return new ModelAndView("choosePreferenceOK");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package org.yacos.web.PCmember.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.yacos.core.article.Preference;
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.yacos.web.author.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
@@ -14,7 +13,6 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
import org.yacos.core.article.Article;
|
||||
import org.yacos.core.article.IArticleManager;
|
||||
import org.yacos.web.author.form.ArticleBean;
|
||||
import org.yacos.web.system.controller.NoConferenceSelectedException;
|
||||
import org.yacos.web.system.session.SessionService;
|
||||
|
||||
@@ -23,40 +21,14 @@ public class ManageArticleController extends SimpleFormController {
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private IArticleManager articleManager;
|
||||
|
||||
/*private List<ArticleBean> listArticleBean;
|
||||
|
||||
public List<ArticleBean> getListArticle() {
|
||||
return listArticleBean;
|
||||
}
|
||||
|
||||
public void setListArticle(List<ArticleBean> listArticleBean) {
|
||||
this.listArticleBean = listArticleBean;
|
||||
}*/
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException, NoConferenceSelectedException {
|
||||
|
||||
logger.info("Returning manageArticle view");
|
||||
|
||||
//listArticleBean = new ArrayList<ArticleBean>();
|
||||
|
||||
List<Article> listArticle;
|
||||
listArticle = articleManager.getArticleOfAuthor(SessionService.getInstance().getCurrentConferenceId(), SessionService.getInstance().getCurrentUserLogin());
|
||||
|
||||
/*for (Article a : listArticle) {
|
||||
ArticleBean ab = new ArticleBean();
|
||||
ab.setId(a.getId());
|
||||
ab.setMainAuthor(a.getMainAuthor().getFirstName() + " " + a.getMainAuthor().getLastName());
|
||||
ab.setSecondaryAuthors(a.getSecondaryAuthors());
|
||||
ab.setTitle(a.getTitle());
|
||||
ab.setTopic(a.getTopic());
|
||||
String fullUrl = request.getContextPath()+"/download.htm?articleId="+a.getId();
|
||||
ab.setURL_article(fullUrl);
|
||||
ab.setState(a.getState().toString());
|
||||
|
||||
listArticleBean.add(ab);
|
||||
}*/
|
||||
|
||||
return new ModelAndView("manageArticle", "listArticle", listArticle);
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.yacos.web.author.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.mvc.SimpleFormController;
|
||||
|
||||
public class SArticleControllerOK extends SimpleFormController {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException {
|
||||
|
||||
logger.info("Returning submission OK view");
|
||||
|
||||
return new ModelAndView("submissionArticleOK");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package org.yacos.web.author.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ArticleBean {
|
||||
|
||||
private int id;
|
||||
private String title;
|
||||
private String topic;
|
||||
private String URL_article;
|
||||
private String mainAuthor;
|
||||
private ArrayList<String> secondaryAuthors;
|
||||
private String state;
|
||||
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public ArticleBean() {}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
public String getTopic() {
|
||||
return topic;
|
||||
}
|
||||
public void setTopic(String topic) {
|
||||
this.topic = topic;
|
||||
}
|
||||
public String getURL_article() {
|
||||
return URL_article;
|
||||
}
|
||||
public void setURL_article(String url_article) {
|
||||
URL_article = url_article;
|
||||
}
|
||||
public String getMainAuthor() {
|
||||
return mainAuthor;
|
||||
}
|
||||
public void setMainAuthor(String mainAuthor) {
|
||||
this.mainAuthor = mainAuthor;
|
||||
}
|
||||
public ArrayList<String> getSecondaryAuthors() {
|
||||
return secondaryAuthors;
|
||||
}
|
||||
public void setSecondaryAuthors(ArrayList<String> secondaryAuthors) {
|
||||
this.secondaryAuthors = secondaryAuthors;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,27 +25,27 @@ import org.yacos.core.users.User;
|
||||
*/
|
||||
public class SessionService {
|
||||
private static SessionService instance = new SessionService();
|
||||
|
||||
|
||||
protected static ServletContext servletContext = null;
|
||||
protected static HttpServletRequest request = null;
|
||||
|
||||
|
||||
private IConferenceManager conferenceManager;
|
||||
private IUserManager userManager;
|
||||
|
||||
|
||||
private User currentUser;
|
||||
private Conference currentConference;
|
||||
private int nbUserConferences;
|
||||
|
||||
|
||||
private SessionService(){
|
||||
}
|
||||
|
||||
|
||||
public static SessionService getInstance(){
|
||||
if(instance == null){
|
||||
instance = new SessionService();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Init method to be called at filter time
|
||||
* Makes the sessionAttributes available in the request context
|
||||
@@ -66,33 +66,34 @@ public class SessionService {
|
||||
request.setAttribute("currentUser", getCurrentUser());
|
||||
// Put the current roles for this user
|
||||
//request.setAttribute("nbUserConferences",getNbUserConferences());
|
||||
|
||||
|
||||
} catch (NamingException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getNbUserConferences() {
|
||||
if(nbUserConferences == -1)
|
||||
{
|
||||
setNbUserConferences();
|
||||
}
|
||||
|
||||
|
||||
return nbUserConferences;
|
||||
}
|
||||
|
||||
public void setNbUserConferences() {
|
||||
int nb = conferenceManager.getConferences(getCurrentUser()).size();
|
||||
this.nbUserConferences = nb;
|
||||
request.setAttribute("nbUserConferences", getNbUserConferences());
|
||||
//request.setAttribute("nbUserConferences", getNbUserConferences());
|
||||
request.setAttribute("nbUserConferences", this.nbUserConferences);
|
||||
}
|
||||
|
||||
public void setConferenceManager(IConferenceManager conferenceManager) {
|
||||
this.conferenceManager = conferenceManager;
|
||||
}
|
||||
|
||||
|
||||
public IConferenceManager getConferenceManager() {
|
||||
if(conferenceManager == null){
|
||||
Context context;
|
||||
@@ -105,11 +106,11 @@ public class SessionService {
|
||||
}
|
||||
return conferenceManager;
|
||||
}
|
||||
|
||||
|
||||
public void setUserManager(IUserManager userManager) {
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
|
||||
public IUserManager getUserManager() {
|
||||
if(userManager == null){
|
||||
Context context;
|
||||
@@ -122,7 +123,7 @@ public class SessionService {
|
||||
}
|
||||
return userManager;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current conference Id
|
||||
* Additionally, put the current conference object in the request context
|
||||
@@ -135,7 +136,7 @@ public class SessionService {
|
||||
Integer confId = (Integer) WebUtils.getSessionAttribute(request, "currentConferenceId");
|
||||
return confId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current conference id
|
||||
* @param request The current HTTP request object, necessary for session operations
|
||||
@@ -148,7 +149,7 @@ public class SessionService {
|
||||
// Refreshing user credentials
|
||||
refreshAuthentication();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current conference using a conference object
|
||||
* @param request The current HTTP request object, necessary for session operations
|
||||
@@ -158,7 +159,7 @@ public class SessionService {
|
||||
setCurrentConferenceId( c.getId() );
|
||||
currentConference = c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets (if necessary) and returns the current conference of the session
|
||||
* @param request The current HTTP request object, necessary for session operations
|
||||
@@ -166,21 +167,23 @@ public class SessionService {
|
||||
*/
|
||||
public Conference getCurrentConference(){
|
||||
Integer id = getCurrentConferenceId();
|
||||
|
||||
|
||||
// The currentConference can be out to date : force the update
|
||||
if(currentConference != null && id != currentConference.getId()){
|
||||
currentConference = null;
|
||||
}
|
||||
|
||||
|
||||
if( currentConference == null && id != null ){
|
||||
currentConference = conferenceManager.getConference(id);
|
||||
}
|
||||
|
||||
if (isUserLogged()){setNbUserConferences();};
|
||||
|
||||
|
||||
if (isUserLogged()) {
|
||||
setNbUserConferences();
|
||||
}
|
||||
|
||||
return currentConference;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current user login from the session
|
||||
* Additionally, puts the current User object in the request context
|
||||
@@ -192,7 +195,7 @@ public class SessionService {
|
||||
// Retrieve the login from the acegi security session
|
||||
return SecurityContextHolder.getContext().getAuthentication().getName();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get (if necessary) and returns the current user object
|
||||
* @return The current User
|
||||
@@ -200,12 +203,12 @@ public class SessionService {
|
||||
public User getCurrentUser() {
|
||||
// Retrieve the login from the session
|
||||
String login = this.getCurrentUserLogin();
|
||||
|
||||
|
||||
// The user can be out to date : force the update
|
||||
if(currentUser != null && (! currentUser.getLogin().equals(login)) ){
|
||||
currentUser = null;
|
||||
}
|
||||
|
||||
|
||||
// Check if the user object is already in cache
|
||||
if(currentUser == null || (currentUser.getLogin().equals(login)) ){
|
||||
// Checks login for validity
|
||||
@@ -218,7 +221,7 @@ public class SessionService {
|
||||
}
|
||||
return currentUser;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether the user is logged (is there a current User for this session)
|
||||
* @return true if there's a current user in the session, false otherwise
|
||||
@@ -226,7 +229,7 @@ public class SessionService {
|
||||
public boolean isUserLogged(){
|
||||
return getCurrentUser() != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Puts an object in the session
|
||||
* @param name The name of the attribute in the session
|
||||
@@ -235,7 +238,7 @@ public class SessionService {
|
||||
public void setSessionAttribute(String name, Object attribute){
|
||||
WebUtils.setSessionAttribute(request, name, attribute);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves an object from the Session
|
||||
* @param name The name of the attribute to retrieve
|
||||
@@ -248,27 +251,27 @@ public class SessionService {
|
||||
public void refreshAuthentication(){
|
||||
refreshAuthentication(null);
|
||||
}
|
||||
|
||||
|
||||
public void refreshAuthentication(String newPassword) {
|
||||
// First step : remove user from the cache
|
||||
DaoAuthenticationProvider authProvider = (DaoAuthenticationProvider) RequestContextUtils.getWebApplicationContext(request).getBean("daoAuthenticationProvider");
|
||||
UserCache userCache = authProvider.getUserCache();
|
||||
|
||||
|
||||
if(userCache != null){
|
||||
userCache.removeUserFromCache(getCurrentUserLogin());
|
||||
}
|
||||
|
||||
|
||||
// Second step : Refreshing user credentials
|
||||
Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if(currentAuthentication instanceof UsernamePasswordAuthenticationToken){
|
||||
|
||||
|
||||
if(newPassword != null){
|
||||
// Setting the new password in the authentication token
|
||||
currentAuthentication = new UsernamePasswordAuthenticationToken(currentAuthentication.getPrincipal(),newPassword);
|
||||
}
|
||||
|
||||
|
||||
SecurityContextHolder.getContext().setAuthentication(authProvider.authenticate(currentAuthentication));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user