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

Commit

Permalink
TaskController is a "SqlTableProvider" plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed May 24, 2016
1 parent a546843 commit 4aba2d4
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 12 deletions.
17 changes: 10 additions & 7 deletions core/src/plugins/core.mq/class.MqManager.php
Expand Up @@ -191,11 +191,13 @@ public function sendInstantMessage($xmlContent, $repositoryId, $targetUserId = n
$input["NODE_PATHES"] = $nodePathes;
}


// Publish on NSQ
$nsq = new nsqphp;
$nsq->publishTo("127.0.0.1", 1);
$nsq->publish('im', new \nsqphp\Message\Message(json_encode($input)));
$host = $this->getFilteredOption("WS_SERVER_HOST");
if(!empty($host) && !empty($port)){
// Publish on NSQ
$nsq = new nsqphp;
$nsq->publishTo($host, 1);
$nsq->publish('im', new \nsqphp\Message\Message(json_encode($input)));
}

$this->hasPendingMessage = true;

Expand All @@ -217,8 +219,9 @@ public function appendRefreshInstruction(ResponseInterface &$responseInterface){
}

/**
* @param $request
* @param $response
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @throws \Pydio\Core\Exception\AuthRequiredException
*/
public function clientChannelMethod(ServerRequestInterface $request, ResponseInterface &$response)
{
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/core.tasks/create.mysql
Expand Up @@ -13,5 +13,5 @@ CREATE TABLE IF NOT EXISTS `ajxp_tasks` (
`nodes` text NOT NULL,
PRIMARY KEY (`uid`),
KEY `userId` (`userId`,`status`),
FULLTEXT KEY `nodes` (`nodes`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Task persistence layer';
INDEX (nodes(40))
) DEFAULT CHARSET=utf8 COMMENT='Task persistence layer';
20 changes: 20 additions & 0 deletions core/src/plugins/core.tasks/create.pgsql
@@ -0,0 +1,20 @@
CREATE TABLE ajxp_tasks (
uid VARCHAR(255) NOT NULL ,
flags INTEGER NOT NULL,
label VARCHAR(255) NOT NULL,
userId VARCHAR(255) NOT NULL,
wsId VARCHAR(32) NOT NULL,
status INTEGER NOT NULL,
status_msg VARCHAR(500) NOT NULL,
progress INTEGER NOT NULL,
schedule VARCHAR(500) NOT NULL,
action VARCHAR(255) NOT NULL,
parameters VARCHAR(500) NOT NULL,
nodes VARCHAR(500) NOT NULL
);

CREATE INDEX ajxp_task_idx ON ajxp_tasks ('uid');
CREATE INDEX ajxp_task_usr_idx ON ajxp_tasks ('userId');
CREATE INDEX ajxp_task_status_idx ON ajxp_tasks ('status');
CREATE INDEX ajxp_task_nodes_idx ON ajxp_tasks ('nodes');

19 changes: 19 additions & 0 deletions core/src/plugins/core.tasks/create.sqlite
@@ -0,0 +1,19 @@
CREATE TABLE ajxp_tasks (
uid text NOT NULL ,
flags integer NOT NULL,
label text NOT NULL,
userId text NOT NULL,
wsId text NOT NULL,
status INTEGER NOT NULL,
status_msg text NOT NULL,
progress INTEGER NOT NULL,
schedule text NOT NULL,
action text NOT NULL,
parameters text NOT NULL,
nodes text NOT NULL
);

CREATE INDEX ajxp_task_idx ON ajxp_tasks (uid);
CREATE INDEX ajxp_task_usr_idx ON ajxp_tasks (userId);
CREATE INDEX ajxp_task_status_idx ON ajxp_tasks (status);
CREATE INDEX ajxp_task_nodes_idx ON ajxp_tasks (nodes);
17 changes: 14 additions & 3 deletions core/src/plugins/core.tasks/src/TaskController.php
Expand Up @@ -27,6 +27,7 @@
use Pydio\Core\Http\Message\UserMessage;
use Pydio\Core\Http\SimpleRestResourceRouter;
use Pydio\Core\PluginFramework\Plugin;
use Pydio\Core\PluginFramework\SqlTableProvider;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\Utils;
Expand All @@ -35,7 +36,7 @@

defined('AJXP_EXEC') or die('Access not allowed');

class TaskController extends Plugin
class TaskController extends Plugin implements SqlTableProvider
{

public function init($options)
Expand Down Expand Up @@ -143,7 +144,7 @@ public function attachTasksToNode(AJXP_Node &$node, $isContextNode = false, $det
public function enrichConsumeChannel(ServerRequestInterface &$requestInterface, ResponseInterface &$responseInterface){

if(AuthService::getLoggedUser() == null || ConfService::getRepository() == null){
return [];
return;
}
$respType = &$responseInterface->getBody();
if(!$respType instanceof \Pydio\Core\Http\Response\SerializableResponseStream && !$respType->getSize()){
Expand All @@ -157,5 +158,15 @@ public function enrichConsumeChannel(ServerRequestInterface &$requestInterface,

}


/**
* Install SQL table using a dibi driver data
* @param $param array("SQL_DRIVER" => $dibiDriverData)
* @return mixed
*/
public function installSQLTables($param)
{
$p = Utils::cleanDibiDriverParameters($param["SQL_DRIVER"]);
return Utils::runCreateTablesQuery($p, $this->getBaseDir()."/create.sql");
}

}
1 change: 1 addition & 0 deletions core/src/plugins/core.tasks/src/TaskService.php
Expand Up @@ -28,6 +28,7 @@
use Pydio\Conf\Core\AbstractAjxpUser;
use Pydio\Core\Controller\Controller;
use Pydio\Core\Exception\PydioException;
use Pydio\Core\PluginFramework\SqlTableProvider;
use Pydio\Core\Services\AuthService;
use Pydio\Core\Services\ConfService;
use Pydio\Core\Utils\Utils;
Expand Down

0 comments on commit 4aba2d4

Please sign in to comment.