Skip to content

Commit

Permalink
Various fixes and improvements to plugin infrastructure and FileSourc…
Browse files Browse the repository at this point in the history
…e (CFM-42, CFM-117, CFM-341, CFM-362, CFM-445, CFM-451, CFM-452)
  • Loading branch information
Benn Oshrin committed Aug 13, 2025
1 parent c4ce79a commit b8478f0
Show file tree
Hide file tree
Showing 31 changed files with 490 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"api": [
"ApiSourceEndpoints"
],
"source": [
"external_identity_source": [
"ApiSources"
]
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"types": {
"provisioner": [
"provisioning_target": [
"FileProvisioners"
],
"source": [
"external_identity_source": [
"FileSources"
]
},
Expand All @@ -26,7 +26,7 @@
"filename": { "type": "string", "size": 256 },
"format": { "type": "string", "size": 2 },
"archivedir": { "type": "string", "size": 256 },
"threshold_warn": { "type": "integer" },
"threshold_check": { "type": "integer" },
"threshold_override": { "type": "boolean" }
},
"indexes": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@ msgstr "{0,plural,=1{File Provisioner} other{File Provisioners}}"
msgid "enumeration.FileSourceFormatEnum.C3"
msgstr "CSV v3"

msgid "error.filename.absolute"
msgstr "File path \"{0}\" does not begin with \"/\""

msgid "error.filename.readable"
msgstr "The file \"{0}\" is not readable"

msgid "error.filename.writeable"
msgid "error.filename.writable"
msgstr "The file \"{0}\" is not writable"

msgid "error.FileSource.copy"
msgstr "Failed to copy {0} to {1}"

msgid "error.FileSource.threshold"
msgstr "{0} of {1} records changed ({2}%, including new records), exceeding threshold of {3}% - processing canceled"

msgid "error.FileSource.threshold.config"
msgstr "Threshold Check requires Archive Directory"

msgid "error.header"
msgstr "Did not find CSV file header"

msgid "error.header.invalid"
msgstr "\"{0}\" is not a valid field"

msgid "error.header.sorid"
msgstr "Did not find SORID as first defined column, check file header definition"

Expand All @@ -61,14 +76,17 @@ msgstr "Full path to file to read from, which must exist and be readable"
msgid "field.FileSources.format"
msgstr "File Format"

msgid "field.FileSources.threshold_warn"
msgid "field.FileSources.threshold_check"
msgstr "Warning Threshold"

msgid "field.FileSources.threshold_warn.desc"
msgid "field.FileSources.threshold_check.desc"
msgstr "If the number of changed records exceeds the specified percentage, a warning will be generated and processing will stop (requires Archive Directory)"

msgid "field.FileSources.threshold_override"
msgstr "Warning Threshold Override"

msgid "field.FileSources.threshold_override.desc"
msgstr "If set, the next Full sync will ignore the Warning Threshold"
msgstr "If set, the next Full sync will ignore the Warning Threshold"

msgid "result.FileProvisioner.done"
msgstr "Wrote 1 record to file"
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use Cake\Validation\Validator;
use App\Lib\Enum\ProvisioningEligibilityEnum;
use App\Lib\Enum\ProvisioningStatusEnum;
use \FileConnector\Model\Entity\FileProvisioner;
use App\Model\Entity\ProvisioningTarget;

class FileProvisionersTable extends Table {
use \App\Lib\Traits\ChangelogBehaviorTrait;
Expand Down Expand Up @@ -98,10 +98,10 @@ public function initialize(array $config): void {
*/

public function buildRules(RulesChecker $rules): RulesChecker {
// The requested file must exist and be writeable.
// The requested file must exist and be writable.

$rules->add([$this, 'ruleIsFileWriteable'],
'isFileWriteable',
$rules->add([$this, 'ruleIsFileWritable'],
'isFileWritable',
['errorField' => 'filename']);

return $rules;
Expand All @@ -110,17 +110,17 @@ public function buildRules(RulesChecker $rules): RulesChecker {
/**
* Provision object data to the provisioning target.
*
* @param FileProvisioner $provisioningTarget FileProvisioner configuration
* @param string $entityName
* @param object $data Provisioning data in Entity format (eg: \App\Model\Entity\Person)
* @param string $eligibility Provisioning Eligibility Enum
* @param ProvisioningTarget $provisioningTarget FileProvisioner configuration
* @param string $entityName
* @param object $data Provisioning data in Entity format (eg: \App\Model\Entity\Person)
* @param string $eligibility Provisioning Eligibility Enum
*
* @return array Array of status, comment, and optional identifier
* @since COmanage Registry v5.0.0
*/

public function provision(
FileProvisioner $provisioningTarget,
ProvisioningTarget $provisioningTarget,
string $entityName,
object $data,
string $eligibility
Expand All @@ -133,22 +133,22 @@ public function provision(
}

if(file_put_contents(
filename: $provisioningTarget->filename,
filename: $provisioningTarget->file_provisioner->filename,
data: json_encode($output, JSON_INVALID_UTF8_SUBSTITUTE) . "\n",
flags: FILE_APPEND
) === false) {
throw new \RuntimeException("Write to " . $provisioningTarget->filename . " failed");
throw new \RuntimeException("Write to " . $provisioningTarget->file_provisioner->filename . " failed");
}

return [
'status' => ProvisioningStatusEnum::Provisioned,
'comment' => "Wrote 1 record to file",
'comment' => __d('file_connector', 'result.FileProvisioner.done'),
'identifier' => null
];
}

/**
* Application Rule to determine if the current entity is a writeable file.
* Application Rule to determine if the current entity is a writable file.
*
* @param Entity $entity Entity to be validated
* @param array $options Application rule options
Expand All @@ -157,9 +157,9 @@ public function provision(
* @since COmanage Registry v5.0.0
*/

public function ruleIsFileWriteable($entity, array $options): string|bool {
public function ruleIsFileWritable($entity, array $options): string|bool {
if(!is_writable($entity->filename)) {
return __d('file_connector', 'error.filename.writeable', [$entity->filename]);
return __d('file_connector', 'error.filename.writable', [$entity->filename]);
}

return true;
Expand Down
Loading

0 comments on commit b8478f0

Please sign in to comment.