diff options
author | devega <ma.devega@globunet.com> | 2019-04-03 13:07:58 +0200 |
---|---|---|
committer | devega <ma.devega@globunet.com> | 2019-04-03 13:07:58 +0200 |
commit | 320686abdd195a5637647536ba324dbbba7664b0 (patch) | |
tree | fd677147ceac122d0baa033f1f90022ada7a81c2 | |
parent | b082903077cb649cf5b81e74b69816afe6c36643 (diff) |
Creado el Bundle OpengnsysCoreBundle e implementado Auth2, Rest y User (entidades y configuración necesaria)
Actualizacion del command migration
Creado repositorio para algunas entidades
Actualizado el shell instalador
127 files changed, 3006 insertions, 1761 deletions
diff --git a/admin/WebConsole3/backend/README.md b/admin/WebConsole3/backend/README.md index b9db1c22..8ae3da18 100644 --- a/admin/WebConsole3/backend/README.md +++ b/admin/WebConsole3/backend/README.md @@ -11,4 +11,74 @@ php app/console doctrine:generate:entities Opengnsys/ServerBundle/Entity php app/console doctrine:schema:update --dump-sql // --force -php app/console doctrine:mapping:import --em og_1 --force OpengnsysMigrationBundle xml
\ No newline at end of file +php app/console doctrine:mapping:import --em og_1 --force OpengnsysMigrationBundle xml + + +- Es necesario instalar la extensión de PHP XML +sudo apt-get install php7.0-xml + + +php app/console doctrine:mapping:import --force MigrationBundle xml +###### USER ###### +// Crea un usuario: ususername / email / password +php bin/console fos:user:create testuser test@globunet.com password + +// Crea un usuario con el rol SUPER_ADMIN +php app/console fos:user:create admin --super-admin + +// Crea un usuario con el check ENABLE false +php app/console fos:user:create testuser --inactive + +// Activar o desactivar un usuario +php app/console fos:user:activate testuser +php app/console fos:user:deactivate testuser + +// Asigna / Desasigna Rol a un usuario +php app/console fos:user:promote testuser ROLE_ADMIN +php app/console fos:user:demote testuser ROLE_ADMIN + +// Asigna / Desasigna el rol SUPER_ADMIN a un usuario. +php app/console fos:user:promote testuser --super +php app/console fos:user:demote testuser --super + +// Cambia la contraseña a un usuario +php app/console fos:user:change-password testuser newp@ssword + + +###### AUTH 2 ###### +// Crear el id y secret del Auth2 +php app/console opengsys:oauth-server:client:create --redirect-uri="http://globunet.es/" --grant-type="authorization_code" --grant-type="password" --grant-type="refresh_token" --grant-type="token" --grant-type="client_credentials" + + +### TOKEN ### + +# grant-type="password" +.../oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=password&username=USERNAME&password=PASSWORD +# Autenticacion en una sola petición, añade las credenciales del clientes y del usuario. + +# grant-type="client_credentials" +.../oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=client_credentials +# Autenticacion en una sola petición, añade las credenciales del clientes. solo indicando el client_id y secret te devuelve el access_token + + +# grant-type="refresh_token" +.../oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=refresh_token&refresh_token=REFRESH_TOKEN +# Actualiza el access_token a partir de un refresh_token + +# grant-type="token" +.../oauth/v2/auth?client_id=CLIENT_ID&redirect_uri=URL&response_type=token +# Es igual que authorization_code pero en un solo paso. + + +# grant-type="authorization_code" +.../oauth/v2/token?client_id=CLIENT_ID&client_secret=CLIENT_SECRET&grant_type=authorization_code&code=CODE&redirect_uri=URL +// Autenticación de tercero (IDP). + +### AUTH ### +// Autenticar SSO para clientes de terceros. La URL es la definida en el redirect-uri permitido. + +.../oauth/v2/auth?client_id=CLIENT_ID&response_type=code&redirect_uri=URL +# Te devuelve un code para luego solicitar el token con grant-type="authorization_code". + +.../oauth/v2/auth?client_id=CLIENT_ID&response_type=token&redirect_uri=URL +# Te devuelve el token directamente en el GET de la petición. diff --git a/admin/WebConsole3/backend/app/AppKernel.php b/admin/WebConsole3/backend/app/AppKernel.php index b941aacd..480347f6 100644 --- a/admin/WebConsole3/backend/app/AppKernel.php +++ b/admin/WebConsole3/backend/app/AppKernel.php @@ -16,14 +16,11 @@ class AppKernel extends Kernel new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), + new Opengnsys\CoreBundle\OpengnsysCoreBundle('FOSUserBundle'), + new Opengnsys\MigrationBundle\OpengnsysMigrationBundle(), new Opengnsys\ServerBundle\OpengnsysServerBundle(), new Opengnsys\RepositoryBundle\OpengnsysRepositoryBundle(), - # Globunet - #new Globunet\CoreBundle\GlobunetCoreBundle(), - new Globunet\ApiBundle\GlobunetApiBundle(), - new Globunet\UserBundle\GlobunetUserBundle('FOSUserBundle'), - # FOS new FOS\RestBundle\FOSRestBundle(), new FOS\UserBundle\FOSUserBundle(), @@ -35,7 +32,7 @@ class AppKernel extends Kernel # Nelmio new Nelmio\ApiDocBundle\NelmioApiDocBundle(), new Nelmio\CorsBundle\NelmioCorsBundle(), - new Opengnsys\MigrationBundle\OpengnsysMigrationBundle(), + ); if (in_array($this->getEnvironment(), array('dev', 'test'), true)) { diff --git a/admin/WebConsole3/backend/app/config/config.yml b/admin/WebConsole3/backend/app/config/config.yml index 9408c532..6ea364af 100644 --- a/admin/WebConsole3/backend/app/config/config.yml +++ b/admin/WebConsole3/backend/app/config/config.yml @@ -1,8 +1,8 @@ imports: - { resource: parameters.yml } - # Globunet Feature Bundles - - { resource: globunet/config.yml } + # Opengnsys Feature Bundles + - { resource: opengnsys/config.yml } # JMS Feature Bundles - { resource: jms/config.yml } @@ -49,7 +49,7 @@ doctrine: connections: default: driver: '%database_driver%' - #server_version: '5.5' # your database server version here + server_version: '5.5' # your database server version here host: "%database_host%" port: "%database_port%" dbname: "%database_name%" @@ -61,6 +61,7 @@ doctrine: set: string og_1: driver: '%og_1_database_driver%' + server_version: '5.5' # your database server version here host: '%og_1_database_host%' port: '%og_1_database_port%' dbname: '%og_1_database_name%' @@ -80,7 +81,7 @@ doctrine: mappings: OpengnsysServerBundle: ~ OpengnsysRepositoryBundle: ~ - GlobunetUserBundle: ~ + OpengnsysCoreBundle: ~ FOSUserBundle: ~ FOSOAuthServerBundle: ~ #OpengnsysMigrationBundle: ~ @@ -109,6 +110,4 @@ monolog: type: stream level: debug path: '%kernel.logs_dir%/og_migration.log' - channels: [og_migration] -nelmio_api_doc: - name: Page Opengnsys API + channels: [og_migration]
\ No newline at end of file diff --git a/admin/WebConsole3/backend/app/config/globunet/config.yml b/admin/WebConsole3/backend/app/config/globunet/config.yml deleted file mode 100644 index b266d799..00000000 --- a/admin/WebConsole3/backend/app/config/globunet/config.yml +++ /dev/null @@ -1,12 +0,0 @@ -imports: - # GlobunetApi - - { resource: "@GlobunetApiBundle/Resources/config/config.yml" } - - # Globunet User - - { resource: "@GlobunetUserBundle/Resources/config/config.yml" } - - { resource: "@GlobunetUserBundle/Resources/config/parameters.yml" } - -parameters: - globunet_user__user_class: Opengnsys\ServerBundle\Entity\User - globunet_user__group_class: Opengnsys\ServerBundle\Entity\Group - globunet_user__provider_default: fos_user.user_provider.username
\ No newline at end of file diff --git a/admin/WebConsole3/backend/app/config/jms/config.yml b/admin/WebConsole3/backend/app/config/jms/config.yml index 04221db9..4820ff61 100644 --- a/admin/WebConsole3/backend/app/config/jms/config.yml +++ b/admin/WebConsole3/backend/app/config/jms/config.yml @@ -5,12 +5,12 @@ jms_serializer: default_timezone: "UTC" # defaults to whatever timezone set in php.ini or via date_default_timezone_set metadata: directories: - #GlobunetUserBundle: - # namespace_prefix: "Globunet\\UserBundle" - # path: "%kernel.root_dir%/../src/Globunet/UserBundle/Resources/config/serializer/GlobunetUserBundle" - #FOSUserBundle: - # namespace_prefix: "FOS\\UserBundle" - # path: "%kernel.root_dir%/../src/Globunet/UserBundle/Resources/config/serializer/FOSUserBundle" + OpengnsysCoreBundle: + namespace_prefix: "Opengnsys\\CoreBundle" + path: "%kernel.root_dir%/../src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle" + FOSUserBundle: + namespace_prefix: "FOS\\UserBundle" + path: "%kernel.root_dir%/../src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle" OpengnsysServerBundle: namespace_prefix: "Opengnsys\\ServerBundle" path: "%kernel.root_dir%/../src/Opengnsys/ServerBundle/Resources/config/serializer/OpengnsysServerBundle" diff --git a/admin/WebConsole3/backend/app/config/opengnsys/config.yml b/admin/WebConsole3/backend/app/config/opengnsys/config.yml new file mode 100644 index 00000000..ff6e6563 --- /dev/null +++ b/admin/WebConsole3/backend/app/config/opengnsys/config.yml @@ -0,0 +1,10 @@ +parameters: + path_client: "/opt/opengnsys/log/clients/" + path_images: "/opt/opengnsys/images/" + oglivecli: "/opt/opengnsys/bin/oglivecli" + pxedir: "/opt/opengnsys/tftpboot/menu.lst" + + +imports: + # OpengnsysCore + - { resource: "@OpengnsysCoreBundle/Resources/config/config.yml" }
\ No newline at end of file diff --git a/admin/WebConsole3/backend/app/config/parameters.yml.dist b/admin/WebConsole3/backend/app/config/parameters.yml.dist index 3ee1119e..4e9051b0 100644 --- a/admin/WebConsole3/backend/app/config/parameters.yml.dist +++ b/admin/WebConsole3/backend/app/config/parameters.yml.dist @@ -3,14 +3,14 @@ # http://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration parameters: database_driver: pdo_mysql - database_host: 127.0.0.1 + database_host: localhost database_port: ~ database_name: ogAdmBD3 database_user: u1consola1OG database_password: c1consola1OG og_1_database_driver: pdo_mysql - og_1_database_host: 127.0.0.1 + og_1_database_host: localhost og_1_database_port: 3606 og_1_database_name: "ogAdmBD" og_1_database_user: "u1consola1OG" @@ -18,14 +18,10 @@ parameters: mailer_transport: smtp mailer_host: 127.0.0.1 - mailer_user: ~ + mailer_user: no-reply@opengnsys.com mailer_password: ~ - mailer_sender_name: ~ + mailer_sender_name: Opengnsys # A secret key that's used to generate certain security-related tokens secret: ThisTokenIsNotSoSecretChangeIt - path_client: "/opt/opengnsys/log/clients/" - path_images: "/opt/opengnsys/images/" - oglivecli: "/opt/opengnsys/bin/oglivecli" - pxedir: "/opt/opengnsys/tftpboot/menu.lst"
\ No newline at end of file diff --git a/admin/WebConsole3/backend/app/config/routing.yml b/admin/WebConsole3/backend/app/config/routing.yml index 85e44971..d1a02c93 100644 --- a/admin/WebConsole3/backend/app/config/routing.yml +++ b/admin/WebConsole3/backend/app/config/routing.yml @@ -1,5 +1,5 @@ -opengnsys_migration: - resource: "@OpengnsysMigrationBundle/Resources/config/routing.yml" +opengnsys_core: + resource: "@OpengnsysCoreBundle/Resources/config/routing.yml" prefix: / opengnsys_server: @@ -10,21 +10,6 @@ opengnsys_repository: resource: "@OpengnsysRepositoryBundle/Resources/config/routing.yml" prefix: / - -#globunet_user: -# resource: "@GlobunetUserBundle/Resources/config/routing.yml" -# prefix: / - -# GlobunetUser Api -globunet_user_api: - resource: "@GlobunetUserBundle/Resources/config/routing_api.yml" - prefix: / - -# GlobunetUser OAuth -globunet_user_oauth: - resource: "@GlobunetUserBundle/Resources/config/routing_oauth.yml" - prefix: / - # Nelmio NelmioApiDocBundle: resource: "@NelmioApiDocBundle/Resources/config/routing.yml" diff --git a/admin/WebConsole3/backend/app/config/routing_dev.yml b/admin/WebConsole3/backend/app/config/routing_dev.yml index 531fa783..81f199a6 100644 --- a/admin/WebConsole3/backend/app/config/routing_dev.yml +++ b/admin/WebConsole3/backend/app/config/routing_dev.yml @@ -13,10 +13,10 @@ _errors: _main: resource: routing.yml -opengnsys_server: - resource: "@OpengnsysServerBundle/Resources/config/routing_dev.yml" - prefix: / +#opengnsys_server: +# resource: "@OpengnsysServerBundle/Resources/config/routing_dev.yml" +# prefix: / -opengnsys_repository: - resource: "@OpengnsysRepositoryBundle/Resources/config/routing_dev.yml" - prefix: / +#opengnsys_repository: +# resource: "@OpengnsysRepositoryBundle/Resources/config/routing_dev.yml" +# prefix: / diff --git a/admin/WebConsole3/backend/composer.json b/admin/WebConsole3/backend/composer.json index d97e44d4..7c5da3b8 100644 --- a/admin/WebConsole3/backend/composer.json +++ b/admin/WebConsole3/backend/composer.json @@ -21,9 +21,12 @@ "sensio/distribution-bundle": "~5.0", "sensio/framework-extra-bundle": "^3.0.2", "incenteev/composer-parameter-handler": "~2.0", - "globunet/core-bundle" : "dev-trunk", - "globunet/api-bundle" : "dev-trunk", - "globunet/user-bundle" : "dev-trunk" + "friendsofsymfony/user-bundle" : ">=1.3.3", + "friendsofsymfony/oauth-server-bundle" : ">=1.5.2", + "friendsofsymfony/rest-bundle" : "~2.0", + "jms/serializer-bundle" : "~2.0", + "nelmio/api-doc-bundle" : "~2.12.0", + "nelmio/cors-bundle" : "~1.5.0" }, "require-dev": { "doctrine/doctrine-fixtures-bundle": "^3.0", diff --git a/admin/WebConsole3/backend/composer.lock b/admin/WebConsole3/backend/composer.lock index 88bacc9f..8f50218e 100644 --- a/admin/WebConsole3/backend/composer.lock +++ b/admin/WebConsole3/backend/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "f522f9118aaec28a6838e59f257ad714", + "content-hash": "bb47c989d783013292749204f43c64f6", "packages": [ { "name": "composer/ca-bundle", @@ -64,16 +64,16 @@ }, { "name": "doctrine/annotations", - "version": "v1.6.0", + "version": "v1.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5" + "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", - "reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/53120e0eb10355388d6ccbe462f1fea34ddadb24", + "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24", "shasum": "" }, "require": { @@ -128,7 +128,7 @@ "docblock", "parser" ], - "time": "2017-12-06T07:11:42+00:00" + "time": "2019-03-25T19:12:02+00:00" }, { "name": "doctrine/cache", @@ -207,34 +207,36 @@ }, { "name": "doctrine/collections", - "version": "v1.5.0", + "version": "v1.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/collections.git", - "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf" + "reference": "d2ae4ef05e25197343b6a39bae1d3c427a2f6956" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/collections/zipball/a01ee38fcd999f34d9bfbcee59dbda5105449cbf", - "reference": "a01ee38fcd999f34d9bfbcee59dbda5105449cbf", + "url": "https://api.github.com/repos/doctrine/collections/zipball/d2ae4ef05e25197343b6a39bae1d3c427a2f6956", + "reference": "d2ae4ef05e25197343b6a39bae1d3c427a2f6956", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1.3" }, "require-dev": { - "doctrine/coding-standard": "~0.1@dev", - "phpunit/phpunit": "^5.7" + "doctrine/coding-standard": "^6.0", + "phpstan/phpstan-shim": "^0.9.2", + "phpunit/phpunit": "^7.0", + "vimeo/psalm": "^3.2.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Collections\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Collections\\": "lib/Doctrine/Common/Collections" } }, "notification-url": "https://packagist.org/downloads/", @@ -263,14 +265,15 @@ "email": "schmittjoh@gmail.com" } ], - "description": "Collections Abstraction library", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.", + "homepage": "https://www.doctrine-project.org/projects/collections.html", "keywords": [ "array", "collections", - "iterator" + "iterators", + "php" ], - "time": "2017-07-22T10:37:32+00:00" + "time": "2019-03-25T19:03:48+00:00" }, { "name": "doctrine/common", @@ -754,27 +757,29 @@ }, { "name": "doctrine/instantiator", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + "reference": "a2c590166b2133a4633738648b6b064edae0814a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", - "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", + "reference": "a2c590166b2133a4633738648b6b064edae0814a", "shasum": "" }, "require": { "php": "^7.1" }, "require-dev": { - "athletic/athletic": "~0.1.8", + "doctrine/coding-standard": "^6.0", "ext-pdo": "*", "ext-phar": "*", - "phpunit/phpunit": "^6.2.3", - "squizlabs/php_codesniffer": "^3.0.2" + "phpbench/phpbench": "^0.13", + "phpstan/phpstan-phpunit": "^0.11", + "phpstan/phpstan-shim": "^0.11", + "phpunit/phpunit": "^7.0" }, "type": "library", "extra": { @@ -799,12 +804,12 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", "keywords": [ "constructor", "instantiate" ], - "time": "2017-07-22T11:58:36+00:00" + "time": "2019-03-17T17:37:11+00:00" }, { "name": "doctrine/lexer", @@ -1472,14 +1477,15 @@ }, { "name": "globunet/api-bundle", - "version": "dev-trunk", + "version": "dev-master", "source": { - "type": "svn", - "url": "https://bundles.globunet.com/bundles/api", - "reference": "/trunk/globunetApi/src/Globunet/ApiBundle/@66" + "type": "git", + "url": "https://gitlab.globunet.com/globunet/symfony-bundle/api.git", + "reference": "5a587fbf997c04572aed6e99f7976212dd16e0b9" }, "require": { "friendsofsymfony/rest-bundle": "~2.0", + "globunet/core-bundle": "dev-master", "jms/serializer-bundle": "~2.0", "nelmio/api-doc-bundle": "~2.12.0", "nelmio/cors-bundle": "~1.5.0", @@ -1516,15 +1522,15 @@ "keywords": [ "globunet api" ], - "time": "2019-02-13T17:38:30+00:00" + "time": "2019-04-02T17:36:46+00:00" }, { "name": "globunet/core-bundle", - "version": "dev-trunk", + "version": "dev-master", "source": { - "type": "svn", - "url": "https://bundles.globunet.com/bundles/core", - "reference": "/trunk/globunetCore/src/Globunet/CoreBundle/@65" + "type": "git", + "url": "https://gitlab.globunet.com/globunet/symfony-bundle/core.git", + "reference": "2b1f07e9feef6222dfcc0c520716b069c8290af9" }, "require": { "php": ">=5.5.9" @@ -1560,19 +1566,20 @@ "keywords": [ "globunet core" ], - "time": "2019-02-14T00:16:11+00:00" + "time": "2019-03-26T20:25:25+00:00" }, { "name": "globunet/user-bundle", - "version": "dev-trunk", + "version": "dev-master", "source": { - "type": "svn", - "url": "https://bundles.globunet.com/bundles/user", - "reference": "/trunk/globunetUser/src/Globunet/UserBundle/@276" + "type": "git", + "url": "https://gitlab.globunet.com/globunet/symfony-bundle/user.git", + "reference": "8c7ff1fcfc4567daa31f06a2cf21e0d0f6999cc5" }, "require": { "friendsofsymfony/oauth-server-bundle": ">=1.5.2", "friendsofsymfony/user-bundle": ">=1.3.3", + "globunet/core-bundle": "dev-master", "php": ">=7.0.0" }, "type": "symfony-bundle", @@ -1606,7 +1613,7 @@ "keywords": [ "globunet user" ], - "time": "2019-02-07T08:50:19+00:00" + "time": "2019-03-31T00:10:08+00:00" }, { "name": "incenteev/composer-parameter-handler", @@ -1885,16 +1892,16 @@ }, { "name": "jms/serializer-bundle", - "version": "2.4.3", + "version": "2.4.4", "source": { "type": "git", "url": "https://github.com/schmittjoh/JMSSerializerBundle.git", - "reference": "e5231652ce24b8673b2ac70bc76b0cabaf35deea" + "reference": "92ee808c64c1c180775a0e57d00e3be0674668fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/JMSSerializerBundle/zipball/e5231652ce24b8673b2ac70bc76b0cabaf35deea", - "reference": "e5231652ce24b8673b2ac70bc76b0cabaf35deea", + "url": "https://api.github.com/repos/schmittjoh/JMSSerializerBundle/zipball/92ee808c64c1c180775a0e57d00e3be0674668fb", + "reference": "92ee808c64c1c180775a0e57d00e3be0674668fb", "shasum": "" }, "require": { @@ -1955,7 +1962,7 @@ "serialization", "xml" ], - "time": "2018-12-09T07:52:19+00:00" + "time": "2019-03-30T10:26:09+00:00" }, { "name": "michelf/php-markdown", @@ -2168,16 +2175,16 @@ }, { "name": "nelmio/cors-bundle", - "version": "1.5.4", + "version": "1.5.5", "source": { "type": "git", "url": "https://github.com/nelmio/NelmioCorsBundle.git", - "reference": "548dc8ebd3984acd2f6d8787ab1dac2e9aa14254" + "reference": "adabee944e6fe52ee566caf1770a29355b1e8d83" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/548dc8ebd3984acd2f6d8787ab1dac2e9aa14254", - "reference": "548dc8ebd3984acd2f6d8787ab1dac2e9aa14254", + "url": "https://api.github.com/repos/nelmio/NelmioCorsBundle/zipball/adabee944e6fe52ee566caf1770a29355b1e8d83", + "reference": "adabee944e6fe52ee566caf1770a29355b1e8d83", "shasum": "" }, "require": { @@ -2222,7 +2229,7 @@ "cors", "crossdomain" ], - "time": "2017-12-11T18:41:54+00:00" + "time": "2019-02-27T13:13:15+00:00" }, { "name": "paragonie/random_compat", @@ -2897,16 +2904,16 @@ }, { "name": "symfony/polyfill-apcu", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-apcu.git", - "reference": "19e1b73bf255265ad0b568f81766ae2a3266d8d2" + "reference": "a502face1da6a53289480166f24de2c3c68e5c3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/19e1b73bf255265ad0b568f81766ae2a3266d8d2", - "reference": "19e1b73bf255265ad0b568f81766ae2a3266d8d2", + "url": "https://api.github.com/repos/symfony/polyfill-apcu/zipball/a502face1da6a53289480166f24de2c3c68e5c3c", + "reference": "a502face1da6a53289480166f24de2c3c68e5c3c", "shasum": "" }, "require": { @@ -2915,7 +2922,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2949,20 +2956,20 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" + "reference": "82ebae02209c21113908c229e9883c419720738a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a", + "reference": "82ebae02209c21113908c229e9883c419720738a", "shasum": "" }, "require": { @@ -2974,7 +2981,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -2996,7 +3003,7 @@ }, { "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" + "email": "backendtea@gmail.com" } ], "description": "Symfony polyfill for ctype functions", @@ -3007,20 +3014,20 @@ "polyfill", "portable" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-intl-icu", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-icu.git", - "reference": "f22a90256d577c7ef7efad8df1f0201663d57644" + "reference": "999878a3a09d73cae157b0cf89bb6fb2cc073057" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/f22a90256d577c7ef7efad8df1f0201663d57644", - "reference": "f22a90256d577c7ef7efad8df1f0201663d57644", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/999878a3a09d73cae157b0cf89bb6fb2cc073057", + "reference": "999878a3a09d73cae157b0cf89bb6fb2cc073057", "shasum": "" }, "require": { @@ -3065,20 +3072,20 @@ "portable", "shim" ], - "time": "2018-08-06T14:22:27+00:00" + "time": "2019-01-07T19:39:47+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", - "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609", + "reference": "fe5e94c604826c35a32fa832f35bd036b6799609", "shasum": "" }, "require": { @@ -3090,7 +3097,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -3124,20 +3131,20 @@ "portable", "shim" ], - "time": "2018-09-21T13:07:52+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-php56", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php56.git", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af" + "reference": "f4dddbc5c3471e1b700a147a20ae17cdb72dbe42" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af", - "reference": "ff208829fe1aa48ab9af356992bb7199fed551af", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/f4dddbc5c3471e1b700a147a20ae17cdb72dbe42", + "reference": "f4dddbc5c3471e1b700a147a20ae17cdb72dbe42", "shasum": "" }, "require": { @@ -3147,7 +3154,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -3180,20 +3187,20 @@ "portable", "shim" ], - "time": "2018-09-21T06:26:08+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-php70", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php70.git", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" + "reference": "bc4858fb611bda58719124ca079baff854149c89" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", - "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/bc4858fb611bda58719124ca079baff854149c89", + "reference": "bc4858fb611bda58719124ca079baff854149c89", "shasum": "" }, "require": { @@ -3203,7 +3210,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -3239,20 +3246,20 @@ "portable", "shim" ], - "time": "2018-09-21T06:26:08+00:00" + "time": "2019-02-06T07:57:58+00:00" }, { "name": "symfony/polyfill-util", - "version": "v1.10.0", + "version": "v1.11.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-util.git", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c" + "reference": "b46c6cae28a3106735323f00a0c38eccf2328897" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c", - "reference": "3b58903eae668d348a7126f999b0da0f2f93611c", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/b46c6cae28a3106735323f00a0c38eccf2328897", + "reference": "b46c6cae28a3106735323f00a0c38eccf2328897", "shasum": "" }, "require": { @@ -3261,7 +3268,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.9-dev" + "dev-master": "1.11-dev" } }, "autoload": { @@ -3291,7 +3298,7 @@ "polyfill", "shim" ], - "time": "2018-09-30T16:36:12+00:00" + "time": "2019-02-08T14:16:39+00:00" }, { "name": "symfony/swiftmailer-bundle", @@ -3354,16 +3361,16 @@ }, { "name": "symfony/symfony", - "version": "v3.4.22", + "version": "v3.4.24", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "907d4d1d1a419663c3c37cfb33dd65c48fa62d1b" + "reference": "4783969de06e5b8787b5e3ad2279f6b8aceeb81b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/907d4d1d1a419663c3c37cfb33dd65c48fa62d1b", - "reference": "907d4d1d1a419663c3c37cfb33dd65c48fa62d1b", + "url": "https://api.github.com/repos/symfony/symfony/zipball/4783969de06e5b8787b5e3ad2279f6b8aceeb81b", + "reference": "4783969de06e5b8787b5e3ad2279f6b8aceeb81b", "shasum": "" }, "require": { @@ -3505,20 +3512,20 @@ "keywords": [ "framework" ], - "time": "2019-02-03T12:23:08+00:00" + "time": "2019-04-02T13:48:13+00:00" }, { "name": "twig/twig", - "version": "v2.6.2", + "version": "v2.7.4", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "7d7342c8a4059fefb9b8d07db0cc14007021f9b7" + "reference": "ed9c49220e09bfaeb1ba4d48077c08a7b09908dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/7d7342c8a4059fefb9b8d07db0cc14007021f9b7", - "reference": "7d7342c8a4059fefb9b8d07db0cc14007021f9b7", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ed9c49220e09bfaeb1ba4d48077c08a7b09908dd", + "reference": "ed9c49220e09bfaeb1ba4d48077c08a7b09908dd", "shasum": "" }, "require": { @@ -3534,7 +3541,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.7-dev" } }, "autoload": { @@ -3572,7 +3579,7 @@ "keywords": [ "templating" ], - "time": "2019-01-14T15:00:48+00:00" + "time": "2019-03-23T14:28:58+00:00" }, { "name": "willdurand/jsonp-callback-validator", diff --git a/admin/WebConsole3/backend/install.txt b/admin/WebConsole3/backend/install.txt deleted file mode 100644 index cb30a501..00000000 --- a/admin/WebConsole3/backend/install.txt +++ /dev/null @@ -1,6 +0,0 @@ -- Es necesario instalar la extensión de PHP XML -sudo apt-get install php7.0-xml - - - -php app/console doctrine:mapping:import --force MigrationBundle xml
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Command/CreateClientCommand.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Command/CreateClientCommand.php new file mode 100644 index 00000000..687476c0 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Command/CreateClientCommand.php @@ -0,0 +1,57 @@ +<?php + +namespace Opengnsys\CoreBundle\Command; + +use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; +//use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class CreateClientCommand extends ContainerAwareCommand +{ + protected function configure() + { + $this + ->setName('opengnsys:oauth-server:client:create') + ->setDescription('Creates a new client') + ->addOption( + 'redirect-uri', + null, + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'Sets redirect uri for client. Use this option multiple times to set multiple redirect URIs.', + null + ) + ->addOption( + 'grant-type', + null, + InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, + 'Sets allowed grant type for client. Use this option multiple times to set multiple grant types..', + null + ) + ->setHelp( + <<<EOT + The <info>%command.name%</info>command creates a new client. + +<info>php %command.full_name% [--redirect-uri=...] [--grant-type=...] name</info> + +EOT + ); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default'); + $client = $clientManager->createClient(); + $client->setRedirectUris($input->getOption('redirect-uri')); + $client->setAllowedGrantTypes($input->getOption('grant-type')); + $clientManager->updateClient($client); + $output->writeln( + sprintf( + 'Added a new client with public id <info>%s</info>, secret <info>%s</info>', + $client->getPublicId(), + $client->getSecret() + ) + ); + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/Api/UserController.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/Api/UserController.php new file mode 100644 index 00000000..6698de0a --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/Api/UserController.php @@ -0,0 +1,293 @@ +<?php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Miguel Angel de Vega on 18/03/16. <miguelangel.devega@sic.com> + * Copyright (c) 2015 Opengnsys. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Controller\Api; + +use Symfony\Component\Security\Core\Exception\AccessDeniedException; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Form\FormTypeInterface; +use FOS\RestBundle\Controller\Annotations; +use FOS\RestBundle\Controller\Annotations\RouteResource; +use FOS\RestBundle\View\View; +use FOS\RestBundle\Request\ParamFetcherInterface; +use Nelmio\ApiDocBundle\Annotation\ApiDoc; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Form\Type\Api\UserFormType; + +/** + * @RouteResource("User") + */ +class UserController extends ApiController +{ + + /** + * Options a User from the submitted data. + * + * @ApiDoc( + * resource = true, + * description = "Options User", + * ) + * + * @param Request $request the request object + * + * @return Response + */ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); + $array = array(); + $array['class'] = UserFormType::class; + $array['options'] = array(); + + $options = $this->container->get('nelmio_api_doc.parser.form_type_parser')->parse($array); + return $options; + } + + /** + * List all User. + * + * @ApiDoc( + * resource = true, + * statusCodes = { + * 200 = "Returned when successful" + * } + * ) + * + * @Annotations\QueryParam(name="offset", requirements="\d+", nullable=true, description="Offset from which to start listing objects.") + * @Annotations\QueryParam(name="limit", requirements="\d+", nullable=true, description="How many objects to return.") + * + * @Annotations\View(templateVar="User", serializerGroups={"opengnsys_server__user_cget"}) + * + * @param Request $request the request object + * @param ParamFetcherInterface $paramFetcher param fetcher service + * + * @return array + */ + public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) + { + $request->setRequestFormat($request->get('_format')); + $offset = $paramFetcher->get('offset'); + $offset = null == $offset ? 0 : $offset; + $limit = $paramFetcher->get('limit'); + + $matching = $this->filterCriteria($paramFetcher); + + $objects = $this->container->get('opengnsys_core.user_manager')->searchBy($limit, $offset, $matching); + + return $objects; + } + + /** + * Get single User. + * + * @ApiDoc( + * resource = true, + * description = "Gets a User for a given id", + * output = "Opengnsys\ServerBundle\Entity\User", + * statusCodes = { + * 200 = "Returned when successful", + * 404 = "Returned when the user is not found" + * } + * ) + * + * @Annotations\View(templateVar="user", serializerGroups={"opengnsys_server__user_get"}) + * + * @param int $slug the user id + * + * @return array + * + * @throws NotFoundHttpException when user not exist + */ + public function getAction(Request $request, $slug) + { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); + + return $object; + } + + /** + * Create a User from the submitted data. + * + * @ApiDoc( + * resource = true, + * description = "Creates a new object from the submitted data.", + * input = {"class" = "Opengnsys\CoreBundle\Form\Type\UserFormType", "name" = ""}, + * statusCodes = { + * 200 = "Returned when successful", + * 400 = "Returned when the form has errors" + * } + * ) + * + * @Annotations\View( + * template = "object", + * serializerGroups={"opengnsys_server__user_get"}, + * statusCode = Response::HTTP_CREATED + * ) + * + * @param Request $request the request object + * + * @return FormTypeInterface|View + */ + public function cpostAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); + try { + $object = $this->container->get('opengnsys_core.user_manager')->post( + $request->request->all() + ); + + /* + if (is_object($this->getUser())) + { + $admin = $this->container->get('globunet_api.admin.object'); + $admin->createObjectSecurity($object); + } + */ + + return $object; + + } catch (InvalidFormException $exception) { + + return $exception->getForm(); + } + } + + /** + * Update existing User from the submitted data or create a new User at a specific location. + * + * @ApiDoc( + * resource = true, + * input = {"class" = "Opengnsys\CoreBundle\Form\Type\UserFormType", "name" = ""}, + * statusCodes = { + * 204 = "Returned when successful", + * 400 = "Returned when the form has errors" + * } + * ) + * + * @Annotations\View( + * template = "object", + * serializerGroups={"opengnsys_server__user_get"}, + * statusCode = Response::HTTP_OK + * ) + * + * @param Request $request the request object + * @param int $slug the user id + * + * @return FormTypeInterface|View + * + * @throws NotFoundHttpException when User not exist + */ + public function patchAction(Request $request, $slug) + { + $request->setRequestFormat($request->get('_format')); + try { + $object = $this->container->get('opengnsys_core.user_manager')->patch( + $this->getOr404($slug), + $request->request->all() + ); + + return $object; + + } catch (InvalidFormException $exception) { + + return $exception->getForm(); + } + } + + /** + * Delete single User. + * + * @ApiDoc( + * resource = true, + * description = "Delete a User for a given id", + * output = "Opengnsys\ServerBundle\Entity\User", + * statusCodes = { + * 200 = "Returned when successful", + * 404 = "Returned when the user is not found" + * } + * ) + * + * @Annotations\View(templateVar="delete") + * + * @param int $slug the object id + * + * @return array + * + * @throws NotFoundHttpException when object not exist + */ + public function deleteAction(Request $request, $slug) + { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); + $object = $this->container->get('opengnsys_core.user_manager')->delete($object); + + return $this->view(null, Response::HTTP_NO_CONTENT); + } + + /** + * Fetch a User or throw an 404 Exception. + * + * @param mixed $slug + * + * @return User + * + * @throws NotFoundHttpException + */ + protected function getOr404($slug) + { + if (!($object = $this->container->get('opengnsys_core.user_manager')->get($slug))) { + throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); + } + + return $object; + } + + /** + * + * @Annotations\View(templateVar="users", serializerGroups={"opengnsys_server__user_me"}) + * + * @ApiDoc(resource = true) + */ + public function getMeAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); + + try{ + /* + if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) { + throw new AccessDeniedException(); + } + */ + $this->forwardIfNotAuthenticated(); + $response = $this->getUser(); + + //$this->get('logger')->error(var_export($response,true)); + }catch(AccessDeniedException $ade){ + $response = new Response($ade->getMessage(), $ade->getCode()); + } + + return $response; + } + + /** + * Shortcut to throw a AccessDeniedException($message) if the user is not authenticated + * @param String $message The message to display (default:'warn.user.notAuthenticated') + */ + protected function forwardIfNotAuthenticated($message='warn.user.notAuthenticated'){ + if (!is_object($this->getUser())) + { + throw new AccessDeniedException($message); + } + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/ApiController.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/ApiController.php new file mode 100644 index 00000000..87d430e2 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/ApiController.php @@ -0,0 +1,45 @@ +<?php + +namespace Opengnsys\CoreBundle\Controller; + +use FOS\RestBundle\Controller\FOSRestController; +use FOS\RestBundle\Routing\ClassResourceInterface; +use FOS\RestBundle\Request\ParamFetcherInterface; + +use Symfony\Component\DependencyInjection\ContainerInterface; + +class ApiController extends FOSRestController implements ClassResourceInterface +{ + /** + * Constructor + */ + public function __construct(ContainerInterface $container = null){ + $this->container = $container; + } + + /** + * Filters criteria from $paramFetcher to be compatible with the Pager criteria. + * + * @param ParamFetcherInterface $paramFetcher + * + * @return array The filtered criteria + */ + protected function filterCriteria(ParamFetcherInterface $paramFetcher) + { + $criteria = $paramFetcher->all(); + + unset($criteria['offset'], $criteria['limit']); + + foreach ($criteria as $key => $value) { + if (null === $value) { + unset($criteria[$key]); + }else if($key == "fromDate" || $key == "toDate" || $key == "startDate" || $key == "endDate" ){ + $criteria[$key] = null == $value ? null : new \DateTime($value); + } + + } + + return $criteria; + } + +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/SecurityOAuthController.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/SecurityOAuthController.php new file mode 100644 index 00000000..0b18ffb6 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Controller/SecurityOAuthController.php @@ -0,0 +1,48 @@ +<?php + +namespace Opengnsys\CoreBundle\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\Security\Core\Security; + +class SecurityOAuthController extends Controller +{ + public function loginAction(Request $request) + { + $session = $request->getSession(); + + $authErrorKey = Security::AUTHENTICATION_ERROR; + $lastUsernameKey = Security::LAST_USERNAME; + + // get the error if any (works with forward and redirect -- see below) + if ($request->attributes->has($authErrorKey)) { + $error = $request->attributes->get($authErrorKey); + } elseif (null !== $session && $session->has($authErrorKey)) { + $error = $session->get($authErrorKey); + $session->remove($authErrorKey); + } else { + $error = null; + } + + if (!$error instanceof AuthenticationException) { + $error = null; // The value does not come from the security component. + } + + // last username entered by the user + $lastUsername = (null === $session) ? '' : $session->get($lastUsernameKey); + + return $this->render( + 'GlobunetUserBundle:Security:loginOAuth.html.twig', + array( + 'last_username' => $lastUsername, + 'error' => $error, + ) + ); + } + + public function loginCheckAction(Request $request) + { + + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelExtendedManager.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelExtendedManager.php new file mode 100644 index 00000000..1cc916bd --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelExtendedManager.php @@ -0,0 +1,165 @@ +<?php + +/* + * This file is part of the Globunet Project package. + * + * Created by Globunet on 15/03/19. <info@globunet.com> + * Copyright (c) 2015 Globunet Soluciones Tecnológicas, SL. All rights reserved. + * + */ +namespace Opengnsys\CoreBundle\Domain; + +use Doctrine\ORM\EntityManager; +use Symfony\Component\Form\FormFactoryInterface; +use Opengnsys\CoreBundle\Exception\InvalidFormException; + +class ModelExtendedManager extends ModelManager +{ + protected $formFactory; + protected $formTypeClass; + protected $form; + + public function __construct(EntityManager $entityManager, FormFactoryInterface $formFactory = null, $formTypeClass = null, $objectClass = null) + { + parent::__construct($entityManager, $objectClass); + + $this->formFactory = $formFactory; + $this->formTypeClass = $formTypeClass; + $this->form = null; + } + + /** + * Create a new object. + * + * @param array $parameters + * + * @return object + */ + public function post(array $parameters, $flush = true, $validationGroup = null) + { + $object = $this->create(); + + return $this->persistForm($object, $parameters, 'POST', $flush, $validationGroup); + } + + /** + * Create a new object. + * + * @param array $parameters + * + * @return object + */ + public function cpost(array $parameters) + { + foreach($parameters as $params) { + $object = $this->create(); + $this->persistForm($object, $params, 'POST', false); + } + $this->entityManager->flush(); + return null; + } + + /** + * Edit a object. + * + * @param $object + * @param array $parameters + * + * @return object + */ + public function put($object, array $parameters, $flush = true, $validationGroup = null) + { + return $this->persistForm($object, $parameters, 'PUT', $flush, $validationGroup); + } + + /** + * Partially update a object. + * + * @param $object + * @param array $parameters + * + * @return object + */ + public function patch($object, array $parameters, $flush = true, $validationGroup = null) + { + return $this->persistForm($object, $parameters, 'PATCH', $flush, $validationGroup); + } + + /** + * Persist the Data by form. + * + * @param $object + * @param array $parameters + * @param String $method + * + * @return object + * + * @throws \Globunet\UserBundle\Exception\InvalidFormException + */ + public function persistForm($object, array $parameters, $method = "PUT", $flush = true, $validationGroup = null) + { + if($validationGroup == null){ + if($method === 'POST'){ + $validationGroup = 'creation'; + }else if($method === 'PUT' || $method === 'PATCH'){ + $validationGroup = 'edition'; + }else{ + $validationGroup = ""; + } + } + + $object = $this->processForm($object, $parameters, 'PATCH', $validationGroup); + + if($validationGroup === 'creation'){ + $this->prePersist($object); + }else if($validationGroup === 'edition'){ + $this->preUpdate($object); + } + + $this->persist($object, $flush); + + if($validationGroup === 'creation'){ + $this->postPersist($object); + }else if($validationGroup === 'edition'){ + $this->postUpdate($object); + } + + return $object; + } + + /** + * Processes the form. + * + * @param $object + * @param array $parameters + * @param String $method + * + * @return object + * + * @throws \Globunet\UserBundle\Exception\InvalidFormException + */ + public function processForm($object, array $parameters, $method = "PUT", $validationGroup = "") + { + $this->preProccessForm($parameters, $method, $validationGroup); + + $this->form = $this->formFactory->create($this->formTypeClass, $object, array('method' => $method, 'validation_groups'=>$validationGroup, 'csrf_protection' => false, 'allow_extra_fields' => true,)); + $this->form->submit($parameters, 'PATCH' !== $method); + if ($this->form->isValid()) { + $object = $this->form->getData(); + return $object; + } + + throw new InvalidFormException('Invalid submitted data', $this->form); + } + + public function getForm(){ + return $this->form; + } + + /** + * {@inheritdoc} + */ + public function preProccessForm(&$parameters, $method = "PUT", $validationGroup = "") + { + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelManager.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelManager.php new file mode 100644 index 00000000..7cb2c2d0 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Domain/ModelManager.php @@ -0,0 +1,205 @@ +<?php + +/* + * This file is part of the Globunet Project package. + * + * Created by Globunet on 16/04/16. <info@globunet.com> + * Copyright (c) 2015 Globunet Soluciones Tecnológicas, SL. All rights reserved. + * + */ +namespace Opengnsys\CoreBundle\Domain; + +use Doctrine\ORM\EntityManager; + +class ModelManager +{ + const ID_SEPARATOR = ';'; + + protected $entityManager; + protected $repository; + protected $objectClass; + + + public function __construct(EntityManager $entityManager, $objectClass = null) + { + $this->entityManager = $entityManager; + $this->objectClass = $objectClass; + if($objectClass != null){ + $this->repository = $this->entityManager->getRepository($objectClass); + } + } + + public function getClass(){ + /* + if (false !== strpos($this->objectClass, ':')) { + $metadata = $this->entityManager->getClassMetadata($this->objectClass); + $this->class = $metadata->getName(); + } + */ + + return $this->objectClass; + } + + public function getRepository(){ + return $this->repository; + } + + /** + * Get structure medatada + */ + public function getMetadata() + { + return $this->entityManager->getMetadataFactory()->getMetadataFor($this->objectClass); + } + + /** + * {@inheritdoc} + */ + public function getExportFields($class) + { + $metadata = $this->entityManager->getClassMetadata($class); + + return $metadata->getFieldNames(); + } + + /** + * {@inheritdoc} + */ + public function getModelInstance($class) + { + $r = new \ReflectionClass($class); + if ($r->isAbstract()) { + throw new \RuntimeException(sprintf('Cannot initialize abstract class: %s', $class)); + } + + return new $class(); + } + + /** + * Get a object. + * + * @param mixed $id + * + * @return object + */ + public function get($id) + { + return $this->repository->find($id); + } + + /** + * Get a list of objects. + * + * @param int $limit the limit of the result + * @param int $offset starting from the offset + * + * @return array + */ + public function searchBy($limit, $offset = 0, $matching = array(), $ordered = array()) + { + //return $this->repository->findBy($matching, $ordered, $limit, $offset); + return $this->repository->searchBy($matching, $ordered, $limit, $offset); + } + + /** + * Get a one object. + * + * + * @return object + */ + public function searchOneBy($matching = array()) + { + //return $this->repository->findOneBy($matching); + return $this->repository->searchOneBy($matching); + } + + public function create() + { + return new $this->objectClass(); + } + + /** + * Delete a object. + * + * @param $object + * @param array $parameters + * + * @return object + */ + public function delete($object, $flush = true) + { + $this->preRemove($object); + $this->entityManager->remove($object); + if($flush){ + $this->entityManager->flush(); + } + $this->postRemove($object); + } + + /** + * Persist a object. + * + * @param $object + * @param array $parameters + * + * @return object + */ + public function persist($object, $flush = true) + { + $this->prePersist($object); + $this->entityManager->persist($object); + if($flush){ + $this->entityManager->flush(); + } + $this->postPersist($object); + } + + /** + * {@inheritdoc} + */ + public function preValidate($object) + { + } + + /** + * {@inheritdoc} + */ + public function preUpdate($object) + { + } + + /** + * {@inheritdoc} + */ + public function postUpdate($object) + { + } + + /** + * {@inheritdoc} + */ + public function prePersist($object) + { + } + + /** + * {@inheritdoc} + */ + public function postPersist($object) + { + } + + /** + * {@inheritdoc} + */ + public function preRemove($object) + { + } + + /** + * {@inheritdoc} + */ + public function postRemove($object) + { + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AccessToken.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AccessToken.php new file mode 100644 index 00000000..ddf89dc8 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AccessToken.php @@ -0,0 +1,24 @@ +<?php +// src/Opengnsys/CoreBundle/Entity/AccessToken.php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 20/10/15. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\OAuthServerBundle\Entity\AccessToken as BaseAccessToken; + +class AccessToken extends BaseAccessToken +{ + + protected $id; + + protected $client; + + protected $user; +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AuthCode.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AuthCode.php new file mode 100644 index 00000000..2fdb336f --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/AuthCode.php @@ -0,0 +1,23 @@ +<?php +// src/Opengnsys/CoreBundle/Entity/AuthCode.php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 20/10/15. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\OAuthServerBundle\Entity\AuthCode as BaseAuthCode; + +class AuthCode extends BaseAuthCode +{ + protected $id; + + protected $client; + + protected $user; +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Client.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Client.php new file mode 100644 index 00000000..9117dc5d --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Client.php @@ -0,0 +1,76 @@ +<?php +// src/Opengnsys/CoreBundle/Entity/Client.php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 20/10/15. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\OAuthServerBundle\Entity\Client as BaseClient; + +class Client extends BaseClient +{ + + protected $id; + + /** + * @var string + */ + protected $name; + + /** + * @var string + */ + protected $description; + + public function __construct() + { + parent::__construct(); + // your own logic + } + + /** + * + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * + * @return null|string + */ + public function getName() + { + return $this->name; + } + + /** + * + * @param string $name + */ + public function setDescription($description) + { + $this->description = $description; + + return $this; + } + + /** + * + * @return null|string + */ + public function getDescription() + { + return $this->description; + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/DBAL/EnumType.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/DBAL/EnumType.php new file mode 100644 index 00000000..0842ae5a --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/DBAL/EnumType.php @@ -0,0 +1,43 @@ +<?php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 27/009/16. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity\DBAL; + +use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Platforms\AbstractPlatform; + +abstract class EnumType extends Type +{ + protected $name; + protected $values = array(); + + public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform) + { + return "varchar(40)"; + } + + public function convertToPHPValue($value, AbstractPlatform $platform) + { + return $value; + } + + public function convertToDatabaseValue($value, AbstractPlatform $platform) + { + if ($value != null && !in_array($value, $this->values)) { + throw new \InvalidArgumentException("Invalid '".$this->name."' value: ".$value."."); + } + return $value; + } + + public function getName() + { + return $this->name; + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Group.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Group.php new file mode 100644 index 00000000..274d1dcc --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Group.php @@ -0,0 +1,27 @@ +<?php + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\UserBundle\Model\Group as FOSBaseGroup; +use FOS\UserBundle\Model\GroupInterface as FOSGroupInterface; + +/** + * Group + */ +class Group extends FOSBaseGroup implements FOSGroupInterface +{ + public function __construct() + { + parent::__construct("", array()); + } + + /** + * Represents a string representation + * + * @return string + */ + public function __toString() + { + return $this->getName() ?: ''; + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/RefreshToken.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/RefreshToken.php new file mode 100644 index 00000000..c8fe519d --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/RefreshToken.php @@ -0,0 +1,23 @@ +<?php +// src/Acme/CoreBundle/Entity/RefreshToken.php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 20/10/15. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\OAuthServerBundle\Entity\RefreshToken as BaseRefreshToken; + +class RefreshToken extends BaseRefreshToken +{ + protected $id; + + protected $client; + + protected $user; +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/BaseRepository.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/BaseRepository.php new file mode 100644 index 00000000..b184374d --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/BaseRepository.php @@ -0,0 +1,215 @@ +<?php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 01/10/18. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity\Repository; + +class BaseRepository extends \Doctrine\ORM\EntityRepository +{ + public function findByObservable($term = "", $limit = null, $offset = null, $ordered = array(), $selects = array(), $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + $qb = $this->createSelect($qb, $selects); + + $qb = $this->createSearch($qb, $term, $searchs); + + $qb = $this->createMaching($qb, $matching); + + $qb = $this->createOrdered($qb, $ordered); + + if($limit != null){ + $qb->setMaxResults($limit); + } + + if($offset){ + $qb->setFirstResult($offset); + } + + $entities = $qb->getQuery()->getScalarResult(); + return $entities; + } + + public function countFiltered($term = "", $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + $qb->select("count(DISTINCT o.id)"); + + $qb = $this->createSearch($qb, $term, $searchs); + + $qb = $this->createMaching($qb, $matching); + + $count = $qb->getQuery()->getSingleScalarResult(); + return $count; + } + + public function countAll($matching = array()) + { + $qb = $this->createQueryBuilder('o'); + $qb->select("count(DISTINCT o.id)"); + + $qb = $this->createMaching($qb, $matching); + + $count = $qb->getQuery()->getSingleScalarResult(); + return $count; + } + + public function searchBy($matching = array(), $ordered = array(), $limit, $offset = 0){ + $qb = $this->createQueryBuilder('o'); + + $qb = $this->createMaching($qb, $matching); + + if($limit != null){ + $qb->setMaxResults($limit); + } + + if($offset){ + $qb->setFirstResult($offset); + } + + $qb = $this->createOrdered($qb, $ordered); + + $objects = $qb->getQuery()->getResult(); + + return $objects; + + } + + public function searchOneBy($matching = array()){ + $qb = $this->createQueryBuilder('o'); + + $qb = $this->createMaching($qb, $matching); + + $object = $qb->getQuery()->getOneOrNullResult(); + + return $object; + + } + + protected function createSelect($qb, $selects){ + if(count($selects) > 0){ + $select = ""; + foreach ($selects as $field) { + if (\strpos($field, '.') === false) { + $field = "o.".$field; + } + $select .= $field.", "; + } + $select = substr($select, 0, -2); + $qb->select("DISTINCT ".$select); + } + return $qb; + } + + protected function createSearch($qb, $term, $searchs){ + if($term != "" && count($searchs) > 0){ + $search = ""; + foreach ($searchs as $field){ + if (\strpos($field, '.') === false) { + $field = "o.".$field; + } + $search .= $field." LIKE :term OR "; + } + $search = substr($search, 0, -3); + $qb->andWhere($search)->setParameter('term', '%' . $term . '%'); + } + return $qb; + } + + protected function createOrdered($qb, $ordered){ + foreach ($ordered as $key => $value) { + if (\strpos($key, '.') === false) { + $key = "o.".$key; + } + $qb->addOrderBy($key, $value); + } + return $qb; + } + + protected function createMaching($qb, $matching){ + $joins = []; + $i=65; + + foreach ($matching as $key => $value) { + $function = null; + + // Comprueba si es una where simple o con condicionantes + if(!is_array($value)){ + $comparison = "="; + }else{ + $item = $value; + $comparison = $item["comparison"]; //operator + $value = $item["value"]; + + if($comparison == "LIKE"){ + $value = '%' . $value . '%'; + } + + if(array_key_exists('function', $item)){ + $function = $item["function"]; + } + + } + + // Comprueba si es un where con left-join o la propiedad esta en el objeto buscado + if (\strpos($key, '.') === false) { + $field = "o.".$key; + }else{ + $keys = explode(".", $key); + $letter = "o"; + foreach ($keys as $key){ + + if($key !== end($keys)) { + if (!array_key_exists($key, $joins)) { + $joins[$key] = $newLetter = chr($i++); + // First Element + if ($key === reset($keys)) { + $join = "o." . $key; + } else { + $join = $letter . "." . $key; + + } + //echo "leftJoin: " . $join . "=" . $newLetter . "<br>"; + $letter = $newLetter; + $qb->leftJoin($join, $letter); + } else { + $letter = $joins[$key]; + } + } + // Last Element + else { + $field = $letter.".".$key; + } + } + } + + // Comprobamos si el parámetro está + if($function !== null){ + $field = $function."(".$field.")"; + } + + if($comparison === "in"){ + $where = $field." ".$comparison." (:".$key.")"; + }else if($comparison === ">=" || $comparison === ">"){ + $key = $key."Major"; + $where = $field." ".$comparison." :".$key; + }else if($comparison === "<=" || $comparison === "<"){ + $key = $key."Minor"; + $where = $field." ".$comparison." :".$key; + }else{ + $where = $field." ".$comparison." :".$key; + } + + //echo "andWhere: ".$where." --> ".$key." = ".$value."<br>"; + $qb->andWhere($where)->setParameter($key, $value); + } + return $qb; + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/UserRepository.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/UserRepository.php new file mode 100644 index 00000000..b97356f4 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/Repository/UserRepository.php @@ -0,0 +1,74 @@ +<?php + +/* + * This file is part of the Opengnsys Project package. + * + * Created by Opengnsys on 01/10/18. <info@globunet.com> + * Copyright (c) 2015 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. + * + */ + +namespace Opengnsys\CoreBundle\Entity\Repository; + +/** + * UserRepository + * + * This class was generated by the Doctrine ORM. Add your own custom + * repository methods below. + */ +class UserRepository extends BaseRepository +{ + public function findByObservable($term = "", $limit = null, $offset = null, $ordered = array(), $selects = array(), $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + if(count($selects) > 0){ + $qb = $this->createSelect($qb, $selects); + }else{ + $qb->select("DISTINCT o.username, o.usernameCanonical, o.email, o.emailCanonical, o.enabled, o.salt, o.password, o.lastLogin, o.confirmationToken, o.passwordRequestedAt, o.roles, o.firstname, o.lastname, o.locale, o.timezone, o.createdAt, o.updatedAt, o.name, o.profile, o.id"); + } + + if($term != ""){ + if(count($searchs) > 0){ + $qb = $this->createSearch($qb, $term, $searchs); + }else{ + $qb->andWhere("o.username LIKE :term OR o.usernameCanonical LIKE :term OR o.email LIKE :term OR o.emailCanonical LIKE :term OR o.enabled LIKE :term OR o.salt LIKE :term OR o.password LIKE :term OR o.lastLogin LIKE :term OR o.confirmationToken LIKE :term OR o.passwordRequestedAt LIKE :term OR o.roles LIKE :term OR o.firstname LIKE :term OR o.lastname LIKE :term OR o.locale LIKE :term OR o.timezone LIKE :term OR o.createdAt LIKE :term OR o.updatedAt LIKE :term OR o.name LIKE :term OR o.profile LIKE :term OR o.id LIKE :term ")->setParameter('term', '%' . $term . '%'); + } + } + + $qb = $this->createMaching($qb, $matching); + + $qb = $this->createOrdered($qb, $ordered); + + if($limit != null){ + $qb->setMaxResults($limit); + } + + if($offset){ + $qb->setFirstResult($offset); + } + + $entities = $qb->getQuery()->getScalarResult(); + return $entities; + } + + public function countFiltered($term = "", $searchs = array(), $matching = array()) + { + $qb = $this->createQueryBuilder('o'); + + $qb->select("count(DISTINCT o.id)"); + + if($term != ""){ + if(count($searchs) > 0){ + $qb = $this->createSearch($qb, $term, $searchs); + }else{ + $qb->andWhere("o.username LIKE :term OR o.usernameCanonical LIKE :term OR o.email LIKE :term OR o.emailCanonical LIKE :term OR o.enabled LIKE :term OR o.salt LIKE :term OR o.password LIKE :term OR o.lastLogin LIKE :term OR o.confirmationToken LIKE :term OR o.passwordRequestedAt LIKE :term OR o.roles LIKE :term OR o.firstname LIKE :term OR o.lastname LIKE :term OR o.locale LIKE :term OR o.timezone LIKE :term OR o.createdAt LIKE :term OR o.updatedAt LIKE :term OR o.name LIKE :term OR o.profile LIKE :term OR o.id LIKE :term ")->setParameter('term', '%' . $term . '%'); + } + } + + $qb = $this->createMaching($qb, $matching); + + $count = $qb->getQuery()->getSingleScalarResult(); + return $count; + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/User.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/User.php new file mode 100644 index 00000000..13411fa3 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Entity/User.php @@ -0,0 +1,340 @@ +<?php + +namespace Opengnsys\CoreBundle\Entity; + +use FOS\UserBundle\Model\User as FOSBaseUser; +use FOS\UserBundle\Model\UserInterface as FOSUserInterface; + +/** + * User + */ +class User extends FOSBaseUser implements FOSUserInterface +{ + /** + * @var string + */ + protected $firstname; + + /** + * @var string + */ + protected $lastname; + + /** + * @var string + */ + protected $locale; + + /** + * @var string + */ + protected $timezone; + + /** + * Fecha creación + * + * @var \DateTime + */ + protected $createdAt; + + /** + * Fecha acutalización + * + * @var \DateTime + */ + protected $updatedAt; + + /** + * @var + */ + protected $groups; + + /** + * @var string + */ + protected $name; + + /** + * @var \Doctrine\Common\Collections\Collection + */ + protected $organizationalUnits; + + /** + * @var json_array + */ + private $profile; + + /** + * PrePersist + */ + public function setCreatedAtValue() + { + $this->createdAt = (new \DateTime())->setTimezone(new \DateTimeZone("UTC")); + $this->updatedAt = (new \DateTime())->setTimezone(new \DateTimeZone("UTC")); + } + + /** + * PreUpdate + */ + public function setUpdatedAtValue() + { + $this->updatedAt = (new \DateTime())->setTimezone(new \DateTimeZone("UTC")); + } + + + /** + * Constructor + */ + public function __construct() + { + parent::__construct(); + $this->organizationalUnits = new \Doctrine\Common\Collections\ArrayCollection(); + } + + /** + * Get id + * + * @return integer + */ + public function getId() + { + return $this->id; + } + + public function setPlainPassword($password) + { + $this->password = null; + $this->plainPassword = $password; + + return $this; + } + + public function setEmail($email){ + $this->email = $email; + $this->username = ($this->username == null)? $email:$this->username; + } + + /** + * Set firstname + * + * @param string $firstname + * + * @return User + */ + public function setFirstname($firstname) + { + $this->firstname = $firstname; + + return $this; + } + + /** + * Get firstname + * + * @return string + */ + public function getFirstname() + { + return $this->firstname; + } + + /** + * Set lastname + * + * @param string $lastname + * + * @return User + */ + public function setLastname($lastname) + { + $this->lastname = $lastname; + + return $this; + } + + /** + * Get lastname + * + * @return string + */ + public function getLastname() + { + return $this->lastname; + } + + /** + * Set locale + * + * @param string $locale + * + * @return User + */ + public function setLocale($locale) + { + $this->locale = $locale; + + return $this; + } + + /** + * Get locale + * + * @return string + */ + public function getLocale() + { + return $this->locale; + } + + /** + * Set timezone + * + * @param string $timezone + * + * @return User + */ + public function setTimezone($timezone) + { + $this->timezone = $timezone; + + return $this; + } + + /** + * Get timezone + * + * @return string + */ + public function getTimezone() + { + return $this->timezone; + } + + /** + * Set createdAt + * + * @param \DateTime $createdAt + * @return Dealer + */ + public function setCreatedAt($createdAt) + { + $this->createdAt = $createdAt; + + return $this; + } + + /** + * Get createdAt + * + * @return \DateTime + */ + public function getCreatedAt() + { + return $this->createdAt; + } + + /** + * Set updatedAt + * + * @param \DateTime $updatedAt + * @return Dealer + */ + public function setUpdatedAt($updatedAt) + { + $this->updatedAt = $updatedAt; + + return $this; + } + + /** + * Get updatedAt + * + * @return \DateTime + */ + public function getUpdatedAt() + { + return $this->updatedAt; + } + + /** + * Set name + * + * @param string $name + * + * @return User + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Add organizationalUnit + * + * @param \Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit + * + * @return User + */ + public function addOrganizationalUnit(\Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit) + { + $this->organizationalUnits[] = $organizationalUnit; + + return $this; + } + + /** + * Remove organizationalUnit + * + * @param \Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit + */ + public function removeOrganizationalUnit(\Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit) + { + $this->organizationalUnits->removeElement($organizationalUnit); + } + + /** + * Get organizationalUnits + * + * @return \Doctrine\Common\Collections\Collection + */ + public function getOrganizationalUnits() + { + return $this->organizationalUnits; + } + + /** + * Set profile + * + * @param \json_array $profile + * + * @return User + */ + public function setProfile($profile) + { + $this->profile = $profile; + + return $this; + } + + /** + * Get profile + * + * @return \json_array + */ + public function getProfile() + { + return $this->profile; + } +} diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Exception/InvalidFormException.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Exception/InvalidFormException.php new file mode 100644 index 00000000..791b5374 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Exception/InvalidFormException.php @@ -0,0 +1,21 @@ +<?php +namespace Opengnsys\CoreBundle\Exception; + +class InvalidFormException extends \RuntimeException +{ + protected $form; + + public function __construct($message, $form = null) + { + parent::__construct($message); + $this->form = $form; + } + + /** + * @return array|null + */ + public function getForm() + { + return $this->form; + } +}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/UserType.php b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Form/Type/UserFormType.php index a7ec2f92..cec98e2d 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/UserType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Form/Type/UserFormType.php @@ -1,21 +1,13 @@ <?php -/* - * This file is part of the Opengnsys Project package. - * - * Created by Miguel Angel de Vega on 18/03/16. <miguelangel.devega@sic.com> - * Copyright (c) 2015 Opengnsys. All rights reserved. - * - */ +namespace Opengnsys\CoreBundle\Form\Type; -namespace Opengnsys\ServerBundle\Form\Type\Api; - -use Opengnsys\ServerBundle\Entity\User; +use Opengnsys\CoreBundle\Entity\User; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -class UserType extends AbstractType +class UserFormType extends AbstractType { /** * @param FormBuilderInterface $builder @@ -24,11 +16,9 @@ class UserType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { $builder - ->add('user') - ->add('password') + ->add('plainPassword') ->add('name') ->add('email') - ->add('language') ; } @@ -40,7 +30,7 @@ class UserType extends AbstractType $resolver->setDefaults(array( 'data_class' => User::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } @@ -49,7 +39,7 @@ class UserType extends AbstractType */ public function getName() { - return 'opengnsys_server__api_form_type_user'; + return 'opengnsys_core__api_form_type_user'; } /** diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/config.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/config.yml new file mode 100644 index 00000000..71d9d2e4 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/config.yml @@ -0,0 +1,7 @@ +imports: + # FOS Feature Bundles + - { resource: fos/rest/config.yml } + - { resource: fos/user/config.yml } + - { resource: fos/oauth/config.yml } + # Nelmio Feature Bundles + - { resource: nelmio/config.yml } diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AccessToken.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AccessToken.orm.xml new file mode 100644 index 00000000..700ab4ef --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AccessToken.orm.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + <entity + name="Opengnsys\CoreBundle\Entity\AccessToken" + table="globunet_user__access_tokens" + > + + <id name="id" type="integer" column="id"> + <generator strategy="AUTO"/> + </id> + + <many-to-one field="client" target-entity="Opengnsys\CoreBundle\Entity\Client"> + <join-column nullable="false" /> + </many-to-one> + + <many-to-one field="user" target-entity="Opengnsys\CoreBundle\Entity\User"> + <join-column name="user_id" referenced-column-name="id" on-delete="CASCADE" /> + </many-to-one> + + </entity> +</doctrine-mapping> + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AuthCode.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AuthCode.orm.xml new file mode 100644 index 00000000..85f8a37f --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/AuthCode.orm.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + <entity + name="Opengnsys\CoreBundle\Entity\AuthCode" + table="globunet_user__auth_codes" + > + + <id name="id" type="integer" column="id"> + <generator strategy="AUTO"/> + </id> + + <many-to-one field="client" target-entity="Opengnsys\CoreBundle\Entity\Client"> + <join-column nullable="false" /> + </many-to-one> + + <many-to-one field="user" target-entity="Opengnsys\CoreBundle\Entity\User"> + <join-column name="user_id" referenced-column-name="id" on-delete="CASCADE" /> + </many-to-one> + + </entity> +</doctrine-mapping> + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/Client.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/Client.orm.xml new file mode 100644 index 00000000..aad5c983 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/Client.orm.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + <entity + name="Opengnsys\CoreBundle\Entity\Client" + table="globunet_user__clients" + > + + <id name="id" type="integer" column="id"> + <generator strategy="AUTO"/> + </id> + + <field name="name" column="name" type="string" length="64" nullable="true" /> + + <field name="description" column="description" type="text" nullable="true" /> + + </entity> +</doctrine-mapping> + diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Group.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/Group.orm.xml index 5ebbe618..92c8446c 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Group.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/Group.orm.xml @@ -3,7 +3,7 @@ xsi="http://www.w3.org/2001/XMLSchema-instance" schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Group" table="og_groups"> + <entity name="Opengnsys\CoreBundle\Entity\Group" table="og_groups"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/RefreshToken.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/RefreshToken.orm.xml new file mode 100644 index 00000000..cca315c0 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/RefreshToken.orm.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" + xsi="http://www.w3.org/2001/XMLSchema-instance" + schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + <entity + name="Opengnsys\CoreBundle\Entity\RefreshToken" + table="globunet_user__refresh_tokens" + > + + <id name="id" type="integer" column="id"> + <generator strategy="AUTO"/> + </id> + + <many-to-one field="client" target-entity="Opengnsys\CoreBundle\Entity\Client"> + <join-column nullable="false"/> + </many-to-one> + + <many-to-one field="user" target-entity="Opengnsys\CoreBundle\Entity\User"> + <join-column name="user_id" referenced-column-name="id" on-delete="CASCADE"/> + </many-to-one> + + </entity> +</doctrine-mapping> + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/User.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/User.orm.xml new file mode 100644 index 00000000..751e647e --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/doctrine/User.orm.xml @@ -0,0 +1,54 @@ +<?xml version="1.0" encoding="utf-8"?> +<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> + + <entity name="Opengnsys\CoreBundle\Entity\User" table="og_users" + repository-class="Opengnsys\CoreBundle\Entity\Repository\UserRepository"> + + <lifecycle-callbacks> + <lifecycle-callback type="prePersist" method="setCreatedAtValue"/> + <lifecycle-callback type="preUpdate" method="setUpdatedAtValue"/> + </lifecycle-callbacks> + + <id name="id" type="integer" column="id"> + <generator strategy="AUTO"/> + </id> + + <field name="name" type="string" column="name" length="200" nullable="true"/> + + <field name="profile" column="profile" type="json_array" nullable="true"/> + + <field name="firstname" column="firstname" type="string" length="64" nullable="true"/> + <field name="lastname" column="lastname" type="string" length="64" nullable="true"/> + <field name="locale" type="string" column="locale" length="8" nullable="true"/> + <field name="timezone" type="string" column="timezone" length="64" nullable="true"/> + + <field name="createdAt" type="datetime" column="created_at"/> + <field name="updatedAt" type="datetime" column="updated_at"/> + + <many-to-many field="groups" target-entity="Opengnsys\CoreBundle\Entity\Group"> + <join-table name="globunet_user__users_groups"> + <join-columns> + <join-column name="user_id" referenced-column-name="id" nullable="false" unique="false"/> + </join-columns> + <inverse-join-columns> + <join-column name="group_id" referenced-column-name="id"/> + </inverse-join-columns> + </join-table> + </many-to-many> + + <many-to-many field="organizationalUnits" target-entity="\Opengnsys\ServerBundle\Entity\OrganizationalUnit" + inversed-by="users"> + <join-table name="og_users__organizational_units"> + <join-columns> + <join-column name="user_id" referenced-column-name="id"/> + </join-columns> + <inverse-join-columns> + <join-column name="organizational_unit_id" referenced-column-name="id"/> + </inverse-join-columns> + </join-table> + </many-to-many> + + </entity> +</doctrine-mapping> diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/oauth/config.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/oauth/config.yml new file mode 100644 index 00000000..373c2c4a --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/oauth/config.yml @@ -0,0 +1,15 @@ +# FOS OAUTH +fos_oauth_server: + db_driver: orm # Driver availables: orm, mongodb, or propel + client_class: Opengnsys\CoreBundle\Entity\Client + access_token_class: Opengnsys\CoreBundle\Entity\AccessToken + refresh_token_class: Opengnsys\CoreBundle\Entity\RefreshToken + auth_code_class: Opengnsys\CoreBundle\Entity\AuthCode + service: + user_provider: fos_user.user_provider.username + options: + # Example + supported_scopes: user #string + # Changing tokens and authcode lifetime (seconds) + access_token_lifetime: 1209600 # 336 horas + refresh_token_lifetime: 9209600 # aprox 106 días diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/rest/config.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/rest/config.yml new file mode 100644 index 00000000..d6d2864c --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/rest/config.yml @@ -0,0 +1,40 @@ +# app/config/config.yml +sensio_framework_extra: + view: { annotations: true } + router: { annotations: true } + request: { converters: true } + +fos_rest: + serializer: + serialize_null: true + param_fetcher_listener: true + view: + view_response_listener: 'force' + formats: + xml: true + json: true + templating_formats: + html: true + format_listener: + rules: + - { path: ^/, priorities: [ html, json, xml ], fallback_format: ~, prefer_extension: true } + exception: + codes: + 'Symfony\Component\Routing\Exception\ResourceNotFoundException': 404 + 'Doctrine\ORM\OptimisticLockException': HTTP_CONFLICT + messages: + 'Symfony\Component\Routing\Exception\ResourceNotFoundException': true + allowed_methods_listener: true + access_denied_listener: + json: true + body_listener: true + body_converter: + enabled: true + validate: true + #array_normalizer: fos_rest.normalizer.camel_keys + disable_csrf_role: ROLE_API + routing_loader: + default_format: json + +twig: + exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/user/config.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/user/config.yml new file mode 100644 index 00000000..6b85fa3d --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/fos/user/config.yml @@ -0,0 +1,12 @@ +# FOS USER +fos_user: + db_driver: orm # other valid values are 'mongodb', 'couchdb' and 'propel' + firewall_name: main + user_class: Opengnsys\CoreBundle\Entity\User + group: + group_class: Opengnsys\CoreBundle\Entity\Group + from_email: + address: "%mailer_user%" + sender_name: "%mailer_sender_name%" + + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/nelmio/config.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/nelmio/config.yml new file mode 100644 index 00000000..bd522fe0 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/nelmio/config.yml @@ -0,0 +1,31 @@ +nelmio_api_doc: + name: Page Opengnsys API + +nelmio_cors: + defaults: + allow_credentials: false + allow_origin: [] + allow_headers: [] + allow_methods: [] + expose_headers: [] + max_age: 0 + hosts: [] + origin_regex: false + paths: + '^/oauth/': + allow_origin: ['*'] + allow_headers: ['*'] + allow_methods: ['POST', 'PUT', 'GET', 'DELETE','OPTIONS'] + max_age: 3600 + '^/api/': + allow_origin: ['*'] + allow_headers: ['*'] #allow_headers: ['Origin, X-Requested-With, Content-Type, Accept'] + allow_methods: ['POST', 'PUT', 'PATCH', 'GET', 'DELETE', 'OPTIONS'] + max_age: 3600 + '^/': + origin_regex: true + allow_origin: ['^http://localhost:[0-9]+'] + allow_headers: ['*'] #allow_headers: ['X-Custom-Auth'] + allow_methods: ['POST', 'PUT', 'PATCH', 'GET', 'DELETE', 'OPTIONS'] + max_age: 3600 + hosts: ['^api\.']
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/api.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/api.yml new file mode 100644 index 00000000..6f059fd6 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/api.yml @@ -0,0 +1,4 @@ +user: + type: rest + resource: Opengnsys\CoreBundle\Controller\Api\UserController + name_prefix: opengnsys_core__api_
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/fos/oauth.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/fos/oauth.yml new file mode 100644 index 00000000..524bb1ad --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/routing/fos/oauth.yml @@ -0,0 +1,15 @@ +# Proporcionar un token como validación +fos_oauth_server_token: + resource: "@FOSOAuthServerBundle/Resources/config/routing/token.xml" + +# Permitir autenticaciones para clientes de terceros +fos_oauth_server_authorize: + resource: "@FOSOAuthServerBundle/Resources/config/routing/authorize.xml" + +globunet_user_auth_login: + path: /oauth/v2/auth_login + defaults: { _controller: 'OpengnsysCoreBundle:SecurityOAuth:login' } +globunet_user_auth_login_check: + path: /oauth/v2/auth_login_check + defaults: { _controller: 'OpengnsysCoreBundle:SecurityOAuth:check' } + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.Group.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.Group.yml new file mode 100644 index 00000000..6d2a0585 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.Group.yml @@ -0,0 +1,10 @@ +FOS\CoreBundle\Model\Group: + exclusion_policy: ALL + properties: + name: + groups: [app__user_me, app__group_get, app__group_cget, app__user_get, user_app__user_me, app__user_get, app__user_cget] + expose: true + roles: + groups: [app__user_me, app__group_get, app__group_cget, user_app__user_me, app__user_get] + expose: true +
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.User.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.User.yml new file mode 100644 index 00000000..c11a5945 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/FOSUserBundle/Model.User.yml @@ -0,0 +1,25 @@ +FOS\UserBundle\Model\User: + exclusion_policy: ALL + properties: + id: + groups: [opengnsys_server__user_me, opengnsys_server__user_cget, opengnsys_server__user_get] + expose: true + username: + groups: [opengnsys_server__user_me, opengnsys_server__user_cget, opengnsys_server__user_get] + expose: true + email: + groups: [opengnsys_server__user_me, opengnsys_server__user_cget, opengnsys_server__user_get] + expose: true + locked: + groups: [opengnsys_server__user_me, opengnsys_server__user_get] + expose: true + enabled: + groups: [opengnsys_server__user_me, opengnsys_server__user_get] + expose: true + groups: + groups: [opengnsys_server__user_me, opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + roles: + groups: [opengnsys_server__user_me, opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.Group.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.Group.yml new file mode 100644 index 00000000..01d1ab99 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.Group.yml @@ -0,0 +1,6 @@ +Opengnsys\CoreBundle\Entity\Group: + exclusion_policy: ALL + properties: + id: + groups: [app__group_cget, app__group_get, app__user_get] + expose: true
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.User.yml b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.User.yml new file mode 100644 index 00000000..5bdba952 --- /dev/null +++ b/admin/WebConsole3/backend/src/Opengnsys/CoreBundle/Resources/config/serializer/OpengnsysCoreBundle/Entity.User.yml @@ -0,0 +1,96 @@ +Opengnsys\CoreBundle\Entity\User: + exclusion_policy: ALL + properties: + #dateOfBirth: + # groups: [opengnsys_server__user_me, opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: dateOfBirth + firstname: + groups: [opengnsys_server__user_me, opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: firstname + lastname: + groups: [opengnsys_server__user_me, opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: lastname + #website: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: website + #biography: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: biography + #gender: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: gender + locale: + groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: locale + timezone: + groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: timezone + #phone: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: phone + #facebookUid: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: facebookUid + #facebookName: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: facebookName + #facebookData: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: facebookData + #twitterUid: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: twitterUid + #twitterName: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: twitterName + #twitterData: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: twitterData + #gplusUid: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: gplusUid + #gplusName: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: gplusName + #gplusData: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: gplusData + #token: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: token + #twoStepVerificationCode: + # groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + # expose: true + # serialized_name: twoStepVerificationCode + + name: + groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: name + profile: + groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: profile + id: + groups: [opengnsys_server__user_get, opengnsys_server__user_cget] + expose: true + serialized_name: id
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php index 20922975..3f0f4bee 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php +++ b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Command/MigrateCommand.php @@ -5,15 +5,22 @@ namespace Opengnsys\MigrationBundle\Command; use Opengnsys\MigrationBundle\Entity\Aulas; use Opengnsys\MigrationBundle\Entity\Centros; use Opengnsys\MigrationBundle\Entity\Gruposordenadores; +use Opengnsys\MigrationBundle\Entity\Imagenes; use Opengnsys\MigrationBundle\Entity\Menus; use Opengnsys\MigrationBundle\Entity\Ordenadores; +use Opengnsys\MigrationBundle\Entity\OrdenadoresParticiones; use Opengnsys\MigrationBundle\Entity\Perfileshard; +use Opengnsys\MigrationBundle\Entity\Perfilessoft; use Opengnsys\MigrationBundle\Entity\Repositorios; +use Opengnsys\MigrationBundle\Entity\Sistemasficheros; +use Opengnsys\MigrationBundle\Entity\Tiposos; use Opengnsys\ServerBundle\Entity\Client; use Opengnsys\ServerBundle\Entity\HardwareProfile; +use Opengnsys\ServerBundle\Entity\Image; use Opengnsys\ServerBundle\Entity\Menu; use Opengnsys\ServerBundle\Entity\NetworkSettings; use Opengnsys\ServerBundle\Entity\OrganizationalUnit; +use Opengnsys\ServerBundle\Entity\Partition; use Opengnsys\ServerBundle\Entity\Repository; use Opengnsys\ServerBundle\Entity\SoftwareProfile; use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; @@ -34,6 +41,8 @@ class MigrateCommand extends ContainerAwareCommand protected function execute(InputInterface $input, OutputInterface $output) { $logger = $this->getContainer()->get('monolog.logger.og_migration'); + //$logger = $this->getContainer()->get('logger'); + $em = $this->getContainer()->get('doctrine')->getManager(); $emSlave = $this->getContainer()->get('doctrine')->getManager('og_1'); @@ -45,7 +54,12 @@ class MigrateCommand extends ContainerAwareCommand $repositorios = $emSlave->getRepository(Repositorios::class)->findAll(); $menuses = $emSlave->getRepository(Menus::class)->findAll(); $perfileshards = $emSlave->getRepository(Perfileshard::class)->findAll(); - $perfilessofts = $emSlave->getRepository(Perfileshard::class)->findAll(); + $perfilessofts = $emSlave->getRepository(Perfilessoft::class)->findAll(); + $imagenes = $emSlave->getRepository(Imagenes::class)->findAll(); + $particiones = $emSlave->getRepository(OrdenadoresParticiones::class)->findAll(); + + $sistemasFicherosRepository = $emSlave->getRepository(Sistemasficheros::class); + $tipososRepository = $emSlave->getRepository(Tiposos::class); // og_3 $organizationalUnitRepository = $em->getRepository(OrganizationalUnit::class); @@ -54,7 +68,8 @@ class MigrateCommand extends ContainerAwareCommand $menuRepository = $em->getRepository(Menu::class); $hardwareProfileRepository = $em->getRepository(HardwareProfile::class); $softwareProfileRepository = $em->getRepository(SoftwareProfile::class); - + $imageRepository = $em->getRepository(Image::class); + $partitionRepository = $em->getRepository(Partition::class); /** Centros **/ $logger->info("CENTROS TOTAL: ". count($centros)); @@ -113,7 +128,7 @@ class MigrateCommand extends ContainerAwareCommand } /** Grupo Ordenador **/ - $logger->info("Grupos TOTAL: ". count($grupos)); + $logger->info("GRUPOS TOTAL: ". count($grupos)); foreach ($grupos as $grupo){ $id = $grupo->getIdgrupo(); $migrateId ="grupo:".$id; @@ -175,7 +190,6 @@ class MigrateCommand extends ContainerAwareCommand /** Perfil Hardware **/ $logger->info("PERFIL HARDWARES TOTAL: ". count($perfileshards)); foreach ($perfileshards as $perfileshard){ - $perfileshard = new Perfileshard(); $id = $perfileshard->getIdperfilhard(); $migrateId ="perfilHardware:".$id; @@ -188,7 +202,6 @@ class MigrateCommand extends ContainerAwareCommand $hardwareProfile->setDescription($perfileshard->getDescripcion()); $hardwareProfile->setComments($perfileshard->getComentarios()); - // OrganizationalUnit if($perfileshard->getGrupoid() == 0){ $migrateId = "centro:".$perfileshard->getIdcentro(); @@ -201,11 +214,64 @@ class MigrateCommand extends ContainerAwareCommand $em->flush(); /** Perfil Softwares **/ + $logger->info("PERFIL SOFTWARES TOTAL: ". count($perfilessofts)); + foreach ($perfilessofts as $perfilessoft){ + $id = $perfilessoft->getIdperfilsoft(); + $migrateId ="perfilSoftware:".$id; + + $softwareProfile = $softwareProfileRepository->findOneByNotes($migrateId); + if(!$softwareProfile){ + $softwareProfile = new SoftwareProfile(); + $softwareProfile->setNotes($migrateId); + $em->persist($softwareProfile); + } + $softwareProfile->setDescription($perfilessoft->getDescripcion()); + $softwareProfile->setComments($perfilessoft->getComentarios()); + + // OrganizationalUnit + if($perfilessoft->getGrupoid() == 0){ + $migrateId = "centro:".$perfilessoft->getIdcentro(); + }else{ + $migrateId = "grupo:".$perfilessoft->getGrupoid(); + } + $organizationalUnit = $organizationalUnitRepository->findOneByNotes($migrateId); + $softwareProfile->setOrganizationalUnit($organizationalUnit); + } + $em->flush(); /** Menus **/ + $logger->info("PERFIL MENUS TOTAL: ". count($menuses)); + foreach ($menuses as $menuse){ + $id = $menuse->getIdmenu(); + $migrateId ="menu:".$id; + + $menu = $menuRepository->findOneByNotes($migrateId); + if(!$menu){ + $menu = new Menu(); + $menu->setNotes($migrateId); + $em->persist($menu); + } + $menu->setTitle($menuse->getTitulo()); + $menu->setDescription($menuse->getDescripcion()); + $menu->setComments($menuse->getComentarios()); + $menu->setResolution($menuse->getResolucion()); + + $menu->setIdurlimg($menuse->getIdurlimg()); + $menu->setPublicmenuhtml($menuse->getHtmlmenupub()); + + // OrganizationalUnit + if($menuse->getGrupoid() == 0){ + $migrateId = "centro:".$menuse->getIdcentro(); + }else{ + $migrateId = "grupo:".$menuse->getGrupoid(); + } + $organizationalUnit = $organizationalUnitRepository->findOneByNotes($migrateId); + $menu->setOrganizationalUnit($organizationalUnit); + } + $em->flush(); /** Ordenadores **/ - $logger->info("Ordenadores TOTAL: ". count($ordenadores)); + $logger->info("ORDENADORES TOTAL: ". count($ordenadores)); foreach ($ordenadores as $ordenador){ //$ordenador = new Ordenadores(); $id = $ordenador->getIdordenador(); @@ -262,6 +328,93 @@ class MigrateCommand extends ContainerAwareCommand } $em->flush(); + /** Imagen **/ + $logger->info("PERFIL IMAGENES TOTAL: ". count($imagenes)); + foreach ($imagenes as $imagen){ + //$imagen = new Imagenes(); + $id = $imagen->getIdimagen(); + $migrateId ="imagen:".$id; + + $image = $imageRepository->findOneByNotes($migrateId); + if(!$image){ + $image = new Image(); + $image->setNotes($migrateId); + $em->persist($image); + } + $image->setCanonicalName($imagen->getNombreca()); + $image->setDescription($imagen->getDescripcion()); + $image->setComments($imagen->getComentarios()); + $image->setPath($imagen->getRuta()); + $image->setRevision($imagen->getRevision()); + + $image->setType($imagen->getTipo()); + //$image->setPartitionInfo(); + //$image->setFileSize(); + + // SoftwareProfile + $migrateId = "perfilSoftware:".$imagen->getIdperfilsoft(); + $softwareProfile = $softwareProfileRepository->findOneByNotes($migrateId); + $image->setSoftwareProfile($softwareProfile); + + // Client + $migrateId = "ordenador:".$imagen->getIdordenador(); + $client = $clientRepository->findOneByNotes($migrateId); + $image->setClient($client); + + // Repository + $migrateId = "repositorio:".$imagen->getIdrepositorio(); + $repository = $repositoryRepository->findOneByNotes($migrateId); + $image->setRepository($repository); + + } + $em->flush(); + + /** Particiones **/ + $logger->info("PARTICIONES TOTAL: ". count($particiones)); + foreach ($particiones as $particion){ + //$particion = new OrdenadoresParticiones(); + $ordenadorId = $particion->getIdordenador(); + $numDisk = $particion->getNumdisk(); + $numPar = $particion->getNumpar(); + $migrateId ="paricion:".$ordenadorId."_".$numDisk."_".$numPar; + + $partition = $partitionRepository->findOneByNotes($migrateId); + if(!$partition){ + $partition = new Partition(); + $partition->setNotes($migrateId); + $em->persist($partition); + } + $partition->setNumDisk($particion->getNumdisk()); + $partition->setNumPartition($particion->getNumpar()); + $partition->setPartitionCode($particion->getCodpar()); + $partition->setSize($particion->getTamano()); + $partition->setCacheContent($particion->getCache()); + $partition->setUsage($particion->getUso()); + + //$logger->warning("Find FylesSystema ID: ". $particion->getIdsistemafichero()); + $sistemasFicheros = $sistemasFicherosRepository->find($particion->getIdsistemafichero()); + if($sistemasFicheros){ + $partition->setFilesystem($sistemasFicheros->getDescripcion()); + } + + $tiposos = $tipososRepository->find($particion->getIdnombreso()); + if($tiposos){ + $partition->setOsName($tiposos->getTiposo()); + } + + // Image + $migrateId = "image:".$particion->getIdimagen(); + $image = $imageRepository->findOneByNotes($migrateId); + $partition->setImage($image); + //$particion->getIdperfilsoft(); + + // Client + $migrateId ="ordenador:".$ordenadorId; + $client = $clientRepository->findOneByNotes($migrateId); + $partition->setClient($client); + } + $em->flush(); + diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Controller/DefaultController.php b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Controller/DefaultController.php deleted file mode 100644 index ced5ec47..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Controller/DefaultController.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php - -namespace Opengnsys\MigrationBundle\Controller; - -use Symfony\Bundle\FrameworkBundle\Controller\Controller; - -class DefaultController extends Controller -{ - public function indexAction() - { - return $this->render('OpengnsysMigrationBundle:Default:index.html.twig'); - } -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/DependencyInjection/OpengnsysMigrationExtension.php b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/DependencyInjection/OpengnsysMigrationExtension.php index f51174aa..f5c460f8 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/DependencyInjection/OpengnsysMigrationExtension.php +++ b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/DependencyInjection/OpengnsysMigrationExtension.php @@ -21,8 +21,6 @@ class OpengnsysMigrationExtension extends Extension { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); - - $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yml'); } + } diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/routing.yml b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/routing.yml deleted file mode 100644 index 3c87cf6a..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/routing.yml +++ /dev/null @@ -1,3 +0,0 @@ -opengnsys_migration_homepage: - path: / - defaults: { _controller: OpengnsysMigrationBundle:Default:index } diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/services.yml b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/services.yml deleted file mode 100644 index 7ddaaf74..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/config/services.yml +++ /dev/null @@ -1,4 +0,0 @@ -services: -# opengnsys_migration.example: -# class: Opengnsys\MigrationBundle\Example -# arguments: ["@service_id", "plain_value", "%parameter%"] diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/views/Default/index.html.twig b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/views/Default/index.html.twig deleted file mode 100644 index 980a0d5f..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Resources/views/Default/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -Hello World! diff --git a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Tests/Controller/DefaultControllerTest.php b/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Tests/Controller/DefaultControllerTest.php deleted file mode 100644 index 25ae982e..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/MigrationBundle/Tests/Controller/DefaultControllerTest.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Opengnsys\MigrationBundle\Tests\Controller; - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class DefaultControllerTest extends WebTestCase -{ - public function testIndex() - { - $client = static::createClient(); - - $crawler = $client->request('GET', '/'); - - $this->assertContains('Hello World', $client->getResponse()->getContent()); - } -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Controller/Api/ImageController.php b/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Controller/Api/ImageController.php index 1ee1feb0..8ec774ed 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Controller/Api/ImageController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Controller/Api/ImageController.php @@ -28,8 +28,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Image") @@ -104,7 +104,7 @@ class ImageController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { $path = $this->getParameter("path_images"); $finder = new Finder(); diff --git a/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Tests/Controller/DefaultControllerTest.php b/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Tests/Controller/DefaultControllerTest.php deleted file mode 100644 index ade12a76..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/RepositoryBundle/Tests/Controller/DefaultControllerTest.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Opengnsys\RepositoryBundle\Tests\Controller; - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class DefaultControllerTest extends WebTestCase -{ - public function testIndex() - { - $client = static::createClient(); - - $crawler = $client->request('GET', '/'); - - $this->assertContains('Hello World', $client->getResponse()->getContent()); - } -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ClientController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ClientController.php index bf139d65..7b4ed58e 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ClientController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ClientController.php @@ -25,8 +25,8 @@ use FOS\RestBundle\Context\Context; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Client") @@ -46,7 +46,10 @@ class ClientController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); + $array = array(); $array['class'] = ClientType::class; $array['options'] = array(); @@ -77,13 +80,18 @@ class ClientController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); + $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - - $objects = $this->container->get('opengnsys_server.api_client_manager')->all($limit, $offset, $matching); + + $clientManager = $this->container->get('opengnsys_server.client_manager'); + + //$objects = $clientManager->getRepository()->findAll(); + $objects = $clientManager->searchBy($limit, $offset, $matching); $groups = array(); $groups[] = 'opengnsys_server__client_get'; @@ -121,8 +129,10 @@ class ClientController extends ApiController * * @throws NotFoundHttpException when client not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); $groups = array(); @@ -165,17 +175,18 @@ class ClientController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); $parameters = $request->request->all(); - $logger = $this->get('monolog.logger.opengnsys'); + $logger = $this->get('monolog.logger.og_server'); $logger->info("----------- NEW CLIENT -----------"); foreach ($parameters as $key => $parameter){ $logger->info($key."=>".$parameter); } try { - $object = $this->container->get('opengnsys_server.api_client_manager')->post($parameters); + $object = $this->container->get('opengnsys_server.client_manager')->post($parameters); $serviceNetboot = $this->get('opengnsys_service.netboot'); $serviceNetboot->createBootMode($object); @@ -195,59 +206,6 @@ class ClientController extends ApiController * resource = true, * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\ClientType", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__client_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the client id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when client not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_client_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_client_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_client_manager')->put( - $object, - $request->request->all() - ); - } - - $serviceNetboot = $this->get('opengnsys_service.netboot'); - $serviceNetboot->createBootMode($object); - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing Client from the submitted data or create a new Client at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\ClientType", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -268,8 +226,10 @@ class ClientController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + try { - $object = $this->container->get('opengnsys_server.api_client_manager')->patch( + $object = $this->container->get('opengnsys_server.client_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -306,11 +266,13 @@ class ClientController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_client_manager')->delete($object); + $object = $this->container->get('opengnsys_server.client_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -337,12 +299,13 @@ class ClientController extends ApiController */ public function statusAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); + $clients = ($paramFetcher->get('clients'))?explode(",",$paramFetcher->get('clients')):null; $ou = $paramFetcher->get('ou'); - $em = $this->getDoctrine()->getManager(); - $clientRepository = $em->getRepository(Client::class); + $clientRepository = $this->container->get('opengnsys_server.client_manager')->getRepository(); $clients = $clientRepository->searchStatus($clients, $ou); return $clients; //$this->view($clients, Response::HTTP_NO_CONTENT); @@ -364,9 +327,11 @@ class ClientController extends ApiController */ public function postStatusAction(Request $request) { - $logger = $this->get('monolog.logger.opengnsys'); - $em = $this->getDoctrine()->getManager(); - $clientRepository = $em->getRepository(Client::class); + $request->setRequestFormat($request->get('_format')); + + $logger = $this->get('monolog.logger.og_server'); + $clientManager = $this->container->get('opengnsys_server.client_manager'); + $clientRepository = $clientManager->getRepository(); $data = $request->request->all(); @@ -379,7 +344,7 @@ class ClientController extends ApiController $client = $clientRepository->findOneBy(array("ip"=>$ip)); $client->setStatus($status); - $em->flush(); + $clientManager->persist($client); return $this->view($client, Response::HTTP_NO_CONTENT); } @@ -400,7 +365,9 @@ class ClientController extends ApiController */ public function postConfigAction(Request $request) { - $logger = $this->get('monolog.logger.opengnsys'); + $request->setRequestFormat($request->get('_format')); + + $logger = $this->get('monolog.logger.og_server'); $em = $this->getDoctrine()->getManager(); $clientRepository = $em->getRepository(Client::class); @@ -474,7 +441,7 @@ class ClientController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_client_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.client_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CommandController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CommandController.php index d86acb6a..d429a6a0 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CommandController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CommandController.php @@ -28,8 +28,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** @@ -37,7 +37,6 @@ use Symfony\Component\Routing\Generator\UrlGeneratorInterface; */ class CommandController extends ApiController { - /** * Options a Command from the submitted data. * @@ -50,7 +49,9 @@ class CommandController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = CommandType::class; $array['options'] = array(); @@ -81,13 +82,14 @@ class CommandController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_command_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.command_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -113,8 +115,9 @@ class CommandController extends ApiController * * @throws NotFoundHttpException when command not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -145,8 +148,9 @@ class CommandController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_command_manager')->post( + $object = $this->container->get('opengnsys_server.command_manager')->post( $request->request->all() ); return $object; @@ -184,8 +188,9 @@ class CommandController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_command_manager')->patch( + $object = $this->container->get('opengnsys_server.command_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -220,8 +225,8 @@ class CommandController extends ApiController */ public function postExecuteAction(Request $request) { - - $logger = $this->get('monolog.logger.opengnsys'); + $request->setRequestFormat($request->get('_format')); + $logger = $this->get('monolog.logger.og_server'); $logger->info("----------- COMMAND EXECUTE -----------"); $user = $this->getUser(); @@ -306,7 +311,7 @@ class CommandController extends ApiController private function sendCurl($client, $script, $trace) { - $logger = $this->get('monolog.logger.opengnsys'); + $logger = $this->get('monolog.logger.og_server'); $ip = $client->getIp(); $url = "http://".$ip."/cgi-bin/api/LogCommand.sh"; @@ -396,11 +401,12 @@ class CommandController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_command_manager')->delete($object); + $object = $this->container->get('opengnsys_server.command_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -416,7 +422,7 @@ class CommandController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_command_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.command_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CoreController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CoreController.php index d7c82df7..664b88ef 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CoreController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/CoreController.php @@ -14,9 +14,10 @@ use FOS\RestBundle\Controller\Annotations; use FOS\RestBundle\Controller\Annotations\RouteResource; use Nelmio\ApiDocBundle\Annotation\ApiDoc; - -use Globunet\ApiBundle\Controller\ApiController; use Opengnsys\ServerBundle\Entity\Enum\CommandType; +use Symfony\Component\HttpFoundation\Request; +use Opengnsys\CoreBundle\Controller\ApiController; + /** * @RouteResource("Core") @@ -35,8 +36,10 @@ class CoreController extends ApiController * * @return JSON object with basic server information (version, services, etc.) */ - public function getInfoAction() + public function getInfoAction(Request $request) { + $request->setRequestFormat($request->get('_format')); + // Reading version file. @list($project, $version, $release) = explode(' ', file_get_contents('/opt/opengnsys/doc/VERSION.txt')); $response['project'] = trim($project); @@ -74,8 +77,10 @@ class CoreController extends ApiController * * @return JSON object with all data collected from server status (RAM, %CPU, etc.). */ - public function getStatusAction() + public function getStatusAction(Request $request) { + $request->setRequestFormat($request->get('_format')); + // Getting memory and CPU information. exec("awk '$1~/Mem/ {print $2}' /proc/meminfo",$memInfo); $memInfo = array("total" => $memInfo[0], "used" => $memInfo[0]-$memInfo[1]); @@ -134,9 +139,12 @@ class CoreController extends ApiController * * @return JSON object with all data collected from server status (RAM, %CPU, etc.). */ - public function getEngineAction() + public function getEngineAction(Request $request) { + $request->setRequestFormat($request->get('_format')); + $appPath = $this->container->getParameter('kernel.root_dir'); + $content = file_get_contents($appPath.'/doc/engine.json'); $json = json_decode($content, true); diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareController.php index 5aa5e125..91939eb4 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareController.php @@ -23,8 +23,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Hardware") @@ -44,7 +44,9 @@ class HardwareController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = HardwareType::class; $array['options'] = array(); @@ -75,13 +77,14 @@ class HardwareController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_hardware_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.hardware_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -107,8 +110,9 @@ class HardwareController extends ApiController * * @throws NotFoundHttpException when hardware not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -139,8 +143,9 @@ class HardwareController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_hardware_manager')->post( + $object = $this->container->get('opengnsys_server.hardware_manager')->post( $request->request->all() ); @@ -167,56 +172,6 @@ class HardwareController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_hardware", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__hardware_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the hardware id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when hardware not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_hardware_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_hardware_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_hardware_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing Hardware from the submitted data or create a new Hardware at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_hardware", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -237,8 +192,9 @@ class HardwareController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_hardware_manager')->patch( + $object = $this->container->get('opengnsys_server.hardware_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -272,11 +228,12 @@ class HardwareController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_hardware_manager')->delete($object); + $object = $this->container->get('opengnsys_server.hardware_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -292,7 +249,7 @@ class HardwareController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_hardware_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.hardware_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareProfileController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareProfileController.php index 3061ff2c..baeb52db 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareProfileController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/HardwareProfileController.php @@ -25,8 +25,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("HardwareProfile") @@ -46,7 +46,9 @@ class HardwareProfileController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = HardwareProfileType::class; $array['options'] = array(); @@ -77,13 +79,14 @@ class HardwareProfileController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_hardware_profile_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.hardware_profile_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -109,8 +112,9 @@ class HardwareProfileController extends ApiController * * @throws NotFoundHttpException when hardwareProfile not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); $groups = array(); @@ -131,7 +135,7 @@ class HardwareProfileController extends ApiController * @ApiDoc( * resource = true, * description = "Creates a new object from the submitted data.", - * input = {"class" = "opengnsys_server__api_form_type_hardware_profile", "name" = ""}, + * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\HardwareProfileType", "name" = ""}, * statusCodes = { * 200 = "Returned when successful", * 400 = "Returned when the form has errors" @@ -150,11 +154,12 @@ class HardwareProfileController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->post( + $object = $this->container->get('opengnsys_server.hardware_profile_manager')->post( $request->request->all() - ); - + ); + /* if (is_object($this->getUser())) { @@ -162,71 +167,21 @@ class HardwareProfileController extends ApiController $admin->createObjectSecurity($object); } */ - + return $object; - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing HardwareProfile from the submitted data or create a new HardwareProfile at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_hardware_profile", "name" = ""}, - * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__hardware_profile_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the hardwareProfile id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when hardwareProfile not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - + } catch (InvalidFormException $exception) { - + return $exception->getForm(); } } - + /** * Update existing HardwareProfile from the submitted data or create a new HardwareProfile at a specific location. * * @ApiDoc( * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_hardware_profile", "name" = ""}, + * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\HardwareProfileType", "name" = ""}, * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" @@ -248,8 +203,9 @@ class HardwareProfileController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->patch( + $object = $this->container->get('opengnsys_server.hardware_profile_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -283,11 +239,12 @@ class HardwareProfileController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->delete($object); + $object = $this->container->get('opengnsys_server.hardware_profile_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -303,7 +260,7 @@ class HardwareProfileController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_hardware_profile_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.hardware_profile_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ImageController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ImageController.php index 6c602690..c6c10b71 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ImageController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ImageController.php @@ -27,8 +27,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Image") @@ -49,6 +49,8 @@ class ImageController extends ApiController * @return Response */ public function optionsAction(Request $request){ + $request->setRequestFormat($request->get('_format')); + $array = array(); $array['class'] = ImageType::class; $array['options'] = array(); @@ -79,13 +81,15 @@ class ImageController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); + $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_image_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.image_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -111,8 +115,10 @@ class ImageController extends ApiController * * @throws NotFoundHttpException when image not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); $groups = array(); @@ -150,8 +156,10 @@ class ImageController extends ApiController * * @throws NotFoundHttpException when image not exist */ - public function getSoftwaresAction($slug) + public function getSoftwaresAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); return $object->getSoftwareProfile()->getSoftwares(); @@ -182,8 +190,10 @@ class ImageController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); + try { - $object = $this->container->get('opengnsys_server.api_image_manager')->post( + $object = $this->container->get('opengnsys_server.image_manager')->post( $request->request->all() ); @@ -202,56 +212,6 @@ class ImageController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_image", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__image_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the image id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when image not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_image_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_image_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_image_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing Image from the submitted data or create a new Image at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_image", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -272,8 +232,10 @@ class ImageController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + try { - $object = $this->container->get('opengnsys_server.api_image_manager')->patch( + $object = $this->container->get('opengnsys_server.image_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -308,11 +270,13 @@ class ImageController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); + $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_image_manager')->delete($object); + $object = $this->container->get('opengnsys_server.image_manager')->delete($object); /* $path = $object->getPath(); @@ -334,7 +298,7 @@ class ImageController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_image_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.image_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/MenuController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/MenuController.php index 85796393..86447e38 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/MenuController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/MenuController.php @@ -24,8 +24,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Menu") @@ -45,7 +45,9 @@ class MenuController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = MenuType::class; $array['options'] = array(); @@ -76,13 +78,14 @@ class MenuController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_menu_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.menu_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -108,8 +111,9 @@ class MenuController extends ApiController * * @throws NotFoundHttpException when menu not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -140,8 +144,9 @@ class MenuController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_menu_manager')->post( + $object = $this->container->get('opengnsys_server.menu_manager')->post( $request->request->all() ); @@ -160,57 +165,7 @@ class MenuController extends ApiController return $exception->getForm(); } } - - /** - * Update existing Menu from the submitted data or create a new Menu at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_menu", "name" = ""}, - * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__menu_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the menu id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when menu not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_menu_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_menu_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_menu_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - + /** * Update existing Menu from the submitted data or create a new Menu at a specific location. * @@ -238,8 +193,9 @@ class MenuController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_menu_manager')->patch( + $object = $this->container->get('opengnsys_server.menu_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -273,11 +229,12 @@ class MenuController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_menu_manager')->delete($object); + $object = $this->container->get('opengnsys_server.menu_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -293,7 +250,7 @@ class MenuController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_menu_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.menu_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetbootController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetbootController.php index 347266a0..3f2c4ab0 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetbootController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetbootController.php @@ -26,8 +26,8 @@ use FOS\RestBundle\Context\Context; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Netboot") @@ -47,7 +47,9 @@ class NetbootController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = NetbootType::class; $array['options'] = array(); @@ -78,13 +80,14 @@ class NetbootController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_netboot_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.netboot_manager')->searchBy($limit, $offset, $matching); $groups = array(); $groups[] = 'opengnsys_server__netboot_get'; @@ -118,8 +121,9 @@ class NetbootController extends ApiController * * @throws NotFoundHttpException when netboot not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); $groups = array(); @@ -161,8 +165,9 @@ class NetbootController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_netboot_manager')->post( + $object = $this->container->get('opengnsys_server.netboot_manager')->post( $request->request->all() ); @@ -181,56 +186,6 @@ class NetbootController extends ApiController * resource = true, * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\NetbootType", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__netboot_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the netboot id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when netboot not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_netboot_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_netboot_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_netboot_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing Netboot from the submitted data or create a new Netboot at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "Opengnsys\ServerBundle\Form\Type\Api\NetbootType", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -251,8 +206,9 @@ class NetbootController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_netboot_manager')->patch( + $object = $this->container->get('opengnsys_server.netboot_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -286,11 +242,12 @@ class NetbootController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_netboot_manager')->delete($object); + $object = $this->container->get('opengnsys_server.netboot_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -320,7 +277,8 @@ class NetbootController extends ApiController */ public function postClientAction(Request $request) { - $logger = $this->get('monolog.logger.opengnsys'); + $request->setRequestFormat($request->get('_format')); + $logger = $this->get('monolog.logger.og_server'); $parameteres = $request->request->all(); $serviceNetboot = $this->get('opengnsys_service.netboot'); @@ -358,7 +316,7 @@ class NetbootController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_netboot_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.netboot_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetworkSettingsController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetworkSettingsController.php index 515c4d6e..15b0088d 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetworkSettingsController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/NetworkSettingsController.php @@ -24,8 +24,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("NetworkSettings") @@ -45,7 +45,9 @@ class NetworkSettingsController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = NetworkSettingsType::class; $array['options'] = array(); @@ -76,13 +78,14 @@ class NetworkSettingsController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_network_settings_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.network_settings_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -108,8 +111,9 @@ class NetworkSettingsController extends ApiController * * @throws NotFoundHttpException when networkSettings not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -140,8 +144,9 @@ class NetworkSettingsController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_network_settings_manager')->post( + $object = $this->container->get('opengnsys_server.network_settings_manager')->post( $request->request->all() ); @@ -168,56 +173,6 @@ class NetworkSettingsController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_network_settings", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__network_settings_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the networkSettings id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when networkSettings not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_network_settings_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_network_settings_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_network_settings_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing NetworkSettings from the submitted data or create a new NetworkSettings at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_network_settings", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -238,8 +193,9 @@ class NetworkSettingsController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_network_settings_manager')->patch( + $object = $this->container->get('opengnsys_server.network_settings_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -273,11 +229,12 @@ class NetworkSettingsController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_network_settings_manager')->delete($object); + $object = $this->container->get('opengnsys_server.network_settings_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -293,7 +250,7 @@ class NetworkSettingsController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_network_settings_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.network_settings_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/OrganizationalUnitController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/OrganizationalUnitController.php index f6bd67e0..39d21613 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/OrganizationalUnitController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/OrganizationalUnitController.php @@ -11,6 +11,7 @@ namespace Opengnsys\ServerBundle\Controller\Api; use FOS\RestBundle\Context\Context; +use Opengnsys\ServerBundle\Entity\OrganizationalUnit; use Opengnsys\ServerBundle\Form\Type\Api\OrganizationalUnitType; use Opengnsys\ServerBundle\OpengnsysServerBundle; use Symfony\Component\HttpFoundation\Request; @@ -25,8 +26,8 @@ use FOS\RestBundle\View\View; use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("OrganizationalUnit") @@ -46,7 +47,9 @@ class OrganizationalUnitController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = OrganizationalUnitType::class; $array['options'] = array(); @@ -79,18 +82,17 @@ class OrganizationalUnitController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); - $hierarchical = $paramFetcher->get('hierarchical'); - $leaf = $paramFetcher->get('leaf'); + $matching["hierarchical"] = $paramFetcher->get('hierarchical'); + $matching["leaf"] = $paramFetcher->get('leaf'); - $matching = $this->filterCriteria($paramFetcher); - $repository = $this->getDoctrine()->getManager()->getRepository('OpengnsysServerBundle:OrganizationalUnit'); + //$matching = $this->filterCriteria($paramFetcher); - $objects = $repository->allBy($limit, $offset, $hierarchical, $leaf); - //$objects = $this->container->get('opengnsys_server.api_organizational_unit_manager')->allBy($limit, $offset, $hierarchical, $leaf); + $objects = $this->container->get('opengnsys_server.organizational_unit_manager')->searchBy($limit, $offset, $matching); $groups = array(); $groups[] = 'opengnsys_server__client_cget'; @@ -99,7 +101,7 @@ class OrganizationalUnitController extends ApiController $groups[] = 'opengnsys_server__partition_get'; $groups[] = 'opengnsys_server__netboot_get'; - if($hierarchical){ + if($matching["hierarchical"]){ $groups[] = 'opengnsys_server__organizational_unit_cget_h'; }else{ $groups[] = 'opengnsys_server__organizational_unit_cget'; @@ -138,8 +140,9 @@ class OrganizationalUnitController extends ApiController * * @throws NotFoundHttpException when organizationalUnit not exist */ - public function getAction($slug, ParamFetcherInterface $paramFetcher) + public function getAction(Request $request, $slug, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $groups = array(); $groups[] = 'opengnsys_server__organizational_unit_get'; $groups[] = 'opengnsys_server__client_cget'; @@ -193,8 +196,9 @@ class OrganizationalUnitController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->post( + $object = $this->container->get('opengnsys_server.organizational_unit_manager')->post( $request->request->all() ); @@ -213,57 +217,7 @@ class OrganizationalUnitController extends ApiController return $exception->getForm(); } } - - /** - * Update existing OrganizationalUnit from the submitted data or create a new OrganizationalUnit at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_organizational_unit", "name" = ""}, - * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__organizational_unit_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the organizationalUnit id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when organizationalUnit not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - + /** * Update existing OrganizationalUnit from the submitted data or create a new OrganizationalUnit at a specific location. * @@ -291,8 +245,9 @@ class OrganizationalUnitController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->patch( + $object = $this->container->get('opengnsys_server.organizational_unit_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -326,10 +281,11 @@ class OrganizationalUnitController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->delete($object); + $object = $this->container->get('opengnsys_server.organizational_unit_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -345,7 +301,7 @@ class OrganizationalUnitController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_organizational_unit_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.organizational_unit_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/PartitionController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/PartitionController.php index aa78b2c1..8b0f10ba 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/PartitionController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/PartitionController.php @@ -24,8 +24,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Partition") @@ -45,7 +45,9 @@ class PartitionController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = PartitionType::class ; $array['options'] = array(); @@ -76,13 +78,14 @@ class PartitionController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_partition_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.partition_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -108,8 +111,9 @@ class PartitionController extends ApiController * * @throws NotFoundHttpException when partition not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -140,8 +144,9 @@ class PartitionController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_partition_manager')->post( + $object = $this->container->get('opengnsys_server.partition_manager')->post( $request->request->all() ); @@ -160,57 +165,7 @@ class PartitionController extends ApiController return $exception->getForm(); } } - - /** - * Update existing Partition from the submitted data or create a new Partition at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_partition", "name" = ""}, - * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__partition_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the partition id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when partition not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_partition_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_partition_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_partition_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - + /** * Update existing Partition from the submitted data or create a new Partition at a specific location. * @@ -238,8 +193,9 @@ class PartitionController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_partition_manager')->patch( + $object = $this->container->get('opengnsys_server.partition_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -273,11 +229,12 @@ class PartitionController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_partition_manager')->delete($object); + $object = $this->container->get('opengnsys_server.partition_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -293,7 +250,7 @@ class PartitionController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_partition_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.partition_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/RepositoryController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/RepositoryController.php index 3d1e3d3a..19804768 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/RepositoryController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/RepositoryController.php @@ -23,8 +23,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Repository") @@ -44,7 +44,9 @@ class RepositoryController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = RepositoryType::class; $array['options'] = array(); @@ -75,13 +77,14 @@ class RepositoryController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_repository_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.repository_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -107,8 +110,9 @@ class RepositoryController extends ApiController * * @throws NotFoundHttpException when repository not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -139,8 +143,9 @@ class RepositoryController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_repository_manager')->post( + $object = $this->container->get('opengnsys_server.repository_manager')->post( $request->request->all() ); @@ -159,57 +164,7 @@ class RepositoryController extends ApiController return $exception->getForm(); } } - - /** - * Update existing Repository from the submitted data or create a new Repository at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_repository", "name" = ""}, - * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__repository_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the repository id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when repository not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_repository_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_repository_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_repository_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - + /** * Update existing Repository from the submitted data or create a new Repository at a specific location. * @@ -237,8 +192,9 @@ class RepositoryController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_repository_manager')->patch( + $object = $this->container->get('opengnsys_server.repository_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -272,11 +228,11 @@ class RepositoryController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - - $object = $this->container->get('opengnsys_server.api_repository_manager')->delete($object); + $object = $this->container->get('opengnsys_server.repository_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -292,7 +248,7 @@ class RepositoryController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_repository_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.repository_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareController.php index 7553b22e..9fff9251 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareController.php @@ -24,8 +24,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Software") @@ -45,7 +45,9 @@ class SoftwareController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = SoftwareType::class; $array['options'] = array(); @@ -76,13 +78,14 @@ class SoftwareController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_software_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.software_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -108,8 +111,9 @@ class SoftwareController extends ApiController * * @throws NotFoundHttpException when software not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -140,8 +144,9 @@ class SoftwareController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_software_manager')->post( + $object = $this->container->get('opengnsys_server.software_manager')->post( $request->request->all() ); @@ -168,56 +173,6 @@ class SoftwareController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_software", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__software_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the software id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when software not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_software_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_software_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_software_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing Software from the submitted data or create a new Software at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_software", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -238,8 +193,9 @@ class SoftwareController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_software_manager')->patch( + $object = $this->container->get('opengnsys_server.software_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -273,11 +229,12 @@ class SoftwareController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_software_manager')->delete($object); + $object = $this->container->get('opengnsys_server.software_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -293,7 +250,7 @@ class SoftwareController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_software_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.software_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareProfileController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareProfileController.php index 557aec83..21a759c6 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareProfileController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/SoftwareProfileController.php @@ -25,8 +25,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("SoftwareProfile") @@ -46,7 +46,9 @@ class SoftwareProfileController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = SoftwareProfile::class; $array['options'] = array(); @@ -77,13 +79,14 @@ class SoftwareProfileController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_software_profile_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.software_profile_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -109,8 +112,9 @@ class SoftwareProfileController extends ApiController * * @throws NotFoundHttpException when softwareProfile not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); $groups = array(); @@ -150,8 +154,9 @@ class SoftwareProfileController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_software_profile_manager')->post( + $object = $this->container->get('opengnsys_server.software_profile_manager')->post( $request->request->all() ); @@ -178,56 +183,6 @@ class SoftwareProfileController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_software_profile", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__software_profile_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the softwareProfile id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when softwareProfile not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_software_profile_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_software_profile_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_software_profile_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing SoftwareProfile from the submitted data or create a new SoftwareProfile at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_software_profile", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -248,8 +203,9 @@ class SoftwareProfileController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_software_profile_manager')->patch( + $object = $this->container->get('opengnsys_server.software_profile_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -283,11 +239,11 @@ class SoftwareProfileController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - - $object = $this->container->get('opengnsys_server.api_software_profile_manager')->delete($object); + $object = $this->container->get('opengnsys_server.software_profile_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -303,7 +259,7 @@ class SoftwareProfileController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_software_profile_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.software_profile_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/TraceController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/TraceController.php index 639acfca..4a47d886 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/TraceController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/TraceController.php @@ -31,8 +31,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("Trace") @@ -52,7 +52,9 @@ class TraceController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = CommandType::class; $array['options'] = array(); @@ -84,6 +86,7 @@ class TraceController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); @@ -130,7 +133,8 @@ class TraceController extends ApiController */ public function cpostAction(Request $request) { - $logger = $this->get('monolog.logger.opengnsys'); + $request->setRequestFormat($request->get('_format')); + $logger = $this->get('monolog.logger.og_server'); $response = null; $output = ""; @@ -279,10 +283,6 @@ class TraceController extends ApiController }else{ $logger->info("Not Found Image"); } - - - - } $em->flush(); case \Opengnsys\ServerBundle\Entity\Enum\CommandType::SOFTWARE_INVENTORY: @@ -371,7 +371,7 @@ class TraceController extends ApiController // http://172.16.140.210/opengnsys3/rest/web/app_dev.php/api/clients/status - //$objects = $this->container->get('opengnsys_server.api_client_manager')->all($limit, $offset, $matching); + //$objects = $this->container->get('opengnsys_server.client_manager')->searchBy($limit, $offset, $matching); return $this->view($output, Response::HTTP_NO_CONTENT); } @@ -397,8 +397,9 @@ class TraceController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $em = $this->getDoctrine()->getManager(); $traceRepository = $em->getRepository(Trace::class); diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/UserController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/UserController.php index 2d5960cd..86e1fa1d 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/UserController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/UserController.php @@ -10,7 +10,7 @@ namespace Opengnsys\ServerBundle\Controller\Api; -use Opengnsys\ServerBundle\Form\Type\Api\UserType; +use Opengnsys\ServerBundle\Form\Type\Api\UserFormType; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; @@ -24,8 +24,9 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * @RouteResource("User") @@ -45,9 +46,11 @@ class UserController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); - $array['class'] = UserType::class; + $array['class'] = UserFormType::class; $array['options'] = array(); $options = $this->container->get('nelmio_api_doc.parser.form_type_parser')->parse($array); @@ -76,13 +79,14 @@ class UserController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_user_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.user_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -108,8 +112,9 @@ class UserController extends ApiController * * @throws NotFoundHttpException when user not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -140,8 +145,9 @@ class UserController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_user_manager')->post( + $object = $this->container->get('opengnsys_server.user_manager')->post( $request->request->all() ); @@ -168,56 +174,6 @@ class UserController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_user", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__user_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the user id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when user not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_user_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_user_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_user_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing User from the submitted data or create a new User at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_user", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -238,8 +194,9 @@ class UserController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_user_manager')->patch( + $object = $this->container->get('opengnsys_server.user_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -273,11 +230,11 @@ class UserController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - - $object = $this->container->get('opengnsys_server.api_user_manager')->delete($object); + $object = $this->container->get('opengnsys_server.user_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -293,10 +250,48 @@ class UserController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_user_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.user_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } return $object; } + + /** + * + * @Annotations\View(templateVar="users", serializerGroups={"opengnsys_server__user_me"}) + * + * @ApiDoc(resource = true) + */ + public function getMeAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); + + try{ + /* + if (false === $this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) { + throw new AccessDeniedException(); + } + */ + $this->forwardIfNotAuthenticated(); + $response = $this->getUser(); + + //$this->get('logger')->error(var_export($response,true)); + }catch(AccessDeniedException $ade){ + $response = new Response($ade->getMessage(), $ade->getCode()); + } + + return $response; + } + + /** + * Shortcut to throw a AccessDeniedException($message) if the user is not authenticated + * @param String $message The message to display (default:'warn.user.notAuthenticated') + */ + protected function forwardIfNotAuthenticated($message='warn.user.notAuthenticated'){ + if (!is_object($this->getUser())) + { + throw new AccessDeniedException($message); + } + } } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ValidationSettingsController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ValidationSettingsController.php index defabe7d..b0d77506 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ValidationSettingsController.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/Api/ValidationSettingsController.php @@ -23,8 +23,8 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use Nelmio\ApiDocBundle\Annotation\ApiDoc; -use Globunet\ApiBundle\Exception\InvalidFormException; -use Globunet\ApiBundle\Controller\ApiController; +use Opengnsys\CoreBundle\Exception\InvalidFormException; +use Opengnsys\CoreBundle\Controller\ApiController; /** * @RouteResource("ValidationSettings") @@ -44,7 +44,9 @@ class ValidationSettingsController extends ApiController * * @return Response */ - public function optionsAction(Request $request){ + public function optionsAction(Request $request) + { + $request->setRequestFormat($request->get('_format')); $array = array(); $array['class'] = "opengnsys_server__api_form_type_validation_settings"; $array['options'] = array(); @@ -75,13 +77,14 @@ class ValidationSettingsController extends ApiController */ public function cgetAction(Request $request, ParamFetcherInterface $paramFetcher) { + $request->setRequestFormat($request->get('_format')); $offset = $paramFetcher->get('offset'); $offset = null == $offset ? 0 : $offset; $limit = $paramFetcher->get('limit'); $matching = $this->filterCriteria($paramFetcher); - $objects = $this->container->get('opengnsys_server.api_validation_settings_manager')->all($limit, $offset, $matching); + $objects = $this->container->get('opengnsys_server.validation_settings_manager')->searchBy($limit, $offset, $matching); return $objects; } @@ -107,8 +110,9 @@ class ValidationSettingsController extends ApiController * * @throws NotFoundHttpException when validationSettings not exist */ - public function getAction($slug) + public function getAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); return $object; @@ -139,8 +143,9 @@ class ValidationSettingsController extends ApiController */ public function cpostAction(Request $request) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_validation_settings_manager')->post( + $object = $this->container->get('opengnsys_server.validation_settings_manager')->post( $request->request->all() ); @@ -167,56 +172,6 @@ class ValidationSettingsController extends ApiController * resource = true, * input = {"class" = "opengnsys_server__api_form_type_validation_settings", "name" = ""}, * statusCodes = { - * 201 = "Returned when the Activity is created", - * 204 = "Returned when successful", - * 400 = "Returned when the form has errors" - * } - * ) - * - * @Annotations\View( - * template = "object", - * serializerGroups={"opengnsys_server__validation_settings_get"}, - * statusCode = Response::HTTP_OK - * ) - * - * @param Request $request the request object - * @param int $slug the validationSettings id - * - * @return FormTypeInterface|View - * - * @throws NotFoundHttpException when validationSettings not exist - */ - public function putAction(Request $request, $slug) - { - try { - if (!($object = $this->container->get('opengnsys_server.api_validation_settings_manager')->get($slug))) { - $statusCode = Response::HTTP_CREATED; - $object = $this->container->get('opengnsys_server.api_validation_settings_manager')->post( - $request->request->all() - ); - } else { - $statusCode = Response::HTTP_NO_CONTENT; - $object = $this->container->get('opengnsys_server.api_validation_settings_manager')->put( - $object, - $request->request->all() - ); - } - - return $this->view($object, $statusCode); - - } catch (InvalidFormException $exception) { - - return $exception->getForm(); - } - } - - /** - * Update existing ValidationSettings from the submitted data or create a new ValidationSettings at a specific location. - * - * @ApiDoc( - * resource = true, - * input = {"class" = "opengnsys_server__api_form_type_validation_settings", "name" = ""}, - * statusCodes = { * 204 = "Returned when successful", * 400 = "Returned when the form has errors" * } @@ -237,8 +192,9 @@ class ValidationSettingsController extends ApiController */ public function patchAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); try { - $object = $this->container->get('opengnsys_server.api_validation_settings_manager')->patch( + $object = $this->container->get('opengnsys_server.validation_settings_manager')->patch( $this->getOr404($slug), $request->request->all() ); @@ -272,11 +228,12 @@ class ValidationSettingsController extends ApiController * * @throws NotFoundHttpException when object not exist */ - public function deleteAction($slug) + public function deleteAction(Request $request, $slug) { + $request->setRequestFormat($request->get('_format')); $object = $this->getOr404($slug); - $object = $this->container->get('opengnsys_server.api_validation_settings_manager')->delete($object); + $object = $this->container->get('opengnsys_server.validation_settings_manager')->delete($object); return $this->view(null, Response::HTTP_NO_CONTENT); } @@ -292,7 +249,7 @@ class ValidationSettingsController extends ApiController */ protected function getOr404($slug) { - if (!($object = $this->container->get('opengnsys_server.api_validation_settings_manager')->get($slug))) { + if (!($object = $this->container->get('opengnsys_server.validation_settings_manager')->get($slug))) { throw new NotFoundHttpException(sprintf('The resource \'%s\' was not found.',$slug)); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/DefaultController.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/DefaultController.php deleted file mode 100644 index 7907622d..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Controller/DefaultController.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Controller; - -use Opengnsys\ServerBundle\Entity\Client; -use Opengnsys\ServerBundle\Entity\Hardware; -use Opengnsys\ServerBundle\Entity\User; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; -use Lsw\ApiCallerBundle\Call\HttpPostJsonBody; - -class DefaultController extends Controller -{ - public function indexAction() - { - return $this->render('OpengnsysServerBundle:Default:index.html.twig', array()); - } -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DataFixtures/LoadClientApi.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DataFixtures/LoadClientApi.php index 7006d2b7..b66745d7 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DataFixtures/LoadClientApi.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DataFixtures/LoadClientApi.php @@ -4,7 +4,7 @@ namespace Opengnsys\ServerBundle\DataFixtures; use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\Persistence\ObjectManager; -use Globunet\UserBundle\Entity\Client; +use Opengnsys\CoreBundle\Entity\Client; use Opengnsys\ServerBundle\Entity\Netboot; class LoadClientApi extends Fixture diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DependencyInjection/OpengnsysServerExtension.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DependencyInjection/OpengnsysServerExtension.php index 6e13758b..4058aadc 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DependencyInjection/OpengnsysServerExtension.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/DependencyInjection/OpengnsysServerExtension.php @@ -24,6 +24,5 @@ class OpengnsysServerExtension extends Extension $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); - $loader->load('api.yml'); } } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/BaseEntity.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/BaseEntity.php index 6cc7776a..20f4915b 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/BaseEntity.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/BaseEntity.php @@ -1,10 +1,10 @@ <?php /* - * This file is part of the Globunet Project package. + * This file is part of the Opengnsys Project package. * - * Created by Globunet on 06/02/19. <info@globunet.com> - * Copyright (c) 2019 Globunet Soluciones Tecnológicas, SL. All rights reserved. + * Created by Opengnsys on 06/02/19. <info@globunet.com> + * Copyright (c) 2019 Opengnsys Soluciones Tecnológicas, SL. All rights reserved. * */ diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Group.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Group.php deleted file mode 100644 index fff0e162..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Group.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity; - -use Globunet\UserBundle\Entity\BaseGroup; -use Globunet\UserBundle\Model\GroupInterface; - -/** - * Group - */ -class Group extends BaseGroup implements GroupInterface -{ - -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Hardware.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Hardware.php index f32cbb5f..ee774ce9 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Hardware.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Hardware.php @@ -7,8 +7,6 @@ namespace Opengnsys\ServerBundle\Entity; */ class Hardware extends BaseEntity { - - /** * @var string */ diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository.php index 70029bcd..9dc37677 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository.php @@ -58,12 +58,6 @@ class Repository extends BaseEntity private $organizationalUnit; /** - * @var \Opengnsys\ServerBundle\Entity\Group - */ - private $group; - - - /** * Set name * * @param string $name @@ -289,28 +283,4 @@ class Repository extends BaseEntity return $this->organizationalUnit; } - /** - * Set group - * - * @param \Opengnsys\ServerBundle\Entity\Group $group - * - * @return Repository - */ - public function setGroup(\Opengnsys\ServerBundle\Entity\Group $group = null) - { - $this->group = $group; - - return $this; - } - - /** - * Get group - * - * @return \Opengnsys\ServerBundle\Entity\Group - */ - public function getGroup() - { - return $this->group; - } - } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/ClientRepository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/ClientRepository.php deleted file mode 100644 index 02920446..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/ClientRepository.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity\Repository; - -use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -class ClientRepository extends EntityRepository{ - - public function allBy($limit , $offset, $organizationalUnit, $recursive) - { - - $qb = $this->createQueryBuilder('o'); - - if($organizationalUnit){ - $qb->andWhere("o.organizationalUnit = :organizationalUnit")->setParameter("organizationalUnit", $organizationalUnit); - } - - /* - if($hierarchical){ - $qb->andWhere("o.parent is null"); - }else if($leaf){ - $qb->andWhere("o.children is empty"); - } - */ - - if($limit != null){ - $qb->setMaxResults($limit); - } - if($offset != null){ - $qb->setFirstResult($offset); - } - - try { - $objects = $qb->getQuery()->getResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } - - public function searchStatus($clients , $ou){ - $qb = $this->createQueryBuilder('o'); - - $qb->select('o.id, o.status'); - - if($ou){ - $qb->andWhere("o.organizationalUnit = :organizationalUnit")->setParameter("organizationalUnit", $ou); - } - - if($clients){ - $qb->andWhere("o.id in (:clients)")->setParameter("clients", $clients); - } - - try { - $objects = $qb->getQuery()->getScalarResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } -}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/OrganizationalUnitRepository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/OrganizationalUnitRepository.php deleted file mode 100644 index 1ef4dcad..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/OrganizationalUnitRepository.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity\Repository; - -use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -class OrganizationalUnitRepository extends EntityRepository{ - - public function allBy($limit , $offset, $hierarchical, $leaf) - { - - $qb = $this->createQueryBuilder('o'); - - if($hierarchical){ - $qb->andWhere("o.parent is null"); - }else if($leaf){ - $qb->andWhere("o.children is empty"); - } - - if($limit != null){ - $qb->setMaxResults($limit); - } - if($offset != null){ - $qb->setFirstResult($offset); - } - - try { - $objects = $qb->getQuery()->getResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } -}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/RepositoryRepository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/RepositoryRepository.php deleted file mode 100644 index cb0fca66..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/RepositoryRepository.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity\Repository; - -use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -class RepositoryRepository extends EntityRepository{ - - public function allBy($limit , $offset, $organizationalUnit, $recursive) - { - - $qb = $this->createQueryBuilder('o'); - - if($organizationalUnit){ - $qb->andWhere("o.organizationalUnit = :organizationalUnit")->setParameter("organizationalUnit", $organizationalUnit); - } - - /* - if($hierarchical){ - $qb->andWhere("o.parent is null"); - }else if($leaf){ - $qb->andWhere("o.children is empty"); - } - */ - - if($limit != null){ - $qb->setMaxResults($limit); - } - if($offset != null){ - $qb->setFirstResult($offset); - } - - try { - $objects = $qb->getQuery()->getResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } -}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/TraceRepository.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/TraceRepository.php deleted file mode 100644 index 2cd6359d..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/Repository/TraceRepository.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity\Repository; - -use Doctrine\ORM\EntityRepository; -use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -class TraceRepository extends EntityRepository{ - - public function searchBy($limit , $offset, $finished) - { - - $qb = $this->createQueryBuilder('o'); - - - if($finished != null){ - if($finished){ - $qb->andWhere("o.status is not null"); - }else{ - $qb->andWhere("o.status is null"); - } - } - - if($limit != null){ - $qb->setMaxResults($limit); - } - if($offset != null){ - $qb->setFirstResult($offset); - } - - try { - $objects = $qb->getQuery()->getResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } - - public function searchStatus($clients , $ou){ - $qb = $this->createQueryBuilder('o'); - - $qb->select('o.id, o.status'); - - if($ou){ - $qb->andWhere("o.organizationalUnit = :organizationalUnit")->setParameter("organizationalUnit", $ou); - } - - if($clients){ - $qb->andWhere("o.id in (:clients)")->setParameter("clients", $clients); - } - - try { - $objects = $qb->getQuery()->getScalarResult(); - } catch (NoResultException $e) { - $message = sprintf('Unable to find an objects'); - throw new NotFoundHttpException($message, null, 0, $e); - } - return $objects; - } -}
\ No newline at end of file diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/User.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/User.php deleted file mode 100644 index 1d7eb0c5..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Entity/User.php +++ /dev/null @@ -1,128 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Entity; - -use Globunet\UserBundle\Entity\BaseUser; -use Globunet\UserBundle\Model\UserInterface; - -/** - * User - */ -class User extends BaseUser implements UserInterface -{ - /** - * @var string - */ - protected $name; - - /** - * @var \Doctrine\Common\Collections\Collection - */ - protected $organizationalUnits; - - /** - * @var json_array - */ - private $profile; - - /** - * Constructor - */ - public function __construct() - { - parent::__construct(); - $this->organizationalUnits = new \Doctrine\Common\Collections\ArrayCollection(); - } - - /** - * Set name - * - * @param string $name - * - * @return User - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Get id - * - * @return integer - */ - public function getId() - { - return $this->id; - } - - /** - * Add organizationalUnit - * - * @param \Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit - * - * @return User - */ - public function addOrganizationalUnit(\Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit) - { - $this->organizationalUnits[] = $organizationalUnit; - - return $this; - } - - /** - * Remove organizationalUnit - * - * @param \Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit - */ - public function removeOrganizationalUnit(\Opengnsys\ServerBundle\Entity\OrganizationalUnit $organizationalUnit) - { - $this->organizationalUnits->removeElement($organizationalUnit); - } - - /** - * Get organizationalUnits - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getOrganizationalUnits() - { - return $this->organizationalUnits; - } - - /** - * Set profile - * - * @param \json_array $profile - * - * @return User - */ - public function setProfile($profile) - { - $this->profile = $profile; - - return $this; - } - - /** - * Get profile - * - * @return \json_array - */ - public function getProfile() - { - return $this->profile; - } -} diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientConfigType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientConfigType.php index 76d61902..53c9377a 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientConfigType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientConfigType.php @@ -35,9 +35,8 @@ class ClientConfigType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientStatusType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientStatusType.php index 97c82a31..64b78211 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientStatusType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientStatusType.php @@ -35,9 +35,8 @@ class ClientStatusType extends AbstractType public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( - 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientType.php index 1e89f12f..ede1fdf0 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ClientType.php @@ -48,7 +48,6 @@ class ClientType extends AbstractType $resolver->setDefaults(array( 'data_class' => Client::class, 'cascade_validation' => true, - 'csrf_protection' => false )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandExecuteType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandExecuteType.php index df82e3b6..274ea59e 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandExecuteType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandExecuteType.php @@ -39,7 +39,7 @@ class CommandExecuteType extends AbstractType $resolver->setDefaults(array( 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandType.php index 2f2632a3..c5ac60db 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/CommandType.php @@ -40,7 +40,7 @@ class CommandType extends AbstractType $resolver->setDefaults(array( 'data_class' => Command::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareProfileType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareProfileType.php index 89ba86fc..dca70b4e 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareProfileType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareProfileType.php @@ -38,7 +38,7 @@ class HardwareProfileType extends AbstractType $resolver->setDefaults(array( 'data_class' => HardwareProfile::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareType.php index 9b27c4ff..d6ee85aa 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/HardwareType.php @@ -37,7 +37,7 @@ class HardwareType extends AbstractType $resolver->setDefaults(array( 'data_class' => Hardware::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ImageType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ImageType.php index d324434b..2d8847d2 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ImageType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ImageType.php @@ -48,7 +48,7 @@ class ImageType extends AbstractType $resolver->setDefaults(array( 'data_class' => Image::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/MenuType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/MenuType.php index 242dce83..f5ab412f 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/MenuType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/MenuType.php @@ -48,7 +48,7 @@ class MenuType extends AbstractType $resolver->setDefaults(array( 'data_class' => Menu::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetbootType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetbootType.php index 28acc6c4..c26ecd13 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetbootType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetbootType.php @@ -39,7 +39,7 @@ class NetbootType extends AbstractType $resolver->setDefaults(array( 'data_class' => Netboot::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetworkSettingsType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetworkSettingsType.php index 23b14fd6..02a2b54b 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetworkSettingsType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/NetworkSettingsType.php @@ -46,7 +46,7 @@ class NetworkSettingsType extends AbstractType $resolver->setDefaults(array( 'data_class' => NetworkSettings::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OrganizationalUnitType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OrganizationalUnitType.php index d426e57f..67d5d03c 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OrganizationalUnitType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OrganizationalUnitType.php @@ -40,7 +40,7 @@ class OrganizationalUnitType extends AbstractType $resolver->setDefaults(array( 'data_class' => OrganizationalUnit::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OsNameType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OsNameType.php index c0a869ae..ec37ea91 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OsNameType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/OsNameType.php @@ -37,7 +37,7 @@ class OsNameType extends AbstractType $resolver->setDefaults(array( 'data_class' => OsName::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/PartitionType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/PartitionType.php index 89f64b56..9d3c20ae 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/PartitionType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/PartitionType.php @@ -41,7 +41,7 @@ class PartitionType extends AbstractType $resolver->setDefaults(array( 'data_class' => Partition::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/RepositoryType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/RepositoryType.php index 59146eee..2edebcab 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/RepositoryType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/RepositoryType.php @@ -43,7 +43,7 @@ class RepositoryType extends AbstractType $resolver->setDefaults(array( 'data_class' => Repository::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareProfileType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareProfileType.php index 2ef71ab4..823bb8ed 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareProfileType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareProfileType.php @@ -38,7 +38,7 @@ class SoftwareProfileType extends AbstractType $resolver->setDefaults(array( 'data_class' => SoftwareProfile::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareType.php index 3e4df2c2..f221c390 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/SoftwareType.php @@ -37,7 +37,7 @@ class SoftwareType extends AbstractType $resolver->setDefaults(array( 'data_class' => Software::class, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/TraceType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/TraceType.php index c0f2599c..bd4b8ceb 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/TraceType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/TraceType.php @@ -40,7 +40,7 @@ class TraceType extends AbstractType $resolver->setDefaults(array( 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ValidationSettingsType.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ValidationSettingsType.php index 07f49557..5224fb38 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ValidationSettingsType.php +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Form/Type/Api/ValidationSettingsType.php @@ -43,7 +43,7 @@ class ValidationSettingsType extends AbstractType $resolver->setDefaults(array( 'data_class' => $this->objectClass, 'cascade_validation' => true, - 'csrf_protection' => false + 'allow_extra_fields' => true )); } diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/api.yml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/api.yml deleted file mode 100644 index fb32b408..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/api.yml +++ /dev/null @@ -1,69 +0,0 @@ -services: - opengnsys_server.api_client_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ClientType, Opengnsys\ServerBundle\Entity\Client] - - opengnsys_server.api_command_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\CommandType, Opengnsys\ServerBundle\Entity\Command] - - opengnsys_server.api_hardware_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\HardwareType, Opengnsys\ServerBundle\Entity\Hardware] - - opengnsys_server.api_hardware_profile_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\HardwareProfileType, Opengnsys\ServerBundle\Entity\HardwareProfile] - - opengnsys_server.api_image_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ImageType, Opengnsys\ServerBundle\Entity\Image] - - opengnsys_server.api_menu_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\MenuType, Opengnsys\ServerBundle\Entity\Menu] - - opengnsys_server.api_network_settings_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\NetworkSettingsType, Opengnsys\ServerBundle\Entity\NetworkSettings] - - opengnsys_server.api_organizational_unit_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\OrganizationalUnitType, Opengnsys\ServerBundle\Entity\OrganizationalUnit] - - opengnsys_server.api_os_name_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\OsNameType, Opengnsys\ServerBundle\Entity\OsName] - - opengnsys_server.api_partition_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\PartitionType, Opengnsys\ServerBundle\Entity\Partition] - - opengnsys_server.api_repository_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\RepositoryType, Opengnsys\ServerBundle\Entity\Repository] - - opengnsys_server.api_software_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\SoftwareType, Opengnsys\ServerBundle\Entity\Software] - - opengnsys_server.api_software_profile_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\SoftwareProfileType, Opengnsys\ServerBundle\Entity\SoftwareProfile] - - opengnsys_server.api_user_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\UserType, Opengnsys\ServerBundle\Entity\User] - - opengnsys_server.api_user_type_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\UserTypeType, Opengnsys\ServerBundle\Entity\UserType] - - opengnsys_server.api_validation_settings_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ValidationSettingsType, Opengnsys\ServerBundle\Entity\ValidationSettings] - - opengnsys_server.api_netboot_manager: - class: Globunet\ApiBundle\Domain\RESTManager - arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\NetbootType, Opengnsys\ServerBundle\Entity\Netboot] - diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Command.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Command.orm.xml index 42cf5f38..86457065 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Command.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Command.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Command" table="og_commands"> + <entity name="Opengnsys\ServerBundle\Entity\Command" table="og_commands" + repository-class="Opengnsys\ServerBundle\Entity\Repository\CommandRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Hardware.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Hardware.orm.xml index 5b68e58f..00c60eaa 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Hardware.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Hardware.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Hardware" table="og_hardwares"> + <entity name="Opengnsys\ServerBundle\Entity\Hardware" table="og_hardwares" + repository-class="Opengnsys\ServerBundle\Entity\Repository\HardwareRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/HardwareProfile.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/HardwareProfile.orm.xml index 5e8534fc..284fbe5f 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/HardwareProfile.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/HardwareProfile.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\HardwareProfile" table="og_hardware_profiles"> + <entity name="Opengnsys\ServerBundle\Entity\HardwareProfile" table="og_hardware_profiles" + repository-class="Opengnsys\ServerBundle\Entity\Repository\HardwareProfileRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Image.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Image.orm.xml index 3c4903c4..76d40740 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Image.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Image.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Image" table="og_images"> + <entity name="Opengnsys\ServerBundle\Entity\Image" table="og_images" + repository-class="Opengnsys\ServerBundle\Entity\Repository\ImageRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> @@ -13,13 +14,9 @@ <field name="comments" type="text" column="comments" length="65535" nullable="true"/> <field name="path" type="string" column="path" length="250" nullable="true"/> - <field name="type" column="type" type="integer" nullable="true"/> - <field name="revision" column="revision" type="integer" nullable="true"/> - <field name="partitionInfo" column="partition_info" type="text" nullable="true"/> - <field name="fileSize" column="file_size" type="string" length="20" nullable="true"/> <!-- diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Menu.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Menu.orm.xml index 13b4bd45..96ec3f4f 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Menu.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Menu.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Menu" table="og_menus"> + <entity name="Opengnsys\ServerBundle\Entity\Menu" table="og_menus" + repository-class="Opengnsys\ServerBundle\Entity\Repository\MenuRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Netboot.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Netboot.orm.xml index da3e02b1..b0daffd6 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Netboot.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Netboot.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Netboot" table="og_netboots"> + <entity name="Opengnsys\ServerBundle\Entity\Netboot" table="og_netboots" + repository-class="Opengnsys\ServerBundle\Entity\Repository\NetbootRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/NetworkSettings.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/NetworkSettings.orm.xml index 3411e033..8a5bebc7 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/NetworkSettings.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/NetworkSettings.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\NetworkSettings" table="og_network_settings"> + <entity name="Opengnsys\ServerBundle\Entity\NetworkSettings" table="og_network_settings" + repository-class="Opengnsys\ServerBundle\Entity\Repository\NetworkSettingsRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/OrganizationalUnit.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/OrganizationalUnit.orm.xml index 629aa957..51951dfc 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/OrganizationalUnit.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/OrganizationalUnit.orm.xml @@ -57,7 +57,7 @@ </many-to-one> <!-- - <many-to-many field="user" target-entity="\Opengnsys\ServerBundle\Entity\User" mapped-by="organizationalUnit"/> + <many-to-many field="user" target-entity="\Opengnsys\CoreBundle\Entity\User" mapped-by="organizationalUnit"/> --> </entity> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Partition.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Partition.orm.xml index 47ba56df..e9cfee0c 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Partition.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Partition.orm.xml @@ -2,10 +2,11 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Partition" table="og_partitions"> + <entity name="Opengnsys\ServerBundle\Entity\Partition" table="og_partitions" + repository-class="Opengnsys\ServerBundle\Entity\Repository\PartitionRepository"> <unique-constraints> - <unique-constraint name="unique_Partition_id_numDisk_numPartition" columns="id,num_disk,num_partition"/> + <unique-constraint name="unique_Partition_id_numDisk_numPartition" columns="client_id,num_disk,num_partition"/> </unique-constraints> <id name="id" type="integer" column="id"> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Software.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Software.orm.xml index 3f56a12f..e60a8917 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Software.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Software.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Software" table="og_softwares"> + <entity name="Opengnsys\ServerBundle\Entity\Software" table="og_softwares" + repository-class="Opengnsys\ServerBundle\Entity\Repository\SoftwareRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/SoftwareProfile.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/SoftwareProfile.orm.xml index 095399e2..09499e09 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/SoftwareProfile.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/SoftwareProfile.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\SoftwareProfile" table="og_software_profiles"> + <entity name="Opengnsys\ServerBundle\Entity\SoftwareProfile" table="og_software_profiles" + repository-class="Opengnsys\ServerBundle\Entity\Repository\SoftwareProfileRepository"> <id name="id" type="integer" column="id"> @@ -20,8 +21,7 @@ <many-to-many field="softwares" target-entity="\Opengnsys\ServerBundle\Entity\Software"> <cascade> - <cascade-persist/> - <cascade-remove/> + <cascade-all/> </cascade> <join-table name="og_software_profiles_softwares"> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Task.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Task.orm.xml index 129ba336..6ff885d3 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Task.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Task.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\Task" table="og_tasks"> + <entity name="Opengnsys\ServerBundle\Entity\Task" table="og_tasks" + repository-class="Opengnsys\ServerBundle\Entity\Repository\TaskRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Trace.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Trace.orm.xml index 063d60ec..90e23d59 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Trace.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/Trace.orm.xml @@ -26,7 +26,7 @@ </join-columns> </many-to-one> - <many-to-one field="doneBy" target-entity="\Opengnsys\ServerBundle\Entity\User" fetch="LAZY"> + <many-to-one field="doneBy" target-entity="\Opengnsys\CoreBundle\Entity\User" fetch="LAZY"> <join-columns> <join-column name="done_by" referenced-column-name="id"/> </join-columns> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/User.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/User.orm.xml deleted file mode 100644 index 3cdef99e..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/User.orm.xml +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\User" table="og_users"> - - <id name="id" type="integer" column="id"> - <generator strategy="AUTO"/> - </id> - - <field name="name" type="string" column="name" length="200" nullable="true"/> - - <field name="profile" column="profile" type="json_array" nullable="true"/> - - <many-to-many field="organizationalUnits" target-entity="\Opengnsys\ServerBundle\Entity\OrganizationalUnit" - inversed-by="users"> - <join-table name="og_users__organizational_units"> - <join-columns> - <join-column name="user_id" referenced-column-name="id"/> - </join-columns> - <inverse-join-columns> - <join-column name="organizational_unit_id" referenced-column-name="id"/> - </inverse-join-columns> - </join-table> - </many-to-many> - - </entity> -</doctrine-mapping> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/ValidationSettings.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/ValidationSettings.orm.xml index 5a597839..1157319e 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/ValidationSettings.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/ValidationSettings.orm.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\ValidationSettings" table="og_validation_settings"> + <entity name="Opengnsys\ServerBundle\Entity\ValidationSettings" table="og_validation_settings" + repository-class="Opengnsys\ServerBundle\Entity\Repository\ValidationSettingsRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/View.orm.xml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/View.orm.xml index 48b008af..89329119 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/View.orm.xml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/doctrine/View.orm.xml @@ -2,7 +2,8 @@ <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> - <entity name="Opengnsys\ServerBundle\Entity\View" table="og_views"> + <entity name="Opengnsys\ServerBundle\Entity\View" table="og_views" + repository-class="Opengnsys\ServerBundle\Entity\Repository\ViewRepository"> <id name="id" type="integer" column="id"> <generator strategy="AUTO"/> diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing.yml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing.yml index 55bd26a2..6b397f45 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing.yml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing.yml @@ -1,7 +1,3 @@ -opengnsys_server_homepage: - path: / - defaults: { _controller: OpengnsysServerBundle:Default:index } - opengnsys_server__api: type: rest resource: "@OpengnsysServerBundle/Resources/config/routing/api.yml" diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing/api.yml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing/api.yml index c2ef0fcd..c7f191af 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing/api.yml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing/api.yml @@ -46,10 +46,6 @@ software_profile: type: rest resource: Opengnsys\ServerBundle\Controller\Api\SoftwareProfileController name_prefix: opengnsys_server__api_ -user: - type: rest - resource: Opengnsys\ServerBundle\Controller\Api\UserController - name_prefix: opengnsys_server__api_ #validation_settings: # type: rest # resource: Opengnsys\ServerBundle\Controller\Api\ValidationSettingsController diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing_dev.yml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing_dev.yml index 39935e43..614acb48 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing_dev.yml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/routing_dev.yml @@ -1,7 +1,3 @@ -opengnsys_server_homepage: - path: / - defaults: { _controller: OpengnsysServerBundle:Default:index } - opengnsys_server__api: type: rest resource: "@OpengnsysServerBundle/Resources/config/routing/api.yml" diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/services.yml b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/services.yml index 501ce2f6..8eeb6409 100644 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/services.yml +++ b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/config/services.yml @@ -18,4 +18,70 @@ services: # SERVICE opengnsys_service.netboot: class: Opengnsys\ServerBundle\Service\NetbootService - arguments: ["%pxedir%", '@doctrine.orm.entity_manager']
\ No newline at end of file + arguments: ["%pxedir%", '@doctrine.orm.entity_manager'] + + # MANAGER + opengnsys_server.client_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ClientType, Opengnsys\ServerBundle\Entity\Client] + + opengnsys_server.command_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\CommandType, Opengnsys\ServerBundle\Entity\Command] + + opengnsys_server.hardware_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\HardwareType, Opengnsys\ServerBundle\Entity\Hardware] + + opengnsys_server.hardware_profile_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\HardwareProfileType, Opengnsys\ServerBundle\Entity\HardwareProfile] + + opengnsys_server.image_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ImageType, Opengnsys\ServerBundle\Entity\Image] + + opengnsys_server.menu_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\MenuType, Opengnsys\ServerBundle\Entity\Menu] + + opengnsys_server.network_settings_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\NetworkSettingsType, Opengnsys\ServerBundle\Entity\NetworkSettings] + + opengnsys_server.organizational_unit_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\OrganizationalUnitType, Opengnsys\ServerBundle\Entity\OrganizationalUnit] + + opengnsys_server.os_name_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\OsNameType, Opengnsys\ServerBundle\Entity\OsName] + + opengnsys_server.partition_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\PartitionType, Opengnsys\ServerBundle\Entity\Partition] + + opengnsys_server.repository_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\RepositoryType, Opengnsys\ServerBundle\Entity\Repository] + + opengnsys_server.software_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\SoftwareType, Opengnsys\ServerBundle\Entity\Software] + + opengnsys_server.software_profile_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\SoftwareProfileType, Opengnsys\ServerBundle\Entity\SoftwareProfile] + + opengnsys_server.user_type_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\UserTypeType, Opengnsys\ServerBundle\Entity\UserType] + + opengnsys_server.validation_settings_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\ValidationSettingsType, Opengnsys\ServerBundle\Entity\ValidationSettings] + + opengnsys_server.netboot_manager: + class: Opengnsys\CoreBundle\Domain\ModelExtendedManager + arguments: ["@doctrine.orm.entity_manager", "@form.factory", Opengnsys\ServerBundle\Form\Type\Api\NetbootType, Opengnsys\ServerBundle\Entity\Netboot] + diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/views/Default/index.html.twig b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/views/Default/index.html.twig deleted file mode 100644 index 7410e8a9..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Resources/views/Default/index.html.twig +++ /dev/null @@ -1 +0,0 @@ -Hello Opengnsys! diff --git a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Tests/Controller/DefaultControllerTest.php b/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Tests/Controller/DefaultControllerTest.php deleted file mode 100644 index 9594a885..00000000 --- a/admin/WebConsole3/backend/src/Opengnsys/ServerBundle/Tests/Controller/DefaultControllerTest.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Opengnsys\ServerBundle\Tests\Controller; - -use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; - -class DefaultControllerTest extends WebTestCase -{ - public function testIndex() - { - $client = static::createClient(); - - $crawler = $client->request('GET', '/'); - - $this->assertContains('Hello World', $client->getResponse()->getContent()); - } -} diff --git a/installer/console3_installer.sh b/installer/console3_installer.sh index 6a4f9c06..220229fd 100644 --- a/installer/console3_installer.sh +++ b/installer/console3_installer.sh @@ -6,12 +6,12 @@ PATH=$PATH:$INSTALL_TARGET/bin OPENGNSYS_CLIENTUSER="opengnsys" # Usuario Samba -# Sólo ejecutable por usuario root +# Solo ejecutable por usuario root if [ "$(whoami)" != 'root' ]; then echo "ERROR: this program must run under root privileges!!" exit 1 fi -# Error si OpenGnsys no está instalado (no existe el directorio del proyecto) +# Error si OpenGnsys no esta instalado (no existe el directorio del proyecto) if [ ! -d $INSTALL_TARGET ]; then echo "ERROR: OpenGnsys is not installed, cannot update!!" exit 1 @@ -82,7 +82,7 @@ function getNetworkSettings() function downloadFiles() { - cp -r /root/opengnsys/* $WORKDIR + cp -rf /root/opengnsys/* $WORKDIR #git clone gituser@opengnsys.es:/git/opengnsys -b webconsole3 $WORKDIR } @@ -125,25 +125,34 @@ function configureBackend() { mkdir -p $INSTALL_TARGET/www3 INSTALL_BACKEND=$INSTALL_TARGET/www3/backend echo $INSTALL_BACKEND - cp -r $WORKDIR/admin/WebConsole3/backend $INSTALL_BACKEND + cp -rf $WORKDIR/admin/WebConsole3/backend $INSTALL_BACKEND pushd $INSTALL_TARGET/www3/backend - echo "Configuración de la base de datos MYSQL" - echo "Usuario: " - read MYSQL_USER - sed -i -e "s/database_user:.*/database_user: "$MYSQL_USER"/g" $INSTALL_BACKEND/app/config/parameters.yml - echo "Password: " - read MYSQL_PASSWORD - sed -i -e "s/database_password:.*/database_password: "$MYSQL_PASSWORD"/g" $INSTALL_BACKEND/app/config/parameters.yml - - echo "Nombre de la base de datos. (En caso de que el usuario tenga permiso de crear nueva base de datos, dejar este campo vacío)" - read MYSQL_DB - if [ -z $MYSQL_DB ] || [ $MYSQL_DB = "" ] - then - MYSQL_DB="opengnsys" - fi - sed -i -e "s/database_name:.*/database_name: "$MYSQL_DB"/g" $INSTALL_BACKEND/app/config/parameters.yml + #echo "Configuración de la base de datos MYSQL" + #echo "Usuario: " + #read MYSQL_USER + #if [ -z $MYSQL_USER ] || [ $MYSQL_USER = "" ] + #then + # MYSQL_USER="u1consola1OG" + #fi + #sed -i -e "s/database_user:.*/database_user: "$MYSQL_USER"/g" $INSTALL_BACKEND/app/config/parameters.yml + # + #echo "Password: " + #read MYSQL_PASSWORD + #if [ -z $MYSQL_PASSWORD ] || [ $MYSQL_PASSWORD = "" ] + #then + # MYSQL_PASSWORD="c1consola1OG" + #fi + #sed -i -e "s/database_password:.*/database_password: "$MYSQL_PASSWORD"/g" $INSTALL_BACKEND/app/config/parameters.yml + # + #echo "Nombre de la base de datos. (En caso de que el usuario tenga permiso de crear nueva base de datos, dejar este campo vacío)" + #read MYSQL_DB + #if [ -z $MYSQL_DB ] || [ $MYSQL_DB = "" ] + #then + # MYSQL_DB="ogAdmBD3" + #fi + #sed -i -e "s/^database_name:.*/database_name: "$MYSQL_DB"/g" $INSTALL_BACKEND/app/config/parameters.yml php composer.phar update chmod 777 -R var/cache @@ -155,6 +164,10 @@ function configureBackend() { php app/console doctrine:schema:update --force php app/console doctrine:fixtures:load php app/console fos:user:create test test@opengnsys.es test + + # Preguntar si quiere migrar de la versión 1.1 anterior. + php app/console opengnsys:migration:execute + popd ## Añadir al fichero de configuracion del cliente "ogAdmClient.cfg" la Url de la nueva API Rest #echo "UrlApi=https://$SERVERIP/opengnsys3/rest/web/app_dev.php/api/" >> $INSTALL_TARGET/client/etc/ogAdmClient.cfg @@ -178,9 +191,7 @@ function configureFrontend() { popd } - # Logs - function getDateTime() { date "+%Y%m%d-%H%M%S" @@ -230,8 +241,8 @@ fi #getNetworkSettings #echoAndLog "Install dependencies" #installDependencies -#echoAndLog "Download source files" -#downloadFiles +echoAndLog "Download source files" +downloadFiles #echoAndLog "Configuring apache" #configureApache #echoAndLog "Configuring opengnsys client" |