Added a way to force add to context
This commit is contained in:
parent
f79e5ab3ff
commit
4b8966d907
|
@ -51,4 +51,6 @@ public interface ERManagement {
|
|||
|
||||
public AvailableInAnotherContextException getSpecificAvailableInAnotherContextException(String message);
|
||||
|
||||
public void setForceAddToContext(Boolean forceAddToContext);
|
||||
|
||||
}
|
|
@ -138,7 +138,10 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
*/
|
||||
protected Map<String,RelationManagement<?, ?>> relationManagements;
|
||||
|
||||
/* Indicate that AddToContext skipped the isntance because it was not the source context */
|
||||
/* The instance is added to the context even is not in source context */
|
||||
protected boolean forceAddToContext;
|
||||
|
||||
/* Indicate that AddToContext skipped the instance because it was not the source context */
|
||||
protected boolean skipped;
|
||||
|
||||
protected EntityManagement(AccessType accessType) {
|
||||
|
@ -298,7 +301,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
|
||||
protected void reallyAddToContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
if(!sourceSecurityContext.isElementInContext(getElement())) {
|
||||
if(!forceAddToContext && !sourceSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
skipped = true;
|
||||
return;
|
||||
|
@ -896,4 +899,9 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceAddToContext(Boolean forceAddToContext) {
|
||||
this.forceAddToContext = forceAddToContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -262,7 +262,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
|||
protected void reallyAddToContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
|
||||
if(!sourceSecurityContext.isElementInContext(getElement())) {
|
||||
if(!forceAddToContext && !sourceSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
skipped = true;
|
||||
return;
|
||||
|
|
|
@ -158,7 +158,10 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
protected PropagationConstraint propagationConstraint;
|
||||
|
||||
/* Indicate that AddToContext skipped the isntance because it was not the source context */
|
||||
/* The instance is added to the context even is not in source context */
|
||||
protected boolean forceAddToContext;
|
||||
|
||||
/* Indicate that AddToContext skipped the instance because it was not the source context */
|
||||
protected boolean skipped;
|
||||
|
||||
@Override
|
||||
|
@ -376,7 +379,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
protected void reallyAddToContext()
|
||||
throws ContextException, ResourceRegistryException {
|
||||
if(!sourceSecurityContext.isElementInContext(getElement())) {
|
||||
if(!forceAddToContext && !sourceSecurityContext.isElementInContext(getElement())) {
|
||||
// The element in not in the source security context. It will be skipped
|
||||
skipped = true;
|
||||
return;
|
||||
|
@ -791,4 +794,9 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
return serializeJsonNodeCollectionAsString(collection);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForceAddToContext(Boolean forceAddToContext) {
|
||||
this.forceAddToContext = forceAddToContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -171,7 +171,8 @@ public class SharingManager {
|
|||
@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
|
||||
@PathParam(AccessPath.UUID_PATH_PARAM) String instanceId,
|
||||
@QueryParam(SharingPath.OPERATION_QUERY_PARAMETER) SharingOperation operation,
|
||||
@QueryParam(SharingPath.DRY_RUN_QUERY_PARAMETER) @DefaultValue("false") Boolean dryRun)
|
||||
@QueryParam(SharingPath.DRY_RUN_QUERY_PARAMETER) @DefaultValue("false") Boolean dryRun,
|
||||
@QueryParam(SharingPath.FORCE_ADD_TO_CONTEXT_QUERY_PARAMETER) @DefaultValue("false") Boolean forceAddToContext)
|
||||
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
|
||||
StringBuffer calledMethod = new StringBuffer();
|
||||
|
@ -196,12 +197,12 @@ public class SharingManager {
|
|||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||
elementManagement.setUUID(UUID.fromString(instanceId));
|
||||
elementManagement.setDryRun(dryRun);
|
||||
|
||||
UUID contextUUID = UUID.fromString(contextId);
|
||||
|
||||
|
||||
if(operation == SharingOperation.ADD) {
|
||||
((ERManagement) elementManagement).addToContext(contextUUID);
|
||||
((ERManagement) elementManagement).setForceAddToContext(forceAddToContext);
|
||||
}else {
|
||||
((ERManagement) elementManagement).removeFromContext(contextUUID);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue