Class PushService

  • All Implemented Interfaces:
    com.priint.pubserver.plugin.interfaces.PluginControl

    @Consumes({"application/json","application/xml"})
    @Produces({"application/json","application/xml"})
    @Path("/push")
    public class PushService
    extends AbstractService
    RESTful service interface for persist interface of PublishingHubDB connector.

    Data modifications methods use the following formats from PubServerSDK:
    Data input format is ConnectorPersistRemote.PushData,
    output format is ServiceResult.

    You may use either XML or JSON as serialization method.

    In case of errors a ServerResult object will be returned along with the HTTP status code (in most cases 500) containing exception details.

    Base URL by example:

    http://pubserver:40080/EntityDataService/push

    Authentication can either by BASIC_AUTH or by session id. User has to have a valid user account within publishing server.
    For session id use methods getLogin(String, String) and getLogout() together with cookie named 'PubServSessID' (see Constants.PUBSERVER_SESSSION_NAME).

    Since:
    4.0.5
    • Constructor Detail

      • PushService

        public PushService()
    • Method Detail

      • pushData

        @Path("/command")
        @POST
        public com.priint.pubserver.webservice.ServiceResult pushData​(@QueryParam("instance")
                                                                      java.lang.String instance,
                                                                      @QueryParam("source")
                                                                      java.lang.String source,
                                                                      @QueryParam("command")
                                                                      java.lang.String commandStr,
                                                                      @QueryParam("connector")
                                                                      java.lang.String connector,
                                                                      @QueryParam("flattenStructure")
                                                                      java.lang.String flattenStructureStr,
                                                                      com.priint.pubserver.plugin.interfaces.ConnectorPersistRemote.PushData data)
                                                               throws com.priint.pubserver.exception.PubServerException
        Generic push method on a persistable connector.

        URL by example

         POST /EntityDataService/push/command?instance=default&source=MegaMarket&command=INSERT
         
        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - Name of originator of the data. Currently not in use.
        commandStr - Specifies the request as either INSERT, UPDATE, or DELETE operation.
        connector - mappedName (defaults to PublishingHubDbConnector)
        flattenStructureStr - it is used to flatten the structure of the data
        data - Data to be processed. Will try to process all entitydata objects referenced by identifier as specified by the command parameter.
        Returns:
        Returns a ServiceResult object.
        Throws:
        com.priint.pubserver.exception.PubServerException - If anything fails HTTP error 500 will be send. Exception data will be returned to the client in a ServiceException.
      • pushData2

        @Path("command2")
        @POST
        public com.priint.pubserver.webservice.ServiceResult pushData2​(@QueryParam("instance")
                                                                       java.lang.String instance,
                                                                       @QueryParam("source")
                                                                       java.lang.String source,
                                                                       @QueryParam("connector")
                                                                       java.lang.String connector,
                                                                       com.priint.pubserver.plugin.interfaces.ConnectorPersistRemote.PushData data)
                                                                throws com.priint.pubserver.exception.PubServerException
        Generic push method on a persistable connector for deployment package purpose. It does not have command query parameter, it takes it from a data object (PushData).

        URL by example

         POST /EntityDataService/push/command?instance=default&source=MegaMarket&command=INSERT
         
        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - Name of originator of the data. Currently not in use.
        connector - mappedName (defaults to PublishingHubDbConnector)
        data - Data to be processed. Will try to process all entitydata objects referenced by identifier as specified by the command parameter.
        Returns:
        Returns a ServiceResult object.
        Throws:
        ServiceException - If anything fails HTTP error 500 will be send. Exception data will be returned to the client in a ServiceException.
        com.priint.pubserver.exception.PubServerException
      • pushSelect

        @Path("/data")
        @GET
        public com.priint.pubserver.webservice.ServiceResult pushSelect()
                                                                 throws com.priint.pubserver.exception.PubServerException
        Reads data from the connector's data source.
        Currently not supported.

        URL by example

        GET /EntityDataService/push/data
         
        Returns:
        Returns a ServiceResult object. If case of success ServiceResult.isSuccess() attribute will be set to true. In case of failure ServiceResult.isSuccess() attribute will be set to false and ServiceResult.getStatus() and ServiceResult.getValue() attributes will contain information about the exception.
        Throws:
        com.priint.pubserver.exception.PubServerException - Thrown if anything fails.
      • pushInsert

        @Path("/data")
        @POST
        public com.priint.pubserver.webservice.ServiceResult pushInsert​(@QueryParam("instance")
                                                                        java.lang.String instance,
                                                                        @QueryParam("source")
                                                                        java.lang.String source,
                                                                        @QueryParam("connector")
                                                                        java.lang.String connector,
                                                                        com.priint.pubserver.plugin.interfaces.ConnectorPersistRemote.PushData data)
                                                                 throws com.priint.pubserver.exception.PubServerException
        Will create (insert/persist) all entitydata from the data input that are not already existing in the connector data source.

        URL by example

        POST /EntityDataService/push/data?instance=default&source=MegaMarket
         

        Request body is a push data object serialized as XML or JSON.

        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - Name of originator of the data. Currently not in use.
        connector - mappedName (defaults to PublishingHubDbConnector)
        data - Data to be processed. Will try to create all entitydata objects referenced by identifier.
        Returns:
        Returns a ServiceResult object.
        Throws:
        com.priint.pubserver.exception.PubServerException - If anything fails HTTP error 500 will be send. Exception data will be returned to the client in a PubServerException.
      • pushUpdate

        @Path("/data")
        @PUT
        public com.priint.pubserver.webservice.ServiceResult pushUpdate​(@QueryParam("instance")
                                                                        java.lang.String instance,
                                                                        @QueryParam("source")
                                                                        java.lang.String source,
                                                                        @QueryParam("connector")
                                                                        java.lang.String connector,
                                                                        com.priint.pubserver.plugin.interfaces.ConnectorPersistRemote.PushData data)
                                                                 throws com.priint.pubserver.exception.PubServerException
        Will update (merge) all entitydata from the data input that are already existing in the connector data source.

        URL by example

        PUT /EntityDataService/push/data?instance=default&source=MegaMarket
         

        Request body is a push data object serialized as XML or JSON.

        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - Name of originator of the data. Currently not in use.
        connector - mappedName (defaults to PublishingHubDbConnector)
        data - Data to be processed. Will try to update all entitydata objects referenced by identifier.
        Returns:
        Returns a ServiceResult object.
        Throws:
        com.priint.pubserver.exception.PubServerException - If anything fails HTTP error 500 will be send. Exception data will be returned to the client in a PubServerException.
      • pushDelete

        @Path("/data")
        @DELETE
        public com.priint.pubserver.webservice.ServiceResult pushDelete​(@QueryParam("instance")
                                                                        java.lang.String instance,
                                                                        @QueryParam("source")
                                                                        java.lang.String source,
                                                                        @QueryParam("connector")
                                                                        java.lang.String connector,
                                                                        com.priint.pubserver.plugin.interfaces.ConnectorPersistRemote.PushData data)
                                                                 throws com.priint.pubserver.exception.PubServerException
        Deletes data from the connector's data source.

        URL by example

        DELETE /EntityDataService/push/data?instance=default&source=MegaMarket
         

        Request body is a push data object serialized as XML or JSON. Serialized form can be sparse - only identifier attributes of buckets, texts, etc must be specified.

        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - Name of originator of the data. Currently not in use.
        connector - mappedName (defaults to PublishingHubDbConnector)
        data - Data to be processed. Will try to delete all entitydata objects referenced by identifier.
        Returns:
        deleted data
        Throws:
        com.priint.pubserver.exception.PubServerException - when anything fails
      • getProposedEntities

        @Path("/model")
        @GET
        public java.lang.Object getProposedEntities​(@QueryParam("source")
                                                    java.lang.String source,
                                                    @QueryParam("instance")
                                                    java.lang.String instance)
                                             throws com.priint.pubserver.exception.PubServerException
        Get a list of proposed entities from the connector.
        GET /EntityDataService/push/model
        Sample output:

        <proposedEntities>
        <proposedEntity>
        <entityType>Bucket</entityType>
        <entityId>product</entityId>
        <parentBucketEntityId>category</parentBucketEntityId>
        <targetEntityId></targetEntityId>
        <contentEntityId></contentEntityId>
        <entityClass>com.priint.pubserver.entity.EntityBucket</entityClass>
        </proposedEntity>
        <proposedEntity>
        <entityType>Cord</entityType>
        <entityId>accessory</entityId>
        <parentBucketEntityId>product</parentBucketEntityId>
        <targetEntityId>product</targetEntityId>
        <contentEntityId>accessory-content</contentEntityId>
        <entityClass>com.priint.pubserver.entity.EntityCord</entityClass>
        </proposedEntity>
        </proposedEntities>

        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        source - String identifying the origin of the data.
        Returns:
        Returns a ProposedEntities object.
        Throws:
        com.priint.pubserver.exception.PubServerException - when anything fails
      • getLogin

        @GET
        @Path("/login")
        @Deprecated
        public javax.ws.rs.core.Response getLogin​(@DefaultValue("") @QueryParam("user")
                                                  java.lang.String user,
                                                  @DefaultValue("") @QueryParam("password")
                                                  java.lang.String password)
                                           throws com.priint.pubserver.exception.PubServerException
        Deprecated.
        Please use BASIC_AUTH or TOKEN_AUTH authentication until 4.1.6
        Login a user by form post

        returns 401 if user is already logged in

        URL by example

        GET /EntityDataService/push/login?user=john&password=*****
         
        Parameters:
        user - login name
        password - plain text secret
        Returns:
        SessionID wrapped as value within a ServiceResult object
        Throws:
        com.priint.pubserver.exception.PubServerException - when anything fails
      • getLogout

        @GET
        @Path("/logout")
        @Deprecated
        public javax.ws.rs.core.Response getLogout()
        Deprecated.
        Please use BASIC_AUTH or TOKEN_AUTH authentication until 4.1.6
        Logout the currently active user by form post

        returns HTTP 401 if user is not logged in

        URL by example

        GET /EntityDataService/push/logout
         
        Returns:
        sessionid (now invalidated)
      • postClearCaches

        @Path("/clear-caches")
        @POST
        public com.priint.pubserver.webservice.ServiceResult postClearCaches​(@QueryParam("instance")
                                                                             java.lang.String instance)
                                                                      throws com.priint.pubserver.exception.PubServerException
        Clear caches of the connector

        URL by example

        POST /EntityDataService/push/clear-caches?instance=default
         
        Parameters:
        instance - Name of the connector instance. Different instances are typically associated with different data sources.
        Returns:
        Returns a ServiceResult object.
        Throws:
        com.priint.pubserver.exception.PubServerException - when anything fails