diff --git a/src/main/java/fr/cirad/web/controller/gigwa/GigwaRestController.java b/src/main/java/fr/cirad/web/controller/gigwa/GigwaRestController.java index 77ac5045..4d55ccfd 100644 --- a/src/main/java/fr/cirad/web/controller/gigwa/GigwaRestController.java +++ b/src/main/java/fr/cirad/web/controller/gigwa/GigwaRestController.java @@ -1851,6 +1851,7 @@ else if (filesByExtension.containsKey(fileExtension)) progress.setError("Uploaded data is larger than your allowed maximum (" + maxUploadSize + " Mb)."); boolean fAdminImporter = auth.getAuthorities().contains(new SimpleGrantedAuthority(IRoleDefinition.ROLE_ADMIN)); + boolean fDbCreatorImporter = auth.getAuthorities().contains(new SimpleGrantedAuthority(IRoleDefinition.ROLE_DB_CREATOR)); boolean fAnonymousImporter = auth == null || "anonymousUser".equals(auth.getName()); if (progress.getError() == null) { for (String uri : Arrays.asList(dataUri1, dataUri2, dataUri3)) @@ -2051,7 +2052,7 @@ else if (!writableDBs.contains(sNormalizedModule)) progress.moveToNextStep(); try { // create it - if (!fAdminImporter) { // only administrators may create permanent databases + if (!fAdminImporter && !fDbCreatorImporter) { // only administrators and DB creators may create permanent databases expiryDate = System.currentTimeMillis() + 1000 * 60 * 60 * 24 /* 1 day */; // expiryDate = System.currentTimeMillis() + 1000*60*5 /* 5 mn */; @@ -2070,7 +2071,7 @@ else if (sHost == null || sHost.trim().length() == 0 && !MongoTemplateManager.ge if (sHost == null || sHost.trim().length() == 0) throw new Exception("No host was specified!"); - if (MongoTemplateManager.saveOrUpdateDataSource(MongoTemplateManager.ModuleAction.CREATE, sNormalizedModule, !fAdminImporter, !fAdminImporter, sHost, ncbiTaxonIdNameAndSpecies, expiryDate)) { + if (MongoTemplateManager.saveOrUpdateDataSource(MongoTemplateManager.ModuleAction.CREATE, sNormalizedModule, !fAdminImporter && !fDbCreatorImporter, !fAdminImporter, sHost, ncbiTaxonIdNameAndSpecies, expiryDate)) { LOG.info("Adding database " + sNormalizedModule + " to host " + sHost); fDatasourceExists = true; } @@ -2294,8 +2295,8 @@ else if (MongoTemplateManager.removeDataSource(sNormalizedModule, true)) else if (!fDatasourceAlreadyExisted.get() && !fAnonymousImporter && !fAdminImporter) // a new permanent database was created so we give this user supervisor role on it try { UserWithMethod owner = (UserWithMethod) userDao.loadUserByUsername(auth.getName()); - if (owner.getAuthorities() != null && (owner.getAuthorities().contains(new SimpleGrantedAuthority(IRoleDefinition.ROLE_ADMIN)))) - return; // no need to grant any role to administrators +// if (owner.getAuthorities() != null && (owner.getAuthorities().contains(new SimpleGrantedAuthority(IRoleDefinition.ROLE_ADMIN)))) +// return; // no need to grant any role to administrators SimpleGrantedAuthority role = new SimpleGrantedAuthority(sModule + UserPermissionController.ROLE_STRING_SEPARATOR + IRoleDefinition.ROLE_DB_SUPERVISOR); if (!owner.getAuthorities().contains(role)) { @@ -2309,7 +2310,7 @@ else if (!fDatasourceAlreadyExisted.get() && !fAnonymousImporter && !fAdminImpor tokenManager.reloadUserPermissions(securityContext); } catch (IOException e) { - LOG.error("Unable to give manager role to importer of project " + createdProjectId + " in database " + sModule); + LOG.error("Unable to give manager role to importer of project " + createdProjectId + " in database " + sModule, e); } if (scanner != null) diff --git a/src/main/webapp/WEB-INF/jsp/import.jsp b/src/main/webapp/WEB-INF/jsp/import.jsp index 9b8bf19e..829b4833 100644 --- a/src/main/webapp/WEB-INF/jsp/import.jsp +++ b/src/main/webapp/WEB-INF/jsp/import.jsp @@ -15,7 +15,7 @@ * Public License V3. --%> -<%@ page language="java" contentType="text/html; charset=utf-8" import="fr.cirad.web.controller.ga4gh.Ga4ghRestController,fr.cirad.security.base.IRoleDefinition,fr.cirad.web.controller.gigwa.GigwaRestController,fr.cirad.io.brapi.BrapiService,org.brapi.v2.api.ServerinfoApi,org.brapi.v2.api.SamplesApi" %> +<%@ page language="java" contentType="text/html; charset=utf-8" import="fr.cirad.web.controller.ga4gh.Ga4ghRestController,fr.cirad.security.base.IRoleDefinition,org.springframework.security.core.context.SecurityContextHolder,fr.cirad.web.controller.gigwa.GigwaRestController,fr.cirad.io.brapi.BrapiService,org.brapi.v2.api.ServerinfoApi,org.brapi.v2.api.SamplesApi" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %> @@ -28,6 +28,9 @@ + + + @@ -75,7 +78,7 @@ var brapiGenotypesToken, distinctBrapiMetadataURLs; var extRefIdField = "<%= BrapiService.BRAPI_FIELD_externalReferenceId %>"; var extRefSrcField = "<%= BrapiService.BRAPI_FIELD_externalReferenceSource %>"; - var isAnonymous = ${isAnonymous}, isAdmin = ${isAdmin}; + var isAnonymous = ${isAnonymous}, isAdmin = ${isAdmin}, hasDbCreatorRole = ${hasDbCreatorRole}; var supervisedModules = []; @@ -140,7 +143,7 @@
- +
@@ -152,7 +155,7 @@
- +
You may only create temporary databases