Skip to content

Commit

Permalink
Merge pull request #262 from ec-jrc/develop
Browse files Browse the repository at this point in the history
Pre-release of v2.4.2
  • Loading branch information
unaibrrgn authored Mar 20, 2023
2 parents 7d2bef3 + 367b76d commit f528762
Show file tree
Hide file tree
Showing 41 changed files with 1,491 additions and 175 deletions.
14 changes: 13 additions & 1 deletion dist/db-scripts/registry2_drop-and-create-and-init.sql.orig
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,14 @@ CREATE TABLE reg_user_reg_group_mapping
editdate TIMESTAMP WITHOUT TIME ZONE
);

CREATE TABLE reg_user_codes
(
uuid VARCHAR(50) NOT NULL,
reg_user VARCHAR(50) NOT NULL,
code VARCHAR(80),
action VARCHAR(50),
insertdate TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now()
);

/* Create Primary Keys */

Expand Down Expand Up @@ -448,7 +456,9 @@ ALTER TABLE reg_user ADD CONSTRAINT PK_reg_user

ALTER TABLE reg_user_reg_group_mapping ADD CONSTRAINT PK_reg_user_reg_group_mapping
PRIMARY KEY (uuid);


ALTER TABLE reg_user_codes ADD CONSTRAINT PK_reg_user_codes
PRIMARY KEY (uuid);

/* Create Uniques */

Expand Down Expand Up @@ -722,6 +732,8 @@ ALTER TABLE reg_user_reg_group_mapping ADD CONSTRAINT FK_reg_user_reg_group_mapp
ALTER TABLE reg_user_reg_group_mapping ADD CONSTRAINT FK_reg_user_reg_group_mapping_reg_user
FOREIGN KEY (reg_user) REFERENCES reg_user (uuid) ON DELETE NO ACTION ON UPDATE CASCADE;

ALTER TABLE reg_user_codes ADD CONSTRAINT FK_reg_user_code_reg_user
FOREIGN KEY (reg_user) REFERENCES reg_user (uuid) ON DELETE NO ACTION ON UPDATE CASCADE;

/* Create functions and triggers */

Expand Down
10 changes: 10 additions & 0 deletions documentation/developer-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,13 @@ For tomcat, add two files to the tomcat lib folder: ecas-tomcat-x.y.z.jar and lo
Verify that the JDK trusts the [ECAS certificates](https://webgate.ec.europa.eu/CITnet/confluence/display/IAM/Downloads-Certificates) else import them on the keystore of the JVM.

Restart the service and check the authentication menchanism.

### Email notifications and templates

You can currently change some of the variables of the different email templates such as the instance/organisation name.

To change those you can access the [configuration.properties](https://github.com/ec-jrc/re3gistry/blob/master/sources/Re3gistry2/src/main/resources/configurations_files/configuration.properties) file, where you can search the mail template variables by searching the "mail.text" variables.
You can there see the different subjects and text that you can change. Have in account that some of these may need some proper code changing in their respective java classes.
App's default name is Re3gistry2, this variable is used in some email templates that show the instance name. The property that manages this name is called "application.default.name". This variable can be found in the same [configuration.properties](https://github.com/ec-jrc/re3gistry/blob/master/sources/Re3gistry2/src/main/resources/configurations_files/configuration.properties) file.


3 changes: 3 additions & 0 deletions documentation/user-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ Depending on the type of installation, using an external authentication provider

![User profile section - Editing details](images/userprofile.png)

## Email notifications

Users can receive different email notifications, indicating different statuses and actions done to the items and actions they're related to. These notifications indicate the status of the items (Item's been submitted, published etc.) and some of the actions done in the instance such as permissions and roles given to a user.

## Additional Notes

Expand Down
9 changes: 3 additions & 6 deletions sources/Re3gistry2-build-helper/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,17 @@ services:
- ALLOW_IP_RANGE="0.0.0.0/0"
volumes:
- ../../dist/db-scripts/registry2_drop-and-create-and-init.sql.orig:/docker-entrypoint-initdb.d/init.sql
# - ../../dist/customize-interface/example-profile-developer-docker/dbdumpv1.sql:/docker-entrypoint-initdb.d/init.sql
# Test database tu use it without installation
# Test database to use it without installation
# Be sure file sources-main/resources-configurations_files/system.installed
# is removed from the war file. If not, installation will be not detected.
# - ../../dist/customize-interface/example-profile-developer-docker/dbdumpv1.sql:/docker-entrypoint-initdb.d/init_backup.sql
- ../../dist/customize-interface/example-profile-developer-docker/dump-docker-202205180929.sql:/docker-entrypoint-initdb.d/init_backup.sql
# - ../../dist/customize-interface/example-profile-developer-docker/fulldump.sql:/docker-entrypoint-initdb.d/init_backup.sql
# login from example db: [email protected] password
# login example db: [email protected] password
expose:
- "5432"
ports:
- 5432:5432
networks:
- main

web:
depends_on:
- db
Expand Down Expand Up @@ -84,6 +80,7 @@ services:
- "8983:8983"
# volumes:
# - ../../../solr:/opt/solr/server/solr/re3gistry2

entrypoint:
- docker-entrypoint.sh
- solr-precreate
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import eu.europa.ec.re3gistry2.base.utility.Configuration;
import eu.europa.ec.re3gistry2.base.utility.BaseConstants;
import eu.europa.ec.re3gistry2.base.utility.InputSanitizerHelper;
import eu.europa.ec.re3gistry2.base.utility.MailManager;
import eu.europa.ec.re3gistry2.base.utility.PersistenceFactory;
import eu.europa.ec.re3gistry2.base.utility.UserHelper;
import eu.europa.ec.re3gistry2.base.utility.WebConstants;
Expand Down Expand Up @@ -53,15 +54,19 @@
import eu.europa.ec.re3gistry2.model.RegRelationproposed;
import eu.europa.ec.re3gistry2.model.RegRole;
import eu.europa.ec.re3gistry2.model.RegUser;
import eu.europa.ec.re3gistry2.web.utility.SendEmailFromAction;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
import java.util.ResourceBundle;
import javax.mail.internet.InternetAddress;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.Persistence;
Expand Down Expand Up @@ -167,53 +172,53 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
// This is a view request


//Cache the parent of the proposed item
ItemCache cache = (ItemCache) request.getAttribute(BaseConstants.ATTRIBUTE_CACHE_KEY);
if (cache == null) {
cache = new EhCache();
request.setAttribute(BaseConstants.ATTRIBUTE_CACHE_KEY, cache);
}
if (formRegActionUuid != null){
RegAction regActionForCache;
List<RegItemproposed> regItemProposeds;
try{
regActionForCache = regActionManager.get(formRegActionUuid);
regItemProposeds = regItemproposedManager.getAll(regActionForCache);
}catch(Exception e){
regItemProposeds = Collections.emptyList();
}

HashSet<String> parentsList = new HashSet <String>();
HashSet<String> collectionsList = new HashSet <String>();
for (RegItemproposed regItemProposed : regItemProposeds) {
List<RegRelationproposed> collections = regRelationproposedManager.getAllByObject(regItemProposed);

if(collections != null && collections.size() > 0 ){
for (RegRelationproposed collection : collections) {
if(collection.getRegRelationpredicate().getLocalid().equals(BaseConstants.KEY_PREDICATE_COLLECTION)){
String uuid = collection.getRegItemObject().getUuid();
collectionsList.add(uuid);
}
}
}
if(regItemProposed.getRegAction() != null && regItemProposed.getRegAction().getRegItemRegister() != null){
if(regItemProposed.getRegAction().getRegItemRegister().getRegItemclass() != null && regItemProposed.getRegAction().getRegItemRegister().getRegItemclass().getUuid() != null){
String uuid = regItemProposed.getRegAction().getRegItemRegister().getRegItemclass().getUuid();
parentsList.add(uuid);
}
}
}
EntityManager emCache = PersistenceFactory.getEntityManagerFactory().createEntityManager();
CacheAll cacheAll = new CacheAll(emCache, cache, null);
for (String uuid : parentsList) {
// EntityManager emCache = Persistence.createEntityManagerFactory(BaseConstants.KEY_PROPERTY_PERSISTENCE_UNIT_NAME).createEntityManager();
cacheAll.run(uuid);
}
for (String uuid : collectionsList) {
// EntityManager emCache = Persistence.createEntityManagerFactory(BaseConstants.KEY_PROPERTY_PERSISTENCE_UNIT_NAME).createEntityManager();
cacheAll.run(uuid);
}
}
// //Cache the parent of the proposed item
// ItemCache cache = (ItemCache) request.getAttribute(BaseConstants.ATTRIBUTE_CACHE_KEY);
// if (cache == null) {
// cache = new EhCache();
// request.setAttribute(BaseConstants.ATTRIBUTE_CACHE_KEY, cache);
// }
// if (formRegActionUuid != null){
// RegAction regActionForCache;
// List<RegItemproposed> regItemProposeds;
// try{
// regActionForCache = regActionManager.get(formRegActionUuid);
// regItemProposeds = regItemproposedManager.getAll(regActionForCache);
// }catch(Exception e){
// regItemProposeds = Collections.emptyList();
// }
//
// HashSet<String> parentsList = new HashSet <String>();
// HashSet<String> collectionsList = new HashSet <String>();
// for (RegItemproposed regItemProposed : regItemProposeds) {
// List<RegRelationproposed> collections = regRelationproposedManager.getAllByObject(regItemProposed);
//
// if(collections != null && collections.size() > 0 ){
// for (RegRelationproposed collection : collections) {
// if(collection.getRegRelationpredicate().getLocalid().equals(BaseConstants.KEY_PREDICATE_COLLECTION)){
// String uuid = collection.getRegItemObject().getUuid();
// collectionsList.add(uuid);
// }
// }
// }
// if(regItemProposed.getRegAction() != null && regItemProposed.getRegAction().getRegItemRegister() != null){
// if(regItemProposed.getRegAction().getRegItemRegister().getRegItemclass() != null && regItemProposed.getRegAction().getRegItemRegister().getRegItemclass().getUuid() != null){
// String uuid = regItemProposed.getRegAction().getRegItemRegister().getRegItemclass().getUuid();
// parentsList.add(uuid);
// }
// }
// }
// EntityManager emCache = PersistenceFactory.getEntityManagerFactory().createEntityManager();
// CacheAll cacheAll = new CacheAll(emCache, cache, null);
// for (String uuid : parentsList) {
//// EntityManager emCache = Persistence.createEntityManagerFactory(BaseConstants.KEY_PROPERTY_PERSISTENCE_UNIT_NAME).createEntityManager();
// cacheAll.run(uuid);
// }
// for (String uuid : collectionsList) {
//// EntityManager emCache = Persistence.createEntityManagerFactory(BaseConstants.KEY_PROPERTY_PERSISTENCE_UNIT_NAME).createEntityManager();
// cacheAll.run(uuid);
// }
// }


// Getting the submitting organization RegRole
Expand Down Expand Up @@ -269,13 +274,22 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp
} catch (NoResultException e) {
}
}



