Skip to content
Merged
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
6 changes: 3 additions & 3 deletions features/repository_descriptor_list.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Feature: List Repository Descriptors
And I execute the "repository:descriptor:list" command
Then the command should not fail
And I should see a table containing the following rows:
| Key | Value |
| jcr.repository.name | Jackrabbit |
| jcr.repository.vendor | Apache Software Foundation |
| Key | Value | Standard? |
| jcr.repository.name | Jackrabbit | yes |
| jcr.repository.vendor | Apache Software Foundation | yes |
21 changes: 12 additions & 9 deletions src/PHPCR/Shell/Console/Application/ShellApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
use Jackalope\NotImplementedException;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Formatter\OutputFormatter;
use PHPCR\Shell\Console\Helper\RepositoryHelper;
use PHPCR\Shell\Console\Command\PhpcrShellCommand;

class ShellApplication extends Application
{
Expand Down Expand Up @@ -136,6 +138,16 @@ public function init()
$this->transports[$transport->getName()] = $transport;;
}

$session = $this->getSession($this->sessionInput);

$this->getHelperSet()->set(new EditorHelper($session));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i believe that helper thing needs to take a set multiple don't you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be easiser ..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$this->getHelperSet()->set(new PhpcrConsoleDumperHelper());
$this->getHelperSet()->set(new PhpcrHelper($session));
$this->getHelperSet()->set(new ResultFormatterHelper());
$this->getHelperSet()->set(new TextHelper());
$this->getHelperSet()->set(new NodeHelper($session));
$this->getHelperSet()->set(new RepositoryHelper($session->getRepository()));

// add new commands
$this->add(new AccessControlPrivilegeListCommand());
$this->add(new RepositoryDescriptorListCommand());
Expand Down Expand Up @@ -239,15 +251,6 @@ public function init()
->setName('workspace-purge')
);

$this->initSession();

$this->getHelperSet()->set(new EditorHelper($this->session));
$this->getHelperSet()->set(new PhpcrConsoleDumperHelper());
$this->getHelperSet()->set(new PhpcrHelper($this->session));
$this->getHelperSet()->set(new ResultFormatterHelper());
$this->getHelperSet()->set(new TextHelper());
$this->getHelperSet()->set(new NodeHelper($this->session));

$this->initialized = true;
}

Expand Down
6 changes: 5 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockInfoCommand extends Command
class LockInfoCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -23,6 +24,9 @@ protected function configure()
above that node.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
$this->dequiresDescriptor('jackalope.not_implemented.lock.get');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is dequires??? blew my mind!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opposite of requires .. it requires that the given option is NOT set.

}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockLockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockLockCommand extends Command
class LockLockCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand Down Expand Up @@ -51,6 +52,8 @@ protected function configure()
It is possible to lock a node even if it is checked-in.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockRefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockRefreshCommand extends Command
class LockRefreshCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -23,6 +24,8 @@ protected function configure()
has no effect.
HERE
);
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
$this->dequiresDescriptor('jackalope.not_implemented.lock.refresh');
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockTokenAddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockTokenAddCommand extends Command
class LockTokenAddCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -22,6 +23,8 @@ protected function configure()
specified by that particular lock token.
HERE
);
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockTokenListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockTokenListCommand extends Command
class LockTokenListCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -22,6 +23,8 @@ protected function configure()
locks, since session-scoped locks do not have tokens.
HERE
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inconsistency see?

$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockTokenRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockTokenRemoveCommand extends Command
class LockTokenRemoveCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -19,6 +20,8 @@ protected function configure()
Removes the specified lock token from the current Session.
HERE
);
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
$this->dequiresDescriptor('jackalope.not_implemented.lock.token');
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
4 changes: 3 additions & 1 deletion src/PHPCR/Shell/Console/Command/LockUnlockCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class LockUnlockCommand extends Command
class LockUnlockCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -35,6 +36,7 @@ protected function configure()
lock-related properties will be changed despite the checked-in status).
HERE
);
$this->requiresDescriptor(RepositoryInterface::OPTION_LOCKING_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use PHPCR\NodeType\NoSuchNodeTypeException;
use PHPCR\Util\CND\Parser\CndParser;
use PHPCR\NamespaceException;
use PHPCR\RepositoryInterface;

class NodeLifecycleFollowCommand extends Command
class NodeLifecycleFollowCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -30,6 +31,8 @@ protected function configure()
need to call save.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_LIFECYCLE_SUPPORTED, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the interface has to do with the implementations? should not the same Repository implementations should have these options there?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are capacilties defined by PHPCR, so are part of the PHPCR interface. The implementations can add their own capbilties if they choose, but obviously they will not be standard.

}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/NodeLifecycleListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
use PHPCR\NodeType\NoSuchNodeTypeException;
use PHPCR\Util\CND\Parser\CndParser;
use PHPCR\NamespaceException;
use PHPCR\RepositoryInterface;

