Fixing code
This commit is contained in:
parent
05299464ae
commit
ef6975a2b5
|
@ -481,24 +481,27 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
@Override
|
||||
protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
|
||||
|
||||
InstanceEnvironment requestEnvironment = ContextUtility.getCurrentRequestEnvironment();
|
||||
InstanceEnvironment parentInstanceEnvironment = (InstanceEnvironment) requestEnvironment.getParentEnvironment();
|
||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
||||
InstanceEnvironment instanceEnvironment = contextUtility.getEnvironmentByUUID(uuid);
|
||||
InstanceEnvironment parentInstanceEnvironment = (InstanceEnvironment) instanceEnvironment.getParentEnvironment();
|
||||
|
||||
InstanceEnvironment requestInstanceEnvironment = ContextUtility.getCurrentRequestEnvironment();
|
||||
|
||||
if(parentInstanceEnvironment==null) {
|
||||
// We are trying to delete the root
|
||||
Set<String> allowedRoles = Environment.getAllOperationsAllowedRoles();
|
||||
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
|
||||
if(!requestInstanceEnvironment.isUserAllowed(allowedRoles)) {
|
||||
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can delete the root Context.");
|
||||
}
|
||||
}else {
|
||||
if(uuid.compareTo(parentInstanceEnvironment.getUUID())==0) {
|
||||
Set<String> allowedRoles = requestEnvironment.getAllowedRoles();
|
||||
if(requestInstanceEnvironment.getUUID().compareTo(parentInstanceEnvironment.getUUID())==0) {
|
||||
Set<String> allowedRoles = requestInstanceEnvironment.getAllowedRoles();
|
||||
if(!parentInstanceEnvironment.isUserAllowed(allowedRoles)) {
|
||||
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can delete a child Context.");
|
||||
}
|
||||
}else {
|
||||
Set<String> allowedRoles = Environment.getAllOperationsAllowedRoles();
|
||||
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
|
||||
if(!requestInstanceEnvironment.isUserAllowed(allowedRoles)) {
|
||||
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can delete a Context requesting the operation from a Context which is not the parent.");
|
||||
}
|
||||
}
|
||||
|
@ -516,9 +519,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
* of the context when deleted because the full path is logged.
|
||||
*/
|
||||
element.delete();
|
||||
|
||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
||||
InstanceEnvironment instanceEnvironment = contextUtility.getEnvironmentByUUID(uuid);
|
||||
|
||||
instanceEnvironment.delete(oDatabaseDocument);
|
||||
|
||||
ServerContextCache.getInstance().cleanCache();
|
||||
|
|
Loading…
Reference in New Issue