Package org.ligoj.app.plugin.req.squash
Class SquashPluginResource
- java.lang.Object
-
- org.ligoj.app.resource.plugin.AbstractToolPluginResource
-
- org.ligoj.app.plugin.req.squash.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.ReqServicePluginSquash TM resource.
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEYPlug-in key.static StringPARAMETER_PASSWORDSquash TM user password able to connect to instance.static StringPARAMETER_PROJECTSquash TM project's identifier, an integerstatic StringPARAMETER_URLWeb site URLstatic StringPARAMETER_USERSquash TM user name able to connect to instance.static StringURLPlug-in key.
-
Constructor Summary
Constructors Constructor Description SquashPluginResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckStatus(Map<String,String> parameters)org.ligoj.app.api.SubscriptionStatusWithDatacheckSubscriptionStatus(Map<String,String> parameters)List<SquashProject>findAllByName(String node, String criteria)Search the Squash TM the projects matching to the given criteria.StringgetKey()StringgetLastVersion()protected SquashProjectgetProject(Map<String,String> parameters, int id)Return Squash project from its identifier.protected List<SquashProject>getProjects(Map<String,String> parameters)Return all Squash TM projects without limit.protected List<SquashProject>getProjectsDataTables(Map<String,String> parameters, String criteria)Return all Squash TM projects without limit and an optional criteria.protected StringgetResource(Map<String,String> parameters, String resource)Return a Squash's resource.protected StringgetResource(org.ligoj.bootstrap.core.curl.CurlProcessor processor, Map<String,String> parameters, String url, String resource)Return a Squash's resource.StringgetVersion(Map<String,String> parameters)voidlink(int subscription)javax.ws.rs.core.Responseredirect(int subscription)Redirect to the home page of the linked project.protected StringvalidateAdminAccess(Map<String,String> parameters)Validate the basic REST connectivity to Squash.protected SquashProjectvalidateProject(Map<String,String> parameters)Validate the project connectivity.-
Methods inherited from class org.ligoj.app.resource.plugin.AbstractToolPluginResource
create, download, getInstalledEntities, getVersion
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
URL
public static final String URL
Plug-in key.- See Also:
- Constant Field Values
-
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
-
-
Method Detail
-
link
public void link(int subscription) throws IOException- Specified by:
linkin interfaceorg.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. Returnnullwhen 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. Returnnullwhen 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 URISyntaxExceptionRedirect 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:
getVersionin interfaceorg.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 IOExceptionSearch 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:
getKeyin interfaceorg.ligoj.bootstrap.core.plugin.FeaturePlugin
-
getLastVersion
public String getLastVersion() throws IOException
- Specified by:
getLastVersionin interfaceorg.ligoj.app.api.ToolPlugin- Throws:
IOException
-
checkSubscriptionStatus
public org.ligoj.app.api.SubscriptionStatusWithData checkSubscriptionStatus(Map<String,String> parameters) throws IOException
- Specified by:
checkSubscriptionStatusin interfaceorg.ligoj.app.api.ToolPlugin- Throws:
IOException
-
-