class NodeLifecycleListCommand extends Command
class NodeLifecycleListCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -21,6 +22,8 @@ protected function configure()
Returns the list of valid state transitions for this node.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_LIFECYCLE_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
7 changes: 5 additions & 2 deletions src/PHPCR/Shell/Console/Command/NodeSharedRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
use PHPCR\Util\CND\Parser\CndParser;
use PHPCR\NamespaceException;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class NodeSharedRemoveCommand extends Command
class NodeSharedRemoveCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -27,7 +28,9 @@ protected function configure()

If this node is not shared this method removes only this node.
HERE
);
);

$this->requiresDescriptor(RepositoryInterface::OPTION_SHAREABLE_NODES_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/NodeSharedShowCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
use PHPCR\Util\CND\Parser\CndParser;
use PHPCR\NamespaceException;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class NodeSharedShowCommand extends Command
class NodeSharedShowCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -27,6 +28,8 @@ protected function configure()
If this node is not shared then only this node is shown.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_SHAREABLE_NODES_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
41 changes: 41 additions & 0 deletions src/PHPCR/Shell/Console/Command/PhpcrShellCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace PHPCR\Shell\Console\Command;

use Symfony\Component\Console\Command\Command;

class PhpcrShellCommand extends Command
{
protected $descriptorRequires = array();
protected $descriptorDequires = array();

public function requiresDescriptor($descriptorKey, $value = null)
{
$this->descriptorRequires[$descriptorKey] = $value;
}

public function dequiresDescriptor($descriptorKey, $value = null)
{
$this->descriptorDequires[$descriptorKey] = $value;
}

public function isEnabled()
{
foreach ($this->descriptorRequires as $key => $value) {
$has = $this->getHelper('repository')->hasDescriptor($key, $value);
if (!$has) {
return false;
}
}

foreach ($this->descriptorDequires as $key => $value) {
$has = $this->getHelper('repository')->hasDescriptor($key, $value);

if ($has) {
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,30 @@ public function execute(InputInterface $input, OutputInterface $output)
$keys = $repository->getDescriptorKeys();

$table = clone $this->getHelper('table');
$table->setHeaders(array('Key', 'Value'));
$table->setHeaders(array('Key', 'Value', 'Standard?'));

foreach ($keys as $key) {
$descriptor = $repository->getDescriptor($key);
$isStandard = $repository->isStandardDescriptor($key);
if (is_array($descriptor)) {
$descriptor = implode(', ', $descriptor);
$descriptor = implode(', ', $this->getDescriptorValue($descriptor));
}
$table->addRow(array($key, $descriptor));
$table->addRow(array(
$key,
$this->getDescriptorValue($descriptor),
$isStandard ? 'yes' : 'no',
));
}

$table->render($output);
}

private function getDescriptorValue($value)
{
if (is_bool($value)) {
return $value ? 'true' : 'false';
}

return $value;
}
}
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/RetentionHoldAddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class RetentionHoldAddCommand extends Command
class RetentionHoldAddCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -26,6 +27,8 @@ protected function configure()
specified. They are application-dependent.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_RETENTION_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
5 changes: 4 additions & 1 deletion src/PHPCR/Shell/Console/Command/RetentionHoldListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\RepositoryInterface;

class RetentionHoldListCommand extends Command
class RetentionHoldListCommand extends PhpcrShellCommand
{
protected function configure()
{
Expand All @@ -20,6 +21,8 @@ protected function configure()
existing node at <info>absPath</info>.
HERE
);

$this->requiresDescriptor(RepositoryInterface::OPTION_RETENTION_SUPPORTED, true);
}

public function execute(InputInterface $input, OutputInterface $output)
Expand Down
Loading