Class SquashPluginResource

  • All Implemented Interfaces:
    Comparable<org.ligoj.bootstrap.core.plugin.FeaturePlugin>, org.ligoj.app.api.ServicePlugin, org.ligoj.app.api.ToolPlugin, org.ligoj.app.plugin.req.ReqServicePlugin, org.ligoj.bootstrap.core.plugin.FeaturePlugin

    @Path("/service/req/squash")
    @Service
    @Produces("application/json")
    public class SquashPluginResource
    extends org.ligoj.app.resource.plugin.AbstractToolPluginResource
    implements org.ligoj.app.plugin.req.ReqServicePlugin
    Squash TM resource.
    • Field Detail

      • KEY

        public static final String KEY
        Plug-in key.
      • PARAMETER_USER

        public static final String PARAMETER_USER
        Squash TM user name able to connect to instance.
      • PARAMETER_PASSWORD

        public static final String PARAMETER_PASSWORD
        Squash TM user password able to connect to instance.
      • PARAMETER_PROJECT

        public static final String PARAMETER_PROJECT
        Squash TM project's identifier, an integer
      • PARAMETER_URL

        public static final String PARAMETER_URL
        Web site URL
    • Constructor Detail

      • SquashPluginResource

        public SquashPluginResource()
    • Method Detail

      • link

        public void link​(int subscription)
                  throws IOException
        Specified by:
        link in interface org.ligoj.app.api.ServicePlugin
        Throws:
        IOException
      • validateProject

        protected SquashProject validateProject​(Map<String,​String> parameters)
                                         throws IOException
        Validate the project connectivity.
        Parameters:
        parameters - the project parameters.
        Returns:
        project details.
        Throws:
        IOException - When the Squash TM content cannot be parsed.
      • validateAdminAccess

        protected String validateAdminAccess​(Map<String,​String> parameters)
        Validate the basic REST connectivity to Squash.
        Parameters:
        parameters - the server parameters.
        Returns:
        the detected Squash version.
      • getResource

        protected String getResource​(Map<String,​String> parameters,
                                     String resource)
        Return a Squash's resource. Return null when the resource is not found.
        Parameters:
        parameters - The subscription parameters.
        resource - The requested resource URL
        Returns:
        The resource content.
      • getResource

        protected String getResource​(org.ligoj.bootstrap.core.curl.CurlProcessor processor,
                                     Map<String,​String> parameters,
                                     String url,
                                     String resource)
        Return a Squash's resource. Return null when the resource is not found.
        Parameters:
        processor - The CURL processor.
        parameters - The subscription parameters.
        url - The base URL.
        resource - The requested resource URL
        Returns:
        The resource content.
      • redirect

        @GET
        @Path("redirect/{subscription:\\d+}")
        public javax.ws.rs.core.Response redirect​(@PathParam("subscription")
                                                  int subscription)
                                           throws URISyntaxException
        Redirect to the home page of the linked project. Send a redirect code with the relevant cookies used by Squash TM since there is no way to force the link to a desired project.
        Parameters:
        subscription - The subscription identifier.
        Returns:
        The response redirection to go to the right project.
        Throws:
        URISyntaxException - When the Squash TM base URL is malformed.
      • getVersion

        public String getVersion​(Map<String,​String> parameters)
        Specified by:
        getVersion in interface org.ligoj.app.api.ToolPlugin
      • getProjects

        protected List<SquashProject> getProjects​(Map<String,​String> parameters)
                                           throws IOException
        Return all Squash TM projects without limit.
        Parameters:
        parameters - The subscription parameters.
        Returns:
        The resource content.
        Throws:
        IOException - When the Squash TM content cannot be parsed.
      • getProjectsDataTables

        protected List<SquashProject> getProjectsDataTables​(Map<String,​String> parameters,
                                                            String criteria)
                                                     throws IOException
        Return all Squash TM projects without limit and an optional criteria.
        Parameters:
        parameters - The subscription parameters.
        criteria - The criteria (plain text) for the lookup.
        Returns:
        The resource content.
        Throws:
        IOException - When the Squash TM content cannot be parsed.
      • getProject

        protected SquashProject getProject​(Map<String,​String> parameters,
                                           int id)
                                    throws IOException
        Return Squash project from its identifier.
        Parameters:
        parameters - The subscription parameters.
        id - The Squash TM project identifier.
        Returns:
        The resource content.
        Throws:
        IOException - When the Squash TM content cannot be parsed.
      • findAllByName

        @GET
        @Path("{node}/{criteria}")
        @Consumes("application/json")
        public List<SquashProject> findAllByName​(@PathParam("node")
                                                 String node,
                                                 @PathParam("criteria")
                                                 String criteria)
                                          throws IOException
        Search the Squash TM the projects matching to the given criteria. Name only is considered.
        Parameters:
        node - the node to be tested with given parameters.
        criteria - the search criteria.
        Returns:
        project names matching the criteria.
        Throws:
        IOException - When the Squash TM content cannot be parsed.
      • getKey

        public String getKey()
        Specified by:
        getKey in interface org.ligoj.bootstrap.core.plugin.FeaturePlugin
      • getLastVersion

        public String getLastVersion()
                              throws IOException
        Specified by:
        getLastVersion in interface org.ligoj.app.api.ToolPlugin
        Throws:
        IOException
      • checkSubscriptionStatus

        public org.ligoj.app.api.SubscriptionStatusWithData checkSubscriptionStatus​(Map<String,​String> parameters)
                                                                             throws IOException
        Specified by:
        checkSubscriptionStatus in interface org.ligoj.app.api.ToolPlugin
        Throws:
        IOException
      • checkStatus

        public boolean checkStatus​(Map<String,​String> parameters)
        Specified by:
        checkStatus in interface org.ligoj.app.api.ToolPlugin