You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by se...@apache.org on 2012/01/24 16:10:21 UTC

svn commit: r1235292 - in /incubator/openmeetings/trunk/singlewebapp/src/src_tool: ./ org/ org/openmeetings/ org/openmeetings/srctool/ org/openmeetings/srctool/AsfCopyRightReplace.java

Author: sebawagner
Date: Tue Jan 24 15:10:20 2012
New Revision: 1235292

URL: http://svn.apache.org/viewvc?rev=1235292&view=rev
Log:
Small Update License Header Class for ASF files

Added:
    incubator/openmeetings/trunk/singlewebapp/src/src_tool/
    incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/
    incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/
    incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/
    incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java   (with props)

Added: incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java
URL: http://svn.apache.org/viewvc/incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java?rev=1235292&view=auto
==============================================================================
--- incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java (added)
+++ incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java Tue Jan 24 15:10:20 2012
@@ -0,0 +1,193 @@
+/*
+ * 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.openmeetings.srctool;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.FilenameFilter;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.StringWriter;
+
+public class AsfCopyRightReplace {
+
+	String asf_copyright = "/*\n"
+			+ " * Licensed to the Apache Software Foundation (ASF) under one\n"
+			+ " * or more contributor license agreements.  See the NOTICE file\n"
+			+ " * distributed with this work for additional information\n"
+			+ " * regarding copyright ownership.  The ASF licenses this file\n"
+			+ " * to you under the Apache License, Version 2.0 (the\n"
+			+ " * \"License\") +  you may not use this file except in compliance\n"
+			+ " * with the License.  You may obtain a copy of the License at\n"
+			+ " *\n"
+			+ " *   http://www.apache.org/licenses/LICENSE-2.0\n"
+			+ " *\n"
+			+ " * Unless required by applicable law or agreed to in writing,\n"
+			+ " * software distributed under the License is distributed on an\n"
+			+ " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+			+ " * KIND, either express or implied.  See the License for the\n"
+			+ " * specific language governing permissions and limitations\n"
+			+ " * under the License.\n" + " */\n";
+
+	String asf_xml_copyright = "<!--\n"
+			+ "  Licensed to the Apache Software Foundation (ASF) under one\n"
+			+ "  or more contributor license agreements.  See the NOTICE file\n"
+			+ "  distributed with this work for additional information\n"
+			+ "  regarding copyright ownership.  The ASF licenses this file\n"
+			+ "  to you under the Apache License, Version 2.0 (the\n"
+			+ "  \"License\"); you may not use this file except in compliance\n"
+			+ "  with the License.  You may obtain a copy of the License at\n"
+			+ "  \n" + "      http://www.apache.org/licenses/LICENSE-2.0\n"
+			+ "    	  \n"
+			+ "  Unless required by applicable law or agreed to in writing,\n"
+			+ "  software distributed under the License is distributed on an\n"
+			+ "  \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n"
+			+ "  KIND, either express or implied.  See the License for the\n"
+			+ "  specific language governing permissions and limitations\n"
+			+ "  under the License.\n" + "  \n" + "-->\n";
+
+	public static void main(String... args) {
+		new AsfCopyRightReplace();
+	}
+
+	public AsfCopyRightReplace() {
+		// scanFolder(new File("./src"));
+		// scanFolder(new File("./WebContent/languages/"));
+		// scanFolder(new File("./WebContent/src/"));
+		scanFolder(new File("./WebContent/WEB-INF/"));
+	}
+
+	private void scanFolder(File folder) {
+
+		for (File javaFile : folder.listFiles(new FilenameFilter() {
+			public boolean accept(File b, String name) {
+				return name.endsWith(".java");
+			}
+		})) {
+			scanAndWriteJavaFile(javaFile);
+		}
+
+		for (File javaFile : folder.listFiles(new FilenameFilter() {
+			public boolean accept(File b, String name) {
+				return name.endsWith(".xml") || name.endsWith(".lzx");
+			}
+		})) {
+			scanAndWriteXMLFile(javaFile);
+		}
+
+		for (File folderFile : folder.listFiles(new FilenameFilter() {
+			public boolean accept(File b, String name) {
+				String absPath = b.getAbsolutePath() + File.separatorChar
+						+ name;
+				File f = new File(absPath);
+				return f.isDirectory();
+			}
+		})) {
+			scanFolder(folderFile);
+		}
+	}
+
+	private void scanAndWriteXMLFile(File javaFile) {
+		try {
+			System.err.println(" " + javaFile.getAbsolutePath());
+
+			BufferedReader is = new BufferedReader(new InputStreamReader(
+					new FileInputStream(javaFile), "UTF-8"));
+
+			String line;
+			String firstline = "";
+			StringWriter strWriter = new StringWriter();
+			int i = 0;
+
+			while ((line = is.readLine()) != null) {
+				if (i == 0) {
+					firstline = line;
+					
+					if (firstline.startsWith("<canvas")) {
+						strWriter.append(asf_xml_copyright);
+					} else if (firstline.startsWith("<library")) {
+						strWriter.append(asf_xml_copyright);
+					}
+							
+					
+				} else if (i == 1) {
+					if (firstline.startsWith("<?xml ")
+							&& !line.startsWith("<!--")) {
+						strWriter.append(asf_xml_copyright);
+					} else if (firstline.startsWith("<?xml ")
+							&& !line.startsWith("<library")) {
+						strWriter.append(asf_xml_copyright);
+					} else if (firstline.startsWith("<?xml ")
+							&& !line.startsWith("<canvas")) {
+						strWriter.append(asf_xml_copyright);
+					}
+				}
+				strWriter.append(line + "\n");
+				i++;
+			}
+			is.close();
+
+			OutputStreamWriter out = new OutputStreamWriter(
+					new FileOutputStream(javaFile.getAbsolutePath()), "UTF-8");
+
+			out.write(strWriter.toString());
+			out.flush();
+			out.close();
+
+		} catch (Exception err) {
+			err.printStackTrace();
+		}
+	}
+
+	private void scanAndWriteJavaFile(File javaFile) {
+		try {
+			System.err.println(" " + javaFile.getAbsolutePath());
+
+			BufferedReader is = new BufferedReader(new InputStreamReader(
+					new FileInputStream(javaFile)));
+
+			String line;
+			StringWriter strWriter = new StringWriter();
+			int i = 0;
+
+			while ((line = is.readLine()) != null) {
+				if (i == 0) {
+					if (line.startsWith("package ")) {
+						strWriter.append(asf_copyright);
+					}
+				}
+				strWriter.append(line + "\n");
+				i++;
+			}
+			is.close();
+
+			FileWriter fileWriter = new FileWriter(javaFile, false);
+			fileWriter.write(strWriter.toString());
+			fileWriter.flush();
+			fileWriter.close();
+
+		} catch (Exception err) {
+			err.printStackTrace();
+		}
+	}
+
+}

Propchange: incubator/openmeetings/trunk/singlewebapp/src/src_tool/org/openmeetings/srctool/AsfCopyRightReplace.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain