Skip to content
Snippets Groups Projects
Commit 4fb9bd71 authored by Steinwender, Tamara's avatar Steinwender, Tamara
Browse files

Add config and sharelink persistance

parent a335853f
No related branches found
No related tags found
No related merge requests found
Pipeline #197095 failed
......@@ -13,6 +13,15 @@ class Configuration implements ConfigurationInterface
{
$treeBuilder = new TreeBuilder('dbp_relay_blob_connector_local');
$treeBuilder
->getRootNode()
->children()
->scalarNode('path')
->defaultValue('/blobFiles')
->end()
->end()
->end();
return $treeBuilder;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use Dbp\Relay\BlobConnectorLocalBundle\Controller\LoggedInOnly;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* collectionOperations={
* "get" = {
* "path" = "/blob-connector-local/entitys",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* }
* },
* itemOperations={
* "get" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "put" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "delete" = {
* "path" = "/blob-connector-local/entitys/{identifier}",
* "openapi_context" = {
* "tags" = {"Blob Connector local datasystem"},
* },
* },
* "loggedin_only" = {
* "security" = "is_granted('IS_AUTHENTICATED_FULLY')",
* "method" = "GET",
* "path" = "/blob-connector-local/entitys/{identifier}/loggedin-only",
* "controller" = LoggedInOnly::class,
* "openapi_context" = {
* "summary" = "Only works when logged in.",
* "tags" = {"Blob Connector local datasystem"},
* },
* }
* },
* iri="https://schema.org/Entity",
* shortName="BlobConnectorLocalEntity",
* normalizationContext={
* "groups" = {"BlobConnectorLocalEntity:output"},
* "jsonld_embed_context" = true
* },
* denormalizationContext={
* "groups" = {"BlobConnectorLocalEntity:input"},
* "jsonld_embed_context" = true
* }
* )
*/
class Entity
{
/**
* @ApiProperty(identifier=true)
*/
private $identifier;
/**
* @ApiProperty(iri="https://schema.org/name")
* @Groups({"BlobConnectorLocalEntity:output", "BlobConnectorLocalEntity:input"})
*
* @var string
*/
private $name;
public function getName(): string
{
return $this->name;
}
public function setName(string $name): void
{
$this->name = $name;
}
public function getIdentifier(): string
{
return $this->identifier;
}
public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Entity;
use Dbp\Relay\BlobBundle\Entity\FileData;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="blob_connector_local")
*/
class ShareLinkPersistence
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $identifier;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $validUntil;
/**
* @var string
* @ORM\Column(type="string")
*/
private $link;
/**
* @var string
* @ORM\Column(type="string")
*/
private $fileDataIdentifier;
/**
* @return mixed
*/
public function getIdentifier()
{
return $this->identifier;
}
/**
* @param mixed $identifier
*/
public function setIdentifier($identifier): void
{
$this->identifier = $identifier;
}
/**
* @return \DateTime
*/
public function getValidUntil(): \DateTime
{
return $this->validUntil;
}
/**
* @param \DateTime $validUntil
*/
public function setValidUntil(\DateTime $validUntil): void
{
$this->validUntil = $validUntil;
}
/**
* @return string
*/
public function getLink(): string
{
return $this->link;
}
/**
* @param string $link
*/
public function setLink(string $link): void
{
$this->link = $link;
}
/**
* @return string
*/
public function getFileDataIdentifier(): string
{
return $this->fileDataIdentifier;
}
/**
* @param string $fileDataIdentifier
*/
public function setFileDataIdentifier(string $fileDataIdentifier): void
{
$this->fileDataIdentifier = $fileDataIdentifier;
}
}
services:
Dbp\Relay\BlobConnectorLocalBundle\Service\LocalDataSystemService:
autowire: true
autoconfigure: true
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Service;
use Dbp\Relay\BlobBundle\Entity\Bucket;
use Symfony\Component\HttpFoundation\UrlHelper;
class ConfigurationService
{
/**
* @var array
*/
private $config = [];
/**
* @var UrlHelper
*/
private $urlHelper;
public function __construct(
UrlHelper $urlHelper
) {
$this->urlHelper = $urlHelper;
}
/**
* @return void
*/
public function setConfig(array $config)
{
$this->config = $config;
}
public function getConfig(): array
{
return $this->config;
}
public function getPath(): string
{
return $this->config['path'];
}
}
<?php
declare(strict_types=1);
namespace Dbp\Relay\BlobConnectorLocalBundle\Service;
use Dbp\Relay\BlobBundle\Entity\Bucket;
use Dbp\Relay\BlobBundle\Entity\FileData;
use Dbp\Relay\BlobBundle\Helper\PoliciesStruct;
use Dbp\Relay\CoreBundle\Exception\ApiError;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Response;
class LocalDataSystemService implements DatasystemProviderServiceInterface
{
/**
* @var EntityManagerInterface
*/
private $em;
/** @var EventDispatcherInterface */
private $dispatcher;
public function __construct(EntityManagerInterface $em, EventDispatcherInterface $dispatcher)
{
$this->em = $em;
$this->dispatcher = $dispatcher;
}
public function checkConnection()
{
$this->em->getConnection()->connect();
}
public function saveFile(FileData &$fileData): ?FileData
{
dump("------------YES--------------------");
try {
$this->em->persist($fileData);
$this->em->flush();
} catch (\Exception $e) {
throw ApiError::withDetails(Response::HTTP_INTERNAL_SERVER_ERROR, 'File could not be created!', 'blob:form-not-created', ['message' => $e->getMessage()]);
}
return null;
}
public function renameFile(FileData &$fileData): ?FileData
{
return null;
}
public function getLink(FileData &$fileData, PoliciesStruct $policiesStruct): ?FileData
{
return null;
}
public function removeFile(FileData &$fileData): bool
{
return true;
}
public function removePathFromBucket(string $path, Bucket $bucket): bool
{
return true;
}
public function removeBucket(Bucket $bucket): bool
{
return true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment