Class ContactRestController

  • All Implemented Interfaces:
    ContactRestOpenApi

    @RestController
    @RequestMapping("/v2.1.1/contact-manager/")
    public class ContactRestController
    extends Object
    implements ContactRestOpenApi
    The definition of the Contact Rest Controller.
    Author:
    Mauricio Ruiz Beltrán <mauricio.ruiz@kuwaiba.org>
    • Constructor Detail

      • ContactRestController

        public ContactRestController()
    • Method Detail

      • createContact

        @RequestMapping(method=POST,
                        value="createContact/{contactClassName}/{customerClassName}/{customerId}/{userName}/{sessionId}",
                        produces="application/json")
        public String createContact​(@PathVariable("contactClassName")
                                    String contactClassName,
                                    @PathVariable("customerClassName")
                                    String customerClassName,
                                    @PathVariable("customerId")
                                    String customerId,
                                    @PathVariable("userName")
                                    String userName,
                                    @PathVariable("sessionId")
                                    String sessionId)
        Creates a contact. Contacts are always associated to a customer.
        Specified by:
        createContact in interface ContactRestOpenApi
        Parameters:
        contactClassName - Class of the contact. This class should always be a subclass of GenericContact.
        customerClassName - The class of the customer this contact will be associated to.
        customerId - The id of the customer this contact will be associated to.
        userName - The user name of the session.
        sessionId - The session token id.
        Returns:
        The id of the newly created contact.
      • updateContact

        @RequestMapping(method=PUT,
                        value="updateContact/{contactClassName}/{contactId}/{userName}/{sessionId}",
                        produces="application/json")
        public void updateContact​(@PathVariable("contactClassName")
                                  String contactClassName,
                                  @PathVariable("contactId")
                                  String contactId,
                                  @RequestBody
                                  List<StringPair> properties,
                                  @PathVariable("userName")
                                  String userName,
                                  @PathVariable("sessionId")
                                  String sessionId)
        Updates a contact's information.
        Specified by:
        updateContact in interface ContactRestOpenApi
        Parameters:
        contactClassName - The class of the contact.
        contactId - The id of the contact.
        properties - The attributes to be updated. The list types require only the id of the linked list type as a string.
        userName - The user name of the session.
        sessionId - The session token id.
      • deleteContact

        @RequestMapping(method=DELETE,
                        value="deleteContact/{contactClassName}/{contactId}/{userName}/{sessionId}",
                        produces="application/json")
        public void deleteContact​(@PathVariable("contactClassName")
                                  String contactClassName,
                                  @PathVariable("contactId")
                                  String contactId,
                                  @PathVariable("userName")
                                  String userName,
                                  @PathVariable("sessionId")
                                  String sessionId)
        Deletes a contact.
        Specified by:
        deleteContact in interface ContactRestOpenApi
        Parameters:
        contactClassName - The class of the contact.
        contactId - The id of the contact.
        userName - The user name of the session.
        sessionId - The session token id.
      • getContact

        @RequestMapping(method=GET,
                        value="getContact/{contactClassName}/{contactId}/{sessionId}",
                        produces="application/json")
        public Contact getContact​(@PathVariable("contactClassName")
                                  String contactClassName,
                                  @PathVariable("contactId")
                                  String contactId,
                                  @PathVariable("sessionId")
                                  String sessionId)
        Gets the entire information of a given contact.
        Specified by:
        getContact in interface ContactRestOpenApi
        Parameters:
        contactClassName - The class of the contact.
        contactId - The id of the contact
        sessionId - The session token id.
        Returns:
        The contact.
      • getContactsForCustomer

        @RequestMapping(method=GET,
                        value="getContactsForCustomer/{customerClassName}/{customerId}/{sessionId}",
                        produces="application/json")
        public List<Contact> getContactsForCustomer​(@PathVariable("customerClassName")
                                                    String customerClassName,
                                                    @PathVariable("customerId")
                                                    String customerId,
                                                    @PathVariable("sessionId")
                                                    String sessionId)
        Retrieves the list of contacts associated to a customer.
        Specified by:
        getContactsForCustomer in interface ContactRestOpenApi
        Parameters:
        customerClassName - The class of the customer the contacts belong to.
        customerId - The id of the customer the contacts belong to.
        sessionId - The session token id.
        Returns:
        The list of contacts.
      • searchForContacts

        @RequestMapping(method=GET,
                        value="searchForContacts/{searchString}/{maxResults}/{sessionId}",
                        produces="application/json")
        public List<Contact> searchForContacts​(@PathVariable("searchString")
                                               String searchString,
                                               @PathVariable("maxResults")
                                               int maxResults,
                                               @PathVariable("sessionId")
                                               String sessionId)
        Searches in all the properties of a contact for a given string.
        Specified by:
        searchForContacts in interface ContactRestOpenApi
        Parameters:
        searchString - The string to be matched.
        maxResults - The max number of results. Use -1 to retrieve al results.
        sessionId - The session token id.
        Returns:
        The list of contacts that matches the search criteria.
      • getContacts

        @RequestMapping(method=POST,
                        value="getContacts/{page}/{limit}/{sessionId}",
                        produces="application/json")
        public List<Contact> getContacts​(@PathVariable("page")
                                         int page,
                                         @PathVariable("limit")
                                         int limit,
                                         @RequestBody(required=false)
                                         HashMap<String,​Object> filters,
                                         @PathVariable("sessionId")
                                         String sessionId)
        Retrieves the list of contacts that matches the search criteria.
        Specified by:
        getContacts in interface ContactRestOpenApi
        Parameters:
        page - Current page.
        limit - Limit of results per page. -1 to retrieve them all.
        filters - The response may be filtered by customer (use key customer, value the customer name, a String) by type (use key type, value the type name, a String) by contact name (use key contact_name, value the contact name, a String) by contact email1 (use key contact_email1, value the contact email1, a String) by contact email2 (use key contact_email2, value the contact email2, a String)
        sessionId - The session token id.
        Returns:
        The list of contacts that matches the search criteria.
      • relateObjectToContact

        @RequestMapping(method=PUT,
                        value="relateObjectToContact/{objectClassName}/{objectId}/{contactClassName}/{contactId}/{userName}/{sessionId}",
                        produces="application/json")
        public void relateObjectToContact​(@PathVariable("objectClassName")
                                          String objectClassName,
                                          @PathVariable("objectId")
                                          String objectId,
                                          @PathVariable("contactClassName")
                                          String contactClassName,
                                          @PathVariable("contactId")
                                          String contactId,
                                          @PathVariable("userName")
                                          String userName,
                                          @PathVariable("sessionId")
                                          String sessionId)
        Relates an inventory object to a contact.
        Specified by:
        relateObjectToContact in interface ContactRestOpenApi
        Parameters:
        objectClassName - The class of the object.
        objectId - The id of the object.
        contactClassName - The class of the contact.
        contactId - The id of the contact.
        userName - The user name of the session.
        sessionId - The session token id.
      • releaseObjectFromContact

        @RequestMapping(method=PUT,
                        value="releaseObjectFromContact/{objectClassName}/{objectId}/{contactClassName}/{contactId}/{userName}/{sessionId}",
                        produces="application/json")
        public void releaseObjectFromContact​(@PathVariable("objectClassName")
                                             String objectClassName,
                                             @PathVariable("objectId")
                                             String objectId,
                                             @PathVariable("contactClassName")
                                             String contactClassName,
                                             @PathVariable("contactId")
                                             String contactId,
                                             @PathVariable("userName")
                                             String userName,
                                             @PathVariable("sessionId")
                                             String sessionId)
        Releases an inventory object from a contact.
        Specified by:
        releaseObjectFromContact in interface ContactRestOpenApi
        Parameters:
        objectClassName - The class of the object.
        objectId - The id of the object.
        contactClassName - The class of the contact.
        contactId - The id of the contact.
        userName - The user name of the session.
        sessionId - The session token id.
      • getContactResources

        @RequestMapping(method=GET,
                        value="getContactResources/{contactClassName}/{contactId}/{sessionId}",
                        produces="application/json")
        public List<BusinessObjectLight> getContactResources​(@PathVariable("contactClassName")
                                                             String contactClassName,
                                                             @PathVariable("contactId")
                                                             String contactId,
                                                             @PathVariable("sessionId")
                                                             String sessionId)
        Retrieves the list of resources (inventory objects) related to a contact.
        Specified by:
        getContactResources in interface ContactRestOpenApi
        Parameters:
        contactClassName - The class of the contact.
        contactId - The id of the contact.
        sessionId - The session token id.
        Returns:
        List of related resources.