Sam Adams avatar Sam Adams committed 7df21c5

Fixed lots of checkstyle violations

Comments (0)

Files changed (15)

client-cli/src/checkstyle/suppressions.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suppressions PUBLIC
+        "-//Puppy Crawl//DTD Suppressions 1.1//EN"
+        "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
+<suppressions>
+    <suppress files="src/main/.*\.java$" checks="Regexp" />
+    <suppress files="src/main/.*\.java$" checks="VisibilityModifier" />
+</suppressions>

client-cli/src/main/java/net/chempound/client/cli/ChempoundClientCLI.java

 
 import com.beust.jcommander.JCommander;
 import com.beust.jcommander.ParameterException;
-import net.chempound.client.cli.command.*;
+import net.chempound.client.cli.command.Command;
+import net.chempound.client.cli.command.CreateCollectionCommand;
+import net.chempound.client.cli.command.DepositCommand;
 import net.chempound.client.cli.options.GlobalOptions;
 import net.chempound.client.cli.types.URIConverter;
 
-import java.util.Formatter;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
     private static final String C_HELP = "help";
     private static final String C_MOVE = "move";
 
-    private Map<String,Command> commands = new LinkedHashMap<String, Command>();
+    private final Map<String,Command> commands = new LinkedHashMap<String, Command>();
 
-    final GlobalOptions globalOptions = new GlobalOptions();
+    protected final GlobalOptions globalOptions = new GlobalOptions();
 
-    final JCommander jCommander;
+    protected final JCommander jCommander;
 
     public static void main(final String[] args) {
         final ChempoundClientCLI depositCli = new ChempoundClientCLI();
             if (command != null) {
                 invokeCommand(command);
             } else {
-                throw new UnsupportedOperationException("Unsupported command: "+jCommander.getParsedCommand());
+                throw new UnsupportedOperationException("Unsupported command: " + jCommander.getParsedCommand());
             }
         }
     }
 //        addCommand(jCommander, C_MOVE, new MoveCommand());
     }
 
-    protected void addCommand(final JCommander jCommander, final String alias, Command<?> command) {
+    protected void addCommand(final JCommander jCommander, final String alias, final Command<?> command) {
         commands.put(alias, command);
         jCommander.addCommand(alias, command.getOptions());
     }
 
         final int maxLen = getMaxCommandLength();
         for (final String command : jCommander.getCommands().keySet()) {
-            System.out.printf(" %-"+maxLen+"s   %s%n", command, jCommander.getCommandDescription(command));
+            System.out.printf(" %-" + maxLen + "s   %s%n", command, jCommander.getCommandDescription(command));
         }
 
         System.out.println();

client-cli/src/main/java/net/chempound/client/cli/command/DepositCommand.java

 import net.chempound.storage.LocalFileResource;
 import net.chempound.storage.LocalResource;
 import org.apache.commons.io.FilenameUtils;
-import org.swordapp.client.Deposit;
-import org.swordapp.client.SWORDClient;
 
 import java.io.File;
 import java.net.URI;

client-cli/src/main/java/net/chempound/client/cli/options/CopyOptions.java

  */
 public class CopyOptions {
 
-    @Parameter(names = {"-s", "--source"}, required = true)
+    @Parameter(names = { "-s", "--source" }, required = true)
     public String source;
 
-    @Parameter(names = {"-t", "--target"}, required = true)
+    @Parameter(names = { "-t", "--target" }, required = true)
     public String target;
 
 }

client-cli/src/main/java/net/chempound/client/cli/options/CreateCollectionOptions.java

  */
 public class CreateCollectionOptions {
 
-    @Parameter(names = {"-s", "--slug"})
+    @Parameter(names = { "-s", "--slug" })
     public String slug;
 
-    @Parameter(names = {"-d", "--description"})
+    @Parameter(names = { "-d", "--description" })
     public String description;
 
-    @Parameter(names = {"-a", "--accepts"})
+    @Parameter(names = { "-a", "--accepts" })
     public List<String> accepts;
 
     @Parameter(description = "The title", arity = 1)

client-cli/src/main/java/net/chempound/client/cli/options/DepositOptions.java

 
 public class DepositOptions {
 
-    @Parameter(names = {"-s", "--slug"})
+    @Parameter(names = { "-s", "--slug" })
     public String slug;
 
-    @Parameter(names = {"-t", "--title"}, description = "Title")
+    @Parameter(names = { "-t", "--title" }, description = "Title")
     public String title;
 
     @Parameter(description = "The list of files")

client-cli/src/main/java/net/chempound/client/cli/options/GlobalOptions.java

 
 public class GlobalOptions {
 
-    @Parameter(names = {"-q", "--quiet"}, description = "enable additional output")
+    @Parameter(names = { "-q", "--quiet" }, description = "enable additional output")
     public boolean quiet;
 
-    @Parameter(names = {"-v", "--verbose"}, description = "enable additional output")
+    @Parameter(names = { "-v", "--verbose" }, description = "enable additional output")
     public boolean verbose;
 
-    @Parameter(names = {"--version"}, description = "output version information and exit")
+    @Parameter(names = { "--version" }, description = "output version information and exit")
     public boolean version;
 
-    @Parameter(names = {"-h", "--help"}, description = "display help and exit")
+    @Parameter(names = { "-h", "--help" }, description = "display help and exit")
     public boolean help;
 
-    @Parameter(names = {"-R", "--repository"}, description = "target repository")
+    @Parameter(names = { "-R", "--repository" }, description = "target repository")
     public String repository;
 
-    @Parameter(names = {"--cwd"}, description = "change working directory")
+    @Parameter(names = { "--cwd" }, description = "change working directory")
     public File workingDirectory;
 
 }

client-cli/src/main/java/net/chempound/client/cli/types/PersonConverter.java

 
     }
 
-}
+}

