Omaha #3582 Clean up SerializationUtil's JAXB/XML support
Change-Id: Ic334e43ff0ddb2556f79b04e32a3daeed478f431 Former-commit-id: fcb1a5c9c93ffe19f9a4e3706f68fab12a0649dc
This commit is contained in:
parent
0bde7e01fb
commit
63f44c571d
11 changed files with 1 additions and 373 deletions
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.edex.adaptersrv</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -1,7 +0,0 @@
|
|||
#Thu Mar 26 10:08:45 CDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
|
@ -1,10 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Adaptersrv Plug-in
|
||||
Bundle-SymbolicName: com.raytheon.edex.adaptersrv
|
||||
Bundle-Version: 1.12.1174.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: com.raytheon.edex.common,
|
||||
com.raytheon.uf.edex.core
|
||||
Export-Package: com.raytheon.edex.adapterSrv
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
|
@ -1,4 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -1,114 +0,0 @@
|
|||
/**
|
||||
* 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.edex.adapterSrv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.raytheon.edex.msg.Command;
|
||||
import com.raytheon.edex.msg.ProgramOutput;
|
||||
import com.raytheon.edex.utility.StreamHandler;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.util.StringUtil;
|
||||
import com.raytheon.uf.edex.core.EdexException;
|
||||
|
||||
/**
|
||||
* Receives a canonical XML message from a mule endpoint containing a command
|
||||
* and associated arguments necessary for running an external command line
|
||||
* application.
|
||||
* <p>
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 09August2006 17 Phillippe Initial Creation
|
||||
* 10August2006 17 Phillippe Output is now persisted as XML in
|
||||
* ..\opt\data\output
|
||||
* 1Sept2006 17 Phillippe Modified to use JiBX to create XML output
|
||||
* 12Feb2007 TO5 MW Fegan Modified to return program output as XML.
|
||||
* 26Nov2008 chammack Camel refactor
|
||||
* 19Sep2011 10955 rferrel make sure process destroy is called.
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author bphillip
|
||||
*
|
||||
*/
|
||||
public class AdapterSrv {
|
||||
|
||||
protected String process(String msg) throws EdexException {
|
||||
Command command = null;
|
||||
ArrayList<String> execCommand = new ArrayList<String>();
|
||||
ProgramOutput progOut = null;
|
||||
ProcessBuilder procBuilder;
|
||||
Process proc = null;
|
||||
StreamHandler output;
|
||||
int exitCode;
|
||||
|
||||
try {
|
||||
long executionTime = System.currentTimeMillis() / 1000;
|
||||
|
||||
/* get the Command object and extract the command line */
|
||||
command = (Command) SerializationUtil.unmarshalFromXml(msg);
|
||||
execCommand.add(command.getName());
|
||||
String[] args = command.getArguments();
|
||||
if (args != null && args.length != 0) {
|
||||
for (String arg : command.getArguments()) {
|
||||
execCommand.add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
// Creates and starts a new process with the given command/args.
|
||||
// Also merges error stream with the output stream.
|
||||
// logger.debug("process() executing " + execCommand.get(0));
|
||||
procBuilder = new ProcessBuilder(execCommand);
|
||||
procBuilder.redirectErrorStream(true);
|
||||
proc = procBuilder.start();
|
||||
|
||||
// Monitors output stream of created process
|
||||
output = new StreamHandler(proc.getInputStream());
|
||||
output.start();
|
||||
|
||||
// Waits for child process to terminate
|
||||
exitCode = proc.waitFor();
|
||||
if (exitCode != 0) {
|
||||
throw new EdexException("Program: " + execCommand.get(0)
|
||||
+ " Terminated Abnormally");
|
||||
}
|
||||
|
||||
progOut = new ProgramOutput(executionTime, execCommand,
|
||||
output.getOutput());
|
||||
// logger.debug("process() execution complete");
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new EdexException(
|
||||
"AdapterSrv: Error running external executable: "
|
||||
+ StringUtil.printString(command), e);
|
||||
} finally {
|
||||
// #DR 10955
|
||||
if (proc != null) {
|
||||
proc.destroy();
|
||||
}
|
||||
}
|
||||
return progOut.toXML();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* 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.
|
||||
**/
|
||||
/**
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 09August2006 17 Phillippe Initial Creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bphillip
|
||||
* @version 1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Classes for implementing the external program Adapter Service
|
||||
*/
|
||||
package com.raytheon.edex.adapterSrv;
|
|
@ -1,99 +0,0 @@
|
|||
/**
|
||||
* 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.edex.uengine.tasks.process;
|
||||
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.dataplugin.persist.PersistableDataObject;
|
||||
import com.raytheon.uf.common.message.response.AbstractResponseMessage;
|
||||
import com.raytheon.uf.common.message.response.ResponseMessageError;
|
||||
import com.raytheon.uf.common.message.response.ResponseMessageGeneric;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.edex.database.dao.CoreDao;
|
||||
import com.raytheon.uf.edex.database.dao.DaoConfig;
|
||||
|
||||
/**
|
||||
* Updates a row in the database by unmarshalling an xml String and then storing
|
||||
* the equivalent object in the correct table.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 9/25/2007 njensen Initial creation.
|
||||
* 10/17/2007 482 grichard Changed method to dao.saveOrUpdate().
|
||||
* 12/17/2007 639 grichard Restored method call dao.saveOrUpdate().
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
*/
|
||||
public class TableUpdate extends ScriptTask {
|
||||
|
||||
private final String className;
|
||||
|
||||
private final String xml;
|
||||
|
||||
private final String database;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param aClassName
|
||||
* the class name of the object to update
|
||||
* @param aXml
|
||||
* the xml representation of the object
|
||||
*/
|
||||
public TableUpdate(String database, String aClassName, String aXml) {
|
||||
this.database = database;
|
||||
className = aClassName;
|
||||
xml = aXml;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
CoreDao dao = null;
|
||||
|
||||
AbstractResponseMessage msg = null;
|
||||
try {
|
||||
System.out.println(xml);
|
||||
PersistableDataObject obj = (PersistableDataObject) SerializationUtil
|
||||
.unmarshalFromXml(xml);
|
||||
System.out.println(obj);
|
||||
dao = new CoreDao(
|
||||
DaoConfig.forClass(database, className));
|
||||
dao.saveOrUpdate(obj);
|
||||
} catch (Exception e) {
|
||||
msg = ResponseMessageError.generateErrorResponse(
|
||||
"Error updating row in the database.", e);
|
||||
}
|
||||
|
||||
if (msg == null) {
|
||||
msg = new ResponseMessageGeneric("Row successfully updated.");
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
from java.util import ArrayList
|
||||
from com.raytheon.edex.uengine.tasks.process import TableUpdate
|
||||
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||
|
||||
#
|
||||
# Update of table data
|
||||
#
|
||||
#
|
||||
# SOFTWARE HISTORY
|
||||
#
|
||||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 04/17/08 njensen Initial Creation.
|
||||
#
|
||||
#
|
||||
|
||||
class TableResponse():
|
||||
|
||||
def __init__(self, db, table, row):
|
||||
self.__database = db
|
||||
self.__tableName = table
|
||||
self.__rowName = row
|
||||
self.__updateResults = None
|
||||
self.__update = TableUpdate(self.__database, self.__tableName, self.__rowName)
|
||||
|
||||
def execute(self):
|
||||
self.__updateResults = self.__update.execute()
|
||||
return self.__updateResults
|
||||
|
||||
def makeXmlResponse(self):
|
||||
size = self.__updateResults.size()
|
||||
response = ArrayList()
|
||||
for i in range(size):
|
||||
makeResponse = ResponseMessageGeneric(self.__updateResults.get(i))
|
||||
response.add(makeResponse.execute())
|
||||
return response
|
||||
|
|
@ -20,14 +20,7 @@
|
|||
<requires>
|
||||
<import feature="com.raytheon.uf.edex.common.core.feature" version="1.0.0.qualifier"/>
|
||||
</requires>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.edex.adaptersrv"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.edex.notifysrv"
|
||||
download-size="0"
|
||||
|
|
Loading…
Add table
Reference in a new issue