-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…form-let-them-accept-if-he/she-agrees-to-join Adding a user to the platform let them accept if he/she agrees to join
- Loading branch information
Showing
25 changed files
with
1,011 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
sources/Re3gistry2/src/main/java/eu/europa/ec/re3gistry2/web/controller/Activate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license | ||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template | ||
*/ | ||
package eu.europa.ec.re3gistry2.web.controller; | ||
|
||
import eu.europa.ec.re3gistry2.base.utility.BaseConstants; | ||
import eu.europa.ec.re3gistry2.base.utility.Configuration; | ||
import eu.europa.ec.re3gistry2.base.utility.PersistenceFactory; | ||
import eu.europa.ec.re3gistry2.base.utility.WebConstants; | ||
import eu.europa.ec.re3gistry2.crudimplementation.RegUserCodesManager; | ||
import eu.europa.ec.re3gistry2.crudimplementation.RegUserManager; | ||
import eu.europa.ec.re3gistry2.crudimplementation.RegUserRegGroupMappingManager; | ||
import eu.europa.ec.re3gistry2.javaapi.handler.RegUserHandler; | ||
import eu.europa.ec.re3gistry2.javaapi.handler.RegUserRegCodesHandler; | ||
import eu.europa.ec.re3gistry2.model.RegUser; | ||
import eu.europa.ec.re3gistry2.model.RegUserCodes; | ||
import eu.europa.ec.re3gistry2.model.RegUserRegGroupMapping; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import javax.persistence.EntityManager; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
@WebServlet(WebConstants.PAGE_URINAME_ACTIVATE) | ||
public class Activate extends HttpServlet { | ||
|
||
private void processRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { | ||
|
||
//Init frontend servlet | ||
//añadir booleano para no login? | ||
Configuration.getInstance().initServlet(request, response, false, false); | ||
|
||
// Setup the entity manager | ||
EntityManager entityManager = PersistenceFactory.getEntityManagerFactory().createEntityManager(); | ||
|
||
// Init logger | ||
Logger logger = Configuration.getInstance().getLogger(); | ||
|
||
// Instantiating managers | ||
RegUserCodesManager regUserCodesManager = new RegUserCodesManager(entityManager); | ||
RegUserRegCodesHandler regUserCodesHandler = new RegUserRegCodesHandler(); | ||
RegUserManager regUserManager = new RegUserManager(entityManager); | ||
RegUserHandler regUserHandler = new RegUserHandler(); | ||
|
||
// Getting form parameter | ||
String code = request.getParameter("code"); | ||
|
||
// Getting the user from the code | ||
RegUserCodes regCode = regUserCodesManager.getByCode(code); | ||
RegUser regUser = regUserManager.get(regCode.getRegUser()); | ||
List<RegUserCodes> regCodeAux = regUserCodesManager.getByRegUser(regCode.getRegUser()); | ||
|
||
if(regCode.getAction().equals(BaseConstants.KEY_USER_ACTION_ACTIVATE_USER)){ | ||
//Enabling the user | ||
Boolean enabled = regUserHandler.toggleUserEnabled(regUser, Boolean.TRUE); | ||
|
||
if(enabled){ | ||
//Delete the codes | ||
for(RegUserCodes r:regCodeAux){ | ||
regUserCodesHandler.deleteCode(r); | ||
} | ||
request.getRequestDispatcher(WebConstants.PAGE_JSP_FOLDER + WebConstants.PAGE_PATH_ACTIVATE+ WebConstants.PAGE_URINAME_ACTIVATE + WebConstants.PAGE_JSP_EXTENSION).forward(request, response); | ||
}else{ | ||
//Dispatch request | ||
request.getRequestDispatcher(WebConstants.PAGE_JSP_FOLDER + WebConstants.PAGE_PATH_REGISTRYMANAGER_USERS_ADD + WebConstants.PAGE_URINAME_REGISTRYMANAGER_USERS_ADD + WebConstants.PAGE_JSP_EXTENSION).forward(request, response); | ||
} | ||
}else{ | ||
//Delete the codes | ||
for(RegUserCodes r:regCodeAux){ | ||
regUserCodesHandler.deleteCode(r); | ||
} | ||
|
||
//Delete the user | ||
Boolean removed = regUserHandler.removeUser(regUser); | ||
if(removed){ | ||
//response.sendRedirect("/help"); | ||
request.getRequestDispatcher(WebConstants.PAGE_JSP_FOLDER + WebConstants.PAGE_PATH_DELETE_USER+ WebConstants.PAGE_URINAME_DELETE_USER + WebConstants.PAGE_JSP_EXTENSION).forward(request, response); | ||
}else{ | ||
//Dispatch request | ||
request.getRequestDispatcher(WebConstants.PAGE_JSP_FOLDER + WebConstants.PAGE_PATH_REGISTRYMANAGER_USERS_ADD + WebConstants.PAGE_URINAME_REGISTRYMANAGER_USERS_ADD + WebConstants.PAGE_JSP_EXTENSION).forward(request, response); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { | ||
try { | ||
processRequest(request, response); | ||
} catch (Exception ex) { | ||
Logger logger = Configuration.getInstance().getLogger(); | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { | ||
try { | ||
processRequest(request, response); | ||
} catch (Exception ex) { | ||
Logger logger = Configuration.getInstance().getLogger(); | ||
logger.error(ex.getMessage(), ex); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<%-- | ||
/* | ||
* Copyright 2007,2016 EUROPEAN UNION | ||
* Licensed under the EUPL, Version 1.2 or - as soon they will be approved by | ||
* the European Commission - subsequent versions of the EUPL (the "Licence"); | ||
* You may not use this work except in compliance with the Licence. | ||
* You may obtain a copy of the Licence at: | ||
* | ||
* https://ec.europa.eu/isa2/solutions/european-union-public-licence-eupl_en | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the Licence is distributed on an "AS IS" basis, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the Licence for the specific language governing permissions and | ||
* limitations under the Licence. | ||
* | ||
* Date: 2020/05/11 | ||
* Authors: | ||
* European Commission, Joint Research Centre - jrc-inspire-support@ec.europa.eu | ||
* | ||
* This work was supported by the Interoperability solutions for public | ||
* administrations, businesses and citizens programme (http://ec.europa.eu/isa2) | ||
* through Action 2016.10: European Location Interoperability Solutions for e-Government (ELISE) | ||
*/ | ||
--%> | ||
<%@page import="java.util.ResourceBundle"%> | ||
<%@page import="java.text.MessageFormat"%> | ||
<%@page import="eu.europa.ec.re3gistry2.base.utility.UserHelper"%> | ||
<%@page import="eu.europa.ec.re3gistry2.crudimplementation.RegItemRegGroupRegRoleMappingManager"%> | ||
<%@page import="eu.europa.ec.re3gistry2.model.RegGroup"%> | ||
<%@page import="java.util.HashMap"%> | ||
<%@page import="eu.europa.ec.re3gistry2.base.utility.BaseConstants"%> | ||
<%@page import="javax.persistence.EntityManager"%> | ||
<%@page import="eu.europa.ec.re3gistry2.base.utility.PersistenceFactory"%> | ||
<%@page contentType="text/html" pageEncoding="UTF-8"%> | ||
<%@include file="includes/common.inc.jsp" %> | ||
<jsp:useBean id="constants" class="eu.europa.ec.re3gistry2.base.utility.BaseConstants" scope="session"/> | ||
|
||
<% // Checking if the current user has the rights to add a new itemclass | ||
ResourceBundle localization = (ResourceBundle) request.getAttribute(BaseConstants.KEY_REQUEST_LOCALIZATION); | ||
%> | ||
<!DOCTYPE html> | ||
<html lang="${localization.getString("property.localeid")}" role="document"> | ||
<%@include file="includes/head.inc.jsp" %> | ||
<body> | ||
<%@include file="includes/header.inc.jsp"%> | ||
|
||
<div class="container"> | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
<h1 class="page-heading">${localization.getString("activate.label.title")}</h1> | ||
</div> | ||
</div> | ||
|
||
<div class="row"> | ||
<div class="col"> | ||
|
||
<p>${localization.getString("activate.body")}</p> | ||
<p><%=MessageFormat.format(localization.getString("activate.body.login"), WebConstants.PAGE_URINAME_LOGIN)%></p> | ||
|
||
</div> | ||
</div> | ||
|
||
<hr/> | ||
|
||
</div> | ||
|
||
<%@include file="includes/footer.inc.jsp" %> | ||
<%@include file="includes/pageend.inc.jsp" %> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.