Batch to synchronize a local database from a remote instance of Mantis Bug Tracker with Soap call
1.0K
Batch to synchronize a local database from a remote instance of Mantis Bug Tracker with Soap calls. This batch is aimed to retrieve informations from a distant Mantis Bug Tracker when the database is not directly accessible. This informations are inserted in a local database and so can be used for further usages (calculating indicators, sync with another bug tracker...).
The batch is compatible with MantisBT 1.2.19 and higher (successfully tested with 1.2.19 and 1.3.0-rc.1).
It also supports authentication through an intranet portal before accessing the MantisBT instance.
Database :
Installation in production : see Docker image
For development :
If authentication through an intranet portal is needed :
In development, in-memory database (HSQLDB) is used.
Properties used in this project are :
Jobs launching and monitoring are performed through REST calls thank to Codecentric's spring-boot-starter-batch-web.
http://{host}:{port}/batch/operations/jobs/{jobName} / POST
Optionally you may define job parameters via request param 'jobParameters'. If a JobParametersIncrementer is specified in the job, it is used to increment the parameters. On success, it returns the JobExecution's id as a plain string. On failure, it returns the message of the Exception as a plain string. There are different failure possibilities :
http://{host}:{port}/batch/operations/jobs/executions/{executionId} / GET
On success, it returns the ExitCode of the JobExecution specified by the executionId as a plain string. On failure, it returns the message of the Exception as a plain string. There are different failure possibilities:
http://{host}:{port}/batch/operations/jobs/executions/{executionId}/log / GET
On success, it returns the log file belonging to the run of the JobExecution specified by the executionId as a plain string. On failure, it returns the message of the Exception as a plain string. There are different failure possibilities:
http://{host}:{port}/batch/operations/jobs/executions/{executionId} / DELETE
On success, it returns true. On failure, it returns the message of the Exception as a plain string. There are different failure possibilities:
http://{host}:{port}/batch/monitoring/jobs / GET
On success, it returns a JSON array of String containing the names of the deployed jobs.
http://{host}:{port}/batch/monitoring/jobs/runningexecutions / GET
On success, it returns a JSON array containing the ids of the JobExecutions running on this server.
http://{host}:{port}/batch/monitoring/jobs/runningexecutions/{jobName} / GET
On success, it returns a JSON array containing the ids of the JobExecutions running on this server belonging to the specified job.
http://{host}:{port}/batch/monitoring/jobs/executions/{executionId} / GET
On success, it returns a JSON representation of the JobExecution specified by the id. This representation contains everything you need to know about that job, from job name and BatchStatus to the number of processed items and time used and so on. If the JobExecution cannot be found, a HTTP response code 404 is returned.
Enumerations are system values used to define status, priorities, severities... This sync should be launch at least once at first use. Job parameters (all mandatory) are :
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/syncEnumsJob' --data "jobParameters=mantis.username=foo,mantis.password=foopasswd"; echo
Note : Don't worry if the job fails because of access denied by MantisBT server. In fact, this sync isn't mandatory because the issues sync jobs will insert those values if needed
This job will sync all data related to projects :
Note that syncing a project will also sync its sub-projects. Job parameters (all mandatory) are :
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/syncProjectsJob' --data "jobParameters=mantis.username=foo,mantis.password=foopasswd,mantis.project_id=1"; echo
Several jobs are available for syncing issues :
For initial import, the fileSyncIssuesJob job should be used. This job reads a list of issues ids from a CSV file and retrieves all data related to those issues. The CSV file must not have a header line for columns definition. It can be exported from MantisBT web UI.
Job parameters (all mandatory) are :
Note : the file is loaded through Spring resource loader so the file path can contains definitions like classpath: and others.
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/fileSyncIssuesJob' --data "jobParameters=mantis.username=foo,mantis.password=foopasswd,mantis.filepath=file:/path/to/file/filename.csv"; echo
For periodic sync (for instance via a cron job), the syncIssuesJob job should be used. This job will update all modified issues which are still marked as open is MantisBT or in the local DB. The update is perform in differential mode since last successful execution of this job for the given project. Note : all issues related to a subproject are updated to.
Job parameters (all mandatory) are :
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/syncIssuesJob' --data "jobParameters=mantis.username=foo,mantis.password=foopasswd,mantis.project_id=1"; echo
If needed, a forced sync mode is available through forceSyncIssuesJob job. This job will update all issues for which the id is passed as job parameter, even if the issue is closed in MantisBT.
Job parameters (all mandatory) are :
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/forceSyncIssuesJob' --data "jobParameters=mantis.username=foo,mantis.password=foopasswd,mantis.issues_id=1;2"; echo
A job to compute the number of issues in a project by handler at a given time is available through handlersStatJob job. It will add a line in the handler_stat table with :
Note : if a user doesn't handle any issue, no line will be inserted.
Job parameters (all mandatory) are :
To launch the job with curl :
curl --silent -X POST 'http://localhost:8080/batch/operations/jobs/handlersStatJob' --data "jobParameters=mantis.computeDate=2016-11-06T23:27:11"; echo
Content type
Image
Digest
Size
80.7 MB
Last updated
over 9 years ago
docker pull jrrdev/mantisbt-sync-core