forked from Mapepire-IBMi/mapepire-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial rewrite * Better error handling * code formatting * code cleanup * Add db liveliness check to ping * Clean up code warnings * gut use of `AppLogger` * Update README.md * SQL results be array of objects instead of 2d array. Also trimmed strings * GH action
- Loading branch information
Showing
22 changed files
with
886 additions
and
802 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,42 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | ||
|
||
name: Build new release | ||
name: Release | ||
|
||
on: | ||
push: | ||
# Sequence of patterns matched against refs/tags | ||
tags: | ||
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v3 | ||
name: Check out | ||
|
||
- name: Get Maven project version | ||
run: | | ||
echo "project_version=$(mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive exec:exec --file pom.xml)" >> $GITHUB_ENV | ||
cat $GITHUB_ENV | ||
- name: Set up JDK 8 | ||
uses: actions/setup-java@v2 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '8' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: create jt400 psudo-directory | ||
run: sudo mkdir -p /QIBM/ProdData/OS400/jt400/lib/ | ||
- name: change ownership of jt400 psudo-directory | ||
run: sudo chown $USER /QIBM/ProdData/OS400/jt400/lib/ | ||
- name: fetch jt400.jar | ||
run: sudo curl https://repo1.maven.org/maven2/net/sf/jt400/jt400/10.7/jt400-10.7.jar -o /QIBM/ProdData/OS400/jt400/lib/jt400.jar | ||
- name: Build with Maven | ||
|
||
- name: Build with Maven (Java 8) | ||
run: mvn -B package --file pom.xml | ||
- name: Copy .jar file to target name | ||
run: cp target/*-with-dependencies.jar ./codeforibmiserver.jar | ||
- name: Create the release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload .zip file to release | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: List target directory | ||
run: ls -l target | ||
|
||
- name: Copy dist artifacts to staging directory | ||
run: mkdir staging && cp target/*with-dependencies.jar staging/codeforiserver-${{ env.project_version }}.jar | ||
|
||
- name: Create the tag and release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: ./codeforibmiserver.jar | ||
asset_name: codeforibmiserver.jar | ||
asset_content_type: application/zip | ||
tag_name: v${{ env.project_version }} | ||
name: v${{ env.project_version }} | ||
files: staging/codeforiserver-${{ env.project_version }}.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
/target/ | ||
src/main/java/com/github/theprez/codefori/Version.java | ||
.vscode/settings.json | ||
.project | ||
.classpath | ||
.settings/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,79 @@ | ||
# CodeForIBMiServer | ||
Server-side support for Code for IBM i. | ||
Server-side support for Code for IBM i, more specifically database support. | ||
Intended for programmatic interaction. | ||
|
||
# Usage | ||
```bash | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -jar codeforibmiserver.jar <operation> [[item]..] | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -jar codeforibmiserver.jar | ||
``` | ||
For instance, | ||
```bash | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -jar codeforibmiserver.jar sysval qccsid QINACTITV | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -jar codeforibmiserver.jar | ||
``` | ||
Supported operations are currently: | ||
- `sysval`: fetch system values | ||
- `sql`: run SQL | ||
- `gencmdxml`: Generate XML for a CL command | ||
- `filebytes`: Get the raw bytes for a file | ||
|
||
This server-side job processes requests asynchronously. Requests are sent and received | ||
through simple use of stdin/stdout streams. The intent is that the client program | ||
is able to launch this process through SSH and interact with it through pipes. | ||
|
||
The data stream is relatively simple. Requests and responses are newline-delimited and | ||
are formatted in JSON. | ||
|
||
All requests require these two fields to be specified: | ||
- `id` (string): Since the server can process requests asynchronously, responses are not | ||
guaranteed back in the same order as requests were sent. The `id` field passed into | ||
the request will be included in the response so that the client can match it up | ||
to the request. This can be any string, but should be unique for obvious reasons | ||
- `type` (string): this specifies the type of request | ||
|
||
All responses will include these fields: | ||
- `id` (string): corresponding to the request ID | ||
- `success` (boolean): whether or not the request was successful | ||
|
||
|
||
The following request types are currently supported | ||
|
||
| Type | Description | Additional input fields | Additional output fields | | ||
| ------------- | ------------- | ------------- | ------------- | | ||
| `connect` | Connect to the database (implicitly disconnects any existing connection) | `props`: a semicolon-delimited list of connection properties | `job`: the server job | | ||
| `sql` | Run SQL | `sql`: the SQL statement <br/> `rows`: the maximum number of rows to return on the first request | `metadata`: metadata about the result set <br/> `data`: the data <br/> `is_done`: whether all rows were fetched | | ||
| `sqlmore` | fetch more rows from a previous `sql` request | `cont_id`: the request ID of the previously-run `sql` request <br/> `rows`: the maximum number of rows to return | `data`: the data <br/> `is_done`: whether all rows were fetched | | ||
| `getdbjob` | Get server job for database tasks | | `job`: the server job | | ||
| `getversion` | Get version info | | `build_date`: build date <br/> `version`: version | | ||
| `ping` | Liveness check | | `alive`: this program is still responsive <br/> `db_alive`: there is an active connection to the database | | ||
| `exit ` | Exit | | | | ||
|
||
|
||
# Examples | ||
|
||
Example request to exit gracefully: | ||
```json | ||
{"id": "bye", "type": "exit"} | ||
``` | ||
|
||
Example to connect to the database with an initial library list | ||
```json | ||
{"id": "conn14", "type": "connect", "props":"naming=system;libraries=jesseg,qiws"} | ||
``` | ||
|
||
Example SQL query: | ||
```json | ||
{"id": "1l", "type": "sql", "rows":4, "sql":"select * from qiws.qcustcddt"} | ||
``` | ||
|
||
Example to fetch more data (4 more rows) from previous query | ||
```json | ||
{"id": "2l", "type": "sqlmore", "cont_id":"1l", "rows":4} | ||
``` | ||
|
||
|
||
# Options for customizing behavior | ||
Some operations support behavior customizations. This is done by setting Java system properties. | ||
|
||
Operation `sql` supports the following properties: | ||
- `codefori.sql.initialschema`: Initial schema | ||
- `codefori.sql.connprops`: Connection properties (semicolon-delimited) | ||
Operation `sql` supports the following Java system properties: | ||
- `codeserver.jdbc.autoconnect`: Enable SQL to be run without first issuing a `connect` request (uses default values) | ||
- `codeserver.verbose`: verbose mode | ||
|
||
So, for instance: | ||
|
||
```bash | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -Dcodefori.sql.initialschema=qiws -jar codeforibmiserver.jar sql "select * from qcustcdt" | ||
/QOpenSys/QIBM/ProdData/JavaVM/jdk80/64bit/bin/java -Dcodeserver.jdbc.autoconnect=true -jar codeforibmiserver.jar | ||
``` | ||
|
||
# Output | ||
It's JSON. Schema/format not documented, but you'll figure it out. Pipe the output through `jq` for pretty printing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.github.theprez.codefori; | ||
class Version { | ||
static String s_compileDateTime = "@timestamp@ (GMT)"; | ||
static String s_version = "@version@"; | ||
public class Version { | ||
static public final String s_compileDateTime = "@timestamp@ (GMT)"; | ||
static public final String s_version = "@version@"; | ||
} |
Oops, something went wrong.