client-utils/src/main/java/net/chempound/client/AttachmentBodyPart.java

         this.name = name;
         this.md5 = md5;
 
-        Header header = new Header();
+        final Header header = new Header();
         setHeader(header);
         setBody(body);
 
     }
 
     protected void generateContentDisp(final ContentBody body) {
-        StringBuilder buffer = new StringBuilder();
+        final StringBuilder buffer = new StringBuilder();
         buffer.append("form-data; name=\"");
         buffer.append(getName());
         buffer.append("\"");
 
     protected void generateContentType(final ContentDescriptor desc) {
         if (desc.getMimeType() != null) {
-            StringBuilder buffer = new StringBuilder();
+            final StringBuilder buffer = new StringBuilder();
             buffer.append(desc.getMimeType());
             if (desc.getCharset() != null) {
                 buffer.append("; charset=");

client-utils/src/main/java/net/chempound/client/DepositBuilder.java

 
     private DepositRequest depositRequest = new DefaultDepositRequest();
 
-    public void setTitle(String title) {
+    public void setTitle(final String title) {
         depositRequest.setTitle(title);
     }
 
-    public void setSlug(String slug) {
+    public void setSlug(final String slug) {
         depositRequest.setSlug(slug);
     }
 

client-utils/src/main/java/net/chempound/client/MinimalField.java

 
     @Override
     public String toString() {
-        StringBuilder buffer = new StringBuilder();
+        final StringBuilder buffer = new StringBuilder();
         buffer.append(this.name);
         buffer.append(": ");
         buffer.append(this.value);

client-utils/src/main/java/net/chempound/client/MultipartRelatedEntity.java

     private volatile boolean dirty; // used to decide whether to recalculate length
 
     public MultipartRelatedEntity(
-            HttpMultipartMode mode,
+            final HttpMultipartMode mode,
             final String boundary,
             final Charset charset) {
         super();
         this.dirty = true;
 
         this.message = new Message();
-        org.apache.james.mime4j.message.Header header =
+        final org.apache.james.mime4j.message.Header header =
           new org.apache.james.mime4j.message.Header();
         this.message.setHeader(header);
         this.multipart.setParent(message);
-        if (mode == null) {
-            mode = HttpMultipartMode.STRICT;
-        }
-        this.multipart.setMode(mode);
+        this.multipart.setMode(mode == null ? HttpMultipartMode.STRICT : mode);
         this.message.getHeader().addField(Fields.contentType(this.contentType.getValue()));
     }
 
     protected String generateContentType(
             final String boundary,
             final Charset charset) {
-        StringBuilder buffer = new StringBuilder();
+        final StringBuilder buffer = new StringBuilder();
         buffer.append("multipart/related; boundary=");
         if (boundary != null) {
             buffer.append(boundary);
         } else {
-            Random rand = new Random();
-            int count = rand.nextInt(11) + 30; // a random size from 30 to 40
+            final Random rand = new Random();
+            final int count = rand.nextInt(11) + 30; // a random size from 30 to 40
             for (int i = 0; i < count; i++) {
                 buffer.append(MULTIPART_CHARS[rand.nextInt(MULTIPART_CHARS.length)]);
             }
     }
 
     public boolean isRepeatable() {
-        List<?> parts = this.multipart.getBodyParts();
-        for (Iterator<?> it = parts.iterator(); it.hasNext(); ) {
-            AttachmentBodyPart part = (AttachmentBodyPart) it.next();
-            ContentBody body = (ContentBody) part.getBody();
+        final List<?> parts = this.multipart.getBodyParts();
+        for (final Iterator<?> it = parts.iterator(); it.hasNext();) {
+            final AttachmentBodyPart part = (AttachmentBodyPart) it.next();
+            final ContentBody body = (ContentBody) part.getBody();
             if (body.getContentLength() < 0) {
                 return false;
             }
         return null;
     }
 
-    public void consumeContent()
-        throws IOException, UnsupportedOperationException{
+    public void consumeContent() {
         if (isStreaming()) {
             throw new UnsupportedOperationException(
                     "Streaming entity does not implement #consumeContent()");
         }
     }
 
-    public InputStream getContent() throws IOException, UnsupportedOperationException {
+    public InputStream getContent() {
         throw new UnsupportedOperationException(
                     "Multipart related entity does not implement #getContent()");
     }

client-utils/src/main/java/net/chempound/client/SwordClient.java

 import net.chempound.storage.LocalResource;
 import net.sf.atomxom.AtomBuilder;
 import nu.xom.*;
-import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.http.HttpEntityEnclosingRequest;
 import org.apache.http.HttpResponse;
                 final Document doc = readHtml(response);
                 return findServiceDocumentUrl(doc);
             } else {
-                throw new RuntimeException("Error loading repository page: "+response.getStatusLine());
+                throw new RuntimeException("Error loading repository page: " + response.getStatusLine());
             }
         } finally {
             closeQuietly(response);
             if (SC_OK == response.getStatusLine().getStatusCode()) {
                 return getServiceDocument(discoveryEnabled, response);
             } else {
-                throw new RuntimeException("Error loading repository page: "+response.getStatusLine());
+                throw new RuntimeException("Error loading repository page: " + response.getStatusLine());
             }
         } finally {
             closeQuietly(response);

client-utils/src/main/java/net/chempound/client/sword/SwordCollection.java

 
     public static Element createElementInContext(final Element context, final String localName, final String namespace, final String defaultPrefix) {
         final String prefix = getNamespacePrefix(context, namespace, defaultPrefix);
-        return new Element((prefix == null ? localName : prefix+':'+localName), namespace);
+        return new Element((prefix == null ? localName : prefix + ':' + localName), namespace);
     }
 
     public static String getNamespacePrefix(final Element context, final String namespace, final String defaultPrefix) {
         Element current = context;
         while (current != null) {
-            for (int i = current.getNamespaceDeclarationCount()-1; i >= 0; i--) {
+            for (int i = current.getNamespaceDeclarationCount() - 1; i >= 0; i--) {
                 final String prefix = current.getNamespacePrefix(i);
                 if (context.getNamespaceURI(prefix).equals(namespace)) {
                     return prefix;

client-utils/src/main/java/net/chempound/client/sword/SwordService.java

 
 import nu.xom.Element;
 import nu.xom.Elements;
-import nu.xom.Serializer;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
 import static net.chempound.client.atom.AtomPub.ATOMPUB_NAMESPACE;
 import static net.chempound.client.atom.AtomPub.WORKSPACE;
-import static net.chempound.client.sword.Sword.MAX_UPLOAD_SIZE;
-import static net.chempound.client.sword.Sword.SWORD_NAMESPACE;
-import static net.chempound.client.sword.Sword.VERSION;
+import static net.chempound.client.sword.Sword.*;
 
 /**
  * @author Sam Adams
         return list;
     }
 
-    public void debug() {
-        Serializer ser = new Serializer(System.out);
-        ser.setIndent(2);
-        try {
-            ser.write(service.getDocument());
-        } catch (IOException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
-        }
-    }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.