Skip to content

Commit

Permalink
Entities Manager
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
some more

Signed-off-by: Maxence Lange <[email protected]>
fixing stuff, better details

Signed-off-by: Maxence Lange <[email protected]>
still working on details

Signed-off-by: Maxence Lange <[email protected]>
details on members

Signed-off-by: Maxence Lange <[email protected]>
--short option

Signed-off-by: Maxence Lange <[email protected]>
create entities from command line

Signed-off-by: Maxence Lange <[email protected]>
cleaner way to check for owner

Signed-off-by: Maxence Lange <[email protected]>
search within accounts

Signed-off-by: Maxence Lange <[email protected]>
import displayName during migration

Signed-off-by: Maxence Lange <[email protected]>
display result in table

Signed-off-by: Maxence Lange <[email protected]>
admin right, some cleaning and sql logging

Signed-off-by: Maxence Lange <[email protected]>
add comments to sql log

Signed-off-by: Maxence Lange <[email protected]>
log exception from sql execution

Signed-off-by: Maxence Lange <[email protected]>
fixing and cleaning !

Signed-off-by: Maxence Lange <[email protected]>
fixing

Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed May 28, 2019
1 parent abeea8b commit 4014b36
Show file tree
Hide file tree
Showing 69 changed files with 7,917 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 3rdparty
Submodule 3rdparty updated 819 files
269 changes: 269 additions & 0 deletions core/Migrations/Version17000Date20190417091242.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
<?php
declare(strict_types=1);


