Skip to content

Commit

Permalink
Merge branch 'master' into PHRAS-3901_release_version_4.1.8-rc6
Browse files Browse the repository at this point in the history
  • Loading branch information
nmaillat authored Sep 12, 2023
2 parents 7ed7550 + f3d8159 commit 5d6759e
Show file tree
Hide file tree
Showing 17 changed files with 458 additions and 183 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
with:
mask-password: 'true'

- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v2
Expand Down
9 changes: 6 additions & 3 deletions docker/nginx/root/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ else
fi

if [ ! -z "$GATEWAY_FASTCGI_HTTPS" ]; then

echo "GATEWAY_FASTCGI_HTTPS is defined : $GATEWAY_FASTCGI_HTTPS"
GATEWAY_FASTCGI_HTTPS="fastcgi_param HTTPS $GATEWAY_FASTCGI_HTTPS;"
if [ "$GATEWAY_FASTCGI_HTTPS" = "on" ] || [ "$GATEWAY_FASTCGI_HTTPS" = "1" ];then
echo "SETTING SERVER_PORT TO: 443"
GATEWAY_FASTCGI_HTTPS="fastcgi_param HTTPS on;fastcgi_param SERVER_PORT 443;"
else
GATEWAY_FASTCGI_HTTPS="fastcgi_param HTTPS $GATEWAY_FASTCGI_HTTPS;"
fi
else
echo "NO GATEWAY_FASTCGI_HTTPS is defined"
GATEWAY_FASTCGI_HTTPS="fastcgi_param HTTPS on;fastcgi_param SERVER_PORT 443;"

fi

cat /nginx.conf.sample | sed "s/\$MAX_BODY_SIZE/$MAX_BODY_SIZE/g" | sed "s/\$GATEWAY_SEND_TIMEOUT/$GATEWAY_SEND_TIMEOUT/g" | sed "s/\$GATEWAY_FASTCGI_TIMEOUT/$GATEWAY_FASTCGI_TIMEOUT/g" | sed "s/\$MAX_BODY_SIZE/$MAX_BODY_SIZE/g" | sed "s/\$GATEWAY_PROXY_TIMEOUT/$GATEWAY_PROXY_TIMEOUT/g" | sed "s/\$NEW_TARGET/$NEW_TARGET/g" | sed "s/\$NEW_RESOLVER/$NEW_RESOLVER/g" | sed "s/\$GATEWAY_FASTCGI_HTTPS/$GATEWAY_FASTCGI_HTTPS/g" > /etc/nginx/conf.d/default.conf
Expand Down
38 changes: 38 additions & 0 deletions lib/Alchemy/Phrasea/Controller/Admin/RootController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
use Alchemy\Phrasea\Core\Event\Record\Structure\StatusBitEvent;
use Alchemy\Phrasea\Core\Event\Record\Structure\StatusBitUpdatedEvent;
use Alchemy\Phrasea\Exception\SessionNotFound;
use Alchemy\Phrasea\SearchEngine\Elastic\ElasticsearchOptions;
use Alchemy\Phrasea\Status\StatusStructureProviderInterface;
use GuzzleHttp\Client;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;

Expand Down Expand Up @@ -360,6 +362,42 @@ public function submitStatusBitAction(Request $request, $databox_id, $bit) {
return $this->app->redirectPath('database_display_statusbit', ['databox_id' => $databox_id, 'success' => 1]);
}

public function displayInspector(Request $request)
{
$databoxIds = array_map(function (\databox $databox) {
return $databox->get_sbas_id();
},
$this->app->getApplicationBox()->get_databoxes()
);

return $this->render('admin/inspector/record-index.html.twig', ['databoxIds' => $databoxIds]);
}

public function getESRecord(Request $request)
{
$client = new Client();

/** @var ElasticsearchOptions $options */
$options = $this->app['elasticsearch.options'];

$uri = $options->getHost() . ":" . $options->getPort() . "/" . urlencode($options->getIndexName()) . "/record/" . urlencode($request->query->get('databoxId')) . "_" . urlencode($request->query->get('recordId'));

$ret = [
'uri' => $uri
];
$js = $client->get($uri, ['http_errors' => false])->getBody()->getContents();
$arr = json_decode($js,true);
if(is_null($arr)) {
$ret['result'] = "*** error decoding json ***";
$ret['raw'] = $js;
}
else {
$ret['result'] = $arr;
}

return json_encode($ret, JSON_PRETTY_PRINT, 512);
}

