STEP Default Constructor
This commit is contained in:
parent
7fb88afb5b
commit
bd5aa2d4d9
|
@ -1,10 +1,7 @@
|
|||
package org.gcube.application.cms.plugins.implementations;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import lombok.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.serialization.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||
|
@ -16,18 +13,21 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ToString
|
||||
public class RoleManager {
|
||||
|
||||
HashMap<String,StepAccess> accessMap=new HashMap<>();
|
||||
|
||||
|
||||
public RoleManager(HandlerDeclaration config) throws ConfigurationException {
|
||||
log.debug("Instantiating for configuration {}",config);
|
||||
List l =config.getConfiguration().get("step_access", List.class);
|
||||
if(l==null|| l.isEmpty()) throw new ConfigurationException("Missing Role management in UCD");
|
||||
for (Object o : l) {
|
||||
StepAccess a= Serialization.convert(o, StepAccess.class);
|
||||
accessMap.put(a.getStepId(),a);
|
||||
}
|
||||
log.debug("Access Map is {}",accessMap);
|
||||
}
|
||||
|
||||
public boolean canInvokeStep(String stepID,User u) throws ConfigurationException {
|
||||
|
@ -44,6 +44,7 @@ public class RoleManager {
|
|||
}
|
||||
|
||||
@XmlRootElement
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.gcube.application.cms.plugins;
|
||||
|
||||
public class SimpleLifecycleTests{
|
||||
public class SimpleLifecycleTests {
|
||||
|
||||
// NB cannot use test commons, need to separate modules
|
||||
// extends
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
package org.gcube.application.geoportal.service;
|
||||
|
||||
public class PluginsTests {
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -69,4 +69,6 @@ public class UCDTests extends BasicServiceTestUnit{
|
|||
MediaType.APPLICATION_JSON)), UseCaseDescriptor.class);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
package org.gcube.application.geoportal.service.framework.lifecycleManagers;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.plugins.implementations.RoleManager;
|
||||
import org.gcube.application.cms.tests.TestProfiles;
|
||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||
import org.gcube.application.geoportal.common.model.plugins.LifecycleManagerDescriptor;
|
||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||
import org.gcube.application.geoportal.common.model.useCaseDescriptor.HandlerDeclaration;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class RoleManagerTests {
|
||||
|
||||
@Test
|
||||
public void testRead(){
|
||||
TestProfiles.profiles.forEach((s,u)->{
|
||||
System.out.println("Checking "+s);
|
||||
List<HandlerDeclaration> descriptors =u.getHandlersByType(LifecycleManagerDescriptor.LIFECYCLE_MANAGER_TYPE);
|
||||
descriptors.stream().forEach(h->{
|
||||
RoleManager r = null;
|
||||
try {
|
||||
System.out.println("Role manager : "+ new RoleManager(h));
|
||||
} catch (ConfigurationException e){
|
||||
log.error("Not supported "+ s,e);
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue