Class CreateAndLinkResourceController

  • All Implemented Interfaces:
    edu.cornell.mannlib.vitro.webapp.controller.MultipartRequestWrapper.ParsingStrategy, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

    @WebServlet(name="CreateAndLinkResource",
                urlPatterns="/createAndLink/*")
    public class CreateAndLinkResourceController
    extends edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet
    Main controller class for claiming (creating and/or linking) resources to a profile
    See Also:
    Serialized Form
    • Constructor Detail

      • CreateAndLinkResourceController

        public CreateAndLinkResourceController()
    • Method Detail

      • init

        public void init​(javax.servlet.ServletConfig config)
                  throws javax.servlet.ServletException
        Specified by:
        init in interface javax.servlet.Servlet
        Overrides:
        init in class javax.servlet.GenericServlet
        Throws:
        javax.servlet.ServletException
      • getEnabledProviders

        public static Set<String> getEnabledProviders​(edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties props)
      • registerProviders

        public static void registerProviders​(edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties props)
      • requiredActions

        protected edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest requiredActions​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq)
        Ensure that we can only be called if the user has the correct permissions
        Overrides:
        requiredActions in class edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet
        Parameters:
        vreq -
        Returns:
      • processRequest

        protected edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues processRequest​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq)
        Main method for the resource claiming (create and link) workflow
        Overrides:
        processRequest in class edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet
        Parameters:
        vreq -
        Returns:
      • proposeAuthorToLink

        protected void proposeAuthorToLink​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                           Citation citation,
                                           String profileUri)
        Method to find an author to propose for linking
        Parameters:
        vreq -
        citation -
        profileUri -
      • getExistingResource

        protected org.apache.jena.rdf.model.Model getExistingResource​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                                                      String uri)
        Find an existing resource in VIVO, and return a Model with the appropriate statements
        Parameters:
        vreq -
        uri -
        Returns:
      • processRelationships

        protected void processRelationships​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                            org.apache.jena.rdf.model.Model model,
                                            String vivoUri,
                                            String userUri,
                                            String relationship)
        Adjust the in-memory model to create the appropriate relationships for the claimed user role (authorship, editorship, etc)
        Parameters:
        vreq -
        model -
        vivoUri -
        userUri -
        relationship -
      • removeAuthorship

        protected void removeAuthorship​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                        org.apache.jena.rdf.model.Model model,
                                        String vivoUri,
                                        int rank)
        Removes an existing authorship at a given position, when that position is claimed by the author
        Parameters:
        model -
        rank -
      • removeVCard

        protected void removeVCard​(org.apache.jena.rdf.model.Model model,
                                   String vcardUri)
        Attempt to remove a VCARD from VIVO, ensuring that it is not being used first
        Parameters:
        model -
        vcardUri -
      • createVIVOObject

        protected String createVIVOObject​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                          org.apache.jena.rdf.model.Model model,
                                          ResourceModel resourceModel,
                                          String typeUri)
        Create a new resource in VIVO, based on the values of the intermediate model
        Parameters:
        vreq -
        model -
        resourceModel -
        Returns:
      • getPublisherURI

        protected String getPublisherURI​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                         String publisher)
        Get a URI for the publisher object
        Parameters:
        vreq -
        publisher -
        Returns:
      • getVCardURI

        protected String getVCardURI​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                     String familyName,
                                     String givenName)
        Get a URI for a VCARD object
        Parameters:
        vreq -
        familyName -
        givenName -
        Returns:
      • addDateToResource

        protected boolean addDateToResource​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                            org.apache.jena.rdf.model.Resource work,
                                            ResourceModel.DateField date)
        Add a date object to the resource
        Parameters:
        vreq -
        work -
        date -
        Returns:
      • findInVIVO

        protected String findInVIVO​(edu.cornell.mannlib.vitro.webapp.controller.VitroRequest vreq,
                                    ExternalIdentifiers ids,
                                    String profileUri,
                                    Citation citation)
        Try to find a resource in VIVO that defines one of the external identifiers
        Parameters:
        vreq -
        ids -
        profileUri -
        citation -
        Returns:
      • isResourceOfType

        protected boolean isResourceOfType​(org.apache.jena.rdf.model.Resource resource,
                                           String typeUri)
        Check that the resource is declared to be of a particular type
        Parameters:
        resource -
        typeUri -
        Returns:
      • writeChanges

        protected void writeChanges​(edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService rdfService,
                                    org.apache.jena.rdf.model.Model existingModel,
                                    org.apache.jena.rdf.model.Model updatedModel)
        Determine the difference between the "existing" and "updated" models, and write the changes to VIVO
        Parameters:
        rdfService -
        existingModel -
        updatedModel -