This commit is contained in:
Fabio Sinibaldi 2022-04-08 11:13:25 +02:00
parent c9e5cf473a
commit 28fca1bb6d
3 changed files with 12 additions and 3 deletions

View File

@ -1,6 +1,8 @@
package org.gcube.application.geoportal.service.rest;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.plugins.faults.InsufficientPrivileges;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
import org.gcube.application.geoportal.service.model.internal.faults.InvalidLockException;
import org.gcube.application.geoportal.service.model.internal.faults.ProjectLockedException;
import org.gcube.application.geoportal.service.model.internal.faults.ProjectNotFoundException;
@ -26,14 +28,18 @@ public abstract class GuardedMethod<T> {
public GuardedMethod<T> execute() throws WebApplicationException{
try {
if(!preoperations.isEmpty()) {
if (!preoperations.isEmpty()) {
log.trace("Running preops (size : {} )", preoperations.size());
for (Runnable r : preoperations)
r.run();
}
log.trace("Executing actual method..");
result=run();
result = run();
return this;
}catch (ConfigurationException e){
throw new WebApplicationException("Environment is not properly configured", e,Status.EXPECTATION_FAILED);
}catch (InsufficientPrivileges e){
throw new WebApplicationException("User has insufficient privileges for requested action", e,Status.FORBIDDEN);
}catch(WebApplicationException e) {
log.error("Throwing Web Application Exception ", e);
throw e;

View File

@ -83,7 +83,7 @@ public class UserUtils {
user.setUsername(this.getUser().getId());
user.setRoles(roles);
}catch(Exception e){
log.warn("Unable to determine user id, using FAKE");
log.warn("Unable to determine user id, using FAKE",e);
user.setUsername("FAKE");
user.setRoles(new HashSet<>());
user.getRoles().addAll(DEFAULT_ROLES);

View File

@ -9,6 +9,7 @@ import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
import org.gcube.application.geoportal.common.utils.StorageUtils;
import org.gcube.application.geoportal.service.utils.UserUtils;
import org.junit.Test;
import javax.ws.rs.client.WebTarget;
@ -18,6 +19,7 @@ import static org.junit.Assert.assertTrue;
public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
@Override
protected WebTarget baseTarget() {
@ -27,6 +29,7 @@ public class ProfiledConcessioniTests extends AbstractProfiledDocumentsTests{
@Test
public void testSDI() throws Exception {
UserUtils.DEFAULT_ROLES.add("Data-Manager");
// Create new
Document theDoc=Document.parse("{\n" +
"\"posizionamentoScavo\" :{\n" +