You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jd...@apache.org on 2008/10/06 07:04:05 UTC
svn commit: r701946 - in /geronimo/gshell/trunk:
gshell-commands/gshell-admin/src/main/resources/META-INF/spring/
gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/
gshell-commands/gshell-bsf/src/main/resources/META-INF/s...
Author: jdillon
Date: Sun Oct 5 22:04:03 2008
New Revision: 701946
URL: http://svn.apache.org/viewvc?rev=701946&view=rev
Log:
More work on the meta:/ stuff
Putting some plugins into their own namespace under meta:/commands/*
Most things now support FileType.FILE_OR_FOLDER, including completion
When adding new meta:/* stuff if the parent tree is missing it will be created
MetaDataInstaller is now spring happy, configuring the meta:/system/* bits from components.xml now
VfsCommandSupport now uses FailureNotification in helpers to ensure common stuff like file exists and so on
Using Java 5 printf stuff instead of plexus StringUtils where possible
'rshd' is now a link instead of an alias
The resolver now caches the meta:/commands directory ref
Hooked up {Failure|Success}Notification handling in wisdom
Added:
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java (contents, props changed)
- copied, changed from r701826, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/meta/MetaDataInstaller.java
Removed:
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/meta/MetaDataInstaller.java
Modified:
geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptAction.java
geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryAction.java
geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-commands/gshell-remote/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CurrentDirectoryAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/EditAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileInfoAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FindAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java
geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VfsActionSupport.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistry.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistryImpl.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjectNameCompleter.java
geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccessImpl.java
geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
Modified: geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-admin/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -29,11 +29,11 @@
<gshell:plugin name="gshell-admin">
<gshell:command-bundle name="default">
- <gshell:command name="list-plugins" type="stateless">
+ <gshell:command name="admin/list-plugins" type="stateless">
<gshell:action class="org.apache.geronimo.gshell.commands.admin.ListPluginsAction"/>
</gshell:command>
- <gshell:command name="install-plugin">
+ <gshell:command name="admin/install-plugin">
<gshell:action class="org.apache.geronimo.gshell.commands.admin.InstallPluginAction"/>
</gshell:command>
</gshell:command-bundle>
Modified: geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/java/org/apache/geronimo/gshell/commands/bsf/ScriptAction.java Sun Oct 5 22:04:03 2008
@@ -154,8 +154,8 @@
io.error("File not found: {}", file.getName());
return Result.FAILURE;
}
- else if (file.getType() == FileType.FOLDER) {
- io.error("File is a directory: {}", file.getName());
+ else if (!file.getType().hasContent()) {
+ io.error("File has not content: {}", file.getName());
return Result.FAILURE;
}
else if (!file.isReadable()) {
Modified: geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-bsf/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -29,7 +29,7 @@
<gshell:plugin name="gshell-bsf">
<gshell:command-bundle name="default">
- <gshell:command name="script">
+ <gshell:command name="bsf/script">
<gshell:action class="org.apache.geronimo.gshell.commands.bsf.ScriptAction"/>
<gshell:completers>
<ref bean="fileObjectNameCompleter"/>
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/AliasAction.java Sun Oct 5 22:04:03 2008
@@ -27,7 +27,6 @@
import org.apache.geronimo.gshell.i18n.MessageSource;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.registry.AliasRegistry;
-import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -87,7 +86,7 @@
io.out.println("Defined aliases:");
for (String name : names) {
String alias = aliasRegistry.getAlias(name);
- String formattedName = StringUtils.rightPad(name, maxNameLen);
+ String formattedName = String.format("%-" + maxNameLen + "s", name);
io.out.print(" ");
io.out.print(Renderer.encode(formattedName, Code.BOLD));
@@ -96,8 +95,6 @@
io.out.print("Alias to: ");
io.out.println(alias);
}
-
- io.out.println();
}
return Result.SUCCESS;
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HelpAction.java Sun Oct 5 22:04:03 2008
@@ -31,7 +31,6 @@
import org.apache.geronimo.gshell.registry.CommandResolver;
import org.apache.geronimo.gshell.registry.NoSuchAliasException;
import org.apache.geronimo.gshell.registry.NoSuchCommandException;
-import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -91,7 +90,6 @@
io.out.print(Renderer.encode(commandName, Code.BOLD));
io.out.print(" is an alias to: ");
io.out.println(Renderer.encode(alias, Code.BOLD));
- io.out.println();
return Result.SUCCESS;
}
@@ -104,8 +102,6 @@
io.out.print(Renderer.encode("help", Code.BOLD));
io.out.println(" for a list of available commands.");
- io.out.println();
-
return Result.FAILURE;
}
}
@@ -131,8 +127,7 @@
for (Command command : commands) {
CommandDocumenter documenter = command.getDocumenter();
- // TODO: Use printf
- String formattedName = StringUtils.rightPad(documenter.getName(), maxNameLen);
+ String formattedName = String.format("%-" + maxNameLen + "s", documenter.getName());
String desc = documenter.getDescription();
io.out.print(" ");
@@ -147,8 +142,6 @@
}
}
- io.out.println();
-
return Result.SUCCESS;
}
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-builtins/src/main/java/org/apache/geronimo/gshell/commands/builtins/HistoryAction.java Sun Oct 5 22:04:03 2008
@@ -19,14 +19,13 @@
package org.apache.geronimo.gshell.commands.builtins;
+import jline.History;
+import org.apache.geronimo.gshell.ansi.Code;
+import org.apache.geronimo.gshell.ansi.Renderer;
import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
-import org.apache.geronimo.gshell.ansi.Renderer;
-import org.apache.geronimo.gshell.ansi.Code;
import org.springframework.beans.factory.annotation.Autowired;
-import org.codehaus.plexus.util.StringUtils;
-import jline.History;
import java.util.List;
@@ -54,7 +53,7 @@
int i = 0;
for (String element : elements) {
- String index = StringUtils.leftPad(String.valueOf(i), 3, " ");
+ String index = String.format("%3d", i);
io.info(" {} {}", Renderer.encode(index, Code.BOLD), element);
i++;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-optional/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -29,23 +29,23 @@
<gshell:plugin name="gshell-optional">
<gshell:command-bundle name="default">
- <gshell:command name="exec">
+ <gshell:command name="optional/exec">
<gshell:action class="org.apache.geronimo.gshell.commands.optional.ExecuteAction"/>
</gshell:command>
- <gshell:command name="java">
+ <gshell:command name="optional/java">
<gshell:action class="org.apache.geronimo.gshell.commands.optional.JavaAction"/>
</gshell:command>
- <gshell:command name="sleep">
+ <gshell:command name="optional/sleep">
<gshell:action class="org.apache.geronimo.gshell.commands.optional.SleepAction"/>
</gshell:command>
- <gshell:command name="date">
+ <gshell:command name="optional/date">
<gshell:action class="org.apache.geronimo.gshell.commands.optional.DateAction"/>
</gshell:command>
- <gshell:command name="hostname">
+ <gshell:command name="optional/hostname">
<gshell:action class="org.apache.geronimo.gshell.commands.optional.HostnameAction"/>
</gshell:command>
</gshell:command-bundle>
Modified: geronimo/gshell/trunk/gshell-commands/gshell-remote/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-remote/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-remote/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-remote/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -29,15 +29,15 @@
<gshell:plugin name="gshell-remote">
<gshell:command-bundle name="default">
- <gshell:command name="rsh">
+ <gshell:command name="remote/rsh">
<gshell:action class="org.apache.geronimo.gshell.commands.remote.RshAction"/>
</gshell:command>
- <gshell:command name="rsh-server">
+ <gshell:command name="remote/rsh-server">
<gshell:action class="org.apache.geronimo.gshell.commands.remote.RshServerAction"/>
</gshell:command>
- <gshell:alias name="rshd" alias="rsh-server"/>
+ <gshell:link name="remote/rshd" target="remote/rsh-server"/>
</gshell:command-bundle>
</gshell:plugin>
Modified: geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-repository/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -29,7 +29,7 @@
<gshell:plugin name="gshell-repository">
<gshell:command-bundle name="default">
- <gshell:command name="resolve">
+ <gshell:command name="repository/resolve">
<gshell:action class="org.apache.geronimo.gshell.commands.repository.ResolveAction"/>
</gshell:command>
</gshell:command-bundle>
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CatAction.java Sun Oct 5 22:04:03 2008
@@ -22,13 +22,12 @@
import org.apache.commons.vfs.FileContent;
import org.apache.commons.vfs.FileContentInfo;
import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileType;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
@@ -42,12 +41,12 @@
public class CatAction
extends VfsActionSupport
{
- @Argument(required=true)
- private String path;
-
@Option(name="-n")
private boolean displayLineNumbers;
+ @Argument(required=true)
+ private String path;
+
public Object execute(final CommandContext context) throws Exception {
assert context != null;
IO io = context.getIo();
@@ -58,14 +57,8 @@
FileObject file = resolveFile(context, path);
- if (!file.exists()) {
- io.error("File not found: {}", file.getName());
- return Result.FAILURE;
- }
- else if (file.getType() == FileType.FOLDER) {
- io.error("File is a directory: {}", file.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(file);
+ ensureFileHasContent(file);
FileContent content = file.getContent();
FileContentInfo info = content.getContentInfo();
@@ -86,7 +79,7 @@
IOUtil.close(reader);
}
- closeFile(file);
+ FileObjects.close(file);
return Result.SUCCESS;
}
@@ -97,13 +90,7 @@
while ((line = reader.readLine()) != null) {
if (displayLineNumbers) {
- //
- // TODO: Replace with io.out.printf()
- //
-
- String gutter = StringUtils.leftPad(String.valueOf(lineno++), 6);
- io.out.print(gutter);
- io.out.print(" ");
+ io.out.print(String.format("%6d ", lineno++));
}
io.out.println(line);
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ChangeDirectoryAction.java Sun Oct 5 22:04:03 2008
@@ -20,10 +20,10 @@
package org.apache.geronimo.gshell.commands.vfs;
import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileType;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
/**
* Changes the current directory.
@@ -47,18 +47,12 @@
FileObject file = resolveFile(context, path);
- if (!file.exists()) {
- io.error("Directory not found: {}", file.getName());
- return Result.FAILURE;
- }
- else if (file.getType() != FileType.FOLDER) {
- io.error("File is not a directory: {}", file.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(file);
+ ensureFileHasChildren(file);
setCurrentDirectory(context, file);
- closeFile(file);
+ FileObjects.close(file);
return Result.SUCCESS;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CopyAction.java Sun Oct 5 22:04:03 2008
@@ -20,11 +20,11 @@
package org.apache.geronimo.gshell.commands.vfs;
import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.Selectors;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
/**
* Copies a file or directory.
@@ -51,14 +51,11 @@
FileObject source = resolveFile(context, sourcePath);
FileObject target = resolveFile(context, targetPath);
- if (!source.exists()) {
- io.error("Source file not found: {}", source.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(source);
// TODO: Validate more
- if (target.exists() && target.getType() == FileType.FOLDER) {
+ if (target.exists() && target.getType().hasChildren()) {
target = target.resolveFile(source.getName().getBaseName());
}
@@ -66,8 +63,7 @@
target.copyFrom(source, Selectors.SELECT_ALL);
- closeFile(source);
- closeFile(target);
+ FileObjects.closeAll(source, target);
return Result.SUCCESS;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CurrentDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CurrentDirectoryAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CurrentDirectoryAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/CurrentDirectoryAction.java Sun Oct 5 22:04:03 2008
@@ -22,6 +22,7 @@
import org.apache.commons.vfs.FileObject;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
/**
* Displays the current directory.
@@ -36,9 +37,9 @@
IO io = context.getIo();
FileObject dir = getCurrentDirectory(context);
- io.info("{}", dir.getName());
+ io.info(dir.getName().getURI());
- closeFile(dir);
+ FileObjects.close(dir);
return Result.SUCCESS;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/EditAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/EditAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/EditAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/EditAction.java Sun Oct 5 22:04:03 2008
@@ -21,13 +21,13 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystem;
-import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.Selectors;
import org.apache.commons.vfs.util.Os;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.apache.geronimo.gshell.vfs.provider.local.LocalFile;
import org.apache.geronimo.gshell.vfs.provider.local.LocalFileSystem;
@@ -55,23 +55,11 @@
FileObject file = resolveFile(context, path);
- if (!file.exists()) {
- // TODO: Allow creation of files which don't exist
- io.error("File not found: {}", file.getName());
- return Result.FAILURE;
- }
- else if (file.getType() == FileType.FOLDER) {
- io.error("File is a directory: {}", file.getName());
- return Result.FAILURE;
- }
- else if (!file.isReadable()) {
- io.error("File is not readble: {}", file.getName());
- return Result.FAILURE;
- }
- else if (!file.isWriteable()) {
- io.error("File is not writable: {}", file.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(file);
+ ensureFileHasContent(file);
+ ensureFileIsReadable(file);
+ ensureFileIsWritable(file);
+
FileObject tmp = file;
FileSystem fs = file.getFileSystem();
@@ -95,10 +83,10 @@
log.debug("Updating original file with edited content");
file.copyFrom(tmp, Selectors.SELECT_SELF);
tmp.delete();
- closeFile(tmp);
+ FileObjects.close(tmp);
}
- closeFile(file);
+ FileObjects.close(file);
return result;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileInfoAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileInfoAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileInfoAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FileInfoAction.java Sun Oct 5 22:04:03 2008
@@ -22,6 +22,7 @@
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.FileContent;
@@ -72,6 +73,7 @@
io.info("Content encoding: {}", contentInfo.getContentEncoding());
try {
+ // noinspection unchecked
Map<String,Object> attrs = content.getAttributes();
if (attrs != null && !attrs.isEmpty()) {
io.info("Attributes:");
@@ -100,7 +102,7 @@
if (file.getType().equals(FileType.FILE)) {
io.info("Size: {} bytes", content.getSize());
}
- else if (file.getType().equals(FileType.FOLDER) && file.isReadable()) {
+ else if (file.getType().hasChildren() && file.isReadable()) {
FileObject[] children = file.getChildren();
io.info("Directory with {} files", children.length);
@@ -118,7 +120,7 @@
io.info("The file does not exist");
}
- closeFile(file);
+ FileObjects.close(file);
return Result.SUCCESS;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FindAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FindAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FindAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/FindAction.java Sun Oct 5 22:04:03 2008
@@ -29,6 +29,7 @@
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.vfs.selector.AggregateFileSelector;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.apache.oro.text.GlobCompiler;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
@@ -73,14 +74,11 @@
FileObject root = resolveFile(context, path);
- if (!root.exists()) {
- io.error("File not found: {}", root.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(root);
find(context, root, selector);
- closeFile(root);
+ FileObjects.close(root);
return Result.SUCCESS;
}
@@ -96,7 +94,7 @@
for (FileObject child : files) {
display(context, child);
- if (child.getType() == FileType.FOLDER) {
+ if (child.getType().hasChildren()) {
find(context, child, selector);
}
}
@@ -146,6 +144,8 @@
case F:
return ftype == FileType.FILE;
+ // TODO: Handle FileType.FILE_OR_FOLDER
+
default:
return false;
}
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/GrepAction.java Sun Oct 5 22:04:03 2008
@@ -24,17 +24,18 @@
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.apache.oro.text.MatchAction;
import org.apache.oro.text.MatchActionInfo;
import org.apache.oro.text.MatchActionProcessor;
import org.apache.oro.text.regex.MalformedPatternException;
-import org.apache.oro.text.regex.Perl5Compiler;
-import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.oro.text.regex.PatternMatcher;
-import org.apache.oro.text.regex.Pattern;
-import org.apache.oro.text.regex.PatternMatcherInput;
import org.apache.oro.text.regex.MatchResult;
+import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
+import org.apache.oro.text.regex.PatternMatcher;
+import org.apache.oro.text.regex.PatternMatcherInput;
+import org.apache.oro.text.regex.Perl5Compiler;
+import org.apache.oro.text.regex.Perl5Matcher;
import org.codehaus.plexus.util.IOUtil;
import java.io.BufferedInputStream;
@@ -119,13 +120,12 @@
}
FileObject file = resolveFile(context, path);
- BufferedInputStream input = new BufferedInputStream(file.getContent().getInputStream());
+
try {
- processor.processMatches(input, io.outputStream);
+ grep(context, processor, file);
}
finally {
- IOUtil.close(input);
- closeFile(file);
+ FileObjects.close(file);
}
if (count) {
@@ -135,6 +135,24 @@
return matches != 0 ? FOUND: NOT_FOUND;
}
+ private void grep(final CommandContext context, final MatchActionProcessor processor, final FileObject file) throws Exception {
+ assert context != null;
+ assert processor != null;
+ assert file != null;
+
+ ensureFileExists(file);
+ ensureFileHasContent(file);
+ ensureFileIsReadable(file);
+
+ BufferedInputStream input = new BufferedInputStream(file.getContent().getInputStream());
+ try {
+ processor.processMatches(input, context.getIo().outputStream);
+ }
+ finally {
+ IOUtil.close(input);
+ }
+ }
+
/**
* Delegating {@link PatternMatcher} which allows the match/contains results to be
* inverted based on the {@link GrepAction#invertMatch} field for --invert-match support.
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/ListDirectoryAction.java Sun Oct 5 22:04:03 2008
@@ -25,11 +25,12 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSelectInfo;
import org.apache.commons.vfs.FileSystemException;
-import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.FileName;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.clp.Option;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import java.util.ArrayList;
import java.util.LinkedList;
@@ -67,15 +68,14 @@
file = getCurrentDirectory(context);
}
- FileType type = file.getType();
- if (type == FileType.FOLDER || type == FileType.FILE_OR_FOLDER) {
+ if (file.getType().hasChildren()) {
listChildren(io, file);
}
else {
io.info(file.getName().getPath());
}
- closeFile(file);
+ FileObjects.close(file);
return Result.SUCCESS;
}
@@ -113,22 +113,19 @@
List<FileObject> dirs = new LinkedList<FileObject>();
for (FileObject file : files) {
- FileType type = file.getType();
+ String fileName = file.getName().getBaseName();
- if (type == FileType.FILE) {
- names.add(file.getName().getBaseName());
-
- }
- else if (type == FileType.FOLDER || type == FileType.FILE_OR_FOLDER) {
- names.add(file.getName().getBaseName() + "/");
+ if (FileObjects.hasChildren(file)) {
+ fileName += FileName.SEPARATOR;
if (recursive) {
dirs.add(file);
}
}
- else {
- log.warn("Unable to handle file type: {}", type);
- }
+
+ names.add(fileName);
+
+ file.close();
}
if (longList) {
@@ -148,5 +145,7 @@
listChildren(io, subdir);
}
}
+
+ dir.close();
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/RemoveAction.java Sun Oct 5 22:04:03 2008
@@ -24,6 +24,7 @@
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.io.IO;
+import org.apache.geronimo.gshell.vfs.FileObjects;
/**
* Remove a file or directory.
@@ -46,15 +47,15 @@
FileObject file = resolveFile(context, path);
- if (!file.exists()) {
- io.error("File not found: {}", file.getName());
- return Result.FAILURE;
- }
+ ensureFileExists(file);
- file.delete(Selectors.SELECT_SELF);
+ try {
+ file.delete(Selectors.SELECT_SELF);
+ }
+ finally {
+ FileObjects.close(file);
+ }
- closeFile(file);
-
return Result.SUCCESS;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/TouchAction.java Sun Oct 5 22:04:03 2008
@@ -22,6 +22,7 @@
import org.apache.commons.vfs.FileObject;
import org.apache.geronimo.gshell.clp.Argument;
import org.apache.geronimo.gshell.command.CommandContext;
+import org.apache.geronimo.gshell.vfs.FileObjects;
/**
* Sets the last-modified time of a file.
@@ -41,14 +42,17 @@
FileObject file = resolveFile(context, path);
- if (!file.exists()) {
- file.createFile();
- }
+ try {
+ if (!file.exists()) {
+ file.createFile();
+ }
- file.getContent().setLastModifiedTime(System.currentTimeMillis());
+ file.getContent().setLastModifiedTime(System.currentTimeMillis());
+ }
+ finally {
+ FileObjects.close(file);
+ }
- closeFile(file);
-
return Result.SUCCESS;
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VfsActionSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VfsActionSupport.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VfsActionSupport.java (original)
+++ geronimo/gshell/trunk/gshell-commands/gshell-vfs/src/main/java/org/apache/geronimo/gshell/commands/vfs/VfsActionSupport.java Sun Oct 5 22:04:03 2008
@@ -24,6 +24,8 @@
import org.apache.geronimo.gshell.command.CommandAction;
import org.apache.geronimo.gshell.command.CommandContext;
import org.apache.geronimo.gshell.vfs.FileSystemAccess;
+import org.apache.geronimo.gshell.vfs.FileObjects;
+import org.apache.geronimo.gshell.notification.FailureNotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,8 +38,6 @@
public abstract class VfsActionSupport
implements CommandAction
{
- public static final String CWD = "vfs.cwd";
-
protected final Logger log = LoggerFactory.getLogger(getClass());
@Autowired
@@ -70,16 +70,52 @@
return getFileSystemAccess().resolveFile(cwd, path);
}
- protected void closeFile(final FileObject file) {
- if (file != null) {
- log.trace("Closing file: {}", file);
-
- try {
- file.close();
- }
- catch (FileSystemException e) {
- log.debug("Failed to close file: " + file, e);
- }
+ //
+ // TODO: Make these more generally available to other plugins. Maybe even to FileObjects?
+ //
+
+ protected void ensureFileExists(final FileObject file) throws FileSystemException {
+ assert file != null;
+
+ if (!file.exists()) {
+ FileObjects.close(file);
+ throw new FailureNotification("File not found: " + file.getName());
+ }
+ }
+
+ protected void ensureFileHasContent(final FileObject file) throws FileSystemException {
+ assert file != null;
+
+ if (!file.getType().hasContent()) {
+ FileObjects.close(file);
+ throw new FailureNotification("File has no content: " + file.getName());
+ }
+ }
+
+ protected void ensureFileHasChildren(final FileObject file) throws FileSystemException {
+ assert file != null;
+
+ if (!file.getType().hasChildren()) {
+ FileObjects.close(file);
+ throw new FailureNotification("File has no children: " + file.getName());
+ }
+ }
+
+ protected void ensureFileIsReadable(final FileObject file) throws FileSystemException {
+ assert file != null;
+
+ if (!file.getType().hasChildren()) {
+ FileObjects.close(file);
+ throw new FailureNotification("File is not readable: " + file.getName());
+ }
+ }
+
+ protected void ensureFileIsWritable(final FileObject file) throws FileSystemException {
+ assert file != null;
+
+ if (!file.getType().hasChildren()) {
+ FileObjects.close(file);
+ throw new FailureNotification("File is not writable: " + file.getName());
}
}
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java Sun Oct 5 22:04:03 2008
@@ -27,8 +27,6 @@
import org.apache.commons.vfs.provider.AbstractFileSystem;
import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.Collection;
@@ -42,8 +40,6 @@
public class MetaFileSystem
extends AbstractFileSystem
{
- private final Logger log = LoggerFactory.getLogger(getClass());
-
private final MetaDataRegistry registry;
public MetaFileSystem(final MetaDataRegistry registry, final FileName rootName, final FileSystemOptions options) {
@@ -54,11 +50,7 @@
}
protected FileObject createFile(final FileName fileName) throws Exception {
- MetaFileObject file = new MetaFileObject(fileName, this);
-
- log.debug("Created file: {}", file);
-
- return file;
+ return new MetaFileObject(fileName, this);
}
protected void addCapabilities(final Collection capabilities) {
@@ -74,26 +66,18 @@
MetaData lookupData(final MetaFileObject file) throws FileSystemException {
assert file != null;
-
- log.debug("Looking up data: {}", file);
-
FileName name = file.getName();
- assert name != null;
- // FIXME: This should probably toss an exception if the data is not registered
- MetaData data = registry.lookupData(name);
- if (data == null) {
- data = new MetaData(name, FileType.IMAGINARY);
+ if (!registry.containsData(name)) {
+ return new MetaData(name, FileType.IMAGINARY);
}
- return data;
+ return registry.lookupData(name);
}
String[] listChildren(final FileName name) throws FileSystemException {
assert name != null;
- log.debug("Listing children: {}", name);
-
MetaData data = registry.lookupData(name);
Collection<MetaData> children = data.getChildren();
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaData.java Sun Oct 5 22:04:03 2008
@@ -20,7 +20,6 @@
package org.apache.geronimo.gshell.vfs.provider.meta.data;
import org.apache.commons.vfs.FileName;
-import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,10 +39,6 @@
private final Logger log = LoggerFactory.getLogger(getClass());
private final FileName name;
-
- //
- // TODO: Consider making all meta files FileType.FILE_OR_FOLDER
- //
private final FileType type;
@@ -56,7 +51,7 @@
private long lastModified = -1;
//
- // TODO: Consider changing "name" to a String here?
+ // TODO: Consider changing "name" to a String here? name.getParent() is used in a few places, so have to resolve that first, perhaps expose MetaData getParent() ?
//
public MetaData(final FileName name, final FileType type, final MetaDataContent content) {
@@ -74,7 +69,11 @@
}
public MetaData(final FileName name, final MetaDataContent content) {
- this(name, FileType.FILE, content);
+ this(name, FileType.FILE_OR_FOLDER, content);
+ }
+
+ public MetaData(final FileName name) {
+ this(name, FileType.FILE_OR_FOLDER, null);
}
public FileName getName() {
@@ -128,33 +127,33 @@
return children;
}
- public void addChild(final MetaData data) throws FileSystemException {
+ public void addChild(final MetaData data) {
assert data != null;
if (!getType().hasChildren()) {
- throw new FileSystemException("A child can only be added in a folder");
+ throw new MetaDataException("A child can only be added in a folder");
}
if (hasChild(data)) {
- throw new FileSystemException("Child already exists: " + data);
+ throw new MetaDataException("Child already exists: " + data);
}
- log.debug("Adding child: {}", data);
+ log.trace("Adding child: {}", data);
getChildren().add(data);
updateLastModified();
}
- public void removeChild(final MetaData data) throws FileSystemException{
+ public void removeChild(final MetaData data) {
assert data != null;
if (!getType().hasChildren()) {
- throw new FileSystemException("A child can only be removed from a folder");
+ throw new MetaDataException("A child can only be removed from a folder");
}
if (!hasChild(data)) {
- throw new FileSystemException("Child not found: " + data);
+ throw new MetaDataException("Child not found: " + data);
}
- log.debug("Removing child: {}", data);
+ log.trace("Removing child: {}", data);
getChildren().remove(data);
updateLastModified();
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistry.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistry.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistry.java Sun Oct 5 22:04:03 2008
@@ -32,7 +32,7 @@
void removeData(FileName name);
- MetaData lookupData(FileName name) /* throws MetaFileDataRegistryException */;
+ MetaData lookupData(FileName name);
boolean containsData(FileName name);
}
\ No newline at end of file
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistryImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistryImpl.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/MetaDataRegistryImpl.java Sun Oct 5 22:04:03 2008
@@ -41,7 +41,7 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private final Map<FileName, MetaData> nodes = /*Collections.synchronizedMap(*/new HashMap<FileName, MetaData>()/*)*/;
+ private final Map<FileName, MetaData> nodes = new HashMap<FileName, MetaData>();
private String rootFileName = MetaFileName.SCHEME + ":/";
@@ -61,37 +61,43 @@
assert name != null;
assert data != null;
- log.debug("Registering data: {} -> {}", name, data);
+ log.debug("Registering data: {}", name);
if (name.getDepth() > 0) {
- FileName parentName = name.getParent();
- if (parentName != null) {
- if (containsData(parentName)) {
- MetaData parent = lookupData(parentName);
-
- if (!parent.hasChild(data)) {
- try {
- parent.addChild(data);
- }
- catch (FileSystemException ignore) {
- throw new Error(ignore);
- }
- }
- }
- else {
- //
- // TODO: Consider auto-creating parents, this will work well
- // if we switch to all files as FileType.FILE_OR_FOLDER
- //
-
- log.warn("Missing parent folder: " + parentName);
+ MetaData parent = getParentData(name);
+ if (parent != null) {
+ if (!parent.hasChild(data)) {
+ parent.addChild(data);
}
}
+ else {
+ log.warn("Depth is > 0, but parent name is null for node: " + name);
+ }
}
getNodes().put(name, data);
}
+ private MetaData getParentData(final FileName name) {
+ assert name != null;
+
+ FileName parentName = name.getParent();
+ MetaData parent = null;
+
+ if (parentName != null) {
+ if (containsData(parentName)) {
+ parent = lookupData(parentName);
+ }
+ else {
+ log.debug("Building parent tree: {}", parentName);
+ parent = new MetaData(parentName, FileType.FOLDER);
+ registerData(parentName, parent);
+ }
+ }
+
+ return parent;
+ }
+
public void removeData(final FileName name) {
assert name != null;
@@ -102,12 +108,7 @@
FileName parentName = name.getParent();
if (parentName != null && containsData(parentName)) {
MetaData parent = lookupData(parentName);
- try {
- parent.removeChild(data);
- }
- catch (FileSystemException ignore) {
- throw new Error(ignore);
- }
+ parent.removeChild(data);
}
}
@@ -120,8 +121,15 @@
public MetaData lookupData(final FileName name) {
assert name != null;
- log.debug("Looking up data: {}", name);
+ log.trace("Looking up data: {}", name);
+ if (!containsData(name)) {
+ //
+ // TODO: Maybe reconsider just returning null, not sure the exception sipmlifies anything
+ //
+ throw new MetaDataRegistryException("No data registered for: " + name);
+ }
+
return getNodes().get(name);
}
}
\ No newline at end of file
Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java (from r701826, geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/meta/MetaDataInstaller.java)
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java&p1=geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/meta/MetaDataInstaller.java&r1=701826&r2=701946&rev=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/meta/MetaDataInstaller.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java Sun Oct 5 22:04:03 2008
@@ -17,16 +17,18 @@
* under the License.
*/
-package org.apache.geronimo.gshell.wisdom.meta;
+package org.apache.geronimo.gshell.vfs.provider.meta.data.support;
import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry;
-import org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataRegistryConfigurer;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData;
+import org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataContent;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
+import java.util.Map;
/**
- * Installs {@link org.apache.geronimo.gshell.vfs.provider.meta.data.MetaData} into the {@link MetaDataRegistry}.
+ * Installs {@link MetaData} into the {@link MetaDataRegistry}.
*
* @version $Rev$ $Date$
*/
@@ -35,15 +37,25 @@
@Autowired
private MetaDataRegistry metaRegistry;
+ private Map<String,MetaDataContent> contentNodes;
+
+ public void setContentNodes(final Map<String, MetaDataContent> nodes) {
+ this.contentNodes = nodes;
+ }
+
@PostConstruct
public void init() throws Exception {
assert metaRegistry != null;
MetaDataRegistryConfigurer metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- // HACK: Hard code this for now, evetually configure via spring
- metaConfig.addFolder("/system");
- metaConfig.addContent("/system/runtime", new RuntimeContent());
- metaConfig.addContent("/system/properties", new SystemPropertiesContent());
- metaConfig.addContent("/system/environment", new SystemEnvironmentContent());
+ if (contentNodes != null && !contentNodes.isEmpty()) {
+ for (Map.Entry<String,MetaDataContent> entry : contentNodes.entrySet()) {
+ metaConfig.addContent(entry.getKey(), entry.getValue());
+ }
+ }
}
+
+ //
+ // TODO: Merge this guy with MetaDataRegistryConfigurer, allow for spring+direct usage.
+ //
}
\ No newline at end of file
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataInstaller.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/data/support/MetaDataRegistryConfigurer.java Sun Oct 5 22:04:03 2008
@@ -30,7 +30,7 @@
import org.slf4j.LoggerFactory;
/**
- * Helper to configure the contents of a {@link org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistry}.
+ * Helper to configure the contents of a {@link MetaDataRegistry}.
*
* @version $Rev$ $Date$
*/
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -26,7 +26,7 @@
<bean id="metaDataRegistry" class="org.apache.geronimo.gshell.vfs.provider.meta.data.MetaDataRegistryImpl"/>
- <bean class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
+ <bean id="metaFileProviderConfigurer" class="org.apache.geronimo.gshell.vfs.config.FileProviderConfigurer">
<property name="scheme" value="meta"/>
<property name="provider">
<bean class="org.apache.geronimo.gshell.vfs.provider.meta.MetaFileProvider"/>
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjectNameCompleter.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjectNameCompleter.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjectNameCompleter.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileObjectNameCompleter.java Sun Oct 5 22:04:03 2008
@@ -61,6 +61,10 @@
assert fileSystemAccess != null;
FileObject file = fileSystemAccess.resolveFile(path);
+ //
+ // TODO: Close files
+ //
+
log.trace("Resolved file: {}", file);
final String search;
@@ -72,7 +76,7 @@
file = file.getParent();
}
}
- else if (file.getType() == FileType.FOLDER && !path.endsWith(FileName.SEPARATOR)) {
+ else if (file.getType().hasChildren() && !path.endsWith(FileName.SEPARATOR)) {
// Handle the special cases when we resolved to a directory, with out a trailing seperator,
// complete to the directory + "/" first.
@@ -147,7 +151,7 @@
// TODO: Need to encode spaces, once the parser can handle escaped spaces.
//
- if (files.length == 1 && child.getType() == FileType.FOLDER) {
+ if (files.length == 1 && child.getType().hasChildren()) {
buff.append(FileName.SEPARATOR);
}
else {
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccess.java Sun Oct 5 22:04:03 2008
@@ -43,6 +43,9 @@
FileObject resolveFile(FileObject baseFile, String name) throws FileSystemException;
+ //
+ // TODO: Consider renaming this puppy, as it resolved relative to CWD, to resolve w/o use ^^^ and pass null to the first, bit me a few times already
+ //
+
FileObject resolveFile(String name) throws FileSystemException;
-
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccessImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccessImpl.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccessImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/java/org/apache/geronimo/gshell/vfs/FileSystemAccessImpl.java Sun Oct 5 22:04:03 2008
@@ -22,7 +22,6 @@
import org.apache.commons.vfs.FileObject;
import org.apache.commons.vfs.FileSystemException;
import org.apache.commons.vfs.FileSystemManager;
-import org.apache.commons.vfs.FileType;
import org.apache.geronimo.gshell.application.ApplicationManager;
import org.apache.geronimo.gshell.command.Variables;
import org.slf4j.Logger;
@@ -97,8 +96,8 @@
if (!dir.exists()) {
throw new RuntimeException("Directory not found: " + dir.getName());
}
- else if (dir.getType() != FileType.FOLDER) {
- throw new RuntimeException("File is not a directory: " + dir.getName());
+ else if (!dir.getType().hasChildren()) {
+ throw new RuntimeException("File can not contain children: " + dir.getName());
}
vars.parent().set(CWD, dir);
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -49,6 +49,9 @@
</bean>
</property>
+ <!--
+ TODO: Try and root the temporary store under ${gshell.home}/tmp or something
+ -->
<property name="temporaryFileStore">
<ref bean="defaultFileReplicator"/>
</property>
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandDocumenterSupport.java Sun Oct 5 22:04:03 2008
@@ -108,6 +108,10 @@
out.println(getDescription());
out.println();
+ //
+ // TODO: Use a prefixing writer here, take the impl from shitty
+ //
+
out.println(renderer.render(Renderer.encode("MANUAL", Code.BOLD)));
out.println(getManual());
out.println();
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/CommandSupport.java Sun Oct 5 22:04:03 2008
@@ -32,6 +32,8 @@
import org.apache.geronimo.gshell.i18n.MessageSource;
import org.apache.geronimo.gshell.io.IO;
import org.apache.geronimo.gshell.notification.Notification;
+import org.apache.geronimo.gshell.notification.FailureNotification;
+import org.apache.geronimo.gshell.notification.SuccessNotification;
import org.apache.geronimo.gshell.shell.ShellContext;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
@@ -259,6 +261,8 @@
assert context != null;
assert args != null;
+ final IO io = context.getIo();
+
log.trace("Executing action");
// Setup the command context
@@ -270,7 +274,7 @@
}
public IO getIo() {
- return context.getIo();
+ return io;
}
public Variables getVariables() {
@@ -295,6 +299,20 @@
result = new CommandResult.ValueResult(value);
}
+ catch (final FailureNotification n) {
+ log.trace("Command notified FAILURE result: " + n, n);
+
+ io.error(n.getMessage());
+
+ result = new CommandResult.ValueResult(CommandAction.Result.FAILURE);
+ }
+ catch (final SuccessNotification n) {
+ log.trace("Command notified SUCCESS result: " + n, n);
+
+ io.verbose(n.getMessage());
+
+ result = new CommandResult.ValueResult(CommandAction.Result.SUCCESS);
+ }
catch (final Notification n) {
log.trace("Notified: " + n, n);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/command/LinkCommand.java Sun Oct 5 22:04:03 2008
@@ -80,6 +80,9 @@
return new CommandDocumenter() {
public String getName() {
+ //
+ // FIXME: This is not correct, need to fix this... help listing shows up bunk.
+ //
return delegate.getName();
}
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/plugin/PluginMetaMapper.java Sun Oct 5 22:04:03 2008
@@ -49,7 +49,6 @@
public void init() {
assert metaRegistry != null;
metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/plugins");
assert eventManager != null;
eventManager.addListener(this);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/AliasMetaMapper.java Sun Oct 5 22:04:03 2008
@@ -49,7 +49,6 @@
public void init() {
assert metaRegistry != null;
metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/aliases");
assert eventManager != null;
eventManager.addListener(this);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandMetaMapper.java Sun Oct 5 22:04:03 2008
@@ -49,7 +49,6 @@
public void init() {
assert metaRegistry != null;
metaConfig = new MetaDataRegistryConfigurer(metaRegistry);
- metaConfig.addFolder("/commands");
assert eventManager != null;
eventManager.addListener(this);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/java/org/apache/geronimo/gshell/wisdom/registry/CommandResolverImpl.java Sun Oct 5 22:04:03 2008
@@ -19,27 +19,27 @@
package org.apache.geronimo.gshell.wisdom.registry;
+import org.apache.commons.vfs.FileObject;
+import org.apache.commons.vfs.FileSystemException;
import org.apache.geronimo.gshell.command.Command;
import org.apache.geronimo.gshell.command.CommandException;
import org.apache.geronimo.gshell.command.Variables;
import org.apache.geronimo.gshell.commandline.CommandLineExecutor;
import org.apache.geronimo.gshell.registry.AliasRegistry;
-import org.apache.geronimo.gshell.registry.CommandRegistry;
import org.apache.geronimo.gshell.registry.CommandResolver;
import org.apache.geronimo.gshell.registry.NoSuchAliasException;
import org.apache.geronimo.gshell.registry.NoSuchCommandException;
import org.apache.geronimo.gshell.spring.BeanContainer;
import org.apache.geronimo.gshell.spring.BeanContainerAware;
import org.apache.geronimo.gshell.vfs.FileSystemAccess;
-import org.apache.commons.vfs.FileObject;
-import org.apache.commons.vfs.FileSystemException;
+import org.apache.geronimo.gshell.vfs.FileObjects;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.Collection;
-import java.util.Collections;
+import javax.annotation.PostConstruct;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
/**
@@ -52,9 +52,6 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- // @Autowired
- // private CommandRegistry commandRegistry;
-
@Autowired
private AliasRegistry aliasRegistry;
@@ -66,6 +63,14 @@
private BeanContainer container;
+ private FileObject commandsDirectory;
+
+ @PostConstruct
+ public void init() throws Exception {
+ assert fileSystemAccess != null;
+ commandsDirectory = fileSystemAccess.resolveFile(null, "meta:/commands");
+ }
+
public void setBeanContainer(final BeanContainer container) {
assert container != null;
@@ -90,10 +95,8 @@
}
else {
try {
- FileObject base = fileSystemAccess.resolveFile("meta:/commands");
- assert base.exists();
-
- FileObject file = fileSystemAccess.resolveFile(base, path);
+ assert commandsDirectory != null;
+ FileObject file = fileSystemAccess.resolveFile(commandsDirectory, path);
if (file.exists()) {
command = (Command) file.getContent().getAttribute("COMMAND");
}
@@ -101,8 +104,7 @@
throw new NoSuchCommandException(path);
}
- base.close();
- file.close();
+ FileObjects.close(file);
}
catch (FileSystemException e) {
throw new CommandException(e);
@@ -147,16 +149,13 @@
List<Command> commands = new ArrayList<Command>();
try {
- FileObject base = fileSystemAccess.resolveFile("meta:/commands");
- assert base.exists();
-
- for (FileObject file : base.getChildren()) {
- Command command = (Command)file.getContent().getAttribute("COMMAND");
- commands.add(command);
+ for (FileObject file : commandsDirectory.getChildren()) {
+ // FIXME: For now ignore folders, not yet supported fully
+ if (!file.getType().hasChildren()) {
+ Command command = (Command)file.getContent().getAttribute("COMMAND");
+ commands.add(command);
+ }
}
-
- base.close();
-
}
catch (FileSystemException e) {
throw new CommandException(e);
Modified: geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml
URL: http://svn.apache.org/viewvc/geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml?rev=701946&r1=701945&r2=701946&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml (original)
+++ geronimo/gshell/trunk/gshell-wisdom/gshell-wisdom-core/src/main/resources/META-INF/spring/components.xml Sun Oct 5 22:04:03 2008
@@ -37,7 +37,7 @@
<bean id="commandMetaMapper" class="org.apache.geronimo.gshell.wisdom.registry.CommandMetaMapper"/>
- <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.registry.CommandResolverImpl"/>
+ <bean id="commandResolver" class="org.apache.geronimo.gshell.wisdom.registry.CommandResolverImpl" depends-on="metaFileProviderConfigurer"/>
<bean id="commandLineBuilder" class="org.apache.geronimo.gshell.wisdom.shell.CommandLineBuilderImpl"/>
@@ -65,7 +65,21 @@
<bean id="commandsCompleter" class="org.apache.geronimo.gshell.wisdom.completer.CommandsCompleter"/>
- <bean class="org.apache.geronimo.gshell.wisdom.meta.MetaDataInstaller"/>
+ <bean class="org.apache.geronimo.gshell.vfs.provider.meta.data.support.MetaDataInstaller">
+ <property name="contentNodes">
+ <map>
+ <entry key="/system/runtime">
+ <bean class="org.apache.geronimo.gshell.wisdom.meta.RuntimeContent"/>
+ </entry>
+ <entry key="/system/properties">
+ <bean class="org.apache.geronimo.gshell.wisdom.meta.SystemPropertiesContent"/>
+ </entry>
+ <entry key="/system/environment">
+ <bean class="org.apache.geronimo.gshell.wisdom.meta.SystemEnvironmentContent"/>
+ </entry>
+ </map>
+ </property>
+ </bean>
<bean id="pluginTemplate" class="org.apache.geronimo.gshell.wisdom.plugin.PluginImpl" abstract="true">
<property name="activationRules">