@Test(expected=AuthorizeException.class) public void testCreateAdministratorsNoAuth() throws Exception { new NonStrictExpectations() { AuthorizeUtil authManager; { AuthorizeUtil.authorizeManageAdminGroup((Context) any, (Community) any); result = new AuthorizeException(); } }; Group result = c.createAdministrators(); fail("Exception should have been thrown"); }
public Group createAdministrators() throws SQLException, AuthorizeException { AuthorizeUtil.authorizeManageAdminGroup(ourContext, this); if (admins == null) { ourContext.turnOffAuthorisationSystem(); admins = Group.create(ourContext); ourContext.restoreAuthSystemState(); admins.setName("COMMUNITY_" + getID() + "_ADMIN"); admins.update(); } AuthorizeManager.addPolicy(ourContext, this, Constants.ADMIN, admins); communityRow.setColumn("admin", admins.getID()); modified = true; return admins; }
Community extends DSpaceObject { public Group createAdministrators() throws SQLException, AuthorizeException { AuthorizeUtil.authorizeManageAdminGroup(ourContext, this); if (admins == null) { ourContext.turnOffAuthorisationSystem(); admins = Group.create(ourContext); ourContext.restoreAuthSystemState(); admins.setName("COMMUNITY_" + getID() + "_ADMIN"); admins.update(); } AuthorizeManager.addPolicy(ourContext, this, Constants.ADMIN, admins); communityRow.setColumn("admin", admins.getID()); modified = true; return admins; } }
Community extends DSpaceObject { public Group createAdministrators() throws SQLException, AuthorizeException { AuthorizeUtil.authorizeManageAdminGroup(ourContext, this); if (admins == null) { ourContext.turnOffAuthorisationSystem(); admins = Group.create(ourContext); ourContext.restoreAuthSystemState(); admins.setName("COMMUNITY_" + getID() + "_ADMIN"); admins.update(); } AuthorizeManager.addPolicy(ourContext, this, Constants.ADMIN, admins); communityRow.setColumn("admin", admins.getID()); modified = true; return admins; } Community(Context context, TableRow row); }
Community extends DSpaceObject { public Group createAdministrators() throws SQLException, AuthorizeException { AuthorizeUtil.authorizeManageAdminGroup(ourContext, this); if (admins == null) { ourContext.turnOffAuthorisationSystem(); admins = Group.create(ourContext); ourContext.restoreAuthSystemState(); admins.setName("COMMUNITY_" + getID() + "_ADMIN"); admins.update(); } AuthorizeManager.addPolicy(ourContext, this, Constants.ADMIN, admins); communityRow.setColumn("admin", admins.getID()); modified = true; return admins; } Community(Context context, TableRow row); static Community find(Context context, int id); static Community create(Community parent, Context context); static Community create(Community parent, Context context, String handle); static Community[] findAll(Context context); static Community[] findAllTop(Context context); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); void update(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); Collection[] getCollections(); Community[] getSubcommunities(); Community getParentCommunity(); Community[] getAllParents(); Collection createCollection(); Collection createCollection(String handle); void addCollection(Collection c); Community createSubcommunity(); Community createSubcommunity(String handle); void addSubcommunity(Community c); void removeCollection(Collection c); void removeSubcommunity(Community c); void delete(); boolean equals(Object other); int hashCode(); int getType(); boolean canEditBoolean(); void canEdit(); int countItems(); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject(); }
Community extends DSpaceObject { public Group createAdministrators() throws SQLException, AuthorizeException { AuthorizeUtil.authorizeManageAdminGroup(ourContext, this); if (admins == null) { ourContext.turnOffAuthorisationSystem(); admins = Group.create(ourContext); ourContext.restoreAuthSystemState(); admins.setName("COMMUNITY_" + getID() + "_ADMIN"); admins.update(); } AuthorizeManager.addPolicy(ourContext, this, Constants.ADMIN, admins); communityRow.setColumn("admin", admins.getID()); modified = true; return admins; } Community(Context context, TableRow row); static Community find(Context context, int id); static Community create(Community parent, Context context); static Community create(Community parent, Context context, String handle); static Community[] findAll(Context context); static Community[] findAllTop(Context context); int getID(); String getHandle(); String getMetadata(String field); void setMetadata(String field, String value); String getName(); Bitstream getLogo(); Bitstream setLogo(InputStream is); void update(); Group createAdministrators(); void removeAdministrators(); Group getAdministrators(); Collection[] getCollections(); Community[] getSubcommunities(); Community getParentCommunity(); Community[] getAllParents(); Collection createCollection(); Collection createCollection(String handle); void addCollection(Collection c); Community createSubcommunity(); Community createSubcommunity(String handle); void addSubcommunity(Community c); void removeCollection(Collection c); void removeSubcommunity(Community c); void delete(); boolean equals(Object other); int hashCode(); int getType(); boolean canEditBoolean(); void canEdit(); int countItems(); DSpaceObject getAdminObject(int action); DSpaceObject getParentObject();  }