Skip to content

Always accept UUID in addition to path #64

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

Merged
merged 1 commit into from
Jul 10, 2014
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ alpha-4

- [node] copy,move and clone - Target paths automatically append basename if target is a node.
- [query] Always show path next to resultset
- [node] `node:list` Enable listing nodes by UUID
- [node|shell] Most commands which accept a node path can also accept a UUID

### Bugs Fixes

Expand Down
26 changes: 26 additions & 0 deletions features/shell_path_change.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Feature: Change the shells current working path
In order to change the current working path of the shell
As a user that is logged into the shell
I should be able to run a command which does that

Background:
Given that I am logged in as "testuser"
And the "session_data.xml" fixtures are loaded

Scenario: Change the current working path to root
Given the current node is "/tests_general_base"
And I execute the "shell:path:change /" command
Then the command should not fail
And the current node should be "/"

Scenario: Change the current working path
Given the current node is "/"
And I execute the "shell:path:change /tests_general_base" command
Then the command should not fail
And the current node should be "/tests_general_base"

Scenario: Change the current working path with a UUID
Given the current node is "/"
And I execute the "shell:path:change 842e61c0-09ab-42a9-87c0-308ccc90e6f4" command
Then the command should not fail
And the current node should be "/tests_general_base/idExample"
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$workspaceName = $input->getArgument('workspaceName');
$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$correspondingPath = $currentNode->getCorrespondingNodePath($workspaceName);
$output->writeln($correspondingPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NodeDefinitionCommand extends PhpcrShellCommand
protected function configure()
{
$this->setName('node:definition');
$this->setDescription('Show the CND Definition of current node');
$this->setDescription('Show the CND Definition of specified node');
$this->addArgument('path', InputArgument::REQUIRED, 'Path of node');
$this->setHelp(<<<HERE
Show the CND definition of the primary type of the current node.
Expand All @@ -25,8 +25,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$workspace = $session->getWorkspace();
$namespaceRegistry = $workspace->getNamespaceRegistry();

Expand Down
44 changes: 44 additions & 0 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeEditCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

namespace PHPCR\Shell\Console\Command\Phpcr;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

class NodeEditCommand extends Command
{
protected function configure()
{
$this->setName('node:edit');
$this->setDescription('Edit the given node in the EDITOR configured by the system');
$this->addArgument('path', InputArgument::REQUIRED, 'Path of node');
$this->setHelp(<<<HERE
Edit the given node
HERE
);
}

public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$formatter = $this->getHelper('result_formatter');
$path = $session->getAbsPath($input->getArgument('path'));

$editor = $this->getHelper('editor');

$skipBinary = true;
$noRecurse = true;

ob_start();
$stream = fopen('php://output', 'w+', false);
$session->exportSystemView($path, $stream, $skipBinary, $noRecurse);
$out = ob_get_clean();
fclose($stream);
$out = $formatter->formatXml($out);

$in = $editor->fromString($out);
}
}

4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$nodeHelper = $this->getHelper('node');
$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$formatter = $this->getHelper('result_formatter');

$mixins = $currentNode->getMixinNodeTypes();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$transition = $input->getArgument('transition');
$currentNode->followLifecycleTransition($transition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$transitions = $currentNode->getAllowedLifecycleTransitions();

foreach ($transitions as $transition) {
Expand Down
9 changes: 1 addition & 8 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use PHPCR\PropertyType;
use PHPCR\Util\UUIDHelper;

class NodeListCommand extends Command
{
Expand Down Expand Up @@ -55,15 +54,9 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->showTemplate = $input->getOption('template');

$session = $this->getHelper('phpcr')->getSession();

$path = $input->getArgument('path');

if (true === UUIDHelper::isUUID($path)) {
$currentNode = $session->getNodeByIdentifier($path);
} else {
$path = $session->getAbsPath($path);
$currentNode = $session->getNode($path);
}
$currentNode = $session->getNodeByPathOrIdentifier($path);

if (!$this->showChildren && !$this->showProperties) {
$this->showChildren = true;
Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$mixinName = $input->getArgument('mixinName');
$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$currentNode->addMixin($mixinName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$srcChildRelPath = $input->getArgument('srcChildRelPath');
$destChildRelPath = $input->getArgument('destChildRelPath');
$node = $session->getNode($path);
$node = $session->getNodeByPathOrIdentifier($path);
$node->orderBefore($srcChildRelPath, $destChildRelPath);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$name = $input->getArgument('name');

$references = array(
Expand Down
9 changes: 4 additions & 5 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$targetPath = $session->getAbsPath($input->getArgument('path'));
$targetPath = $input->getArgument('path');
$currentPath = $session->getCwd();

// verify that node exists by trying to get it..
$targetNode = $session->getNode($targetPath);
$targetNode = $session->getNodeByPathOrIdentifier($targetPath);

if ($targetPath == '/') {
if ($targetNode->getPath() == '/') {
throw new \InvalidArgumentException(
'You cannot delete the root node!'
);
Expand All @@ -38,8 +38,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$session->removeItem($targetPath);

// if we deleted the current path, switch back to the parent node
if ($currentPath == $targetPath) {
echo $currentPath . ' vs. ' . $targetPath;
if ($currentPath == $session->getAbsPath($targetPath)) {
$session->chdir('..');
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$newName = $input->getArgument('newName');
$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$currentNode->rename($newName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$nodeTypeName = $input->getArgument('nodeTypeName');

$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$currentNode->setPrimaryType($nodeTypeName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$sharedSet = $currentNode->removeSharedSet();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);
$sharedSet = $currentNode->getSharedSet();

foreach ($sharedSet as $sharedNode) {
Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeTreeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public function execute(InputInterface $input, OutputInterface $output)
$this->showChildren = $input->getOption('children');
$this->showProperties = $input->getOption('properties');

$path = $session->getAbsPath($input->getArgument('path'));
$currentNode = $session->getNode($path);
$path = $input->getArgument('path');
$currentNode = $session->getNodeByPathOrIdentifier($path);

if (!$showChildren && !$showProperties) {
$this->showChildren = true;
Expand Down
4 changes: 2 additions & 2 deletions src/PHPCR/Shell/Console/Command/Phpcr/NodeUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ protected function configure()
public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$srcWorkspace = $input->getArgument('srcWorkspace');
$currentNode = $session->getNode($path);
$currentNode = $session->getNodeByPathOrIdentifier($path);
$currentNode->update($srcWorkspace);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$nodeHelper = $this->getHelper('node');
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$workspace = $session->getWorkspace();

$versionManager = $workspace->getVersionManager();

$node = $session->getNode($path);
$node = $session->getNodeByPathOrIdentifier($path);
$nodeHelper->assertNodeIsVersionable($node);

$version = $versionManager->checkin($path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$nodeHelper = $this->getHelper('node');
$absPath = $session->getAbsPath($input->getArgument('path'));
$absPath = $input->getArgument('path');
$workspace = $session->getWorkspace();

$node = $session->getNode($absPath);
$node = $session->getNodeByPathOrIdentifier($absPath);
$nodeHelper->assertNodeIsVersionable($node);

$versionManager = $workspace->getVersionManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public function execute(InputInterface $input, OutputInterface $output)
{
$session = $this->getHelper('phpcr')->getSession();
$nodeHelper = $this->getHelper('node');
$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$workspace = $session->getWorkspace();

$node = $session->getNode($path);
$node = $session->getNodeByPathOrIdentifier($path);
$nodeHelper->assertNodeIsVersionable($node);
$versionManager = $workspace->getVersionManager();
$version = $versionManager->checkpoint($path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function execute(InputInterface $input, OutputInterface $output)
$nodeHelper = $this->getHelper('node');
$table = $this->getHelper('table')->create();

$path = $session->getAbsPath($input->getArgument('path'));
$path = $input->getArgument('path');
$workspace = $session->getWorkspace();

$node = $session->getNode($path);
$node = $session->getNodeByPathOrIdentifier($path);
$nodeHelper->assertNodeIsVersionable($node);
$versionManager = $workspace->getVersionManager();
$history = $versionManager->getVersionHistory($path);
Expand Down
Loading