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/04 19:21:55 UTC
svn commit: r701677 -
/geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/
Author: jdillon
Date: Sat Oct 4 10:21:54 2008
New Revision: 701677
URL: http://svn.apache.org/viewvc?rev=701677&view=rev
Log:
Clean up some of the create/delete muck which isn't supported
Adding custom FileName stuff, gonna need to use these bits when configuring the registry
Added:
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.java (contents, props changed)
- copied, changed from r701651, geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java (with props)
Modified:
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.java
geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileSystem.java
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.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/MetaFileData.java?rev=701677&r1=701676&r2=701677&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileData.java Sat Oct 4 10:21:54 2008
@@ -42,7 +42,7 @@
private final FileName name;
- private FileType type = FileType.IMAGINARY;
+ private final FileType type;
private long lastModified = -1;
@@ -58,11 +58,6 @@
this.type = type;
}
-
- public MetaFileData(final FileName name) {
- this(name, FileType.IMAGINARY);
- }
-
public FileName getName() {
return name;
}
@@ -71,16 +66,6 @@
return type;
}
- //
- // TODO: Used by MetaFileObject.injectType() see if we can nuke that and this. Finalize type once that is done.
- //
-
- public void setType(final FileType type) {
- assert type != null;
-
- this.type = type;
- }
-
public void updateLastModified() {
lastModified = System.currentTimeMillis();
}
Modified: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.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/MetaFileDataRegistryImpl.java?rev=701677&r1=701676&r2=701677&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistryImpl.java Sat Oct 4 10:21:54 2008
@@ -39,10 +39,6 @@
private final Map<FileName,MetaFileData> nodes = Collections.synchronizedMap(new HashMap<FileName,MetaFileData>());
- //
- // TODO: Add some helpers to assist registration of new data.
- //
-
public void register(final FileName name, final MetaFileData data) {
assert name != null;
assert data != null;
Copied: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.java (from r701651, geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.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/MetaFileName.java?p2=geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.java&p1=geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java&r1=701651&r2=701677&rev=701677&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileDataRegistry.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.java Sat Oct 4 10:21:54 2008
@@ -20,27 +20,34 @@
package org.apache.geronimo.gshell.vfs.provider.meta;
import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.provider.AbstractFileName;
/**
- * Meta file data registry.
+ * Meta file name.
*
* @version $Rev$ $Date$
*/
-public interface MetaFileDataRegistry
+public class MetaFileName
+ extends AbstractFileName
{
- //
- // TODO: Add some helpers to assist registration of new data. Specifically register(String name, MetaFileData)
- // and maybe even registerChild(FileName parent, FileName name, MetaFileData)
- // Might also not need the child name, as data contains it already?
- //
-
- void register(FileName name, MetaFileData data);
-
- void remove(FileName name);
-
- //
- // TODO: Consider making this always return non-null, throw exception when not found, add contains(FileName)
- //
+ public static final String SCHEME = "meta";
- MetaFileData lookup(FileName name);
+ protected MetaFileName(final String scheme, final String path, final FileType type) {
+ super(scheme, path, type);
+ }
+
+ public FileName createName(final String path, final FileType type) {
+ return new MetaFileName(getScheme(), path, type);
+ }
+
+ protected void appendRootUri(final StringBuffer buffer, final boolean addPassword) {
+ assert buffer != null;
+
+ //
+ // TODO: May want to always append ":/", and make sure the path has that stuff stripped off
+ //
+
+ buffer.append(getScheme()).append(":");
+ }
}
\ 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/MetaFileName.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.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/MetaFileName.java
------------------------------------------------------------------------------
svn:mergeinfo =
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileName.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.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/MetaFileNameParser.java?rev=701677&view=auto
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java (added)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.java Sat Oct 4 10:21:54 2008
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.gshell.vfs.provider.meta;
+
+import org.apache.commons.vfs.FileName;
+import org.apache.commons.vfs.FileType;
+import org.apache.commons.vfs.FileSystemException;
+import org.apache.commons.vfs.provider.AbstractFileNameParser;
+import org.apache.commons.vfs.provider.UriParser;
+import org.apache.commons.vfs.provider.VfsComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Meta file name parser.
+ *
+ * @version $Rev$ $Date$
+ */
+public class MetaFileNameParser
+ extends AbstractFileNameParser
+{
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private final String defaultScheme;
+
+ public MetaFileNameParser(final String scheme) {
+ assert scheme != null;
+
+ this.defaultScheme = scheme;
+ }
+
+ public MetaFileNameParser() {
+ this(MetaFileName.SCHEME);
+ }
+
+ public FileName parseUri(final VfsComponentContext context, final FileName baseName, final String fileName) throws FileSystemException {
+ // context is ignored
+ // baseName could be null
+ assert fileName != null;
+
+ log.info("Parsing URI; base={}, filename={}", baseName, fileName);
+
+ if (baseName != null) {
+ //
+ // FIXME: Do something with base. Maybe need to build a filename first, then if its relative, prefix base?
+ //
+
+ throw new UnsupportedOperationException("Base prefixing is not yet supported");
+ }
+
+ StringBuffer buff = new StringBuffer();
+
+ String scheme = UriParser.extractScheme(fileName, buff);
+ if (scheme == null) {
+ scheme = defaultScheme;
+ }
+
+ UriParser.canonicalizePath(buff, 0, buff.length(), this);
+ UriParser.fixSeparators(buff);
+ FileType type = UriParser.normalisePath(buff);
+
+ log.info("Creating file name; scheme={}, path={}, type={}", new Object[] {scheme, buff, type});
+
+ //
+ // TODO: Need to make sure that we end up with something looking abs here?
+ //
+
+ FileName name = new MetaFileName(scheme, buff.toString(), type);
+
+ log.info("Created file name: {}", name);
+
+ return name;
+ }
+}
\ 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/MetaFileNameParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileNameParser.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/MetaFileNameParser.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/MetaFileObject.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/MetaFileObject.java?rev=701677&r1=701676&r2=701677&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileObject.java Sat Oct 4 10:21:54 2008
@@ -22,8 +22,6 @@
import org.apache.commons.vfs.FileName;
import org.apache.commons.vfs.FileType;
import org.apache.commons.vfs.provider.AbstractFileObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.util.Map;
@@ -47,19 +45,12 @@
this.fileSystem = fileSystem;
}
- MetaFileData getData() {
+ public MetaFileData getData() {
assert data != null;
return data;
}
- void setData(final MetaFileData data) {
- assert data != null;
-
- this.data = data;
- }
-
-
@Override
protected FileType doGetType() throws Exception {
return getData().getType();
@@ -102,20 +93,9 @@
}
@Override
- protected void doDelete() throws Exception {
- fileSystem.delete(this);
- }
-
- @Override
- protected void doCreateFolder() throws Exception {
- injectType(FileType.FOLDER);
- fileSystem.save(this);
- }
-
- @Override
protected void doAttach() throws Exception {
if (data == null) {
- fileSystem.attach(this);
+ data = fileSystem.lookupData(this);
}
}
@@ -123,16 +103,4 @@
protected void doDetach() throws Exception {
data = null;
}
-
- //
- // TODO: See where this is called and figure out if we can nuke it.
- //
-
- @Override
- protected void injectType(final FileType type) {
- assert type != null;
-
- getData().setType(type);
- super.injectType(type);
- }
}
\ 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/MetaFileProvider.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/MetaFileProvider.java?rev=701677&r1=701676&r2=701677&view=diff
==============================================================================
--- geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.java (original)
+++ geronimo/gshell/trunk/gshell-support/gshell-vfs-meta/src/main/java/org/apache/geronimo/gshell/vfs/provider/meta/MetaFileProvider.java Sat Oct 4 10:21:54 2008
@@ -45,11 +45,6 @@
public static final Collection<Capability> CAPABILITIES = Collections.unmodifiableCollection(Arrays.asList(
Capability.ATTRIBUTES,
-
- // TODO: All modification should be done via the registry, see about nuking these
- Capability.CREATE,
- Capability.DELETE,
-
Capability.GET_TYPE,
Capability.GET_LAST_MODIFIED,
Capability.LAST_MODIFIED,
@@ -60,6 +55,10 @@
@Autowired
private MetaFileDataRegistry registry;
+ public MetaFileProvider() {
+ setFileNameParser(new MetaFileNameParser());
+ }
+
public Collection getCapabilities() {
return CAPABILITIES;
}
@@ -67,10 +66,10 @@
protected FileSystem doCreateFileSystem(final FileName fileName, final FileSystemOptions options) throws FileSystemException {
assert registry != null;
- MetaFileSystem fs = new MetaFileSystem(registry, fileName, options);
+ MetaFileSystem fileSystem = new MetaFileSystem(registry, fileName, options);
- log.debug("Created file system: {}", fs);
+ log.debug("Created file system: {}", fileSystem);
- return fs;
+ return fileSystem;
}
}
\ 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=701677&r1=701676&r2=701677&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 Sat Oct 4 10:21:54 2008
@@ -42,7 +42,7 @@
{
private final Logger log = LoggerFactory.getLogger(getClass());
- private MetaFileDataRegistry registry;
+ private final MetaFileDataRegistry registry;
public MetaFileSystem(final MetaFileDataRegistry registry, final FileName rootName, final FileSystemOptions options) {
super(rootName, null, options);
@@ -84,9 +84,25 @@
// Internal bits invoked from MetaFileObject
//
- //
- // TODO: Need to remove some of this, as the files aren't created per-normal, they need to be bound in the registry
- //
+ MetaFileData 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
+ MetaFileData data = registry.lookup(name);
+ if (data == null) {
+ data = new MetaFileData(name, FileType.IMAGINARY);
+ }
+
+ return data;
+ }
+
+ /*
+ TODO: Move this stuff into the registry impl
void save(final MetaFileObject file) throws FileSystemException {
assert file != null;
@@ -111,22 +127,6 @@
file.close();
}
- void attach(final MetaFileObject file) throws FileSystemException {
- assert file != null;
-
- log.debug("Attaching: {}", file);
-
- FileName name = file.getName();
- assert name != null;
-
- MetaFileData data = registry.lookup(name);
- if (data == null) {
- data = new MetaFileData(name);
- }
-
- file.setData(data);
- }
-
void delete(final MetaFileObject file) throws FileSystemException {
assert file != null;
@@ -144,6 +144,7 @@
file.close();
}
+ */
String[] listChildren(final FileName name) throws FileSystemException {
assert name != null;