diff --git a/.travis.yml b/.travis.yml index c3122e37..fa1c2ba2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,3 +13,4 @@ before_script: script: - phpunit --coverage-text - php vendor/behat/behat/bin/behat + - php vendor/bin/phpspec run diff --git a/composer.json b/composer.json index f2559902..bd0ebeda 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,8 @@ "symfony/process": "2.3.*", "symfony/filesystem": "2.3.*", "phpunit/phpunit": "~3.7.28", - "behat/behat": "~2.5" + "behat/behat": "~2.5", + "phpspec/phpspec": "2.0" }, "license": "MIT", "authors": [ diff --git a/features/workspace_node_clone.feature b/features/node_clone.feature similarity index 73% rename from features/workspace_node_clone.feature rename to features/node_clone.feature index ad1d30fe..8344e53d 100644 --- a/features/workspace_node_clone.feature +++ b/features/node_clone.feature @@ -12,13 +12,13 @@ Feature: Clone a node from a given workspace to the current workspace Scenario: Clone node Given the current workspace is "default" - And I execute the "workspace:node:clone default_1 /cms/articles/article1 /cms/clone" command + And I execute the "node:clone /cms/articles/article1 /cms/clone default_1" command Then the command should not fail And I save the session And there should exist a node at "/cms/clone" Scenario: Clone onto existing - Given I execute the "workspace:node:clone default_1 /cms/articles/article1 /cms/articles" command + Given I execute the "node:clone /cms/articles/article1 /cms/articles default_1" command Then the command should fail And I should see the following: """ @@ -26,5 +26,5 @@ Feature: Clone a node from a given workspace to the current workspace """ Scenario: Clone onto existing but remove - Given I execute the "workspace:node:clone --remove-existing default_1 /cms/articles/article1 /cms/articles/article1" command + Given I execute the "node:clone --remove-existing /cms/articles/article1 /cms/articles/article1 default_1" command Then the command should not fail diff --git a/features/workspace_node_copy.feature b/features/node_copy.feature similarity index 78% rename from features/workspace_node_copy.feature rename to features/node_copy.feature index e216434b..a6933e8d 100644 --- a/features/workspace_node_copy.feature +++ b/features/node_copy.feature @@ -11,12 +11,12 @@ Feature: Copy a node from a given workspace to the current workspace And I purge the current workspace Scenario: Copy node from a different workspace - Given I execute the "workspace:node:copy /tests_general_base/index.txt /index.txt default_1" command + Given I execute the "node:copy /tests_general_base/index.txt /index.txt default_1" command Then the command should not fail And there should exist a node at "/index.txt" Scenario: Copy node in the same workspace - And I execute the "workspace:node:copy /tests_general_base/index.txt /tests_general_base/index.txt.2" command + Given I execute the "node:copy /tests_general_base/index.txt /tests_general_base/index.txt.2" command Then the command should not fail And I save the session And there should exist a node at "/tests_general_base/index.txt.2" diff --git a/features/node_corresponding.feature b/features/node_corresponding.feature index d81579fe..96538230 100644 --- a/features/node_corresponding.feature +++ b/features/node_corresponding.feature @@ -11,9 +11,9 @@ Feature: Display the path of any corresponding node in a given workspace And the "session_data.xml" fixtures are loaded And the current workspace is "default" - Scenario: Rename a node + Scenario: Show corresponding nodes Given the current node is "/tests_general_base/idExample" - And I execute the "node:corresponding default" command + And I execute the "node:corresponding . default" command Then the command should not fail And I should see the following: """ diff --git a/features/node_definition.feature b/features/node_definition.feature index 4ba09e44..6dd93e0f 100644 --- a/features/node_definition.feature +++ b/features/node_definition.feature @@ -9,7 +9,7 @@ Feature: Show CND for node Scenario: Show node definition Given the current node is "/tests_general_base" - And I execute the "node:definition --no-ansi" command + And I execute the "node:definition daniel --no-ansi" command Then the command should fail And I should see the following: """ diff --git a/features/node_info.feature b/features/node_info.feature index db0790a0..3881063e 100644 --- a/features/node_info.feature +++ b/features/node_info.feature @@ -9,12 +9,12 @@ Feature: Show information about node Scenario: Show node information Given the current node is "/tests_general_base" - And I execute the "node:info --no-ansi" command + And I execute the "node:info daniel --no-ansi" command Then the command should not fail And I should see the following: """ +-------------------+--------------------------------------+ - | Path | /tests_general_base | + | Path | /tests_general_base/daniel | | UUID | N/A | | Index | 1 | | Primary node type | nt:unstructured | diff --git a/features/node_lifecycle_follow_transition.feature b/features/node_lifecycle_follow_transition.feature index 9d402f2e..67c3838a 100644 --- a/features/node_lifecycle_follow_transition.feature +++ b/features/node_lifecycle_follow_transition.feature @@ -9,7 +9,7 @@ Feature: Follow the given lifecycle transition on the current node Scenario: Follow lifecycle transition Given the current node is "/tests_general_base" - And I execute the "node:lifecycle:follow foo" command + And I execute the "node:lifecycle:follow daniel foo" command Then the command should fail And I should see the following: """ diff --git a/features/node_lifecycle_list.feature b/features/node_lifecycle_list.feature index 188ff236..fe97b09d 100644 --- a/features/node_lifecycle_list.feature +++ b/features/node_lifecycle_list.feature @@ -9,7 +9,7 @@ Feature: List the possible lifecycle transitions for the current node Scenario: List possible lifecycle transitions Given the current node is "/tests_general_base" - And I execute the "node:lifecycle:list" command + And I execute the "node:lifecycle:list daniel" command Then the command should fail And I should see the following: """ diff --git a/features/node_mixin_add.feature b/features/node_mixin_add.feature index 23c7adb4..22459661 100644 --- a/features/node_mixin_add.feature +++ b/features/node_mixin_add.feature @@ -9,7 +9,7 @@ Feature: Add mixin to the current node Scenario: Add a mixin to the current node Given the current node is "/tests_general_base" - And I execute the "node:mixin:add mix:versionable --no-ansi" command + And I execute the "node:mixin:add . mix:versionable --no-ansi" command And I save the session Then the command should not fail And the node at "/tests_general_base" should have the mixin "mix:versionable" diff --git a/features/session_node_move.feature b/features/node_move.feature similarity index 54% rename from features/session_node_move.feature rename to features/node_move.feature index 5c8ae11a..f8762951 100644 --- a/features/session_node_move.feature +++ b/features/node_move.feature @@ -8,8 +8,16 @@ Feature: Move a node in the current session And the "session_data.xml" fixtures are loaded Scenario: Move node - Given I execute the "session:node:move /tests_general_base/index.txt /foobar" command + Given I execute the "node:move /tests_general_base/index.txt /foobar" command Then the command should not fail And I execute the "session:save" command And there should exist a node at "/foobar" And there should not exist a node at "/tests_general_base/index.txt" + + Scenario: Move node relative paths + Given the current node is "/tests_general_base/index.txt" + And I execute the "node:move . /barfoo" command + Then the command should not fail + And I execute the "session:save" command + And there should exist a node at "/barfoo" + And there should not exist a node at "/tests_general_base/index.txt" diff --git a/features/session_property_edit.feature b/features/node_property_edit.feature similarity index 81% rename from features/session_property_edit.feature rename to features/node_property_edit.feature index bc4d6cb5..6f9c59d5 100644 --- a/features/session_property_edit.feature +++ b/features/node_property_edit.feature @@ -14,10 +14,10 @@ Feature: Edit a single property Examples: | command | - | session:property:edit /properties/multivalue 1| + | node:property:edit /properties/multivalue 1| Scenario: Edit multivalue property, no index - Given I execute the "session:property:edit /properties/multivalue" command + Given I execute the "node:property:edit /properties/multivalue" command Then the command should fail And I should see the following: """ @@ -25,7 +25,7 @@ Feature: Edit a single property """ Scenario: Edit multivalue property, out of range - Given I execute the "session:property:edit /properties/multivalue 100" command + Given I execute the "node:property:edit /properties/multivalue 100" command Then the command should fail And I should see the following: """ diff --git a/features/session_property_remove.feature b/features/node_property_remove.feature similarity index 81% rename from features/session_property_remove.feature rename to features/node_property_remove.feature index 95b61e94..13cd5bc0 100644 --- a/features/session_property_remove.feature +++ b/features/node_property_remove.feature @@ -8,13 +8,13 @@ Feature: Remove a single property at a specified path And the "cms.xml" fixtures are loaded Scenario: Remove a property - Given I execute the "session:property:remove /cms/articles/article1/title" command + Given I execute the "node:property:remove /cms/articles/article1/title" command Then the command should not fail And I save the session And there should not exist a property at "/cms/articles/article1/title" Scenario: Try and remove a node - And I execute the "session:property:remove /tests_general_base" command + And I execute the "node:property:remove /tests_general_base" command Then the command should fail And I should see the following: """ diff --git a/features/node_set.feature b/features/node_property_set.feature similarity index 52% rename from features/node_set.feature rename to features/node_property_set.feature index c52036da..e70dc788 100644 --- a/features/node_set.feature +++ b/features/node_property_set.feature @@ -16,7 +16,15 @@ Feature: Set a node property Examples: | command | name | type | - | node:set uri http://foobar | uri | http://foobar | - | node:set double 12.12 | double | 12.12 | - | node:set long 123 | long | 123 | - | node:set thisisnew foobar --type=string | /properties/thisisnew | foobar | + | node:property:set uri http://foobar | uri | http://foobar | + | node:property:set double 12.12 --type=double | double | 12.12 | + | node:property:set long 123 | long | 123 | + | node:property:set thisisnew foobar --type=string | /properties/thisisnew | foobar | + + Scenario: Update a property but do not specify the type + Given I execute the "node:set /properties/decimal 1234" command + And I execute the "node:list /properties" command + Then I should see the following: + """ + decimal | DECIMAL + """ diff --git a/features/session_property_show.feature b/features/node_property_show.feature similarity index 76% rename from features/session_property_show.feature rename to features/node_property_show.feature index 240be60d..7a8f0d0e 100644 --- a/features/session_property_show.feature +++ b/features/node_property_show.feature @@ -8,7 +8,7 @@ Feature: Display the contents of a single property And the "session_data.xml" fixtures are loaded Scenario: Show binary property - Given I execute the "session:property:show /tests_general_base/index.txt/jcr:content/jcr:data" command + Given I execute the "node:property:show /tests_general_base/index.txt/jcr:content/jcr:data" command Then the command should not fail And I should see the following: """ @@ -29,7 +29,7 @@ hello world """ Scenario: Show date property - Given I execute the "session:property:show /tests_general_base/index.txt/jcr:content/mydateprop" command + Given I execute the "node:property:show /tests_general_base/index.txt/jcr:content/mydateprop" command Then the command should not fail And I should see the following: """ @@ -37,7 +37,7 @@ hello world """ Scenario: Try to show non-existing property - Given I execute the "session:property:show /this/path/does/not/exist" command + Given I execute the "node:property:show /this/path/does/not/exist" command Then the command should fail And I should see the following: """ diff --git a/features/node_references.feature b/features/node_references.feature index d924353e..249e2b57 100644 --- a/features/node_references.feature +++ b/features/node_references.feature @@ -9,7 +9,7 @@ Feature: Show node references Scenario: List weak references Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target" - And I execute the "node:references --no-ansi" command + And I execute the "node:references . --no-ansi" command Then the command should not fail And I should see a table containing the following rows: | Type | Property | Node Path | @@ -18,7 +18,7 @@ Feature: Show node references Scenario: List named weak references Given the current node is "/tests_general_base/idExample/jcr:content/weakreference_target" - And I execute the "node:references ref2 --no-ansi" command + And I execute the "node:references . ref2 --no-ansi" command Then the command should not fail And I should see a table containing the following rows: | Type | Property | Node Path | @@ -26,7 +26,7 @@ Feature: Show node references Scenario: List strong references Given the current node is "/tests_general_base/idExample" - And I execute the "node:references --no-ansi" command + And I execute the "node:references . --no-ansi" command Then the command should not fail And I should see a table containing the following rows: | Type | Property | Node Path | diff --git a/features/node_remove.feature b/features/node_remove.feature index cfdd446c..7f64ddc4 100644 --- a/features/node_remove.feature +++ b/features/node_remove.feature @@ -9,7 +9,7 @@ Feature: Remove a node Scenario: Remove a node Given the current node is "/tests_general_base" - And I execute the "node:remove" command + And I execute the "node:remove ." command Then the command should not fail And I save the session And there should not exist a node at "/tests_general_base" diff --git a/features/node_rename.feature b/features/node_rename.feature index cf39e278..352ffa4f 100644 --- a/features/node_rename.feature +++ b/features/node_rename.feature @@ -9,7 +9,7 @@ Feature: Rename a node Scenario: Rename a node Given the current node is "/tests_general_base/idExample" - And I execute the "node:rename foobar" command + And I execute the "node:rename . foobar" command And I save the session Then the command should not fail And there should exist a node at "/tests_general_base/foobar" diff --git a/features/node_reorder_before.feature b/features/node_reorder_before.feature index 7508cf93..08c68ae1 100644 --- a/features/node_reorder_before.feature +++ b/features/node_reorder_before.feature @@ -9,7 +9,7 @@ Feature: Reorder a node Scenario: Reorder a node Given the current node is "/tests_general_base" - And I execute the "node:order-before emptyExample idExample" command + And I execute the "node:order-before . emptyExample idExample" command Then the command should not fail And I save the session And there should exist a node at "/tests_general_base/emptyExample" before "/tests_general_base/idExample" diff --git a/features/node_set_primary_type.feature b/features/node_set_primary_type.feature index 36fb011f..0513d1c5 100644 --- a/features/node_set_primary_type.feature +++ b/features/node_set_primary_type.feature @@ -9,7 +9,7 @@ Feature: Set the nodes primary type Scenario: List the properties and children of the current node Given the current node is "/tests_general_base" - And I execute the "node:set-primary-type nt:unstructured --no-ansi" command + And I execute the "node:set-primary-type . nt:unstructured --no-ansi" command Then the command should fail And I should see the following: """ diff --git a/features/node_shared_remove.feature b/features/node_shared_remove.feature index ca20ed87..209df5c0 100644 --- a/features/node_shared_remove.feature +++ b/features/node_shared_remove.feature @@ -12,7 +12,7 @@ Feature: Remove the current node from any shared set to which it belongs Scenario: Remove the current node and all of its shared paths Given the current node is "/foobar" - And I execute the "node:shared:remove" command + And I execute the "node:shared:remove ." command Then the command should fail And I should see the following: """ diff --git a/features/node_shared_show.feature b/features/node_shared_show.feature index 8c02b4b4..aedb874c 100644 --- a/features/node_shared_show.feature +++ b/features/node_shared_show.feature @@ -12,7 +12,7 @@ Feature: Show the current nodes shared set Scenario: Show the current nodes shared set Given the current node is "/foobar" - And I execute the "node:shared:show" command + And I execute the "node:shared:show ." command Then the command should fail And I should see the following: """ diff --git a/features/node_update.feature b/features/node_update.feature index cbb9e8b9..781bcfaa 100644 --- a/features/node_update.feature +++ b/features/node_update.feature @@ -12,7 +12,7 @@ Feature: Update the current node from the node to which it corresponds in the gi Scenario: Update a node Given the current node is "/foobar" - And I execute the "node:update default_1" command + And I execute the "node:update . default_1" command Then the command should not fail And I save the session And the node at "/foobar" should have the property "title" with value "this is a test" diff --git a/features/session_node_show.feature b/features/session_node_show.feature deleted file mode 100644 index 3b64cc49..00000000 --- a/features/session_node_show.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: Display a detailed view of a single node - In order to display any node in the current workspace - As a user logged into the shell - I want to show all the data available for a node referenced by either its UUID or path - - Background: - Given that I am logged in as "testuser" - And the "session_data.xml" fixtures are loaded - - Scenario: Show node by path - Given I execute the "session:node:show /tests_general_base" command - Then the command should not fail - And I should see a table containing the following rows: - | Property / Node Name | Type / Node Type | Value | - | - jcr:primaryType | NAME | nt:unstructured | diff --git a/features/version_checkout.feature b/features/version_checkout.feature index 65c0dad0..12e7b09a 100644 --- a/features/version_checkout.feature +++ b/features/version_checkout.feature @@ -11,7 +11,7 @@ Feature: Checkout a version Given I execute the "version:checkout /tests_version_base/versioned" command Then the command should not fail And the current node is "/tests_version_base/versioned" - And I execute the "node:info" command + And I execute the "node:info ." command Then I should see the following: """ | Checked out? | yes diff --git a/features/version_checkpoint.feature b/features/version_checkpoint.feature index 663790de..9c98c8b0 100644 --- a/features/version_checkpoint.feature +++ b/features/version_checkpoint.feature @@ -10,10 +10,10 @@ Feature: Checkpoint Scenario: Checkpoint a a given node Given I execute the following commands: | cd /tests_version_base/versioned | - | node:set foo bar | + | node:property:set foo bar | | session:save | | version:checkpoint /tests_version_base/versioned | - | node:set foo baz | + | node:property:set foo baz | | session:save | | version:checkpoint /tests_version_base/versioned | Then the command should not fail @@ -21,7 +21,7 @@ Feature: Checkpoint """ Version: 1.1 """ - And I execute the "node:info" command + And I execute the "node:info ." command Then I should see the following: """ | Checked out? | yes diff --git a/features/version_remove.feature b/features/version_remove.feature index a7772f8b..1aaf1090 100644 --- a/features/version_remove.feature +++ b/features/version_remove.feature @@ -11,11 +11,11 @@ Feature: Remove node version Given I execute the following commands: | cd /tests_version_base/versioned | | version:checkout /tests_version_base/versioned | - | node:set foo baz | + | node:property:set foo baz | | session:save | | version:checkin /tests_version_base/versioned | | version:checkout /tests_version_base/versioned | - | node:set foo bar | + | node:property:set foo bar | | session:save | | version:checkin /tests_version_base/versioned | And I execute the "version:remove /tests_version_base/versioned 1.0" command diff --git a/features/version_restore.feature b/features/version_restore.feature index ace7bb74..d730b408 100644 --- a/features/version_restore.feature +++ b/features/version_restore.feature @@ -10,10 +10,10 @@ Feature: Restore a version Scenario: Restore node version Given I execute the following commands: | cd /tests_version_base/versioned | - | node:set foo initalbar | + | node:property:set foo initalbar | | session:save | | version:checkpoint /tests_version_base/versioned | - | node:set foo baz | + | node:property:set foo baz | | session:save | | version:checkpoint /tests_version_base/versioned | And I execute the "version:restore /tests_version_base/versioned 1.0" command diff --git a/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php b/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php new file mode 100644 index 00000000..333d904c --- /dev/null +++ b/spec/PHPCR/Shell/Console/Helper/PathHelperSpec.php @@ -0,0 +1,24 @@ +shouldHaveType('PHPCR\Shell\Console\Helper\PathHelper'); + } + + function it_has_a_method_to_provide_the_parent_path_for_a_given_path() + { + $this->getParentPath('/foo/bar')->shouldReturn('/foo'); + } + + function it_has_a_method_to_get_the_node_name_of_a_given_path() + { + $this->getNodeName('/foo/bar')->shouldReturn('bar'); + } +} diff --git a/src/PHPCR/Shell/Console/Application/ShellApplication.php b/src/PHPCR/Shell/Console/Application/ShellApplication.php index 4a9e9a3f..db310caf 100644 --- a/src/PHPCR/Shell/Console/Application/ShellApplication.php +++ b/src/PHPCR/Shell/Console/Application/ShellApplication.php @@ -7,14 +7,91 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + +use Jackalope\NotImplementedException; +use PHPCR\Shell\Console\Command\Phpcr\AccessControlPrivilegeListCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockInfoCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockLockCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockRefreshCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockTokenAddCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockTokenListCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockTokenRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\LockUnlockCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeCorrespondingCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeCreateCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeDefinitionCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeInfoCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeLifecycleFollowCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeLifecycleListCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeListCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeMixinAddCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeMixinRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeOrderBeforeCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeReferencesCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeRenameCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodePropertySetCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeSetPrimaryTypeCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeSharedRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeSharedShowCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeTypeEditCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeTypeListCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeTypeLoadCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeTypeShowCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeTypeUnregisterCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeUpdateCommand; +use PHPCR\Shell\Console\Command\Phpcr\PhpcrShellCommand; +use PHPCR\Shell\Console\Command\Phpcr\QueryCommand; +use PHPCR\Shell\Console\Command\Phpcr\QuerySelectCommand; +use PHPCR\Shell\Console\Command\Phpcr\RepositoryDescriptorListCommand; +use PHPCR\Shell\Console\Command\Phpcr\RetentionHoldAddCommand; +use PHPCR\Shell\Console\Command\Phpcr\RetentionHoldListCommand; +use PHPCR\Shell\Console\Command\Phpcr\RetentionHoldRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\RetentionPolicyGetCommand; +use PHPCR\Shell\Console\Command\Phpcr\RetentionPolicyRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionExportViewCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionImpersonateCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionImportXMLCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionInfoCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionLoginCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionLogoutCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionNamespaceListCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionNamespaceSetCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeMoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionNodeShowCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodePropertyEditCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodePropertyRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodePropertyShowCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionRefreshCommand; +use PHPCR\Shell\Console\Command\Phpcr\SessionSaveCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionCheckinCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionCheckoutCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionCheckpointCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionHistoryCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionRemoveCommand; +use PHPCR\Shell\Console\Command\Phpcr\VersionRestoreCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceCreateCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceDeleteCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceListCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceNamespaceListCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceNamespaceRegisterCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceNamespaceUnregisterCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeCloneCommand; +use PHPCR\Shell\Console\Command\Phpcr\NodeCopyCommand; +use PHPCR\Shell\Console\Command\Phpcr\WorkspaceUseCommand; use PHPCR\Shell\Console\Command\Shell\ChangePathCommand; +use PHPCR\Shell\Console\Command\Shell\ExitCommand; +use PHPCR\Shell\Console\Command\Shell\ListTreeCommand; use PHPCR\Shell\Console\Command\Shell\PwdCommand; -use PHPCR\Shell\Console\Helper\ResultFormatterHelper; +use PHPCR\Shell\Console\Helper\EditorHelper; use PHPCR\Shell\Console\Helper\NodeHelper; +use PHPCR\Shell\Console\Helper\PathHelper; +use PHPCR\Shell\Console\Helper\RepositoryHelper; +use PHPCR\Shell\Console\Helper\ResultFormatterHelper; +use PHPCR\Shell\Console\Helper\TextHelper; use PHPCR\Shell\PhpcrSession; use PHPCR\SimpleCredentials; use PHPCR\Util\Console\Command\NodeDumpCommand; -use PHPCR\Util\Console\Command\NodeMoveCommand; use PHPCR\Util\Console\Command\NodeTouchCommand; use PHPCR\Util\Console\Command\NodeTypeRegisterCommand; use PHPCR\Util\Console\Command\NodesUpdateCommand; @@ -22,86 +99,9 @@ use PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper; use PHPCR\Util\Console\Helper\PhpcrHelper; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\ArrayInput; -use PHPCR\Shell\Console\Command\Shell\ExitCommand; -use PHPCR\Shell\Console\Command\Shell\ListTreeCommand; -use PHPCR\Shell\Console\Command\RepositoryDescriptorListCommand; -use PHPCR\Shell\Console\Command\SessionExportViewCommand; -use PHPCR\Shell\Console\Command\SessionImportXMLCommand; -use PHPCR\Shell\Console\Command\SessionInfoCommand; -use PHPCR\Shell\Console\Command\SessionLoginCommand; -use PHPCR\Shell\Console\Command\SessionLogoutCommand; -use PHPCR\Shell\Console\Command\SessionNamespaceListCommand; -use PHPCR\Shell\Console\Command\SessionNamespaceSetCommand; -use PHPCR\Shell\Console\Command\SessionNodeMoveCommand; -use PHPCR\Shell\Console\Command\SessionNodeShowCommand; -use PHPCR\Shell\Console\Helper\TextHelper; -use PHPCR\Shell\Console\Command\SessionPropertyRemoveCommand; -use PHPCR\Shell\Console\Command\SessionPropertyShowCommand; -use PHPCR\Shell\Console\Command\SessionPropertyEditCommand; -use PHPCR\Shell\Console\Command\SessionRefreshCommand; -use PHPCR\Shell\Console\Command\SessionSaveCommand; -use PHPCR\Shell\Console\Command\SessionImpersonateCommand; -use PHPCR\Shell\Console\Command\AccessControlPrivilegeListCommand; -use PHPCR\Shell\Console\Command\QuerySelectCommand; -use PHPCR\Shell\Console\Command\QueryCommand; -use PHPCR\Shell\Console\Command\RetentionHoldAddCommand; -use PHPCR\Shell\Console\Command\RetentionHoldListCommand; -use PHPCR\Shell\Console\Command\RetentionHoldRemoveCommand; -use PHPCR\Shell\Console\Command\RetentionPolicyGetCommand; -use PHPCR\Shell\Console\Command\RetentionPolicyRemoveCommand; -use PHPCR\Shell\Console\Command\WorkspaceCreateCommand; -use PHPCR\Shell\Console\Command\WorkspaceDeleteCommand; -use PHPCR\Shell\Console\Command\WorkspaceListCommand; -use PHPCR\Shell\Console\Command\WorkspaceNodeCloneCommand; -use PHPCR\Shell\Console\Command\WorkspaceNodeCopyCommand; -use PHPCR\Shell\Console\Command\WorkspaceNamespaceListCommand; -use PHPCR\Shell\Console\Command\WorkspaceNamespaceRegisterCommand; -use PHPCR\Shell\Console\Command\WorkspaceNamespaceUnregisterCommand; -use PHPCR\Shell\Console\Command\WorkspaceUseCommand; -use PHPCR\Shell\Console\Command\NodeTypeShowCommand; -use PHPCR\Shell\Console\Helper\EditorHelper; -use PHPCR\Shell\Console\Command\NodeTypeEditCommand; -use PHPCR\Shell\Console\Command\NodeTypeUnregisterCommand; -use PHPCR\Shell\Console\Command\NodeTypeListCommand; -use PHPCR\Shell\Console\Command\NodeTypeLoadCommand; -use PHPCR\Shell\Console\Command\VersionCheckoutCommand; -use PHPCR\Shell\Console\Command\VersionCheckinCommand; -use PHPCR\Shell\Console\Command\VersionHistoryCommand; -use PHPCR\Shell\Console\Command\VersionRestoreCommand; -use PHPCR\Shell\Console\Command\VersionRemoveCommand; -use PHPCR\Shell\Console\Command\VersionCheckpointCommand; -use PHPCR\Shell\Console\Command\NodeCreateCommand; -use PHPCR\Shell\Console\Command\NodeCorrespondingCommand; -use PHPCR\Shell\Console\Command\NodeDefinitionCommand; -use PHPCR\Shell\Console\Command\NodeSetCommand; -use PHPCR\Shell\Console\Command\NodeSetPrimaryTypeCommand; -use PHPCR\Shell\Console\Command\NodeRenameCommand; -use PHPCR\Shell\Console\Command\NodeMixinAddCommand; -use PHPCR\Shell\Console\Command\NodeMixinRemoveCommand; -use PHPCR\Shell\Console\Command\NodeOrderBeforeCommand; -use PHPCR\Shell\Console\Command\NodeInfoCommand; -use PHPCR\Shell\Console\Command\NodeLifecycleFollowCommand; -use PHPCR\Shell\Console\Command\NodeLifecycleListCommand; -use PHPCR\Shell\Console\Command\NodeListCommand; -use PHPCR\Shell\Console\Command\NodeUpdateCommand; -use PHPCR\Shell\Console\Command\NodeReferencesCommand; -use PHPCR\Shell\Console\Command\NodeSharedShowCommand; -use PHPCR\Shell\Console\Command\NodeSharedRemoveCommand; -use PHPCR\Shell\Console\Command\NodeRemoveCommand; -use PHPCR\Shell\Console\Command\LockLockCommand; -use PHPCR\Shell\Console\Command\LockInfoCommand; -use PHPCR\Shell\Console\Command\LockRefreshCommand; -use PHPCR\Shell\Console\Command\LockTokenAddCommand; -use PHPCR\Shell\Console\Command\LockTokenListCommand; -use PHPCR\Shell\Console\Command\LockTokenRemoveCommand; -use PHPCR\Shell\Console\Command\LockUnlockCommand; - -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; +use Symfony\Component\Console\Formatter\OutputFormatterStyle; +use Symfony\Component\Console\Input\ArrayInput; class ShellApplication extends Application { @@ -151,6 +151,7 @@ public function init() $this->getHelperSet()->set(new ResultFormatterHelper()); $this->getHelperSet()->set(new TextHelper()); $this->getHelperSet()->set(new NodeHelper($this->session)); + $this->getHelperSet()->set(new PathHelper($this->session)); $this->getHelperSet()->set(new RepositoryHelper($this->session->getRepository())); // add new commands @@ -164,11 +165,9 @@ public function init() $this->add(new SessionLogoutCommand()); $this->add(new SessionNamespaceListCommand()); $this->add(new SessionNamespaceSetCommand()); - $this->add(new SessionNodeMoveCommand()); - $this->add(new SessionNodeShowCommand()); - $this->add(new SessionPropertyEditCommand()); - $this->add(new SessionPropertyRemoveCommand()); - $this->add(new SessionPropertyShowCommand()); + $this->add(new NodePropertyEditCommand()); + $this->add(new NodePropertyRemoveCommand()); + $this->add(new NodePropertyShowCommand()); $this->add(new SessionRefreshCommand()); $this->add(new SessionSaveCommand()); $this->add(new QuerySelectCommand()); @@ -181,8 +180,8 @@ public function init() $this->add(new WorkspaceCreateCommand()); $this->add(new WorkspaceDeleteCommand()); $this->add(new WorkspaceListCommand()); - $this->add(new WorkspaceNodeCloneCommand()); - $this->add(new WorkspaceNodeCopyCommand()); + $this->add(new NodeCloneCommand()); + $this->add(new NodeCopyCommand()); $this->add(new WorkspaceNamespaceListCommand()); $this->add(new WorkspaceNamespaceRegisterCommand()); $this->add(new WorkspaceNamespaceUnregisterCommand()); @@ -201,9 +200,10 @@ public function init() $this->add(new NodeCreateCommand()); $this->add(new NodeCorrespondingCommand()); $this->add(new NodeDefinitionCommand()); - $this->add(new NodeSetCommand()); + $this->add(new NodePropertySetCommand()); $this->add(new NodeSetPrimaryTypeCommand()); $this->add(new NodeRenameCommand()); + $this->add(new NodeMoveCommand()); $this->add(new NodeMixinAddCommand()); $this->add(new NodeMixinRemoveCommand()); $this->add(new NodeOrderBeforeCommand()); @@ -239,9 +239,6 @@ public function init() $this->add(new ListTreeCommand()); - $this->add($this->wrap(new NodeMoveCommand()) - ->setName('mv') - ); $this->add($this->wrap(new NodeListCommand()) ->setName('ls') ); diff --git a/src/PHPCR/Shell/Console/Command/AccessControlPrivilegeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php similarity index 98% rename from src/PHPCR/Shell/Console/Command/AccessControlPrivilegeListCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php index 2620c1f8..64b02a37 100644 --- a/src/PHPCR/Shell/Console/Command/AccessControlPrivilegeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/AccessControlPrivilegeListCommand.php @@ -1,6 +1,6 @@ setName('lock:info'); $this->setDescription('Create a node at the current path'); - $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path of locked node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of locked node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); - $lock = $lockManager->getLock($absPath); + $lock = $lockManager->getLock($path); $info = array( 'Lock owner' => $lock->getLockOwner(), diff --git a/src/PHPCR/Shell/Console/Command/LockLockCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php similarity index 90% rename from src/PHPCR/Shell/Console/Command/LockLockCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php index 027212a0..0240ce96 100644 --- a/src/PHPCR/Shell/Console/Command/LockLockCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockLockCommand.php @@ -1,6 +1,6 @@ setName('lock:lock'); $this->setDescription('Lock the node at the given path'); - $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path of node to be locked'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node to be locked'); $this->addOption('deep', null, InputOption::VALUE_NONE, 'If given this lock will apply to this node and all its descendants; if not, it applies only to this node.'); $this->addOption('session-scoped', null, InputOption::VALUE_NONE, 'If given, this lock expires with the current session; if not it expires when explicitly or automatically unlocked for some other reason'); $this->addOption('timeout', null, InputOption::VALUE_REQUIRED, 'Desired lock timeout in seconds (servers are free to ignore this value). If not used lock will not timeout'); $this->addOption('owner-info', null, InputOption::VALUE_REQUIRED, ' string containing owner information supplied by the client; servers are free to ignore this value. If none is specified, the implementation chooses one (i.e. user name of current backend authentication credentials'); $this->setHelp(<<absPath. +Places a lock on the node at path. If successful, the node is said to hold the lock. @@ -62,12 +62,12 @@ public function execute(InputInterface $input, OutputInterface $output) $workspace = $session->getWorkspace(); $lockManager = $workspace->getLockManager(); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $isDeep = $input->getOption('deep'); $isSessionScoped = $input->getOption('session-scoped'); $timeout = $input->getOption('timeout'); $ownerInfo = $input->getOption('owner-info'); - $lockManager->lock($absPath, $isDeep, $isSessionScoped, $timeout, $ownerInfo); + $lockManager->lock($path, $isDeep, $isSessionScoped, $timeout, $ownerInfo); } } diff --git a/src/PHPCR/Shell/Console/Command/LockRefreshCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php similarity index 81% rename from src/PHPCR/Shell/Console/Command/LockRefreshCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php index 28b86cb7..3e4384d3 100644 --- a/src/PHPCR/Shell/Console/Command/LockRefreshCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockRefreshCommand.php @@ -1,6 +1,6 @@ setName('lock:refresh'); $this->setDescription('Refresh the TTL of the lock of the node at the given path'); - $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path of node containing the lock to be refreshed'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node containing the lock to be refreshed'); $this->setHelp(<<getWorkspace(); $lockManager = $workspace->getLockManager(); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); - $lock = $lockManager->getLock($absPath); + $lock = $lockManager->getLock($path); $lock->refresh(); } } diff --git a/src/PHPCR/Shell/Console/Command/LockTokenAddCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php similarity index 96% rename from src/PHPCR/Shell/Console/Command/LockTokenAddCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php index ae189c2c..d7421092 100644 --- a/src/PHPCR/Shell/Console/Command/LockTokenAddCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/LockTokenAddCommand.php @@ -1,6 +1,6 @@ setName('lock:unlock'); $this->setDescription('Unlock the node at the given path'); - $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path of node to be unlocked'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getWorkspace(); $lockManager = $workspace->getLockManager(); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); - $lockManager->unlock($absPath); + $lockManager->unlock($path); } } diff --git a/src/PHPCR/Shell/Console/Command/WorkspaceNodeCloneCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php similarity index 92% rename from src/PHPCR/Shell/Console/Command/WorkspaceNodeCloneCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php index cbdcc596..62f43054 100644 --- a/src/PHPCR/Shell/Console/Command/WorkspaceNodeCloneCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCloneCommand.php @@ -1,6 +1,6 @@ setName('workspace:node:clone'); + $this->setName('node:clone'); $this->setDescription('Copy a node from one workspace to another'); - $this->addArgument('srcWorkspace', InputArgument::REQUIRED, 'If specified, copy from this workspace'); $this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node'); $this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node'); + $this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace'); $this->addOption('remove-existing', null, InputOption::VALUE_NONE, 'Remove existing nodes'); $this->setHelp(<<srcAbsPath in diff --git a/src/PHPCR/Shell/Console/Command/WorkspaceNodeCopyCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php similarity index 95% rename from src/PHPCR/Shell/Console/Command/WorkspaceNodeCopyCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php index cfec173a..0fe96e68 100644 --- a/src/PHPCR/Shell/Console/Command/WorkspaceNodeCopyCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCopyCommand.php @@ -1,18 +1,18 @@ setName('workspace:node:copy'); - $this->setDescription('Copy a node from one workspace to another'); + $this->setName('node:copy'); + $this->setDescription('Copy a node'); $this->addArgument('srcAbsPath', InputArgument::REQUIRED, 'Absolute path to source node'); $this->addArgument('destAbsPath', InputArgument::REQUIRED, 'Absolute path to destination node'); $this->addArgument('srcWorkspace', InputArgument::OPTIONAL, 'If specified, copy from this workspace'); diff --git a/src/PHPCR/Shell/Console/Command/NodeCorrespondingCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php similarity index 83% rename from src/PHPCR/Shell/Console/Command/NodeCorrespondingCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php index 54d3ece6..4f88313a 100644 --- a/src/PHPCR/Shell/Console/Command/NodeCorrespondingCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCorrespondingCommand.php @@ -1,6 +1,6 @@ setName('node:corresponding'); $this->setDescription('Show the path for the current nodes corresponding path in named workspace'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('workspaceName', InputArgument::REQUIRED, 'The name of the workspace'); $this->setHelp(<<getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $workspaceName = $input->getArgument('workspaceName'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $correspondingPath = $currentNode->getCorrespondingNodePath($workspaceName); $output->writeln($correspondingPath); } diff --git a/src/PHPCR/Shell/Console/Command/NodeCreateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php similarity index 74% rename from src/PHPCR/Shell/Console/Command/NodeCreateCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php index a16015bc..d21ed6bd 100644 --- a/src/PHPCR/Shell/Console/Command/NodeCreateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeCreateCommand.php @@ -1,6 +1,6 @@ setName('node:create'); $this->setDescription('Create a node at the current path'); - $this->addArgument('relPath', InputArgument::REQUIRED, 'The name of the node to create'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node to create'); $this->addArgument('primaryNodeTypeName', InputArgument::OPTIONAL, 'Optional name of primary node type to use'); $this->setHelp(<<relPath +Creates a new node at the specified path This is session-write method, meaning that the addition of the new node is dispatched upon SessionInterface::save(). -The relPath provided must not have an index on its final element, +The path provided must not have an index on its final element, otherwise a RepositoryException is thrown. If ordering is supported by the node type of the parent node of the new @@ -46,9 +46,14 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); - $relPath = $input->getArgument('relPath'); + $pathHelper = $this->getHelper('path'); + + $path = $session->getAbsPath($input->getArgument('path')); $primaryNodeTypeName = $input->getArgument('primaryNodeTypeName'); - $currentNode = $session->getCurrentNode(); - $currentNode->addNode($relPath, $primaryNodeTypeName); + + $parentPath = $pathHelper->getParentPath($path); + $nodeName = $pathHelper->getNodeName($path); + $parentNode = $session->getNode($parentPath); + $parentNode->addNode($nodeName, $primaryNodeTypeName); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeDefinitionCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php similarity index 83% rename from src/PHPCR/Shell/Console/Command/NodeDefinitionCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php index d114f123..132892fd 100644 --- a/src/PHPCR/Shell/Console/Command/NodeDefinitionCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeDefinitionCommand.php @@ -1,6 +1,6 @@ setName('node:definition'); $this->setDescription('Show the CND Definition of current node NOT IMPLEMENTED'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $workspace = $session->getWorkspace(); $namespaceRegistry = $workspace->getNamespaceRegistry(); @@ -36,4 +38,3 @@ public function execute(InputInterface $input, OutputInterface $output) $output->writeln(sprintf('%s', $out)); } } - diff --git a/src/PHPCR/Shell/Console/Command/NodeInfoCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php similarity index 90% rename from src/PHPCR/Shell/Console/Command/NodeInfoCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php index f2cfa079..d818ed24 100644 --- a/src/PHPCR/Shell/Console/Command/NodeInfoCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeInfoCommand.php @@ -1,6 +1,6 @@ setName('node:info'); $this->setDescription('Show information about the current node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $nodeHelper = $this->getHelper('node'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $formatter = $this->getHelper('result_formatter'); $mixins = $currentNode->getMixinNodeTypes(); diff --git a/src/PHPCR/Shell/Console/Command/NodeLifecycleFollowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php similarity index 87% rename from src/PHPCR/Shell/Console/Command/NodeLifecycleFollowCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php index 7b623711..66fcf52c 100644 --- a/src/PHPCR/Shell/Console/Command/NodeLifecycleFollowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleFollowCommand.php @@ -1,6 +1,6 @@ setName('node:lifecycle:follow'); $this->setDescription('Causes the lifecycle state of this node to undergo the specified transition. NOT IMPLEMENTED'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('transition', InputArgument::REQUIRED, 'A state transition'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $transition = $input->getArgument('transition'); $currentNode->followLifecycleTransition($transition); } diff --git a/src/PHPCR/Shell/Console/Command/NodeLifecycleListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php similarity index 83% rename from src/PHPCR/Shell/Console/Command/NodeLifecycleListCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php index b4e79bca..2c1b482b 100644 --- a/src/PHPCR/Shell/Console/Command/NodeLifecycleListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeLifecycleListCommand.php @@ -1,6 +1,6 @@ setName('node:lifecycle:list'); $this->setDescription('Returns the list of valid state transitions for this node. NOT IMPLEMENTED'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $transitions = $currentNode->getAllowedLifecycleTransitions(); foreach ($transitions as $transition) { diff --git a/src/PHPCR/Shell/Console/Command/NodeListCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php similarity index 92% rename from src/PHPCR/Shell/Console/Command/NodeListCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php index 807cb8f3..e400f2d2 100644 --- a/src/PHPCR/Shell/Console/Command/NodeListCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeListCommand.php @@ -1,6 +1,6 @@ setName('node:list'); $this->setDescription('List the children / properties of this node'); + $this->addArgument('path', InputArgument::OPTIONAL, 'Path of node'); $this->addOption('children', null, InputOption::VALUE_NONE, 'List only the children of this node'); $this->addOption('properties', null, InputOption::VALUE_NONE, 'List only the properties of this node'); $this->addOption('filter', 'f', InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY, 'Optional filter to apply'); @@ -41,7 +42,9 @@ public function execute(InputInterface $input, OutputInterface $output) $showProperties = $input->getOption('properties'); $session = $this->getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); if (!$showChildren && !$showProperties) { $showChildren = true; diff --git a/src/PHPCR/Shell/Console/Command/NodeMixinAddCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php similarity index 87% rename from src/PHPCR/Shell/Console/Command/NodeMixinAddCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php index 686cc311..6eb80c74 100644 --- a/src/PHPCR/Shell/Console/Command/NodeMixinAddCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinAddCommand.php @@ -1,6 +1,6 @@ setName('node:mixin:add'); - $this->setDescription('Add the named mixin to the current node'); + $this->setDescription('Add the named mixin to the node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('mixinName', null, InputArgument::REQUIRED, null, 'The name of the mixin node type to be added'); $this->setHelp(<<mixinName to this node. @@ -48,8 +49,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $mixinName = $input->getArgument('mixinName'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $currentNode->addMixin($mixinName); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeMixinRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php similarity index 96% rename from src/PHPCR/Shell/Console/Command/NodeMixinRemoveCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php index 3df6ce31..c312d111 100644 --- a/src/PHPCR/Shell/Console/Command/NodeMixinRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeMixinRemoveCommand.php @@ -1,6 +1,6 @@ setName('session:node:move'); + $this->setName('node:move'); $this->setDescription('Move a node in the current session'); - $this->addArgument('srcAbsPath', null, InputArgument::REQUIRED, 'The root of the subgraph to be moved.'); - $this->addArgument('destAbsPath', null, InputArgument::REQUIRED, 'The location to which the subgraph is to be moved'); + $this->addArgument('srcPath', null, InputArgument::REQUIRED, 'The root of the subgraph to be moved.'); + $this->addArgument('destPath', null, InputArgument::REQUIRED, 'The location to which the subgraph is to be moved'); $this->setHelp(<<srcAbsPath (and its entire subgraph) to the new -location at destAbsPath. +Moves the node at srcPath (and its entire subgraph) to the new +location at destPath. This is a session-write command and therefor requires a save to dispatch the change. @@ -38,7 +38,7 @@ protected function configure() , which is a workspace-write command and therefore immediately dispatches changes. -The destAbsPath provided must not have an index on its final element. If +The destPath provided must not have an index on its final element. If ordering is supported by the node type of the parent node of the new location, then the newly moved node is appended to the end of the child node list. @@ -52,8 +52,8 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); - $srcAbsPath = $input->getArgument('srcAbsPath'); - $destAbsPath = $input->getArgument('destAbsPath'); - $session->move($srcAbsPath, $destAbsPath); + $srcPath = $session->getAbsPath($input->getArgument('srcPath')); + $destPath = $session->getAbsPath($input->getArgument('destPath')); + $session->move($srcPath, $destPath); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeOrderBeforeCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php similarity index 86% rename from src/PHPCR/Shell/Console/Command/NodeOrderBeforeCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php index 6d295f55..04f6b13f 100644 --- a/src/PHPCR/Shell/Console/Command/NodeOrderBeforeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeOrderBeforeCommand.php @@ -1,6 +1,6 @@ setName('node:order-before'); - $this->setDescription(''); + $this->setDescription('Reorder a child node of the current node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('srcChildRelPath', null, InputArgument::REQUIRED, 'The relative path to the child node to be moved in the ordering'); $this->addArgument('destChildRelPath', null, InputArgument::REQUIRED, 'The relative path to the child before which the node srcChildRelPath will be placed'); $this->setHelp(<<getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $srcChildRelPath = $input->getArgument('srcChildRelPath'); $destChildRelPath = $input->getArgument('destChildRelPath'); - $node = $session->getCurrentNode(); + $node = $session->getNode($path); $node->orderBefore($srcChildRelPath, $destChildRelPath); } } diff --git a/src/PHPCR/Shell/Console/Command/SessionPropertyEditCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyEditCommand.php similarity index 84% rename from src/PHPCR/Shell/Console/Command/SessionPropertyEditCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyEditCommand.php index be78183c..0832a68a 100644 --- a/src/PHPCR/Shell/Console/Command/SessionPropertyEditCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyEditCommand.php @@ -1,6 +1,6 @@ setName('session:property:edit'); + $this->setName('node:property:edit'); $this->setDescription('Edit the property at the given absolute path using EDITOR'); - $this->addArgument('absPath', InputArgument::REQUIRED, 'Absolute path to property'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path to property'); $this->addArgument('multivalue-index', InputArgument::OPTIONAL, 'If editing a multivalue property, the index of the value to edit.'); $this->setHelp(<<getHelper('phpcr')->getSession(); $editor = $this->getHelper('editor'); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $multivalueIndex = $input->getArgument('multivalue-index'); $valueConverter = new ValueConverter(); - $absPath = $input->getArgument('absPath'); - $property = $session->getProperty($absPath); + $path = $input->getArgument('path'); + $property = $session->getProperty($path); if ($property->isMultiple()) { if (null === $multivalueIndex) { diff --git a/src/PHPCR/Shell/Console/Command/SessionPropertyRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php similarity index 88% rename from src/PHPCR/Shell/Console/Command/SessionPropertyRemoveCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php index 027da380..12b99a3f 100644 --- a/src/PHPCR/Shell/Console/Command/SessionPropertyRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyRemoveCommand.php @@ -1,6 +1,6 @@ setName('session:property:remove'); + $this->setName('node:property:remove'); $this->setDescription('Remove the property at the given absolute path'); $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to property'); $this->setHelp(<<setName('node:set'); + $this->setName('node:property:set'); $this->setDescription('Rename the node at the current path'); - $this->addArgument('name', null, InputArgument::REQUIRED, null, 'The name of the node to create'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of property - can include the node name'); $this->addArgument('value', null, InputArgument::OPTIONAL, null, 'Value for named property'); $this->addOption('type', null, InputOption::VALUE_REQUIRED, 'Type of named property'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $name = $input->getArgument('name'); + $pathHelper = $this->getHelper('path'); + $path = $session->getAbsPath($input->getArgument('path')); $value = $input->getArgument('value'); $type = $input->getOption('type'); - $currentNode = $session->getCurrentNode(); - $currentNode->setProperty($name, $value); + $nodePath = $pathHelper->getParentPath($path); + $propName = $pathHelper->getNodeName($path); + $node = $session->getNode($nodePath); + + $intType = null; + + if ($type) { + $intType = PropertyType::valueFromName($type); + } else { + $property = $node->getProperty($propName); + $intType = $property->getType(); + } + + $node->setProperty($propName, $value); } } diff --git a/src/PHPCR/Shell/Console/Command/SessionPropertyShowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php similarity index 89% rename from src/PHPCR/Shell/Console/Command/SessionPropertyShowCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php index 7830f5a9..5609e458 100644 --- a/src/PHPCR/Shell/Console/Command/SessionPropertyShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodePropertyShowCommand.php @@ -1,6 +1,6 @@ setName('session:property:show'); + $this->setName('node:property:show'); $this->setDescription('Show the property at the given absolute path'); $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to property'); $this->setHelp(<<setName('node:references'); $this->setDescription('Returns all REFERENCE properties that refer to this node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('name', InputArgument::OPTIONAL, 'Limit references to given name'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $name = $input->getArgument('name'); $references = array( diff --git a/src/PHPCR/Shell/Console/Command/NodeRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php similarity index 76% rename from src/PHPCR/Shell/Console/Command/NodeRemoveCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php index 2bc60243..638c2724 100644 --- a/src/PHPCR/Shell/Console/Command/NodeRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRemoveCommand.php @@ -1,6 +1,6 @@ setName('node:remove'); - $this->setDescription('Remove the node at the current path'); + $this->setDescription('Remove the node at path'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $currentPath = $currentNode->getPath(); if ($currentPath == '/') { diff --git a/src/PHPCR/Shell/Console/Command/NodeRenameCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php similarity index 91% rename from src/PHPCR/Shell/Console/Command/NodeRenameCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php index 5c75e9eb..79153c07 100644 --- a/src/PHPCR/Shell/Console/Command/NodeRenameCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeRenameCommand.php @@ -1,6 +1,6 @@ setName('node:rename'); $this->setDescription('Rename the node at the current path'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('newName', null, InputArgument::REQUIRED, 'The name of the node to create'); $this->setHelp(<<newName. The ordering (if any) of @@ -60,8 +61,9 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $newName = $input->getArgument('newName'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $currentNode->rename($newName); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeSetPrimaryTypeCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php similarity index 85% rename from src/PHPCR/Shell/Console/Command/NodeSetPrimaryTypeCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php index 866df51b..cba013e0 100644 --- a/src/PHPCR/Shell/Console/Command/NodeSetPrimaryTypeCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSetPrimaryTypeCommand.php @@ -1,6 +1,6 @@ setName('node:set-primary-type'); $this->setDescription('Set the primary type of the current node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('nodeTypeName', null, InputArgument::REQUIRED, null, 'New primary node type name'); $this->setHelp(<<getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $nodeTypeName = $input->getArgument('nodeTypeName'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $currentNode->setPrimaryType($nodeTypeName); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeSharedRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php similarity index 85% rename from src/PHPCR/Shell/Console/Command/NodeSharedRemoveCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php index c9536c54..605fefc3 100644 --- a/src/PHPCR/Shell/Console/Command/NodeSharedRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedRemoveCommand.php @@ -1,6 +1,6 @@ setName('node:shared:remove'); $this->setDescription('Removes this node and every other node in the shared set of this node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $sharedSet = $currentNode->removeSharedSet(); } } diff --git a/src/PHPCR/Shell/Console/Command/NodeSharedShowCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php similarity index 85% rename from src/PHPCR/Shell/Console/Command/NodeSharedShowCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php index e03a53ac..c183223e 100644 --- a/src/PHPCR/Shell/Console/Command/NodeSharedShowCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeSharedShowCommand.php @@ -1,6 +1,6 @@ setName('node:shared:show'); $this->setDescription('Show all the nodes are in the shared set of this node'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->setHelp(<<getHelper('phpcr')->getSession(); - $currentNode = $session->getCurrentNode(); + $path = $session->getAbsPath($input->getArgument('path')); + $currentNode = $session->getNode($path); $sharedSet = $currentNode->getSharedSet(); foreach ($sharedSet as $sharedNode) { diff --git a/src/PHPCR/Shell/Console/Command/NodeTypeEditCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php similarity index 98% rename from src/PHPCR/Shell/Console/Command/NodeTypeEditCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php index 080ac332..8e1f5ad1 100644 --- a/src/PHPCR/Shell/Console/Command/NodeTypeEditCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/NodeTypeEditCommand.php @@ -1,6 +1,6 @@ setName('node:update'); $this->setDescription('Updates a node corresponding to the current one in the given workspace'); + $this->addArgument('path', InputArgument::REQUIRED, 'Path of node'); $this->addArgument('srcWorkspace', null, InputArgument::REQUIRED, 'The name of the source workspace'); $this->setHelp(<<getHelper('phpcr')->getSession(); + $path = $session->getAbsPath($input->getArgument('path')); $srcWorkspace = $input->getArgument('srcWorkspace'); - $currentNode = $session->getCurrentNode(); + $currentNode = $session->getNode($path); $currentNode->update($srcWorkspace); } } diff --git a/src/PHPCR/Shell/Console/Command/PhpcrShellCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php similarity index 96% rename from src/PHPCR/Shell/Console/Command/PhpcrShellCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php index 1c33712e..6c3fcd55 100644 --- a/src/PHPCR/Shell/Console/Command/PhpcrShellCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/PhpcrShellCommand.php @@ -1,6 +1,6 @@ setName('version:checkin'); $this->setDescription('Checkin (commit) a node version'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Absolute path to node'); $this->setHelp(<<absPath a new version with a system +Creates for the versionable node at path a new version with a system generated version name and returns that version (which will be the new base version of this node). Sets the jcr:checkedOut property to false thus putting the node into the checked-in state. This means that the node @@ -49,15 +49,15 @@ public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); $nodeHelper = $this->getHelper('node'); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); $versionManager = $workspace->getVersionManager(); - $node = $session->getNode($absPath); + $node = $session->getNode($path); $nodeHelper->assertNodeIsVersionable($node); - $version = $versionManager->checkin($absPath); + $version = $versionManager->checkin($path); $output->writeln('Version: ' . $version->getName()); } diff --git a/src/PHPCR/Shell/Console/Command/VersionCheckoutCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php similarity index 84% rename from src/PHPCR/Shell/Console/Command/VersionCheckoutCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php index 17b30ccd..e61952ee 100644 --- a/src/PHPCR/Shell/Console/Command/VersionCheckoutCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckoutCommand.php @@ -1,6 +1,6 @@ setName('version:checkout'); $this->setDescription('Checkout a node version and enable changes to be made'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Absolute path to node'); $this->setHelp(<<absPath to checked-out status by setting +Sets the versionable node at path to checked-out status by setting its jcr:isCheckedOut property to true. Under full versioning it also sets the jcr:predecessors property to be a reference to the current base version (the same value as held in jcr:baseVersion). @@ -37,7 +37,7 @@ public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); $nodeHelper = $this->getHelper('node'); - $absPath = $input->getArgument('absPath'); + $absPath = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); $node = $session->getNode($absPath); diff --git a/src/PHPCR/Shell/Console/Command/VersionCheckpointCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php similarity index 77% rename from src/PHPCR/Shell/Console/Command/VersionCheckpointCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php index 17309c50..4b5e2d1b 100644 --- a/src/PHPCR/Shell/Console/Command/VersionCheckpointCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionCheckpointCommand.php @@ -1,6 +1,6 @@ setName('version:checkpoint'); $this->setDescription('Checkin and then checkout a node'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Path to node'); $this->setHelp(<<version:checkin followed by a version:checkout on the versionable node at -absPath +path If this node is already checked-in, this method is equivalent to version:checkout. HERE @@ -27,13 +27,13 @@ public function execute(InputInterface $input, OutputInterface $output) { $session = $this->getHelper('phpcr')->getSession(); $nodeHelper = $this->getHelper('node'); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); - $node = $session->getNode($absPath); + $node = $session->getNode($path); $nodeHelper->assertNodeIsVersionable($node); $versionManager = $workspace->getVersionManager(); - $version = $versionManager->checkpoint($absPath); + $version = $versionManager->checkpoint($path); $output->writeln('Version: ' . $version->getName()); } diff --git a/src/PHPCR/Shell/Console/Command/VersionHistoryCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php similarity index 76% rename from src/PHPCR/Shell/Console/Command/VersionHistoryCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php index a45080b3..8dceb92b 100644 --- a/src/PHPCR/Shell/Console/Command/VersionHistoryCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionHistoryCommand.php @@ -1,6 +1,6 @@ setName('version:history'); $this->setDescription('Show version history of node at given absolute path'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Absolute path to node'); $this->setHelp(<<absPath. +Lists the version history of the node given at path. HERE ); } @@ -26,13 +26,13 @@ public function execute(InputInterface $input, OutputInterface $output) $nodeHelper = $this->getHelper('node'); $table = clone $this->getHelper('table'); - $absPath = $input->getArgument('absPath'); + $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); - $node = $session->getNode($absPath); + $node = $session->getNode($path); $nodeHelper->assertNodeIsVersionable($node); $versionManager = $workspace->getVersionManager(); - $history = $versionManager->getVersionHistory($absPath); + $history = $versionManager->getVersionHistory($path); $versions = $history->getAllVersions(); diff --git a/src/PHPCR/Shell/Console/Command/VersionRemoveCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php similarity index 86% rename from src/PHPCR/Shell/Console/Command/VersionRemoveCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php index 833ae440..f81555be 100644 --- a/src/PHPCR/Shell/Console/Command/VersionRemoveCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRemoveCommand.php @@ -1,6 +1,6 @@ setName('version:remove'); $this->setDescription('Remove a node version'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Path to node'); $this->addArgument('versionName', null, InputArgument::REQUIRED, 'Name of version to remove'); $this->setHelp(<<getArgument('absPath'); - $versionName = $input->getArgument('versionName'); $session = $this->getHelper('phpcr')->getSession(); + + $versionName = $input->getArgument('versionName'); + $path = $session->getAbsPath($input->getArgument('path')); $workspace = $session->getWorkspace(); $versionManager = $workspace->getVersionManager(); - $history = $versionManager->getVersionHistory($absPath); + $history = $versionManager->getVersionHistory($path); $history->removeVersion($versionName); } } diff --git a/src/PHPCR/Shell/Console/Command/VersionRestoreCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php similarity index 81% rename from src/PHPCR/Shell/Console/Command/VersionRestoreCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php index 6b3a88d0..748fc7d0 100644 --- a/src/PHPCR/Shell/Console/Command/VersionRestoreCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/VersionRestoreCommand.php @@ -1,6 +1,6 @@ setName('version:restore'); $this->setDescription('Restore a node version'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); + $this->addArgument('path', null, InputArgument::REQUIRED, 'Path to node'); $this->addArgument('versionName', null, InputArgument::REQUIRED, 'Name of version to retore'); $this->addOption('remove-existing', null, InputOption::VALUE_NONE, 'Flag that governs what happens in case of identifier collision'); $this->setHelp(<<If absPath is given and versionName is a version name: - Restores the node at absPath to the state defined by the version with +If path is given and versionName is a version name: + Restores the node at path to the state defined by the version with the specified version name (versionName). - This method will work regardless of whether the node at absPath is + This method will work regardless of whether the node at path is checked-in or not. -If absPath is given and versionName is a VersionInterface instance: +If path is given and versionName is a VersionInterface instance: - Restores the specified version to absPath. There must be no existing - node at absPath. If one exists, a VersionException is thrown. - There must be a parent node to the location at absPath, otherwise a + Restores the specified version to path. There must be no existing + node at path. If one exists, a VersionException is thrown. + There must be a parent node to the location at path, otherwise a PathNotFoundException is thrown. - If the would-be parent of the location absPath is actually a property, + If the would-be parent of the location path is actually a property, or if a node type restriction would be violated, then a ConstraintViolationException is thrown. @@ -71,7 +71,7 @@ protected function configure() subgraphs that has the same identifier as one of the nodes that would be introduced by the restore operation into one of these subgraphs. Else, an identifier collision occurs when a node exists outside the -subgraph rooted at absPath with the same identifier as a node that would +subgraph rooted at path with the same identifier as a node that would be introduced by the restore operation into the affected subgraph. The result in such a case is governed by the removeExisting flag. If removeExisting is true, then the incoming node takes precedence, and the @@ -93,12 +93,13 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output) { - $absPath = $input->getArgument('absPath'); + $session = $this->getHelper('phpcr')->getSession(); + + $path = $session->getAbsPath($input->getArgument('path')); $versionName = $input->getArgument('versionName'); $removeExisting = $input->getOption('remove-existing'); - $session = $this->getHelper('phpcr')->getSession(); $workspace = $session->getWorkspace(); $versionManager = $workspace->getVersionManager(); - $versionManager->restore($removeExisting, $versionName, $absPath); + $versionManager->restore($removeExisting, $versionName, $path); } } diff --git a/src/PHPCR/Shell/Console/Command/WorkspaceCreateCommand.php b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php similarity index 96% rename from src/PHPCR/Shell/Console/Command/WorkspaceCreateCommand.php rename to src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php index 8edb589c..d04a5e4f 100644 --- a/src/PHPCR/Shell/Console/Command/WorkspaceCreateCommand.php +++ b/src/PHPCR/Shell/Console/Command/Phpcr/WorkspaceCreateCommand.php @@ -1,6 +1,6 @@ setName('session:node:show'); - $this->setDescription('Show the current node'); - $this->addArgument('srcAbsPath', null, InputArgument::REQUIRED, 'The root of the subgraph to be moved.'); - $this->addArgument('destAbsPath', null, InputArgument::REQUIRED, 'The location to which the subgraph is to be moved'); - $this->setHelp(<<srcAbsPath (and its entire subgraph) to the new -location at destAbsPath. - -This is a session-write command and therefor requires a save to dispatch -the change. - -The identifiers of referenceable nodes must not be changed by a move. -The identifiers of non-referenceable nodes may change. - -A ConstraintViolationException is thrown either immediately, on dispatch -or on persist, if performing this operation would violate a node type or -implementation-specific constraint. Implementations may differ on when -this validation is performed. - -As well, a ConstraintViolationException will be thrown on persist if an -attempt is made to separately save either the source or destination -node. - -Note that this behaviour differs from that of workspace::move -, which is a workspace-write command and therefore immediately dispatches -changes. - -The destAbsPath provided must not have an index on its final element. If -ordering is supported by the node type of the parent node of the new -location, then the newly moved node is appended to the end of the child -node list. - -This command cannot be used to move an individual property by itself. It -moves an entire node and its subgraph. -HERE - ); - } - - public function execute(InputInterface $input, OutputInterface $output) - { - $session = $this->getHelper('phpcr')->getSession(); - $srcAbsPath = $input->getArgument('srcAbsPath'); - $destAbsPath = $input->getArgument('destAbsPath'); - $session->move($srcAbsPath, $destAbsPath); - - // TODO: None of the session stuff should be saving. - } -} diff --git a/src/PHPCR/Shell/Console/Command/SessionNodeShowCommand.php b/src/PHPCR/Shell/Console/Command/SessionNodeShowCommand.php deleted file mode 100644 index 587d7468..00000000 --- a/src/PHPCR/Shell/Console/Command/SessionNodeShowCommand.php +++ /dev/null @@ -1,56 +0,0 @@ -setName('session:node:show'); - $this->setDescription('Show all the properties and children of a node'); - $this->addArgument('absPath', null, InputArgument::REQUIRED, 'Absolute path to node'); - $this->setHelp(<<getHelper('phpcr')->getSession(); - $absPath = $input->getArgument('absPath'); - - $node = $session->getNode($absPath); - $properties = $node->getProperties(); - $children = $node->getNodes(); - $formatter = $this->getHelper('result_formatter'); - $textHelper = $this->getHelper('text'); - - $table = clone $this->getHelper('table'); - $table->setHeaders(array('Property / Node Name', 'Type / Node Type', 'Value')); - - foreach ($properties as $key => $property) { - $table->addRow(array( - '- ' . $key, - $formatter->getPropertyTypeName($property->getType()) . ($property->isMultiple() ? '[]' : ''), - $textHelper->truncate($formatter->formatValue($property), 55), - )); - } - - foreach ($children as $child) { - $table->addRow(array( - $formatter->formatNodeName($child), - $child->getPrimaryNodeType()->getName(), - $textHelper->truncate($formatter->formatNodePropertiesInline($child), 55) - )); - } - - $table->render($output); - } -} diff --git a/src/PHPCR/Shell/Console/Helper/PathHelper.php b/src/PHPCR/Shell/Console/Helper/PathHelper.php new file mode 100644 index 00000000..fa515fc1 --- /dev/null +++ b/src/PHPCR/Shell/Console/Helper/PathHelper.php @@ -0,0 +1,38 @@ + + */ +class PathHelper extends Helper +{ + /** + * @see StaticPathHelper::getParentPath + */ + public function getParentPath($path) + { + return StaticPathHelper::getParentPath($path); + } + + /** + * @see StaticPathHelper::getNodeName + */ + public function getNodeName($path) + { + return StaticPathHelper::getNodeName($path); + } + + /** + * {@inheritDoc} + */ + public function getName() + { + return 'path'; + } +} diff --git a/src/PHPCR/Shell/PhpcrSession.php b/src/PHPCR/Shell/PhpcrSession.php index d24ee9cc..74060fcc 100644 --- a/src/PHPCR/Shell/PhpcrSession.php +++ b/src/PHPCR/Shell/PhpcrSession.php @@ -110,7 +110,7 @@ public function chdir($path) public function getAbsPath($path) { - if (!$path) { + if (!$path || $path === '.') { return $this->getCwd(); } diff --git a/tests/PHPCR/Shell/PhpcrSessionTest.php b/tests/PHPCR/Shell/PhpcrSessionTest.php index 6d1387aa..b8de8820 100644 --- a/tests/PHPCR/Shell/PhpcrSessionTest.php +++ b/tests/PHPCR/Shell/PhpcrSessionTest.php @@ -42,6 +42,9 @@ public function provideAbsPath() array('/', 'cms', '/cms'), array('/', '/cms', '/cms'), array('/cms', 'foo', '/cms/foo'), + array('/cms', '', '/cms'), + array('/cms', null, '/cms'), + array('/cms', '.', '/cms'), ); } @@ -51,8 +54,8 @@ public function provideAbsPath() public function testAbsPath($cwd, $path, $expected) { $this->session->setCwd($cwd); - $this->session->chdir($path); - $this->assertEquals($expected, $this->session->getCwd()); + $absPath = $this->session->getAbsPath($path); + $this->assertEquals($expected, $absPath); } public function provideMv()