Skip to content

Commit a1e677b

Browse files
committed
Merge pull request #98 from phpcr/jackalope-fs
Added jackalope-fs transport
2 parents 33dbe4f + 48ff4ac commit a1e677b

29 files changed

+365
-154
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ php:
99
- 5.4
1010

1111
before_script:
12-
- composer install --dev
12+
- composer require "symfony/symfony" "2.6.*" --no-update
13+
- composer install
1314
- bash tests/bin/travis_jackrabbit.sh
1415

1516
script:

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Changelog
44
dev-master
55
----------
66

7+
- [transport] Added transport layer for experimental Jackalope FS implementation
8+
- [node] Added wilcard support to applicable node commands, including "node:list", "node:remove" and "node:property:show"
79
- [global] Refactored to use DI container and various general improvements
810
- [node:references] Shows the referencing node paths instead of the referrered-to node path(s)
911

composer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"symfony/finder": "~2.3",
1010
"symfony/serializer": "~2.3",
1111
"symfony/yaml": "~2.3",
12-
"symfony/dependency-injection": "~2.3"
12+
"symfony/dependency-injection": "~2.3",
13+
"dantleech/glob": "~0.1"
1314
},
1415
"minimum-stability": "dev",
1516
"require-dev": {
@@ -20,11 +21,13 @@
2021
"behat/behat": "~3.0.0",
2122
"phpspec/phpspec": "2.0",
2223
"jackalope/jackalope-doctrine-dbal": "~1.1",
23-
"jackalope/jackalope-jackrabbit": "~1.1"
24+
"jackalope/jackalope-jackrabbit": "~1.1",
25+
"jackalope/jackalope-fs": "dev-master"
2426
},
2527
"suggest": {
2628
"jackalope/jackalope-doctrine-dbal": "To connect to jackalope doctrine-dbal",
27-
"jackalope/jackalope-doctrine-dbal": "To connect to jackalope jackrabbit"
29+
"jackalope/jackalope-jackrabbit": "To connect to jackalope jackrabbit",
30+
"jackalope/jackalope-jackrabbit-fs": "To connect to jackalope jackalope-fs"
2831
},
2932
"license": "MIT",
3033
"authors": [

features/all/phpcr_node_info.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Feature: Show information about node
1414
And I should see the following:
1515
"""
1616
+-------------------+--------------------------------------+
17-
| Path | /tests_general_base/daniel |
1817
| UUID | N/A |
1918
| Index | 1 |
2019
| Primary node type | nt:unstructured |

features/all/phpcr_node_list.feature

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,62 @@ Feature: List properites and chidren of current nodeA
7676
"""
7777
One or more weak reference targets have not been found
7878
"""
79+
80+
Scenario: Wildcard on name
81+
Given I execute the "node:list /tests_general_base/numberPropertyNode/jcr:con*" command
82+
Then the command should not fail
83+
And I should see the following:
84+
"""
85+
+-------------+-----------------+--+
86+
| jcr:content | nt:unstructured | |
87+
+-------------+-----------------+--+
88+
"""
89+
90+
Scenario: Wildcard on directory
91+
Given I execute the "node:list /tests_general_base/*/jcr:content" command
92+
Then the command should not fail
93+
And I should see the following:
94+
"""
95+
/tests_general_base/index.txt
96+
+-------------+-----------------+--+
97+
| jcr:content | nt:unstructured | |
98+
+-------------+-----------------+--+
99+
/tests_general_base/idExample
100+
+--------------+-----------------+--+
101+
| jcr:content/ | nt:unstructured | |
102+
+--------------+-----------------+--+
103+
/tests_general_base/numberPropertyNode
104+
+-------------+-----------------+--+
105+
| jcr:content | nt:unstructured | |
106+
+-------------+-----------------+--+
107+
/tests_general_base/NumberPropertyNodeToCompare1
108+
+-------------+-----------------+--+
109+
| jcr:content | nt:unstructured | |
110+
+-------------+-----------------+--+
111+
/tests_general_base/NumberPropertyNodeToCompare2
112+
+-------------+-----------------+--+
113+
| jcr:content | nt:unstructured | |
114+
+-------------+-----------------+--+
115+
"""
116+
117+
Scenario: Wildcard from relative path
118+
Given the current node is "/tests_general_base"
119+
And I execute the "node:list numberPropertyNode/jcr:con*" command
120+
Then the command should not fail
121+
And I should see the following:
122+
"""
123+
+-------------+-----------------+--+
124+
| jcr:content | nt:unstructured | |
125+
+-------------+-----------------+--+
126+
"""
127+
128+
Scenario: Wildcard from relative path 2
129+
Given the current node is "/tests_general_base"
130+
And I execute the "node:list num*" command
131+
Then the command should not fail
132+
And I should see the following:
133+
"""
134+
+---------------------+---------+--------------+
135+
| numberPropertyNode/ | nt:file | +jcr:content |
136+
+---------------------+---------+--------------+
137+
"""

features/all/phpcr_node_property_show.feature

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,21 @@ hello world
4141
Then the command should fail
4242
And I should see the following:
4343
"""
44-
Item at "/tests_general_base" is not a property
44+
Could not find property(s) at path
4545
"""
4646

4747
Scenario: Try to show non-existing property
4848
Given I execute the "node:property:show /this/path/does/not/exist" command
4949
Then the command should fail
5050
And I should see the following:
5151
"""
52-
There is no property at the path "/this/path/does/not/exist"
52+
Could not find property(s) at path
53+
"""
54+
55+
Scenario: Show properties using wildcard
56+
Given I execute the "node:property:show /tests_general_base/idExample/jcr:*" command
57+
Then the command should not fail
58+
And I should see the following:
59+
"""
60+
/tests_general_base/idExample/jcr:primaryType: nt:file
5361
"""

features/all/phpcr_node_remove.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ Feature: Remove a node
3232
You cannot delete the root node
3333
"""
3434

35+
Scenario: Delete root node by wildcard
36+
Given I execute the "node:remove /tests_general_base/*" command
37+
Then the command should not fail
38+
And I save the session
39+
And there should not exist a node at "/tests_general_base/daniel"

src/PHPCR/Shell/Console/Application/EmbeddedApplication.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function __construct($mode)
3939
$container = new Container($this->mode);
4040
parent::__construct($container, SessionApplication::APP_NAME, SessionApplication::APP_VERSION);
4141
$this->setAutoExit(false);
42+
43+
// @deprecated This will be removed in 1.0
4244
$this->getHelperSet()->set(new PhpcrHelper($container->get('phpcr.session_manager')));
4345
}
4446

