Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Fix META_SOURCES options inheritance for parent/child workspaces: new…
Browse files Browse the repository at this point in the history
… AJXP_AbstractMetaSource abstract class from which all meta/index/metastore plugins must extend. Typical case is updating the quota on a workspace and seeing shared folders correctly updated.
  • Loading branch information
cdujeu committed Sep 10, 2014
1 parent e44641b commit bd2f014
Show file tree
Hide file tree
Showing 18 changed files with 101 additions and 108 deletions.
50 changes: 50 additions & 0 deletions core/src/core/classes/class.AJXP_AbstractMetaSource.php
@@ -0,0 +1,50 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio 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.
*
* Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
defined('AJXP_EXEC') or die( 'Access not allowed');

abstract class AJXP_AbstractMetaSource extends AJXP_Plugin {

/**
* @var AbstractAccessDriver
*/
protected $accessDriver;

/**
*
* @param AbstractAccessDriver $accessDriver
*/
public function initMeta($accessDriver){

$this->accessDriver = $accessDriver;
// Override options with parent META SOURCE options
// Could be refined ?
if($this->accessDriver->repository->hasParent()){
$parentRepo = ConfService::getRepositoryById($this->accessDriver->repository->getParentId());
if($parentRepo != null){
$sources = $parentRepo->getOption("META_SOURCES");
$qParent = $sources["meta.quota"];
$this->options = array_merge($this->options, $qParent);
}
}

}

}
Expand Up @@ -47,18 +47,14 @@ function __autoload_elastica ($class)
* @property Elastica\Index $currentIndex
* @property Elastica\Type $currentType
*/
class AjxpElasticSearch extends AJXP_Plugin
class AjxpElasticSearch extends AJXP_AbstractMetaSource
{
private $client;
private $currentIndex;
private $currentType;
private $nextId;
private $lastIdPath;

/**
* @var AbstractAccessDriver
*/
private $accessDriver;
private $metaFields = array();
private $indexContent = false;
private $specificId = "";
Expand All @@ -85,7 +81,7 @@ public function init($options)

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
if (!empty($this->metaFields) || $this->indexContent) {
$metaFields = $this->metaFields;
$el = $this->xPath->query("/indexer")->item(0);
Expand Down
8 changes: 2 additions & 6 deletions core/src/plugins/index.lucene/class.AjxpLuceneIndexer.php
Expand Up @@ -26,13 +26,9 @@
* @package AjaXplorer_Plugins
* @subpackage Index
*/
class AjxpLuceneIndexer extends AJXP_Plugin
class AjxpLuceneIndexer extends AJXP_AbstractMetaSource
{
private $currentIndex;
/**
* @var AbstractAccessDriver
*/
private $accessDriver;
private $metaFields = array();
private $indexContent = false;
private $specificId = "";
Expand All @@ -55,7 +51,7 @@ public function init($options)

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
if (!empty($this->metaFields) || $this->indexContent) {
$metaFields = $this->metaFields;
$el = $this->xPath->query("/indexer")->item(0);
Expand Down
33 changes: 20 additions & 13 deletions core/src/plugins/meta.comments/class.CommentsMetaManager.php
@@ -1,20 +1,27 @@
<?php
/**
* Created by JetBrains PhpStorm.
* User: admin
* Date: 11/09/13
* Time: 11:14
* To change this template use File | Settings | File Templates.
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio 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.
*
* Pydio 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 Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

define("AJXP_META_SPACE_COMMENTS", "AJXP_META_SPACE_COMMENTS");

class CommentsMetaManager extends AJXP_Plugin
class CommentsMetaManager extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
*/
private $accessDriver;
/**
* @var MetaStoreProvider
*/
Expand All @@ -28,7 +35,7 @@ class CommentsMetaManager extends AJXP_Plugin

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
$feed = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("feed");
if ($feed) {
$this->storageMode = "FEED";
Expand Down
5 changes: 2 additions & 3 deletions core/src/plugins/meta.exif/class.ExifMetaManager.php
Expand Up @@ -26,9 +26,8 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class ExifMetaManager extends AJXP_Plugin
class ExifMetaManager extends AJXP_AbstractMetaSource
{
protected $accessDriver;
protected $metaDefinitions;

public function init($options)
Expand All @@ -45,7 +44,7 @@ public function performChecks()

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
if(!function_exists("exif_read_data")) return ;
//$messages = ConfService::getMessages();
$def = $this->getMetaDefinition();
Expand Down
5 changes: 2 additions & 3 deletions core/src/plugins/meta.filehasher/class.FileHasher.php
Expand Up @@ -26,9 +26,8 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class FileHasher extends AJXP_Plugin
class FileHasher extends AJXP_AbstractMetaSource
{
protected $accessDriver;
const METADATA_HASH_NAMESPACE = "file_hahser";
/**
* @var MetaStoreProvider
Expand Down Expand Up @@ -83,7 +82,7 @@ public function parseSpecificContributions(&$contribNode)

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
$store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
if ($store === false) {
throw new Exception("The 'meta.simple_lock' plugin requires at least one active 'metastore' plugin");
Expand Down
3 changes: 2 additions & 1 deletion core/src/plugins/meta.git/class.GitManager.php
Expand Up @@ -26,7 +26,7 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class GitManager extends AJXP_Plugin
class GitManager extends AJXP_AbstractMetaSource
{

private $repoBase;
Expand All @@ -45,6 +45,7 @@ public function performChecks()
*/
public function initMeta($accessDriver)
{
parent::initMeta($accessDriver);
require_once("VersionControl/Git.php");
$repo = $accessDriver->repository;
$this->repoBase = $repo->getOption("PATH");
Expand Down
Expand Up @@ -26,7 +26,7 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class FSMonitoringManager extends AJXP_Plugin
class FSMonitoringManager extends AJXP_AbstractMetaSource
{
private $repoBase;

Expand All @@ -35,6 +35,7 @@ class FSMonitoringManager extends AJXP_Plugin
*/
public function initMeta($accessDriver)
{
parent::initMeta($accessDriver);
$repo = $accessDriver->repository;
$this->repoBase = $repo->getOption("PATH");
}
Expand Down
9 changes: 2 additions & 7 deletions core/src/plugins/meta.mount/class.FilesystemMounter.php
Expand Up @@ -27,13 +27,8 @@
* @subpackage Meta
*
*/
class FilesystemMounter extends AJXP_Plugin
class FilesystemMounter extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
*/
protected $accessDriver;

/**
* @var Repository
*/
Expand All @@ -56,7 +51,7 @@ public function beforeInitMeta($accessDriver, $repository)
*/
public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
$this->repository = $this->accessDriver->repository;
/*
if($this->isAlreadyMounted()) return;
Expand Down
7 changes: 1 addition & 6 deletions core/src/plugins/meta.quota/class.QuotaComputer.php
Expand Up @@ -26,7 +26,7 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class QuotaComputer extends AJXP_Plugin
class QuotaComputer extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
Expand All @@ -41,11 +41,6 @@ class QuotaComputer extends AJXP_Plugin
*/
protected $mailer;

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
}

protected function getWorkingPath()
{
$repo = $this->accessDriver->repository;
Expand Down
14 changes: 5 additions & 9 deletions core/src/plugins/meta.simple_lock/class.SimpleLockManager.php
Expand Up @@ -26,24 +26,20 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class SimpleLockManager extends AJXP_Plugin
class SimpleLockManager extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
*/
protected $accessDriver;
const METADATA_LOCK_NAMESPACE = "simple_lock";
/**
* @var MetaStoreProvider
*/
protected $metaStore;

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
public function initMeta($accessDriver)
{
parent::initMeta($accessDriver);
$store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
if ($store === false) {
throw new Exception("The 'meta.simple_lock' plugin requires at least one active 'metastore' plugin");
throw new Exception("The 'meta.simple_lock' plugin requires at least one active 'metastore' plugin");
}
$this->metaStore = $store;
$this->metaStore->initMeta($accessDriver);
Expand Down
8 changes: 2 additions & 6 deletions core/src/plugins/meta.svn/class.SvnManager.php
Expand Up @@ -29,14 +29,12 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class SvnManager extends AJXP_Plugin
class SvnManager extends AJXP_AbstractMetaSource
{
private static $svnListDir;
private static $svnListCache;
private $commitMessageParams;

protected $accessDriver;

public function init($options)
{
$this->options = $options;
Expand All @@ -46,10 +44,8 @@ public function init($options)
public function initMeta($accessDriver)
{
require_once("svn_lib.inc.php");

$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);
parent::init($this->options);

}

protected function initDirAndSelection($httpVars, $additionnalPathes = array(), $testRecycle = false)
Expand Down
11 changes: 1 addition & 10 deletions core/src/plugins/meta.syncable/class.ChangesTracker.php
Expand Up @@ -26,12 +26,8 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class ChangesTracker extends AJXP_Plugin
class ChangesTracker extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
*/
protected $accessDriver;
private $sqlDriver;

public function init($options)
Expand All @@ -40,11 +36,6 @@ public function init($options)
parent::init($options);
}

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
}

public function switchActions($actionName, $httpVars, $fileVars)
{
if($actionName != "changes" || !isSet($httpVars["seq_id"])) return false;
Expand Down
8 changes: 2 additions & 6 deletions core/src/plugins/meta.user/class.UserMetaManager.php
Expand Up @@ -27,12 +27,8 @@
* @package AjaXplorer_Plugins
* @subpackage Meta
*/
class UserMetaManager extends AJXP_Plugin
class UserMetaManager extends AJXP_AbstractMetaSource
{
/**
* @var AbstractAccessDriver
*/
protected $accessDriver;
/**
* @var MetaStoreProvider
*/
Expand All @@ -48,7 +44,7 @@ public function init($options)

public function initMeta($accessDriver)
{
$this->accessDriver = $accessDriver;
parent::initMeta($accessDriver);

$store = AJXP_PluginsService::getInstance()->getUniqueActivePluginForType("metastore");
if ($store === false) {
Expand Down

0 comments on commit bd2f014

Please sign in to comment.