private function dispatchEvent($eventName, StatusBitEvent $event = null)
{
$this->app['dispatcher']->dispatch($eventName, $event);
Expand Down
6 changes: 6 additions & 0 deletions lib/Alchemy/Phrasea/ControllerProvider/Admin/Root.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ public function connect(Application $app)
->assert('bit', '\d+')
->bind('database_submit_statusbit');

$controllers->get('/inspector/', 'controller.admin.root:displayInspector')
->bind('admin_inspector');

$controllers->get('/inspector/record/', 'controller.admin.root:getESRecord')
->bind('admin_inspector_record');

return $controllers;
}
}
20 changes: 17 additions & 3 deletions lib/Alchemy/Phrasea/WorkerManager/Subscriber/RecordSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function onRecordsWriteMeta(RecordsWriteMetaEvent $event)
{
$databoxId = $event->getDataboxId();
$recordIds = $event->getRecordIds();
$acceptedMimeTypes = $this->app['conf']->get(['workers', 'writeMetadatas', 'acceptedMimeType'], []);

foreach ($recordIds as $recordId) {
$mediaSubdefRepository = $this->getMediaSubdefRepository($databoxId);
Expand All @@ -173,7 +174,13 @@ public function onRecordsWriteMeta(RecordsWriteMetaEvent $event)

foreach ($mediaSubdefs as $subdef) {
// check subdefmetadatarequired from the subview setup in admin
if (($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) || $this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())) {
// check if we want to write meta in this mime type
if (in_array(trim($subdef->get_mime()), $acceptedMimeTypes) &&
(
($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) ||
$this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())
)
) {
$payload = [
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
'payload' => [
Expand All @@ -182,7 +189,6 @@ public function onRecordsWriteMeta(RecordsWriteMetaEvent $event)
'subdefName' => $subdef->get_name()
]
];

if ($subdef->is_physically_present()) {
$this->messagePublisher->publishMessage($payload, MessagePublisher::WRITE_METADATAS_TYPE);
}
Expand Down Expand Up @@ -273,6 +279,8 @@ public function onSubdefinitionWritemeta(SubdefinitionWritemetaEvent $event)

}
else {
$acceptedMimeTypes = $this->app['conf']->get(['workers', 'writeMetadatas', 'acceptedMimeType'], []);

$databoxId = $event->getRecord()->getDataboxId();
$recordId = $event->getRecord()->getRecordId();

Expand All @@ -291,7 +299,13 @@ public function onSubdefinitionWritemeta(SubdefinitionWritemetaEvent $event)
}

// only the required writemetadata from admin > subview setup is to be writing
if (($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) || $this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())) {
// check if we want to write meta in this mime type
if (in_array($subdef->get_mime(), $acceptedMimeTypes) &&
(
($subdef->get_name() == 'document' && $toWritemetaOriginalDocument) ||
$this->isSubdefMetadataUpdateRequired($databox, $type, $subdef->get_name())
)
) {
$payload = [
'message_type' => MessagePublisher::WRITE_METADATAS_TYPE,
'payload' => [
Expand Down
87 changes: 87 additions & 0 deletions lib/classes/patch/418RC6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?php

use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;

class patch_418RC6 implements patchInterface
{
/** @var string */
private $release = '4.1.8-rc6';

/** @var array */
private $concern = [base::APPLICATION_BOX];

/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}

/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}

/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}

/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}

/**
* {@inheritdoc}
*/
public function apply(base $base, Application $app)
{
if ($base->get_base_type() === base::DATA_BOX) {
$this->patch_databox($base, $app);
} elseif ($base->get_base_type() === base::APPLICATION_BOX) {
$this->patch_appbox($base, $app);
}

return true;
}

private function patch_databox(databox $databox, Application $app)
{
}

private function patch_appbox(base $appbox, Application $app)
{
/** @var PropertyAccess $conf */
$conf = $app['conf'];

// PHRAS-3889
if (!$conf->has(['workers', 'writeMetadatas', 'acceptedMimeType'])) {
$defaultAcceptedMimeType = [
'image/jpeg',
'image/png',
'application/postscript',
'application/pdf',
'image/tiff'
];

$conf->set(['workers', 'writeMetadatas', 'acceptedMimeType'], $defaultAcceptedMimeType);
}

// PHRAS-3896
if ($conf->get(['main', 'search-engine', 'options', 'populate_order']) != 'RECORD_ID') {
$conf->set(['main', 'search-engine', 'options', 'populate_order'], 'RECORD_ID');
}
}
}
7 changes: 7 additions & 0 deletions lib/conf.d/configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ workers:
max_retry: 3
ttl_retry: 10000
ttl_delayed: 5000
writeMetadatas:
acceptedMimeType:
- image/jpeg
- image/png
- application/postscript
- application/pdf
- image/tiff
externalservice:
ginger:
AutoSubtitling:
Expand Down
Loading

0 comments on commit 5d6759e

Please sign in to comment.