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