Omaha #2926 switched textdb to thrift client
Change-Id: I80a55506fa1e6d8780c0d3dbfb4b3c82b1aac9f1 Former-commit-id:53873d8d8f
[formerly8a930b582a
] [formerly344ba01102
] [formerly344ba01102
[formerly1bbf5d7346
]] [formerlyc05e535cc8
[formerly344ba01102
[formerly1bbf5d7346
] [formerlyc05e535cc8
[formerly 856ef48bab005bdb7de9dd4145fafc7fe12084f5]]]] Former-commit-id:c05e535cc8
Former-commit-id: a827f9b346960822a12b349bb40445c9480df1a5 [formerly a8b681ac9858375a256beaf3b32523c39c49ac43] [formerly65d5085dcf
[formerly09d7136915
]] Former-commit-id:65d5085dcf
Former-commit-id:e15b5156db
This commit is contained in:
parent
d296c48473
commit
bd86106ae1
25 changed files with 715 additions and 602 deletions
|
@ -25,15 +25,12 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.uf.common.localization.PathManagerFactory;
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
import com.raytheon.uf.common.message.Message;
|
||||
import com.raytheon.uf.common.message.Property;
|
||||
import com.raytheon.uf.common.message.response.AbstractResponseMessage;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.util.FileUtil;
|
||||
import com.raytheon.uf.common.util.RunProcess;
|
||||
import com.raytheon.uf.edex.core.EDEXUtil;
|
||||
|
@ -56,6 +53,7 @@ import com.raytheon.uf.edex.core.EDEXUtil;
|
|||
* Added logic to utilize the trigger.
|
||||
* Sep 19, 2011 10955 rferrel Use RunProcess
|
||||
* 05/25/2012 DR 15015 D. Friedman Use helper script to launch triggers.
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
* </pre>
|
||||
*
|
||||
* @author mfegan
|
||||
|
@ -133,10 +131,15 @@ public class LdadMicroEngine extends AMicroEngine {
|
|||
*/
|
||||
private String retrieveTextProduct(String prodID) throws Exception {
|
||||
Message message = createProductRequestMessage(prodID);
|
||||
String xml = SerializationUtil.marshalToXml(message);
|
||||
Object response = EDEXUtil.getMessageProducer().sendSync(TEXT_DB_QUEUE,
|
||||
xml);
|
||||
return extractProductFromResponse(response.toString());
|
||||
message);
|
||||
if (response instanceof Message) {
|
||||
return extractProductFromResponse((Message) response);
|
||||
} else {
|
||||
throw new MicroEngineException(
|
||||
"Unexpected return type from textdb service: "
|
||||
+ response.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -166,10 +169,10 @@ public class LdadMicroEngine extends AMicroEngine {
|
|||
Message message = new Message();
|
||||
Header header = new Header();
|
||||
List<Property> properties = new ArrayList<Property>();
|
||||
properties.add(new Property("VIEW", AsciiToHex("text")));
|
||||
properties.add(new Property("OP", AsciiToHex("GET")));
|
||||
properties.add(new Property("SUBOP", AsciiToHex("PROD")));
|
||||
properties.add(new Property("AFOSCMD", AsciiToHex(prodID)));
|
||||
properties.add(new Property("VIEW", "text"));
|
||||
properties.add(new Property("OP", "GET"));
|
||||
properties.add(new Property("SUBOP", "PROD"));
|
||||
properties.add(new Property("AFOSCMD", prodID));
|
||||
header.setProperties(properties.toArray(new Property[] {}));
|
||||
message.setHeader(header);
|
||||
return message;
|
||||
|
@ -195,15 +198,13 @@ public class LdadMicroEngine extends AMicroEngine {
|
|||
* @throws Exception
|
||||
* if an error occurs
|
||||
*/
|
||||
private String extractProductFromResponse(String response) throws Exception {
|
||||
private String extractProductFromResponse(Message reply) throws Exception {
|
||||
StringBuffer retVal = new StringBuffer();
|
||||
Message reply = (Message) SerializationUtil.unmarshalFromXml(response);
|
||||
Header header = reply.getHeader();
|
||||
if (header != null && header.getProperties() != null) {
|
||||
for (Property property : header.getProperties()) {
|
||||
if (property.getName().equalsIgnoreCase("stdout")) {
|
||||
String value = hexToAscii(property.getValue());
|
||||
retVal.append(value).append("\n");
|
||||
retVal.append(property.getValue()).append("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,34 +252,6 @@ public class LdadMicroEngine extends AMicroEngine {
|
|||
.exec(script, strEnv.toArray(new String[] {}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an ASCII string to a binary representation. This conversion is
|
||||
* required as Text Database Server expects all Header Property values to be
|
||||
* HEX encoded.
|
||||
*
|
||||
* @param string
|
||||
* the string to convert
|
||||
* @return the converted string
|
||||
*/
|
||||
private String AsciiToHex(String string) {
|
||||
return new HexBinaryAdapter().marshal(string.getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a HEX encoded string to plain ASCII. This conversion is required
|
||||
* as Text Database Server expects all Header Property values to be HEX
|
||||
* encoded.
|
||||
*
|
||||
* @param hexString
|
||||
* the HEX encoded string
|
||||
*
|
||||
* @return the plain text string
|
||||
*/
|
||||
private String hexToAscii(String hexString) {
|
||||
byte[] b = new HexBinaryAdapter().unmarshal(hexString);
|
||||
return new String(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a helper script that should be used to launch triggers. The helper
|
||||
* script terminates immediately so that resources can be freed even if the
|
||||
|
|
|
@ -1,89 +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.uf.common.dataplugin.text.dbsrv;
|
||||
|
||||
import javax.xml.bind.annotation.adapters.HexBinaryAdapter;
|
||||
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
|
||||
/**
|
||||
* Utilities for hexadecimal property values
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 15, 2014 2536 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class PropConverter {
|
||||
|
||||
/**
|
||||
* ASCII to HEX conversion.
|
||||
*
|
||||
* @param string
|
||||
* ascii string
|
||||
* @return hex code
|
||||
*/
|
||||
public static String asciiToHex(String string) {
|
||||
return new HexBinaryAdapter().marshal(string.getBytes());
|
||||
}
|
||||
|
||||
/**
|
||||
* HEX To ASCII conversion
|
||||
*
|
||||
* @param hexString
|
||||
* @return ascii string
|
||||
*/
|
||||
public static String hexToAscii(String hexString) {
|
||||
|
||||
byte[] b = new HexBinaryAdapter().unmarshal(hexString);
|
||||
|
||||
return new String(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hexadecimal property value. Converts value from hex to ASCII (if
|
||||
* non-null).
|
||||
*
|
||||
* @param header
|
||||
* contains message header.
|
||||
* @param propName
|
||||
* contains property name.
|
||||
* @return property value or null if property is not in header
|
||||
*/
|
||||
public static String getProperty(Header header, String propName) {
|
||||
String result = null;
|
||||
|
||||
String value = header.getProperty(propName);
|
||||
|
||||
if (value != null) {
|
||||
result = hexToAscii(value);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.message.Property;
|
|||
* 02Aug2010 2187 cjeanbap Update variable/method signature to be consistent.
|
||||
* 29Jan2013 1496 rferrel Added methods clearProductIds and clone.
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -431,7 +432,7 @@ public class TextDBQuery {
|
|||
for (Property property : properties) {
|
||||
String s = property.getValue();
|
||||
if (s != null) {
|
||||
property.setValue(PropConverter.asciiToHex(s));
|
||||
property.setValue(s);
|
||||
}
|
||||
}
|
||||
Property[] p = new Property[properties.size()];
|
||||
|
@ -453,7 +454,7 @@ public class TextDBQuery {
|
|||
for (Property p : properties) {
|
||||
String s = p.getValue();
|
||||
if (s != null) {
|
||||
p.setValue(PropConverter.hexToAscii(s));
|
||||
p.setValue(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,9 +71,7 @@
|
|||
|
||||
<route id="textdbsrvinternal">
|
||||
<from uri="direct-vm:int.textdb.request" />
|
||||
<bean ref="serializationUtil" method="unmarshalFromXml" />
|
||||
<bean ref="textdbsrv" method="processMessage" />
|
||||
<bean ref="serializationUtil" method="marshalToXml" />
|
||||
</route>
|
||||
|
||||
<route id="subscriptionNotify">
|
||||
|
|
|
@ -62,10 +62,6 @@
|
|||
</bean>
|
||||
|
||||
<!-- textdb -->
|
||||
<bean id="textDbSrvWrapper" class = "com.raytheon.uf.edex.plugin.text.dbsrv.TextDBSrvWrapper">
|
||||
<property name="textdbSrv" ref="textdbsrv"/>
|
||||
<property name="byteLimitInMB" value="${textdbsrv.byteLimitInMB}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="executeAfosCmdHandler" class="com.raytheon.uf.edex.plugin.text.handler.ExecuteAfosCmdHandler" />
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
|
@ -99,6 +95,15 @@
|
|||
<constructor-arg ref="remoteRetrievalHandler"/>
|
||||
</bean>
|
||||
|
||||
<bean factory-bean="handlerRegistry" factory-method="register">
|
||||
<constructor-arg value="com.raytheon.uf.edex.plugin.text.dbsrv.TextDBRequest"/>
|
||||
<constructor-arg>
|
||||
<bean class="com.raytheon.uf.edex.plugin.text.dbsrv.TextDBRequestHandler">
|
||||
<constructor-arg ref="textdbsrv" />
|
||||
</bean>
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="remoteRetrievalManager" class="com.raytheon.uf.edex.plugin.text.handler.RemoteRetrievalManager">
|
||||
<!-- <property name="remoteRetrievalExternalURI" value="direct-vm:remoteRetrievalExternalRoute" /> -->
|
||||
<property name="rrDelegate" ref="textdbRemoteRetrievalTarget" />
|
||||
|
@ -130,17 +135,9 @@
|
|||
serviceInterface="com.raytheon.uf.edex.plugin.text.handler.RemoteRetrievalManager$IRRDelegate"
|
||||
serviceUrl="direct-vm:remoteRetrievalExternalRoute" />
|
||||
|
||||
<endpoint id="textdbsrvXml_from"
|
||||
uri="jetty:http://0.0.0.0:${HTTP_PORT}/services/textdbsrv?disableStreamCache=true" />
|
||||
|
||||
<endpoint id="subscriptionHTTP_from"
|
||||
uri="jetty:http://0.0.0.0:${HTTP_PORT}/services/subscribe?disableStreamCache=true" />
|
||||
|
||||
<route id="textdbsrvXml">
|
||||
<from uri="ref:textdbsrvXml_from" />
|
||||
<bean ref="textDbSrvWrapper" method="executeTextDBMessage" />
|
||||
</route>
|
||||
|
||||
<route id="remoteRetrievalExternal">
|
||||
<from uri="direct-vm:remoteRetrievalExternalRoute" />
|
||||
<!-- Convert from BeanInvocation if needed. -->
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/**
|
||||
* 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.plugin.text.dbsrv;
|
||||
|
||||
import com.raytheon.uf.common.message.Message;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
|
||||
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
|
||||
import com.raytheon.uf.common.serialization.comm.IServerRequest;
|
||||
|
||||
/**
|
||||
* Object used by thrift clients to make textdb requests
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 18, 2014 2926 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
@DynamicSerialize
|
||||
public class TextDBRequest implements IServerRequest {
|
||||
|
||||
@DynamicSerializeElement
|
||||
private Message message;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public TextDBRequest() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
*/
|
||||
public TextDBRequest(Message message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the message
|
||||
*/
|
||||
public Message getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* the message to set
|
||||
*/
|
||||
public void setMessage(Message message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* 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.plugin.text.dbsrv;
|
||||
|
||||
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
|
||||
|
||||
/**
|
||||
* Handles requests from the textdb client
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 18, 2014 2926 bclement Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bclement
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TextDBRequestHandler implements
|
||||
IRequestHandler<TextDBRequest> {
|
||||
|
||||
private final TextDBSrv textdbSrv;
|
||||
|
||||
/**
|
||||
* @param textdbSrv
|
||||
*/
|
||||
public TextDBRequestHandler(TextDBSrv textdbSrv) {
|
||||
this.textdbSrv = textdbSrv;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.uf.common.serialization.comm.IRequestHandler#handleRequest
|
||||
* (com.raytheon.uf.common.serialization.comm.IServerRequest)
|
||||
*/
|
||||
@Override
|
||||
public Object handleRequest(TextDBRequest request) throws Exception {
|
||||
return textdbSrv.processMessage(request.getMessage());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,176 +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.uf.edex.plugin.text.dbsrv;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import com.raytheon.uf.common.message.Message;
|
||||
import com.raytheon.uf.common.serialization.SerializationUtil;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.common.time.util.ITimer;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.uf.common.util.ByteArrayOutputStreamPool;
|
||||
import com.raytheon.uf.common.util.SizeUtil;
|
||||
import com.raytheon.uf.common.util.stream.LimitingInputStream;
|
||||
import com.raytheon.uf.common.util.stream.LimitingOutputStream;
|
||||
import com.raytheon.uf.edex.plugin.text.dbsrv.impl.CommandExecutor;
|
||||
|
||||
/**
|
||||
* Thin wrapper around TextDBSrv to handle marshalling/unmarshalling and
|
||||
* limiting of the byte stream.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 15, 2014 2928 rjpeter Initial creation.
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
public class TextDBSrvWrapper {
|
||||
private final IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(TextDBSrvWrapper.class);
|
||||
|
||||
private static final IUFStatusHandler textDbSrvLogger = UFStatus
|
||||
.getNamedHandler("TextDBSrvRequestLogger");
|
||||
|
||||
/**
|
||||
* The limit of bytes that we are able to read in without erroring off.
|
||||
*/
|
||||
private long byteLimitInMB;
|
||||
|
||||
/**
|
||||
* TextDbSrv implementation to use.
|
||||
*/
|
||||
private TextDBSrv textdbSrv;
|
||||
|
||||
/**
|
||||
* Unmarshalls the input stream as xml data and sends to textdbsrv for
|
||||
* processing.
|
||||
*
|
||||
* @param is
|
||||
* @return
|
||||
*/
|
||||
public byte[] executeTextDBMessage(InputStream xmlDataStream) {
|
||||
ITimer timer = TimeUtil.getTimer();
|
||||
timer.start();
|
||||
|
||||
/*
|
||||
* This stream does not need to be closed, Camel will handle closing of
|
||||
* data
|
||||
*/
|
||||
LimitingInputStream inputStream = null;
|
||||
String sizeString = null;
|
||||
Message rval;
|
||||
|
||||
try {
|
||||
inputStream = new LimitingInputStream(xmlDataStream, byteLimitInMB
|
||||
* SizeUtil.BYTES_PER_MB);
|
||||
Message message = SerializationUtil.jaxbUnmarshalFromInputStream(
|
||||
Message.class, inputStream);
|
||||
sizeString = SizeUtil.prettyByteSize(inputStream.getBytesRead());
|
||||
textDbSrvLogger.info("Processing xml message of length: "
|
||||
+ sizeString);
|
||||
|
||||
rval = textdbSrv.processMessage(message);
|
||||
} catch (Throwable e) {
|
||||
statusHandler
|
||||
.error("Error occured processing textDbSrv message", e);
|
||||
rval = CommandExecutor
|
||||
.createErrorMessage("Error occurred during processing: "
|
||||
+ e.getLocalizedMessage());
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LimitingOutputStream outStream = null;
|
||||
int tries = 0;
|
||||
byte[] bytesOut = null;
|
||||
|
||||
while ((bytesOut == null) && (tries < 2)) {
|
||||
try {
|
||||
ByteArrayOutputStream baos = ByteArrayOutputStreamPool
|
||||
.getInstance().getStream();
|
||||
outStream = new LimitingOutputStream(baos, byteLimitInMB
|
||||
* SizeUtil.BYTES_PER_MB);
|
||||
SerializationUtil.jaxbMarshalToStream(rval, outStream);
|
||||
bytesOut = baos.toByteArray();
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Error occured marshalling response", e);
|
||||
tries++;
|
||||
rval = CommandExecutor
|
||||
.createErrorMessage("Error occurred during processing: "
|
||||
+ e.getLocalizedMessage());
|
||||
} finally {
|
||||
if (outStream != null) {
|
||||
try {
|
||||
outStream.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
timer.stop();
|
||||
|
||||
StringBuilder sb = new StringBuilder(300);
|
||||
sb.append("Processed message in ").append(timer.getElapsedTime())
|
||||
.append("ms, ");
|
||||
sb.append("request was size ").append(sizeString);
|
||||
sb.append(", response was size ")
|
||||
.append(SizeUtil
|
||||
.prettyByteSize(bytesOut != null ? bytesOut.length : 0));
|
||||
textDbSrvLogger.info(sb.toString());
|
||||
|
||||
return bytesOut;
|
||||
}
|
||||
|
||||
public long getByteLimitInMB() {
|
||||
return byteLimitInMB;
|
||||
}
|
||||
|
||||
public void setByteLimitInMB(long byteLimitInMB) {
|
||||
this.byteLimitInMB = byteLimitInMB;
|
||||
}
|
||||
|
||||
public TextDBSrv getTextdbSrv() {
|
||||
return textdbSrv;
|
||||
}
|
||||
|
||||
public void setTextdbSrv(TextDBSrv textdbSrv) {
|
||||
this.textdbSrv = textdbSrv;
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.PropConverter;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
import com.raytheon.uf.common.message.Message;
|
||||
|
@ -41,6 +40,7 @@ import com.raytheon.uf.common.message.Property;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 7, 2008 1538 jkorman Initial creation
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv, removed unused logger
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -50,6 +50,10 @@ import com.raytheon.uf.common.message.Property;
|
|||
|
||||
public class CommandExecutor implements ICommandExecutor {
|
||||
|
||||
protected static final String STDERR = "STDERR";
|
||||
|
||||
protected static final String STDOUT = "STDOUT";
|
||||
|
||||
private static final TextDBSrvCommandTags VIEW_CMD = TextDBSrvCommandTags.VIEW;
|
||||
|
||||
private Map<String, ICommandExecutor> execMap = new HashMap<String, ICommandExecutor>();
|
||||
|
@ -96,7 +100,7 @@ public class CommandExecutor implements ICommandExecutor {
|
|||
if (message != null) {
|
||||
Header header = message.getHeader();
|
||||
if (header != null) {
|
||||
cmdView = PropConverter.getProperty(header, VIEW_CMD.name());
|
||||
cmdView = header.getProperty(VIEW_CMD.name());
|
||||
}
|
||||
}
|
||||
return cmdView;
|
||||
|
@ -135,8 +139,7 @@ public class CommandExecutor implements ICommandExecutor {
|
|||
public static final Message createErrorMessage(String error) {
|
||||
Message msg = new Message();
|
||||
Header h = new Header();
|
||||
h.setProperties(new Property[] { new Property("STDERR", PropConverter
|
||||
.asciiToHex(error)), });
|
||||
h.setProperties(new Property[] { new Property(STDERR, error), });
|
||||
|
||||
msg.setHeader(h);
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.List;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.text.db.StateMatch;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.PropConverter;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.StateTableTags;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
|
@ -42,6 +41,7 @@ import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|||
* Oct 7, 2008 1538 jkorman Initial creation
|
||||
* Aug 31, 2010 2103 cjeanbap Check variable for null.
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -86,8 +86,7 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
Header sHeader = cmdMessage.getHeader();
|
||||
|
||||
// Get the operation code
|
||||
String op = PropConverter
|
||||
.getProperty(sHeader, StateTableTags.OP.name());
|
||||
String op = sHeader.getProperty(StateTableTags.OP.name());
|
||||
|
||||
TextDBSrvCommandTags opTag = TextDBSrvCommandTags.valueOf(op);
|
||||
|
||||
|
@ -95,32 +94,25 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
switch (opTag) {
|
||||
|
||||
case PUT: {
|
||||
String state = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.STATE.name());
|
||||
String cccId = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.CCC.name());
|
||||
String xxxId = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.XXX.name());
|
||||
String state = sHeader.getProperty(StateTableTags.STATE.name());
|
||||
String cccId = sHeader.getProperty(StateTableTags.CCC.name());
|
||||
String xxxId = sHeader.getProperty(StateTableTags.XXX.name());
|
||||
if ((state != null) && (cccId != null) && (xxxId != null)) {
|
||||
addStateData(sHeader, state, xxxId, cccId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GET: {
|
||||
String state = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.STATE.name());
|
||||
String state = sHeader.getProperty(StateTableTags.STATE.name());
|
||||
if (state != null) {
|
||||
getStateData(sHeader, state);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DELETE: {
|
||||
String state = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.STATE.name());
|
||||
String cccId = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.CCC.name());
|
||||
String xxxId = PropConverter.getProperty(sHeader,
|
||||
StateTableTags.XXX.name());
|
||||
String state = sHeader.getProperty(StateTableTags.STATE.name());
|
||||
String cccId = sHeader.getProperty(StateTableTags.CCC.name());
|
||||
String xxxId = sHeader.getProperty(StateTableTags.XXX.name());
|
||||
if ((state != null) && (cccId != null) && (xxxId != null)) {
|
||||
deleteStateData(sHeader, state, xxxId, cccId);
|
||||
}
|
||||
|
@ -128,10 +120,9 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
}
|
||||
default: {
|
||||
String tagName = (opTag != null) ? opTag.name() : "null";
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Invalid command tag = ["
|
||||
+ tagName + "]")), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"ERROR:Invalid command tag = [" + tagName + "]"), };
|
||||
sHeader.setProperties(props);
|
||||
break;
|
||||
}
|
||||
|
@ -152,11 +143,10 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
*/
|
||||
private void addStateData(Header header, String state, String xxxId,
|
||||
String cccId) {
|
||||
Property newProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Adding a new state-ccc."));
|
||||
Property errProperty = new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure adding to state_ccc table."));
|
||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Adding a new state-ccc.");
|
||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure adding to state_ccc table.");
|
||||
|
||||
Property[] props = new Property[] { newProperty, };
|
||||
if (!textDB.addState(state, cccId, xxxId)) {
|
||||
|
@ -175,7 +165,7 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
private void getStateData(Header header, String state) {
|
||||
final int HEADER_LINES = 2;
|
||||
|
||||
String PROP_FMT = "STDOUT";
|
||||
String PROP_FMT = CommandExecutor.STDOUT;
|
||||
|
||||
Property[] props = null;
|
||||
|
||||
|
@ -184,20 +174,15 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
if (dataList != null && dataList.size() > 0) {
|
||||
props = new Property[dataList.size() + HEADER_LINES];
|
||||
int i = 0;
|
||||
props[i++] = new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex("XXX CCC"));
|
||||
props[i++] = new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex("-------"));
|
||||
props[i++] = new Property(PROP_FMT, "XXX CCC");
|
||||
props[i++] = new Property(PROP_FMT, "-------");
|
||||
for (StateMatch s : dataList) {
|
||||
props[i++] = new Property(PROP_FMT, PropConverter.asciiToHex(s
|
||||
.getPk()
|
||||
.getXxx() + " " + s.getPk().getCcc()));
|
||||
props[i++] = new Property(PROP_FMT, s.getPk().getXxx() + " "
|
||||
+ s.getPk().getCcc());
|
||||
}
|
||||
} else {
|
||||
props = new Property[] { new Property(
|
||||
"STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure reading from state lookup table.")), };
|
||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure reading from state lookup table."), };
|
||||
}
|
||||
header.setProperties(props);
|
||||
}
|
||||
|
@ -215,12 +200,11 @@ public class StateTableAdapter implements ICommandExecutor {
|
|||
Property[] props = null;
|
||||
|
||||
if (textDB.removeState(state, xxxId, cccId)) {
|
||||
props = new Property[] { new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Deleting state-ccc.")), };
|
||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Deleting state-ccc."), };
|
||||
} else {
|
||||
props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure deleting from state_ccc table.")), };
|
||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure deleting from state_ccc table."), };
|
||||
}
|
||||
header.setProperties(props);
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.PropConverter;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextViewGetTags;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextViewTags;
|
||||
|
@ -74,6 +73,7 @@ import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|||
* 27Apr2012 564 jkorman Added sort to ALL times retrieval.
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv, added marshalToStream()
|
||||
* Jul 15, 2014 3373 bclement jaxb manager api changes
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -82,6 +82,7 @@ import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|||
*/
|
||||
|
||||
public class TextViewAdapter implements ICommandExecutor {
|
||||
|
||||
// This is the default textdb formatted time.
|
||||
// Oct 31 08 10:13:15 GMT
|
||||
private static final String DEFAULT_TIME_FORMAT = "%1$tb %1$td %1$ty %1$tT GMT";
|
||||
|
@ -130,7 +131,7 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
Header sHeader = cmdMessage.getHeader();
|
||||
|
||||
// Get the operation code
|
||||
String op = PropConverter.getProperty(sHeader, TextViewTags.OP.name());
|
||||
String op = sHeader.getProperty(TextViewTags.OP.name());
|
||||
|
||||
TextDBSrvCommandTags opTag = TextDBSrvCommandTags.valueOf(op);
|
||||
|
||||
|
@ -147,18 +148,17 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
break;
|
||||
}
|
||||
case DELETE: {
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter.asciiToHex("ERROR:Command tag = ["
|
||||
+ opTag.name()
|
||||
+ "] not implemented")), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"ERROR:Command tag = [" + opTag.name()
|
||||
+ "] not implemented"), };
|
||||
sHeader.setProperties(props);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Invalid command tag = ["
|
||||
+ op + "]")), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"ERROR:Invalid command tag = [" + op + "]"), };
|
||||
sHeader.setProperties(props);
|
||||
break;
|
||||
}
|
||||
|
@ -183,12 +183,9 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
* @return the updated message header
|
||||
*/
|
||||
private Header processPutRequest(Header msgHeader) {
|
||||
String prodId = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.PRODID.name());
|
||||
String product = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.PRODUCT.name());
|
||||
String strMode = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.OPERATIONAL.name());
|
||||
String prodId = msgHeader.getProperty(TextViewTags.PRODID.name());
|
||||
String product = msgHeader.getProperty(TextViewTags.PRODUCT.name());
|
||||
String strMode = msgHeader.getProperty(TextViewTags.OPERATIONAL.name());
|
||||
|
||||
boolean operationalMode = isOperationalMode(strMode);
|
||||
long insertTime = textDB.writeProduct(prodId, product, operationalMode,
|
||||
|
@ -201,14 +198,14 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
Date d = new Date();
|
||||
d.setTime(insertTime);
|
||||
AlarmAlertUtil.sendProductAlarmAlert(prodId, d, operationalMode);
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Saved " + prodId)), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"NORMAL:Saved " + prodId), };
|
||||
msgHeader.setProperties(props);
|
||||
} else {
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("NORMAL:Not Saved; duplicate product "
|
||||
+ prodId)), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"NORMAL:Not Saved; duplicate product " + prodId), };
|
||||
msgHeader.setProperties(props);
|
||||
}
|
||||
|
||||
|
@ -222,31 +219,28 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
*/
|
||||
private Header processGetRequest(Header msgHeader) {
|
||||
|
||||
String op = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.SUBOP.name());
|
||||
String op = msgHeader.getProperty(TextViewTags.SUBOP.name());
|
||||
|
||||
TextViewGetTags subOp = TextViewGetTags.valueOf(op);
|
||||
boolean operationalMode = isOperationalMode(PropConverter.getProperty(
|
||||
msgHeader,
|
||||
TextViewTags.OPERATIONAL.name()));
|
||||
boolean operationalMode = isOperationalMode(msgHeader
|
||||
.getProperty(TextViewTags.OPERATIONAL.name()));
|
||||
|
||||
if (subOp != null) {
|
||||
if (TextViewGetTags.LATEST.equals(subOp)) {
|
||||
|
||||
List<Long> times = new ArrayList<Long>();
|
||||
|
||||
String fmtType = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.FORMAT.name());
|
||||
String timeFmt = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.CLIENTFMT.name());
|
||||
String fmtType = msgHeader.getProperty(TextViewTags.FORMAT
|
||||
.name());
|
||||
String timeFmt = msgHeader.getProperty(TextViewTags.CLIENTFMT
|
||||
.name());
|
||||
|
||||
// get the latest time for one or more products.
|
||||
Property[] msgProps = msgHeader.getProperties();
|
||||
for (Property p : msgProps) {
|
||||
|
||||
if (TextViewTags.PRODID.name().equals(p.getName())) {
|
||||
times.add(textDB.getLatestTime(
|
||||
PropConverter.hexToAscii(p.getValue()),
|
||||
times.add(textDB.getLatestTime(p.getValue(),
|
||||
operationalMode));
|
||||
}
|
||||
} // for
|
||||
|
@ -254,18 +248,17 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
int pIndex = 0;
|
||||
for (Long t : times) {
|
||||
String s = formatTime(t, fmtType, timeFmt);
|
||||
msgProps[pIndex++] = new Property("STDOUT",
|
||||
PropConverter.asciiToHex(s));
|
||||
msgProps[pIndex++] = new Property(CommandExecutor.STDOUT, s);
|
||||
}
|
||||
msgHeader.setProperties(msgProps);
|
||||
} else if (TextViewGetTags.ALL.equals(subOp)) {
|
||||
// get all times for a product
|
||||
String productId = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.PRODID.name());
|
||||
String fmtType = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.FORMAT.name());
|
||||
String timeFmt = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.CLIENTFMT.name());
|
||||
String productId = msgHeader.getProperty(TextViewTags.PRODID
|
||||
.name());
|
||||
String fmtType = msgHeader.getProperty(TextViewTags.FORMAT
|
||||
.name());
|
||||
String timeFmt = msgHeader.getProperty(TextViewTags.CLIENTFMT
|
||||
.name());
|
||||
|
||||
List<Long> times = textDB.getAllTimes(productId,
|
||||
operationalMode);
|
||||
|
@ -276,21 +269,20 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
int pIndex = 0;
|
||||
for (Long t : times) {
|
||||
String s = formatTime(t, fmtType, timeFmt);
|
||||
msgProps[pIndex++] = new Property("STDOUT",
|
||||
PropConverter.asciiToHex(s));
|
||||
msgProps[pIndex++] = new Property(CommandExecutor.STDOUT, s);
|
||||
}
|
||||
msgHeader.setProperties(msgProps);
|
||||
} else if (TextViewGetTags.INFO.equals(subOp)
|
||||
|| TextViewGetTags.PROD.equals(subOp)
|
||||
|| TextViewGetTags.PRODXML.equals(subOp)) {
|
||||
String siteCCCNNNXX = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.SITE.name());
|
||||
String siteCCCNNNXX = msgHeader.getProperty(TextViewTags.SITE
|
||||
.name());
|
||||
if (siteCCCNNNXX == null) {
|
||||
boolean infoFlag = TextViewGetTags.INFO.equals(subOp);
|
||||
boolean xmlFlag = TextViewGetTags.PRODXML.equals(subOp);
|
||||
|
||||
String afosCmd = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.AFOSCMD.name());
|
||||
String afosCmd = msgHeader.getProperty(TextViewTags.AFOSCMD
|
||||
.name());
|
||||
|
||||
logger.info("AFOS Command = " + afosCmd);
|
||||
|
||||
|
@ -302,8 +294,7 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
if (infoFlag) {
|
||||
String ss = "********** Product Count = "
|
||||
+ prods.size();
|
||||
prodList.add(new Property("STDOUT", PropConverter
|
||||
.asciiToHex(ss)));
|
||||
prodList.add(new Property(CommandExecutor.STDOUT, ss));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -311,21 +302,20 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
if (xmlFlag) {
|
||||
ByteArrayOutputStream strm = new ByteArrayOutputStream();
|
||||
marshalToStream(prod, strm);
|
||||
prodList.add(new Property("STDOUT",
|
||||
PropConverter.asciiToHex(strm
|
||||
.toString())));
|
||||
prodList.add(new Property(
|
||||
CommandExecutor.STDOUT, strm.toString()));
|
||||
} else {
|
||||
String s = prod.getProduct();
|
||||
if (s != null) {
|
||||
if (infoFlag) {
|
||||
String ss = "********** Product Size = "
|
||||
+ s.length();
|
||||
prodList.add(new Property("STDOUT",
|
||||
PropConverter.asciiToHex(ss)));
|
||||
prodList.add(new Property(
|
||||
CommandExecutor.STDOUT, ss));
|
||||
}
|
||||
|
||||
prodList.add(new Property("STDOUT",
|
||||
PropConverter.asciiToHex(s)));
|
||||
prodList.add(new Property(
|
||||
CommandExecutor.STDOUT, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -342,11 +332,11 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
|
||||
Property[] props = new Property[1];
|
||||
if (cccNNNXXX != null) {
|
||||
props[0] = new Property("STDOUT",
|
||||
PropConverter.asciiToHex(cccNNNXXX));
|
||||
props[0] = new Property(CommandExecutor.STDOUT,
|
||||
cccNNNXXX);
|
||||
} else {
|
||||
props[0] = new Property("STDERR",
|
||||
PropConverter.asciiToHex(UNKNOWN_SITE));
|
||||
props[0] = new Property(CommandExecutor.STDERR,
|
||||
UNKNOWN_SITE);
|
||||
}
|
||||
|
||||
msgHeader.setProperties(props);
|
||||
|
@ -356,20 +346,17 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
boolean xmlFlag = TextViewGetTags.JOINXML.equals(subOp);
|
||||
|
||||
// get all times for a product
|
||||
String wmoId = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.WMOID.name());
|
||||
String site = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.SITE.name());
|
||||
String abbrId = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.NNNXXX.name());
|
||||
String lastHrs = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.HOUR.name());
|
||||
String hdrTime = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.HDRTIME.name());
|
||||
String bbbId = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.BBB.name());
|
||||
String fullDataReadProp = PropConverter.getProperty(msgHeader,
|
||||
TextViewTags.FULLREAD.name());
|
||||
String wmoId = msgHeader.getProperty(TextViewTags.WMOID.name());
|
||||
String site = msgHeader.getProperty(TextViewTags.SITE.name());
|
||||
String abbrId = msgHeader.getProperty(TextViewTags.NNNXXX
|
||||
.name());
|
||||
String lastHrs = msgHeader
|
||||
.getProperty(TextViewTags.HOUR.name());
|
||||
String hdrTime = msgHeader.getProperty(TextViewTags.HDRTIME
|
||||
.name());
|
||||
String bbbId = msgHeader.getProperty(TextViewTags.BBB.name());
|
||||
String fullDataReadProp = msgHeader
|
||||
.getProperty(TextViewTags.FULLREAD.name());
|
||||
boolean fullDataRead = false;
|
||||
|
||||
if (fullDataReadProp != null && fullDataReadProp.length() > 0) {
|
||||
|
@ -387,9 +374,8 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
// if not xml or last hours request, add the number of returned
|
||||
// items
|
||||
if (!xmlFlag && (lastHrs == null || lastHrs.length() == 0)) {
|
||||
prodList.add(new Property("STDOUT", PropConverter
|
||||
.asciiToHex(""
|
||||
+ prods.size())));
|
||||
prodList.add(new Property(CommandExecutor.STDOUT, ""
|
||||
+ prods.size()));
|
||||
}
|
||||
|
||||
StringBuilder header = new StringBuilder();
|
||||
|
@ -400,9 +386,8 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
if (xmlFlag) {
|
||||
ByteArrayOutputStream strm = new ByteArrayOutputStream();
|
||||
marshalToStream(prod, strm);
|
||||
prodList.add(new Property("STDOUT", PropConverter
|
||||
.asciiToHex(strm
|
||||
.toString())));
|
||||
prodList.add(new Property(CommandExecutor.STDOUT,
|
||||
strm.toString()));
|
||||
} else {
|
||||
String cccId = prod.getCccid();
|
||||
String nnnId = prod.getNnnid();
|
||||
|
@ -427,8 +412,9 @@ public class TextViewAdapter implements ICommandExecutor {
|
|||
header.append(cccId);
|
||||
header.append(nnnId);
|
||||
header.append(xxxId);
|
||||
prodList.add(new Property("STDOUT", PropConverter
|
||||
.asciiToHex(header.toString())));
|
||||
prodList.add(new Property(CommandExecutor.STDOUT,
|
||||
header
|
||||
.toString()));
|
||||
}
|
||||
}
|
||||
} catch (SerializationException e) {
|
||||
|
|
|
@ -21,7 +21,6 @@ package com.raytheon.uf.edex.plugin.text.dbsrv.impl;
|
|||
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.PropConverter;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.VersionsTableTags;
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
|
@ -40,6 +39,7 @@ import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 8, 2008 1538 jkorman Initial creation
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -81,12 +81,10 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
Header sHeader = cmdMessage.getHeader();
|
||||
|
||||
// Get the operation code
|
||||
String op = PropConverter.getProperty(sHeader,
|
||||
VersionsTableTags.OP.name());
|
||||
String op = sHeader.getProperty(VersionsTableTags.OP.name());
|
||||
|
||||
TextDBSrvCommandTags opTag = TextDBSrvCommandTags.valueOf(op);
|
||||
String productId = PropConverter.getProperty(sHeader,
|
||||
VersionsTableTags.PRODID.name());
|
||||
String productId = sHeader.getProperty(VersionsTableTags.PRODID.name());
|
||||
|
||||
if (opTag != null && productId != null) {
|
||||
AFOSProductId prodId = new AFOSProductId(productId);
|
||||
|
@ -94,8 +92,7 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
switch (opTag) {
|
||||
|
||||
case PUT: {
|
||||
String versions = PropConverter.getProperty(sHeader,
|
||||
VersionsTableTags.VERSION.name());
|
||||
String versions = sHeader.getProperty(VersionsTableTags.VERSION.name());
|
||||
|
||||
addVersionInfo(sHeader, prodId.getCcc(), prodId.getNnn(),
|
||||
prodId.getXxx(), versions);
|
||||
|
@ -114,10 +111,9 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
}
|
||||
default: {
|
||||
String tagName = (opTag != null) ? opTag.name() : "null";
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Invalid command tag = ["
|
||||
+ tagName + "]")), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR,
|
||||
"ERROR:Invalid command tag = [" + tagName + "]"), };
|
||||
sHeader.setProperties(props);
|
||||
break;
|
||||
}
|
||||
|
@ -140,12 +136,11 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
*/
|
||||
private void addVersionInfo(Header header, String ccc, String nnn,
|
||||
String xxx, String versions) {
|
||||
Property newProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Adding productId " + ccc + nnn
|
||||
+ xxx + " versions " + versions));
|
||||
Property errProperty = new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure adding to versions table."));
|
||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Adding productId " + ccc + nnn + xxx + " versions "
|
||||
+ versions);
|
||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure adding to versions table.");
|
||||
|
||||
Property[] props = new Property[] { newProperty, };
|
||||
if (!textDB.addVersions(ccc, nnn, xxx, Integer.parseInt(versions))) {
|
||||
|
@ -163,19 +158,16 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
*/
|
||||
private void getVersionInfo(Header header, String ccc, String nnn,
|
||||
String xxx) {
|
||||
String PROP_FMT = "STDOUT";
|
||||
String PROP_FMT = CommandExecutor.STDOUT;
|
||||
|
||||
Property[] props = null;
|
||||
String vers = textDB.getVersions(ccc, nnn, xxx);
|
||||
|
||||
if (vers != null) {
|
||||
props = new Property[] { new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex(vers)) };
|
||||
props = new Property[] { new Property(PROP_FMT, vers) };
|
||||
} else {
|
||||
props = new Property[] { new Property(
|
||||
"STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure reading versions table.")), };
|
||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure reading versions table."), };
|
||||
}
|
||||
header.setProperties(props);
|
||||
}
|
||||
|
@ -189,12 +181,12 @@ public class VersionsAdapter implements ICommandExecutor {
|
|||
*/
|
||||
private void deleteVersionInfo(Header header, String ccc, String nnn,
|
||||
String xxx) {
|
||||
Property newProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Deleting product id " + ccc
|
||||
+ nnn + xxx + " from versionstable."));
|
||||
Property errProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("ERROR:Failure deleting " + ccc + nnn
|
||||
+ xxx + " from versionstable."));
|
||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Deleting product id " + ccc + nnn + xxx
|
||||
+ " from versionstable.");
|
||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure deleting "
|
||||
+ ccc + nnn + xxx + " from versionstable.");
|
||||
|
||||
Property[] props = new Property[] { newProperty, };
|
||||
if (!textDB.deleteVersions(ccc, nnn, xxx)) {
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
|
||||
import com.raytheon.uf.common.dataplugin.text.db.WatchWarn;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.ICommandExecutor;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.PropConverter;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.TextDBSrvCommandTags;
|
||||
import com.raytheon.uf.common.dataplugin.text.dbsrv.WarnTableTags;
|
||||
import com.raytheon.uf.common.message.Header;
|
||||
|
@ -50,6 +49,7 @@ import com.raytheon.uf.edex.plugin.text.db.TextDB;
|
|||
* from WatchWarn table.
|
||||
* Sep 14,2010 3944 cjenabap Added sendTextToQueue()
|
||||
* May 15, 2014 2536 bclement moved from uf.edex.textdbsrv
|
||||
* Aug 22, 2014 2926 bclement compatibility changes with new textdb service
|
||||
* </pre>
|
||||
*
|
||||
* @author jkorman
|
||||
|
@ -94,7 +94,7 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
Header sHeader = cmdMessage.getHeader();
|
||||
|
||||
// Get the operation code
|
||||
String op = PropConverter.getProperty(sHeader, WarnTableTags.OP.name());
|
||||
String op = sHeader.getProperty(WarnTableTags.OP.name());
|
||||
|
||||
TextDBSrvCommandTags opTag = TextDBSrvCommandTags.valueOf(op);
|
||||
|
||||
|
@ -102,10 +102,8 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
switch (opTag) {
|
||||
|
||||
case PUT: {
|
||||
String productId = PropConverter.getProperty(sHeader,
|
||||
WarnTableTags.PRODID.name());
|
||||
String script = PropConverter.getProperty(sHeader,
|
||||
WarnTableTags.SCRIPT.name());
|
||||
String productId = sHeader.getProperty(WarnTableTags.PRODID.name());
|
||||
String script = sHeader.getProperty(WarnTableTags.SCRIPT.name());
|
||||
|
||||
addWatchWarn(sHeader, productId, script);
|
||||
sendTextToQueue(productId, WATCH_WARN_QUEUE);
|
||||
|
@ -113,18 +111,15 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
}
|
||||
|
||||
case GET: {
|
||||
String productId = PropConverter.getProperty(sHeader,
|
||||
WarnTableTags.PRODID.name());
|
||||
String productId = sHeader.getProperty(WarnTableTags.PRODID.name());
|
||||
if (productId != null) {
|
||||
getWatchWarn(sHeader, productId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DELETE: {
|
||||
String productId = PropConverter.getProperty(sHeader,
|
||||
WarnTableTags.PRODID.name());
|
||||
String script = PropConverter.getProperty(sHeader,
|
||||
WarnTableTags.SCRIPT.name());
|
||||
String productId = sHeader.getProperty(WarnTableTags.PRODID.name());
|
||||
String script = sHeader.getProperty(WarnTableTags.SCRIPT.name());
|
||||
|
||||
if ((productId != null) && (script != null)) {
|
||||
deleteWatchWarn(sHeader, productId, script);
|
||||
|
@ -142,9 +137,9 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
}
|
||||
default: {
|
||||
String tagName = (opTag != null) ? opTag.name() : "null";
|
||||
Property[] props = new Property[] { new Property("STDERR",
|
||||
PropConverter.asciiToHex("ERROR:Invalid command tag = ["
|
||||
+ tagName + "]")), };
|
||||
Property[] props = new Property[] { new Property(
|
||||
CommandExecutor.STDERR, "ERROR:Invalid command tag = ["
|
||||
+ tagName + "]"), };
|
||||
sHeader.setProperties(props);
|
||||
break;
|
||||
}
|
||||
|
@ -164,12 +159,10 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
* @return
|
||||
*/
|
||||
private void addWatchWarn(Header header, String productId, String script) {
|
||||
Property newProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Adding productId " + productId
|
||||
+ " to trigger."));
|
||||
Property errProperty = new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure adding to state_ccc table."));
|
||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Adding productId " + productId + " to trigger.");
|
||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure adding to state_ccc table.");
|
||||
|
||||
Property[] props = new Property[] { newProperty, };
|
||||
if (!textDB.addWatchWarn(productId, script)) {
|
||||
|
@ -184,7 +177,7 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
* @param productId
|
||||
*/
|
||||
private void getWatchWarn(Header header, String productId) {
|
||||
String PROP_FMT = "STDOUT";
|
||||
String PROP_FMT = CommandExecutor.STDOUT;
|
||||
|
||||
Property[] props = null;
|
||||
|
||||
|
@ -193,20 +186,15 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
if (dataList.size() > 0) {
|
||||
props = new Property[dataList.size() + 2];
|
||||
int i = 0;
|
||||
props[i] = new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex("PRODUCTID SCRIPT"));
|
||||
props[i] = new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex("--------- ------"));
|
||||
props[i] = new Property(PROP_FMT, "PRODUCTID SCRIPT");
|
||||
props[i] = new Property(PROP_FMT, "--------- ------");
|
||||
for (WatchWarn w : dataList) {
|
||||
props[i++] = new Property(PROP_FMT,
|
||||
PropConverter.asciiToHex(String.format("%9s %s",
|
||||
w
|
||||
.getProductid(), w.getScript())));
|
||||
props[i++] = new Property(PROP_FMT, String.format("%9s %s",
|
||||
w.getProductid(), w.getScript()));
|
||||
}
|
||||
} else {
|
||||
props = new Property[] { new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure reading from watch warn table.")), };
|
||||
props = new Property[] { new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure reading from watch warn table."), };
|
||||
}
|
||||
header.setProperties(props);
|
||||
}
|
||||
|
@ -219,12 +207,10 @@ public class WarnTableAdapter implements ICommandExecutor {
|
|||
* @return
|
||||
*/
|
||||
private void deleteWatchWarn(Header header, String productId, String script) {
|
||||
Property newProperty = new Property("STDERR",
|
||||
PropConverter.asciiToHex("NORMAL:Deleting product id "
|
||||
+ productId + " trigger."));
|
||||
Property errProperty = new Property("STDERR",
|
||||
PropConverter
|
||||
.asciiToHex("ERROR:Failure adding to state_ccc table."));
|
||||
Property newProperty = new Property(CommandExecutor.STDERR,
|
||||
"NORMAL:Deleting product id " + productId + " trigger.");
|
||||
Property errProperty = new Property(CommandExecutor.STDERR,
|
||||
"ERROR:Failure adding to state_ccc table.");
|
||||
|
||||
Property[] props = new Property[] { newProperty, };
|
||||
if (!textDB.deleteWatchWarn(productId, script)) {
|
||||
|
|
|
@ -62,6 +62,7 @@ import com.raytheon.uf.edex.plugin.text.subscription.util.SubscribeAction;
|
|||
* 18Nov2008 1709 MW Fegan Initial creation
|
||||
* May 22, 2014 2536 bclement moved from autobldsrv to edex.plugin.text
|
||||
* removed duplicate SubscribeAction enum
|
||||
* Aug 22, 2014 2926 bclement improved error handling for unknown operation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -128,6 +129,11 @@ public class SubscribeRunner {
|
|||
throw new EdexException("Unable to initialize ISubscribeRunner instance; null or empty operation specified - unable to continue");
|
||||
}
|
||||
SubscribeAction action = SubscribeAction.translate(oper);
|
||||
if (action == null) {
|
||||
throw new EdexException(
|
||||
"Unable to initialize ISubscriberunner instance; unable to find action for operation ["
|
||||
+ oper + "]");
|
||||
}
|
||||
String className = action.getRunner();
|
||||
if (className == null) {
|
||||
throw new EdexException("Unable to initialize ISubscribeRunner instance; invalid operation [" + oper + "] specified - unable to continue");
|
||||
|
|
|
@ -23,12 +23,37 @@ import types
|
|||
|
||||
import lib.CommandLine as CL
|
||||
import lib.InputOutput as IO
|
||||
import lib.CommHandler as CH
|
||||
import lib.Message as MSG
|
||||
import lib.Util as util
|
||||
import subscription.SubscriptionManager as SM
|
||||
|
||||
import conf.TDBConfig as config
|
||||
import collections
|
||||
|
||||
from ufpy import ThriftClient
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.common.message import Message, Header, Property
|
||||
from dynamicserialize.dstypes.com.raytheon.uf.edex.plugin.text.dbsrv import TextDBRequest
|
||||
|
||||
##############################################################################
|
||||
# General exception to be raised when errors occur when processing messages
|
||||
##############################################################################
|
||||
class MessageError(Exception):
|
||||
def __init__(self,value,cause=None):
|
||||
self.value = value
|
||||
self.cause = cause
|
||||
def __str__(self):
|
||||
msg = 'MessageError: ' + repr(self.value)
|
||||
if self.cause is not None:
|
||||
msg += "\n caused by " + repr(self.cause)
|
||||
return msg
|
||||
def __repr__(self):
|
||||
return self.__str__()
|
||||
|
||||
# appends value to list assoticated with key in multimap if the key isn't
|
||||
# present in the map. map must be defaultdict so that list is auto created
|
||||
def appendIfNotPresent(multimap, key, value):
|
||||
if key not in multimap:
|
||||
multimap[key].append(value)
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Class implementing the text database (textdb) Command Line Interface (CLI)
|
||||
|
@ -60,6 +85,7 @@ import conf.TDBConfig as config
|
|||
# 04/07/11 8686 cjeanbap Fixed $ACTION has -i associated
|
||||
# 05/12/14 16954 kshrestha Added Multiple flag functionality for textdb
|
||||
# 08/15/14 2926 bclement Fixed hasSubOperations()
|
||||
# 08/22/14 2926 bclement Switched to ThriftClient
|
||||
##############################################################################
|
||||
class TextDB:
|
||||
|
||||
|
@ -209,24 +235,14 @@ class TextDB:
|
|||
raise IO.InputOutputError("Unable to read product from standard input",e)
|
||||
|
||||
# Generates the request message to be sent to the EDEX server.
|
||||
# The message is similar to
|
||||
# <message>
|
||||
# <header>
|
||||
# <properties name="VIEW" value="text" />
|
||||
# <properties name="OP" value="PUT" />
|
||||
# <properties name="PRODID" value="CCCNNNXX" />
|
||||
# <properties name="product" value="This is a test." />
|
||||
# </header>
|
||||
# </message>
|
||||
#
|
||||
# return:
|
||||
# the generated message in XML format
|
||||
# the generated message in a serializable object
|
||||
# raises:
|
||||
# MessageError if any error occurs
|
||||
def __generateRequestMessage(self):
|
||||
try:
|
||||
msg = MSG.Message(True)
|
||||
msg.initializeMessage(False)
|
||||
multimap = collections.defaultdict(list)
|
||||
commands = self.commands['command']
|
||||
isJoin = False
|
||||
for command in commands:
|
||||
|
@ -241,26 +257,27 @@ class TextDB:
|
|||
if isinstance(value,types.IntType):
|
||||
if args == config.MSG_VAR_ARGS:
|
||||
for item in data:
|
||||
msg.addProperty(name=key,value=item,replace=False)
|
||||
multimap[key].append(item)
|
||||
else:
|
||||
if (len(commands) == 1) or (len(commands) == 3):
|
||||
l = len(commands)
|
||||
if (l == 1) or (l == 3):
|
||||
if ((key == "SITE") and (self.commands.get("site_node") is not None) and (len(self.commands.get("site_node")) == 0)):
|
||||
val = str(os.getenv("sitename"))
|
||||
msg.addProperty(name=key,value=val,replace=True)
|
||||
appendIfNotPresent(multimap, key, val)
|
||||
elif(isJoin == True):
|
||||
msg.addProperty(name=key,value=data,replace=True)
|
||||
appendIfNotPresent(multimap, key, data)
|
||||
isJoin = False
|
||||
else:
|
||||
msg.addProperty(name=key,value=data[value],replace=True)
|
||||
appendIfNotPresent(multimap, key, data[value])
|
||||
else:
|
||||
msg.addProperty(name=key,value=data,replace=True)
|
||||
appendIfNotPresent(multimap, key, data)
|
||||
else:
|
||||
msg.addProperty(name=key,value=value,replace=True)
|
||||
appendIfNotPresent(multimap, key, value)
|
||||
operationalMode = os.getenv("OPERATIONAL_MODE", 'TRUE')
|
||||
msg.addProperty(name='operational',value=operationalMode,replace=False)
|
||||
return msg.getXML()
|
||||
multimap['operational'].append(operationalMode)
|
||||
return Message(header=Header(multimap=multimap))
|
||||
except Exception,e:
|
||||
raise MSG.MessageError('unable to create message for textdb request',e)
|
||||
raise MessageError('unable to create message for textdb request',e)
|
||||
|
||||
# reads the command line and sets up the command data structure
|
||||
#
|
||||
|
@ -324,14 +341,12 @@ class TextDB:
|
|||
# return:
|
||||
# 0 if the message contained valid results, 0 otherwise
|
||||
def __processRequestResponse(self,msg):
|
||||
psr = MSG.Message(True)
|
||||
psr.parse(msg)
|
||||
status = 0
|
||||
io = IO.InputOutput()
|
||||
# process the return message
|
||||
for prop in psr.getProperties():
|
||||
name = prop['name']
|
||||
value = prop['value']
|
||||
for prop in msg.getHeader().getProperties():
|
||||
name = prop.getName()
|
||||
value = prop.getValue()
|
||||
if name == 'STDERR':
|
||||
parts = value.split(':',2)
|
||||
if parts[0] == 'ERROR':
|
||||
|
@ -344,8 +359,6 @@ class TextDB:
|
|||
return status
|
||||
|
||||
# Submits the request to the server and waits for a response.
|
||||
# Does a quick check to eliminate an invalid response from the
|
||||
# server.
|
||||
#
|
||||
# args:
|
||||
# msg: the message to submit to the server
|
||||
|
@ -353,22 +366,16 @@ class TextDB:
|
|||
# the message received from the from the server,
|
||||
# or Null if a connection error occurred.
|
||||
# raise:
|
||||
# CommError if any error occurred.
|
||||
# ThriftRequestException if any error occurred.
|
||||
def __submitRequestMessage(self,msg):
|
||||
try:
|
||||
runner = self.commands.get('runner')
|
||||
service = config.endpoint.get(runner)
|
||||
|
||||
# send the request to the server
|
||||
connection=str(os.getenv("DEFAULT_HOST", "localhost") + ":" + os.getenv("DEFAULT_PORT", "9581"))
|
||||
ch = CH.CommHandler(connection,service)
|
||||
ch.process(msg)
|
||||
if not ch.isGoodStatus():
|
||||
util.reportHTTPResponse(ch.formatResponse())
|
||||
return None
|
||||
return ch.getContents()
|
||||
except Exception,e:
|
||||
raise CH.CommError("Unable to submit request to server",e)
|
||||
host = os.getenv("DEFAULT_HOST", "localhost")
|
||||
port = os.getenv("DEFAULT_PORT", "9581")
|
||||
tClient = ThriftClient.ThriftClient(host, port)
|
||||
req = TextDBRequest()
|
||||
req.setMessage(msg)
|
||||
return tClient.sendRequest(req)
|
||||
|
||||
# Handles the LDAD (script) requests by
|
||||
# 1. morphing the command line to match the micro-engine command line
|
||||
# 2. passing the modified command line to the micro-engine client
|
||||
|
@ -412,7 +419,7 @@ class TextDB:
|
|||
self.__deleteWatchWarn()
|
||||
self.__deleteSubscriptions()
|
||||
except Exception,e:
|
||||
raise MSG.MessageError('unable to create message for textdb request',e)
|
||||
raise MessageError('unable to create message for textdb request',e)
|
||||
try:
|
||||
for i in range(len(args)):
|
||||
f = open(args[i],'r')
|
||||
|
@ -423,21 +430,21 @@ class TextDB:
|
|||
try:
|
||||
values = line.split(' ', 1)
|
||||
try:
|
||||
msg = MSG.Message(True)
|
||||
msg.initializeMessage(False)
|
||||
msg.addProperty(name='VIEW',value='warn',replace=False)
|
||||
msg.addProperty(name='OP',value='PUT',replace=False)
|
||||
msg.addProperty(name='PRODID',value=values[0],replace=False)
|
||||
msg.addProperty(name='SCRIPT',value=values[1],replace=False)
|
||||
props = []
|
||||
props.append(Property(name='VIEW',value='warn'))
|
||||
props.append(Property(name='OP',value='PUT'))
|
||||
props.append(Property(name='PRODID',value=values[0]))
|
||||
props.append(Property(name='SCRIPT',value=values[1]))
|
||||
msg = Message(header=Header(props))
|
||||
except Exception,e:
|
||||
raise MSG.MessageError('unable to create message for textdb request',e)
|
||||
raise MessageError('unable to create message for textdb request',e)
|
||||
|
||||
if ((len(values[0]) >= 8) & (len(values[1].strip('\r\n')) > 0)):
|
||||
# print "Insert Subscription [" + values[0] + "] Status:" + str(sm.execute())
|
||||
cline = ['-o','add', '-t','ldad', '-r','ldad', '-p', values[0], '-f', values[1], '-c','%TRIGGER%']
|
||||
sm = SM.SubscriptionManager(name='textdb',args=cline)
|
||||
sm.execute()
|
||||
msg = self.__submitRequestMessage(msg.getXML())
|
||||
msg = self.__submitRequestMessage(msg)
|
||||
status = self.__processRequestResponse(msg)
|
||||
except ValueError:
|
||||
util.printMessage(sys.stderr,
|
||||
|
@ -446,7 +453,7 @@ class TextDB:
|
|||
finally:
|
||||
f.close()
|
||||
else:
|
||||
raise MSG.MessageError('Unable to locate file: ' + args[0])
|
||||
raise MessageError('Unable to locate file: ' + args[0])
|
||||
else:
|
||||
self.__deleteSubscriptions()
|
||||
return
|
||||
|
@ -455,11 +462,10 @@ class TextDB:
|
|||
#
|
||||
#
|
||||
def __deleteWatchWarn(self):
|
||||
msg = MSG.Message(True)
|
||||
msg.initializeMessage(False)
|
||||
msg.addProperty(name='VIEW',value='warn',replace=False)
|
||||
msg.addProperty(name='OP',value='DELETE',replace=False)
|
||||
msg = self.__submitRequestMessage(msg.getXML())
|
||||
props = []
|
||||
props.append(Property(name='VIEW',value='warn'))
|
||||
props.append(Property(name='OP',value='DELETE'))
|
||||
msg = self.__submitRequestMessage(Message(header=Header(props)))
|
||||
status = self.__processRequestResponse(msg)
|
||||
|
||||
#
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
class Body(object):
|
||||
|
||||
def __init__(self):
|
||||
self.responses = None
|
||||
|
||||
def getResponses(self):
|
||||
return self.responses
|
||||
|
||||
def setResponses(self, responses):
|
||||
self.responses = responses
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
from Property import Property
|
||||
|
||||
class Header(object):
|
||||
|
||||
def __init__(self, properties=None, multimap=None):
|
||||
if properties is None:
|
||||
self.properties = []
|
||||
else:
|
||||
self.properties = properties
|
||||
|
||||
if multimap is not None:
|
||||
for k, l in multimap.iteritems():
|
||||
for v in l:
|
||||
self.properties.append(Property(k, v))
|
||||
|
||||
def getProperties(self):
|
||||
return self.properties
|
||||
|
||||
def setProperties(self, properties):
|
||||
self.properties = properties
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
class Message(object):
|
||||
|
||||
def __init__(self, header=None, body=None):
|
||||
self.header = header
|
||||
self.body = body
|
||||
|
||||
def getHeader(self):
|
||||
return self.header
|
||||
|
||||
def setHeader(self, header):
|
||||
self.header = header
|
||||
|
||||
def getBody(self):
|
||||
return self.body
|
||||
|
||||
def setBody(self, body):
|
||||
self.body = body
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
class Property(object):
|
||||
|
||||
def __init__(self, name=None, value=None):
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
def setName(self, name):
|
||||
self.name = name
|
||||
|
||||
def getValue(self):
|
||||
return self.value
|
||||
|
||||
def setValue(self, value):
|
||||
self.value = value
|
||||
|
|
@ -18,6 +18,13 @@
|
|||
# further licensing information.
|
||||
##
|
||||
|
||||
__all__ = [
|
||||
'Body',
|
||||
'Header',
|
||||
'Message',
|
||||
'Property',
|
||||
'WsId'
|
||||
]
|
||||
|
||||
#
|
||||
# Package definition for com.raytheon.uf.common.message
|
||||
|
@ -28,13 +35,13 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 09/16/10 dgilling Initial Creation.
|
||||
#
|
||||
# 08/19/14 2926 bclement added Message files
|
||||
#
|
||||
#
|
||||
|
||||
|
||||
__all__ = [
|
||||
'WsId'
|
||||
]
|
||||
|
||||
from Body import Body
|
||||
from Header import Header
|
||||
from Message import Message
|
||||
from Property import Property
|
||||
from WsId import WsId
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'plugin'
|
||||
]
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'text'
|
||||
]
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'dbsrv'
|
||||
]
|
||||
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated against equivalent DynamicSerialize Java class
|
||||
|
||||
class TextDBRequest(object):
|
||||
|
||||
def __init__(self):
|
||||
self.message = None
|
||||
|
||||
def getMessage(self):
|
||||
return self.message
|
||||
|
||||
def setMessage(self, message):
|
||||
self.message = message
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
##
|
||||
# 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.
|
||||
##
|
||||
|
||||
# File auto-generated by PythonFileGenerator
|
||||
|
||||
__all__ = [
|
||||
'TextDBRequest'
|
||||
]
|
||||
|
||||
from TextDBRequest import TextDBRequest
|
||||
|
Loading…
Add table
Reference in a new issue