src/PHPCR/Shell/Console/Application/ShellApplication.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ protected function registerShellCommands()
200200
*/
201201
private function configureFormatter(OutputFormatter $formatter)
202202
{
203+
$style = new OutputFormatterStyle('yellow', null, array('bold'));
204+
$formatter->setStyle('path', $style);
205+
206+
$style = new OutputFormatterStyle('green');
207+
$formatter->setStyle('localname', $style);
208+
203209
$style = new OutputFormatterStyle(null, null, array('bold'));
204210
$formatter->setStyle('node', $style);
205211

src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ public function execute(InputInterface $input, OutputInterface $output)
3333
$workspace = $session->getWorkspace();
3434
$lockManager = $workspace->getLockManager();
3535

36-
$path = $session->getAbsPath($input->getArgument('path'));
36+
$path = $input->getArgument('path');
37+
$nodes = $session->findNodes($path);
3738

38-
$lock = $lockManager->getLock($path);
39-
$lock->refresh();
39+
foreach ($nodes as $node) {
40+
41+
$lock = $lockManager->getLock($node->getPath());
42+
$lock->refresh();
43+
}
4044
}
4145
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ protected function configure()
1414
$this->setDescription('Show information about the current node');
1515
$this->addArgument('path', InputArgument::REQUIRED, 'Path of node');
1616
$this->setHelp(<<<HERE
17-
Show information about the current node
17+
Show information about the node(s) at the given path:
18+
19+
PHPCRSH> node:info path/to/node
20+
21+
The path can include wildcards.
1822
HERE
1923
);
2024
}
@@ -23,49 +27,52 @@ public function execute(InputInterface $input, OutputInterface $output)
2327
{
2428
$session = $this->get('phpcr.session');
2529
$path = $input->getArgument('path');
26-
$nodeHelper = $this->get('helper.node');
27-
$currentNode = $session->getNodeByPathOrIdentifier($path);
28-
$formatter = $this->get('helper.result_formatter');
30+
$nodeHelper = $this->getHelper('node');
31+
$formatter = $this->getHelper('result_formatter');
2932

30-
$mixins = $currentNode->getMixinNodeTypes();
31-
$mixinNodeTypeNames = array();
33+
$nodes = $session->findNodes($path);
3234

33-
foreach ($mixins as $name => $mixin) {
34-
$mixinNodeTypeNames[] = $mixin->getName();
35-
}
35+
foreach ($nodes as $node) {
36+
$mixins = $node->getMixinNodeTypes();
37+
$mixinNodeTypeNames = array();
38+
39+
foreach ($mixins as $mixin) {
40+
$mixinNodeTypeNames[] = $mixin->getName();
41+
}
42+
43+
if ($nodeHelper->nodeHasMixinType($node, 'mix:versionable')) {
44+
try {
45+
$isCheckedOut = $node->isCheckedOut() ? 'yes' : 'no';
46+
} catch (\Exception $e) {
47+
$isCheckedOut = $formatter->formatException($e);
48+
}
49+
} else {
50+
$isCheckedOut = 'N/A';
51+
}
3652

37-
if ($nodeHelper->nodeHasMixinType($currentNode, 'mix:versionable')) {
3853
try {
39-
$isCheckedOut = $currentNode->isCheckedOut() ? 'yes' : 'no';
54+
$isLocked = $node->isLocked() ? 'yes' : 'no';
4055
} catch (\Exception $e) {
41-
$isCheckedOut = $formatter->formatException($e);
56+
$isLocked = $formatter->formatException($e);
4257
}
43-
} else {
44-
$isCheckedOut = 'N/A';
45-
}
4658

47-
try {
48-
$isLocked = $currentNode->isLocked() ? 'yes' : 'no';
49-
} catch (\Exception $e) {
50-
$isLocked = $formatter->formatException($e);
51-
}
59+
$info = array(
60+
'UUID' => $node->hasProperty('jcr:uuid') ? $node->getProperty('jcr:uuid')->getValue() : 'N/A',
61+
'Index' => $node->getIndex(),
62+
'Primary node type' => $node->getPrimaryNodeType()->getName(),
63+
'Mixin node types' => implode(', ', $mixinNodeTypeNames),
64+
'Checked out?' => $isCheckedOut,
65+
'Locked?' => $isLocked,
66+
);
5267

53-
$info = array(
54-
'Path' => $currentNode->getPath(),
55-
'UUID' => $currentNode->hasProperty('jcr:uuid') ? $currentNode->getProperty('jcr:uuid')->getValue() : 'N/A',
56-
'Index' => $currentNode->getIndex(),
57-
'Primary node type' => $currentNode->getPrimaryNodeType()->getName(),
58-
'Mixin node types' => implode(', ', $mixinNodeTypeNames),
59-
'Checked out?' => $isCheckedOut,
60-
'Locked?' => $isLocked,
61-
);
68+
$output->writeln('<path>' . $node->getPath() . '</path>');
69+
$table = $this->get('helper.table')->create();
6270

63-
$table = $this->get('helper.table')->create();
71+
foreach ($info as $label => $value) {
72+
$table->addRow(array($label, $value));
73+
}
6474

65-
foreach ($info as $label => $value) {
66-
$table->addRow(array($label, $value));
75+
$table->render($output);
6776
}
68-
69-
$table->render($output);
7077
}
7178
}

