Author: rdonkin
Date: Sun Mar 31 09:33:01 2013
New Revision: 1462905
URL: http://svn.apache.org/r1462905
Log:
Enumerate licenses
Added:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
(with props)
Modified:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/Main.java
Added:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
URL:
http://svn.apache.org/viewvc/creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java?rev=1462905&view=auto
==============================================================================
---
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
(added)
+++
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
Sun Mar 31 09:33:01 2013
@@ -0,0 +1,64 @@
+/**
+ * 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.io.IOException;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public enum LicenseType {
+
+ ASL_2_0("asl-2.0"), CPL_1_0("cpl-1.0"), CDDL_1_0("cddl-1.0");
+
+ public static Map<String, String> loadLicensesFrom(
+ final TentaclesResources tentaclesResources) throws IOException {
+ final Map<String, String> licenses =
+ new ConcurrentHashMap<String, String>();
+ for (final LicenseType type : LicenseType.values()) {
+ type.putTextInto(licenses, tentaclesResources);
+ }
+ return licenses;
+ }
+
+ private final String resourceName;
+ private final String resourcePath;
+
+ private LicenseType(final String resourceName) {
+ this.resourceName = resourceName;
+ this.resourcePath = "licenses/" + getResourceName() + ".txt";
+ }
+
+ public String getResourceName() {
+ return this.resourceName;
+ }
+
+ public String getResourcePath() {
+ return this.resourcePath;
+ }
+
+ public String readText(final TentaclesResources tentaclesResources)
+ throws IOException {
+ return tentaclesResources.readText(getResourcePath()).trim();
+ }
+
+ public void putTextInto(final Map<String, String> licenseTextByName,
+ final TentaclesResources tentaclesResources) throws IOException {
+ licenseTextByName.put(getResourceName(), readText(tentaclesResources));
+ }
+}
Propchange:
creadur/tentacles/trunk/src/main/java/org/apache/creadur/tentacles/LicenseType.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1462905&r1=1462904&r2=1462905&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
Sun Mar 31 09:33:01 2013
@@ -16,6 +16,7 @@
*/
package org.apache.creadur.tentacles;
+import static org.apache.creadur.tentacles.LicenseType.loadLicensesFrom;
import static org.apache.creadur.tentacles.RepositoryType.HTTP;
import static org.apache.creadur.tentacles.RepositoryType.LOCAL_FILE_SYSTEM;
@@ -60,7 +61,7 @@ public class Main {
private final File repository;
private final File content;
private final Reports reports;
- private final Map<String, String> licenses = new HashMap<String, String>();
+ private final Map<String, String> licenses;
private final NexusClient client;
private final Configuration configuration;
@@ -109,14 +110,7 @@ public class Main {
this.tentaclesResources.copyTo("legal/style.css", new File(this.local,
"style.css"));
- licenses("asl-2.0");
- licenses("cpl-1.0");
- licenses("cddl-1.0");
- }
-
- private void licenses(final String name) throws IOException {
- final String path = "licenses/" + name + ".txt";
- this.licenses.put(name, this.tentaclesResources.readText(path).trim());
+ this.licenses = loadLicensesFrom(this.tentaclesResources);
}
public static void main(final String[] args) throws Exception {