Permalink
Browse files

Merge pull request #525 from akinom/GROUP.Anonymous_Admin-Constants

DS-1982 define Group.ANONYMOUS_ID and Group.ADMIN_Id and use instead of 0,1
  • Loading branch information...
2 parents bcdba61 + 7fe95b7 commit 8c9362763f95d6dfde93e5ace4f0acb7cb79d862 @mwoodiupui mwoodiupui committed Jun 25, 2014
@@ -1153,7 +1153,7 @@ public static void generateAutomaticPolicies(Context context, Date embargoDate,
boolean isAnonymousInPlace = false;
for (Group g : authorizedGroups)
{
- if (g.getID() == 0)
+ if (g.getID() == Group.ANONYMOUS_ID)
{
isAnonymousInPlace = true;
}
@@ -205,11 +205,11 @@ else if(dso.getType() == Constants.SITE)
//Default all DSpace groups to have "MANAGED GRP" as the type
String contextClass=GROUP_CONTEXTCLASS;
- if(group.getID()==0) //DSpace Anonymous Group = 'GENERAL PUBLIC' type
+ if(group.getID()==Group.ANONYMOUS_ID) //DSpace Anonymous Group = 'GENERAL PUBLIC' type
{
contextClass = ANONYMOUS_CONTEXTCLASS;
}
- else if(group.getID()==1) //DSpace Administrator Group = 'REPOSITORY MGR' type
+ else if(group.getID()==Group.ADMIN_ID) //DSpace Administrator Group = 'REPOSITORY MGR' type
{
contextClass = ADMIN_CONTEXTCLASS;
}
@@ -107,7 +107,7 @@ protected void generatePolicies(Context context, Date embargoDate,
// look for anonymous
boolean isAnonymousInPlace=false;
for(Group g : authorizedGroups){
- if(g.getID()==0){
+ if(g.getID()==Group.ANONYMOUS_ID){
isAnonymousInPlace=true;
}
}
@@ -48,6 +48,12 @@
/** log4j logger */
private static Logger log = Logger.getLogger(Group.class);
+ /** ID of Anonymous Group */
+ public static final int ANONYMOUS_ID = 0;
+
+ /** ID of Administrator Group */
+ public static final int ADMIN_ID = 1;
+
/** Our context */
private Context myContext;
@@ -332,7 +338,7 @@ public void removeMember(Group g)
public boolean isMember(EPerson e)
{
// special, group 0 is anonymous
- if (getID() == 0)
+ if (getID() == Group.ANONYMOUS_ID)
{
return true;
}
@@ -394,7 +394,7 @@ private static boolean anonAccessAllowed(Context context, HarvestedItemInfo item
for (Group authorizedGroup : authorizedGroups)
{
- if (authorizedGroup.getID() == 0)
+ if (authorizedGroup.getID() == Group.ANONYMOUS_ID)
{
return true;
}
@@ -326,7 +326,7 @@ private boolean itemsChanged(Context context, DSpaceObject dso, long timeStamp)
checkAccess:
for (Group group : AuthorizeManager.getAuthorizedGroups(context, result, Constants.READ))
{
- if ((group.getID() == 0))
+ if ((group.getID() == Group.ANONYMOUS_ID))
{
items.add(result);
break checkAccess;
@@ -228,7 +228,7 @@ public void addBody(Body body) throws WingException, SQLException, AuthorizeExce
// authorizations manager.
tableRow.addCell(1,2).addContent(T_default_read_custom);
}
- else if (defaultRead.getID() == 0) {
+ else if (defaultRead.getID() == Group.ANONYMOUS_ID) {
// Anonymous reading
tableRow.addCell().addContent(T_default_read_anonymous);
addAdministratorOnlyButton(tableRow.addCell(),"submit_create_default_read",T_restrict);
@@ -299,7 +299,7 @@ else if (dso instanceof Community)
checkAccess:
for (Group group : AuthorizeManager.getAuthorizedGroups(context, item, Constants.READ))
{
- if ((group.getID() == 0))
+ if ((group.getID() == Group.ANONYMOUS_ID))
{
result.add(item);
break checkAccess;

0 comments on commit 8c93627

Please sign in to comment.