-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for related objects & Directory sync #154
Changes from all commits
c227a8e
adf70c3
1cbd90a
3b54f41
26088cf
04204f8
8d88d0a
c24434f
2016734
c4bf638
b88310d
7ee7dca
8630a7c
fe9b9b0
172ee0a
345d3ce
14873b9
1268b60
879a475
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\IAppConfig; | ||
use OCP\IRequest; | ||
use OCP\IURLGenerator; | ||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have class docblock? |
||
|
||
|
@@ -33,6 +34,7 @@ class CatalogiController extends Controller | |
* @param ObjectService $objectService The object service | ||
* @param DirectoryService $directoryService The directory service | ||
* @param BroadcastService $broadcastService The broadcast service | ||
* @param IURLGenerator $urlGenerator The URL generator | ||
*/ | ||
public function __construct( | ||
$appName, | ||
|
@@ -41,7 +43,8 @@ public function __construct( | |
private readonly CatalogMapper $catalogMapper, | ||
private readonly ObjectService $objectService, | ||
private readonly DirectoryService $directoryService, | ||
private readonly BroadcastService $broadcastService | ||
private readonly BroadcastService $broadcastService, | ||
private readonly IURLGenerator $urlGenerator | ||
) | ||
{ | ||
parent::__construct($appName, $request); | ||
|
@@ -114,6 +117,17 @@ public function create(ObjectService $objectService): JSONResponse | |
// Save the new catalog object | ||
$object = $this->objectService->saveObject('catalog', $data); | ||
|
||
// If object is a class change it to array | ||
if (is_object($object) === true) { | ||
$object = $object->jsonSerialize(); | ||
} | ||
|
||
// If we do not have an uri, we need to generate one | ||
if (isset($object['uri']) === false) { | ||
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.catalogs.show', ['id' => $object['id']])); | ||
$object = $this->objectService->saveObject('catalog', $object); | ||
} | ||
|
||
// Update all external directories | ||
$this->broadcastService->broadcast(); | ||
|
||
|
@@ -142,6 +156,9 @@ public function update(string|int $id, ObjectService $objectService): JSONRespon | |
// Ensure the ID in the data matches the ID in the URL | ||
$data['id'] = $id; | ||
|
||
// If we do not have an uri, we need to generate one | ||
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.catalogs.show', ['id' => $data['id']])); | ||
|
||
// Save the updated catalog object | ||
$object = $this->objectService->saveObject('catalog', $data); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\IAppConfig; | ||
use OCP\IRequest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have class docblock? |
||
|
||
use OCP\IURLGenerator; | ||
/** | ||
* Class OrganizationsController | ||
* | ||
|
@@ -26,13 +26,15 @@ class OrganizationsController extends Controller | |
* @param IAppConfig $config The app configuration | ||
* @param OrganizationMapper $organizationMapper The organization mapper | ||
* @param ObjectService $objectService The object service | ||
* @param IURLGenerator $urlGenerator The URL generator | ||
*/ | ||
public function __construct( | ||
$appName, | ||
IRequest $request, | ||
private readonly IAppConfig $config, | ||
private readonly OrganizationMapper $organizationMapper, | ||
private readonly ObjectService $objectService | ||
private readonly ObjectService $objectService, | ||
private readonly IURLGenerator $urlGenerator | ||
) | ||
{ | ||
parent::__construct($appName, $request); | ||
|
@@ -109,6 +111,17 @@ public function create(): JSONResponse | |
// Save the new organization object | ||
$object = $this->objectService->saveObject('organization', $data); | ||
|
||
// If object is a class change it to array | ||
if (is_object($object) === true) { | ||
$object = $object->jsonSerialize(); | ||
} | ||
|
||
// If we do not have an uri, we need to generate one | ||
if (isset($object['uri']) === false) { | ||
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.organizations.show', ['id' => $object['id']])); | ||
$object = $this->objectService->saveObject('organization', $object); | ||
} | ||
|
||
// Return the created object as a JSON response | ||
return new JSONResponse($object); | ||
} | ||
|
@@ -130,6 +143,9 @@ public function update(string|int $id): JSONResponse | |
// Ensure the ID in the data matches the ID in the URL | ||
$data['id'] = $id; | ||
|
||
// If we do not have an uri, we need to generate one | ||
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.organizations.show', ['id' => $data['id']])); | ||
|
||
// Save the updated organization object | ||
$object = $this->objectService->saveObject('organization', $data); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\IAppConfig; | ||
use OCP\IRequest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have class docblock? |
||
|
||
use OCP\IURLGenerator; | ||
/** | ||
* Class PublicationTypesController | ||
* | ||
|
@@ -29,6 +29,7 @@ class PublicationTypesController extends Controller | |
* @param ObjectService $objectService The object service | ||
* @param DirectoryService $directoryService The directory service | ||
* @param BroadcastService $broadcastService The broadcast service | ||
* @param IURLGenerator $urlGenerator The URL generator | ||
*/ | ||
public function __construct( | ||
$appName, | ||
|
@@ -37,7 +38,8 @@ public function __construct( | |
private readonly PublicationTypeMapper $publicationTypeMapper, | ||
private readonly ObjectService $objectService, | ||
private readonly DirectoryService $directoryService, | ||
private readonly BroadcastService $broadcastService | ||
private readonly BroadcastService $broadcastService, | ||
private readonly IURLGenerator $urlGenerator | ||
) | ||
{ | ||
parent::__construct($appName, $request); | ||
|
@@ -118,6 +120,17 @@ public function create(): JSONResponse | |
// Save the new publication type object | ||
$object = $this->objectService->saveObject('publicationType', $data); | ||
|
||
// If object is a class change it to array | ||
if (is_object($object) === true) { | ||
$object = $object->jsonSerialize(); | ||
} | ||
|
||
// If we do not have an uri, we need to generate one | ||
if (isset($object['uri']) === false) { | ||
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publicationTypes.show', ['id' => $object['id']])); | ||
$object = $this->objectService->saveObject('publicationType', $object); | ||
} | ||
|
||
// Update all external directories | ||
$this->broadcastService->broadcast(); | ||
|
||
|
@@ -142,6 +155,10 @@ public function update(string|int $id): JSONResponse | |
// Ensure the ID in the data matches the ID in the URL | ||
$data['id'] = $id; | ||
|
||
// If we do not have an uri, we need to generate one | ||
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publicationTypes.show', ['id' => $data['id']])); | ||
|
||
|
||
// Save the updated publication type object | ||
$object = $this->objectService->saveObject('publicationType', $data); | ||
|
||
|
@@ -169,7 +186,7 @@ public function destroy(string|int $id): JSONResponse | |
// Return the result as a JSON response | ||
return new JSONResponse(['success' => $result], $result === true ? '200' : '404'); | ||
} | ||
|
||
/** | ||
* Synchronize or delete a publication type based on listing status | ||
* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
use OCP\AppFramework\OCS\OCSNotFoundException; | ||
use OCP\IAppConfig; | ||
use OCP\IRequest; | ||
use OCP\IURLGenerator; | ||
use Psr\Container\ContainerExceptionInterface; | ||
use Psr\Container\NotFoundExceptionInterface; | ||
use Symfony\Component\Uid\Uuid; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have class docblock? |
||
|
@@ -49,6 +50,8 @@ class PublicationsController extends Controller | |
* @param FileService $fileService The file service | ||
* @param DownloadService $downloadService The download service | ||
* @param ObjectService $objectService The object service | ||
* @param IURLGenerator $urlGenerator The URL generator | ||
* | ||
*/ | ||
public function __construct | ||
( | ||
|
@@ -59,7 +62,8 @@ public function __construct | |
private readonly IAppConfig $config, | ||
private readonly FileService $fileService, | ||
private readonly DownloadService $downloadService, | ||
private ObjectService $objectService | ||
private readonly ObjectService $objectService, | ||
private readonly IURLGenerator $urlGenerator | ||
) | ||
{ | ||
parent::__construct($appName, $request); | ||
|
@@ -197,6 +201,17 @@ public function create(ObjectService $objectService): JSONResponse | |
// Save the new publication object | ||
$object = $this->objectService->saveObject('publication', $data); | ||
|
||
// If object is a class change it to array | ||
if (is_object($object) === true) { | ||
$object = $object->jsonSerialize(); | ||
} | ||
|
||
// If we do not have an uri, we need to generate one | ||
if (isset($object['uri']) === false) { | ||
$object['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publications.show', ['id' => $object['id']])); | ||
$object = $this->objectService->saveObject('publication', $object); | ||
} | ||
|
||
// Return the created object as a JSON response | ||
return new JSONResponse($object); | ||
} | ||
|
@@ -221,6 +236,9 @@ public function update(string|int $id, ObjectService $objectService): JSONRespon | |
// Ensure the ID in the data matches the ID in the URL | ||
$data['id'] = $id; | ||
|
||
// If we do not have an uri, we need to generate one | ||
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.publications.show', ['id' => $data['id']])); | ||
|
||
// Save the updated publication object | ||
$object = $this->objectService->saveObject('publication', $data); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
use OCP\AppFramework\Http\JSONResponse; | ||
use OCP\IAppConfig; | ||
use OCP\IRequest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this file have class docblock? |
||
|
||
use OCP\IURLGenerator; | ||
/** | ||
* Class ThemesController | ||
* | ||
|
@@ -27,14 +27,16 @@ class ThemesController extends Controller | |
* @param ThemeMapper $themeMapper The theme mapper for database operations | ||
* @param IAppConfig $config The app configuration | ||
* @param ObjectService $objectService The service for handling object operations | ||
* @param IURLGenerator $urlGenerator The URL generator | ||
*/ | ||
public function __construct | ||
( | ||
$appName, | ||
IRequest $request, | ||
private readonly ThemeMapper $themeMapper, | ||
private readonly IAppConfig $config, | ||
private readonly ObjectService $objectService | ||
private readonly ObjectService $objectService, | ||
private readonly IURLGenerator $urlGenerator | ||
) | ||
{ | ||
parent::__construct($appName, $request); | ||
|
@@ -97,6 +99,17 @@ public function create(): JSONResponse | |
// Save the new theme object | ||
$object = $this->objectService->saveObject('theme', $data); | ||
|
||
// If object is a class change it to array | ||
if (is_object($object) === true) { | ||
$object = $object->jsonSerialize(); | ||
} | ||
|
||
// If we do not have an uri, we need to generate one | ||
if (isset($object['uri']) === false) { | ||
$object['uri'] = $this->urlGenerator->getAbsoluteURL($$this->urlGenerator->linkToRoute('openCatalogi.themes.show', ['id' => $object['id']])); | ||
$object = $this->objectService->saveObject('theme', $object); | ||
} | ||
|
||
// Return the created object as a JSON response | ||
return new JSONResponse($object); | ||
} | ||
|
@@ -118,6 +131,9 @@ public function update(string|int $id): JSONResponse | |
// Ensure the ID in the data matches the ID in the URL | ||
$data['id'] = $id; | ||
|
||
// If we do not have an uri, we need to generate one | ||
$data['uri'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('openCatalogi.themes.show', ['id' => $data['id']])); | ||
|
||
// Save the updated theme object | ||
$object = $this->objectService->saveObject('theme', $data); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this file have class docblock?