Class CommunitiesResource


  • @Path("/communities")
    public class CommunitiesResource
    extends Resource
    Class which provides CRUD methods over communities.
    Author:
    Rostislav Novak (Computing and Information Centre, CTU in Prague)
    • Constructor Detail

      • CommunitiesResource

        public CommunitiesResource()
    • Method Detail

      • getCommunity

        @GET
        @Path("/{community_id}")
        @Produces({"application/json","application/xml"})
        public Community getCommunity​(@PathParam("community_id")
                                      String communityId,
                                      @QueryParam("expand")
                                      String expand,
                                      @QueryParam("userIP")
                                      String user_ip,
                                      @QueryParam("userAgent")
                                      String user_agent,
                                      @QueryParam("xforwardedfor")
                                      String xforwardedfor,
                                      @Context
                                      javax.ws.rs.core.HttpHeaders headers,
                                      @Context
                                      javax.servlet.http.HttpServletRequest request)
                               throws javax.ws.rs.WebApplicationException
        Returns community with basic properties. If you want more, use expand parameter or method for community collections or subcommunities.
        Parameters:
        communityId - Id of community in DSpace.
        expand - String in which is what you want to add to returned instance of community. Options are: "all", "parentCommunity", "collections", "subCommunities" and "logo". If you want to use multiple options, it must be separated by commas.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return instance of org.dspace.rest.common.Community.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading. Also if id of community is incorrect or logged user into context has no permission to read.
      • getCommunities

        @GET
        @Produces({"application/json","application/xml"})
        public Community[] getCommunities​(@QueryParam("expand")
                                          String expand,
                                          @QueryParam("limit") @DefaultValue("100")
                                          Integer limit,
                                          @QueryParam("offset") @DefaultValue("0")
                                          Integer offset,
                                          @QueryParam("userIP")
                                          String user_ip,
                                          @QueryParam("userAgent")
                                          String user_agent,
                                          @QueryParam("xforwardedfor")
                                          String xforwardedfor,
                                          @Context
                                          javax.ws.rs.core.HttpHeaders headers,
                                          @Context
                                          javax.servlet.http.HttpServletRequest request)
                                   throws javax.ws.rs.WebApplicationException
        Return all communities in DSpace.
        Parameters:
        expand - String in which is what you want to add to returned instance of community. Options are: "all", "parentCommunity", "collections", "subCommunities" and "logo". If you want to use multiple options, it must be separated by commas.
        limit - Maximum communities in array. Default value is 100.
        offset - Index from which will start array of communities.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return array of communities.
        Throws:
        javax.ws.rs.WebApplicationException - It can be caused by creating context or while was problem with reading community from database(SQLException).
      • getTopCommunities

        @GET
        @Path("/top-communities")
        @Produces({"application/json","application/xml"})
        public Community[] getTopCommunities​(@QueryParam("expand")
                                             String expand,
                                             @QueryParam("limit") @DefaultValue("20")
                                             Integer limit,
                                             @QueryParam("offset") @DefaultValue("0")
                                             Integer offset,
                                             @QueryParam("userIP")
                                             String user_ip,
                                             @QueryParam("userAgent")
                                             String user_agent,
                                             @QueryParam("xforwardedfor")
                                             String xforwardedfor,
                                             @Context
                                             javax.ws.rs.core.HttpHeaders headers,
                                             @Context
                                             javax.servlet.http.HttpServletRequest request)
                                      throws javax.ws.rs.WebApplicationException
        Return all top communities in DSpace. Top communities are communities on the root of tree.
        Parameters:
        expand - String in which is what you want to add to returned instance of community. Options are: "all", "parentCommunity", "collections", "subCommunities" and "logo". If you want to use multiple options, it must be separated by commas.
        limit - Maximum communities in array. Default value is 100.
        offset - Index from which will start array of communities. Default value is 0.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return array of top communities.
        Throws:
        javax.ws.rs.WebApplicationException - It can be caused by creating context or while was problem with reading community from database(SQLException).
      • getCommunityCollections

        @GET
        @Path("/{community_id}/collections")
        @Produces({"application/json","application/xml"})
        public Collection[] getCommunityCollections​(@PathParam("community_id")
                                                    String communityId,
                                                    @QueryParam("expand")
                                                    String expand,
                                                    @QueryParam("limit") @DefaultValue("100")
                                                    Integer limit,
                                                    @QueryParam("offset") @DefaultValue("0")
                                                    Integer offset,
                                                    @QueryParam("userIP")
                                                    String user_ip,
                                                    @QueryParam("userAgent")
                                                    String user_agent,
                                                    @QueryParam("xforwardedfor")
                                                    String xforwardedfor,
                                                    @Context
                                                    javax.ws.rs.core.HttpHeaders headers,
                                                    @Context
                                                    javax.servlet.http.HttpServletRequest request)
                                             throws javax.ws.rs.WebApplicationException
        Return all collections of community.
        Parameters:
        communityId - Id of community in DSpace.
        expand - String in which is what you want to add to returned instance of collection. Options are: "all", "parentCommunityList", "parentCommunity", "items", "license" and "logo". If you want to use multiple options, it must be separated by commas.
        limit - Maximum collection in array. Default value is 100.
        offset - Index from which will start array of collections. Default value is 0.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return array of collections of community.
        Throws:
        javax.ws.rs.WebApplicationException - It can be caused by creating context or while was problem with reading community from database(SQLException).
      • getCommunityCommunities

        @GET
        @Path("/{community_id}/communities")
        @Produces({"application/json","application/xml"})
        public Community[] getCommunityCommunities​(@PathParam("community_id")
                                                   String communityId,
                                                   @QueryParam("expand")
                                                   String expand,
                                                   @QueryParam("limit") @DefaultValue("20")
                                                   Integer limit,
                                                   @QueryParam("offset") @DefaultValue("0")
                                                   Integer offset,
                                                   @QueryParam("userIP")
                                                   String user_ip,
                                                   @QueryParam("userAgent")
                                                   String user_agent,
                                                   @QueryParam("xforwardedfor")
                                                   String xforwardedfor,
                                                   @Context
                                                   javax.ws.rs.core.HttpHeaders headers,
                                                   @Context
                                                   javax.servlet.http.HttpServletRequest request)
                                            throws javax.ws.rs.WebApplicationException
        Return all subcommunities of community.
        Parameters:
        communityId - Id of community in DSpace.
        expand - String in which is what you want to add to returned instance of community. Options are: "all", "parentCommunity", "collections", "subCommunities" and "logo". If you want to use multiple options, it must be separated by commas.
        limit - Maximum communities in array. Default value is 20.
        offset - Index from which will start array of communities. Default value is 0.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return array of subcommunities of community.
        Throws:
        javax.ws.rs.WebApplicationException - It can be caused by creating context or while was problem with reading community from database(SQLException).
      • createCommunity

        @POST
        @Consumes({"application/json","application/xml"})
        public Community createCommunity​(Community community,
                                         @QueryParam("userIP")
                                         String user_ip,
                                         @QueryParam("userAgent")
                                         String user_agent,
                                         @QueryParam("xforwardedfor")
                                         String xforwardedfor,
                                         @Context
                                         javax.ws.rs.core.HttpHeaders headers,
                                         @Context
                                         javax.servlet.http.HttpServletRequest request)
                                  throws javax.ws.rs.WebApplicationException
        Create community at top level. Creating community at top level has permission only admin.
        Parameters:
        community - Community which will be created at top level of communities.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Returns response with handle of community, if was all ok.
        Throws:
        javax.ws.rs.WebApplicationException - It can be thrown by SQLException, AuthorizeException and ContextException.
      • addCommunityCollection

        @POST
        @Path("/{community_id}/collections")
        @Consumes({"application/json","application/xml"})
        public Collection addCommunityCollection​(@PathParam("community_id")
                                                 String communityId,
                                                 Collection collection,
                                                 @QueryParam("userIP")
                                                 String user_ip,
                                                 @QueryParam("userAgent")
                                                 String user_agent,
                                                 @QueryParam("xforwardedfor")
                                                 String xforwardedfor,
                                                 @Context
                                                 javax.ws.rs.core.HttpHeaders headers,
                                                 @Context
                                                 javax.servlet.http.HttpServletRequest request)
                                          throws javax.ws.rs.WebApplicationException
        Create collection in community.
        Parameters:
        communityId - Id of community in DSpace.
        collection - Collection which will be added into community.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return response 200 if was everything all right. Otherwise 400 when id of community was incorrect or 401 if was problem with permission to write into collection.
        Throws:
        javax.ws.rs.WebApplicationException - It is thrown when was problem with database reading or writing. Or problem with authorization to community. Or problem with creating context.
      • addCommunityCommunity

        @POST
        @Path("/{community_id}/communities")
        @Consumes({"application/json","application/xml"})
        public Community addCommunityCommunity​(@PathParam("community_id")
                                               String communityId,
                                               Community community,
                                               @QueryParam("userIP")
                                               String user_ip,
                                               @QueryParam("userAgent")
                                               String user_agent,
                                               @QueryParam("xforwardedfor")
                                               String xforwardedfor,
                                               @Context
                                               javax.ws.rs.core.HttpHeaders headers,
                                               @Context
                                               javax.servlet.http.HttpServletRequest request)
                                        throws javax.ws.rs.WebApplicationException
        Create subcommunity in community.
        Parameters:
        communityId - Id of community in DSpace, in which will be created subcommunity.
        community - Community which will be added into community.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return response 200 if was everything all right. Otherwise 400 when id of community was incorrect or 401 if was problem with permission to write into collection.
        Throws:
        javax.ws.rs.WebApplicationException - It is thrown when was problem with database reading or writing. Or problem with authorization to community. Or problem with creating context.
      • updateCommunity

        @PUT
        @Path("/{community_id}")
        @Consumes({"application/json","application/xml"})
        public javax.ws.rs.core.Response updateCommunity​(@PathParam("community_id")
                                                         String communityId,
                                                         Community community,
                                                         @QueryParam("userIP")
                                                         String user_ip,
                                                         @QueryParam("userAgent")
                                                         String user_agent,
                                                         @QueryParam("xforwardedfor")
                                                         String xforwardedfor,
                                                         @Context
                                                         javax.ws.rs.core.HttpHeaders headers,
                                                         @Context
                                                         javax.servlet.http.HttpServletRequest request)
                                                  throws javax.ws.rs.WebApplicationException
        Update community. Replace all information about community except: id, handle and expandle items.
        Parameters:
        communityId - Id of community in DSpace.
        community - Instance of community which will replace actual community in DSpace.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Response 200 if was all ok. Otherwise 400 if id was incorrect or 401 if logged user has no permission to delete community.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading or writing. Or problem with writing to community caused by authorization.
      • deleteCommunity

        @DELETE
        @Path("/{community_id}")
        public javax.ws.rs.core.Response deleteCommunity​(@PathParam("community_id")
                                                         String communityId,
                                                         @QueryParam("userIP")
                                                         String user_ip,
                                                         @QueryParam("userAgent")
                                                         String user_agent,
                                                         @QueryParam("xforwardedfor")
                                                         String xforwardedfor,
                                                         @Context
                                                         javax.ws.rs.core.HttpHeaders headers,
                                                         @Context
                                                         javax.servlet.http.HttpServletRequest request)
                                                  throws javax.ws.rs.WebApplicationException
        Delete community from DSpace. It delete it everything with community!
        Parameters:
        communityId - Id of community in DSpace.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return response code OK(200) if was everything all right. Otherwise return NOT_FOUND(404) if was id of community incorrect. Or (UNAUTHORIZED)401 if was problem with permission to community.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading or deleting. Or problem with deleting community caused by IOException or authorization.
      • deleteCommunityCollection

        @DELETE
        @Path("/{community_id}/collections/{collection_id}")
        public javax.ws.rs.core.Response deleteCommunityCollection​(@PathParam("community_id")
                                                                   String communityId,
                                                                   @PathParam("collection_id")
                                                                   String collectionId,
                                                                   @QueryParam("userIP")
                                                                   String user_ip,
                                                                   @QueryParam("userAgent")
                                                                   String user_agent,
                                                                   @QueryParam("xforwardedfor")
                                                                   String xforwardedfor,
                                                                   @Context
                                                                   javax.ws.rs.core.HttpHeaders headers,
                                                                   @Context
                                                                   javax.servlet.http.HttpServletRequest request)
                                                            throws javax.ws.rs.WebApplicationException
        Delete collection in community.
        Parameters:
        communityId - Id of community in DSpace.
        collectionId - Id of collection which will be deleted.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return response code OK(200) if was everything all right. Otherwise return NOT_FOUND(404) if was id of community or collection incorrect. Or (UNAUTHORIZED)401 if was problem with permission to community or collection.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading or deleting. Or problem with deleting collection caused by IOException or authorization.
      • deleteCommunityCommunity

        @DELETE
        @Path("/{community_id}/communities/{community_id2}")
        public javax.ws.rs.core.Response deleteCommunityCommunity​(@PathParam("community_id")
                                                                  String parentCommunityId,
                                                                  @PathParam("community_id2")
                                                                  String subcommunityId,
                                                                  @QueryParam("userIP")
                                                                  String user_ip,
                                                                  @QueryParam("userAgent")
                                                                  String user_agent,
                                                                  @QueryParam("xforwardedfor")
                                                                  String xforwardedfor,
                                                                  @Context
                                                                  javax.ws.rs.core.HttpHeaders headers,
                                                                  @Context
                                                                  javax.servlet.http.HttpServletRequest request)
                                                           throws javax.ws.rs.WebApplicationException
        Delete subcommunity in community.
        Parameters:
        parentCommunityId - Id of community in DSpace.
        subcommunityId - Id of community which will be deleted.
        user_ip - User's IP address.
        user_agent - User agent string (specifies browser used and its version).
        xforwardedfor - When accessed via a reverse proxy, the application sees the proxy's IP as the source of the request. The proxy may be configured to add the "X-Forwarded-For" HTTP header containing the original IP of the client so that the reverse-proxied application can get the client's IP.
        headers - If you want to access the community as the user logged into the context. The value of the "rest-dspace-token" header must be set to the token received from the login method response.
        request - Servlet's HTTP request object.
        Returns:
        Return response code OK(200) if was everything all right. Otherwise return NOT_FOUND(404) if was id of community or subcommunity incorrect. Or (UNAUTHORIZED)401 if was problem with permission to community or subcommunity.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading or deleting. Or problem with deleting subcommunity caused by IOException or authorization.