if (regItemproposeds == null && regAction!=null) {
regItemproposeds = (List<RegItemproposed>) regItemproposedManager.getAll(regAction);
}

request.setAttribute(BaseConstants.KEY_REQUEST_ACTION_LIST, regActions);
request.setAttribute(BaseConstants.KEY_REQUEST_ACTION, regAction);
request.setAttribute(BaseConstants.KEY_REQUEST_ITEM_PROPOSEDS, regItemproposeds);
request.setAttribute(BaseConstants.KEY_REQUEST_ITEM_HISTORYS, regItemhistorys);
request.setAttribute(BaseConstants.KEY_REQUEST_REGITEMS, regItems);


if (formRegActionUuid != null && formRegActionUuid.length() > 0 && formSubmitAction != null && formSubmitAction.length() > 0 && formActionType != null && formActionType.length() > 0) {
MailManager.sendActionMail(regItemproposeds, regAction, Configuration.getInstance().getLocalization(), BaseConstants.KEY_FIELD_MANDATORY_CONTROLBODY);
}

//Dispatch request
request.getRequestDispatcher(WebConstants.PAGE_JSP_FOLDER + WebConstants.PAGE_PATH_CONTROLBODY + WebConstants.PAGE_URINAME_CONTROLBODY + WebConstants.PAGE_JSP_EXTENSION).forward(request, response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import eu.europa.ec.re3gistry2.base.utility.BaseConstants;
import eu.europa.ec.re3gistry2.base.utility.Configuration;
import eu.europa.ec.re3gistry2.base.utility.InputSanitizerHelper;
import eu.europa.ec.re3gistry2.base.utility.MailManager;
import eu.europa.ec.re3gistry2.base.utility.PersistenceFactory;
import eu.europa.ec.re3gistry2.javaapi.handler.RegItemproposedHandler;
import eu.europa.ec.re3gistry2.model.RegUser;
Expand Down Expand Up @@ -120,6 +121,8 @@ private void processRequest(HttpServletRequest request, HttpServletResponse resp

// get all regItemProposed for this action
List<RegItemproposed> regItemproposedList = regItemproposedManager.getAll(regAction);

MailManager.sendActionMail(regItemproposedList, regAction, Configuration.getInstance().getLocalization(), BaseConstants.KEY_FIELD_MANDATORY_SUBMITTINGORGANIZATIONS);

if (!regItemproposedList.isEmpty()) {
for (RegItemproposed regItemproposed : regItemproposedList) {
Expand Down
Loading

0 comments on commit f528762

Please sign in to comment.