Initial changes for Linux support
Adding LinuxFileDlegate and support in FsAdaptor to load the Linux version of
the delegate.
diff --git a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
index 60343f9..f00d3a9 100644
--- a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
+++ b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
@@ -179,12 +179,15 @@
private FileTimeFilter lastAccessTimeFilter;
public FsAdaptor() {
- // At the moment, we only support Windows.
- if (System.getProperty("os.name").startsWith("Windows")) {
+ String osName = System.getProperty("os.name");
+ if (osName.startsWith("Windows")) {
delegate = new WindowsFileDelegate();
+ } else if (osName.startsWith("Linux")) {
+ delegate = new LinuxFileDelegate();
} else {
throw new IllegalStateException(
- "Windows is the only supported platform.");
+ "This is a non-supported platform. The Connector for File Systems"
+ + " only supports the Windows and Linux platforms.");
}
}
@@ -259,7 +262,11 @@
" is not a supported DFS path. Only DFS links of the format " +
"\\\\host\\namespace\\link are supported.");
}
- } else {
+ // TODO: Skip the "is root" check on Linux for now. We need to determine
+ // an approach at verifying that the src path is the mount point of the
+ // UNC path and that the UNC path is a root UNC (i.e. of the form
+ // \\host\share).
+ } else if (System.getProperty("os.name").startsWith("Windows")) {
if (!rootPath.equals(rootPath.getRoot())) {
// We currently only support a config path that is a root.
// Non-root paths will fail to produce Acls for all the folders up
diff --git a/src/com/google/enterprise/adaptor/fs/LinuxFileDelegate.java b/src/com/google/enterprise/adaptor/fs/LinuxFileDelegate.java
new file mode 100644
index 0000000..b889c1d
--- /dev/null
+++ b/src/com/google/enterprise/adaptor/fs/LinuxFileDelegate.java
@@ -0,0 +1,75 @@
+// Copyright 2014 Google Inc. All Rights Reserved.
+//
+// Licensed 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 com.google.enterprise.adaptor.fs;
+
+import com.google.enterprise.adaptor.AsyncDocIdPusher;
+import com.google.enterprise.adaptor.DocId;
+
+import java.io.IOException;
+import java.nio.file.attribute.AclEntry;
+import java.nio.file.attribute.AclFileAttributeView;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collections;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+class LinuxFileDelegate extends NioFileDelegate {
+ private static final Logger log
+ = Logger.getLogger(LinuxFileDelegate.class.getName());
+
+ @Override
+ public AclFileAttributeViews getAclViews(Path doc) throws IOException {
+ // TODO(mifern): Add Acl support.
+ return new AclFileAttributeViews(
+ new SimpleAclFileAttributeView(Collections.<AclEntry>emptyList()),
+ new SimpleAclFileAttributeView(Collections.<AclEntry>emptyList()));
+ }
+
+ @Override
+ public AclFileAttributeView getShareAclView(Path doc) throws IOException {
+ // TODO(mifern): Add share Acl support.
+ return new SimpleAclFileAttributeView(Collections.<AclEntry>emptyList());
+ }
+
+ @Override
+ public AclFileAttributeView getDfsShareAclView(Path doc) {
+ // TODO(mifern): Add DFS support.
+ return new SimpleAclFileAttributeView(Collections.<AclEntry>emptyList());
+ }
+
+ @Override
+ public Path getDfsUncActiveStorageUnc(Path doc) throws IOException {
+ // TODO(mifern): Add DFS support.
+ return null;
+ }
+
+ @Override
+ public void startMonitorPath(Path watchPath, AsyncDocIdPusher pusher)
+ throws IOException {
+ // TODO(mifern): Start monitoring.
+ }
+
+ @Override
+ public void stopMonitorPath() {
+ // TODO(mifern): Not sure what monitoring we will have but we need
+ // to stop it.
+ }
+
+ @Override
+ public void destroy() {
+ // TODO(mifern): Destroy any resrouces created for monitoring.
+ }
+}