Add wisemapping support for import.

This commit is contained in:
Paulo Gustavo Veiga
2012-06-06 00:48:46 -03:00
parent 88b0efa859
commit 79b009e29e
23 changed files with 214 additions and 339 deletions

View File

@@ -41,6 +41,7 @@ final public class Utils {
return result;
}
@NotNull
public static User getUser() {
User result = null;
final Authentication auth = SecurityContextHolder.getContext().getAuthentication();
@@ -51,6 +52,10 @@ final public class Utils {
result = ((UserDetails)principal).getUser();
}
}
if(result==null){
throw new IllegalStateException("User could not be retrieved");
}
return result;
}
}

View File

@@ -31,9 +31,7 @@ public abstract class BaseSecurityAdvice {
public void checkRole(MethodInvocation methodInvocation) throws UnexpectedArgumentException, AccessDeniedSecurityException {
final User user = Utils.getUser();
final Object argument = methodInvocation.getArguments()[0];
boolean isAllowed;
if (argument instanceof MindMap) {

View File

@@ -24,11 +24,11 @@ import com.wisemapping.model.MindMap;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.jetbrains.annotations.NotNull;
public class UpdateSecurityAdvise
extends BaseSecurityAdvice
implements MethodInterceptor
{
extends BaseSecurityAdvice
implements MethodInterceptor {
private UserRole grantedRole = UserRole.COLLABORATOR;
@@ -37,13 +37,18 @@ public class UpdateSecurityAdvise
return methodInvocation.proceed();
}
protected boolean isAllowed(User user, MindMap map)
{
return getMindmapService().isAllowedToView(user,map,grantedRole);
protected boolean isAllowed(@NotNull User user, @NotNull MindMap map) {
boolean result;
if (map.getOwner() == null) {
// This means that the map is new and is an add operation.
result = true;
} else {
result = getMindmapService().isAllowedToView(user, map, grantedRole);
}
return result;
}
protected boolean isAllowed(User user, int mapId)
{
return getMindmapService().isAllowedToView(user,mapId,grantedRole);
protected boolean isAllowed(User user, int mapId) {
return getMindmapService().isAllowedToView(user, mapId, grantedRole);
}
}