Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development' into feature/CONNEC…
Browse files Browse the repository at this point in the history
…TOR-51/dashboard
  • Loading branch information
rubenvdlinde committed Dec 6, 2024
2 parents a5f79b8 + f61236c commit 00dbf1c
Show file tree
Hide file tree
Showing 16 changed files with 318 additions and 62 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/pull-request-from-branch-check.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
name: Main Branch Protection

on:
pull_request:
branches:
- main
#on:
# pull_request:
# branches:
# - main

jobs:
check-branch:
runs-on: ubuntu-latest
steps:
- name: Check branch
run: |
if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
then
echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
exit 1
fi
#jobs:
# check-branch:
# runs-on: ubuntu-latest
# steps:
# - name: Check branch
# run: |
# if [[ ${GITHUB_HEAD_REF} != development ]] && [[ ${GITHUB_HEAD_REF} != documentation ]] && ! [[ ${GITHUB_HEAD_REF} =~ ^hotfix/ ]];
# then
# echo "Error: Pull request must come from 'development', 'documentation' or 'hotfix/' branch"
# exit 1
# fi
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The OpenConnector Nextcloud app provides a ESB-framework to work together in an
- 🆓 Map and translate API calls
]]></description>
<version>0.1.16</version>
<version>0.1.20</version>
<licence>agpl</licence>
<category>integration</category>
<author mail="[email protected]" homepage="https://www.conduction.nl/">Conduction</author>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,28 @@
"description": "",
"version": "0.0.1",
"mapping": {
"title": "Name"
},
"unset": [],
"cast": [],
"title": "d.woo_x005f_titel",
"description": "d.woo_x005f_beschrijving",
"summary": "d.woo_x005f_samenvatting",
"category": "d.woo_x005f_categorie",
"published": "{% if d['woo_x005f_publicatiedatum']|default %}{{ d['woo_x005f_publicatiedatum']|date('Y-m-d') }}{% endif %}",
"modified": "d.vti_x005f_nexttolasttimemodified",
"attachments": "[ {% for file in fileUrls %} { {% if file['Name']|default %}\"title\": \"{{ file['Name'] }}\",{% endif %}{% if file['d']['document_x005f_label']|default %}\"labels\": [\"{{ file['d']['document_x005f_label'] }}\"],{% endif %}{% if file['__metadata']['uri']|default %}\"downloadUrl\": {\"accessUrl\": \"{{ file['__metadata']['uri']~'/$value' }}\", \"source\": \"1\"}{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %} ]",
"status": "Concept",
"catalog": "",
"publicationType": ""
},
"unset": [],
"cast": {
"title": "unsetIfValue==d.woo_x005f_titel",
"description": "unsetIfValue==d.woo_x005f_beschrijving",
"summary": "unsetIfValue==d.woo_x005f_samenvatting",
"category": "unsetIfValue==d.woo_x005f_categorie",
"published": "unsetIfValue==",
"modified": "unsetIfValue==d.vti_x005f_nexttolasttimemodified",
"attachments": "jsonToArray",
"publicationType": "unsetIfValue==",
"catalog": "unsetIfValue=="
},
"passThrough": false
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
{
"name": "Xxllnc suite to Publication",
"description": "",
"version": "",
"reference": "",
"version": "0.0.1",
"mapping": {
"title": "omschrijving",
"summary": "statustoelichting",
"description": "statusomschrijving"
},
"unset": [],
"cast": [],
"title": "omschrijving",
"summary": "zaaktypeomschrijving",
"description": "zaaktypeomschrijving",
"category": "{% if zaaktypecode|default %}{% set wooVerzoekenEnBesluiten = ['LP00000431', 'B1873', 'cherry'] %}{% set klachtoordelen = ['LP00000091', 'LP00001132', 'LP00000121', 'B0757', 'LP00000832', 'LP00001096'] %}{% if zaaktypecode in wooVerzoekenEnBesluiten %}{{ 'Woo-verzoeken en -besluiten' }}{% elseif zaaktypecode in klachtoordelen %}{{ 'Klachtoordelen' }}{% endif %}{% endif %}",
"published": "startdatum",
"modified": "{{ 'now'|date('H:i:sTm-d-Y') }}",
"attachments": "[{% if files|default %}{% for file in files %} { {% if file['titel']|default %}\"title\": \"{{ file['titel'] }}\",{% endif %}\"labels\": [\"{{ 'Informatieverzoek' }}\"],{% if file['formaat']|default %}\"extension\": \"{{ file['formaat']|split('/')|last }}\",\"type\": \"{{ file['formaat'] }}\",{% endif %}{% if file['inhoud']|default and file['formaat']|default %}\"accessUrl\": \"data:{{ file['formaat'] }};base64,{{ file.inhoud }}\"{% endif %} }{{ loop.last ? '' : ',' }} {% endfor %}{% endif %}]",
"status": "Concept"
},
"unset": [
""
],
"cast": {
"title": "unsetIfValue==omschrijving",
"summary": "unsetIfValue==zaaktypeomschrijving",
"description": "unsetIfValue==zaaktypeomschrijving",
"category": "unsetIfValue==",
"published": "unsetIfValue==startdatum",
"attachments": "jsonToArray"
},
"passThrough": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,20 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "UniqueId",
"resultsPosition": "d.results",
"endpoint": "/Web/GetFolderByServerRelativePath(decodedurl='/WOO/Convenanten')/folders",
"headers": [],
"query": []
},
"idPosition": "UniqueId",
"resultsPosition": "d.results",
"endpoint": "\/Web\/GetFolderByServerRelativePath(decodedurl='\/WOO\/Convenanten')\/folders",
"extraDataConfigs.0.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.0.mergeExtraData": "true",
"extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri",
"extraDataConfigs.1.mergeExtraData": "true",
"extraDataConfigs.1.keyToSetExtraData": "fileUrls",
"extraDataConfigs.1.resultsLocation": "d.results",
"extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true",
"headers": [],
"query": []
},
"targetId": "1/1",
"targetType": "register/schema"
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "UniqueId",
"idPosition": "UniqueId",
"resultsPosition": "d.results",
"endpoint": "/Web/GetFolderByServerRelativePath(decodedurl='/WOO/Woo-verzoeken en -besluiten')/folders",
"headers": [],
"query": []
"extraDataConfigs.0.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.0.mergeExtraData": "true",
"extraDataConfigs.1.dynamicEndpointLocation": "Files.__deferred.uri",
"extraDataConfigs.1.mergeExtraData": "true",
"extraDataConfigs.1.keyToSetExtraData": "fileUrls",
"extraDataConfigs.1.resultsLocation": "d.results",
"extraDataConfigs.1.extraDataConfigPerResult.dynamicEndpointLocation": "Properties.__deferred.uri",
"extraDataConfigs.1.extraDataConfigPerResult.mergeExtraData": "true",
"headers": [],
"query": []
},
"targetId": "1/1",
"targetType": "register/schema"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
"sourceHash": "",
"sourceTargetMapping": "1",
"sourceConfig": {
"idPosition": "id",
"resultsPosition": "results",
"endpoint": "/tlb/zaaksysteem/api/v1/zaken",
"headers": [],
"query.startdatum__gte": "2024-07-06",
"query.einddatum__lt": "2024-08-01"
},
"idPosition": "identificatie",
"resultsPosition": "results",
"endpoint": "\/tlb\/zaaksysteem\/api\/v1\/zaken",
"headers": [],
"query.startdatum__gte": "2024-08-01",
"query.einddatum__lt": "2025-01-01",
"usesPagination": "false",
"extraDataConfigs.0.staticEndpoint": "/tlb/zaaksysteem/api/v1/zaken/{{ originId }}/informatieobjecten",
"extraDataConfigs.0.mergeExtraData": "true",
"extraDataConfigs.0.keyToSetExtraData": "files",
"extraDataConfigs.0.resultsLocation": "results",
"extraDataConfigs.0.extraDataConfigPerResult.staticEndpoint": "/tlb/zaaksysteem/api/v1/informatieobjecten/{{ originId }}"
},
"targetId": "1/1",
"targetType": "register/schema"
}
13 changes: 12 additions & 1 deletion lib/Cron/ActionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use OCP\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\IUserManager;
use OCP\IUserSession;
use Psr\Container\ContainerInterface;
use Symfony\Component\Uid\Uuid;
use DateInterval;
Expand All @@ -30,7 +32,9 @@ public function __construct(
JobMapper $jobMapper,
JobLogMapper $jobLogMapper,
IJobList $jobList,
ContainerInterface $containerInterface
ContainerInterface $containerInterface,
private IUserSession $userSession,
private IUserManager $userManager,
) {
parent::__construct($time);
$this->jobMapper = $jobMapper;
Expand Down Expand Up @@ -80,6 +84,11 @@ public function run($argument)
return;
}