src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
class NodeListCommand extends BasePhpcrCommand
1616
{
1717
protected $formatter;
18-
protected $filters;
1918
protected $textHelper;
2019
protected $maxLevel;
2120

@@ -26,7 +25,6 @@ protected function configure()
2625
$this->addArgument('path', InputArgument::OPTIONAL, 'Path of node', '.');
2726
$this->addOption('children', null, InputOption::VALUE_NONE, 'List only the children of this node');
2827
$this->addOption('properties', null, InputOption::VALUE_NONE, 'List only the properties of this node');
29-
$this->addOption('filter', 'f', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Optional filter to apply');
3028
$this->addOption('level', 'L', InputOption::VALUE_REQUIRED, 'Depth of tree to show');
3129
$this->addOption('template', 't', InputOption::VALUE_NONE, 'Show template nodes and properties');
3230
$this->setHelp(<<<HERE
@@ -37,10 +35,12 @@ protected function configure()
3735
The <info>node:list</info> command can also shows template nodes and properties as defined a nodes node-type by
3836
using the <info>--template</info> option. Template nodes and properties are prefixed with the "@" symbol.
3937
40-
The command accepts wither a path (relative or absolute) to the node or a UUID.
38+
The command accepts either a path (relative or absolute) to the node, a UUID or a pattern:
4139
4240
PHPCRSH> node:list 842e61c0-09ab-42a9-87c0-308ccc90e6f4
4341
PHPCRSH> node:list /tests/foobar
42+
PHPCRSH> node:list /tests/*/foobar
43+
PHPCRSH> node:list /tests/*/foo*
4444
HERE
4545
);
4646
}
@@ -49,7 +49,6 @@ public function execute(InputInterface $input, OutputInterface $output)
4949
{
5050
$this->formatter = $this->get('helper.result_formatter');
5151
$this->textHelper = $this->get('helper.text');
52-
$this->filters = $input->getOption('filter');
5352
$this->maxLevel = $input->getOption('level');
5453

5554
$this->showChildren = $input->getOption('children');
@@ -59,34 +58,52 @@ public function execute(InputInterface $input, OutputInterface $output)
5958
$session = $this->get('phpcr.session');
6059
$path = $input->getArgument('path');
6160

62-
$currentNode = $session->getNodeByPathOrIdentifier($path);
61+
try {
62+
$nodes = array($session->getNodeByPathOrIdentifier($path));
63+
$filter = null;
64+
} catch (\Exception $e) {
65+
$parentPath = $this->getHelper('path')->getParentPath($path);
66+
67+
$filter = substr($path, strlen($parentPath));
68+
69+
if ($filter[0] == '/') {
70+
$filter = substr($filter, 1);
71+
}
72+
73+
$nodes = $session->findNodes($parentPath);
74+
}
6375

6476
if (!$this->showChildren && !$this->showProperties) {
6577
$this->showChildren = true;
6678
$this->showProperties = true;
6779
}
6880

69-
$table = $this->get('helper.table')->create();
81+
foreach ($nodes as $node) {
82+
$table = $this->get('helper.table')->create();
83+
$this->renderNode($node, $table, array(), $filter);
7084

71-
$this->renderNode($currentNode, $table);
85+
if ($table->getNumberOfRows() > 0) {
86+
$output->writeln('<path>' . $node->getPath() . '</path>');
87+
$table->render($output);
88+
}
89+
}
7290

73-
$table->render($output);
7491
}
7592

76-
private function renderNode($currentNode, $table, $spacers = array())
93+
private function renderNode($currentNode, $table, $spacers = array(), $filter = null)
7794
{
7895
if ($this->showChildren) {
79-
$this->renderChildren($currentNode, $table, $spacers);
96+
$this->renderChildren($currentNode, $table, $spacers, $filter);
8097
}
8198

8299
if ($this->showProperties) {
83-
$this->renderProperties($currentNode, $table, $spacers);
100+
$this->renderProperties($currentNode, $table, $spacers, $filter);
84101
}
85102
}
86103

87-
private function renderChildren($currentNode, $table, $spacers)
104+
private function renderChildren($currentNode, $table, $spacers, $filter = null)
88105
{
89-
$children = $currentNode->getNodes($this->filters ? : null);
106+
$children = $currentNode->getNodes($filter ? : null);
90107

91108
$nodeType = $currentNode->getPrimaryNodeType();
92109
$childNodeDefinitions = $nodeType->getDeclaredChildNodeDefinitions();
@@ -147,9 +164,9 @@ private function renderChildren($currentNode, $table, $spacers)
147164
}
148165
}
149166

150-
private function renderProperties($currentNode, $table, $spacers)
167+
private function renderProperties($currentNode, $table, $spacers, $filter = null)
151168
{
152-
$properties = $currentNode->getProperties($this->filters ? : null);
169+
$properties = $currentNode->getProperties($filter ? : null);
153170

154171
try {
155172
$primaryItem = $currentNode->getPrimaryItem();

0 commit comments

Comments
 (0)