Class MetadataRegistryResource


  • @Path("/registries")
    public class MetadataRegistryResource
    extends Resource
    Class which provides read methods over the metadata registry.
    Author:
    Terry Brady, Georgetown University GET /registries/schema - Return the list of schemas in the registry GET /registries/schema/{schema_prefix} - Returns the specified schema GET /registries/schema/{schema_prefix}/metadata-fields/{element} - Returns the metadata field within a schema with an unqualified element name GET /registries/schema/{schema_prefix}/metadata-fields/{element}/{qualifier} - Returns the metadata field within a schema with a qualified element name POST /registries/schema/ - Add a schema to the schema registry POST /registries/schema/{schema_prefix}/metadata-fields - Add a metadata field to the specified schema GET /registries/metadata-fields/{field_id} - Return the specified metadata field PUT /registries/metadata-fields/{field_id} - Update the specified metadata field DELETE /registries/metadata-fields/{field_id} - Delete the specified metadata field from the metadata field registry DELETE /registries/schema/{schema_id} - Delete the specified schema from the schema registry Note: intentionally not providing since there is no date to update other than the namespace PUT /registries/schema/{schema_id}
    • Field Detail

      • authorizeService

        protected org.dspace.authorize.service.AuthorizeService authorizeService
      • metadataFieldService

        protected org.dspace.content.service.MetadataFieldService metadataFieldService
      • metadataSchemaService

        protected org.dspace.content.service.MetadataSchemaService metadataSchemaService
      • siteService

        protected org.dspace.content.service.SiteService siteService
    • Constructor Detail

      • MetadataRegistryResource

        public MetadataRegistryResource()
    • Method Detail

      • getSchemas

        @GET
        @Path("/schema")
        @Produces({"application/json","application/xml"})
        public MetadataSchema[] getSchemas​(@QueryParam("expand") @DefaultValue("fields")
                                           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
        Return all metadata registry items in DSpace.
        Parameters:
        expand - String in which is what you want to add to returned instance of metadata schema. Options are: "all", "fields". Default value "fields".
        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 metadata schema 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 metadata schemas.
        Throws:
        javax.ws.rs.WebApplicationException - It can be caused by creating context or while was problem with reading schema from database(SQLException).
      • getSchema

        @GET
        @Path("/schema/{schema_prefix}")
        @Produces({"application/json","application/xml"})
        public MetadataSchema getSchema​(@PathParam("schema_prefix")
                                        String schemaPrefix,
                                        @QueryParam("expand") @DefaultValue("fields")
                                        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 metadata schema with basic properties. If you want more, use expand parameter or method for metadata fields.
        Parameters:
        schemaPrefix - Prefix for schema in DSpace.
        expand - String in which is what you want to add to returned instance of metadata schema. Options are: "all", "fields". Default value "fields".
        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 metadata schema 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.MetadataSchema.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading. Also if id/prefix of schema is incorrect or logged user into context has no permission to read.
      • getMetadataFieldUnqualified

        @GET
        @Path("/schema/{schema_prefix}/metadata-fields/{element}")
        @Produces({"application/json","application/xml"})
        public MetadataField getMetadataFieldUnqualified​(@PathParam("schema_prefix")
                                                         String schemaPrefix,
                                                         @PathParam("element")
                                                         String element,
                                                         @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 metadata field with basic properties.
        Parameters:
        schemaPrefix - Prefix for schema in DSpace.
        element - Unqualified element name for field in the metadata registry.
        expand - String in which is what you want to add to returned instance of the metadata field. Options are: "all", "parentSchema". Default value "".
        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.MetadataField.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading. Also if id of field is incorrect or logged user into context has no permission to read.
      • getMetadataFieldQualified

        @GET
        @Path("/schema/{schema_prefix}/metadata-fields/{element}/{qualifier}")
        @Produces({"application/json","application/xml"})
        public MetadataField getMetadataFieldQualified​(@PathParam("schema_prefix")
                                                       String schemaPrefix,
                                                       @PathParam("element")
                                                       String element,
                                                       @PathParam("qualifier") @DefaultValue("")
                                                       String qualifier,
                                                       @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 metadata field with basic properties.
        Parameters:
        schemaPrefix - Prefix for schema in DSpace.
        element - Element name for field in the metadata registry.
        qualifier - Element name qualifier for field in the metadata registry.
        expand - String in which is what you want to add to returned instance of the metadata field. Options are: "all", "parentSchema". Default value "".
        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.MetadataField.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading. Also if id of field is incorrect or logged user into context has no permission to read.
      • getMetadataField

        @GET
        @Path("/metadata-fields/{field_id}")
        @Produces({"application/json","application/xml"})
        public MetadataField getMetadataField​(@PathParam("field_id")
                                              Integer fieldId,
                                              @QueryParam("expand") @DefaultValue("parentSchema")
                                              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 metadata field with basic properties.
        Parameters:
        fieldId - Id of metadata field in DSpace.
        expand - String in which is what you want to add to returned instance of the metadata field. Options are: "all", "parentSchema". Default value "parentSchema".
        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.MetadataField.
        Throws:
        javax.ws.rs.WebApplicationException - Thrown if there was a problem with creating context or problem with database reading. Also if id of field is incorrect or logged user into context has no permission to read.
      • createSchema

        @POST
        @Path("/schema")
        @Consumes({"application/json","application/xml"})
        public MetadataSchema createSchema​(MetadataSchema schema,
                                           @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 schema in the schema registry. Creating a schema is restricted to admin users.
        Parameters:
        schema - Schema that will be added to the metadata registry.
        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 schema 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. Returns the schema (schemaId), if was all ok.
        Throws:
        javax.ws.rs.WebApplicationException - It can be thrown by SQLException, AuthorizeException and ContextException.
      • createMetadataField

        @POST
        @Path("/schema/{schema_prefix}/metadata-fields")
        @Consumes({"application/json","application/xml"})
        public MetadataField createMetadataField​(@PathParam("schema_prefix")
                                                 String schemaPrefix,
                                                 MetadataField field,
                                                 @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 a new metadata field within a schema. Creating a metadata field is restricted to admin users.
        Parameters:
        schemaPrefix - Prefix for schema in DSpace.
        field - Field that will be added to the metadata registry for a schema.
        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 schema 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. Returns the field (with fieldId), if was all ok.
        Throws:
        javax.ws.rs.WebApplicationException - It can be thrown by SQLException, AuthorizeException and ContextException.
      • updateMetadataField

        @PUT
        @Path("/metadata-fields/{field_id}")
        @Consumes({"application/json","application/xml"})
        public javax.ws.rs.core.Response updateMetadataField​(@PathParam("field_id")
                                                             Integer fieldId,
                                                             MetadataField field,
                                                             @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 metadata field. Replace all information about community except the id and the containing schema.
        Parameters:
        fieldId - Id of the field in the DSpace metdata registry.
        field - Instance of the metadata field which will replace actual metadata field 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 metadata field 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 was id incorrect or 401 if logged user has no permission to update the metadata field.
        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.
      • deleteMetadataField

        @DELETE
        @Path("/metadata-fields/{field_id}")
        public javax.ws.rs.core.Response deleteMetadataField​(@PathParam("field_id")
                                                             Integer fieldId,
                                                             @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 metadata field from the DSpace metadata registry
        Parameters:
        fieldId - Id of the metadata field 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 metadata field 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 metadata field is incorrect. Or (UNAUTHORIZED)401 if was problem with permission to metadata field.
        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 metadata field caused by IOException or authorization.
      • deleteSchema

        @DELETE
        @Path("/schema/{schema_id}")
        public javax.ws.rs.core.Response deleteSchema​(@PathParam("schema_id")
                                                      Integer schemaId,
                                                      @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 metadata schema from the DSpace metadata registry
        Parameters:
        schemaId - Id of the metadata schema 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 metadata schema 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 metadata schema is incorrect. Or (UNAUTHORIZED)401 if was problem with permission to metadata schema.
        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 metadata schema caused by IOException or authorization.