creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1462824 - in /creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles: Main.java RepositoryType.java
Date Sat, 30 Mar 2013 18:01:59 GMT
Author: rdonkin
Date: Sat Mar 30 18:01:59 2013
New Revision: 1462824

URL: http://svn.apache.org/r1462824
Log:
Push logic out into enumeration

Added:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java
  (with props)
Modified:
    creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java

Modified: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java?rev=1462824&r1=1462823&r2=1462824&view=diff
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java (original)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java Sat Mar 30
18:01:59 2013
@@ -16,6 +16,9 @@
  */
 package org.apache.creadur.tentacles;
 
+import static org.apache.creadur.tentacles.RepositoryType.HTTP;
+import static org.apache.creadur.tentacles.RepositoryType.LOCAL_FILE_SYSTEM;
+
 import java.io.File;
 import java.io.FileFilter;
 import java.io.IOException;
@@ -328,11 +331,8 @@ public class Main {
     private void prepare() throws URISyntaxException, IOException {
         final Set<File> files = new HashSet<File>();
 
-        if (this.configuration.getStagingRepositoryURI().toString()
-                .startsWith("http")) {
-            final Set<URI> resources =
-                    this.client.crawl(this.configuration
-                            .getStagingRepositoryURI());
+        if (HTTP.isRepositoryFor(this.configuration)) {
+            final Set<URI> resources = this.client.crawl(this.configuration.getStagingRepositoryURI());
 
             for (final URI uri : resources) {
                 if (!uri.getPath().matches(".*(war|jar|zip)")) {
@@ -340,10 +340,8 @@ public class Main {
                 }
                 files.add(download(uri));
             }
-        } else if (this.configuration.getStagingRepositoryURI().toString()
-                .startsWith("file:")) {
-            final File file =
-                    new File(this.configuration.getStagingRepositoryURI());
+        } else if (LOCAL_FILE_SYSTEM.isRepositoryFor(this.configuration)) {
+            final File file = new File(this.configuration.getStagingRepositoryURI());
             final List<File> collect =
                     this.fileSystem.collect(file, new FileFilter() {
                         @Override

Added: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java
URL: http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java?rev=1462824&view=auto
==============================================================================
--- creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java
(added)
+++ creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java
Sat Mar 30 18:01:59 2013
@@ -0,0 +1,40 @@
+/**
+ * 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.creadur.tentacles;
+
+import java.net.URI;
+
+public enum RepositoryType {
+
+    HTTP("http"), LOCAL_FILE_SYSTEM("file:");
+
+    private final String prefix;
+
+    private RepositoryType(final String prefix) {
+        this.prefix = prefix;
+    }
+
+    public boolean isRepositoryFor(final Configuration configuration) {
+        return isTypeOf(configuration.getStagingRepositoryURI());
+    }
+
+    public boolean isTypeOf(final URI uri) {
+        return uri.toString().startsWith(this.prefix);
+    }
+}

Propchange: creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/RepositoryType.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message