|
|
|
@ -12,21 +12,18 @@ import ru.simsonic.rscPermissions.Backends.DatabaseContents;
|
|
|
|
|
|
|
|
|
|
public class InternalCache |
|
|
|
|
{ |
|
|
|
|
public InternalCache() |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
protected final RowInheritance defaultInheritance = new RowInheritance(); |
|
|
|
|
private final HashMap<String, RowEntity> entities_g = new HashMap<>(); |
|
|
|
|
private final HashMap<String, RowEntity> entities_u = new HashMap<>(); |
|
|
|
|
private final ArrayList<RowPermission> permissions_p2g = new ArrayList<>(); |
|
|
|
|
private final ArrayList<RowPermission> permissions_p2u = new ArrayList<>(); |
|
|
|
|
private final ArrayList<RowInheritance> inheritance_g2g = new ArrayList<>(); |
|
|
|
|
private final ArrayList<RowInheritance> inheritance_g2u = new ArrayList<>(); |
|
|
|
|
private final RowInheritance defaultInheritance = new RowInheritance(); |
|
|
|
|
public void setDefaultGroup(String defaultGroup) |
|
|
|
|
{ |
|
|
|
|
defaultInheritance.parent = defaultGroup; |
|
|
|
|
defaultInheritance.deriveInstance(); |
|
|
|
|
} |
|
|
|
|
protected final HashMap<String, RowEntity> entities_g = new HashMap<>(); |
|
|
|
|
protected final HashMap<String, RowEntity> entities_u = new HashMap<>(); |
|
|
|
|
protected final ArrayList<RowPermission> permissions_p2g = new ArrayList<>(); |
|
|
|
|
protected final ArrayList<RowPermission> permissions_p2u = new ArrayList<>(); |
|
|
|
|
protected final ArrayList<RowInheritance> inheritance_g2g = new ArrayList<>(); |
|
|
|
|
protected final ArrayList<RowInheritance> inheritance_g2u = new ArrayList<>(); |
|
|
|
|
public static class InheritanceLeaf implements Comparable<InheritanceLeaf> |
|
|
|
|
{ |
|
|
|
|
public RowInheritance node; |
|
|
|
@ -180,13 +177,13 @@ public class InternalCache
|
|
|
|
|
importEntities(contents.entities); |
|
|
|
|
importPermissions(contents.permissions); |
|
|
|
|
importInheritance(contents.inheritance); |
|
|
|
|
buildEntityTree(); |
|
|
|
|
} |
|
|
|
|
private int importEntities(RowEntity[] rows) |
|
|
|
|
private void importEntities(RowEntity[] rows) |
|
|
|
|
{ |
|
|
|
|
entities_g.clear(); |
|
|
|
|
entities_u.clear(); |
|
|
|
|
if(rows == null) |
|
|
|
|
return 0; |
|
|
|
|
if(rows != null) |
|
|
|
|
for(RowEntity row : rows) |
|
|
|
|
{ |
|
|
|
|
if(row.entityType == EntityType.group) |
|
|
|
@ -194,14 +191,12 @@ public class InternalCache
|
|
|
|
|
else |
|
|
|
|
entities_u.put(row.entity.toLowerCase(), row); |
|
|
|
|
} |
|
|
|
|
return entities_g.size() + entities_u.size(); |
|
|
|
|
} |
|
|
|
|
private int importPermissions(RowPermission[] rows) |
|
|
|
|
private void importPermissions(RowPermission[] rows) |
|
|
|
|
{ |
|
|
|
|
permissions_p2g.clear(); |
|
|
|
|
permissions_p2u.clear(); |
|
|
|
|
if(rows == null) |
|
|
|
|
return 0; |
|
|
|
|
if(rows != null) |
|
|
|
|
for(RowPermission row : rows) |
|
|
|
|
{ |
|
|
|
|
if(row.entityType == EntityType.group) |
|
|
|
@ -209,23 +204,18 @@ public class InternalCache
|
|
|
|
|
else |
|
|
|
|
permissions_p2u.add(row); |
|
|
|
|
} |
|
|
|
|
return permissions_p2g.size() + permissions_p2u.size(); |
|
|
|
|
} |
|
|
|
|
private int importInheritance(RowInheritance[] rows) |
|
|
|
|
private void importInheritance(RowInheritance[] rows) |
|
|
|
|
{ |
|
|
|
|
inheritance_g2g.clear(); |
|
|
|
|
inheritance_g2u.clear(); |
|
|
|
|
if(rows == null) |
|
|
|
|
return 0; |
|
|
|
|
if(rows != null) |
|
|
|
|
for(RowInheritance row : rows) |
|
|
|
|
{ |
|
|
|
|
if(row.childType == EntityType.group) |
|
|
|
|
inheritance_g2g.add(row); |
|
|
|
|
else |
|
|
|
|
inheritance_g2u.add(row); |
|
|
|
|
} |
|
|
|
|
return inheritance_g2g.size() + inheritance_g2u.size(); |
|
|
|
|
} |
|
|
|
|
public synchronized void clear() |
|
|
|
|
{ |
|
|
|
|
entities_g.clear(); |
|
|
|
|