fix google java style guide issues fix all google style guide issues except the ones for variable names that have to follow '^[a-z][a-zA-Z0-9]*(_[a-zA-Z0-9]+)*$' because we need to have certain variables match windows lettering precisely.
diff --git a/src/com/google/enterprise/adaptor/fs/AclBuilder.java b/src/com/google/enterprise/adaptor/fs/AclBuilder.java index 28fa5a4..02f785d 100644 --- a/src/com/google/enterprise/adaptor/fs/AclBuilder.java +++ b/src/com/google/enterprise/adaptor/fs/AclBuilder.java
@@ -97,11 +97,11 @@ } Principal principal; - if (entry.principal() instanceof - java.nio.file.attribute.GroupPrincipal) { + if (entry.principal() + instanceof java.nio.file.attribute.GroupPrincipal) { principal = new GroupPrincipal(entry.principal().getName(), namespace); - } else if (entry.principal() instanceof - java.nio.file.attribute.UserPrincipal) { + } else if (entry.principal() + instanceof java.nio.file.attribute.UserPrincipal) { principal = new UserPrincipal(entry.principal().getName(), namespace); } else { log.log(Level.WARNING, "Unsupported Acl entry found: {0}", entry); @@ -227,8 +227,8 @@ isInheritableByAllDescendentFoldersEntry = new Predicate<Set<AclEntryFlag>>() { public boolean apply(Set<AclEntryFlag> flags) { - return flags.contains(AclEntryFlag.DIRECTORY_INHERIT) && - !flags.contains(AclEntryFlag.NO_PROPAGATE_INHERIT); + return flags.contains(AclEntryFlag.DIRECTORY_INHERIT) + && !flags.contains(AclEntryFlag.NO_PROPAGATE_INHERIT); } }; @@ -240,8 +240,8 @@ isInheritableByAllDescendentFilesEntry = new Predicate<Set<AclEntryFlag>>() { public boolean apply(Set<AclEntryFlag> flags) { - return flags.contains(AclEntryFlag.FILE_INHERIT) && - !flags.contains(AclEntryFlag.NO_PROPAGATE_INHERIT); + return flags.contains(AclEntryFlag.FILE_INHERIT) + && !flags.contains(AclEntryFlag.NO_PROPAGATE_INHERIT); } }; }
diff --git a/src/com/google/enterprise/adaptor/fs/FileDelegate.java b/src/com/google/enterprise/adaptor/fs/FileDelegate.java index 1bdd715..9723eef 100644 --- a/src/com/google/enterprise/adaptor/fs/FileDelegate.java +++ b/src/com/google/enterprise/adaptor/fs/FileDelegate.java
@@ -19,11 +19,11 @@ import java.io.IOException; import java.io.InputStream; +import java.nio.file.DirectoryStream; +import java.nio.file.Path; import java.nio.file.attribute.AclFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; -import java.nio.file.DirectoryStream; -import java.nio.file.Path; interface FileDelegate { /**
diff --git a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java index fc59c7c..d2d58f8 100644 --- a/src/com/google/enterprise/adaptor/fs/FsAdaptor.java +++ b/src/com/google/enterprise/adaptor/fs/FsAdaptor.java
@@ -25,9 +25,8 @@ import com.google.enterprise.adaptor.Config; import com.google.enterprise.adaptor.DocId; import com.google.enterprise.adaptor.DocIdPusher; -import com.google.enterprise.adaptor.DocIdPusher.Record; -import com.google.enterprise.adaptor.InvalidConfigurationException; import com.google.enterprise.adaptor.IOHelper; +import com.google.enterprise.adaptor.InvalidConfigurationException; import com.google.enterprise.adaptor.PollingIncrementalLister; import com.google.enterprise.adaptor.Principal; import com.google.enterprise.adaptor.Request; @@ -45,32 +44,24 @@ import java.nio.file.InvalidPathException; import java.nio.file.NoSuchFileException; import java.nio.file.Path; -import java.nio.file.attribute.AclFileAttributeView; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.FileTime; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Calendar; -import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.Locale; import java.util.Map; -import java.text.ParseException; import java.util.Set; -import java.text.SimpleDateFormat; -import java.util.concurrent.BlockingQueue; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; // TODO(mifern): Support\Verify that we can handle \\host\C$ shares. // TODO(mifern): Support\Verify that we can handle \\host only shares. // TODO(mifern): Decide what we want to discover within \\host only shares. - /** * Runs on Microsoft Windows and serves files from networked shares. * <p> @@ -142,8 +133,7 @@ private static final ThreadLocal<SimpleDateFormat> dateFormatter = new ThreadLocal<SimpleDateFormat>() { @Override - protected SimpleDateFormat initialValue() - { + protected SimpleDateFormat initialValue() { return new SimpleDateFormat("yyyy-MM-dd"); } }; @@ -238,8 +228,8 @@ try { rootPathDocId = delegate.newDocId(rootPath); } catch (IllegalArgumentException e) { - throw new InvalidConfigurationException("The path " + rootPath + - " is not valid path - " + e.getMessage() + "."); + throw new InvalidConfigurationException("The path " + rootPath + + " is not valid path - " + e.getMessage() + "."); } // TODO(mifern): Using a path of \\host\ns\link\FolderA will be @@ -255,9 +245,9 @@ // different from the actual DFS link path. final boolean isDfsLink = !rootPath.equals(dfsActiveStorage); if (!isDfsLink) { - throw new InvalidConfigurationException("The DFS path " + rootPath + - " is not a supported DFS path. Only DFS links of the format " + - "\\\\host\\namespace\\link are supported."); + throw new InvalidConfigurationException("The DFS path " + rootPath + + " is not a supported DFS path. Only DFS links of the format " + + "\\\\host\\namespace\\link are supported."); } } else { if (!rootPath.equals(rootPath.getRoot())) { @@ -266,9 +256,9 @@ // to the root from the configured path, so we limit configuration // only to root paths. throw new InvalidConfigurationException( - "Only root paths are supported. Use a path such as C:\\ or " + - "X:\\ or \\\\host\\share. Additionally, you can specify a " + - "DFS link path of the form \\\\host\\ns\\link."); + "Only root paths are supported. Use a path such as C:\\ or " + + "X:\\ or \\\\host\\share. Additionally, you can specify a " + + "DFS link path of the form \\\\host\\ns\\link."); } } if (!delegate.isDirectory(rootPath)) { @@ -281,9 +271,9 @@ try { delegate.newDirectoryStream(rootPath).close(); } catch (AccessDeniedException e) { - throw new IOException("Unable to list the contents of " + rootPath + - ". This can happen if the Windows account used to crawl " + - "the path does not have sufficient permissions.", e); + throw new IOException("Unable to list the contents of " + rootPath + + ". This can happen if the Windows account used to crawl " + + "the path does not have sufficient permissions.", e); } builtinPrefix = context.getConfig().getValue(CONFIG_BUILTIN_PREFIX); @@ -320,11 +310,11 @@ readShareAcls(); delegate.getAclViews(rootPath); } catch (IOException e) { - throw new IOException("Unable to read ACLs for " + rootPath + - ". This can happen if the Windows account used to crawl " + - "the path does not have sufficient permissions. A Windows " + - "account with sufficient permissions to read content, " + - "attributes and ACLs is required to crawl a path.", e); + throw new IOException("Unable to read ACLs for " + rootPath + + ". This can happen if the Windows account used to crawl " + + "the path does not have sufficient permissions. A Windows " + + "account with sufficient permissions to read content, " + + "attributes and ACLs is required to crawl a path.", e); } delegate.startMonitorPath(rootPath, context.getAsyncDocIdPusher()); @@ -356,12 +346,12 @@ } } else if (!configDate.isEmpty()) { log.log(Level.CONFIG, configDateKey + ": " + configDate); - SimpleDateFormat ISO8601DateFormat = new SimpleDateFormat("yyyy-MM-dd"); - ISO8601DateFormat.setCalendar(Calendar.getInstance()); - ISO8601DateFormat.setLenient(true); + SimpleDateFormat iso8601DateFormat = new SimpleDateFormat("yyyy-MM-dd"); + iso8601DateFormat.setCalendar(Calendar.getInstance()); + iso8601DateFormat.setLenient(true); try { return new AbsoluteFileTimeFilter(FileTime.fromMillis( - ISO8601DateFormat.parse(configDate).getTime())); + iso8601DateFormat.parse(configDate).getTime())); } catch (ParseException e) { throw new InvalidConfigurationException(configDateKey + " must be specified in the format \"YYYY-MM-DD\".", e); @@ -392,8 +382,8 @@ // Push the Acl for the active storage UNC path. Path activeStorage = delegate.getDfsUncActiveStorageUnc(rootPath); if (activeStorage == null) { - throw new IOException("The DFS path " + rootPath + - " does not have an active storage."); + throw new IOException("The DFS path " + rootPath + + " does not have an active storage."); } builder = new AclBuilder(activeStorage, @@ -443,12 +433,12 @@ // collisions with the root docid. ShareAcls shareAcls = readShareAcls(); Map<DocId, Acl> namedResources = new HashMap<DocId, Acl>(); - if ((shareAcls.dfsShareAcl != null) && (forcePush || - !shareAcls.dfsShareAcl.equals(lastPushedShareAcls.dfsShareAcl))) { + if ((shareAcls.dfsShareAcl != null) && (forcePush + || !shareAcls.dfsShareAcl.equals(lastPushedShareAcls.dfsShareAcl))) { namedResources.put(DFS_SHARE_ACL_DOCID, shareAcls.dfsShareAcl); } - if ((shareAcls.shareAcl != null) && (forcePush || - !shareAcls.shareAcl.equals(lastPushedShareAcls.shareAcl))) { + if ((shareAcls.shareAcl != null) && (forcePush + || !shareAcls.shareAcl.equals(lastPushedShareAcls.shareAcl))) { namedResources.put(SHARE_ACL_DOCID, shareAcls.shareAcl); } if (namedResources.size() > 0) {
diff --git a/src/com/google/enterprise/adaptor/fs/HtmlResponseWriter.java b/src/com/google/enterprise/adaptor/fs/HtmlResponseWriter.java index e0d50f3..03db890 100644 --- a/src/com/google/enterprise/adaptor/fs/HtmlResponseWriter.java +++ b/src/com/google/enterprise/adaptor/fs/HtmlResponseWriter.java
@@ -26,7 +26,6 @@ import java.net.URISyntaxException; import java.text.MessageFormat; import java.util.Locale; -import java.util.logging.Level; import java.util.logging.Logger; class HtmlResponseWriter implements Closeable {
diff --git a/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java b/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java index 84ab250..5ec6da1 100644 --- a/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java +++ b/src/com/google/enterprise/adaptor/fs/NioFileDelegate.java
@@ -19,15 +19,13 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.nio.file.attribute.AclFileAttributeView; -import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.FileTime; import java.nio.file.DirectoryStream; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.concurrent.BlockingQueue; +import java.nio.file.attribute.BasicFileAttributes; +import java.nio.file.attribute.FileTime; /** * A {@link FileDelegate} implementation on top of Java NIO.
diff --git a/src/com/google/enterprise/adaptor/fs/SimpleAclFileAttributeView.java b/src/com/google/enterprise/adaptor/fs/SimpleAclFileAttributeView.java index 5c42aa0..0082228 100644 --- a/src/com/google/enterprise/adaptor/fs/SimpleAclFileAttributeView.java +++ b/src/com/google/enterprise/adaptor/fs/SimpleAclFileAttributeView.java
@@ -16,7 +16,6 @@ import com.google.common.collect.ImmutableList; -import java.io.IOException; import java.nio.file.attribute.AclEntry; import java.nio.file.attribute.AclFileAttributeView; import java.nio.file.attribute.UserPrincipal;
diff --git a/src/com/google/enterprise/adaptor/fs/WindowsAclFileAttributeViews.java b/src/com/google/enterprise/adaptor/fs/WindowsAclFileAttributeViews.java index 90c3b06..66cf25e 100644 --- a/src/com/google/enterprise/adaptor/fs/WindowsAclFileAttributeViews.java +++ b/src/com/google/enterprise/adaptor/fs/WindowsAclFileAttributeViews.java
@@ -15,7 +15,6 @@ package com.google.enterprise.adaptor.fs; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Strings; import com.google.common.collect.ImmutableList; import com.google.common.collect.Sets; import com.google.enterprise.adaptor.fs.WinApi.Netapi32Ex; @@ -149,7 +148,7 @@ /** Constructor used for production. */ public WindowsAclFileAttributeViews() { this(Advapi32.INSTANCE, Kernel32.INSTANCE, Mpr.INSTANCE, - Netapi32Ex.INSTANCE,Shlwapi.INSTANCE); + Netapi32Ex.INSTANCE, Shlwapi.INSTANCE); } /** Constructor used by the tests. */ @@ -173,9 +172,9 @@ public AclFileAttributeViews getAclViews(Path path) throws IOException { String pathname = path.toRealPath(LinkOption.NOFOLLOW_LINKS).toString(); WinNT.ACCESS_ACEStructure[] aces = getFileSecurity(pathname, - WinNT.DACL_SECURITY_INFORMATION | - WinNT.PROTECTED_DACL_SECURITY_INFORMATION | - WinNT.UNPROTECTED_DACL_SECURITY_INFORMATION); + WinNT.DACL_SECURITY_INFORMATION + | WinNT.PROTECTED_DACL_SECURITY_INFORMATION + | WinNT.UNPROTECTED_DACL_SECURITY_INFORMATION); ImmutableList.Builder<AclEntry> inherited = ImmutableList.builder(); ImmutableList.Builder<AclEntry> direct = ImmutableList.builder(); @@ -231,8 +230,8 @@ Mpr.UNIVERSAL_NAME_INFO_LEVEL, buf, bufSize); } if (result != WinNT.NO_ERROR) { - throw new IOException("Unable to get UNC path for the mapped path " + - path + ". Result: " + result); + throw new IOException("Unable to get UNC path for the mapped path " + + path + ". Result: " + result); } Mpr.UNIVERSAL_NAME_INFO info = new Mpr.UNIVERSAL_NAME_INFO(buf); @@ -281,8 +280,8 @@ } else if (result == LMErr.NERR_NetNameNotFound) { throw new IOException("The share name does not exist."); } else { - throw new IOException("Unable to the read share Acl. Error: " + - result); + throw new IOException("Unable to the read share Acl. Error: " + + result); } } @@ -339,8 +338,8 @@ throw e; } } - String accountName = (account.domain == null ? - account.name : account.domain + "\\" + account.name); + String accountName = (account.domain == null) + ? account.name : account.domain + "\\" + account.name; UserPrincipal aclPrincipal; String accountType = getSidTypeString(account.accountType); if (USER_SID_TYPES.contains(account.accountType)) {
diff --git a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java index cf1ded4..45632ae 100644 --- a/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java +++ b/src/com/google/enterprise/adaptor/fs/WindowsFileDelegate.java
@@ -21,21 +21,14 @@ import com.google.enterprise.adaptor.DocId; import com.google.enterprise.adaptor.DocIdPusher; import com.google.enterprise.adaptor.fs.WinApi.Netapi32Ex; -import com.google.enterprise.adaptor.fs.WinApi.Shlwapi; -import com.sun.jna.Memory; import com.sun.jna.Native; import com.sun.jna.Pointer; -import com.sun.jna.Structure; -import com.sun.jna.WString; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.LMErr; import com.sun.jna.platform.win32.W32Errors; import com.sun.jna.platform.win32.Win32Exception; import com.sun.jna.platform.win32.WinBase; -import com.sun.jna.platform.win32.WinDef.DWORD; -import com.sun.jna.platform.win32.WinDef.ULONG; -import com.sun.jna.platform.win32.WinError; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.platform.win32.WinNT.FILE_NOTIFY_INFORMATION; import com.sun.jna.platform.win32.WinNT.HANDLE; @@ -45,13 +38,12 @@ import java.io.File; import java.io.IOException; -import java.nio.file.attribute.AclEntry; -import java.nio.file.attribute.AclFileAttributeView; import java.nio.file.Files; import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; +import java.nio.file.attribute.AclEntry; +import java.nio.file.attribute.AclFileAttributeView; import java.util.List; import java.util.concurrent.CountDownLatch; import java.util.logging.Level; @@ -96,9 +88,9 @@ PointerByReference sd = new PointerByReference(); IntByReference sdSize = new IntByReference(); int rc = netapi32.NetDfsGetSecurity(doc.toString(), - WinNT.DACL_SECURITY_INFORMATION | - WinNT.PROTECTED_DACL_SECURITY_INFORMATION | - WinNT.UNPROTECTED_DACL_SECURITY_INFORMATION, + WinNT.DACL_SECURITY_INFORMATION + | WinNT.PROTECTED_DACL_SECURITY_INFORMATION + | WinNT.UNPROTECTED_DACL_SECURITY_INFORMATION, sd, sdSize); if (LMErr.NERR_Success != rc) { throw new Win32Exception(rc); @@ -151,8 +143,8 @@ ace = new WinNT.ACCESS_DENIED_ACE(share); break; default: - throw new IllegalArgumentException("Unsupported ACE type " + - aceType); + throw new IllegalArgumentException("Unsupported ACE type " + + aceType); } ACEs[i] = ace; offset += ace.AceSize; @@ -211,8 +203,8 @@ } } if (storageUnc == null) { - throw new IOException("The DFS path " + doc + - " does not have an active storage."); + throw new IOException("The DFS path " + doc + + " does not have an active storage."); } return Paths.get(storageUnc); @@ -324,8 +316,8 @@ } private void runMonitorLoop() throws IOException { - int mask = Kernel32.FILE_SHARE_READ | Kernel32.FILE_SHARE_WRITE | - Kernel32.FILE_SHARE_DELETE; + int mask = Kernel32.FILE_SHARE_READ | Kernel32.FILE_SHARE_WRITE + | Kernel32.FILE_SHARE_DELETE; HANDLE handle = kernel32.CreateFile(watchPath.toString(), Kernel32.FILE_LIST_DIRECTORY, mask, null, Kernel32.OPEN_EXISTING, Kernel32.FILE_FLAG_BACKUP_SEMANTICS | Kernel32.FILE_FLAG_OVERLAPPED, @@ -351,12 +343,12 @@ Kernel32.OVERLAPPED ol = new Kernel32.OVERLAPPED(); final FILE_NOTIFY_INFORMATION info = new FILE_NOTIFY_INFORMATION(4096); - int notifyFilter = Kernel32.FILE_NOTIFY_CHANGE_SECURITY | - Kernel32.FILE_NOTIFY_CHANGE_CREATION | - Kernel32.FILE_NOTIFY_CHANGE_LAST_WRITE | - Kernel32.FILE_NOTIFY_CHANGE_ATTRIBUTES | - Kernel32.FILE_NOTIFY_CHANGE_DIR_NAME | - Kernel32.FILE_NOTIFY_CHANGE_FILE_NAME; + int notifyFilter = Kernel32.FILE_NOTIFY_CHANGE_SECURITY + | Kernel32.FILE_NOTIFY_CHANGE_CREATION + | Kernel32.FILE_NOTIFY_CHANGE_LAST_WRITE + | Kernel32.FILE_NOTIFY_CHANGE_ATTRIBUTES + | Kernel32.FILE_NOTIFY_CHANGE_DIR_NAME + | Kernel32.FILE_NOTIFY_CHANGE_FILE_NAME; Kernel32.OVERLAPPED_COMPLETION_ROUTINE changesCallback = new Kernel32.OVERLAPPED_COMPLETION_ROUTINE() { @@ -376,8 +368,8 @@ // a notification buffer overflows which can cause some // notifications to be lost. log.log(Level.INFO, - "There was a buffer overflow during file monitoring. " + - "Some file update notifications may have been lost."); + "There was a buffer overflow during file monitoring. " + + "Some file update notifications may have been lost."); } else { log.log(Level.WARNING, "Unable to read data notification data. errorCode: {0}", @@ -404,8 +396,8 @@ if (waitResult == Kernel32Ex.WAIT_IO_COMPLETION) { log.log(Level.FINEST, - "WaitForSingleObjectEx returned WAIT_IO_COMPLETION. " + - "A notification was sent to the monitor callback."); + "WaitForSingleObjectEx returned WAIT_IO_COMPLETION. " + + "A notification was sent to the monitor callback."); continue; } else if (waitResult == WinBase.WAIT_OBJECT_0) { log.log(Level.FINE, @@ -413,8 +405,8 @@ return; } else { throw new IOException( - "Unexpected result from WaitForSingleObjectEx: " + waitResult + - ". GetLastError: " + kernel32.GetLastError()); + "Unexpected result from WaitForSingleObjectEx: " + waitResult + + ". GetLastError: " + kernel32.GetLastError()); } } } @@ -469,8 +461,8 @@ "Skipping {0}. It is not a regular file or directory.", doc); } } catch (IOException e) { - log.log(Level.WARNING, "Unable to push the path " + doc + - " to the GSA.", e); + log.log(Level.WARNING, "Unable to push the path " + doc + + " to the GSA.", e); } } }