Skip to content

[JENKINS] Capabilities manager #15093 #17834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions apps/files/appinfo/application.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
/**
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Tobias Kaminsky <[email protected]>
* @author Vincent Petry <[email protected]>
Expand All @@ -21,8 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files\Appinfo;
namespace OCA\Files\AppInfo;

use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App;
Expand Down Expand Up @@ -68,5 +66,10 @@ public function __construct(array $urlParams=array()) {
$homeFolder
);
});

/*
* Register capabilities
*/
$container->registerCapability('OCA\Files\Capabilities');
}
}
9 changes: 3 additions & 6 deletions apps/files/appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* @author Bart Visscher <[email protected]>
* @author Joas Schilling <[email protected]>
* @author Lukas Reschke <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Tobias Kaminsky <[email protected]>
* @author Tom Needham <[email protected]>
* @author Vincent Petry <[email protected]>
Expand All @@ -24,8 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files\Appinfo;
namespace OCA\Files\AppInfo;

$application = new Application();
$application->registerRoutes(
Expand Down Expand Up @@ -82,6 +81,4 @@
$this->create('download', 'download{file}')
->requirements(array('file' => '.*'))
->actionInclude('files/download.php');

// Register with the capabilities API
\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files\Capabilities', 'getCapabilities'), 'files', \OCP\API::USER_AUTH);

37 changes: 23 additions & 14 deletions apps/files/lib/capabilities.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @author Christopher Schäpers <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Tom Needham <[email protected]>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
Expand All @@ -20,19 +20,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files;

class Capabilities {

public static function getCapabilities() {
return new \OC_OCS_Result(array(
'capabilities' => array(
'files' => array(
'bigfilechunking' => true,
),
),
));
namespace OCA\Files;

use OCP\Capabilities\ICapability;

/**
* Class Capabilities
*
* @package OCA\Files
*/
class Capabilities implements ICapability {

/**
* Return this classes capabilities
*
* @return array
*/
public function getCapabilities() {
return [
'files' => [
'bigfilechunking' => true,
],
];
}

}
2 changes: 1 addition & 1 deletion apps/files_external/appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

namespace OCA\Files_External\Appinfo;
namespace OCA\Files_External\AppInfo;

use \OCA\Files_External\Controller\AjaxController;
use \OCP\AppFramework\App;
Expand Down
2 changes: 1 addition & 1 deletion apps/files_external/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*
*/

namespace OCA\Files_External\Appinfo;
namespace OCA\Files_External\AppInfo;

/**
* @var $this \OC\Route\Router
Expand Down
9 changes: 8 additions & 1 deletion apps/files_sharing/appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* @author Morris Jobke <[email protected]>
* @author Robin Appelman <[email protected]>
* @author Roeland Jago Douma <[email protected]>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
Expand All @@ -20,7 +21,7 @@
*
*/

namespace OCA\Files_Sharing\Appinfo;
namespace OCA\Files_Sharing\AppInfo;

use OCA\Files_Sharing\Helper;
use OCA\Files_Sharing\MountProvider;
Expand All @@ -31,6 +32,7 @@
use OCA\Files_Sharing\Controllers\ShareController;
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
use \OCP\IContainer;
use OCA\Files_Sharing\Capabilities;

class Application extends App {
public function __construct(array $urlParams = array()) {
Expand Down Expand Up @@ -122,6 +124,11 @@ public function __construct(array $urlParams = array()) {
$server->getConfig()
);
});

/*
* Register capabilities
*/
$container->registerCapability('OCA\Files_Sharing\Capabilities');
}

public function registerMountProviders() {
Expand Down
5 changes: 0 additions & 5 deletions apps/files_sharing/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,3 @@ function() {
array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
'files_sharing');

// Register with the capabilities API
API::register('get',
'/cloud/capabilities',
array('OCA\Files_Sharing\Capabilities', 'getCapabilities'),
'files_sharing', API::USER_AUTH);
32 changes: 9 additions & 23 deletions apps/files_sharing/lib/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,29 @@
*/
namespace OCA\Files_Sharing;

use OCP\Capabilities\ICapability;
use \OCP\IConfig;

/**
* Class Capabilities
*
* @package OCA\Files_Sharing
*/
class Capabilities {
class Capabilities implements ICapability {

/** @var IConfig */
private $config;

/**
* @param IConfig $config
*/
public function __construct(IConfig $config) {
$this->config = $config;
}

/**
* @return \OC_OCS_Result
*/
public static function getCapabilities() {
$config = \OC::$server->getConfig();
$cap = new Capabilities($config);
return $cap->getCaps();
}


/**
* @return \OC_OCS_Result
* Return this classes capabilities
*
* @return array
*/
public function getCaps() {
public function getCapabilities() {
$res = [];

$public = [];
Expand All @@ -76,12 +66,8 @@ public function getCaps() {

$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';


return new \OC_OCS_Result([
'capabilities' => [
'files_sharing' => $res
],
]);
return [
'files_sharing' => $res,
];
}

}
7 changes: 3 additions & 4 deletions apps/files_sharing/tests/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
* @return string[]
*/
private function getFilesSharingPart(array $data) {
$this->assertArrayHasKey('capabilities', $data);
$this->assertArrayHasKey('files_sharing', $data['capabilities']);
return $data['capabilities']['files_sharing'];
$this->assertArrayHasKey('files_sharing', $data);
return $data['files_sharing'];
}

/**
Expand All @@ -53,7 +52,7 @@ private function getResults(array $map) {
$stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock();
$stub->method('getAppValue')->will($this->returnValueMap($map));
$cap = new Capabilities($stub);
$result = $this->getFilesSharingPart($cap->getCaps()->getData());
$result = $this->getFilesSharingPart($cap->getCapabilities());
return $result;
}

Expand Down
37 changes: 37 additions & 0 deletions apps/files_trashbin/appinfo/application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* @author Roeland Jago Douma <[email protected]>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* 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, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files_Trashbin\AppInfo;

use OCP\AppFramework\App;

class Application extends App {
public function __construct(array $urlParams = array()) {
parent::__construct('files_trashbin', $urlParams);

$container = $this->getContainer();

/*
* Register capabilities
*/
$container->registerCapability('OCA\Files_Trashbin\Capabilities');
}
}
11 changes: 6 additions & 5 deletions apps/files_trashbin/appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?php
/**
* @author Georg Ehrke <[email protected]>
* @author Joas Schilling <[email protected]>
* @author Lukas Reschke <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
* @author Vincent Petry <[email protected]>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
Expand All @@ -22,6 +21,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Files_Trashbin\AppInfo;

$application = new Application();

$this->create('core_ajax_trashbin_preview', 'ajax/preview.php')
->actionInclude('files_trashbin/ajax/preview.php');
$this->create('files_trashbin_ajax_delete', 'ajax/delete.php')
Expand All @@ -33,6 +37,3 @@
$this->create('files_trashbin_ajax_undelete', 'ajax/undelete.php')
->actionInclude('files_trashbin/ajax/undelete.php');


// Register with the capabilities API
\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files_Trashbin\Capabilities', 'getCapabilities'), 'files_trashbin', \OCP\API::USER_AUTH);
22 changes: 12 additions & 10 deletions apps/files_trashbin/lib/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* @author Lukas Reschke <[email protected]>
* @author Morris Jobke <[email protected]>
* @author Roeland Jago Douma <[email protected]>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
Expand All @@ -22,25 +23,26 @@

namespace OCA\Files_Trashbin;

use OCP\Capabilities\ICapability;

/**
* Class Capabilities
*
* @package OCA\Files_Trashbin
*/
class Capabilities {
class Capabilities implements ICapability {

/**
* @return \OC_OCS_Result
* Return this classes capabilities
*
* @return array
*/
public static function getCapabilities() {
return new \OC_OCS_Result(array(
'capabilities' => array(
'files' => array(
'undelete' => true,
),
),
));
public function getCapabilities() {
return [
'files' => [
'undelete' => true
]
];
}

}
Loading