+
+ com.raytheon.uf.edex.archive.feeder.feature
+
+
+
+
+
+ org.eclipse.pde.FeatureBuilder
+
+
+
+
+
+ org.eclipse.pde.FeatureNature
+
+
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/build.properties b/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/build.properties
new file mode 100644
index 0000000000..64f93a9f0b
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/build.properties
@@ -0,0 +1 @@
+bin.includes = feature.xml
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/feature.xml b/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/feature.xml
new file mode 100644
index 0000000000..deae9f808c
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder.feature/feature.xml
@@ -0,0 +1,27 @@
+
+
+
+
+ Use for testing of archive binary files. Not part of standard EDEX.
+
+
+
+ [Enter Copyright Description here.]
+
+
+
+ [Enter License Description here.]
+
+
+
+
+
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/.classpath b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.classpath
new file mode 100644
index 0000000000..098194ca4b
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/.project b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.project
new file mode 100644
index 0000000000..c49d0fc471
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.project
@@ -0,0 +1,28 @@
+
+
+ com.raytheon.uf.edex.archive.feeder
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.pde.ManifestBuilder
+
+
+
+
+ org.eclipse.pde.SchemaBuilder
+
+
+
+
+
+ org.eclipse.pde.PluginNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/.settings/org.eclipse.jdt.core.prefs b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000000..f42de363af
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.archive.feeder/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..f00382758c
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Utility
+Bundle-SymbolicName: com.raytheon.uf.edex.archive.feeder
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: com.raytheon.uf.edex.archive.feeder.Activator
+Bundle-Vendor: RAYTHEON
+Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
+ com.raytheon.edex.common;bundle-version="1.12.1174",
+ com.raytheon.uf.edex.database;bundle-version="1.0.0",
+ org.eclipse.ui,
+ org.eclipse.core.runtime,
+ com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
+ com.raytheon.uf.common.status;bundle-version="1.12.1174",
+ org.apache.camel;bundle-version="1.0.0",
+ com.raytheon.uf.edex.site;bundle-version="1.0.0",
+ com.raytheon.uf.edex.core;bundle-version="1.12.1174",
+ org.apache.commons.beanutils;bundle-version="1.8.3"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Bundle-ActivationPolicy: lazy
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/README.txt b/edexOsgi/com.raytheon.uf.edex.archive.feeder/README.txt
new file mode 100644
index 0000000000..62246b05d3
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/README.txt
@@ -0,0 +1,20 @@
+The com.raytheon.uf.edex.archive.feeder plugin is not part of the standard EDEX deploy.
+It is a tool for debugging the binary files generated for archiving.
+
+The easiest way to generate this plugin jar is to add the following to
+com.raytheon.edex.feature.uframe/feature.xml:
+
+
+
+Then run the build.edex deploy-install.xml. This will create the plugin jar file:
+/awips2/edex/lib/plugins/com.raytheon.uf.edex.archive.feeder.jar
+
+the needed configuration file:
+
+/awips2/edex/conf/resources/com.raytheon.uf.edex.archive.feeder.properties
+
+By placing these two files in the corresponding locations on the desired EDEX server and
+restarting EDEX will start the clusteredArchiveBinaryFeederProc. You can then drop the
+binary files into the archive.feeder.directory, default /tmp/archive-feeder.
\ No newline at end of file
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/build.properties b/edexOsgi/com.raytheon.uf.edex.archive.feeder/build.properties
new file mode 100644
index 0000000000..5791d48d5f
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ res/
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/res/spring/archiveFeeder-spring.xml b/edexOsgi/com.raytheon.uf.edex.archive.feeder/res/spring/archiveFeeder-spring.xml
new file mode 100644
index 0000000000..2bbcd17a87
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/res/spring/archiveFeeder-spring.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/resources/com.raytheon.uf.edex.archive.feeder.properties b/edexOsgi/com.raytheon.uf.edex.archive.feeder/resources/com.raytheon.uf.edex.archive.feeder.properties
new file mode 100644
index 0000000000..d7a4ec2f69
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/resources/com.raytheon.uf.edex.archive.feeder.properties
@@ -0,0 +1,5 @@
+# When true enables the archive binary feeder
+archive.feeder.enable=true
+
+# Directory to check for binary files to ingest.
+archive.feeder.directory=/tmp/archive-feeder
diff --git a/edexOsgi/com.raytheon.uf.edex.archive.feeder/src/com/raytheon/uf/edex/archive/feeder/ArchiveBinaryFeederIngester.java b/edexOsgi/com.raytheon.uf.edex.archive.feeder/src/com/raytheon/uf/edex/archive/feeder/ArchiveBinaryFeederIngester.java
new file mode 100644
index 0000000000..83fdfad8cf
--- /dev/null
+++ b/edexOsgi/com.raytheon.uf.edex.archive.feeder/src/com/raytheon/uf/edex/archive/feeder/ArchiveBinaryFeederIngester.java
@@ -0,0 +1,249 @@
+/**
+ * This software was developed and / or modified by Raytheon Company,
+ * pursuant to Contract DG133W-05-CQ-1067 with the US Government.
+ *
+ * U.S. EXPORT CONTROLLED TECHNICAL DATA
+ * This software product contains export-restricted data whose
+ * export/transfer/disclosure is restricted by U.S. law. Dissemination
+ * to non-U.S. persons whether in the United States or abroad requires
+ * an export license or other authorization.
+ *
+ * Contractor Name: Raytheon Company
+ * Contractor Address: 6825 Pine Street, Suite 340
+ * Mail Stop B8
+ * Omaha, NE 68106
+ * 402.291.0100
+ *
+ * See the AWIPS II Master Rights File ("Master Rights File.pdf") for
+ * further licensing information.
+ **/
+package com.raytheon.uf.edex.archive.feeder;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.persistence.ManyToOne;
+
+import org.apache.commons.beanutils.PropertyUtils;
+
+import com.raytheon.uf.common.dataplugin.PluginDataObject;
+import com.raytheon.uf.common.dataplugin.PluginException;
+import com.raytheon.uf.common.status.IUFStatusHandler;
+import com.raytheon.uf.common.status.UFStatus;
+import com.raytheon.uf.common.status.UFStatus.Priority;
+import com.raytheon.uf.edex.core.EdexException;
+import com.raytheon.uf.edex.database.plugin.PluginDao;
+import com.raytheon.uf.edex.database.plugin.PluginFactory;
+
+/**
+ * This class used to process binary files created for the archive directory.
+ * Not intended for production. Designed for testing of problems with creating
+ * archive data.
+ *
+ *
+ *
+ * SOFTWARE HISTORY
+ *
+ * Date Ticket# Engineer Description
+ * ------------ ---------- ----------- --------------------------
+ * Feb 25, 2014 2838 rferrel Initial creation
+ *
+ *
+ *
+ * @author rferrel
+ * @version 1.0
+ */
+
+public class ArchiveBinaryFeederIngester {
+
+ protected static final IUFStatusHandler statusHandler = UFStatus
+ .getHandler(ArchiveBinaryFeederIngester.class);
+
+ /** The ManyToOne fields in a given class. */
+ private final Map, Field[]> manyToOneFieldMap = new HashMap, Field[]>();
+
+ /**
+ * The constructor. if needed attempts to created the drop directory
+ */
+ public ArchiveBinaryFeederIngester() {
+ String rootName = System.getProperty("archive.feeder.directory");
+ if (rootName != null) {
+ File rootDir = new File(rootName);
+ if (rootDir.exists()) {
+ if (!rootDir.isDirectory()) {
+ if (rootDir.delete()) {
+ rootDir.mkdirs();
+ }
+ }
+ } else {
+ rootDir.mkdirs();
+ }
+ }
+ }
+
+ /**
+ * Process archive binary file.
+ *
+ * @param file
+ * @throws EdexException
+ */
+ public void processEvent(File file) throws EdexException {
+ IUFStatusHandler statusHandler = UFStatus
+ .getHandler(ArchiveBinaryFeederIngester.class);
+
+ boolean enabled = Boolean.getBoolean("archive.feeder.enable");
+ if (!enabled) {
+ if (statusHandler.isPriorityEnabled(Priority.WARN)) {
+ StringBuilder sb = new StringBuilder(
+ ArchiveBinaryFeederIngester.class.getName());
+ sb.setLength(sb.lastIndexOf("."));
+ statusHandler
+ .handle(Priority.WARN,
+ String.format(
+ "file \"%s\" not processed; feeder not enabled consider removing plugin: %s",
+ file, sb.toString()));
+ }
+ return;
+ }
+
+ long start = System.currentTimeMillis();
+ ArchiveBinaryReader reader = new ArchiveBinaryReader(file);
+
+ try {
+ if (statusHandler.isPriorityEnabled(Priority.INFO)) {
+ statusHandler.handle(
+ Priority.INFO,
+ String.format("Start processing file \"%1$s\".",
+ file.getAbsoluteFile()));
+ }
+
+ Object object = reader.getObject();
+ if (!(object instanceof List>)) {
+ if (statusHandler.isPriorityEnabled(Priority.INFO)) {
+ statusHandler
+ .info(String
+ .format("file: \"%s\" does not contain a list of PluginDataObjects",
+ file.getAbsolutePath()));
+ }
+ } else {
+ List> objects = (List>) object;
+ process(objects);
+ }
+ } catch (Exception e) {
+ if (statusHandler.isPriorityEnabled(Priority.PROBLEM)) {
+ statusHandler.handle(Priority.PROBLEM, String.format(
+ "Problem processing the file: \"%s\", %s",
+ file.getAbsolutePath(), e.getLocalizedMessage()));
+ }
+
+ } finally {
+ if (statusHandler.isPriorityEnabled(Priority.INFO)) {
+ long time = System.currentTimeMillis() - start;
+ statusHandler.handle(Priority.INFO, String.format(
+ "Finished processing file \"%1$s\" in %2$d msec.",
+ file.getAbsoluteFile(), time));
+ }
+ }
+ }
+
+ /**
+ * Checks to see if the objects is a list of PluginDataObjects and attempts
+ * use the proper dao to send list to the data base.
+ *
+ * @param objects
+ * @throws PluginException
+ */
+ private void process(List> objects) throws PluginException {
+ if (objects.size() > 0) {
+ Object o = objects.iterator().next();
+
+ if (o instanceof PluginDataObject) {
+ PluginDataObject pdo = (PluginDataObject) o;
+ String pdoName = pdo.getPluginName();
+
+ PluginDao dao = PluginFactory.getInstance().getPluginDao(
+ pdoName);
+
+ processManytoOneFields(objects, pdo.getClass(), dao);
+
+ dao.persistAll(objects);
+ } else {
+ throw new PluginException("Not a list of PluginDataObjects.");
+ }
+ }
+ }
+
+ /**
+ * Determine the fields in the class that are an instance of the ManyToOne
+ * class. This will always return a non null result.
+ *
+ * @param clazz
+ * @return fields
+ */
+ private synchronized Field[] getManyToOneFields(Class> clazz) {
+ Field[] fields = manyToOneFieldMap.get(clazz);
+ if (fields == null) {
+ List fieldList = new ArrayList();
+ Class> currentClass = clazz;
+
+ while (currentClass != null) {
+ for (Field field : currentClass.getDeclaredFields()) {
+ if (field.getAnnotation(ManyToOne.class) != null) {
+ fieldList.add(field);
+ }
+ }
+ currentClass = currentClass.getSuperclass();
+ }
+
+ fields = fieldList.toArray(new Field[fieldList.size()]);
+ manyToOneFieldMap.put(clazz, fields);
+ }
+
+ return fields;
+ }
+
+ /**
+ * Process the Many to one fields of a class so their values are in the data
+ * base prior to attempting to place the objects in the data base.
+ *
+ * @param objects
+ * @param clazz
+ */
+ private void processManytoOneFields(Collection> objects, Class> clazz,
+ PluginDao dao) {
+ Field[] fields = getManyToOneFields(clazz);
+ if (fields.length > 0) {
+ Map