### Clone the OperatorFabric getting started repository Source: https://opfab.github.io/documentation/current/getting_started Clones the OperatorFabric getting started repository, which contains the server and example client scripts. ```bash git clone https://github.com/opfab/operatorfabric-getting-started.git ``` -------------------------------- ### GET user settings response example Source: https://opfab.github.io/documentation/current/api Example response body for retrieving a user's settings, showing the login and locale fields. ```json { "login": "jcleese", "locale": "en" } ``` -------------------------------- ### Start opfab dev environment and Angular server Source: https://opfab.github.io/documentation/current/dev_env Steps to start opfab in dev mode and launch an Angular server. Set environment variables, start opfab, then run ng serve. Test changes at localhost:4200 which leads to localhost:4200/#/feed. ```bash source ${OF_HOME}/bin/load_environment_light.sh ``` ```bash ${OF_HOME}/bin/startOpfab.sh ``` ```bash ng serve ``` -------------------------------- ### CLI environment configuration example Source: https://opfab.github.io/documentation/current/deployment/index.html Example lines for the CLI config file, each line defining an environment configuration with name, URL, port, and optional credentials. ```text dev DEV LOCALHOST_URL 2002 admin test prod PROD PROD_URL 80 ``` -------------------------------- ### Configure perimeter for Example 1 Source: https://opfab.github.io/documentation/current/getting_started Configures the required perimeter for receiving test cards in Example 1. Run from the client/example1 directory. ```bash ./setupPerimeter.sh perimeter.json ``` -------------------------------- ### Start ng serve for Cypress tests Source: https://opfab.github.io/documentation/current/dev_env Starts a dynamically generated UI on port 4200 after starting a Cypress-flavoured OpFab instance in development mode. Used for running tests against the ng serve UI. ```bash cd frontend ng serve ``` -------------------------------- ### Start OpFab instance for Cypress tests Source: https://opfab.github.io/documentation/current/dev_env Starts the OperatorFabric instance for Cypress tests in dev or Java mode. Run from the project root; the bin directory contains the start script. ```bash cd bin ./startOpfab.sh ``` -------------------------------- ### Node service test, build, and start commands Source: https://opfab.github.io/documentation/current/dev_env/index.html Useful commands for Node services: launch unit tests, build the service, and start the service without hot reload. ```bash npm run test ``` ```bash npm run build ``` ```bash node build/cardReminder.ts ``` -------------------------------- ### Install Cypress tests Source: https://opfab.github.io/documentation/current/dev_env/index.html Installs Cypress dependencies using NPM. Run from the tests/cypress directory. ```bash cd tests/cypress npm install ``` -------------------------------- ### Start OperatorFabric with startOpfab.sh Source: https://opfab.github.io/documentation/current/dev_env/index.html Starts OperatorFabric in the specified mode. Replace [mode] with dev, prod, java, or light. The default mode is dev. ```bash cd bin ./startOpfab.sh [mode] ``` -------------------------------- ### Start all Java services with run_all.sh Source: https://opfab.github.io/documentation/current/dev_env/index.html Starts all Java services individually when running in java mode. Use this script from the bin directory. ```bash ${OF_HOME}/bin/run_all.sh start ``` -------------------------------- ### Source environment setup script Source: https://opfab.github.io/documentation/current/dev_env/index.html Sources the environment setup script to set appropriate versions of Node, Java, and project variables. After running, use ${OF_HOME} to refer to the OperatorFabric home directory. ```bash source bin/load_environment_light.sh ``` -------------------------------- ### Start and stop OpFab instance for Cypress tests Source: https://opfab.github.io/documentation/current/dev_env/index.html Start the OpFab instance for Cypress tests in dev or java mode. After tests, stop and destroy containers to avoid side-effects from previous tests. ```bash cd bin ./startOpfab.sh ``` ```bash cd bin ./stopOpfab.sh ``` -------------------------------- ### Example card JSON (card.json) Source: https://opfab.github.io/documentation/current/getting_started Example card JSON showing the structure of a basic card. The startDate field is set to a placeholder that is replaced with the current date by the sending script. ```json { "publisher" : "message-publisher", "processVersion" : "1", "process" :"defaultProcess", "processInstanceId" : "hello-world-1", "state" : "messageState", "groupRecipients": ["Dispatcher"], "severity" : "INFORMATION", "startDate" : 1553186770681, "summary" : {"key" : "defaultProcess.summary"}, "title" : {"key" : "defaultProcess.title"}, "data" : {"message" :"Hello World !!! That's my first message"} } ``` -------------------------------- ### Install Angular CLI globally Source: https://opfab.github.io/documentation/current/dev_env/index.html If ng serve returns 'Command ng not found', install the Angular CLI globally with this command. ```bash npm install -g @angular/cli ``` -------------------------------- ### Example CardCommand JSON dump Source: https://opfab.github.io/documentation/current/dev_env/index.html Example of a CardCommand JSON that would be put on a Kafka topic. Required properties must be set or the card will be rejected by OperatorFabric. The actual values in the dump are illustrative and should be ignored. ```json { "command": "CREATE_CARD", "process": "integrationTest", "processInstanceId": "fa6ce61f-192f-11eb-a6e3-eea952defe56", "card": { "parentCardUid": null, "publisher": "myFirstPublisher", "processVersion": "2", "state": "FirstUserTask", "publishDate": null, "lttd": null, "startDate": 1603897942000, "endDate": 1604070742000, "severity": "ALARM", "tags": null, "timeSpans": null, "details": null, "title": { "key": "FirstUserTask.title", "parameters": null }, "summary": { "key": "FirstUserTask.summary", "parameters": null }, "userRecipients": [ "tso1-operator", "tso2-operator" ], "groupRecipients": null, "entitiesAllowedToRespond": [ "ENTITY1_FR" ], "entityRecipients": null, "hasBeenAcknowledged": null, "data": "{\"action\":\"Just do something\"}" } } ``` -------------------------------- ### Example: new Java file header (2020, Entity X) Source: https://opfab.github.io/documentation/current/community Example of a copyright header for a new Java file created in 2020 by a developer from Entity X. Follows the MPL-2.0 template with the year 2020 and the entity's website. ```text Copyright (c) 2020, Entity X (http://www.entityX.org) See AUTHORS.txt This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. SPDX-License-Identifier: MPL-2.0 This file is part of the OperatorFabric project. ``` -------------------------------- ### Load demo configuration with ./loadDemoConf.sh Source: https://opfab.github.io/documentation/current/getting_started Run from the client/demo folder to set up demo bundles, businessData, perimeters, and realTimeScreens. ```bash ./loadDemoConf.sh ``` -------------------------------- ### GET /cards-consultation/cardSubscription response example Source: https://opfab.github.io/documentation/current/api Example response for the GET /cards-consultation/cardSubscription endpoint. It shows an array of subscription events, each with a type (e.g., DELETE) and a cardId. ```json [ { "type": "DELETE", "cardId": 12345 } ] ``` -------------------------------- ### GET /users/users - Response 200 Example Source: https://opfab.github.io/documentation/current/api Example response for listing all users. Returns an array of user objects with login, firstName, lastName, groups, and entities. This endpoint supports pagination and filtering. 401 if authentication required, 403 if non-admin users access others' data. ```json [ { "login": "jcleese", "firstName": "John", "lastName": "Cleese", "groups": [ "MONTY", "WANDA" ], "entities": [ "ENITY1", "ENTITY2" ] }, { "login": "gchapman", "firstName": "Graham", "lastName": "Chapman", "groups": [ "MONTY" ], "entities": [ "ENITY1" ] } ] ``` -------------------------------- ### Run subset of Cypress tests with Gradle Source: https://opfab.github.io/documentation/current/dev_env Runs a subset of Cypress tests, for example all tests starting with 'User'. The -PspecFiles parameter filters the spec files. ```bash ./gradlew runSomeCypressTests -PspecFiles=User* ``` -------------------------------- ### Curl: Get OAuth2 token Source: https://opfab.github.io/documentation/current/dev_env/index.html POSTs username, password, and grant_type=password to localhost:2002/auth/token to obtain an access token. The example uses the admin user with password 'test'. ```bash curl -s -X POST -d "username=admin&password=test&grant_type=password" http://localhost:2002/auth/token ``` -------------------------------- ### Response JSON for Java logger level Source: https://opfab.github.io/documentation/current/deployment/index.html Example JSON response returned by the GET request to '/actuator/logger' for a Java service. Shows the configured and effective logging levels. ```json { "configuredLevel" : "INFO", "effectiveLevel" : "INFO" } ``` -------------------------------- ### Run ./bin/prepare_release_version.sh -v X.X.X.RELEASE Source: https://opfab.github.io/documentation/current/CICD/index.html Runs the release preparation script and shows its expected output. The script updates the VERSION file, docker-compose files, and package.json files for opfab-cli and web-ui. ```bash ./bin/prepare_release_version.sh -v X.X.X.RELEASE ``` ```text Current version is SNAPSHOT (based on VERSION file) Preparing X.X.X.RELEASE Updating version for pipeline in VERSION file The following files have been updated: M VERSION M config/docker-compose.yml M src/doc/api/openapi.yml ``` -------------------------------- ### Response sample for GET /users/users/{login}/perimeters Source: https://opfab.github.io/documentation/current/api Example JSON response for the perimeters endpoint. Shows an array of perimeter objects with id, process, and stateRights. Note the inconsistency: some objects use 'right' and others 'rights'. ```json [ { "id": "Process1", "process": "Process1", "stateRights": [ { "state": "State1", "right": "Receive" }, { "state": "State2", "rights": "ReceiveAndWrite" } ] }, { "id": "Process2", "process": "Process2", "stateRights": [ { "state": "State1", "right": "ReceiveAndWrite" }, { "state": "State2", "rights": "Write" } ] } ] ``` -------------------------------- ### Command to list available Java versions Source: https://opfab.github.io/documentation/current/dev_env/index.html Runs `sdk list java` to show available versions. The output includes markers for local, installed, and currently used versions. ```text sdk list java ``` -------------------------------- ### GET /users/CurrentUserWithPerimeters - 200 Response Source: https://opfab.github.io/documentation/current/api Example JSON response for the connected user endpoint. The response includes userData with login, firstName, lastName, groups, and entities, plus computedPerimeters with process, state, and rights. Requires authentication; returns 401 if not authenticated. ```json { "userData": { "login": "jcleese", "firstName": "John", "lastName": "Cleese", "groups": [ "MONTY", "WANDA" ], "entities": [ "ENITY1", "ENTITY2" ] }, "computedPerimeters": [ { "process": "Process1", "state": "State1", "rights": "Receive" }, { "process": "Process1", "state": "State2", "rights": "ReceiveAndWrite" } ] } ``` -------------------------------- ### Package and send bundle for message template Source: https://opfab.github.io/documentation/current/getting_started/index.html Use these scripts to build and deploy the bundle with the message template to the server. ```shell ./packageBundle.sh | ./sendBundle.sh ``` -------------------------------- ### common.yml configuration example Source: https://opfab.github.io/documentation/current/deployment/index.html JSON configuration for common.yml with user details including login, name, groups, entities, and creation date. ```json { "login":"john-doe-operator"," firstName":"John", "lastName":"Doe", "groups":[], "entities":[], "creationDate": 1708876800000 } } ``` -------------------------------- ### Create bundle archive with tar -czvf Source: https://opfab.github.io/documentation/current/getting_started Create a bundle archive in the correct tar.gz format. Include config.json, i18n.json, template/, and css/ files. ```bash tar -czvf MyBundleToTest.tar.gz config.json i18n.json template/ css/ ``` -------------------------------- ### Start Node service without hot reload Source: https://opfab.github.io/documentation/current/dev_env Starts the Node service without hot reload. ```bash node build/cardReminder.ts ``` -------------------------------- ### List certificates in keystore Source: https://opfab.github.io/documentation/current/deployment/index.html Command to list certificates in the keystore at /tmp/cacerts using keytool. ```bash $JAVA_HOME/bin/keytool -list -v -keystore /tmp/cacerts -storepass changeit ``` -------------------------------- ### Run unit tests and build with Gradle build Source: https://opfab.github.io/documentation/current/dev_env/index.html Runs unit tests, compiles, and packages the jars. Run from the OF_HOME directory. ```bash cd ${OF_HOME} ./gradlew build ``` -------------------------------- ### GET /users/users Source: https://opfab.github.io/documentation/current/api Get a list of all existing users, with pagination and filter options. Requires authentication; non-admin users can only access their own data. ```APIDOC ## GET /users/users ### Description Get a list of all existing users, with pagination and filter options. ### Method GET ### Endpoint /users/users ### Response #### Success Response (200) OK #### Response Example [ { "login": "jcleese", "firstName": "John", "lastName": "Cleese", "groups": ["MONTY", "WANDA"], "entities": ["ENITY1", "ENTITY2"] }, { "login": "gchapman", "firstName": "Graham", "lastName": "Chapman", "groups": ["MONTY"], "entities": ["ENITY1"] } ] #### Error Responses - **401** - Authentication required - **403** - Authenticated users who are not admins can only access their own data ``` -------------------------------- ### common.yml configuration file Source: https://opfab.github.io/documentation/current/deployment/index.html Example of configuration file common.yml containing user properties: firstName, lastName, login, and creationDate as a timestamp. ```json { "firstName": "John", "lastName": "Doe", "login": "john-doe-operator", "creationDate": 1708876800000 } ``` -------------------------------- ### Get all entities - GET /users/entities Source: https://opfab.github.io/documentation/current/api Fetches a list of all existing entities with pagination and filter options. The response is an array of entity objects with id, name, and description. ```json [ { "id": "ENTITY1", "name": "Control Room 1", "description": "Control Room 1" }, { "id": "ENTITY2", "name": "Control Room 2", "description": "Control Room 2" } ] ``` -------------------------------- ### Create and push release candidate tag Source: https://opfab.github.io/documentation/current/CICD/index.html Checks out the release branch, pulls latest, creates the release candidate tag, and pushes it. ```bash git checkout X.X.release git pull git tag X.X.X-RC.RELEASE git push origin X.X.X-RC.RELEASE ```