if(empty($job->getUserId()) === false && $this->userSession->getUser() === null) {
$user = $this->userManager->get($job->getUserId());
$this->userSession->setUser($user);
}

$time_start = microtime(true);

$action = $this->containerInterface->get($job->getJobClass());
Expand Down Expand Up @@ -127,6 +136,8 @@ public function run($argument)
}
}

$this->jobLogMapper->update(entity: $jobLog);

// Let's report back about what we have just done
return $jobLog;
}
Expand Down
15 changes: 15 additions & 0 deletions lib/Db/Synchronization.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ public function __construct() {
$this->addType(fieldName:'followUps', type: 'json');
}

/**
* Checks through sourceConfig if the source of this sync uses pagination
*
* @return bool true if its uses pagination
*/
public function usesPagination(): bool
{
if (isset($this->sourceConfig['usesPagination']) === true && ($this->sourceConfig['usesPagination'] === false || $this->sourceConfig['usesPagination'] === 'false')) {
return false;
}

// By default sources use basic pagination.
return true;
}

public function getJsonFields(): array
{
return array_keys(
Expand Down
2 changes: 1 addition & 1 deletion lib/Migration/Version1Date20241111144800.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array
&& $table->hasColumn('source_id') === true && $table->hasColumn('source_hash') === true
) {
$this->connection->executeQuery("
UPDATE openconnector_synchronization_contracts
UPDATE oc_openconnector_synchronization_contracts
SET origin_id = source_id, origin_hash = source_hash
WHERE source_id IS NOT NULL
");
Expand Down
31 changes: 30 additions & 1 deletion lib/Service/AuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,35 @@ public function fetchOAuthTokens (array $configuration): string
return $result['access_token'];
}

/**
* Fetch an access token from the DeCOS non-implementation of OAuth 2.0
*
* @param array $configuration The configuration of the source.
*
* @return string The access token
*
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function fetchDecosToken(array $configuration): string
{
$url = $configuration['tokenUrl'];
$tokenLocation = $configuration['tokenLocation'];
unset($configuration['tokenUrl']);

$callConfig['json'] = $configuration;

$client = new Client();
$response = $client->post(uri: $url, options: $callConfig);

$result = json_decode(json: $response->getBody()->getContents(), associative: true);

if (isset($tokenLocation) === true) {
return $result[$tokenLocation];
}

return $result['token'];
}

/**
* Get RSA key for RS and PS (asymmetrical) encryption.
*
Expand All @@ -201,7 +230,7 @@ public function fetchOAuthTokens (array $configuration): string
private function getRSJWK(array $configuration): ?JWK
{
$stamp = microtime().getmypid();
$filename = "privatekey-$stamp";
$filename = "/var/tmp/privatekey-$stamp";
file_put_contents($filename, base64_decode($configuration['secret']));
$jwk = null;
try {
Expand Down
5 changes: 4 additions & 1 deletion lib/Service/CallService.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ public function call(

$time_end = microtime(true);

$body = $response->getBody()->getContents();

// Let create the data array
$data = [
'request' => [
Expand All @@ -263,7 +265,8 @@ public function call(
'size' => $response->getBody()->getSize(),
'remoteIp' => $response->getHeaderLine('X-Real-IP') ?: $response->getHeaderLine('X-Forwarded-For') ?: null,
'headers' => $response->getHeaders(),
'body' => $response->getBody()->getContents(),
'body' => mb_check_encoding(value: $body, encoding: 'UTF-8') !== false ? $body : base64_encode($body),
'encoding' => mb_check_encoding(value: $body, encoding: 'UTF-8') !== false ? 'UTF-8' : 'base64',
]
];

Expand Down
Loading

0 comments on commit 00dbf1c

Please sign in to comment.