The Rigi API provides functionalities to create a project based on another project. This may be handy if you need to create Rigi projects on a regular basis, that all have more or less the same settings as an existing project. The only difference is the files that are specified in the workspace. This article demonstrates how to use the API in that case.

This description may be useful if you want to build a Rigi connector for
- e-commerce systems (ECS), or
- product information management systems (PIM), or
- content management systems (CMS).
This article describes the scenario to clone the project from a project named TEMPLATE, give it a PROJECT_NAME, upload a new set of source files, and approve the workspace and string list.
- Make sure that no project with the name PROJECT_NAME already exists.
- Clone a project. This clones a complete project, including files, parser settings, users, etc.
- Upload the new set of files to the workspace.
- Approve the workspace
- Sync the string list.
Each step is described in the following sections.
API: Project name exists
This returns an object with Boolean exists.
API: Clone
After you initiated the clone of a project, you need to wait until the completion.

Keep it small!
- If the source project is a template, ensure that the size is as limited as possible.
- To copy parser settings, the source project needs to have at least one file with the required parser settings,
Use a small file in the source project with for example only one source string.
This will initiate a full clone of the project.
Wait until the clone is ready
The actions-endpoint provides insight in the status of a project.
GET api/projects/actions?name=PROJECT_NAME
It returns the an object with the project id, project name and status details regarding operations.
- {
- "projectId": "12345",
- "name": "PROJECT_NAME",
- "details": {
- "projectCloneStatus": "1",
- "workspaceFilesStatus": "1",
- "workspaceApproveStatus": "1",
- "workspaceMergeStatus": "1"
- }
- }
The status values can be:
- "0" : the operation is still in-progress.
- "1" : the operation is ready.
- "2" : there is an error.
Cloning a smaller project may take 10 seconds or so. Poll the projectCloneStatus each second and wait until the operation is ready.
- while (true)
- {
- wait 1 second
- get project status
- if (projectCloneStatus == "1")
- return READY
- else if (projectCloneStatus == "2")
- return ERROR
- }
API: Upload the new set of files to the workspace
Pseudo code:
- Create the manifest file based on files to be uploaded
- Create the ZIP to be uploaded with manifest and files
- //workspaceFilesStatus == ready ("1")
- Prepare upload. Set workspaceFilesStatus to in-progress ("0")
- Upload the ZIP
- //Server waits for the ZIP, and updates the workspace.
- Wait until upload completed (e.g. workspaceFilesStatus == ready ("1"))
Create manifest file
The manifest file (manifest.json) is located in the root of the ZIP file that will be uploaded. The manifest contains the following fields:
Field | Required | Description |
filepath | Required | Relative file path in the ZIP file. Examle: abc\def\myfile.json |
parserId | Required | Parser id. You can find it in the parser settings of your source project. Example: json.  |
targetRule | Optional | Name of the target rule that shall be applied for this file. If no target rule is specified, the rule will be used that is assigned to the first file with this extension in the template project. |
fileId | Optional | File identifier that will assigned to this file.
- If no file id is specified, and the template project contains a file with the same name, then that id is used.
- If no file id is specified, and the template project does not contain a file with the same name, then the system will auto-create a file-id.
|
Create the zip
Create the zip file that contains the manifest and the files. For example:
In this example, the manifest file is:
- [
- { "filepath": "en-CA.json", "parserId": "json", "targetRule": null, "fileId": null },
- { "filepath": "hello.json", "parserId": "json", "targetRule": null, "fileId": null },
- { "filepath": "nl-NL.json", "parserId": "json", "targetRule": null, "fileId": null }
- ]
Prepare the upload
Similar like we had to wait until cloning the workspace was completed, we also must wait until all files are processed. There is some time between uploading the ZIP and when the server starts processing that file. To be able to detect when the server has processed the ZIP, we need to mark the workspaceFilesStatus as in-progress ("0") ourselves.
Upload
This operation uploads the ZIP to the workspace. The Rigi server will add the files that are defined in the workspace to the project.
Wait until upload completed
The upload operation may take a while.
- while (true)
- {
- wait 1 second
- get project status
- if (workspaceFilesStatus == "1")
- return READY
- else if (workspaceFilesStatus == "2")
- return ERROR
- }
Approve the workspace
Pseudo code:
- Approve the workspace
- Wait until approval completed (e.g. workspaceApproveStatus== ready ("1"))
API: Approve the workspace
Wait until approved
- while (true)
- {
- wait 1 second
- get project status
- if (workspaceApproveStatus== "1")
- return READY
- else if (workspaceFilesStatus == "2")
- return ERROR
- }
API: Sync the string list
This will update the string list with the files that were uploaded and assigned to the project.
- Sync the string list
- Wait until sync completed (e.g. workspaceMergeStatus== ready ("1"))
Sync
Wait until synced
- while (true)
- {
- wait 1 second
- get project status
- if (workspaceMergeStatus== "1")
- return READY
- else if (workspaceMergeStatus== "2")
- return ERROR
- }