/**
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Maxence Lange <[email protected]>
* @copyright 2019, Maxence Lange <[email protected]>
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/


namespace OC\Core\Migrations;


use Closure;
use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;


/**
*
*/
class Version17000Date20190417091242 extends SimpleMigrationStep {


/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
*
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options
): ISchemaWrapper {

/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();


/**
* entities
*
* - id string - a unique uuid to ident the entity
* - type string - type of the entity: no_member, unique, group, admin_group
* - owner_id string - id from 'entitied_accounts' for the owner
* - visibility small int - visible to all, visible to owner only, visible to members
* - access small int - free, invite only, request needed
* - name string - name of the entity
* - creation datetime
*/
$table = $schema->createTable('entities');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'owner_id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'visibility', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
]
);
$table->addColumn(
'access', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
]
);
$table->addColumn(
'name', Type::STRING,
[
'notnull' => true,
'length' => 63
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_accounts
*
* - id string - a unique uuid to ident the account
* - type string - local_user, mail_address, guest_user
* - account string - account/user_id
* - creation datetime
*/
$table = $schema->createTable('entities_accounts');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'account', Type::STRING,
[
'notnull' => true,
'length' => 127
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_members
*
* - id string - a unique uuid
* - entity_id string - id from 'entities'
* - account_id string - id from 'entities_accounts'
* - slave_entity_id string - id from 'entities'
* - status string - invited, requesting, member
* - level small int - 1=member, 4=moderator, 8=admin
* - creation datetime
*/
$table = $schema->createTable('entities_members');
$table->addColumn(
'id', Type::STRING,
[
'notnull' => true,
'length' => 11,
]
);
$table->addColumn(
'entity_id', Type::STRING,
[
'notnull' => true,
'length' => 11
]
);
$table->addColumn(
'account_id', Type::STRING,
[
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'slave_entity_id', Type::STRING,
[
'notnull' => false,
'length' => 11
]
);
$table->addColumn(
'status', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'level', Type::SMALLINT,
[
'notnull' => true,
'length' => 1,
'unsigned' => true
]
);
$table->addColumn(
'creation', Type::DATETIME,
[
'notnull' => true
]
);
$table->setPrimaryKey(['id']);


/**
* entities_types
*
* - id int - incremented and primary key, nothing more
* - type string - string that define the type
* - interface string - type of the type(sic)
* - class string - class to be called to manage the service
*/
$table = $schema->createTable('entities_types');
$table->addColumn(
'id', Type::INTEGER,
[
'autoincrement' => true,
'notnull' => true,
'length' => 3,
'unsigned' => true,
]
);
$table->addColumn(
'type', Type::STRING,
[
'notnull' => true,
'length' => 15
]
);
$table->addColumn(
'interface', Type::STRING,
[
'notnull' => true,
'length' => 31
]
);
$table->addColumn(
'class', Type::STRING,
[
'notnull' => true,
'length' => 127
]
);
$table->setPrimaryKey(['id']);


return $schema;
}
}
19 changes: 19 additions & 0 deletions core/register_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@
*
*/

use OC\Entities\Command\Create;
use OC\Entities\Command\Delete;
use OC\Entities\Command\Modify;
use OCP\AppFramework\QueryException;


/** @var $application Symfony\Component\Console\Application */
$application->add(new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand());
$application->add(new OC\Core\Command\Status);
Expand Down Expand Up @@ -166,6 +172,19 @@
$application->add(new OC\Core\Command\Security\ListCertificates(\OC::$server->getCertificateManager(null), \OC::$server->getL10N('core')));
$application->add(new OC\Core\Command\Security\ImportCertificate(\OC::$server->getCertificateManager(null)));
$application->add(new OC\Core\Command\Security\RemoveCertificate(\OC::$server->getCertificateManager(null)));

try {
$application->add(new OC\Entities\Command\Create(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Delete(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Details(OC::$server->getEntitiesManager()));
$application->add(new OC\Entities\Command\Install(OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Migration(OC::$server->getEntitiesManager(), OC::$server->getEntitiesMigrationHelper()));
$application->add(new OC\Entities\Command\Modify(OC::$server->getEntitiesManager(), OC::$server->getEntitiesHelper()));
$application->add(new OC\Entities\Command\Search(OC::$server->getEntitiesHelper(), OC::$server->getEntitiesManager()));
} catch (QueryException $e) {
OC::$server->getLogger()->log(3, 'QueryException while loading Entities/Commands: ' . $e->getMessage());
}

} else {
$application->add(new OC\Core\Command\Maintenance\Install(\OC::$server->getSystemConfig()));
}
63 changes: 63 additions & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@
'OCP\\Encryption\\IFile' => $baseDir . '/lib/public/Encryption/IFile.php',
'OCP\\Encryption\\IManager' => $baseDir . '/lib/public/Encryption/IManager.php',
'OCP\\Encryption\\Keys\\IStorage' => $baseDir . '/lib/public/Encryption/Keys/IStorage.php',
'OCP\\Entities\\Helper\\IEntitiesHelper' => $baseDir . '/lib/public/Entities/Helper/IEntitiesHelper.php',
'OCP\\Entities\\Helper\\IEntitiesMigrationHelper' => $baseDir . '/lib/public/Entities/Helper/IEntitiesMigrationHelper.php',
'OCP\\Entities\\IEntitiesManager' => $baseDir . '/lib/public/Entities/IEntitiesManager.php',
'OCP\\Entities\\IEntitiesQueryBuilder' => $baseDir . '/lib/public/Entities/IEntitiesQueryBuilder.php',
'OCP\\Entities\\Implementation\\IEntitiesAccounts\\IEntitiesAccounts' => $baseDir . '/lib/public/Entities/Interface/IEntitiesAccounts/IEntitiesAccounts.php',
'OCP\\Entities\\Implementation\\IEntitiesAccounts\\IEntitiesAccountsAdminRights' => $baseDir . '/lib/public/Entities/Interface/IEntitiesAccounts/IEntitiesAccountsAdminRights.php',
'OCP\\Entities\\Implementation\\IEntitiesAccounts\\IEntitiesAccountsSearchAccounts' => $baseDir . '/lib/public/Entities/Interface/IEntitiesAccounts/IEntitiesAccountsSearchAccounts.php',
'OCP\\Entities\\Implementation\\IEntitiesAccounts\\IEntitiesAccountsSearchDuplicate' => $baseDir . '/lib/public/Entities/Interface/IEntitiesAccounts/IEntitiesAccountsSearchDuplicate.php',
'OCP\\Entities\\Implementation\\IEntitiesAccounts\\IEntitiesAccountsSearchEntities' => $baseDir . '/lib/public/Entities/Interface/IEntitiesAccounts/IEntitiesAccountsSearchEntities.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntities' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntities.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntitiesAdminRights' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntitiesAdminRights.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntitiesConfirmCreation' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntitiesConfirmCreation.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntitiesOwnerIsNotMember' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntitiesOwnerIsNotMember.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntitiesSearchDuplicate' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntitiesSearchDuplicate.php',
'OCP\\Entities\\Implementation\\IEntities\\IEntitiesSearchEntities' => $baseDir . '/lib/public/Entities/Interface/IEntities/IEntitiesSearchEntities.php',
'OCP\\Entities\\Model\\IEntity' => $baseDir . '/lib/public/Entities/Model/IEntity.php',
'OCP\\Entities\\Model\\IEntityAccount' => $baseDir . '/lib/public/Entities/Model/IEntityAccount.php',
'OCP\\Entities\\Model\\IEntityMember' => $baseDir . '/lib/public/Entities/Model/IEntityMember.php',
'OCP\\Entities\\Model\\IEntityType' => $baseDir . '/lib/public/Entities/Model/IEntityType.php',
'OCP\\Federation\\Exceptions\\ActionNotSupportedException' => $baseDir . '/lib/public/Federation/Exceptions/ActionNotSupportedException.php',
'OCP\\Federation\\Exceptions\\AuthenticationFailedException' => $baseDir . '/lib/public/Federation/Exceptions/AuthenticationFailedException.php',
'OCP\\Federation\\Exceptions\\BadRequestException' => $baseDir . '/lib/public/Federation/Exceptions/BadRequestException.php',
Expand Down Expand Up @@ -744,6 +763,7 @@
'OC\\Core\\Migrations\\Version16000Date20190212081545' => $baseDir . '/core/Migrations/Version16000Date20190212081545.php',
'OC\\Core\\Migrations\\Version16000Date20190427105638' => $baseDir . '/core/Migrations/Version16000Date20190427105638.php',
'OC\\Core\\Migrations\\Version16000Date20190428150708' => $baseDir . '/core/Migrations/Version16000Date20190428150708.php',
'OC\\Core\\Migrations\\Version17000Date20190417091242' => $baseDir . '/core/Migrations/Version17000Date20190417091242.php',
'OC\\Core\\Notification\\RemoveLinkSharesNotifier' => $baseDir . '/core/Notification/RemoveLinkSharesNotifier.php',
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',
Expand Down Expand Up @@ -811,6 +831,49 @@
'OC\\Encryption\\Manager' => $baseDir . '/lib/private/Encryption/Manager.php',
'OC\\Encryption\\Update' => $baseDir . '/lib/private/Encryption/Update.php',
'OC\\Encryption\\Util' => $baseDir . '/lib/private/Encryption/Util.php',
'OC\\Entities\\Classes\\IEntitiesAccounts\\LocalUser' => $baseDir . '/lib/private/Entities/Classes/EntitiesAccounts/LocalUser.php',
'OC\\Entities\\Classes\\IEntitiesAccounts\\MailAddress' => $baseDir . '/lib/private/Entities/Classes/EntitiesAccounts/MailAddress.php',
'OC\\Entities\\Classes\\IEntities\\Account' => $baseDir . '/lib/private/Entities/Classes/Entities/Account.php',
'OC\\Entities\\Classes\\IEntities\\AdminGroup' => $baseDir . '/lib/private/Entities/Classes/Entities/AdminGroup.php',
'OC\\Entities\\Classes\\IEntities\\Group' => $baseDir . '/lib/private/Entities/Classes/Entities/Group.php',
'OC\\Entities\\Classes\\IEntities\\User' => $baseDir . '/lib/private/Entities/Classes/Entities/User.php',
'OC\\Entities\\Command\\Create' => $baseDir . '/lib/private/Entities/Command/Create.php',
'OC\\Entities\\Command\\Delete' => $baseDir . '/lib/private/Entities/Command/Delete.php',
'OC\\Entities\\Command\\Details' => $baseDir . '/lib/private/Entities/Command/Details.php',
'OC\\Entities\\Command\\ExtendedBase' => $baseDir . '/lib/private/Entities/Command/ExtendedBase.php',
'OC\\Entities\\Command\\Install' => $baseDir . '/lib/private/Entities/Command/Install.php',
'OC\\Entities\\Command\\Migration' => $baseDir . '/lib/private/Entities/Command/Migration.php',
'OC\\Entities\\Command\\Modify' => $baseDir . '/lib/private/Entities/Command/Modify.php',
'OC\\Entities\\Command\\Search' => $baseDir . '/lib/private/Entities/Command/Search.php',
'OC\\Entities\\Db\\CoreRequestBuilder' => $baseDir . '/lib/private/Entities/Db/CoreRequestBuilder.php',
'OC\\Entities\\Db\\EntitiesAccountsRequest' => $baseDir . '/lib/private/Entities/Db/EntitiesAccountsRequest.php',
'OC\\Entities\\Db\\EntitiesAccountsRequestBuilder' => $baseDir . '/lib/private/Entities/Db/EntitiesAccountsRequestBuilder.php',
'OC\\Entities\\Db\\EntitiesMembersRequest' => $baseDir . '/lib/private/Entities/Db/EntitiesMembersRequest.php',
'OC\\Entities\\Db\\EntitiesMembersRequestBuilder' => $baseDir . '/lib/private/Entities/Db/EntitiesMembersRequestBuilder.php',
'OC\\Entities\\Db\\EntitiesQueryBuilder' => $baseDir . '/lib/private/Entities/Db/EntitiesQueryBuilder.php',
'OC\\Entities\\Db\\EntitiesRequest' => $baseDir . '/lib/private/Entities/Db/EntitiesRequest.php',
'OC\\Entities\\Db\\EntitiesRequestBuilder' => $baseDir . '/lib/private/Entities/Db/EntitiesRequestBuilder.php',
'OC\\Entities\\Db\\EntitiesTypesRequest' => $baseDir . '/lib/private/Entities/Db/EntitiesTypesRequest.php',
'OC\\Entities\\Db\\EntitiesTypesRequestBuilder' => $baseDir . '/lib/private/Entities/Db/EntitiesTypesRequestBuilder.php',
'OC\\Entities\\EntitiesManager' => $baseDir . '/lib/private/Entities/EntitiesManager.php',
'OC\\Entities\\Exceptions\\EntityAccountAlreadyExistsException' => $baseDir . '/lib/private/Entities/Exceptions/EntityAccountAlreadyExistsException.php',
'OC\\Entities\\Exceptions\\EntityAccountCreationException' => $baseDir . '/lib/private/Entities/Exceptions/EntityAccountCreationException.php',
'OC\\Entities\\Exceptions\\EntityAccountNotFoundException' => $baseDir . '/lib/private/Entities/Exceptions/EntityAccountNotFoundException.php',
'OC\\Entities\\Exceptions\\EntityAlreadyExistsException' => $baseDir . '/lib/private/Entities/Exceptions/EntityAlreadyExistsException.php',
'OC\\Entities\\Exceptions\\EntityCreationException' => $baseDir . '/lib/private/Entities/Exceptions/EntityCreationException.php',
'OC\\Entities\\Exceptions\\EntityMemberAlreadyExistsException' => $baseDir . '/lib/private/Entities/Exceptions/EntityMemberAlreadyExistsException.php',
'OC\\Entities\\Exceptions\\EntityMemberCreationException' => $baseDir . '/lib/private/Entities/Exceptions/EntityMemberCreationException.php',
'OC\\Entities\\Exceptions\\EntityMemberNotFoundException' => $baseDir . '/lib/private/Entities/Exceptions/EntityMemberNotFoundException.php',
'OC\\Entities\\Exceptions\\EntityNotFoundException' => $baseDir . '/lib/private/Entities/Exceptions/EntityNotFoundException.php',
'OC\\Entities\\Exceptions\\EntityTypeNotFoundException' => $baseDir . '/lib/private/Entities/Exceptions/EntityTypeNotFoundException.php',
'OC\\Entities\\Exceptions\\ImplementationNotFoundException' => $baseDir . '/lib/private/Entities/Exceptions/ImplementationNotFoundException.php',
'OC\\Entities\\FullMockup' => $baseDir . '/lib/private/Entities/FullMockup.php',
'OC\\Entities\\Helper\\EntitiesHelper' => $baseDir . '/lib/private/Entities/Helper/EntitiesHelper.php',
'OC\\Entities\\Helper\\EntitiesMigrationHelper' => $baseDir . '/lib/private/Entities/Helper/EntitiesMigrationHelper.php',
'OC\\Entities\\Model\\Entity' => $baseDir . '/lib/private/Entities/Model/Entity.php',
'OC\\Entities\\Model\\EntityAccount' => $baseDir . '/lib/private/Entities/Model/EntityAccount.php',
'OC\\Entities\\Model\\EntityMember' => $baseDir . '/lib/private/Entities/Model/EntityMember.php',
'OC\\Entities\\Model\\EntityType' => $baseDir . '/lib/private/Entities/Model/EntityType.php',
'OC\\Federation\\CloudFederationFactory' => $baseDir . '/lib/private/Federation/CloudFederationFactory.php',
'OC\\Federation\\CloudFederationNotification' => $baseDir . '/lib/private/Federation/CloudFederationNotification.php',
'OC\\Federation\\CloudFederationProviderManager' => $baseDir . '/lib/private/Federation/CloudFederationProviderManager.php',
Expand Down
Loading

0 comments on commit 4014b36

Please sign in to comment.