Background

At Leiden University, The Netherlands, we wanted to hide some collections and communities from the Communities and Collections page. This is because we have a special community for all our harvest collections (that include a subset of items from our normal collections), but we did not want to show them to the normal user.

Also, we have a community for a special group within our University, and we wanted to be able to show this community only to people working at this special group.

How it works

It is possible in DSpace to set read access rights to a collection, as you would normally do with items. But for a collection, nothing is done with those access rights if the collection is displayed.

It works by authorizing the READ policy of a community or a collection before it is shown in a Community or Collection list.

If one knows the handle of a hidden community/collection, you can still see it anyway. It is not that access is totally denied to you, it will only not show up on the list if you do not have READ permission.

See it at

If you go to our Communities & Collections page, you cannot see all our communities, because the harvest community is hidden:

https://openaccess.leidenuniv.nl/

or

https://openaccess.leidenuniv.nl/community-list

But if you go directly to it, you can see it:

https://openaccess.leidenuniv.nl/handle/1887/628

Which DSpace version

The modifications I made were originally made to DSpace 1.3.2. It is ported to DSpace version 1.6 and tested on the XMLUI version, but due to the nature of the changes it should also work fine on the JPSUI version.

How to install

Only one file needs to be changed, so make a backup copy of that file! In version 1.6 use a locally changed version of the original file.

Step 1: Change file src/org/dspace/content/Community.java

            // First check the cache
            Community fromCache = (Community) context.fromCache(
                    Community.class, row.getIntColumn("community_id"));
            if (fromCache != null)
            \{
                topCommunities.add(fromCache);
            \}
            else
            \{
                topCommunities.add(new Community(context, row));
            \}

to this:

            // First check the cache
            Community aCommunity = (Community) context.fromCache(
                    Community.class, row.getIntColumn("community_id"));
            if (aCommunity == null) \{
                aCommunity = new Community(context, row);
            \}
            if (AuthorizeManager.authorizeActionBoolean(context,aCommunity,Constants.READ)) \{
              topCommunities.add(aCommunity);
            \}
            // First check the cache
            Collection fromCache = (Collection) ourContext.fromCache(
                    Collection.class, row.getIntColumn("collection_id"));
            if (fromCache != null)
            \{
                collections.add(fromCache);
            \}
            else
            \{
                collections.add(new Collection(ourContext, row));
            \}

to this:

            // First check the cache
            Collection aCollection = (Collection) ourContext.fromCache(
                    Collection.class, row.getIntColumn("collection_id"));
            if (aCollection == null) \{
               aCollection = new Collection(ourContext, row);
            \}
            if (AuthorizeManager.authorizeActionBoolean(ourContext,aCollection,Constants.READ)) \{
              collections.add(aCollection);
            \}
            // First check the cache
            Community fromCache = (Community) ourContext.fromCache(
                    Community.class, row.getIntColumn("community_id"));
            if (fromCache != null)
            \{
                subcommunities.add(fromCache);
            \}
            else
            \{
                subcommunities.add(new Community(ourContext, row));
            \}

to this:

            // First check the cache
            Community aCommunity = (Community) ourContext.fromCache(
                    Community.class, row.getIntColumn("community_id"));
            if (aCommunity == null) \{
                aCommunity = new Community(ourContext, row);
            \}
            if (AuthorizeManager.authorizeActionBoolean(ourContext,aCommunity,Constants.READ)) \{
              subcommunities.add(aCommunity);
            \}

Step 2: Change community and/or collection authorizations

Step 3: build / install / restart

Do the stuff you normally do when deploying a new version of DSpace.

Step 4: test it

Things to do

This functionality can be extended by also checking authorization:

Contact me

If you need help, or have any comments, or you just want to inform me that you (are going to) use this, please contact me at: schaik at library dot leidenuniv dot nl