From 537829c74ce81daf7449f5cd848d937466d54fc8 Mon Sep 17 00:00:00 2001 From: ucar-tmeyer Date: Thu, 25 Aug 2022 08:27:38 -0700 Subject: [PATCH] Number of initial Warngen Changes to make it ready for Unidata use. com.raytheon.viz.textworkstation ------------------------------------ plugin.xml -Added section to add "Text Workstation" to the Tools menu -Removed the extension for paths to COMMON_STATIC/CAVE_STATIC TextWorkstatinDlg.java -Commented out the showing of the first text editor com.raytheon.viz.warngen ------------------------------- MANIFEST.MF -Added the textworkstation viz plugin to the import-package list plugin.xml -Remove menu context for warngen button to show up (this is now in com.raytheon.uf.viz.d2d.ui/plugin.xml) comm/WarningSender.java -Deleted this file template/TemplateRunner.java -Remove backupData gui/WarngenDialog.java -Simplify Warngen Dialog -Bypass JMS messaging and send directly to a textWS Window -Allows proper resizing -Change bulletlist functionality so it doesn't scroll to top after selection -Only resize the bullet list, not the whole GUI -Set proper clumumn number in layout -Disable UPDATE LIST combobox gui/WarngenLayer.java -Remove some backupsite/office variables com.raytheon.viz.texteditor --------------------------------- TextWorkstationPreferences.java -Delete file dialogs/AWIPSHeaderBlockDlg.java -Non-operationalize dialogs/RemoteSiteRequestDlg.java -Delete file dialogs/TextEditorDialog.java -Non-operationalize dialogs/WarnGenConfirmationDlg.java -delete file fxa/dialogs/FaxMesssageDlg.java -Delete file fxa/dialogs/FaxSitEditorDlg.java -Delete file fxa/dialogs/LdadFaxSitesDlg.java -Delete file com.raytheon.uf.edex.dissemination ------------------------------------- -Delete whole plugin --- .../TextWorkstationPreferences.java | 196 ----- .../dialogs/AWIPSHeaderBlockDlg.java | 13 +- .../dialogs/RemoteSiteRequestDlg.java | 749 ------------------ .../texteditor/dialogs/TextEditorDialog.java | 541 +------------ .../dialogs/WarnGenConfirmationDlg.java | 203 ----- .../texteditor/fax/dialogs/FaxMessageDlg.java | 294 ------- .../fax/dialogs/FaxSiteEditorDlg.java | 408 ---------- .../fax/dialogs/LdadFaxSitesDlg.java | 547 ------------- .../plugin.xml | 40 +- .../textworkstation/TextWorkstationDlg.java | 3 +- .../META-INF/MANIFEST.MF | 1 + cave/com.raytheon.viz.warngen/plugin.xml | 23 - .../viz/warngen/comm/WarningSender.java | 283 ------- .../viz/warngen/gui/WarngenDialog.java | 516 ++++-------- .../viz/warngen/gui/WarngenLayer.java | 122 +-- .../viz/warngen/template/TemplateRunner.java | 9 +- .../.classpath | 7 - .../.project | 34 - .../.pydevproject | 5 - .../META-INF/MANIFEST.MF | 32 - .../build.properties | 6 - .../com.raytheon.uf.edex.dissemination.ecl | 0 .../res/spring/dissemination-ingest.xml | 13 - .../res/spring/dissemination-request.xml | 50 -- .../uf/edex/dissemination/ModifyProduct.java | 239 ------ .../uf/edex/dissemination/OUPAckManager.java | 189 ----- .../uf/edex/dissemination/OUPHandler.java | 219 ----- .../dissemination/OUPHeaderException.java | 52 -- .../uf/edex/dissemination/OUPTestHandler.java | 48 -- .../edex/dissemination/StatusConstants.java | 44 - ...isseminationNationalDatasetSubscriber.java | 151 ---- .../transmitted/TransProdHeader.java | 95 --- .../transmitted/TransmittedProductList.java | 188 ----- .../base/dissemination/awipsPriorities.txt | 132 --- .../base/dissemination/handleOUP.py | 594 -------------- .../base/dissemination/rcv_action2codes.txt | 10 - 36 files changed, 185 insertions(+), 5871 deletions(-) delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationPreferences.java delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java delete mode 100644 cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java delete mode 100644 cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/comm/WarningSender.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/.classpath delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/.project delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/.pydevproject delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/META-INF/MANIFEST.MF delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/build.properties delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/com.raytheon.uf.edex.dissemination.ecl delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-ingest.xml delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPAckManager.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHandler.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHeaderException.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPTestHandler.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/StatusConstants.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ingest/DisseminationNationalDatasetSubscriber.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransProdHeader.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransmittedProductList.java delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/awipsPriorities.txt delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/handleOUP.py delete mode 100644 edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/rcv_action2codes.txt diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationPreferences.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationPreferences.java deleted file mode 100644 index 0728b8c217..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/TextWorkstationPreferences.java +++ /dev/null @@ -1,196 +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.viz.texteditor; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.time.Duration; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -import com.raytheon.uf.common.status.IUFStatusHandler; -import com.raytheon.uf.common.status.UFStatus; - -/** - * Text Workstation preferences page in CAVE - * - *
- *
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 11, 2009            mschenke     Initial creation
- * Apr 20, 2020 8137       tgurney      Add Validate button instead of using
- *                                      automatic validation
- *
- * 
- * - * @author mschenke - */ - -public class TextWorkstationPreferences extends FieldEditorPreferencePage - implements IWorkbenchPreferencePage { - - private final IUFStatusHandler statusHandler = UFStatus - .getHandler(getClass()); - - private HostStringFieldEditor hostEditor; - - public TextWorkstationPreferences() { - super(GRID); - setPreferenceStore(TextWorkstationConstants.getPreferenceStore()); - setDescription("Specify the host for Text Workstation communication." - + " Should be the network accessible host of workstation as seen" - + " in the Text Workstation dialog."); - } - - private class HostStringFieldEditor extends StringFieldEditor { - - public HostStringFieldEditor(String name, String labelText, int width, - Composite parent) { - super(name, labelText, width, parent); - } - - private String ip; - - private boolean resolve(String host) throws InterruptedException { - try { - ip = InetAddress.getByName(host).getHostAddress(); - return true; - } catch (UnknownHostException e) { - /* - * The UI will indicate that the validation failed, so this does - * not have to be any higher than debug. - */ - statusHandler.debug(e.getLocalizedMessage(), e); - } - return false; - } - - private boolean resolveWithTimeout(String host, Duration timeout) - throws InterruptedException, ExecutionException { - ExecutorService executor = Executors.newSingleThreadExecutor(); - try { - Future hostResolved = executor - .submit(() -> resolve(host)); - return hostResolved.get(timeout.toMillis(), - TimeUnit.MILLISECONDS); - } catch (TimeoutException e) { - statusHandler.warn("Attempt to resolve " + host + " timed out", - e); - } catch (ExecutionException e) { - statusHandler.warn("Failed to resolve " + host, e); - } catch (InterruptedException e) { - // ignore - } finally { - executor.shutdownNow(); - } - return false; - } - - @Override - protected void doStore() { - if (!validate()) { - return; - } - boolean rval = true; - if (ip != null && ip.startsWith("127.0.")) { - rval = MessageDialog.openQuestion(getShell(), "Confirm", - "The host string you entered maps to a localhost" - + " ip address, are you sure this is" - + " the host name as seen in the Text Workstation dialog?"); - } - if (rval) { - super.doStore(); - } - } - - public boolean validate() { - boolean hostResolved = false; - try { - String host = getTextControl().getText(); - hostResolved = resolveWithTimeout(host, Duration.ofSeconds(5)); - } catch (Exception e) { - statusHandler.warn(e.getLocalizedMessage(), e); - } finally { - int color = hostResolved ? SWT.COLOR_WHITE : SWT.COLOR_RED; - getTextControl().setBackground( - getShell().getDisplay().getSystemColor(color)); - if (hostResolved) { - clearErrorMessage(); - } else { - showErrorMessage(); - } - } - setValid(hostResolved); - return hostResolved; - } - } - - @Override - protected void createFieldEditors() { - // Make sure we grab the env variable if needed - TextWorkstationConstants.getId(); - hostEditor = new HostStringFieldEditor( - TextWorkstationConstants.P_TEXTWORKSTATION_ID, - "Text Workstation host: ", StringFieldEditor.UNLIMITED, - getFieldEditorParent()); - hostEditor.setErrorMessage( - "Unable to validate hostname for text workstation"); - addField(hostEditor); - addValidateBtn(); - } - - private void addValidateBtn() { - GridData gd = new GridData(SWT.RIGHT, SWT.CENTER, true, false); - gd.horizontalSpan = 2; - Button validateBtn = new Button(getFieldEditorParent(), SWT.PUSH); - validateBtn.setText("Validate"); - validateBtn.setLayoutData(gd); - validateBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - hostEditor.validate(); - } - }); - } - - @Override - public void init(IWorkbench workbench) { - // TODO Auto-generated method stub - } - -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java index 5fd1a8fbde..a5ac3cd2e7 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/AWIPSHeaderBlockDlg.java @@ -107,6 +107,8 @@ import com.raytheon.viz.ui.dialogs.ICloseCallback; * Dec 10, 2018 7678 tgurney Take initial WMO ID from afos2awips * (with WMO ID from the product as fallback) * Mar 13, 2020 21048 mgamazaychikov Get wmoid from text product + * Jun 24, 2019 ---- mjames Non-operationalize Warngen + * * * @@ -691,8 +693,8 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog logHeaderBlock("Enter button clicked. AWIPS Header Block values:"); - boolean sendEnabled = true; - boolean unOfficialProd = false; + boolean sendEnabled = false; + boolean unOfficialProd = true; if (!isProductValid()) { // Notify the user that the product may not be valid. // @@ -710,13 +712,6 @@ public class AWIPSHeaderBlockDlg extends CaveSWTDialog if (response == SWT.NO || parentEditor.isDisposed()) { return; } - parentEditor.enableSend(false); - sendEnabled = false; - if (isAfosPilComplete()) { - unOfficialProd = true; - } - } else { - parentEditor.enableSend(true); } // call the set methods diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java deleted file mode 100644 index 2640412eec..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/RemoteSiteRequestDlg.java +++ /dev/null @@ -1,749 +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.viz.texteditor.dialogs; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.VerifyListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.raytheon.uf.common.dataplugin.text.AfosWmoIdDataContainer; -import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; -import com.raytheon.uf.common.dataplugin.text.db.StdTextProduct; -import com.raytheon.uf.common.dataplugin.text.request.GetWmoIdRequest; -import com.raytheon.uf.common.dataplugin.text.request.RemoteRetrievalRequest; -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.common.time.util.TimeUtil; -import com.raytheon.uf.common.util.SystemUtil; -import com.raytheon.uf.common.wmo.WMOHeader; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.requests.ThriftClient; -import com.raytheon.viz.texteditor.command.CommandFactory; -import com.raytheon.viz.texteditor.command.CommandFailedException; -import com.raytheon.viz.texteditor.msgs.IWmoIdSelectionCallback; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * The Remote Site Request dialog. - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date          Ticket#  Engineer  Description
- * ------------- -------- --------- --------------------------------------------
- * Sep 13, 2007  368      lvenable  Initial creation.
- * Oct 11, 2007  482      grichard  Reformatted file.
- * Sep 20, 2012  1196     rferrel   Changing dialogs being called to not block.
- * Sep 09, 2014  3580     mapeters  Removed IQueryTransport usage (no longer
- *                                  exists).
- * Aug 31, 2015  4749     njensen   Changed setCloseCallback to addCloseCallback
- * Aug 28, 2018  7134     randerso  Reworked dialog for new remote request
- *                                  implementation
- *
- * 
- * - * @author lvenable - */ -public class RemoteSiteRequestDlg extends CaveSWTDialog - implements IWmoIdSelectionCallback { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(RemoteSiteRequestDlg.class); - - // pattern used to parse the site id from a standard dx server hostname - private static final Pattern ADDRESS_PATTERN = Pattern - .compile("d[xv]\\d-(\\w{3,4})\\.?.*"); - - private Text ttaaiiTF; - - private Text ccccTF; - - /** - * AFOS site ID text field. - */ - private Text wsfoIdTF; - - /** - * Product category text field. - */ - private Text productCatTF; - - /** - * Product designator text field. - */ - private Text prodDesignatorTF; - - /** - * Address text field. Defines the site where a text product or message is - * sent. - */ - private Text addresseeTF; - - private Button overrideBtn; - - private Text overrideTF; - - private Label addresseeValid; - - private List inputFields; - - private int currentField; - - private Button enterBtn; - - private RemoteRetrievalRequest lastRemoteRetrievalRequest; - - private WmoIdSelectionDialog wmoIdSelectionDialog; - - private boolean lookupAllowed = true; - - private String addressee; - - /** - * Constructor. - * - * @param parent - * Parent shell. - * @param lastRemoteRetrievalRequest - * last RemoteRetrievalRequest used to initialize dialog - */ - public RemoteSiteRequestDlg(Shell parent, - RemoteRetrievalRequest lastRemoteRetrievalRequest) { - super(parent, SWT.DIALOG_TRIM, - CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); - setText("Send Request"); - this.lastRemoteRetrievalRequest = lastRemoteRetrievalRequest; - } - - @Override - protected Layout constructShellLayout() { - return new GridLayout(1, false); - } - - @Override - protected Object constructShellLayoutData() { - return new GridData(); - } - - @Override - protected void initializeComponents(Shell shell) { - createInputFields(); - createBottomButtons(); - checkEnableEnter(); - } - - /** - * Create the input fields. - */ - private void createInputFields() { - inputFields = new ArrayList<>(); - - Composite topComp = new Composite(shell, SWT.NONE); - GridLayout gridLayout = new GridLayout(1, false); - gridLayout.verticalSpacing = 0; - shell.setLayout(gridLayout); - - gridLayout = new GridLayout(2, false); - gridLayout.marginLeft = 1; - gridLayout.marginTop = 1; - gridLayout.horizontalSpacing = 20; - topComp.setLayout(gridLayout); - GridData gd = null; - Label sepLbl = null; - - ttaaiiTF = new Text(topComp, SWT.BORDER | SWT.READ_ONLY); - - GC gc = new GC(ttaaiiTF); - int charWidth = gc.textExtent("W").x; - gc.dispose(); - - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 6; - ttaaiiTF.setLayoutData(gd); - ttaaiiTF.setEnabled(false); - ttaaiiTF.setEditable(false); - ttaaiiTF.setBackground(shell.getBackground()); - - Label ttaaiiLbl = new Label(topComp, SWT.NONE); - ttaaiiLbl.setText("TTAAii"); - - ccccTF = new Text(topComp, SWT.BORDER | SWT.READ_ONLY); - ccccTF.setEnabled(false); - ccccTF.setEditable(false); - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 4; - ccccTF.setLayoutData(gd); - ccccTF.setBackground(shell.getBackground()); - Label ccccLbl = new Label(topComp, SWT.NONE); - ccccLbl.setText("CCCC"); - - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - // Create the WSFO ID text field. - wsfoIdTF = new Text(topComp, SWT.BORDER); - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 3; - wsfoIdTF.setLayoutData(gd); - wsfoIdTF.setTextLimit(3); - - // set value for limitCheck used in modifyListener - wsfoIdTF.setData(true); - - Label wsfoIdLbl = new Label(topComp, SWT.NONE); - wsfoIdLbl.setText("WSFO Identification"); - - // Create the product category text field. - productCatTF = new Text(topComp, SWT.BORDER); - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 3; - productCatTF.setLayoutData(gd); - productCatTF.setTextLimit(3); - - // set value for limitCheck used in modifyListener - productCatTF.setData(true); - - Label productCatLbl = new Label(topComp, SWT.NONE); - productCatLbl.setText("Product Category"); - - // Create the product designator text field. - prodDesignatorTF = new Text(topComp, SWT.BORDER); - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 3; - prodDesignatorTF.setLayoutData(gd); - prodDesignatorTF.setTextLimit(3); - - // set value for limitCheck used in modifyListener - prodDesignatorTF.setData(false); - - Label prodDesignatorLbl = new Label(topComp, SWT.NONE); - prodDesignatorLbl.setText("Product Designator"); - - gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - sepLbl = new Label(topComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - // Create the addressee text field. - addresseeTF = new Text(topComp, SWT.BORDER); - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - gd.widthHint = charWidth * 4; - addresseeTF.setLayoutData(gd); - addresseeTF.setTextLimit(4); - - Label addresseeLbl = new Label(topComp, SWT.NONE); - addresseeLbl.setText("Addressee"); - - Composite overrideComp = new Composite(shell, SWT.NONE); - gridLayout = new GridLayout(2, false); - gridLayout.horizontalSpacing = 0; - gridLayout.marginHeight = 0; - gridLayout.marginBottom = 5; - overrideComp.setLayout(gridLayout); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - overrideComp.setLayoutData(gd); - - overrideBtn = new Button(overrideComp, SWT.CHECK); - overrideBtn.setText("Override Addressee"); - - overrideTF = new Text(overrideComp, SWT.BORDER); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - overrideTF.setLayoutData(gd); - overrideTF.setEnabled(false); - - addresseeValid = new Label(overrideComp, SWT.NONE); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = 2; - addresseeValid.setLayoutData(gd); - - setupTextFieldListeners(); - - gd = new GridData(GridData.FILL_HORIZONTAL); - sepLbl = new Label(shell, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - - String ccc = ""; - String nnn = ""; - String xxx = ""; - String addr = "WNCF"; - if (lastRemoteRetrievalRequest != null) { - String initialAfosID = lastRemoteRetrievalRequest.getAfosID(); - ccc = initialAfosID.substring(0, 3); - nnn = initialAfosID.substring(3, 6); - xxx = initialAfosID.substring(6); - - Matcher m = ADDRESS_PATTERN - .matcher(lastRemoteRetrievalRequest.getAddressee()); - if (m.matches()) { - addr = m.group(1); - } else { - overrideBtn.setSelection(true); - overrideTF.setText(lastRemoteRetrievalRequest.getAddressee()); - overrideTF.setEnabled(true); - addresseeTF.setEnabled(false); - } - } - - wsfoIdTF.setText(ccc); - productCatTF.setText(nnn); - prodDesignatorTF.setText(xxx); - addresseeTF.setText(addr); - } - - private void setupTextFieldListeners() { - /* - * force all fields to upper case and only allows numbers/digits - */ - textFieldVerifyListener(wsfoIdTF, productCatTF, prodDesignatorTF, - addresseeTF); - - /* - * force overwrite and arrow key traversal - */ - textFieldKeyListener(wsfoIdTF, productCatTF, prodDesignatorTF, - addresseeTF, overrideTF); - - /* - * lookup WMO IDs when wsfo id, cat, or designator are updated - */ - textFieldModifyListener(wsfoIdTF, productCatTF, prodDesignatorTF); - - /* - * update override text when addressee modified - */ - addresseeTF.addModifyListener(e -> updateOverrideTF()); - - /* - * handle override check box selection - */ - overrideBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - boolean override = overrideBtn.getSelection(); - addresseeTF.setEnabled(!override); - overrideTF.setEnabled(override); - if (override) { - overrideTF.setFocus(); - overrideTF.selectAll(); - } else { - addresseeTF.setFocus(); - addresseeTF.selectAll(); - updateOverrideTF(); - } - } - }); - - overrideTF.addModifyListener(e -> { - addresseeIsValid(); - checkEnableEnter(); - }); - } - - private void updateOverrideTF() { - if (addresseeTF.isEnabled()) { - overrideTF.setText("edexcluster-" + addresseeTF.getText().toLowerCase()); - addresseeIsValid(); - checkEnableEnter(); - } - } - - private boolean addresseeIsValid() { - boolean valid; - String host = overrideTF.getText(); - try { - InetAddress address = InetAddress.getByName(host); - valid = true; - this.addressee = SystemUtil.getHostName(address); - } catch (UnknownHostException e) { - // not logging this as it is expected - valid = false; - } - addresseeValid.setText("Addressee " + (valid ? "valid" : "invalid")); - - return valid; - } - - /** - * Create the bottom Enter and Cancel buttons. - */ - private void createBottomButtons() { - // Create a composite that will center added controls/composites. - Composite buttonArea = new Composite(shell, SWT.NONE); - buttonArea.setLayoutData( - new GridData(SWT.CENTER, SWT.DEFAULT, true, false)); - buttonArea.setLayout(new GridLayout(1, false)); - - // Create a composite to hold the enter and cancel buttons. - Composite buttons = new Composite(buttonArea, SWT.NONE); - buttons.setLayout(new GridLayout(2, true)); - - // Create the Enter button. - enterBtn = new Button(buttons, SWT.PUSH); - enterBtn.setLayoutData(new GridData(GridData.FILL_BOTH)); - enterBtn.setText("Enter"); - - // Create the Cancel button. - Button cancelBtn = new Button(buttons, SWT.PUSH); - cancelBtn.setLayoutData(new GridData(GridData.FILL_BOTH)); - cancelBtn.setText("Cancel"); - - SelectionAdapter selectionAdapter = new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - buttonPressed((Button) event.widget); - } - }; - enterBtn.addSelectionListener(selectionAdapter); - cancelBtn.addSelectionListener(selectionAdapter); - } - - private void buttonPressed(Button button) { - if (button == enterBtn) { - if (!createReturnValue()) { - return; - } - } else { - setReturnValue(null); - } - shell.close(); - } - - private Calendar createCalRelativeTo(long relative, WMOHeader wmoHeader, - int monthAdjustment) { - Calendar c = TimeUtil.newGmtCalendar(relative); - c.add(GregorianCalendar.MONTH, monthAdjustment); - c.set(GregorianCalendar.DAY_OF_MONTH, wmoHeader.getDay()); - c.set(GregorianCalendar.HOUR_OF_DAY, wmoHeader.getHour()); - c.set(GregorianCalendar.MINUTE, wmoHeader.getMinute()); - c.set(GregorianCalendar.SECOND, 0); - c.set(GregorianCalendar.MILLISECOND, 0); - return c; - } - - private Calendar getCloserCalendar(long reference, Calendar a, Calendar b) { - return Math.abs(a.getTimeInMillis() - reference) < Math - .abs(b.getTimeInMillis() - reference) ? a : b; - } - - private boolean createReturnValue() { - String ccc = wsfoIdTF.getText(); - String nnn = productCatTF.getText(); - String xxx = prodDesignatorTF.getText(); - if (ccc.length() != 3 || nnn.length() != 3 || xxx.isEmpty()) { - return false; - } - - String afosID = ccc + nnn + xxx; - GetWmoIdRequest request = new GetWmoIdRequest(); - request.setAfosId(afosID); - - RemoteRetrievalRequest req = new RemoteRetrievalRequest(); - req.setAddressee(addressee); - req.setAfosID(afosID); - - List latest = null; - try { - latest = CommandFactory.getAfosCommand(req.getAfosID()) - .executeCommand(); - } catch (CommandFailedException e) { - statusHandler.handle(Priority.PROBLEM, "Error retrieving metadata", - e); - // but keep going... - } - - if (latest != null && !latest.isEmpty()) { - long time = latest.get(0).getRefTime(); - req.setMostRecentTime(time); - try { - WMOHeader wmo = new WMOHeader( - latest.get(0).getProduct().getBytes()); - Calendar t = getCloserCalendar(time, - createCalRelativeTo(time, wmo, 0), - createCalRelativeTo(time, wmo, 1)); - t = getCloserCalendar(time, t, - createCalRelativeTo(time, wmo, -1)); - req.setMostRecentTime(t.getTimeInMillis()); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error determining product time", e); - } - } else { - req.setMostRecentTime(0); - } - - String ttaaii = ttaaiiTF.getText(); - String cccc = ccccTF.getText(); - if (ttaaii.length() > 0 && cccc.length() > 0) { - req.setWmoHeader(ttaaii + " " + cccc); - } else { - req.setWmoHeader(""); - } - - req.setValidTime(System.currentTimeMillis() + 600 * 1000); // Current - // time plus - // 10 minutes - - setReturnValue(req); - return true; - } - - private void textFieldKeyListener(Text... fields) { - KeyAdapter keyAdapter = new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - Text tf = (Text) e.widget; - char c = e.character; - - if (Character.isLetterOrDigit(c) || Character.isSpaceChar(c)) { - int pos = tf.getCaretPosition(); - String text = tf.getText(); - - if (text.length() > pos) { - StringBuilder b = new StringBuilder(text); - b.deleteCharAt(pos); - tf.setText(b.toString()); - tf.setSelection(pos); - } - } else if (e.keyCode == SWT.ARROW_UP) { - traverseFields(-1); - } else if (e.keyCode == SWT.ARROW_DOWN) { - traverseFields(1); - } else if (e.character == SWT.CR) { - if (enterBtn.isEnabled()) { - buttonPressed(enterBtn); - } - } - } - }; - - FocusListener focusListener = new FocusListener() { - @Override - public void focusLost(FocusEvent e) { - ((Text) e.widget).clearSelection(); - } - - @Override - public void focusGained(FocusEvent e) { - currentField = inputFields.indexOf(e.widget); - } - }; - - for (Text tf : fields) { - inputFields.add(tf); - tf.addKeyListener(keyAdapter); - tf.addFocusListener(focusListener); - } - } - - private void textFieldVerifyListener(Text... fields) { - /* - * force all fields to upper case and only allows numbers/digits - */ - VerifyListener verifyListener = e -> { - e.text = e.text.toUpperCase(); - StringBuilder b = null; - int posMod = 0; - char[] chars = e.text.toCharArray(); - for (int i = 0; i < chars.length; i++) { - char c = chars[i]; - if (!Character.isLetterOrDigit(c) - && !Character.isSpaceChar(c)) { - if (b == null) { - b = new StringBuilder(e.text); - } - b.deleteCharAt(i - posMod); - posMod++; - } - } - - if (b != null) { - e.text = b.toString(); - } - }; - - for (Text tf : fields) { - tf.addVerifyListener(verifyListener); - } - } - - private void textFieldModifyListener(Text... fields) { - ModifyListener modifyListener = event -> { - Text tf = (Text) event.widget; - Boolean limitCheck = (Boolean) tf.getData(); - if (!limitCheck || tf.getCharCount() == tf.getTextLimit()) { - if (wmoIdSelectionDialog == null) { - lookupWmoIDs(); - } else { - wmoIdSelectionDialog.close(); - wmoIdSelectionDialog = null; - lookupWmoIDs(); - } - } else { - if (wmoIdSelectionDialog != null) { - wmoIdSelectionDialog.close(); - wmoIdSelectionDialog = null; - } - setWmoId("", ""); - checkEnableEnter(); - } - - if (!isDisposed()) { - if (tf.getCaretPosition() == tf.getTextLimit()) { - traverseFields(1); - } - - checkEnableEnter(); - } - }; - - for (Text tf : fields) { - tf.addModifyListener(modifyListener); - } - } - - private void traverseFields(int increment) { - currentField += increment; - if (currentField < 0) { - currentField = inputFields.size() - 1; - } else if (currentField >= inputFields.size()) { - currentField = 0; - } - - Text field = inputFields.get(currentField); - if (!field.getEnabled()) { - traverseFields(increment); - } else { - field.setFocus(); - field.selectAll(); - } - } - - private void lookupWmoIDs() { - if (lookupAllowed && wsfoIdTF.getCharCount() == wsfoIdTF.getTextLimit() - && productCatTF.getCharCount() == productCatTF.getTextLimit() - && prodDesignatorTF.getText().length() > 0) { - GetWmoIdRequest request = new GetWmoIdRequest(); - request.setAfosId(wsfoIdTF.getText() + productCatTF.getText() - + prodDesignatorTF.getText()); - lookupAllowed = false; - - try { - Object response = ThriftClient.sendRequest(request); - if (response != null) { - if (response instanceof AfosWmoIdDataContainer) { - AfosWmoIdDataContainer container = (AfosWmoIdDataContainer) response; - if (container.getErrorMessage() != null) { - statusHandler.handle(Priority.PROBLEM, - "Error occurred looking up WMO IDs\nMessage from server[" - + container.getErrorMessage() - + "]"); - } - - List list = container.getIdList(); - - if (list.size() > 1) { - List ttaaiiIds = new ArrayList<>( - list.size()); - List ccccIds = new ArrayList<>(list.size()); - for (AfosToAwips id : list) { - ttaaiiIds.add(id.getWmottaaii()); - ccccIds.add(id.getWmocccc()); - } - - wmoIdSelectionDialog = new WmoIdSelectionDialog( - shell, this, ttaaiiIds, ccccIds); - wmoIdSelectionDialog - .addCloseCallback(returnValue -> { - lookupAllowed = true; - wmoIdSelectionDialog = null; - }); - wmoIdSelectionDialog.setBlockOnOpen(false); - wmoIdSelectionDialog.open(); - return; - } else if (list.size() == 1) { - AfosToAwips id = list.get(0); - setWmoId(id.getWmottaaii(), id.getWmocccc()); - } else { - setWmoId("", ""); - } - checkEnableEnter(); - } else { - statusHandler.handle(Priority.PROBLEM, - "Received unhandled WMO Id lookup response from server. Received obj of type [" - + response.getClass() + "], contents[" - + response + "]"); - } - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error occurred looking up WMO IDs", e); - } - - lookupAllowed = true; - } - } - - private void checkEnableEnter() { - boolean enabled = false; - if (enterBtn != null && !isDisposed()) { - if (ttaaiiTF.getCharCount() > 0 && ccccTF.getCharCount() > 0 - && addresseeIsValid()) { - enabled = true; - } - enterBtn.setEnabled(enabled); - } - } - - @Override - public void setWmoId(String ttaaii, String cccc) { - ttaaiiTF.setText(ttaaii); - ccccTF.setText(cccc); - checkEnableEnter(); - } -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java index bd65408f0a..eb14c74903 100644 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java +++ b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java @@ -106,7 +106,6 @@ import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.menus.IMenuService; -import com.raytheon.uf.common.activetable.SendPracticeProductRequest; import com.raytheon.uf.common.dataplugin.text.RemoteRetrievalResponse; import com.raytheon.uf.common.dataplugin.text.alarms.AlarmAlertProduct; import com.raytheon.uf.common.dataplugin.text.db.MixedCaseProductSupport; @@ -120,8 +119,6 @@ import com.raytheon.uf.common.dataplugin.text.request.TextProductInfoCreateReque import com.raytheon.uf.common.dataplugin.text.util.AFOSParser; import com.raytheon.uf.common.dissemination.OUPRequest; import com.raytheon.uf.common.dissemination.OUPResponse; -import com.raytheon.uf.common.dissemination.OUPTestRequest; -import com.raytheon.uf.common.dissemination.OfficialUserProduct; import com.raytheon.uf.common.jms.notification.INotificationObserver; import com.raytheon.uf.common.jms.notification.NotificationException; import com.raytheon.uf.common.jms.notification.NotificationMessage; @@ -143,7 +140,6 @@ import com.raytheon.uf.common.time.ISimulatedTimeChangeListener; import com.raytheon.uf.common.time.SimulatedTime; import com.raytheon.uf.common.time.util.TimeUtil; import com.raytheon.uf.viz.core.VizApp; -import com.raytheon.uf.viz.core.auth.UserController; import com.raytheon.uf.viz.core.exception.VizException; import com.raytheon.uf.viz.core.notification.jobs.NotificationManagerJob; import com.raytheon.uf.viz.core.requests.ThriftClient; @@ -163,9 +159,6 @@ import com.raytheon.viz.texteditor.command.CommandType; import com.raytheon.viz.texteditor.command.ICommand; import com.raytheon.viz.texteditor.command.IProductQueryCallback; import com.raytheon.viz.texteditor.command.ProductQueryJob; -import com.raytheon.viz.texteditor.dialogs.LineWrapCheckConfirmationMsg.AnswerChoices; -import com.raytheon.viz.texteditor.fax.dialogs.FaxMessageDlg; -import com.raytheon.viz.texteditor.fax.dialogs.LdadFaxSitesDlg; import com.raytheon.viz.texteditor.msgs.IAfosBrowserCallback; import com.raytheon.viz.texteditor.msgs.IAwipsBrowserCallback; import com.raytheon.viz.texteditor.msgs.IRecoverEditSessionCallback; @@ -571,6 +564,7 @@ import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; * Nov 01, 2018 7599 tgurney Reimplement "select to end of line" * Nov 05, 2018 6804 tgurney executeTextScript return the script * controller + * Nov 9, 2018 mjames Remove send button capability * Nov 09, 2018 7587 tgurney Add "writeToLog" parameter to * showScriptStatus() * Nov 13, 2018 7598 tgurney Stop redraw of text editor during @@ -868,11 +862,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private MenuItem saveItem; - /** - * Send and Exit menu item. - */ - private MenuItem sendExitEditorItem; - /** * Cancel editor item. */ @@ -888,11 +877,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private MenuItem recoverEditSessionItem; - /** - * Re-send warning product menu item. - */ - private MenuItem resendWarningProductnItem; - /** * Close menu item. */ @@ -1171,11 +1155,6 @@ public class TextEditorDialog extends CaveSWTDialog */ private Button editorFillBtn; - /** - * Editor send button. - */ - private Button editorSendBtn; - /** * Editor attach button. */ @@ -1439,15 +1418,6 @@ public class TextEditorDialog extends CaveSWTDialog /** Text character wrap dialog */ private TextCharWrapDlg textCharWrapDlg; - /** LDAD fax sites dialog */ - private LdadFaxSitesDlg ldadFaxSitesDlg; - - /** Fax all message dialog */ - private FaxMessageDlg faxAllMsgDlg; - - /** Fax message dialog */ - private FaxMessageDlg faxMsgDlg; - /* * enum to detemine if editor session can be closed. */ @@ -1738,53 +1708,6 @@ public class TextEditorDialog extends CaveSWTDialog new MenuItem(fileMenu, SWT.SEPARATOR); - MenuItem faxAllItem = new MenuItem(fileMenu, SWT.NONE); - faxAllItem.setText("Fax All..."); - faxAllItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - - if (faxAllMsgDlg == null || faxAllMsgDlg.isDisposed()) { - faxAllMsgDlg = new FaxMessageDlg(shell); - faxAllMsgDlg.setInitialText(textEditor.getText()); - faxAllMsgDlg.open(); - } else { - faxAllMsgDlg.bringToTop(); - } - } - }); - - MenuItem faxSelectionItem = new MenuItem(fileMenu, SWT.NONE); - faxSelectionItem.setText("Fax Selection..."); - faxSelectionItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - if (faxMsgDlg == null || faxMsgDlg.isDisposed()) { - faxMsgDlg = new FaxMessageDlg(shell); - faxMsgDlg.setInitialText(textEditor.getSelectionText()); - faxMsgDlg.open(); - } else { - faxMsgDlg.bringToTop(); - } - } - }); - - MenuItem configAutoFaxItem = new MenuItem(fileMenu, SWT.NONE); - configAutoFaxItem.setText("Configure Auto Fax..."); - configAutoFaxItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - if (ldadFaxSitesDlg == null || ldadFaxSitesDlg.isDisposed()) { - ldadFaxSitesDlg = new LdadFaxSitesDlg(shell); - ldadFaxSitesDlg.open(); - } else { - ldadFaxSitesDlg.bringToTop(); - } - } - }); - - new MenuItem(fileMenu, SWT.SEPARATOR); - enterEditorItem = new MenuItem(fileMenu, SWT.NONE); enterEditorItem.setText("Enter Editor"); enterEditorItem.addSelectionListener(new SelectionAdapter() { @@ -1806,17 +1729,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - sendExitEditorItem = new MenuItem(fileMenu, SWT.NONE); - sendExitEditorItem.setText("Send && Exit Editor"); - sendExitEditorItem.setEnabled(false); - sendExitEditorItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("File -> Send & Exit clicked"); - sendProduct(false); - } - }); - cancelEditorItem = new MenuItem(fileMenu, SWT.NONE); cancelEditorItem.setText("Cancel Editor"); cancelEditorItem.setEnabled(false); @@ -1850,24 +1762,6 @@ public class TextEditorDialog extends CaveSWTDialog new MenuItem(fileMenu, SWT.SEPARATOR); - MenuItem requestFromRemoteSiteItem = new MenuItem(fileMenu, SWT.NONE); - requestFromRemoteSiteItem.setText("Request From Remote Site..."); - requestFromRemoteSiteItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - RemoteSiteRequestDlg requestDlg = new RemoteSiteRequestDlg( - shell, lastRemoteRetrievalRequest); - requestDlg.addCloseCallback(returnValue -> { - RemoteRetrievalRequest req = (RemoteRetrievalRequest) returnValue; - if (req != null) { - lastRemoteRetrievalRequest = req; - sendRemoteRetrievalRequest(req); - } - }); - requestDlg.open(); - } - }); - recoverEditSessionItem = new MenuItem(fileMenu, SWT.NONE); recoverEditSessionItem.setText("Recover Edit Sesssion..."); recoverEditSessionItem.addSelectionListener(new SelectionAdapter() { @@ -1883,19 +1777,6 @@ public class TextEditorDialog extends CaveSWTDialog new MenuItem(fileMenu, SWT.SEPARATOR); - resendWarningProductnItem = new MenuItem(fileMenu, SWT.NONE); - resendWarningProductnItem.setText("Resend Warning Product..."); - resendWarningProductnItem.setEnabled(false); - resendWarningProductnItem.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("File -> Resend Warning Product... clicked"); - sendProduct(true); - } - }); - - new MenuItem(fileMenu, SWT.SEPARATOR); - closeItem = new MenuItem(fileMenu, SWT.NONE); closeItem.setText("Close\tAlt+F4"); closeItem.setAccelerator(SWT.ALT | SWT.F4); @@ -3578,19 +3459,6 @@ public class TextEditorDialog extends CaveSWTDialog } }); - // Add the Send button. - gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); - editorSendBtn = new Button(editorBtnRowComp, SWT.PUSH); - editorSendBtn.setText("Send"); - editorSendBtn.setLayoutData(gd); - editorSendBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - logInfo("Send button clicked"); - sendProduct(false); - } - }); - // Add the Cancel button. gd = new GridData(SWT.DEFAULT, SWT.DEFAULT); Button editorCancelBtn = new Button(editorBtnRowComp, SWT.PUSH); @@ -4505,20 +4373,11 @@ public class TextEditorDialog extends CaveSWTDialog importFromFileItem.setEnabled(!inEditMode); recoverEditSessionItem.setEnabled(!inEditMode); - // --------------------------------- - // File Menu menu items - // Disabled when in editor mode - // --------------------------------- - resendWarningProductnItem - .setEnabled(!inEditMode && textEditor.getText() != null - && textEditor.getText().length() > 0); - // --------------------------------- // File Menu menu items // Enabled when in editor mode // --------------------------------- saveItem.setEnabled(inEditMode); - sendExitEditorItem.setEnabled(inEditMode); cancelEditorItem.setEnabled(inEditMode); // --------------------------------- @@ -4912,276 +4771,6 @@ public class TextEditorDialog extends CaveSWTDialog userInformation("Notice", information); } - /** - * Disseminate the product. - * - * @param resend - * true if product is to be resent - */ - private synchronized void sendProduct(final boolean resend) { - if (!validateTime()) { - return; - } - StdTextProduct prod = getStdTextProduct(); - if (warnGenFlag) { - QCConfirmationMsg qcMsg = new QCConfirmationMsg(); - if (!qcMsg.checkWarningInfo(headerTF.getText(), - textEditor.getText(), prod.getNnnid())) { - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - qcMsg.getTitle(), qcMsg.getProductMessage(), - qcMsg.getModeMessage()); - wgcd.addCloseCallback(returnValue -> { - if (Boolean.TRUE.equals(returnValue)) { - finishSendProduct(resend); - } - - }); - wgcd.open(); - } else { - finishSendProduct(resend); - } - } else { - finishSendProduct(resend); - } - } - - /** - * This finishes preparing to send a product as part of normal completion of - * sendProduct or as part of the call back when there is a problem with the - * WarnGen being sent. - * - * @param resend - */ - private void finishSendProduct(final boolean resend) { - if (statusBarLabel.getText().startsWith("Attachment:")) { - StringBuilder sb = new StringBuilder("An Attachment file ("); - int startIndex = "Attachment:".length() + 1; - sb.append(statusBarLabel.getText().substring(startIndex)); - sb.append(") will be transmitted with this message."); - int response = TextWSMessageBox.open(shell, "Notice", sb.toString(), - SWT.OK | SWT.CANCEL); - if (SWT.OK != response) { - return; - } - } - - // verify if product has already been resent - if (!verifyResendProduct()) { - return; - } - - // verify required fields - if (!verifyRequiredFields()) { - return; - } - - // verify wrapping - if (!verifyLineWidth(resend)) { - return; - } - - concludeSendProduct(resend); - } - - private void concludeSendProduct(final boolean resend) { - StdTextProduct prod = getStdTextProduct(); - if (TextEditorCfg.getTextEditorCfg().getValidateCharacterSet() - && !validateCharacterSet(prod.getNnnid())) { - return; - } - - // verify that the buffer does not exceed permitted length for FTM - if ("FTM".equals(prod.getNnnid()) && !verifyBufferSize()) { - return; - } - - if (isWarnGenDlg) { - String afosId = prod.getCccid() + prod.getNnnid() + prod.getXxxid(); - SendConfirmationMsg sendMsg = new SendConfirmationMsg(resend, - afosId, prod.getNnnid()); - - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - sendMsg.getTitle(), sendMsg.getProductMessage(), - sendMsg.getModeMessage()); - wgcd.addCloseCallback(returnValue -> { - if (Boolean.TRUE.equals(returnValue)) { - checkEmergencyProduct(resend); - } - }); - wgcd.open(); - } else { - checkEmergencyProduct(resend); - } - } - - /** - * Checks if the product is a emergency warning product and opens up the - * WarnGen Confirmation Dialog if necessary. - * - * @param resend - * true if product is to be resent - */ - private void checkEmergencyProduct(final boolean resend) { - StdTextProduct prod = getStdTextProduct(); - EmergencyConfirmationMsg emergencyMsg = new EmergencyConfirmationMsg(); - if (!emergencyMsg - .checkWarningInfo(headerTF.getText().toUpperCase(), - MixedCaseProductSupport.conditionalToUpper( - prod.getNnnid(), textEditor.getText()), - prod.getNnnid())) { - - WarnGenConfirmationDlg wgcd = new WarnGenConfirmationDlg(shell, - emergencyMsg.getTitle(), emergencyMsg.getProductMessage(), - emergencyMsg.getModeMessage()); - wgcd.addCloseCallback(returnValue -> { - if (Boolean.TRUE.equals(returnValue)) { - warngenCloseCallback(resend); - } - - }); - wgcd.open(); - } else { - warngenCloseCallback(resend); - } - } - - /** - * This is used by finishedSendProduct as the call back to the warnGen - * confirmaiton Dialog. - * - * @param resend - * @param result - */ - private void warngenCloseCallback(boolean resend) { - - StdTextProduct prod = getStdTextProduct(); - String body = MixedCaseProductSupport - .conditionalToUpper(prod.getNnnid(), textEditor.getText()); - CAVEMode mode = CAVEMode.getMode(); - boolean isOperational = CAVEMode.OPERATIONAL.equals(mode) - || CAVEMode.TEST.equals(mode); - if (isOperational) { - removeOptionalFields(); - - try { - updateTextEditor(body); - if ((inEditMode || resend) - && !saveEditedProduct(prod, false, resend, true) - .isEmpty()) { - inEditMode = false; - } - if (!resend) { - // DR 2028 - changing the order to always have etn for - // product - // from : send product, increment ETN - // to : increment ETN, send product - if (shouldSetETNtoNextValue(prod)) { - statusHandler.handle(Priority.INFO, - "Will increment ETN for this product."); - prod.setProduct( - VtecUtil.getVtec(prod.getProduct(), true)); - } else { - statusHandler.handle(Priority.INFO, - "Will NOT increment ETN for this product."); - } - - OUPTestRequest testReq = new OUPTestRequest(); - testReq.setOupRequest( - createOUPRequest(prod, prod.getProduct())); - try { - OUPResponse checkResponse = (OUPResponse) ThriftClient - .sendRequest(testReq); - if (checkResponse.hasFailure()) { - statusHandler.handle(Priority.PROBLEM, - "Error during text product transmission check: " - + checkResponse.getMessage()); - inEditMode = true; - return; - } - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error during text product transmission check", - e); - inEditMode = true; - return; - } - - // Update editor so the proper send times are displayed. - textEditor.setText(prod.getProduct()); - } - - String product = prod.getProduct(); - OUPRequest req = createOUPRequest(prod, product); - - if (notify != null) { - notify.add(product); - } - - // Code in Run statement goes here! - new Thread(new ThriftClientRunnable(req)).start(); - logInfo("Autowrap char size = " + currentWrapCfg.getWrapCol()); - logInfo("Sent product:\n" + product); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error transmitting text product", e); - } - } else { - try { - if (!resend) { - if (shouldSetETNtoNextValue(prod)) { - statusHandler.handle(Priority.INFO, - "Will increment ETN for this product."); - body = VtecUtil.getVtec( - MixedCaseProductSupport.conditionalToUpper( - prod.getNnnid(), textEditor.getText())); - } else { - statusHandler.handle(Priority.INFO, - "Will NOT increment ETN for this product."); - } - } - updateTextEditor(body); - if ((inEditMode || resend) - && !saveEditedProduct(prod, false, resend, false) - .isEmpty()) { - inEditMode = false; - } - String practiceProd = TextDisplayModel.getInstance() - .getProduct(token); - textEditor.setText(practiceProd); - SendPracticeProductRequest req = new SendPracticeProductRequest(); - req.setProductText(practiceProd); - req.setNotifyGFE(true); - req.setDrtString(new SimpleDateFormat("yyyyMMdd_HHmm") - .format(SimulatedTime.getSystemTime().getTime())); - - ThriftClient.sendRequest(req); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error transmitting text product", e); - } - } - - if (!inEditMode && !resend) { - saved = true; - StdTextProduct finalProduct = this.getStdTextProduct(); - String header = null; - if ("WRK".equals(finalProduct.getNnnid()) - && !finalProduct.getXxxid().startsWith("WG")) { - header = "ZCZC " + finalProduct.getCccid() - + finalProduct.getNnnid() + finalProduct.getXxxid() - + " " + getAddressee() + "\nTTAA00 " - + finalProduct.getSite() + " " - + finalProduct.getHdrtime(); - } else { - header = finalProduct.getWmoid() + " " + finalProduct.getSite() - + " " + finalProduct.getHdrtime() + "\n" - + finalProduct.getNnnid() + finalProduct.getXxxid(); - } - headerTF.setText(header); - cancelEditor(false); - } - } - private EtnRules getETNRules() throws Exception { LocalizationFile lf = PathManagerFactory.getPathManager() .getStaticLocalizationFile(ETN_RULES_FILE); @@ -5213,37 +4802,6 @@ public class TextEditorDialog extends CaveSWTDialog return result; } - private OUPRequest createOUPRequest(StdTextProduct prod, String text) { - OUPRequest req = new OUPRequest(); - OfficialUserProduct oup = new OfficialUserProduct(); - String awipsWanPil = prod.getSite() + prod.getNnnid() + prod.getXxxid(); - String awipsID = prod.getNnnid() + prod.getXxxid(); - - oup.setAwipsWanPil(awipsWanPil); - oup.setNeedsWmoHeader(false); - oup.setProductText(text); - oup.setSource("TextWS"); - oup.setWmoType(fixNOR(prod.getBbbid())); - oup.setUserDateTimeStamp(prod.getHdrtime()); - StringBuilder fileName = new StringBuilder(); - - // The .wan extension followed by the 10 digit epoch seconds - // of simulated time is used in EDEX's WarningDecoder to - // determine the base time. - fileName.append(awipsID).append(".wan") - .append(TimeUtil.getUnixTime(TimeUtil.newDate())); - oup.setFilename(fileName.toString()); - oup.setAddress(addressee); - if (attachedFile != null && attachedFilename != null) { - oup.setAttachedFile(attachedFile); - oup.setAttachedFilename(attachedFilename); - } - req.setCheckBBB(true); - req.setProduct(oup); - req.setUser(UserController.getUserObject()); - return req; - } - /** * Recreates the original message by combining the header and the body from * the edit windows. @@ -5339,9 +4897,8 @@ public class TextEditorDialog extends CaveSWTDialog replaceWorkProductId(); String header = headerTF.getText().toUpperCase(); - String body = resend ? resendMessage() - : MixedCaseProductSupport.conditionalToUpper( - product.getNnnid(), textEditor.getText()); + String body = MixedCaseProductSupport.conditionalToUpper( + product.getNnnid(), textEditor.getText()); // verify text headerTF.setText(header); updateTextEditor(body); @@ -5354,8 +4911,7 @@ public class TextEditorDialog extends CaveSWTDialog // New up a StdTextProduct, then set the product component // to the tmpStr that represents the new content. StdTextProduct storedProduct = tdmInst.getStdTextProduct(token, true); - String productText = resend ? resendMessage() - : combineOriginalMessage(); + String productText = combineOriginalMessage(); if (!isAutoSave) { if (!resend) { @@ -6345,8 +5901,6 @@ public class TextEditorDialog extends CaveSWTDialog // Automatically open the editor window with returned data. if (enterEditor) { enterEditor(); - } else { - resendWarningProductnItem.setEnabled(true); } } } @@ -7140,51 +6694,6 @@ public class TextEditorDialog extends CaveSWTDialog return resend; } - /** - * Add RESENT to the end of the MND line - */ - private String resendMessage() { - boolean updatedMND = false; - StringBuilder sb = new StringBuilder(); - - for (String line : textEditor.getText().split("\n")) { - if (!updatedMND && (line.endsWith("WARNING") - || line.endsWith("WARNING...TEST") - || line.endsWith("WARNING...CORRECTED") - || line.endsWith("WARNING...CORRECTED...TEST") - || line.endsWith("STATEMENT") - || line.endsWith("STATEMENT...TEST") - || line.endsWith("STATEMENT...CORRECTED") - || line.endsWith("STATEMENT...CORRECTED...TEST") - || line.endsWith("FORECAST") - || line.endsWith("FORECAST...TEST") - || line.endsWith("ADVISORY") - || line.endsWith("ADVISORY...TEST") - || line.endsWith("ADVISORY...CORRECTED") - || line.endsWith("ADVISORY...CORRECTED...TEST"))) { - line += "...RESENT"; - updatedMND = true; - } - sb.append(line + "\n"); - } - - return sb.toString(); - } - - private void removeOptionalFields() { - String text = textEditor.getText(); - int startIndex = text.indexOf("!--"); - int endIndex = text.indexOf("--!", startIndex); - while (startIndex >= 0 && endIndex >= startIndex) { - String part1 = text.substring(0, startIndex).trim(); - String part2 = text.substring(endIndex + 3).trim(); - text = part1 + "\n\n" + part2; - startIndex = text.indexOf("!--"); - endIndex = text.indexOf("--!", startIndex); - } - textEditor.setText(text); - } - /* * This class handles a timer to auto save a product to a file. */ @@ -8442,15 +7951,6 @@ public class TextEditorDialog extends CaveSWTDialog return bytes; } - /** - * Set the enable state of the editor's send button. - * - * @param state - */ - public void enableSend(boolean state) { - editorSendBtn.setEnabled(state); - } - /** * Queue a afosId and who to noify. * @@ -8734,39 +8234,6 @@ public class TextEditorDialog extends CaveSWTDialog return paddingPatternList; } - private boolean verifyLineWidth(final boolean resend) { - if (!currentWrapCfg.isWrapEnabled()) { - return true; - } - - int lineToWrap = findLineToWrap(); - if (lineToWrap == -1) { - return true; - } - LineWrapCheckConfirmationMsg lineWrapCheckConfirmationMsg = new LineWrapCheckConfirmationMsg( - shell); - lineWrapCheckConfirmationMsg.addCloseCallback(returnValue -> { - if (AnswerChoices.EDIT.equals(returnValue)) { - // do nothing - } else if (AnswerChoices.FIX.equals(returnValue)) { - int lineToWrap1 = findLineToWrap(); - while (lineToWrap1 > -1) { - // recompileRegex might not have been called - if (standardWrapRegex == null) { - recompileRegex(); - } - rewrapInternal(lineToWrap1); - lineToWrap1--; - } - concludeSendProduct(resend); - } else if (AnswerChoices.SEND.equals(returnValue)) { - concludeSendProduct(resend); - } - }); - lineWrapCheckConfirmationMsg.open(); - return false; - } - private int findLineToWrap() { int rval = -1; for (int i = 0; i < textEditor.getLineCount(); ++i) { diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java deleted file mode 100644 index 004488e6ba..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/WarnGenConfirmationDlg.java +++ /dev/null @@ -1,203 +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.viz.texteditor.dialogs; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; - -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.viz.core.mode.CAVEMode; -import com.raytheon.viz.texteditor.Activator; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * Main Text Editor dialog. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#     Engineer    Description
- * ------------ ----------  ----------  --------------------------
- * 27Jul2010    4773        cjeanbap    Initial development
- * 10Aug2010    2187        cjeanbap    Removed warnGenFlag.
- * 10Nov2011    11552       rferrel     returnvalue no longer null
- * 08/20/2012   DR 15340    D. Friedman Use callbacks for closing
- * 09/24/2012   1196        rferrel     Refactored to use close callback
- *                                      added to CaveSWTDialog.
- * 17 Sep 2013  #2384       lvenable    Fixed memory leak and utilized the disposed()
- *                                      method.
- * May 29, 2015 #4441       randerso    Fixed loading of images
- * 
- * 
- * - * @author cjeanbap - */ -public class WarnGenConfirmationDlg extends CaveSWTDialog { - - /** - * Handler used for messges. - */ - private final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(TextEditorDialog.class); - - private String productMessage; - - private String modeMessage; - - private CAVEMode mode; - - private String IMAGE_OPERATIONAL = "res/images/twsOper.gif"; - - private String IMAGE_TEST = "res/images/twsTest.gif"; - - private String IMAGE_PRACTICE = "res/images/twsPractice.gif"; - - private Image stopSign = null; - - /** - * Constructor. - * - * @param parentShell - * Parent shell. - * @param title - * Dialog title. - * @param productMessage - * Product message. - * @param modeMessage - * Mode message. - */ - protected WarnGenConfirmationDlg(Shell parentShell, String title, - String productMessage, String modeMessage) { - super(parentShell, SWT.DIALOG_TRIM | SWT.PRIMARY_MODAL, CAVE.NONE - | CAVE.DO_NOT_BLOCK); - - setText(title); - - this.productMessage = productMessage; - this.modeMessage = modeMessage; - this.mode = CAVEMode.getMode(); - setReturnValue(Boolean.FALSE); - } - - @Override - protected void initializeComponents(Shell shell) { - Composite mainComposite = new Composite(shell, SWT.NONE); - mainComposite.setLayout(new GridLayout(1, false)); - createImage(mainComposite); - createMessageLabel(mainComposite); - createButtonRow(mainComposite); - } - - private void createImage(Composite mainComposite) { - - String imagePath = null; - try { - if (mode.equals(CAVEMode.OPERATIONAL)) { - // add Live image - imagePath = IMAGE_OPERATIONAL; - } else if (mode.equals(CAVEMode.TEST)) { - // add Test image - imagePath = IMAGE_TEST; - } else if (mode.equals(CAVEMode.PRACTICE)) { - // add Practice image - imagePath = IMAGE_PRACTICE; - } else { - // unknown - imagePath = IMAGE_OPERATIONAL; - } - - ImageDescriptor id = Activator.imageDescriptorFromPlugin( - Activator.PLUGIN_ID, imagePath); - stopSign = id.createImage(mainComposite.getDisplay()); - Label stopSignLbl = new Label(mainComposite, 0); - stopSignLbl.setImage(stopSign); - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, e.getLocalizedMessage(), e); - } - } - - private void createMessageLabel(Composite mainComposite) { - Label productMsgLbl = new Label(mainComposite, 0); - productMsgLbl.setText(this.productMessage); - Label modeMsgLbl = new Label(mainComposite, 0); - modeMsgLbl.setText(this.modeMessage); - - Label sepLbl = new Label(mainComposite, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - } - - private void createButtonRow(Composite mainComposite) { - Composite buttonRowComp = new Composite(mainComposite, SWT.NONE); - buttonRowComp.setLayout(new GridLayout(2, true)); - buttonRowComp.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, - false)); - - // Add the Go Ahead (Save) button. - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - Button saveBtn = new Button(buttonRowComp, SWT.PUSH); - saveBtn.setText("Go Ahead!"); - saveBtn.setLayoutData(gd); - saveBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - dispose(Boolean.TRUE); - } - }); - - // Add the Abort button. - gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.widthHint = 100; - Button abortCutBtn = new Button(buttonRowComp, SWT.PUSH); - abortCutBtn.setText("Abort"); - abortCutBtn.setLayoutData(gd); - abortCutBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - dispose(Boolean.FALSE); - } - }); - } - - private void dispose(Boolean returnValue) { - setReturnValue(returnValue); - close(); - } - - @Override - protected void disposed() { - if (stopSign != null) { - stopSign.dispose(); - } - } -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java deleted file mode 100644 index e4e8ccb3d1..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxMessageDlg.java +++ /dev/null @@ -1,294 +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.viz.texteditor.fax.dialogs; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.raytheon.uf.common.dataplugin.text.subscription.request.SendFaxRequest; -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.common.util.SystemUtil; -import com.raytheon.uf.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.requests.ThriftClient; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * TODO Add Description - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date          Ticket#  Engineer  Description
- * ------------- -------- --------- ------------------------------
- * Oct 31, 2010           lvenable  Initial creation
- * Sep 26, 2012  1196     lvenable  Prevent dialog from blocking.
- * Apr 29, 2021  8137     randerso  Change to use SystemUtil.getHostName()
- *
- * 
- * - * @author lvenable - */ - -// TODO - need to replace CaveSWTDialogStub with CaveSWTDialog - -public class FaxMessageDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(FaxMessageDlg.class); - - private Text faxNumberTF; - - private Text recipientTF; - - private Text companyTF; - - private StyledText stText; - - private String initialText; - - public void setInitialText(String initialText) { - this.initialText = initialText; - } - - public FaxMessageDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); - setText("Fax Message"); - } - - @Override - protected Layout constructShellLayout() { - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 2; - mainLayout.verticalSpacing = 2; - return mainLayout; - } - - @Override - protected Object constructShellLayoutData() { - return new GridData(SWT.FILL, SWT.FILL, true, true); - } - - @Override - protected void initializeComponents(Shell shell) { - // Create the menus - createMenus(); - - // Create the controls on the display - createControls(); - } - - private void createMenus() { - Menu menuBar = new Menu(shell, SWT.BAR); - - createFileMenu(menuBar); - createHelpMenu(menuBar); - - shell.setMenuBar(menuBar); - } - - private void createFileMenu(Menu menuBar) { - // ------------------------------------- - // Create the file menu - // ------------------------------------- - MenuItem fileMenuItem = new MenuItem(menuBar, SWT.CASCADE); - fileMenuItem.setText("&File"); - - // Create the File menu item with a File "dropdown" menu - Menu fileMenu = new Menu(menuBar); - fileMenuItem.setMenu(fileMenu); - - /* - * Exit - */ - MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); - exitMI.setText("Exit"); - exitMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - shell.dispose(); - } - }); - } - - private void createHelpMenu(Menu menuBar) { - // ------------------------------------- - // Create the file menu - // ------------------------------------- - MenuItem helpMenuItem = new MenuItem(menuBar, SWT.CASCADE); - helpMenuItem.setText("&Help"); - - // Create the File menu item with a Help "dropdown" menu - Menu helpMenu = new Menu(menuBar); - helpMenuItem.setMenu(helpMenu); - - /* - * Contents and About - */ - MenuItem contentsMI = new MenuItem(helpMenu, SWT.NONE); - contentsMI.setText("&Contents"); - contentsMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - - } - }); - - MenuItem aboutMI = new MenuItem(helpMenu, SWT.NONE); - aboutMI.setText("&About"); - aboutMI.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - - } - }); - } - - private void createControls() { - Composite controlComp = new Composite(shell, SWT.NONE); - controlComp.setLayout(new GridLayout(2, false)); - controlComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns; - Label ldadLbl = new Label(controlComp, SWT.NONE); - ldadLbl.setText("LDAD Fax Recipient"); - ldadLbl.setLayoutData(gd); - - Label faxNumLbl = new Label(controlComp, SWT.NONE); - faxNumLbl.setText("Fax Number: "); - - gd = new GridData(180, SWT.DEFAULT); - faxNumberTF = new Text(controlComp, SWT.BORDER); - faxNumberTF.setLayoutData(gd); - - // Add a separator bar - addSeparator(controlComp); - - Label recipLbl = new Label(controlComp, SWT.NONE); - recipLbl.setText("Recipient: "); - - gd = new GridData(275, SWT.DEFAULT); - recipientTF = new Text(controlComp, SWT.BORDER); - recipientTF.setLayoutData(gd); - - Label companyLbl = new Label(controlComp, SWT.NONE); - companyLbl.setText("Company: "); - - gd = new GridData(275, SWT.DEFAULT); - companyTF = new Text(controlComp, SWT.BORDER); - companyTF.setLayoutData(gd); - - // Add a separator bar - addSeparator(controlComp); - - /* - * Send and Cancel buttons - */ - Composite buttonComp = new Composite(controlComp, SWT.NONE); - buttonComp.setLayout(new GridLayout(2, true)); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns; - buttonComp.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Button sendBtn = new Button(buttonComp, SWT.PUSH); - sendBtn.setText("Send"); - sendBtn.setLayoutData(gd); - sendBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - sendAction(); - } - }); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Button cancelBtn = new Button(buttonComp, SWT.PUSH); - cancelBtn.setText("Cancel"); - cancelBtn.setLayoutData(gd); - cancelBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - shell.dispose(); - } - }); - - /* - * Styled text control - */ - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 500; - gd.heightHint = 350; - gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns; - - stText = new StyledText(controlComp, - SWT.BORDER | SWT.V_SCROLL | SWT.WRAP); - stText.setLayoutData(gd); - if (initialText != null) { - stText.setText(initialText); - } - } - - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - private void sendAction() { - String faxNumber = faxNumberTF.getText(); - String faxTitle = SystemUtil.getHostName(); - String faxCompany = companyTF.getText(); - String faxText = stText.getText(); - String faxRecipient = recipientTF.getText(); - if (null != faxNumber && null != faxTitle && null != faxCompany - && null != faxText && null != faxRecipient) { - SendFaxRequest faxReq = new SendFaxRequest(faxNumber, faxTitle, - faxCompany, faxText, faxRecipient); - try { - Object retval = ThriftClient.sendRequest(faxReq); - if (retval instanceof String && !"Success".equals(retval)) { - statusHandler.handle(Priority.SIGNIFICANT, (String) retval); - } - } catch (VizException e) { - statusHandler.handle(Priority.SIGNIFICANT, - "Exception while sending fax to edex.", e); - } - } - } -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java deleted file mode 100644 index 3489fb8b6b..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/FaxSiteEditorDlg.java +++ /dev/null @@ -1,408 +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.viz.texteditor.fax.dialogs; - -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; - -import com.raytheon.uf.common.dataplugin.text.subscription.db.AutoFaxRecord; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 1, 2010            lvenable     Initial creation
- * 26Sep2012    1196      lvenable     Update for dialog refactor to not block the dialog on open.
- * 
- * 
- * - * @author lvenable - * @version 1.0 - */ - -public class FaxSiteEditorDlg extends CaveSWTDialog { - - private Text afosPilTF; - - private Text faxNumberTF; - - private Text phoneNumberTF; - - private Text recipientTF; - - private Text companyTF; - - private AutoFaxRecord faxRecord; - - private LdadFaxSitesDlg callback; - - public FaxSiteEditorDlg(Shell parent, LdadFaxSitesDlg callback) { - super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, - CAVE.PERSPECTIVE_INDEPENDENT | CAVE.DO_NOT_BLOCK); - setText("Fax Message"); - this.callback = callback; - } - - @Override - protected Layout constructShellLayout() { - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 2; - mainLayout.verticalSpacing = 2; - return mainLayout; - } - - @Override - protected Object constructShellLayoutData() { - return new GridData(SWT.FILL, SWT.FILL, true, true); - } - - @Override - protected void initializeComponents(Shell shell) { - // Create the menus - createMenus(); - - // Create the controls on the display - createControls(); - } - - private void createMenus() { - Menu menuBar = new Menu(shell, SWT.BAR); - - createFileMenu(menuBar); - createRecipientMenu(menuBar); - createHelpMenu(menuBar); - - shell.setMenuBar(menuBar); - } - - private void createFileMenu(Menu menuBar) { - // ------------------------------------- - // Create the file menu - // ------------------------------------- - MenuItem fileMenuItem = new MenuItem(menuBar, SWT.CASCADE); - fileMenuItem.setText("&File"); - - // Create the File menu item with a File "dropdown" menu - Menu fileMenu = new Menu(menuBar); - fileMenuItem.setMenu(fileMenu); - - /* - * Update DB - */ - MenuItem updateDbMI = new MenuItem(fileMenu, SWT.NONE); - updateDbMI.setText("Update DB"); - updateDbMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - String afosPil = afosPilTF.getText(); - String faxNumber = faxNumberTF.getText(); - String phoneNumber = phoneNumberTF.getText(); - String recipient = recipientTF.getText(); - String company = companyTF.getText(); - if (null != afosPil && null != faxNumber && null != phoneNumber - && null != recipient && null != company) { - AutoFaxRecord add = new AutoFaxRecord(afosPil, faxNumber, - phoneNumber, recipient, company); - callback.addAutoFaxSite(add); - callback.updateDBAction(); - FaxSiteEditorDlg.this.close(); - } else { - MessageDialog.open(MessageDialog.INFORMATION, getParent(), - null, "Please fill out the record completely!", - SWT.NONE); - } - } - }); - - /* - * Exit - */ - MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); - exitMI.setText("Exit"); - exitMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - shell.dispose(); - } - }); - } - - private void createRecipientMenu(Menu menuBar) { - // ------------------------------------- - // Create the recipient menu - // ------------------------------------- - MenuItem recipientMenuItem = new MenuItem(menuBar, SWT.CASCADE); - recipientMenuItem.setText("&Recipient"); - - // Create the Recipient menu item with a Recipient "dropdown" menu - Menu recipientMenu = new Menu(menuBar); - recipientMenuItem.setMenu(recipientMenu); - - /* - * Add Recipient - */ - MenuItem addRecipientMI = new MenuItem(recipientMenu, SWT.NONE); - addRecipientMI.setText("Add Recipient"); - addRecipientMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - addRecipientAction(); - } - }); - - /* - * Delete Recipient - */ - MenuItem deleteRecipientMI = new MenuItem(recipientMenu, SWT.NONE); - deleteRecipientMI.setText("Delete Recipient"); - deleteRecipientMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - deleteRecipientAction(); - } - }); - } - - private void createHelpMenu(Menu menuBar) { - // ------------------------------------- - // Create the file menu - // ------------------------------------- - MenuItem helpMenuItem = new MenuItem(menuBar, SWT.CASCADE); - helpMenuItem.setText("&Help"); - - // Create the File menu item with a Help "dropdown" menu - Menu helpMenu = new Menu(menuBar); - helpMenuItem.setMenu(helpMenu); - - /* - * Contents and About - */ - MenuItem contentsMI = new MenuItem(helpMenu, SWT.NONE); - contentsMI.setText("&Contents"); - contentsMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - - } - }); - - MenuItem aboutMI = new MenuItem(helpMenu, SWT.NONE); - aboutMI.setText("&About"); - aboutMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - - } - }); - } - - private void createControls() { - - Composite controlComp = new Composite(shell, SWT.NONE); - controlComp.setLayout(new GridLayout(2, false)); - controlComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - - GridData gd = new GridData(SWT.CENTER, SWT.DEFAULT, true, false); - gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns; - Label ldadLbl = new Label(controlComp, SWT.NONE); - ldadLbl.setText("LDAD Fax Recipient"); - ldadLbl.setLayoutData(gd); - - // AFOS PIL - Label afosPilLbl = new Label(controlComp, SWT.NONE); - afosPilLbl.setText("AFOS PIL: "); - - gd = new GridData(140, SWT.DEFAULT); - afosPilTF = new Text(controlComp, SWT.BORDER); - afosPilTF.setLayoutData(gd); - - // Fax Number - Label faxNumLbl = new Label(controlComp, SWT.NONE); - faxNumLbl.setText("Fax Number: "); - - gd = new GridData(180, SWT.DEFAULT); - faxNumberTF = new Text(controlComp, SWT.BORDER); - faxNumberTF.setLayoutData(gd); - - // Add a separator bar - addSeparator(controlComp); - - Label phoneNumberLbl = new Label(controlComp, SWT.NONE); - phoneNumberLbl.setText("Phone Number: "); - - gd = new GridData(275, SWT.DEFAULT); - phoneNumberTF = new Text(controlComp, SWT.BORDER); - phoneNumberTF.setLayoutData(gd); - - Label recipLbl = new Label(controlComp, SWT.NONE); - recipLbl.setText("Recipient: "); - - gd = new GridData(275, SWT.DEFAULT); - recipientTF = new Text(controlComp, SWT.BORDER); - recipientTF.setLayoutData(gd); - - Label companyLbl = new Label(controlComp, SWT.NONE); - companyLbl.setText("Company: "); - - gd = new GridData(275, SWT.DEFAULT); - companyTF = new Text(controlComp, SWT.BORDER); - companyTF.setLayoutData(gd); - - if (null != faxRecord) { - afosPilTF.setText(faxRecord.getId().getAfosPil()); - faxNumberTF.setText(faxRecord.getId().getFaxNumber()); - phoneNumberTF.setText(faxRecord.getPhoneNumber()); - recipientTF.setText(faxRecord.getRecipient()); - companyTF.setText(faxRecord.getCompany()); - } - // Add a separator bar - addSeparator(controlComp); - - /* - * Send and Cancel buttons - */ - Composite buttonComp = new Composite(controlComp, SWT.NONE); - buttonComp.setLayout(new GridLayout(2, true)); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = ((GridLayout) controlComp.getLayout()).numColumns; - buttonComp.setLayoutData(gd); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Button addRecipientBtn = new Button(buttonComp, SWT.PUSH); - addRecipientBtn.setText("Add Recipient"); - addRecipientBtn.setLayoutData(gd); - addRecipientBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - addRecipientAction(); - } - }); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - Button deleteRecipientBtn = new Button(buttonComp, SWT.PUSH); - deleteRecipientBtn.setText("Delete Recipient"); - deleteRecipientBtn.setLayoutData(gd); - deleteRecipientBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - deleteRecipientAction(); - } - }); - - } - - private void addSeparator(Composite parentComp) { - GridLayout gl = (GridLayout) parentComp.getLayout(); - - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - gd.horizontalSpan = gl.numColumns; - Label sepLbl = new Label(parentComp, SWT.SEPARATOR | SWT.HORIZONTAL); - sepLbl.setLayoutData(gd); - } - - private void addRecipientAction() { - boolean addRecord = MessageDialog - .open(MessageDialog.QUESTION_WITH_CANCEL, - getParent(), - "Add Recipient", - "Adding this recipient is not finished until \"Update DB\" is selected from the LDAD Fax Dialog.", - SWT.NONE); - - if (addRecord) { - String afosPil = afosPilTF.getText(); - String faxNumber = faxNumberTF.getText(); - String phoneNumber = phoneNumberTF.getText(); - String recipient = recipientTF.getText(); - String company = companyTF.getText(); - if (null != afosPil && null != faxNumber && null != phoneNumber - && null != recipient && null != company) { - AutoFaxRecord add = new AutoFaxRecord(afosPil, faxNumber, - phoneNumber, recipient, company); - if (null != faxRecord) { - callback.deleteAutoFaxSite(faxRecord); - } - callback.addAutoFaxSite(add); - this.close(); - } else { - MessageDialog.open(MessageDialog.INFORMATION, getParent(), - null, "Please fill out the record completely!", - SWT.NONE); - } - } - - } - - private void deleteRecipientAction() { - boolean deleteRecord = MessageDialog - .open(MessageDialog.QUESTION_WITH_CANCEL, - getParent(), - "Delete Recipient", - "Deleting this recipient is not finished until \"Update DB\" is selected from the LDAD Fax Dialog.", - SWT.NONE); - - if (deleteRecord) { - String afosPil = afosPilTF.getText(); - String faxNumber = faxNumberTF.getText(); - String phoneNumber = phoneNumberTF.getText(); - String recipient = recipientTF.getText(); - String company = companyTF.getText(); - if (null != afosPil && null != faxNumber && null != phoneNumber - && null != recipient && null != company) { - if (null != faxRecord) { - callback.deleteAutoFaxSite(faxRecord); - } - this.close(); - } else { - MessageDialog.open(MessageDialog.INFORMATION, getParent(), - null, "Please fill out the record completely!", - SWT.NONE); - } - } - } - - /** - * @return the faxRecord - */ - public AutoFaxRecord getFaxRecord() { - return faxRecord; - } - - /** - * @param faxRecord - * the faxRecord to set - */ - public void setFaxRecord(AutoFaxRecord faxRecord) { - this.faxRecord = faxRecord; - } -} diff --git a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java b/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java deleted file mode 100644 index 17d044ab1e..0000000000 --- a/cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/fax/dialogs/LdadFaxSitesDlg.java +++ /dev/null @@ -1,547 +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.viz.texteditor.fax.dialogs; - -import java.util.ArrayList; -import java.util.List; -import java.util.TreeMap; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Layout; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; - -import com.raytheon.uf.common.dataplugin.text.subscription.AutoFaxContainer; -import com.raytheon.uf.common.dataplugin.text.subscription.db.AutoFaxRecord; -import com.raytheon.uf.common.dataplugin.text.subscription.request.AutoFaxRequest; -import com.raytheon.uf.common.dataplugin.text.subscription.request.GetAutoFaxRecordsRequest; -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.viz.core.exception.VizException; -import com.raytheon.uf.viz.core.requests.ThriftClient; -import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -import com.raytheon.viz.ui.dialogs.ICloseCallback; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 1, 2010            lvenable     Initial creation
- * 26Sep2012    1196      lvenable     Dialog refacter to not block.
- * 
- * 
- * - * @author lvenable - * @version 1.0 - */ - -public class LdadFaxSitesDlg extends CaveSWTDialog { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(LdadFaxSitesDlg.class); - - private Tree faxSiteTree; - - private Label faxNumLbl; - - private Label afosPilLbl; - - private Label companyLbl; - - private Label phoneNumLbl; - - private Label contactLbl; - - private final String faxNumPrefix = "Fax Number: "; - - private final String afosPilPrefix = "AFOS PIL: "; - - private final String companyPrefix = "Company: "; - - private final String phoneNumPrefix = "Phone Number: "; - - private final String contactPrefix = "Contact: "; - - private FaxSiteEditorDlg faxSiteEditorDlg; - - private Button updateDbBtn; - - private AutoFaxContainer addList = new AutoFaxContainer(); - - private AutoFaxContainer removeList = new AutoFaxContainer(); - - private AutoFaxContainer currentList = new AutoFaxContainer(); - - private boolean sortByPil = true; - - public LdadFaxSitesDlg(Shell parent) { - super(parent, SWT.DIALOG_TRIM | SWT.RESIZE, CAVE.DO_NOT_BLOCK); - setText("Fax Site Editor"); - } - - @Override - protected Layout constructShellLayout() { - // Create the main layout for the shell. - GridLayout mainLayout = new GridLayout(1, false); - mainLayout.marginHeight = 0; - mainLayout.marginWidth = 2; - mainLayout.verticalSpacing = 2; - return mainLayout; - } - - @Override - protected Object constructShellLayoutData() { - return new GridData(SWT.FILL, SWT.FILL, true, true); - } - - @Override - protected void initializeComponents(Shell shell) { - // Create the menus - createMenus(); - - // Create the controls on the display - createControls(); - } - - private void createMenus() { - Menu menuBar = new Menu(shell, SWT.BAR); - - createFileMenu(menuBar); - createViewMenu(menuBar); - createHelpMenu(menuBar); - - shell.setMenuBar(menuBar); - } - - private void createFileMenu(Menu menuBar) { - // ------------------------------------- - // Create the file menu - // ------------------------------------- - MenuItem fileMenuItem = new MenuItem(menuBar, SWT.CASCADE); - fileMenuItem.setText("&File"); - - // Create the File menu item with a File "dropdown" menu - Menu fileMenu = new Menu(menuBar); - fileMenuItem.setMenu(fileMenu); - - /* - * Add Site - */ - MenuItem addSiteMI = new MenuItem(fileMenu, SWT.NONE); - addSiteMI.setText("Add Site..."); - addSiteMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - addSiteAction(); - } - }); - - /* - * Edit Site - */ - MenuItem editSiteMI = new MenuItem(fileMenu, SWT.NONE); - editSiteMI.setText("Edit Site..."); - editSiteMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - editSiteAction(); - } - }); - - /* - * Update DB - */ - MenuItem updateDbMI = new MenuItem(fileMenu, SWT.NONE); - updateDbMI.setText("Update DB"); - updateDbMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - updateDBAction(); - } - }); - - /* - * Exit - */ - MenuItem exitMI = new MenuItem(fileMenu, SWT.NONE); - exitMI.setText("Exit"); - exitMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - shell.dispose(); - } - }); - } - - private void createViewMenu(Menu menuBar) { - // ------------------------------------- - // Create the View menu - // ------------------------------------- - MenuItem viewMenuItem = new MenuItem(menuBar, SWT.CASCADE); - viewMenuItem.setText("&View"); - - // Create the View menu item with a View "dropdown" menu - Menu viewMenu = new Menu(menuBar); - viewMenuItem.setMenu(viewMenu); - - /* - * Sort by Fax Number - */ - MenuItem sortByFaxMI = new MenuItem(viewMenu, SWT.NONE); - sortByFaxMI.setText("Sort by Fax Number"); - sortByFaxMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - sortByFaxAction(); - } - }); - - /* - * Sort by AFOS PIL - */ - MenuItem sortByAfosPilMI = new MenuItem(viewMenu, SWT.NONE); - sortByAfosPilMI.setText("Sort by AFOS PIL"); - sortByAfosPilMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - sortByAfosPilAction(); - } - }); - } - - private void createHelpMenu(Menu menuBar) { - // ------------------------------------- - // Create the help menu - // ------------------------------------- - MenuItem helpMenuItem = new MenuItem(menuBar, SWT.CASCADE); - helpMenuItem.setText("&Help"); - - // Create the Help menu item with a Help "dropdown" menu - Menu helpMenu = new Menu(menuBar); - helpMenuItem.setMenu(helpMenu); - - /* - * Contents and About - */ - MenuItem contentsMI = new MenuItem(helpMenu, SWT.NONE); - contentsMI.setText("&Contents"); - contentsMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - - } - }); - - MenuItem aboutMI = new MenuItem(helpMenu, SWT.NONE); - aboutMI.setText("&About"); - aboutMI.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - - } - }); - } - - private void createControls() { - - /* - * Add the tree view of existing fax sites - */ - GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); - gd.widthHint = 300; - gd.heightHint = 450; - faxSiteTree = new Tree(shell, SWT.MULTI | SWT.BORDER | SWT.SINGLE); - faxSiteTree.setLayoutData(gd); - faxSiteTree.setLinesVisible(true); - faxSiteTree.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - treeSelectionAction(); - } - }); - - getRecordsFromDB(); - - gd = new GridData(SWT.FILL, SWT.FILL, true, true); - Group siteInfoGroup = new Group(shell, SWT.NONE); - siteInfoGroup.setLayout(new GridLayout(1, false)); - siteInfoGroup.setLayoutData(gd); - siteInfoGroup.setText(" Site Information "); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - faxNumLbl = new Label(siteInfoGroup, SWT.NONE); - faxNumLbl.setLayoutData(gd); - setLabelText(faxNumLbl, faxNumPrefix, null); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - afosPilLbl = new Label(siteInfoGroup, SWT.NONE); - afosPilLbl.setLayoutData(gd); - setLabelText(afosPilLbl, afosPilPrefix, null); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - companyLbl = new Label(siteInfoGroup, SWT.NONE); - companyLbl.setLayoutData(gd); - setLabelText(companyLbl, companyPrefix, null); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - phoneNumLbl = new Label(siteInfoGroup, SWT.NONE); - phoneNumLbl.setLayoutData(gd); - setLabelText(phoneNumLbl, phoneNumPrefix, null); - - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - contactLbl = new Label(siteInfoGroup, SWT.NONE); - contactLbl.setLayoutData(gd); - setLabelText(contactLbl, contactPrefix, null); - - /* - * Update DB button - */ - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - updateDbBtn = new Button(shell, SWT.PUSH); - updateDbBtn.setText("Update DB"); - updateDbBtn.setLayoutData(gd); - updateDbBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - updateDBAction(); - } - }); - } - - protected void treeSelectionAction() { - for (TreeItem treeItem : faxSiteTree.getSelection()) { - if (null != treeItem.getParentItem()) { - TreeItem parent = treeItem.getParentItem(); - String index = parent.getText(); - String second = treeItem.getText(); - for (AutoFaxRecord faxRecord : currentList.getAutoFaxList()) { - if (sortByPil) { - if (index.equals(faxRecord.getId().getAfosPil()) - && second.equals(faxRecord.getId() - .getFaxNumber())) { - updateInfoDisplay(faxRecord); - } - } else { - if (index.equals(faxRecord.getId().getFaxNumber()) - && second - .equals(faxRecord.getId().getAfosPil())) { - updateInfoDisplay(faxRecord); - } - } - } - } - } - } - - private void updateInfoDisplay(AutoFaxRecord faxRecord) { - setLabelText(faxNumLbl, faxNumPrefix, faxRecord.getId().getFaxNumber()); - setLabelText(afosPilLbl, afosPilPrefix, faxRecord.getId().getAfosPil()); - setLabelText(companyLbl, companyPrefix, faxRecord.getCompany()); - setLabelText(phoneNumLbl, phoneNumPrefix, faxRecord.getPhoneNumber()); - setLabelText(contactLbl, contactPrefix, faxRecord.getRecipient()); - } - - private void setLabelText(Label lbl, String prefix, String text) { - if (text != null) { - lbl.setText(prefix + text); - } else { - lbl.setText(prefix); - } - } - - private void addSiteAction() { - if (faxSiteEditorDlg == null || faxSiteEditorDlg.isDisposed()) { - faxSiteEditorDlg = new FaxSiteEditorDlg(shell, this); - faxSiteEditorDlg.open(); - } else { - faxSiteEditorDlg.bringToTop(); - } - } - - private void editSiteAction() { - - if (faxSiteTree.getSelection().length > 0) { - faxSiteEditorDlg = new FaxSiteEditorDlg(shell, this); - for (TreeItem treeItem : faxSiteTree.getSelection()) { - if (null != treeItem.getParentItem()) { - TreeItem parent = treeItem.getParentItem(); - String index = parent.getText(); - String second = treeItem.getText(); - for (AutoFaxRecord faxRecord : currentList.getAutoFaxList()) { - if (sortByPil) { - if (index.equals(faxRecord.getId().getAfosPil()) - && second.equals(faxRecord.getId() - .getFaxNumber())) { - faxSiteEditorDlg.setFaxRecord(faxRecord); - } - } else { - if (index.equals(faxRecord.getId().getFaxNumber()) - && second.equals(faxRecord.getId() - .getAfosPil())) { - faxSiteEditorDlg.setFaxRecord(faxRecord); - } - } - } - } - } - faxSiteEditorDlg.addCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - faxSiteEditorDlg = null; - } - }); - faxSiteEditorDlg.open(); - } - } - - private void sortByFaxAction() { - sortByPil = false; - populateTree(); - } - - private void sortByAfosPilAction() { - sortByPil = true; - populateTree(); - } - - /* - * TODO - this just fills the tree with sample data - */ - private void populateTree() { - // Construct the map used to build the tree. - TreeMap> treeMap = new TreeMap>(); - if (sortByPil) { - for (AutoFaxRecord faxRecord : currentList.getAutoFaxList()) { - if (treeMap.get(faxRecord.getId().getAfosPil()) == null) { - treeMap.put(faxRecord.getId().getAfosPil(), - new ArrayList()); - } - treeMap.get(faxRecord.getId().getAfosPil()).add( - faxRecord.getId().getFaxNumber()); - } - } else { - for (AutoFaxRecord faxRecord : currentList.getAutoFaxList()) { - if (treeMap.get(faxRecord.getId().getFaxNumber()) == null) { - treeMap.put(faxRecord.getId().getFaxNumber(), - new ArrayList()); - } - treeMap.get(faxRecord.getId().getFaxNumber()).add( - faxRecord.getId().getAfosPil()); - } - } // We now have a sorted set of the desired key to a list of the - // secondary values corresponding to that key. - - // Turn off drawing to avoid flicker - faxSiteTree.removeAll(); - faxSiteTree.setRedraw(false); - - for (String index : treeMap.keySet()) { - TreeItem item = new TreeItem(faxSiteTree, SWT.NONE); - item.setText(index); - item.setExpanded(true); - - for (String secondary : treeMap.get(index)) { - TreeItem child = new TreeItem(item, SWT.NONE); - child.setText(secondary); - } - } - // Turn drawing back on! - faxSiteTree.setRedraw(true); - } - - protected void addAutoFaxSite(AutoFaxRecord add) { - addList.add(add); - currentList.add(add); - populateTree(); - } - - protected void deleteAutoFaxSite(AutoFaxRecord del) { - removeList.add(del); - currentList.getAutoFaxList().remove(del); - populateTree(); - } - - protected void updateDBAction() { - for (AutoFaxRecord faxRecord : removeList.getAutoFaxList()) { - AutoFaxRequest faxReq = new AutoFaxRequest(faxRecord.getId() - .getAfosPil(), faxRecord.getId().getFaxNumber(), - faxRecord.getPhoneNumber(), faxRecord.getRecipient(), - faxRecord.getCompany(), true); - try { - ThriftClient.sendRequest(faxReq); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error removing autofax record.", e); - } - } - for (AutoFaxRecord faxRecord : addList.getAutoFaxList()) { - AutoFaxRequest faxReq = new AutoFaxRequest(faxRecord.getId() - .getAfosPil(), faxRecord.getId().getFaxNumber(), - faxRecord.getPhoneNumber(), faxRecord.getRecipient(), - faxRecord.getCompany(), false); - try { - ThriftClient.sendRequest(faxReq); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error adding autofax record.", e); - } - } - removeList.getAutoFaxList().clear(); - addList.getAutoFaxList().clear(); - getRecordsFromDB(); - } - - private void getRecordsFromDB() { - GetAutoFaxRecordsRequest getRecords = new GetAutoFaxRecordsRequest(); - AutoFaxContainer temp = null; - try { - temp = (AutoFaxContainer) ThriftClient.sendRequest(getRecords); - } catch (VizException e) { - statusHandler.handle(Priority.PROBLEM, - "Error obtaining auto fax records from DB.", e); - } - if (null != temp) { - currentList = temp; - populateTree(); - } - - } - - protected void removeSiteFromTree(String afosPil, String faxNumber) { - if (null != currentList) { - for (AutoFaxRecord faxRecord : currentList.getAutoFaxList()) { - if (faxRecord.getId().getAfosPil().equals(afosPil) - && faxRecord.getId().getFaxNumber().equals(faxNumber)) { - currentList.getAutoFaxList().remove(faxRecord); - break; - } - } - populateTree(); - } - } -} diff --git a/cave/com.raytheon.viz.textworkstation/plugin.xml b/cave/com.raytheon.viz.textworkstation/plugin.xml index 844c7758dd..52668041d3 100644 --- a/cave/com.raytheon.viz.textworkstation/plugin.xml +++ b/cave/com.raytheon.viz.textworkstation/plugin.xml @@ -20,6 +20,22 @@ --> + + + + + + + + + + + + - - - - - - - - diff --git a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java index 18850c1332..4c0ea9f436 100644 --- a/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java +++ b/cave/com.raytheon.viz.textworkstation/src/com/raytheon/viz/textworkstation/TextWorkstationDlg.java @@ -127,6 +127,7 @@ import com.raytheon.viz.ui.dialogs.DialogUtil; * Jan 03, 2018 6804 tgurney Stop all scripts on dispose * Jan 24, 2018 7132 tgurney Set alarm/alert bell to null on dispose * May 23, 2018 7313 tgurney Add scroll bar and allow resize + * Nov 16, 2020 mjames Disable pop-up of first text editor * Apr 29, 2021 8137 randerso Force use of short hostname for * text workstation queue * @@ -328,7 +329,7 @@ public class TextWorkstationDlg extends CaveSWTDialog } // Display the first Text Editor - showTextEditor(0); + // showTextEditor(0); } private void createMenus() { diff --git a/cave/com.raytheon.viz.warngen/META-INF/MANIFEST.MF b/cave/com.raytheon.viz.warngen/META-INF/MANIFEST.MF index 9d19e09f02..a9b058438d 100644 --- a/cave/com.raytheon.viz.warngen/META-INF/MANIFEST.MF +++ b/cave/com.raytheon.viz.warngen/META-INF/MANIFEST.MF @@ -42,6 +42,7 @@ Import-Package: com.raytheon.uf.common.activetable, com.raytheon.uf.common.dataplugin.text.request, javax.vecmath, org.eclipse.core.expressions, + com.raytheon.viz.textworkstation, com.raytheon.viz.core.mode, com.raytheon.viz.core.map Bundle-ClassPath: com.raytheon.viz.warngen.jar diff --git a/cave/com.raytheon.viz.warngen/plugin.xml b/cave/com.raytheon.viz.warngen/plugin.xml index 79aa974eac..39c068387f 100644 --- a/cave/com.raytheon.viz.warngen/plugin.xml +++ b/cave/com.raytheon.viz.warngen/plugin.xml @@ -47,29 +47,6 @@ - - - - - - - - - - - - - - - * - * SOFTWARE HISTORY - * Date Ticket# Engineer Description - * ------------ ---------- ----------- -------------------------- - * Nov 11, 2009 mschenke Initial creation - * 01Jun2010 2187 cjeanbap Added operational mode functionality - * 02Aug2010 2187 cjeanbap Update variable/method signature to be consistent. - * 04Oct2010 7193 cjeanbap Add time-to-live value to MessageProducer. - * Sep 13, 2013 2368 rjpeter Set delivery mode to PERSISTENT. - * May 7, 2015 ASM #17438 D. Friedman Clean up debug and performance logging. - * Sep 03, 2015 4784 rjpeter Set notifySubscriptions on sendToTextDatabase. - * - * - * @author mschenke - * @version 1.0 - */ - -public class WarningSender implements IWarngenObserver { - private static final transient IUFStatusHandler statusHandler = UFStatus - .getHandler(WarningSender.class); - - private static final IPerformanceStatusHandler perfLog = PerformanceStatus - .getHandler("WG:"); - - private final String hostName = null; - - private boolean notifyError; - - private static final long MILLISECONDS_PER_SECOND = 1000; - - private static final long SECONDS_PER_MINUTE = 60; - - private static final long TTL_MINUTES = 5; - - private static Pattern PATTERN = Pattern.compile("(\\d{1,1})"); - - private static final SimpleDateFormat sdf; - - static { - sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); - sdf.setTimeZone(TimeZone.getTimeZone("GMT")); - } - - /* - * (non-Javadoc) Incoming message was not a binary - * - * @see - * com.raytheon.viz.texteditor.msgs.IWarngenObserver#setTextWarngenDisplay - * (java.lang.String) - */ - @Override - public void setTextWarngenDisplay(String warning, boolean ne) { - this.notifyError = ne; - - String number = "0"; - String host = TextWorkstationConstants.getId(); - long t0 = System.currentTimeMillis(); - String siteNode = SiteAbbreviationUtil.getSiteNode(LocalizationManager - .getInstance().getCurrentSite()); - perfLog.logDuration("Get site node time", - System.currentTimeMillis() - t0); - if (host == null) { - statusHandler.handle(Priority.ERROR, - "Text Workstation host not set in preferences."); - } else { - Matcher m = PATTERN.matcher(host); - if (m.find()) { - number = m.group(); - } - } - - String id = siteNode + "WRKWG" + number; - boolean sentToTextDatabase = false; - - try { - boolean messageNotSent = true; - int connectCount = 0; - t0 = System.currentTimeMillis(); - byte[] data = SerializationUtil.transformToThrift(id + ":" - + warning); - while (messageNotSent && (connectCount < 4)) { - Session s = null; - MessageProducer mp = null; - Connection conn = null; - try { - conn = JMSConnection.getInstance().getFactory() - .createConnection(); - s = conn.createSession(false, Session.CLIENT_ACKNOWLEDGE); - mp = s.createProducer(s - .createQueue(TextWorkstationConstants - .getDestinationTextWorkstationQueueName())); - mp.setTimeToLive(TTL_MINUTES * SECONDS_PER_MINUTE - * MILLISECONDS_PER_SECOND); - BytesMessage m = s.createBytesMessage(); - m.writeBytes(data); - m.setJMSDeliveryMode(DeliveryMode.PERSISTENT); - mp.send(m); - long t1 = System.currentTimeMillis(); - perfLog.log(id + " sent to text workstation in " - + (t1 - t0) + "ms in " + (connectCount + 1) - + (connectCount > 0 ? " tries" : " try")); - messageNotSent = false; - } catch (JMSException e) { - if (notifyError) { - statusHandler - .handle(Priority.PROBLEM, - "Error trying to send product [" - + id - + "] to Text Workstation. Attempting to reconnect. ", - e); - notifyError = false; - } - } finally { - if (mp != null) { - try { - mp.close(); - mp = null; - } catch (Exception e) { - mp = null; - } - } - if (s != null) { - try { - s.close(); - s = null; - } catch (Exception e) { - s = null; - } - } - if (conn != null) { - try { - conn.close(); - conn = null; - } catch (Exception e) { - conn = null; - } - } - } - if (messageNotSent) { - if (!sentToTextDatabase) { - try { - sendToTextDatabase(id, warning); - sentToTextDatabase = true; - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error trying to save product [" + id - + "] to Text Database: ", e); - } - } - - connectCount++; - switch (connectCount) { - case 1: - Thread.sleep(1000); - break; - case 2: - Thread.sleep(5 * 1000); - break; - case 3: - Thread.sleep(30 * 1000); - break; - case 4: - statusHandler.handle(Priority.PROBLEM, - "Could not reconnect (" + id - + ") after 3 tries: "); - break; - } - } - } - - if (!sentToTextDatabase) { - try { - sendToTextDatabase(id, warning); - sentToTextDatabase = true; - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error trying to save product [" + id - + "] to Text Database: ", e); - } - } - } catch (UnknownHostException uhe) { - if (notifyError) { - statusHandler.handle(Priority.PROBLEM, - "unable to map hostname, " + hostName - + ", to an ip address", uhe); - notifyError = false; - } - - } catch (Exception e) { - statusHandler.handle(Priority.PROBLEM, - "Error trying to send product [" + id - + "] to Text Workstation: ", e); - } - - } - - /** - * Saves a product to the text database. - * - * @param id - * @param warning - * @throws VizException - */ - public static void sendToTextDatabase(String id, String warning) - throws VizException { - CAVEMode mode = CAVEMode.getMode(); - boolean operationalMode = (CAVEMode.OPERATIONAL.equals(mode) - || CAVEMode.TEST.equals(mode) ? true : false); - - // Generate StdTextProduct and insert into db - long t0 = System.currentTimeMillis(); - InsertStdTextProductRequest request = new InsertStdTextProductRequest(id, warning, - operationalMode); - request.setNotifySubscriptions(true); - ThriftClient.sendRequest(request); - - perfLog.logDuration(id + " save to textdb", - System.currentTimeMillis() - t0); - } - - public static String getCurTimeString() { - String rval = null; - synchronized (sdf) { - rval = sdf.format(new Date()); - } - return rval; - } -} diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java index ab73bc5d54..bfa86974af 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenDialog.java @@ -59,9 +59,11 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; @@ -96,19 +98,18 @@ import com.raytheon.uf.viz.core.requests.ThriftClient; import com.raytheon.uf.viz.core.rsc.AbstractVizResource; import com.raytheon.uf.viz.core.rsc.AbstractVizResource.ResourceStatus; import com.raytheon.uf.viz.core.rsc.IDisposeListener; -import com.raytheon.uf.viz.d2d.ui.map.SideView; import com.raytheon.uf.viz.vtec.VtecUtil; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.DisplayType; import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState.Mode; import com.raytheon.viz.core.mode.CAVEMode; -import com.raytheon.viz.texteditor.msgs.IWarngenObserver; +import com.raytheon.viz.texteditor.TextWorkstationConstants; +import com.raytheon.viz.texteditor.dialogs.TextEditorDialog; +import com.raytheon.viz.texteditor.util.SiteAbbreviationUtil; import com.raytheon.viz.ui.EditorUtil; import com.raytheon.viz.ui.dialogs.CaveSWTDialog; -import com.raytheon.viz.ui.dialogs.ICloseCallback; import com.raytheon.viz.ui.input.EditableManager; import com.raytheon.viz.ui.simulatedtime.SimulatedTimeOperations; import com.raytheon.viz.warngen.Activator; -import com.raytheon.viz.warngen.comm.WarningSender; import com.raytheon.viz.warngen.gis.PolygonUtil; import com.raytheon.viz.warngen.template.TemplateRunner; import com.raytheon.viz.warngen.util.CurrentWarnings; @@ -250,7 +251,10 @@ import com.raytheon.viz.warngen.util.FollowUpUtil; * Aug 29, 2017 6328 randerso Convert to use PresetInfoBullet. Made * GUI resizable. Removed/renamed dam * specific code. - * Oct 16, 2017 18282 Qinglu Lin Updated resetPressed(). + * Jun 25, 2017 mjames@ucar Simple dialog. + * Oct 16, 2017 18282 Qinglu Lin Updated resetPressed(). + * Jun 07, 2018 mjames@ucar Bypass JMS messaging and send directly + * to a textWS window. * Mar 02, 2018 6786 dgilling Pass event duration if product uses * durations instead of explicit start * and end times. @@ -258,6 +262,20 @@ import com.raytheon.viz.warngen.util.FollowUpUtil; * Mar 09, 2020 8050 randerso Created separate function to update * the bullets in the list vs updating * which bullets are selected. + * Nov 17, 2021 srcarter@ucar Set reasonable height, allow proper + * resizing, remove instructions label call + * because it's null and never used, change + * bulletlist functionality so it doesn't + * scroll to the top as soon as a user makes + * a selection + * Dec 20, 2021 srcarter@ucar Check for null before setting layout data + * on tabs. Make all other components have false + * for vertical expansion so the resizing + * only resizes the bullet list + * Mar 15, 2022 srcarter@ucar Set the proper number of columns in the layout + * for the bottom buttons to be centered + * Jun 28, 2022 srcarter@ucar Small change to disable the "UPDATE LIST" + * combobox (not used in Unidata version) * * * @@ -285,6 +303,8 @@ public class WarngenDialog extends CaveSWTDialog private static final int FONT_HEIGHT = 9; + private static Pattern PATTERN = Pattern.compile("(\\d{1,1})"); + private class TemplateRunnerInitJob extends Job { private final String site; @@ -311,8 +331,6 @@ public class WarngenDialog extends CaveSWTDialog private static final String UPDATELISTTEXT = "UPDATE LIST "; - private static final String NO_BACKUP_SELECTED = "none"; - /** "OK" button text */ private static final String OK_BTN_LABEL = "Create Text"; @@ -366,8 +384,6 @@ public class WarngenDialog extends CaveSWTDialog private Button fromTrack; - private Button warnedAreaVisible; - private Button[] mainProductBtns; private Button other; @@ -378,10 +394,6 @@ public class WarngenDialog extends CaveSWTDialog public Button box; - private Button changeBtn; - - private ValidPeriodDialog validPeriodDlg; - private boolean boxEditable = true; private boolean trackEditable = true; @@ -398,15 +410,13 @@ public class WarngenDialog extends CaveSWTDialog private Button presetThreatArea; - private Group instructionsGroup; + private Label instructionsLabel; private Button restartBtn; - private Text start; + private Label validPeriod; - private Text end; - - private Combo backupSiteCbo; + private static String SEP = " to "; private Text instructionsBox; @@ -414,7 +424,7 @@ public class WarngenDialog extends CaveSWTDialog private boolean invalidFollowUpAction = false; - private final IWarngenObserver wed = new WarningSender(); + private TextEditorDialog wgDlg; /** Bullet list font. */ private Font bulletListFont = null; @@ -450,16 +460,19 @@ public class WarngenDialog extends CaveSWTDialog timer.cancel(); updateTimeTask.cancel(); CurrentWarnings.removeListener(this); - IDisplayPaneContainer container = warngenLayer.getResourceContainer(); - if (container != null && !(container instanceof SideView)) { - WarngenLayer - .setLastSelectedBackupSite(warngenLayer.getBackupSite()); - } warngenLayer = null; } @Override protected void initializeComponents(Shell shell) { + shell.addListener(SWT.Close, new Listener() { + @Override + public void handleEvent(Event event) { + event.doit = false; + closePressed(); + } + }); + Composite parent = shell; boolean advanced = isAdvancedOptionsEnabled(); CTabFolder tabs = null; @@ -481,8 +494,11 @@ public class WarngenDialog extends CaveSWTDialog gl.marginWidth = 1; mainComposite.setLayout(gl); - GridData gd = new GridData(SWT.DEFAULT, SWT.FILL, false, true); + GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); mainComposite.setLayoutData(gd); + if (tabs != null) { + tabs.setLayoutData(gd); + } createBackupTrackEditGroups(mainComposite); createRedrawBoxGroup(mainComposite); @@ -490,7 +506,18 @@ public class WarngenDialog extends CaveSWTDialog createTimeRangeGroup(mainComposite); createBulletListAndLabel(mainComposite); createBottomButtons(mainComposite); - setBackupSite(); + createMainProductButtons(productType); + createOtherProductsList(productType); + productType.layout(true, true); + // Don't let errors prevent the new controls from being displayed! + try { + changeTemplate(getDefaultTemplate()); + resetPressed(); + } catch (Exception e) { + statusHandler.error( + "Error occurred while switching to the default template.", + e); + } setInstructions(); if (advanced) { @@ -536,7 +563,7 @@ public class WarngenDialog extends CaveSWTDialog GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); gd.widthHint = BULLETLIST_WIDTH_IN_CHARS * charWidth; - gd.heightHint = BULLETLIST_HEIGHT_IN_LINES * lineHeight; + gd.heightHint = lineHeight * 4; bulletList.setLayoutData(gd); bulletListManager.recreateBullets( warngenLayer.getConfiguration().getBullets(), @@ -546,28 +573,14 @@ public class WarngenDialog extends CaveSWTDialog bulletList.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { + // get the current scroll location + int topIdx = bulletList.getTopIndex(); bulletListSelected(); + // reset the scroll location back after the update + bulletList.setTopIndex(topIdx); } }); - instructionsGroup = new Group(mainComposite, SWT.NONE); - instructionsGroup.setText("Instructions"); - GridLayout layout = new GridLayout(1, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - instructionsGroup.setLayout(layout); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - instructionsGroup.setLayoutData(gd); - - instructionsBox = new Text(instructionsGroup, - SWT.READ_ONLY | SWT.MULTI); - instructionsBox.setText(""); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - lineHeight = instructionsBox.getLineHeight(); - gd.heightHint = INSTRUCTIONS_HEIGHT_IN_LINES * lineHeight; - instructionsBox.setLayoutData(gd); - instructionsBox.setBackground(instructionsGroup.getBackground()); - startTimeTimer(); } @@ -576,24 +589,21 @@ public class WarngenDialog extends CaveSWTDialog */ private void createTimeRangeGroup(Composite mainComposite) { Group timeRange = new Group(mainComposite, SWT.NONE); - timeRange.setText("Time Range"); - timeRange.setLayout(new GridLayout(1, false)); - GridData gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - timeRange.setLayoutData(gd); + GridLayout gl = new GridLayout(1, false); + gl.verticalSpacing = 2; + gl.marginHeight = 1; + timeRange.setLayout(gl); + timeRange.setLayoutData( + new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1)); - Composite durComp = new Composite(timeRange, SWT.NONE); - GridLayout layout = new GridLayout(2, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - durComp.setLayout(layout); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - durComp.setLayoutData(gd); + Composite timeRangeComp = new Composite(timeRange, SWT.NONE); + timeRangeComp.setLayout(new GridLayout(3, false)); + timeRangeComp.setLayoutData( + new GridData(SWT.DEFAULT, SWT.FILL, false, false)); - Label dur = new Label(durComp, SWT.BOLD); - dur.setText("Duration:"); - - gd = new GridData(); - durationList = new Combo(durComp, SWT.READ_ONLY); + GridData gd = new GridData(); + gd.horizontalSpan = 1; + durationList = new Combo(timeRangeComp, SWT.READ_ONLY); WarngenConfiguration config = warngenLayer.getConfiguration(); if (config.getDefaultDuration() != 0) { setDefaultDuration(config.getDefaultDuration()); @@ -605,37 +615,15 @@ public class WarngenDialog extends CaveSWTDialog durationList.setLayoutData(gd); durationList.setEnabled(config.isEnableDuration()); - Composite changeComp = new Composite(timeRange, SWT.NONE); - layout = new GridLayout(4, false); - layout.marginHeight = 0; - layout.marginWidth = 0; - changeComp.setLayout(layout); - gd = new GridData(SWT.FILL, SWT.DEFAULT, true, false); - changeComp.setLayoutData(gd); - startTime = TimeUtil.newCalendar(); endTime = DurationUtil.calcEndTime(this.startTime, defaultDuration.minutes); gd = new GridData(); - start = new Text(changeComp, SWT.BORDER | SWT.READ_ONLY); - start.setLayoutData(gd); - start.setText(df.format(this.startTime.getTime())); - - new Label(changeComp, SWT.NONE).setText(" to "); - - end = new Text(changeComp, SWT.BORDER | SWT.READ_ONLY); - end.setText(df.format(this.endTime.getTime())); - - changeBtn = new Button(changeComp, SWT.PUSH); - changeBtn.setText("Change..."); - changeBtn.setEnabled(!config.isEnableDuration()); - changeBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - changeSelected(); - } - }); + gd.horizontalSpan = 2; + validPeriod = new Label(timeRangeComp, SWT.FILL); + validPeriod.setText(df.format(this.startTime.getTime()) + SEP + + df.format(this.endTime.getTime())); durationList.addSelectionListener(new SelectionAdapter() { @Override @@ -647,7 +635,6 @@ public class WarngenDialog extends CaveSWTDialog private void createProductTypeGroup(Composite mainComposite) { productType = new Group(mainComposite, SWT.NONE); - productType.setText("Product type"); GridLayout gl = new GridLayout(2, false); gl.verticalSpacing = 2; gl.marginHeight = 1; @@ -736,6 +723,8 @@ public class WarngenDialog extends CaveSWTDialog gd.horizontalIndent = 30; updateListCbo = new Combo(productType, SWT.READ_ONLY | SWT.DROP_DOWN); + // disable the update list since we disable sending of warnings + updateListCbo.setEnabled(false); updateListCbo.setLayoutData(gd); recreateUpdates(); @@ -790,22 +779,9 @@ public class WarngenDialog extends CaveSWTDialog gl.verticalSpacing = 2; gl.marginHeight = 1; redrawBox.setLayout(gl); - redrawBox.setText("Redraw Box on Screen from:"); redrawBox.setLayoutData( new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - warnedAreaVisible = new Button(redrawBox, SWT.CHECK); - warnedAreaVisible.setText("Warned Area Visible"); - warnedAreaVisible.setLayoutData( - new GridData(SWT.RIGHT, SWT.DEFAULT, true, false)); - warnedAreaVisible.setSelection(true); - warnedAreaVisible.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - warnedAreaVisibleToggled(); - } - }); - Composite redrawFrom = new Composite(redrawBox, SWT.NONE); int columns = debug ? 4 : 3; redrawFrom.setLayout(new GridLayout(columns, false)); @@ -875,62 +851,28 @@ public class WarngenDialog extends CaveSWTDialog backupTrackEditComp.setLayoutData( new GridData(SWT.FILL, SWT.DEFAULT, true, false)); - createBackupGroup(backupTrackEditComp); + restartBtn = new Button(backupTrackEditComp, SWT.PUSH); + restartBtn.setText("Reset"); + GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, false); + gd.widthHint = 100; + restartBtn.setLayoutData(gd); + restartBtn.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + resetPressed(); + } + }); createTrackGroup(backupTrackEditComp); createEditGroup(backupTrackEditComp); - // Populate the control - populateBackupGroup(); - } + gd = new GridData(SWT.FILL, SWT.FILL, true, false); + gd.heightHint = 40; + instructionsBox = new Text(mainComposite, + SWT.NONE | SWT.READ_ONLY | SWT.MULTI); + instructionsBox.setText(""); + instructionsBox.setLayoutData(gd); + // instructionsBox.setSize(SWT.DEFAULT, SWT.DEFAULT); - /** - * Create the backup site - * - * @param backupTrackEditComp - */ - private void createBackupGroup(Composite backupTrackEditComp) { - Group backupGroup = new Group(backupTrackEditComp, SWT.NONE); - backupGroup.setLayoutData( - new GridData(SWT.DEFAULT, SWT.FILL, false, true)); - backupGroup.setText("Backup"); - backupGroup.setLayout(new GridLayout(2, false)); - - Label label2 = new Label(backupGroup, SWT.BOLD); - label2.setText("WFO:"); - label2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - backupSiteCbo = new Combo(backupGroup, SWT.READ_ONLY | SWT.DROP_DOWN); - backupSiteCbo.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - backupSiteSelected(); - } - - }); - } - - /** - * Populate the backup site combo with data from preference store - */ - private void populateBackupGroup() { - backupSiteCbo.removeAll(); - backupSiteCbo.add(NO_BACKUP_SELECTED); - String[] CWAs = warngenLayer.getDialogConfig().getBackupCWAs() - .split(","); - int index = 0, selectedIndex = 0; - for (String cwa : CWAs) { - if (cwa.length() > 0) { - index += 1; - BackupData data = new BackupData(cwa); - backupSiteCbo.setData(data.site, data); - backupSiteCbo.add(data.site); - if (data.site.equals(warngenLayer.getBackupSite())) { - selectedIndex = index; - warngenLayer.setBackupSite(data.site); - } - } - } - backupSiteCbo.select(selectedIndex); - setBackupCboColors(); } private void createTrackGroup(Composite backupTrackEditComp) { @@ -939,12 +881,12 @@ public class WarngenDialog extends CaveSWTDialog gl.verticalSpacing = 2; gl.marginHeight = 1; trackGroup.setLayout(gl); - trackGroup.setText("Track type"); trackGroup.setLayoutData( - new GridData(SWT.DEFAULT, SWT.FILL, false, true)); + new GridData(SWT.DEFAULT, SWT.FILL, false, false)); + trackGroup.setBackgroundMode(SWT.INHERIT_NONE); oneStorm = new Button(trackGroup, SWT.RADIO); - oneStorm.setText("One Storm"); + oneStorm.setText("Single Storm"); oneStorm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent arg0) { @@ -985,9 +927,8 @@ public class WarngenDialog extends CaveSWTDialog gl.verticalSpacing = 2; gl.marginHeight = 1; editGroup.setLayout(gl); - editGroup.setText("Edit"); editGroup.setLayoutData( - new GridData(SWT.DEFAULT, SWT.FILL, false, true)); + new GridData(SWT.DEFAULT, SWT.FILL, false, false)); box = new Button(editGroup, SWT.RADIO); box.setText("Box"); @@ -1027,7 +968,7 @@ public class WarngenDialog extends CaveSWTDialog */ private void createBottomButtons(Composite parent) { Composite buttonComp = new Composite(parent, SWT.NONE); - GridLayout gl = new GridLayout(3, true); + GridLayout gl = new GridLayout(2, true); gl.marginHeight = 1; buttonComp.setLayout(gl); buttonComp.setLayoutData( @@ -1035,7 +976,7 @@ public class WarngenDialog extends CaveSWTDialog okButton = new Button(buttonComp, SWT.PUSH); okButton.setText(OK_BTN_LABEL); - GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); + GridData gd = new GridData(SWT.CENTER, SWT.CENTER, true, false); gd.widthHint = 100; okButton.setLayoutData(gd); okButton.addSelectionListener(new SelectionAdapter() { @@ -1053,21 +994,9 @@ public class WarngenDialog extends CaveSWTDialog }); - restartBtn = new Button(buttonComp, SWT.PUSH); - restartBtn.setText(RS_BTN_LABEL); - gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); - gd.widthHint = 100; - restartBtn.setLayoutData(gd); - restartBtn.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent event) { - resetPressed(); - } - }); - Button btn = new Button(buttonComp, SWT.PUSH); btn.setText(CLOSE_BUTTON_LABEL); - gd = new GridData(SWT.CENTER, SWT.CENTER, true, true); + gd = new GridData(SWT.CENTER, SWT.CENTER, true, false); gd.widthHint = 100; btn.setLayoutData(gd); btn.addSelectionListener(new SelectionAdapter() { @@ -1118,9 +1047,9 @@ public class WarngenDialog extends CaveSWTDialog str = presetInstruct; } instructionsBox.setText(str); - Point p1 = instructionsBox.getSize(); - Point p2 = instructionsBox.computeSize(SWT.DEFAULT, SWT.DEFAULT); - instructionsBox.setSize(new Point(p1.x, p2.y)); + // Point p1 = instructionsBox.getSize(); + // Point p2 = instructionsBox.computeSize(SWT.DEFAULT, SWT.DEFAULT); + // instructionsBox.setSize(new Point(p1.x, p2.y)); } /** @@ -1148,12 +1077,11 @@ public class WarngenDialog extends CaveSWTDialog WarningAction[] acts = new WarningAction[] { WarningAction.CON, WarningAction.COR, WarningAction.CAN, WarningAction.EXP, WarningAction.NEW, WarningAction.EXT }; - for (int i = 0; i < warnings.size(); i++) { + for (AbstractWarningRecord warning : warnings) { for (WarningAction act : acts) { if (FollowUpUtil.checkApplicable(site, - warngenLayer.getConfiguration(), warnings.get(i), - act)) { - FollowupData data = new FollowupData(act, warnings.get(i)); + warngenLayer.getConfiguration(), warning, act)) { + FollowupData data = new FollowupData(act, warning); updateListCbo.setData(data.getDisplayString(), data); if (act == WarningAction.NEW) { newYes = true; @@ -1214,8 +1142,8 @@ public class WarngenDialog extends CaveSWTDialog updateListCbo.add(UPDATELISTTEXT); updateListCbo.select(0); - for (int i = 0; i < dropDownItems.size(); i++) { - updateListCbo.add(dropDownItems.get(i)); + for (String dropDownItem : dropDownItems) { + updateListCbo.add(dropDownItem); } // Select the previously selected item. invalidFollowUpAction = false; @@ -1285,12 +1213,12 @@ public class WarngenDialog extends CaveSWTDialog ArrayList durList = new ArrayList<>(durations.length); boolean isDefaultDurationInList = false; durationList.removeAll(); - for (int i = 0; i < durations.length; i++) { + for (int duration : durations) { if (defaultDuration != null - && defaultDuration.minutes == durations[i]) { + && defaultDuration.minutes == duration) { isDefaultDurationInList = true; } - DurationData data = new DurationData(durations[i]); + DurationData data = new DurationData(duration); durationList.setData(data.displayString, data); durList.add(data.displayString); } @@ -1303,29 +1231,6 @@ public class WarngenDialog extends CaveSWTDialog durationList.setItems(durList.toArray(new String[durList.size()])); } - - /** - * Sets the Duration drop-down to a fixed value - * - * - * @param duration - * minutes to assign to duration - */ - public void setLockedDuration(int duration){ - - durationList.removeAll(); - DurationData data = new DurationData(duration); - //Split full string to largest time interval given by DurationData formatting - // Duration drop-down does not accept full duration string - String[] splitDuration = data.displayString.split(" "); - data.displayString = splitDuration[0] + " " +splitDuration[1]; - durationList.setData(data.displayString, data); - durationList.add(data.displayString); - durationList.setItem(0, data.displayString); - durationList.setText(data.displayString); - durationList.setEnabled(false); - - } /** * Set the default duration @@ -1354,8 +1259,6 @@ public class WarngenDialog extends CaveSWTDialog .getSelectedBulletNames(); final FollowupData followupData = (FollowupData) updateListCbo.getData( updateListCbo.getItem(updateListCbo.getSelectionIndex())); - final BackupData backupData = (BackupData) backupSiteCbo.getData( - backupSiteCbo.getItem(backupSiteCbo.getSelectionIndex())); if (!checkFollowupSelection(followupData)) { return; @@ -1401,20 +1304,11 @@ public class WarngenDialog extends CaveSWTDialog statusHandler .debug("using startTime " + startTime.getTime() + " endTime " + endTime.getTime()); - if (warngenLayer.getConfiguration() - .isEnableDuration()) { - int duration = getSelectedDuration(); - resultContainer[0] = TemplateRunner.runTemplate( - warngenLayer, duration, extEndTime, - selectedBullets, followupData, backupData); - } else { - resultContainer[0] = TemplateRunner.runTemplate( - warngenLayer, startTime.getTime(), - endTime.getTime(), selectedBullets, - followupData, backupData); - } - Matcher m = FollowUpUtil.vtecPtrn - .matcher(resultContainer[0]); + String result = TemplateRunner.runTemplate(warngenLayer, + startTime.getTime(), endTime.getTime(), + selectedBullets, followupData, null); + resultContainer[0] = result; + Matcher m = FollowUpUtil.vtecPtrn.matcher(result); totalSegments = 0; while (m.find()) { totalSegments++; @@ -1448,7 +1342,7 @@ public class WarngenDialog extends CaveSWTDialog try { String result = resultContainer[0]; if (result != null) { - wed.setTextWarngenDisplay(result, true); + setTextWarngenDisplay(result); updateWarngenUIState(result); } else { statusHandler.handle(Priority.PROBLEM, @@ -1474,6 +1368,36 @@ public class WarngenDialog extends CaveSWTDialog } } + protected void setTextWarngenDisplay(String warning) { + String number = "0"; + String host = TextWorkstationConstants.getId(); + String siteNode = SiteAbbreviationUtil.getSiteNode( + LocalizationManager.getInstance().getCurrentSite()); + if (host == null) { + statusHandler.handle(Priority.ERROR, + "Text Workstation host not set in preferences."); + } else { + Matcher m = PATTERN.matcher(host); + if (m.find()) { + number = m.group(); + } + } + String id = siteNode + "WRKWG" + number; + try { + String product = id + ":" + warning; + if (wgDlg == null) { + wgDlg = new TextEditorDialog(getShell(), "Text Warngen", false, + "9", true); + } + wgDlg.showWarngenProduct(product, null); + } catch (Exception e) { + statusHandler.handle(Priority.PROBLEM, + "Error trying to send product [" + id + + "] to Text Workstation: ", + e); + } + } + private boolean checkPresetSelection() { if (bulletListManager.isPresetNameSeletcted()) { PresetInfoBullet presetBullet = bulletListManager @@ -1584,7 +1508,6 @@ public class WarngenDialog extends CaveSWTDialog } warngenLayer.resetInitialFrame(); warngenLayer.setWarningAction(null); - instructionsGroup.setText("Instructions"); changeStartEndTimes(); warngenLayer.issueRefresh(); setTrackLocked(false); @@ -1598,70 +1521,6 @@ public class WarngenDialog extends CaveSWTDialog hide(); } - private boolean setBackupSite() { - if ((backupSiteCbo.getSelectionIndex() >= 0) - && (backupSiteCbo.getItemCount() > 0)) { - int index = backupSiteCbo.getSelectionIndex(); - String backupSite = backupSiteCbo.getItem(index); - warngenLayer.setBackupSite(backupSite); - IDisplayPaneContainer container = warngenLayer - .getResourceContainer(); - if (container != null && !(container instanceof SideView)) { - WarngenLayer.setLastSelectedBackupSite(backupSite); - } - if ("none".equalsIgnoreCase(backupSite)) { - new TemplateRunnerInitJob().schedule(); - } else { - new TemplateRunnerInitJob(backupSite).schedule(); - } - - /* - * When the product selection buttons are recreated below, the - * button for the default template will be selected and mainProducts - * will have been recreated. Then getDefaultTemplate() can be used - * here to change the state. - */ - createMainProductButtons(productType); - createOtherProductsList(productType); - - // Don't let errors prevent the new controls from being displayed! - try { - changeTemplate(getDefaultTemplate()); - resetPressed(); - } catch (Exception e) { - statusHandler.error( - "Error occurred while switching to the default template.", - e); - } - return true; - } else { - return false; - } - } - - /** - * Action for when something is selected from the backup site combo - */ - private void backupSiteSelected() { - if (setBackupSite()) { - productType.layout(true, true); - getShell().pack(true); - } - setBackupCboColors(); - } - - private void setBackupCboColors() { - if (backupSiteCbo.getSelectionIndex() == 0) { - backupSiteCbo.setBackground(null); - backupSiteCbo.setForeground(null); - } else { - backupSiteCbo.setBackground( - shell.getDisplay().getSystemColor(SWT.COLOR_YELLOW)); - backupSiteCbo.setForeground( - shell.getDisplay().getSystemColor(SWT.COLOR_BLACK)); - } - } - /** * Select one storm */ @@ -1739,14 +1598,6 @@ public class WarngenDialog extends CaveSWTDialog realizeEditableState(); } - /** - * Whether to warn area visible was toggled - */ - private void warnedAreaVisibleToggled() { - warngenLayer.setShouldDrawShaded(warnedAreaVisible.getSelection()); - warngenLayer.issueRefresh(); - } - /** * Responsible for drawing a pre-defined warning polygon (coords) on the * WarnGen layer. @@ -1878,7 +1729,6 @@ public class WarngenDialog extends CaveSWTDialog boolean enableDuration = warngenLayer.getConfiguration() .isEnableDuration(); durationList.setEnabled(enableDuration); - changeBtn.setEnabled(!enableDuration); recreateDurations(durationList); // Current selection doesn't matter anymore @@ -1938,7 +1788,8 @@ public class WarngenDialog extends CaveSWTDialog if (warngenLayer.getConfiguration().isEnableDuration()) { endTime = DurationUtil.calcEndTime(startTime, defaultDuration.minutes); - end.setText(df.format(endTime.getTime())); + validPeriod.setText(df.format(startTime.getTime()) + SEP + + df.format(endTime.getTime())); } warngenLayer.getStormTrackState().newDuration = defaultDuration.minutes; @@ -2159,43 +2010,6 @@ public class WarngenDialog extends CaveSWTDialog // TODO : this pack/layout maybe causing the issue } - private void changeSelected() { - statusHandler.debug("changeSelected"); - if ((validPeriodDlg == null) || validPeriodDlg.isDisposed()) { - validPeriodDlg = new ValidPeriodDialog(shell, - (Calendar) startTime.clone(), (Calendar) endTime.clone()); - validPeriodDlg.addCloseCallback(new ICloseCallback() { - - @Override - public void dialogClosed(Object returnValue) { - int duration = (Integer) returnValue; - statusHandler - .debug("changeSelected.dialogClosed: " + duration); - if (duration != -1) { - durationList.setEnabled(false); - if (warngenLayer.getConfiguration() - .isEnableDuration()) { - endTime.add(Calendar.MINUTE, duration); - } else { - endTime = (Calendar) validPeriodDlg.getEndTime() - .clone(); - } - end.setText(df.format(endTime.getTime())); - warngenLayer - .getStormTrackState().newDuration = duration; - warngenLayer.getStormTrackState().geomChanged = true; - warngenLayer.issueRefresh(); - changeStartEndTimes(); - } - validPeriodDlg = null; - } - }); - validPeriodDlg.open(); - } else { - validPeriodDlg.bringToTop(); - } - } - /** * */ @@ -2206,7 +2020,8 @@ public class WarngenDialog extends CaveSWTDialog endTime = DurationUtil.calcEndTime( extEndTime != null ? extEndTime : startTime, ((DurationData) durationList.getData(selection)).minutes); - end.setText(df.format(endTime.getTime())); + validPeriod.setText(df.format(startTime.getTime()) + SEP + + df.format(endTime.getTime())); warngenLayer .getStormTrackState().newDuration = ((DurationData) durationList @@ -2222,7 +2037,6 @@ public class WarngenDialog extends CaveSWTDialog private void bulletListSelected() { bulletListManager.updateSelectedIndices(bulletList.getSelectionIndex(), warngenLayer.state.followupData != null); - refreshBulletSelections(); } /** @@ -2238,14 +2052,6 @@ public class WarngenDialog extends CaveSWTDialog // updateMaps(bulletListManager.getMapsToLoad()); } - /** - * Call this function when only selection has changed. - */ - private void refreshBulletSelections() { - bulletList.deselectAll(); - bulletList.select(bulletListManager.getSelectedIndices()); - } - private void updateMaps(java.util.List mapsToLoad) { /* Load maps */ for (String str : mapsToLoad) { @@ -2355,7 +2161,6 @@ public class WarngenDialog extends CaveSWTDialog FollowupData fd = (FollowupData) updateListCbo.getData( updateListCbo.getItem(updateListCbo.getSelectionIndex())); startTime = TimeUtil.newCalendar(); - start.setText(df.format(startTime.getTime())); if ((fd == null) || (WarningAction .valueOf(fd.getAct()) == WarningAction.NEW)) { endTime = DurationUtil.calcEndTime(startTime, duration); @@ -2365,7 +2170,8 @@ public class WarngenDialog extends CaveSWTDialog endTime = DurationUtil.calcEndTime(extEndTime, duration); } } - end.setText(df.format(endTime.getTime())); + validPeriod.setText(df.format(startTime.getTime()) + SEP + + df.format(endTime.getTime())); } } @@ -2574,7 +2380,6 @@ public class WarngenDialog extends CaveSWTDialog boolean enableDuration = warngenLayer.getConfiguration() .isEnableDuration(); durationList.setEnabled(enableDuration); - changeBtn.setEnabled(!enableDuration); AbstractWarningRecord newWarn = CurrentWarnings .getInstance(warngenLayer.getLocalizedSite()) @@ -2605,21 +2410,10 @@ public class WarngenDialog extends CaveSWTDialog private void setTimesFromFollowup(Date startDate, Date endDate) { // Sets the Time Range start and end times on dialog - start.setText(df.format(startDate)); startTime.setTime(startDate); - end.setText(df.format(endDate)); endTime.setTime(endDate); endTime.add(Calendar.MILLISECOND, 1); - // Sets the duration value on the dialog - int durationInMinutes = (int) ((endDate.getTime() - startDate.getTime()) - / (TimeUtil.MILLIS_PER_MINUTE)); - //Need to set the Duration drop down for followups - // When not set, will use the default 30min for a followup, - // which can omit the Day from a longer warning's followup - setLockedDuration(durationInMinutes); - - changeBtn.setEnabled(false); warngenLayer.getStormTrackState().endTime = endTime; } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java index a7941dcc99..8c3bb37b7f 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gui/WarngenLayer.java @@ -307,14 +307,8 @@ public class WarngenLayer extends AbstractStormTrackResource { private static final String EXTENSION_AREA_MAP_NAME = "WarnGen Extension Area"; - private static String lastSelectedBackupSite; - private String uniqueFip = null; - private String backupOfficeShort = null; - - private String backupOfficeLoc = null; - private Map geomArea = new HashMap<>(); private Map geomInteriorPt = new HashMap<>(); @@ -1477,8 +1471,6 @@ public class WarngenLayer extends AbstractStormTrackResource { private String templateName; - private String backupSite; - private boolean boxEditable = true; private final CustomMaps customMaps; @@ -1540,8 +1532,6 @@ public class WarngenLayer extends AbstractStormTrackResource { "Error loading config.xml", e); } - setBackupSite(WarngenLayer.getLastSelectedBackupSite()); - // Load default template String defaultTemplate = dialogConfig.getDefaultTemplate(); if (defaultTemplate.isEmpty()) { @@ -2085,7 +2075,7 @@ public class WarngenLayer extends AbstractStormTrackResource { try { config = WarngenConfiguration.loadConfig(templateName, LocalizationManager.getInstance().getCurrentSite(), - backupSite); + null); } catch (Exception e) { statusHandler.handle(Priority.PROBLEM, "Error occurred loading template " + templateName, e); @@ -2420,95 +2410,8 @@ public class WarngenLayer extends AbstractStormTrackResource { return state.getWarningPolygon(); } - public void setBackupSite(String site) { - if (site == null || "none".equalsIgnoreCase(site)) { - backupSite = null; - } else { - backupSite = site; - } - - DialogConfiguration dc = null; - if (backupSite != null) { - boolean haveBackupConfig = DialogConfiguration - .isSiteDialogConfigExtant(backupSite); - if (haveBackupConfig) { - try { - dc = DialogConfiguration.loadDialogConfigNoUser(backupSite); - } catch (Exception e) { - statusHandler.error(String.format( - "Unable to load WarnGen configuration for site %s. Falling back to local configuration.", - getLocalizedSite()), e); - } - } else { - statusHandler.warn(String.format( - "WarnGen configuration for site %s does not exist. Falling back to local configuration.", - backupSite)); - } - if (dc == null) { - try { - dc = DialogConfiguration.loadDialogConfigNoUser( - LocalizationManager.getInstance().getCurrentSite()); - } catch (Exception e) { - dc = new DialogConfiguration(); - statusHandler.error(String.format( - "Unable to load WarnGen configuration for site %s.", - getLocalizedSite()), e); - } - } - } else { - try { - dc = DialogConfiguration.loadDialogConfig( - LocalizationManager.getInstance().getCurrentSite()); - } catch (Exception e) { - dc = new DialogConfiguration(); - statusHandler.error( - "Unable to load local WarnGen configuration.", e); - } - } - if ((dc != null) && (dialogConfig != null)) { - dialogConfig.setDefaultTemplate(dc.getDefaultTemplate()); - dialogConfig.setMainWarngenProducts(dc.getMainWarngenProducts()); - dialogConfig.setOtherWarngenProducts(dc.getOtherWarngenProducts()); - backupOfficeShort = dc.getWarngenOfficeShort(); - backupOfficeLoc = dc.getWarngenOfficeLoc(); - if (backupSite != null) { - boolean shortTag = false; - boolean locTag = false; - String infoType = null; - if ((backupOfficeShort == null) - || (backupOfficeShort.trim().isEmpty())) { - shortTag = true; - } - if ((backupOfficeLoc == null) - || (backupOfficeLoc.trim().isEmpty())) { - locTag = true; - } - if (shortTag && locTag) { - infoType = "warngenOfficeShort and warngenOfficeLoc"; - } else { - if (shortTag) { - infoType = "warngenOfficeShort"; - } else if (locTag) { - infoType = "warngenOfficeLoc"; - } - } - if (infoType != null) { - statusHandler.handle(Priority.CRITICAL, - "Info for " + infoType + " in " + backupSite - + "'s config.xml is missing."); - } - } - } - } - public String getLocalizedSite() { - String site = ""; - if (backupSite == null) { - site = LocalizationManager.getInstance().getCurrentSite(); - } else { - site = backupSite; - } - return site; + return LocalizationManager.getInstance().getCurrentSite(); } /** @@ -4764,27 +4667,6 @@ public class WarngenLayer extends AbstractStormTrackResource { } } - public String getBackupOfficeShort() { - return backupOfficeShort; - } - - public String getBackupOfficeLoc() { - return backupOfficeLoc; - } - - public String getBackupSite() { - return backupSite; - } - - public static String getLastSelectedBackupSite() { - return lastSelectedBackupSite; - } - - public static synchronized void setLastSelectedBackupSite( - String backupSite) { - lastSelectedBackupSite = backupSite; - } - private GeospatialData[] getActiveFeatures() { return geoData.getFeatures(isCwaStretch()); } diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java index fa904f06eb..7c28e3a27a 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/template/TemplateRunner.java @@ -162,6 +162,7 @@ import org.locationtech.jts.io.WKTReader; * Jul 21, 2016 DR 18159 Qinglu Lin update runTemplate(). * Aug 29, 2017 6328 randerso Fix misspelled method name * Oct 31, 2017 6328 randerso Fix missing CAN segment for partial cancellation + * Jun 24, 2019 ---- mjames@ucar Remove backupData * Mar 02, 2018 6786 dgilling Don't allow WMO header time to be * different than VTEC start time for some * products. @@ -435,14 +436,6 @@ public class TemplateRunner { context.put("officeLoc", warngenLayer.getDialogConfig().getWarngenOfficeLoc()); - if (backupData != null) { - context.remove("officeLoc"); - context.remove("officeShort"); - context.put("officeLoc", warngenLayer.getBackupOfficeLoc()); - context.put("officeShort", warngenLayer.getBackupOfficeShort()); - context.put("backupSite", - warngenLayer.getDialogConfig().getWarngenOfficeShort()); - } String productId = config.getProductId(); if (productId == null) { diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/.classpath b/edexOsgi/com.raytheon.uf.edex.dissemination/.classpath deleted file mode 100644 index 1fa3e6803d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/.project b/edexOsgi/com.raytheon.uf.edex.dissemination/.project deleted file mode 100644 index c0bc739738..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/.project +++ /dev/null @@ -1,34 +0,0 @@ - - - com.raytheon.uf.edex.dissemination - - - - - - org.python.pydev.PyDevBuilder - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - org.python.pydev.pythonNature - - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/.pydevproject b/edexOsgi/com.raytheon.uf.edex.dissemination/.pydevproject deleted file mode 100644 index dc3b82c133..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/.pydevproject +++ /dev/null @@ -1,5 +0,0 @@ - - -python 3.6 -Default - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/META-INF/MANIFEST.MF b/edexOsgi/com.raytheon.uf.edex.dissemination/META-INF/MANIFEST.MF deleted file mode 100644 index 52836eff01..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/META-INF/MANIFEST.MF +++ /dev/null @@ -1,32 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Dissemination Plug-in -Bundle-SymbolicName: com.raytheon.uf.edex.dissemination -Bundle-Version: 1.19.0.qualifier -Bundle-Vendor: RAYTHEON -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Import-Package: com.raytheon.edex.exception, - com.raytheon.uf.common.dataplugin.text, - com.raytheon.uf.common.dataplugin.text.db, - com.raytheon.uf.common.dissemination, - com.raytheon.uf.common.localization, - com.raytheon.uf.common.localization.exception, - com.raytheon.uf.common.python, - com.raytheon.uf.common.serialization, - com.raytheon.uf.common.serialization.comm, - com.raytheon.uf.common.status, - com.raytheon.uf.edex.core, - com.raytheon.uf.edex.database, - com.raytheon.uf.edex.database.purge, - org.apache.camel -Require-Bundle: org.jep, - com.raytheon.uf.edex.plugin.text, - com.raytheon.uf.common.site, - org.springframework, - com.raytheon.uf.edex.database, - com.raytheon.uf.common.auth, - com.raytheon.uf.edex.auth, - com.raytheon.uf.edex.ndm - - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/build.properties b/edexOsgi/com.raytheon.uf.edex.dissemination/build.properties deleted file mode 100644 index 20a5272307..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/build.properties +++ /dev/null @@ -1,6 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - utility/,\ - .,\ - res/ diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/com.raytheon.uf.edex.dissemination.ecl b/edexOsgi/com.raytheon.uf.edex.dissemination/com.raytheon.uf.edex.dissemination.ecl deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-ingest.xml b/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-ingest.xml deleted file mode 100644 index 822b2116f4..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-ingest.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml b/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml deleted file mode 100644 index 6886bca4f5..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/res/spring/dissemination-request.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - java.lang.Throwable - - - - - - - - - - - java.lang.Throwable - - - - - - - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java deleted file mode 100644 index 1074f1516e..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ModifyProduct.java +++ /dev/null @@ -1,239 +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.dissemination; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; - -import com.raytheon.uf.common.dataplugin.text.db.AfosToAwips; -import com.raytheon.uf.common.dissemination.OUPRequest; -import com.raytheon.uf.common.dissemination.OfficialUserProduct; -import com.raytheon.uf.edex.database.DataAccessLayerException; -import com.raytheon.uf.edex.dissemination.transmitted.TransProdHeader; -import com.raytheon.uf.edex.dissemination.transmitted.TransmittedProductList; -import com.raytheon.uf.edex.plugin.text.AfosToAwipsLookup; - -/** - * Utilities for generating a wmo header or tracking headers - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date          Ticket#  Engineer     Description
- * ------------- -------- ------------ --------------------
- * Nov 13, 2009           njensen      Initial creation
- * Aug 20, 2012  15340    D. Friedman  Fix BBB problems
- * Aug 09, 2016  5801     tgurney      Use AfosToAwipsLookup
- * 
- * 
- * - * @author njensen - */ - -public class ModifyProduct { - - private static final SimpleDateFormat DDHHMM = new SimpleDateFormat( - "ddHHmm"); - - public static TransProdHeader getProductHeader(OfficialUserProduct product) - throws OUPHeaderException { - TransProdHeader header = null; - String[] splitLines = product.getProductText().split("\n"); - String[] firstLine = splitLines[0].split(" "); - if (firstLine.length < 3) { - throw new OUPHeaderException("Bad wmo header on product: " - + splitLines[0]); - } - String ttaaii = firstLine[0]; - String cccc = firstLine[1]; - String productTime = firstLine[2]; - String productAwipsId = product.getAwipsWanPil().substring(4); - List list = AfosToAwipsLookup.lookupAfosId(ttaaii, cccc) - .getIdList(); - String productId = null; - for (AfosToAwips ata : list) { - String afosId = ata.getAfosid(); - String awipsId = afosId.substring(3); - if (awipsId.equals(productAwipsId)) { - productId = afosId; - break; - } - } - if (productId != null) { - String wmoId = ttaaii + " " + cccc; - String bbbid = product.getWmoType(); - header = new TransProdHeader(productId, wmoId, productTime, bbbid); - } else { - throw new OUPHeaderException( - "Error determining afosID. No matching afosID found for ttaaii " - + ttaaii + " cccc " + cccc + " afosID %" - + productAwipsId); - } - - return header; - } - - public static OUPRequest addWmoHeader(OUPRequest req) - throws OUPHeaderException { - String text = req.getProduct().getProductText(); - String awipsWanPil = req.getProduct().getAwipsWanPil(); - String cccc = awipsWanPil.substring(0, 4); - String nnn = awipsWanPil.substring(4, 7); - String xxx = null; - if (awipsWanPil.length() >= 10) { - xxx = awipsWanPil.substring(7, 10); - } else { - xxx = awipsWanPil.substring(7); - } - - List list = AfosToAwipsLookup.lookupAfosId(cccc, nnn, - xxx.trim()).getIdList(); - if (list.size() == 1) { - StringBuilder sb = new StringBuilder(); - sb.append(list.get(0).getWmottaaii()); - sb.append(" "); - sb.append(list.get(0).getWmocccc()); - sb.append(" "); - if (req.getProduct().getUserDateTimeStamp() != null) { - sb.append(req.getProduct().getUserDateTimeStamp()); - } else { - synchronized (DDHHMM) { - sb.append(DDHHMM.format(new Date())); - } - } - if (req.getProduct().getWmoType() != null - && req.getProduct().getWmoType().length() > 0) { - sb.append(" "); - sb.append(req.getProduct().getWmoType()); - } - sb.append("\n"); - sb.append(nnn); - sb.append(xxx); - sb.append("\n"); - sb.append(text); - - req.getProduct().setProductText(sb.toString()); - req.getProduct().setNeedsWmoHeader(false); - - return req; - } else if (list.size() == 0) { - throw new OUPHeaderException( - "Error building WMO header. No matching ttaaii found for cccc " - + cccc + " nnn " + nnn + " xxx " + xxx); - } else { - throw new OUPHeaderException( - "Error building WMO header. Too many matching ttaaii found for cccc " - + cccc + " nnn " + nnn + " xxx " + xxx); - } - } - - public static boolean checkBBBField(OfficialUserProduct product, - TransProdHeader header) throws DataAccessLayerException { - boolean changed = false; - String productBBB = header.getBbb(); - String[] splitLines = product.getProductText().split("\n", 2); - String bbbToUse = TransmittedProductList.getBBB(header.getProductId(), - header.getWmoId(), header.getProductTime(), header.getBbb()); - - if (!productBBB.equals(bbbToUse)) { - productBBB = bbbToUse; - } - - if (productBBB != null) { - // if the BBB is already in the wmo header do not append - if (!splitLines[0].endsWith(" " + productBBB)) { - splitLines[0] += " " + productBBB; - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (String line : splitLines) { - if (first) { - first = false; - } else { - sb.append("\n"); - } - sb.append(line); - } - product.setProductText(sb.toString()); - changed = true; - } - header.setBbb(productBBB); - } - product.setWmoType(productBBB); - - return changed; - } - - public static String convertNewline2rrn(String textString) { - StringBuffer newString = new StringBuffer(); - - // Don't do any change if string doesn't contain any newline - if (textString.contains("\n") == false) { - return textString; - } - - String[] lines = textString.split("\n"); - - for (String line : lines) { - int length = line.length(); - - // The index of the first "\n" is bigger than 1 - if (length > 1) { - - // "...xx\n" case - if (line.charAt(length - 1) != '\r') { - // replace with "...xx\r\r\n" - newString.append(line.substring(0, length)); - newString.append("\r\r\n"); - - // "...x\r\n" and case - } else if (line.charAt(length - 2) != '\r') { - // replace with ""...x\r\r\n" - newString.append(line.substring(0, length - 1)); - newString.append("\r\r\n"); - - // "...\r\r\n" case - } else { - // jusy copy "..." - newString.append(line); - } - - // "\r\n" and "x\n" case - } else if (length == 1) { - char char0 = line.charAt(0); - - // copy the "x" if is the "x\n" case - if (char0 != '\r') { - newString.append(char0); - } - - newString.append("\r\r\n"); - - // "\n" case - } else { - newString.append("\r\r\n"); - } - - } - - return newString.toString(); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPAckManager.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPAckManager.java deleted file mode 100644 index ba22e4958c..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPAckManager.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.raytheon.uf.edex.dissemination; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; - -import org.apache.camel.Header; - -import com.raytheon.uf.common.dissemination.OUPResponse; - -/** - * Manages MHS acknowledgments. Currently this means supporting synchronous - * waiting for acknowledgments. - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * 2012-04-13   DR 10388   D. Friedman Initial creation
- * 
- * 
- * - */ - -public class OUPAckManager { - - private static final long MAX_ENTRY_LIFE_TIME_MILLIS = 15 * 60 * 1000; // 15 minutes - private static final long ACK_WAIT_TIMEOUT_MILLIS = 5 * 60 * 1000; // 5 minutes - - private static final String ACK_RESPONSE = "ACK"; - private static final String NACK_RESPONSE = "NACK"; - private static final String NWWS_UPLINK_ADDRESS = "NWWSUP"; - private static final String[] EXCLUSIVE_ADDRESS_SEARCH_STRINGS = { "NCF", "SBN" }; - - /* - * EDEX can receive an ACK before waitAck is called. Because the ACK cannot - * be correctly processed before the addresses are know (i.e., waitAck is - * called), we must queue all ACKs for processing on the thread that calls - * waitAck. This includes ACKs for messages that were not even sent from - * this JVM. If OUP requests and ACK/NACK messages could be processed - * serially in the same thread, this complexity could be reduced. - */ - private static class Entry { - public Entry() { - this.createTime = System.currentTimeMillis(); - } - long createTime; - String addresses; - String result; - ArrayList pendingResponses = new ArrayList(1); - - boolean isDone() { - if (result != null) - return true; - while (pendingResponses.size() > 0) { - Response r = pendingResponses.remove(0); - if (matches(r)) { - result = r.response != null ? r.response : "(null response)"; - return true; - } - } - return false; - } - - /* Logic and comments from MhsWfoProduct.C: MhsWfoProduct::matches() */ - private boolean matches(Response r) { - // Check for acks from the NWWS address. - if (NWWS_UPLINK_ADDRESS.equals(r.sender) - && this.addresses.indexOf(NWWS_UPLINK_ADDRESS) >= 0) - return true; - - /* - * If the message was sent to the NCF, then only handle acks from - * the NCF. If the message was sent to the NCF for distribution on - * the SBN, then only handle acks with the SBN address. - */ - for (String searchString : EXCLUSIVE_ADDRESS_SEARCH_STRINGS) - if (this.addresses.indexOf(searchString) >= 0) { - if (r.sender != null && r.sender.indexOf(searchString) >= 0) - return true; - else - return false; - } - - /* - * If none of the above special addresses were used, compare the - * sender to the list of addresses. If there's only one address, and - * the sender matches it, return true. - */ - if (addresses != null && addresses.equals(r.sender)) - return true; - - return false; - } - } - - private static class Response { - private String sender; - private String response; - public Response(String sender, String response) { - this.sender = sender; - this.response = response; - } - } - - private HashMap entries = new HashMap(); - - public Entry getEntry(String messageId) { - synchronized (entries) { - // Purge abandonded entries - long purgeTime = System.currentTimeMillis() - MAX_ENTRY_LIFE_TIME_MILLIS; - Iterator i = entries.values().iterator(); - while (i.hasNext()) { - Entry entry = i.next(); - if (entry.createTime <= purgeTime) { - i.remove(); - synchronized (entry) { - entry.result = "ACK wait purged"; - entry.notify(); - } - } - } - - Entry entry = entries.get(messageId); - if (entry == null) { - entry = new Entry(); - entries.put(messageId, entry); - } - return entry; - } - } - - /** Synchronously waits for an acknowledgment of the specified MHS message - * @param messageId MHS message ID - * @param addresses list of addresses used to determine which ACKs are relevant - * @param response On return, the {@code acknowledged} and (if no positive ACK) {@code message} - * properties will be set. - * @param messageDescription description of the MHS message to be used in error messages - */ - public void waitAck(String messageId, String addresses, OUPResponse response, String messageDescription) { - long now = System.currentTimeMillis(); - long targetTime = now + ACK_WAIT_TIMEOUT_MILLIS; - Entry entry = getEntry(messageId); - - synchronized (entry) { - entry.addresses = addresses; - while (! entry.isDone()) { - now = System.currentTimeMillis(); - if (now < targetTime) { - try { - entry.wait(targetTime - now); - } catch (InterruptedException e) { - response.setAcknowledged(false); - response.setMessage(String.format("Interrupted while waiting for acknowledgement of %s", - messageDescription)); - return; - } - } else { - response.setAcknowledged(false); - response.setMessage(String.format("Timed out waiting for acknowledgement of %s", - messageDescription)); - return; - } - } - response.setAcknowledged(ACK_RESPONSE.equals(entry.result)); - if (! response.isAcknowledged()) - response.setMessage(String.format( - "An error was received while sending %s to the WAN.\nA %s.", - messageDescription, - NACK_RESPONSE.equals(entry.result) ? - "negative acknowledgment was received from the remote site" : - "unknown response was received: " + entry.result)); - } - - synchronized (this) { - entries.remove(messageId); - } - } - - public void processAck(String messageId, @Header("sender") String sender, - @Header("response") String response) { - Entry entry = getEntry(messageId); - synchronized (entry) { - entry.pendingResponses.add(new Response(sender, response)); - entry.notify(); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHandler.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHandler.java deleted file mode 100644 index bfa3c50ff1..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHandler.java +++ /dev/null @@ -1,219 +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.dissemination; - -import java.util.HashMap; -import java.util.Map; - -import com.raytheon.uf.common.auth.exception.AuthorizationException; -import com.raytheon.uf.common.dataplugin.text.db.MixedCaseProductSupport; -import com.raytheon.uf.common.dissemination.OUPRequest; -import com.raytheon.uf.common.dissemination.OUPResponse; -import com.raytheon.uf.common.dissemination.OfficialUserProduct; -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.python.PyUtil; -import com.raytheon.uf.common.python.PythonScript; -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.auth.AuthManagerFactory; -import com.raytheon.uf.edex.auth.IPermissionsManager; -import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; -import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; -import com.raytheon.uf.edex.dissemination.transmitted.TransProdHeader; - -import jep.JepConfig; -import jep.JepException; - -/** - * IRequestHandler for OUPRequests - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date          Ticket#  Engineer     Description
- * ------------- -------- ------------ -----------------------------------------
- * Oct 22, 2009           njensen      Initial creation
- * Oct 12, 2012  15418    D. Friedman  Use clustered TransmittedProductList
- * Jun 07, 2013  1981     mpduff       This is now a privileged request handler.
- * Nov 20, 2013  16777    D. Friedman  Add a test mode.
- * May 28, 2014  3211     njensen      Use IAuthorizer instead of IRoleStorage
- * Feb 24, 2016  5411     randerso     Force product to upper case if necessary
- * Aug 01, 2016  5744     mapeters     Python script moved from edex_static to
- *                                     common_static
- * Jul 17, 2017  6288     randerso     Changed to use new Roles/Permissions
- *                                     framework
- *Jun 03, 2019   7852     dgilling     Update code for jep 3.8.
- *
- * 
- * - * @author njensen - */ - -public class OUPHandler extends AbstractPrivilegedRequestHandler { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(OUPHandler.class); - - private OUPAckManager ackManager; - - @Override - public OUPResponse handleRequest(OUPRequest request) throws Exception { - return handleOUPRequest(request, false); - } - - public OUPResponse handleOUPRequest(OUPRequest request, boolean test) - throws Exception { - OfficialUserProduct oup = request.getProduct(); - OUPResponse resp = new OUPResponse(); - boolean changedBbb = false; - if (oupOk(oup)) { - try { - if (oup.isNeedsWmoHeader()) { - request = ModifyProduct.addWmoHeader(request); - } - TransProdHeader header = ModifyProduct.getProductHeader(oup); - if (request.isCheckBBB() && !test) { - changedBbb = ModifyProduct.checkBBBField(oup, header); - if (changedBbb) { - resp.setChangedBBB(request.getProduct().getWmoType()); - } - } - - String convertedProductText = ModifyProduct - .convertNewline2rrn(oup.getProductText()); - - /* - * Force to upper case if product is not enabled for mixed case - * transmission - */ - String nnn = oup.getAwipsWanPil().substring(4, 7); - convertedProductText = MixedCaseProductSupport - .conditionalToUpper(nnn, convertedProductText); - - oup.setProductText(convertedProductText); - - try (PythonScript py = initializePython()) { - Map args = new HashMap<>(); - args.put("oup", oup); - args.put("afosID", header.getProductId()); - args.put("resp", resp); - args.put("ackMgr", ackManager); - args.put("test", test); - resp.setAttempted(true); - py.execute("process", args); - } catch (JepException e) { - resp.setMessage("Error executing handleOUP python"); - statusHandler.handle(Priority.SIGNIFICANT, - "Error executing handleOUP python", e); - } - - /* - * TODO: Should be updating TransmittedProductList here, after - * success has been confirmed. - */ - } catch (OUPHeaderException e) { - statusHandler.error(e.getMessage(), e); - resp.setAttempted(false); - resp.setMessage( - "Product not sent, error encountered with header.\n" - + e.getMessage()); - } - } else { - resp.setAttempted(false); - resp.setMessage( - "Product not sent. OfficialUserProduct requires an awipsWanPil, " - + "product text, and product filename."); - } - - if ((resp != null) && (resp.getMessage() == null)) { - resp.setMessage(""); - } - return resp; - } - - private static boolean oupOk(OfficialUserProduct oup) { - boolean ok = false; - if (oup != null) { - if ((oup.getAwipsWanPil() != null) && (oup.getFilename() != null) - && (oup.getProductText() != null)) { - ok = true; - } - } - - return ok; - } - - private static PythonScript initializePython() throws JepException { - IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext commonBase = pathMgr.getContext( - LocalizationType.COMMON_STATIC, LocalizationLevel.BASE); - - String path = pathMgr.getFile(commonBase, - "dissemination" + IPathManager.SEPARATOR + "handleOUP.py") - .getPath(); - String statusPath = pathMgr.getFile(commonBase, "python").getPath(); - - PythonScript python = new PythonScript( - new JepConfig() - .setIncludePath(PyUtil.buildJepIncludePath(statusPath)) - .setClassLoader(OUPHandler.class.getClassLoader()), - path); - return python; - } - - public OUPAckManager getAckManager() { - return ackManager; - } - - public void setAckManager(OUPAckManager ackManager) { - this.ackManager = ackManager; - } - - /** - * {@inheritDoc} - */ - @Override - public AuthorizationResponse authorized(OUPRequest request) - throws AuthorizationException { - boolean authorized = false; - - if (request.getUser().uniqueId().toString() - .equals(OUPRequest.EDEX_ORIGINATION)) { - authorized = true; - } else { - IPermissionsManager manager = AuthManagerFactory.getInstance() - .getPermissionsManager(); - - authorized = manager.isPermitted(request.getRoleId()); - } - - if (authorized) { - return new AuthorizationResponse(authorized); - } else { - return new AuthorizationResponse( - (request).getNotAuthorizedMessage()); - } - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHeaderException.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHeaderException.java deleted file mode 100644 index a5a196a9cf..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPHeaderException.java +++ /dev/null @@ -1,52 +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.dissemination; - -import com.raytheon.uf.edex.core.EdexException; - -/** - * Exception when dealing with the WMO header of Official User Products - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Jan 5, 2010            njensen     Initial creation
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class OUPHeaderException extends EdexException { - - private static final long serialVersionUID = 1L; - - public OUPHeaderException(String message) { - super(message); - } - - public OUPHeaderException(String message, Throwable cause) { - super(message, cause); - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPTestHandler.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPTestHandler.java deleted file mode 100644 index ff1e1abbe4..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/OUPTestHandler.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.raytheon.uf.edex.dissemination; - -import com.raytheon.uf.common.auth.exception.AuthorizationException; -import com.raytheon.uf.common.dissemination.OUPTestRequest; -import com.raytheon.uf.edex.auth.req.AbstractPrivilegedRequestHandler; -import com.raytheon.uf.edex.auth.resp.AuthorizationResponse; - -/** - * Check if an OUPRequest will work - * - *
- *
- * SOFTWARE HISTORY
- *
- * Date          Ticket#  Engineer     Description
- * ------------- -------- ------------ -----------------------------------------
- * Nov 20, 2013  16777    D. Friedman  Initial creation
- * Jul 18, 2017  6288     randerso     Changed to use new Roles/Permissions
- *                                     framework
- *
- * 
- * - */ -public class OUPTestHandler - extends AbstractPrivilegedRequestHandler { - - private OUPHandler oupHandler; - - @Override - public Object handleRequest(OUPTestRequest request) throws Exception { - return oupHandler.handleOUPRequest(request.getOupRequest(), true); - } - - @Override - public AuthorizationResponse authorized(OUPTestRequest request) - throws AuthorizationException { - return oupHandler.authorized(request.getOupRequest()); - } - - public OUPHandler getOupHandler() { - return oupHandler; - } - - public void setOupHandler(OUPHandler oupHandler) { - this.oupHandler = oupHandler; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/StatusConstants.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/StatusConstants.java deleted file mode 100644 index 28ca533181..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/StatusConstants.java +++ /dev/null @@ -1,44 +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.dissemination; - -/** - * StatusConstants for dissemination - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Oct 29, 2009            njensen     Initial creation
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class StatusConstants { - - public static final String PLUGIN_NAME = "com.raytheon.uf.edex.dissemination"; - - public static final String CATEGORY_HANDLE_OUP = "HandleOUP"; - -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ingest/DisseminationNationalDatasetSubscriber.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ingest/DisseminationNationalDatasetSubscriber.java deleted file mode 100644 index f3c1cb8f81..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/ingest/DisseminationNationalDatasetSubscriber.java +++ /dev/null @@ -1,151 +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.dissemination.ingest; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import com.raytheon.uf.common.localization.ILocalizationFile; -import com.raytheon.uf.common.localization.IPathManager; -import com.raytheon.uf.common.localization.LocalizationContext; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel; -import com.raytheon.uf.common.localization.LocalizationContext.LocalizationType; -import com.raytheon.uf.common.localization.PathManagerFactory; -import com.raytheon.uf.common.localization.SaveableOutputStream; -import com.raytheon.uf.common.localization.exception.LocalizationException; -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.ndm.ingest.INationalDatasetSubscriber; - -/** - * Dissemination NDM subscriber. - * - *
- * 
- * SOFTWARE HISTORY
- * 
- * Date          Ticket#  Engineer  Description
- * ------------- -------- --------- --------------------------------------------
- * Jan 13, 2011           bfarmer   Initial creation
- * Mar 06, 2014  2876     mpduff    New NDM plugin.
- * Aug 01, 2016  5744     mapeters  Save priorities file to
- *                                  common_static.configured instead of
- *                                  edex_static.base, use ILocalizationFile
- * 
- * 
- * - * @author bfarmer - */ - -public class DisseminationNationalDatasetSubscriber implements - INationalDatasetSubscriber { - private static final IUFStatusHandler statusHandler = UFStatus - .getHandler(DisseminationNationalDatasetSubscriber.class); - - private static final String AWIPS_PRIORITIES_FILENAME = "dissemination" - + IPathManager.SEPARATOR + "awipsPriorities.txt"; - - @Override - public void notify(String fileName, File file) { - if ("awipsPriorities.txt".equals(fileName)) { - IPathManager pathMgr = PathManagerFactory.getPathManager(); - LocalizationContext lc = pathMgr.getContext( - LocalizationType.COMMON_STATIC, - LocalizationLevel.CONFIGURED); - ILocalizationFile outFile = pathMgr.getLocalizationFile(lc, - AWIPS_PRIORITIES_FILENAME); - long time = System.currentTimeMillis(); - String backupFilename = "dissemination" + IPathManager.SEPARATOR - + "awipsPriorities" + time + ".txt"; - ILocalizationFile backupFile = pathMgr.getLocalizationFile(lc, - backupFilename); - - saveFile(outFile, backupFile); - saveFile(file, outFile); - } - } - - /** - * Write the contents of inFile to outFile and save it to the localization - * server - * - * @param inFile - * @param outFile - */ - private void saveFile(ILocalizationFile inFile, ILocalizationFile outFile) { - if (inFile != null && inFile.exists()) { - try (InputStream is = inFile.openInputStream(); - SaveableOutputStream os = outFile.openOutputStream()) { - saveInputStreamToLocalization(is, os); - } catch (IOException | LocalizationException e) { - String msg = "Failed to save " + inFile.getPath() + " to " - + outFile.getPath(); - statusHandler.handle(Priority.PROBLEM, msg, e); - } - } - } - - /** - * Write the contents inFile to outFile and save it to the localization - * server - * - * @param inFile - * @param outFile - */ - private void saveFile(File inFile, ILocalizationFile outFile) { - if (inFile != null && inFile.exists()) { - try (FileInputStream is = new FileInputStream(inFile); - SaveableOutputStream os = outFile.openOutputStream()) { - saveInputStreamToLocalization(is, os); - } catch (IOException e) { - String msg = "Failed to save " + inFile.getAbsolutePath() - + " to localization file " + outFile.getPath(); - statusHandler.handle(Priority.PROBLEM, msg, e); - } catch (LocalizationException e) { - String msg = "Failed to open output stream for file: " - + outFile.getPath(); - statusHandler.handle(Priority.PROBLEM, msg, e); - } - } - } - - /** - * Write the contents of the given InputStream to the SaveableOutputStream - * and save it to the localization server - * - * @param is - * @param os - * @throws IOException - */ - private void saveInputStreamToLocalization(InputStream is, - SaveableOutputStream os) throws IOException { - byte[] buf = new byte[2048]; - int len = is.read(buf); - while (len > 0) { - os.write(buf, 0, len); - len = is.read(buf); - } - - os.save(); - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransProdHeader.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransProdHeader.java deleted file mode 100644 index 7819e6c502..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransProdHeader.java +++ /dev/null @@ -1,95 +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.dissemination.transmitted; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 10, 2009            njensen     Initial creation
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class TransProdHeader { - - private String productId; - - private String wmoId; - - private String productTime; - - private String bbb; - - public TransProdHeader(String productId, String wmoId, String productTime, - String bbb) { - this.productId = productId; - this.wmoId = wmoId; - this.productTime = productTime; - this.bbb = bbb; - if (this.bbb == null) { - this.bbb = ""; - } - } - - public boolean matches(String productId, String wmoId) { - return (this.productId.equals(productId) && this.wmoId.equals(wmoId)); - } - - public String getProductId() { - return productId; - } - - public void setProductId(String productId) { - this.productId = productId; - } - - public String getWmoId() { - return wmoId; - } - - public void setWmoId(String wmoId) { - this.wmoId = wmoId; - } - - public String getProductTime() { - return productTime; - } - - public void setProductTime(String productTime) { - this.productTime = productTime; - } - - public String getBbb() { - return bbb; - } - - public void setBbb(String bbb) { - this.bbb = bbb; - } - -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransmittedProductList.java b/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransmittedProductList.java deleted file mode 100644 index e4e820b59b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/src/com/raytheon/uf/edex/dissemination/transmitted/TransmittedProductList.java +++ /dev/null @@ -1,188 +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.dissemination.transmitted; - -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.database.cluster.ClusterLockUtils; -import com.raytheon.uf.edex.database.cluster.ClusterLockUtils.LockState; -import com.raytheon.uf.edex.database.cluster.ClusterTask; -import com.raytheon.uf.edex.database.cluster.handler.CurrentTimeClusterLockHandler; - -/** - * TODO Add Description - * - *
- * 
- * SOFTWARE HISTORY
- * Date         Ticket#    Engineer    Description
- * ------------ ---------- ----------- --------------------------
- * Nov 10, 2009            njensen     Initial creation
- * 08/20/2012   DR 15340   D. Friedman Fix BBB problems
- * 10/12/2012   DR 15418   D. Friedman Make BBB determination cluster-aware
- * 
- * 
- * - * @author njensen - * @version 1.0 - */ - -public class TransmittedProductList { - private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(TransmittedProductList.class); - - private static final String LOCK_NAME = "OUP-TransProdList"; - - /** Represents a BBB field that is set to an empty value (as opposed to - * an "unknown" or "not set" state. - */ - private static final String EMPTY_BBB_VAL = "-"; - - private static final long CLUSTER_LOCK_TIMEOUT = 15 * 1000; - - public static String getBBB(String productId, String wmoId, - String productTime, String productBBB) { - /* If the user has assigned a value to the BBB field, just pass the - * product through without incrementing the BBB value. If that - * assigned value is RRx, still need to need to update the - * cluster-shared header list. - */ - boolean getNextBBB = true; - if (productBBB.length() == 3) { - String left2 = productBBB.substring(0, 2); - if (left2.equals("RR")) - getNextBBB = false; - else if (left2.equals("AA") || left2.equals("CC")) - return productBBB; - } - - String lockName = LOCK_NAME; - CurrentTimeClusterLockHandler lockHandler = null; - lockHandler = new CurrentTimeClusterLockHandler(CLUSTER_LOCK_TIMEOUT, - false); - ClusterTask ct = ClusterLockUtils.lock(lockName, - wmoId, lockHandler, true); - if (! ct.getLockState().equals(LockState.SUCCESSFUL)) - statusHandler.handle(Priority.ERROR, - String.format("Unable to get cluster lock for %s %s. Proceeding without it.", - wmoId, productId)); - try { - TphInfo info = parse(ct.getExtraInfo()); - String result; - if (getNextBBB) { - String tplBBB = info.getBBBForTime(productTime); - String bbbToUse = getNextBBB(productBBB, tplBBB); - info.setBBBForTime(productTime, isSet(bbbToUse) ? bbbToUse : EMPTY_BBB_VAL); - statusHandler.handle(isSet(bbbToUse) ? Priority.INFO : Priority.VERBOSE, - String.format("For %s %s DDHHMM=%s,BBB=%s,tplBBB=%s, use BBB=%s", - wmoId, productId, productTime, productBBB, tplBBB, bbbToUse)); - // Current protocol is to return null for empty case - result = isSet(bbbToUse) ? bbbToUse : null; - } else { - statusHandler.handle(Priority.INFO, - String.format("Product %s %s DDHHMM=%s explicity requested BBB=%s", - wmoId, productId, productTime, productBBB)); - info.setBBBForTime(productTime, productBBB); - result = productBBB; - } - lockHandler.setExtraInfo(info.format()); - return result; - } finally { - if (ct.getLockState().equals(LockState.SUCCESSFUL)) - ClusterLockUtils.unlock(ct, false); - } - } - - private static String getNextBBB(String productBBB, String transmittedBBB) { - if (! isSet(transmittedBBB)) - return ""; - else if (EMPTY_BBB_VAL.equals(transmittedBBB)) - return "RRA"; - - char newX = transmittedBBB.charAt(2); - if (newX == 'X') { - newX = 'A'; - } else { - newX++; - } - return transmittedBBB.substring(0, 2) + Character.toString(newX); - } - - public static boolean isSet(String s) { - return s != null && s.length() > 0; - } - - /** Manages the storage of transmitted product header state in the - * cluster lock table. Currently only supports tracking state for - * one minute at a time (like AWIPS I.) - */ - private static class TphInfo { - private String time; - private String bbb; - - public String format() { - if (isSet(time)) - return String.format("%s:%s", time, isSet(bbb) ? bbb : ""); - else - return ""; - } - - public void setBBBForTime(String productTime, String bbbToUse) { - time = productTime; - bbb = isSet(bbbToUse) ? bbbToUse : null; - } - - public String getBBBForTime(String productTime) { - if (productTime != null && productTime.equals(time)) - return isSet(bbb) ? bbb : null; - else - return null; - } - } - - public static TphInfo parse(String input) { - TphInfo inf = new TphInfo(); - if (input != null) { - String[] parts = input.split(":"); - if (parts.length == 2) { - inf.time = parts[0]; // Only compared via String.equals; no need to validate further - if (validateBBB(parts[1])) - inf.bbb = parts[1]; - } - } - return inf; - } - - private static boolean validateBBB(String bbb) { - if (EMPTY_BBB_VAL.equals(bbb)) - return true; - else if (bbb.length() == 3) { - int i; - for (i = 0; i < bbb.length(); ++i) - if (bbb.charAt(i) < 'A' || bbb.charAt(i) > 'Z') - break; - if (i == bbb.length()) - return true; - } - statusHandler.handle(Priority.ERROR, - String.format("Invalid BBB in cluster lock info: \"%s\"", bbb)); - return false; - } -} diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/awipsPriorities.txt b/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/awipsPriorities.txt deleted file mode 100644 index 891a911bdf..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/awipsPriorities.txt +++ /dev/null @@ -1,132 +0,0 @@ -# ------------------------------------------------------------------------- -# awipsPriorities.txt -# -# Table containing AFOS product categories (NNN) and corresponding priorities. -# -# Column 1: AFOS product category -# Column 2: AWIPS transmission priority which is different from AFOS -# AFOS = 1 (hi) to 5 (low) -# AWIPS = 2 (hi) to 0 (low) -# Since the default is 0, only priority 1 and 2 are in this file -# ------------------------------------------------------------------------- -ACR 1 -ADA 1 -ADX 1 -AIR 1 -ALT 2 -ARS 1 -AVA 1 -AVW 2 -AWG 2 -AWN 2 -AWU 1 -AWW 2 -BLU 2 -BOT 1 -BOY 1 -CAE 1 -CDW 2 -CEM 2 -CFA 1 -CFS 1 -CFW 2 -CHG 2 -CWA 1 -EQW 2 -EVI 2 -EXM 1 -EXT 1 -FFA 2 -FFM 1 -FFS 2 -FFW 2 -FLS 2 -FLW 2 -FOB 1 -FRW 2 -FZL 1 -HLS 2 -HMW 2 -HSR 1 -IAO 1 -LAE 1 -LEW 2 -LSH 2 -LSR 2 -MAW 1 -MBK 2 -MTR 1 -NIM 2 -NPW 2 -NUW 2 -OPU 2 -OWA 1 -OWW 2 -PSH 2 -PWO 2 -RCM 1 -RFW 2 -RHW 2 -ROB 1 -SAB 2 -SAO 1 -SAW 2 -SCP 1 -SDO 1 -SEL 2 -SEV 2 -SIG 2 -SLS 2 -SMW 2 -SPF 2 -SPS 2 -SPW 2 -STA 2 -STW 2 -SVR 2 -SVS 2 -TAP 1 -TCD 2 -TCE 2 -TCM 2 -TCP 2 -TCU 2 -TDM 1 -TDT 1 -TMA 2 -TMM 1 -TMT 1 -TOE 1 -TOR 2 -TSM 1 -TSU 2 -VOW 2 -WA0 2 -WA1 2 -WA2 2 -WA3 2 -WA4 2 -WA5 2 -WA6 2 -WA7 2 -WA8 2 -WA9 2 -WAC 2 -WAR 2 -WAT 2 -WCM 2 -WCN 2 -WS1 2 -WS2 2 -WS3 2 -WS4 2 -WS5 2 -WS6 2 -WS7 2 -WS8 2 -WS9 2 -WST 2 -WSV 2 -WSW 2 -WVM 1 -WWA 2 diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/handleOUP.py b/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/handleOUP.py deleted file mode 100644 index e88392fa8b..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/handleOUP.py +++ /dev/null @@ -1,594 +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. -## - -# -# Derived from port of handleOUP.pl, but diverged to support single path -# of dissemination. Assigns a priority to the product, and attempts to send -# it to the message handling system if it's not in the include lists. -# -# -# SOFTWARE HISTORY -# -# Date Ticket# Engineer Description -# ------------ ---------- ----------- -------------------------- -# 10/28/09 njensen Initial Creation. -# 12/09/09 DR3778 M. Huang Add acknowledgment handling -# 09/05/11 DR9602 M. Huang Fix acknowledgment handling error -# 04/13/12 DR 10388 D. Friedman Correct acknowledgment handling -# 08/17/12 DR 15304 D. Friedman Use unique output file names -# 10/12/12 DR 15418 D. Friedman Use unique attachment file names -# 11/20/13 DR 16777 D. Friedman Add a test mode. -# 12/05/16 DR 16842 D. Friedman Do not set product ID on MhsMessage -# 07/29/14 DR 2914 G. Armendariz Remove call to PropertiesFactory -# Apr 25, 2015 4952 njensen Updated for new JEP API -# Oct 09, 2015 4790 dgilling Set msg_send code for NCF products -# to 134. -# Aug 01, 2016 5744 mapeters Config files moved from -# edex_static to common_static, -# get highest version of files -# Dec 12, 2016 DR 19612 D. Friedman Fix identifier typos -# Dec 14, 2016 DCS19530 jdynina Added sending of FTM products to RPG -# Feb 06, 2018 6683 njensen Don't return if local send fails -# -# - -## -# This is a base file that is not intended to be overridden. -## - - -import os, os.path, sys, subprocess, errno -import logging, UFStatusHandler - -_Logger = logging.getLogger("HandleOUP") -_Logger.addHandler(UFStatusHandler.UFStatusHandler("com.raytheon.uf.edex.dissemination", "HandleOUP", level=logging.INFO)) -_Logger.setLevel(logging.INFO) - -DB_SUCCESS = 0 -DB_FAILURE = 1 -DB_TIMEOUT = 2 -DB_DUPLICATE = 4 - -ACTION_CODES = {} -from com.raytheon.uf.common.localization import PathManagerFactory -from com.raytheon.uf.common.localization import LocalizationContext -LocalizationType = LocalizationContext.LocalizationType -LocalizationLevel = LocalizationContext.LocalizationLevel -DISSEMINATION_DIR = 'dissemination/' -pathMgr = PathManagerFactory.getPathManager() -path = pathMgr.getStaticFile(DISSEMINATION_DIR + 'rcv_action2codes.txt').getPath() -f = open(path) -for line in f: - codeSplit = line.split() - ACTION_CODES[codeSplit[0]] = codeSplit[1] -f.close() - -from com.raytheon.uf.edex.core import EDEXUtil -dataDir = EDEXUtil.getEdexData() -OUT_DIR = dataDir + 'outgoing' -if not os.path.isdir(OUT_DIR): - os.mkdir(OUT_DIR) -INGEST_DIR = dataDir + 'manual' -INGEST_ROUTE = 'handleoupFilePush' -SITE_ID = EDEXUtil.getEdexSite() - -def process(oup, afosID, resp, ackMgr=None, test=False): - _Logger.info("handleOUP.py received " + str(oup.getFilename())) - wmoTypeString = "" - userDateTimeStamp = "" - msg = '' - - # WMO message type, aka bbb - if oup.getWmoType(): - wmoTypeString = oup.getWmoType().upper() - - # address - address = oup.getAddress() - if address == 'DEF' or address == 'ALL': - address = 'DEFAULTNCF,NWWSUP' - elif address is None: - address = 'DEFAULTNCF,NWWSUP' - - # source, possibly None - source = oup.getSource() - - # time stamp DDHHMM - if oup.getUserDateTimeStamp(): - userDateTimeStamp = oup.getUserDateTimeStamp().upper() - if len(userDateTimeStamp) != 6: - msg = "Error: User date time stamp is wrong length\n" - _Logger.error("User date time stamp is wrong length") - resp.setMessage(msg) - return - - #---------- - # Initialize the product identifier - #---------- - awipsWanPil = oup.getAwipsWanPil() - _Logger.debug('awipsWanPil = ' + awipsWanPil) - - #---------- - # Extract the category ( NNN of CCCCNNNXXX ) from the awips ID - #---------- - prodCategory = getCategory(awipsWanPil) - _Logger.debug("Product Category = " + prodCategory) - - #---------- - # Determine the transmission priority for WAN distribution - #---------- - priority = getPriority(prodCategory) - oup.setPriority(priority) - _Logger.debug('Priority = ' + str(priority)) - - #---------- - # Retrieve the contents of the product - #---------- - contents = oup.getProductText() - productId = contents.split('\n')[0].strip() - - #---------- - # Locally store OUP in text database and archive - #---------- - resp.setSendLocalSuccess(True) - awipsPathname = createTargetFile(contents, - OUT_DIR + '/' + oup.getFilename()) - if not awipsPathname: - # must have awipsPathname for any sends - _Logger.debug('Unable to store product to text database:') - storageCompleted = DB_FAILURE - msg = 'Product ' + awipsWanPil + ' failed to be ingested and archived.\n' - _Logger.debug(msg) - resp.setMessage(msg) - resp.setSendLocalSuccess(False) - resp.setSendWANSuccess(False) - return - elif not test: - try: - from com.raytheon.uf.edex.plugin.manualIngest import MessageGenerator - if MessageGenerator.getInstance().sendFileToIngest(awipsPathname, INGEST_ROUTE): - msg = 'Product ' + awipsWanPil + ' successfully ingested and archived locally.\n' - resp.setSendLocalSuccess(True) - _Logger.info(msg) - else: - msg = 'Product ' + awipsWanPil + ' failed to be ingested and archived.\n' - _Logger.error(msg) - resp.setSendLocalSuccess(False) - except Exception as e: - msg = 'Product ' + awipsWanPil + ' failed to be ingested and archived properly. Reason:\n' + str(e) - _Logger.error(msg) - resp.setSendLocalSuccess(False) - - attachedFilename = oup.getAttachedFilename() - attachedFile = oup.getAttachedFile() - if attachedFilename and attachedFile: - # spaces will screw up the command line string - attachedFilename = attachedFilename.replace(" ", "") - # dealing with a java byte[] so write it out with java - from java.io import File, FileOutputStream - attachedFilename = createTargetFile("", OUT_DIR + '/' + attachedFilename) - f = File(attachedFilename) - fos = FileOutputStream(f) - fos.write(attachedFile) - fos.flush() - fos.close() - - if test: - try: - os.remove(awipsPathname) - except EnvironmentError: - pass # ignore - if attachedFilename: - try: - os.remove(attachedFilename) - except EnvironmentError: - pass # ignore - - resp.setSendWANSuccess(True) - return - - messageIdToAcknowledge = None - #---------- - # Check if product should be distributed over WAN via NCF - #---------- - wmoID = contents[0:6] - splitAddr = address.split(',') - for addr in splitAddr: - if addr != '000': # 000 is local only - _Logger.info("Addressee is " + addr) - #---------- - # Check if product should be sent to the NWWS for uplink - #---------- - if (addr.find('NWWSUP') > -1): - if isNWWSProduct(awipsWanPil, afosID, wmoID, SITE_ID): - #---------- - # Send OUP to its designated NWWS primary and backup sites for up-link - #---------- - code = "NWWS_UPLINK" - if source and source == 'TextWS': - code = "42" - sendResult = sendWANMsg(productId, awipsPathname, addr, code, - userDateTimeStamp, priority, wmoTypeString, source, resp, afosID, attachedFilename) - if not sendResult: - # failure of some kind so return - return - else: - _Logger.debug("Product is not an NWWS product. Not sending product " + - 'over NWWS up-link.') - else: - if isLegalWANProduct(awipsWanPil, afosID, wmoID, SITE_ID): - #---------- - # Send OUP to the NCF - #---------- - code = "0" - if addr == "DEFAULTNCF": - code = "134" - if source and source == 'TextWS': - if (prodCategory == 'ADR' or prodCategory == 'ADM' or prodCategory == 'ADA') and \ - attachedFilename: - code = "7" - else: - code = "4" - - if prodCategory == 'FTM': - _Logger.info("Sending FTM to the RPG") - try: - from com.raytheon.edex.rpgenvdata import RadarTextDataManager - ftmReq = RadarTextDataManager(contents) - ftmReq.sendRadarTextDataToRPGs() - ftmReq.close() - except Exception as e: - result = "Error sending product FTM.\n" + str(e) - _Logger.error(result) - ftmReq.close() - - sendResult = sendWANMsg(productId, awipsPathname, addr, code, userDateTimeStamp, - priority, wmoTypeString, source, resp, afosID, attachedFilename) - if not sendResult: - # failure of some kind so return - return - # Copy this now as the values may change in another loop iteration - if resp.getNeedAcknowledgment() and messageIdToAcknowledge is None: - messageIdToAcknowledge = resp.getMessageId() - else: - _Logger.info("Product is not authorized for distribution.") - _Logger.info("Not sending product to NCF.") - msg = "Warning: Product is not authorized for distribution.\n" - resp.setMessage(msg) - return - - if messageIdToAcknowledge: - resp.setNeedAcknowledgment(True) - resp.setMessageId(messageIdToAcknowledge) - if ackMgr != None: - _Logger.info("Waiting for acknowledgment of " + messageIdToAcknowledge) - ackMgr.waitAck(messageIdToAcknowledge, address, resp, - afosID + " " + userDateTimeStamp) - _Logger.info("Finished waiting for acknowledgment of %s: %s", - messageIdToAcknowledge, - resp.isAcknowledged() and "ACK" or resp.getMessage()) - if not resp.isAcknowledged(): - # Send ITO alarm - ito_err = None - try: - ec = subprocess.call(['/opt/OV/bin/OpC/opcmsg', 'application=MHS', 'object=MHS', - 'msg_text=%s (msgid %s)' % (resp.getMessage(), messageIdToAcknowledge), - 'severity=Critical', 'msg_grp=AWIPS']) - if ec != 0: - ito_err = 'exit code = ' + str(ec) - except: - ito_err = str(sys.exc_info()[1]) - if ito_err is not None: - _Logger.error("Error sending ITO alarm: " + ito_err) - else: - _Logger.error("Acknowledgment requirement, but ackMgr is None") - - _Logger.debug('Script done....') - return - - -#---getCategory()--------------------------------------------------------------# -# -# Purpose: -# Determines the product category from the AWIPS identifier. -# -# Parameters: -# AWIPS product identifier (CCCCNNNXXX) -# -# Returns: -# 3-letter product category (NNN of CCCCNNNXXX) -# -# Implementation: -# -#------------------------------------------------------------------------------# -def getCategory(awipsID): - _Logger.debug("getCategory():") - return awipsID[4:7] - - -#---getPriority()--------------------------------------------------------------# -# -# Purpose: -# Returns the priority level of the product based on its category. -# -# Parameters: -# 3 letter product category (NNN) -# -# Returns: -# Priority level [0,1,2] where 2 = highest -# -# Implementation: -# Searches awipsPriorities.txt using the product category as the key. -# If the file does not contain the specified category entry, the lowest -# priority level is assumed. -# Exits program if file cannot be opened. -# -#------------------------------------------------------------------------------# -def getPriority(nnn): - _Logger.debug('getPriority():') - - priority = "0" - path = pathMgr.getStaticFile(DISSEMINATION_DIR + 'awipsPriorities.txt').getPath() - pfile = open(path, 'r') - for line in pfile: - if nnn == line[0:3]: - _Logger.debug(line) - priority = line[4:].strip() - break - pfile.close() - - priority = int(priority) - return priority - -#---isLegalWANProduct()------------------------------------------------------# -# -# Purpose: -# Determines whether the product is a valid NWWS product. -# -# Parameters: -# AWIPS identifier (CCCCNNNXXX) -# AFOS identifier (CCCNNNXXX) -# WMO identifier (TTAAII) -# -# Returns: -# 1 (TRUE)/ 0 (FALSE) -# -# Implementation: -# Reads the site-specific WAN exclusionary list which contains a -# list of product ids representing products which are not meant for -# distribution over WAN via NCF. The AWIPS id, the AFOS id, -# and the WMO id, are acceptable representations of the product id. -# -# If the exclusionary file either does not exist, is empty, or cannot -# be read, then the product will be distributed. -# -# Program exits if the site id environment variable (FXA_LOCAL_SITE) -# is undefined. -# -#------------------------------------------------------------------------------# -def isLegalWANProduct(myAwipsId, myAfosId, myWmoId, siteID): - _Logger.debug('isLegalWANProduct():') - - # Read the WAN exclusionary file - fileName = 'WAN_exclude_' + siteID + '.txt' - locFile = pathMgr.getStaticFile(DISSEMINATION_DIR + fileName) - filePath = None - if locFile is not None: - filePath = locFile.getPath() - if filePath is not None and os.path.isfile(filePath): - wanExcludeFile = open(filePath, 'r') - for line in wanExcludeFile: - if not line.startswith('#'): - productId = line.strip() - if productId == myAwipsId or productId == myAfosId or productId == myWmoId: - _Logger.info('Product found in WAN exclude list as ' + productId) - wanExcludeFile.close() - return False - # Otherwise, product did not appear on the exclude list and therefore, - # product is meant for distribution - _Logger.info(myAwipsId + ' is a legal WAN product.') - wanExcludeFile.close() - return True - else: - _Logger.info(fileName + ' does not exist or is empty. Sending ' + - 'product over WAN.') - return True - - -#---sendWANMsg()---------------------------------------------------------------# -# -# Purpose: -# Distributes an OUP to a specified receiving site over the WAN. -# -# Parameters: -# receiving site -# handling action to take on product at the receiving site -# additional option string -# -# Returns: -# 1 (TRUE) = successful message submission -# 0 (FALSE) = unsuccessful message submission -# -# Implementation: -# Uses system() function to execute the distributeProduct program. -# -#------------------------------------------------------------------------------# -def sendWANMsg(productId, prodPathName, receivingSite, handling, - userDateTimeStamp, priority, wmoTypeString, source, resp, subject=None, attachedFilename=None): - # _Logger.debug('sendWANMsg():') - _Logger.info('sendWANMsg ' + str(prodPathName) + ' addr=' + str(receivingSite) + \ - ' code=' + str(handling) + ' source=' + str(source)) - - try: - code = int(handling) - except: - code = int(ACTION_CODES[handling]) - - # set acknowledgment from receiver if message is high priority and is from TextWS - from com.raytheon.messaging.mhs import MhsMessage, MhsMessagePriority, MhsSubmitException - mhsMsg = MhsMessage(code) - - if subject: - mhsMsg.setSubject(subject) - - if attachedFilename: - mhsMsg.addEnclosure(attachedFilename) - - #mhsMsg.setBodyFile(prodPathName) - mhsMsg.addEnclosure(prodPathName) - if priority == 0: - jpriority = MhsMessagePriority.Default - elif priority == 1: - jpriority = MhsMessagePriority.Medium - elif priority == 2: - jpriority = MhsMessagePriority.High - mhsMsg.setPriority(jpriority) - - if priority == 2 and source == "TextWS": - resp.setNeedAcknowledgment(True) - mhsMsg.addAckAddressee(receivingSite) - mhsMsg.setTimeoutTime(300) - else: - # No need to get acknowledgment from receiver - resp.setNeedAcknowledgment(False) - mhsMsg.addAddressee(receivingSite) - - _Logger.info("Calling mhsMsg.send()") - result = mhsMsg.send() - - if not result: - result = "Error sending product " + productId + " to " + receivingSite + ". Check server logs for more detail.\n" - _Logger.error(result) - resp.setSendWANSuccess(False) - resp.setMessage(result) - return False - else: - resp.setSendWANSuccess(True) - if resp.getNeedAcknowledgment(): - resp.setMessageId(result) - - _Logger.info("Successful send of " + str(result)) - return True - - -#---isNWWSProduct()------------------------------------------------------------# -# -# Purpose: -# Determines whether the product is a valid NWWS product. -# -# Parameters: -# AWIPS identifier (CCCCNNNXXX) -# AFOS identifier (CCCNNNXXX) -# WMO identifier (TTAAII) -# -# Returns: -# 1 (TRUE)/ 0 (FALSE) -# -# Implementation: -# Reads the site-specific NWWS exclusionary list which contains a -# list of product ids representing products which are not meant for -# distribution over the NWWS up-link. The AWIPS id, the AFOS id, -# and the WMO id, are acceptable representations of the product id. -# -# If the exclusionary file either does not exist, is empty, or cannot -# be read, then the product will be uplink. -# -# Program exits if the site id environment variable (FXA_LOCAL_SITE) -# is undefined. -# -# This module addresses DR 5191. -# -#------------------------------------------------------------------------------# -def isNWWSProduct(myAwipsId, myAfosId, myWmoId, siteID): - _Logger.debug('isNWWSProduct():\n') - - # Read the NWWS exclusionary file - fileName = 'NWWS_exclude_' + siteID + '.txt' - locFile = pathMgr.getStaticFile(DISSEMINATION_DIR + fileName) - filePath = None - if locFile is not None: - filePath = locFile.getPath() - if filePath is not None and os.path.isfile(filePath): - nwwsExcludeFile = open(filePath, 'r') - for line in nwwsExcludeFile: - # If entry is found, then product should not be distributed - # over the NWWS uplink - if not line.startswith('#'): # skips comment lines - productId = line.strip() - if productId == myAwipsId or productId == myAfosId or productId == myWmoId: - _Logger.info('Product found in NWWS exclude list as ' + productId) - nwwsExcludeFile.close() - return False - # Otherwise, product did not appear on the exclude list and therefore, - # product is meant for distribution - _Logger.info(myAwipsId + ' is an NWWS product.') - nwwsExcludeFile.close() - return True - else: - _Logger.info(fileName + ' does not exist or is empty. Sending ' + - 'product over NWWS uplink.') - return True - - - - -#---createTargetFile()---------------------------------------------------------# -# -# Purpose: -# Creates a product file in the named target directory with a selected -# communications header for identification. -# -# Parameters: -# communications header -# product contents -# target product pathname (Output) -# -# Returns: -# The output path (which may differ from targetPathname) -# -# Implementation: -# -#------------------------------------------------------------------------------# -def createTargetFile(fileData, targetPathname): - _Logger.debug('createTargetFile():') - _Logger.debug('target product pathname = ' + targetPathname) - - pathToUse = targetPathname - i = 0 - while True: - try: - fd = os.open(pathToUse, os.O_WRONLY | os.O_CREAT | os.O_EXCL, 0o666) - except OSError as e: - if e.errno == errno.EEXIST: - i += 1 - pathToUse = targetPathname + '.' + str(i) - continue - raise e - else: - break - - if i > 0: - _Logger.info('Renamed target file to ' + pathToUse) - - outFile = os.fdopen(fd, 'w') - outFile.write(fileData) - outFile.flush() - outFile.close() - return pathToUse - diff --git a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/rcv_action2codes.txt b/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/rcv_action2codes.txt deleted file mode 100644 index 90bf10ba9d..0000000000 --- a/edexOsgi/com.raytheon.uf.edex.dissemination/utility/common_static/base/dissemination/rcv_action2codes.txt +++ /dev/null @@ -1,10 +0,0 @@ -TEST_ECHO 128 -AFOS_STORE_TEXTDB 129 -AWIPS_STORE_TEXTDB 130 -NWWS_UPLINK 131 -RIVPROD_CRS 132 -SHEFPRODUCT 133 -INTERSITE_STORE 134 -HYDRO_MODEL_DATA 135 -RIVPROD_BACKUP 136 -RADAR_PRECIP_BIAS 137